@prisma/client-engine-runtime 6.12.0-dev.3 → 6.12.0-dev.30
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 +53 -2
- package/dist/index.d.ts +53 -2
- package/dist/index.js +141 -28
- package/dist/index.mjs +140 -28
- package/dist/interpreter/QueryInterpreter.d.ts +4 -1
- package/dist/json-protocol.d.ts +33 -0
- package/dist/schema.d.ts +4 -0
- package/dist/tracing.d.ts +5 -4
- package/dist/transactionManager/TransactionManager.d.ts +3 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,16 @@ import { SqlQueryable } from '@prisma/driver-adapter-utils';
|
|
|
7
7
|
import { SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
8
8
|
import { Transaction } from '@prisma/driver-adapter-utils';
|
|
9
9
|
|
|
10
|
+
export declare type BigIntTaggedValue = {
|
|
11
|
+
$type: 'BigInt';
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export declare type BytesTaggedValue = {
|
|
16
|
+
$type: 'Bytes';
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
export declare class DataMapperError extends Error {
|
|
11
21
|
name: string;
|
|
12
22
|
}
|
|
@@ -24,6 +34,16 @@ export declare type DataRule = {
|
|
|
24
34
|
type: 'never';
|
|
25
35
|
};
|
|
26
36
|
|
|
37
|
+
export declare type DateTaggedValue = {
|
|
38
|
+
$type: 'DateTime';
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare type DecimalTaggedValue = {
|
|
43
|
+
$type: 'Decimal';
|
|
44
|
+
value: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
27
47
|
/**
|
|
28
48
|
* Checks if two objects representing the names and values of key columns match. A match is
|
|
29
49
|
* defined by one of the sets of keys being a subset of the other. This function also
|
|
@@ -31,6 +51,11 @@ export declare type DataRule = {
|
|
|
31
51
|
*/
|
|
32
52
|
export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
|
|
33
53
|
|
|
54
|
+
export declare type EnumTaggedValue = {
|
|
55
|
+
$type: 'Enum';
|
|
56
|
+
value: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
34
59
|
declare type ExtendedSpanOptions = SpanOptions & {
|
|
35
60
|
name: string;
|
|
36
61
|
};
|
|
@@ -59,6 +84,13 @@ export declare type FieldOperation = {
|
|
|
59
84
|
value: PrismaValue;
|
|
60
85
|
};
|
|
61
86
|
|
|
87
|
+
export declare type FieldRefTaggedValue = {
|
|
88
|
+
$type: 'FieldRef';
|
|
89
|
+
value: {
|
|
90
|
+
_ref: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
62
94
|
export declare type Fragment = {
|
|
63
95
|
type: 'stringChunk';
|
|
64
96
|
chunk: string;
|
|
@@ -94,8 +126,19 @@ export declare type JoinExpression = {
|
|
|
94
126
|
isRelationUnique: boolean;
|
|
95
127
|
};
|
|
96
128
|
|
|
129
|
+
export declare type JsonInputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | FieldRefTaggedValue | JsonTaggedValue | EnumTaggedValue;
|
|
130
|
+
|
|
131
|
+
export declare type JsonOutputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | JsonTaggedValue;
|
|
132
|
+
|
|
133
|
+
export declare type JsonTaggedValue = {
|
|
134
|
+
$type: 'Json';
|
|
135
|
+
value: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
97
138
|
export declare const noopTracingHelper: TracingHelper;
|
|
98
139
|
|
|
140
|
+
export declare function normalizeJsonProtocolValues(result: unknown): unknown;
|
|
141
|
+
|
|
99
142
|
export declare type Pagination = {
|
|
100
143
|
cursor: Record<string, PrismaValue> | null;
|
|
101
144
|
take: number | null;
|
|
@@ -175,12 +218,13 @@ export declare type QueryEvent = {
|
|
|
175
218
|
|
|
176
219
|
export declare class QueryInterpreter {
|
|
177
220
|
#private;
|
|
178
|
-
constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, }: QueryInterpreterOptions);
|
|
221
|
+
constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, }: QueryInterpreterOptions);
|
|
179
222
|
static forSql(options: {
|
|
180
223
|
transactionManager: QueryInterpreterTransactionManager;
|
|
181
224
|
placeholderValues: Record<string, unknown>;
|
|
182
225
|
onQuery?: (event: QueryEvent) => void;
|
|
183
226
|
tracingHelper: TracingHelper;
|
|
227
|
+
provider?: SchemaProvider;
|
|
184
228
|
}): QueryInterpreter;
|
|
185
229
|
run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
|
|
186
230
|
private interpretNode;
|
|
@@ -193,6 +237,7 @@ export declare type QueryInterpreterOptions = {
|
|
|
193
237
|
tracingHelper: TracingHelper;
|
|
194
238
|
serializer: (results: SqlResultSet) => Value;
|
|
195
239
|
rawSerializer?: (results: SqlResultSet) => Value;
|
|
240
|
+
provider?: SchemaProvider;
|
|
196
241
|
};
|
|
197
242
|
|
|
198
243
|
export declare type QueryInterpreterTransactionManager = {
|
|
@@ -349,6 +394,11 @@ export declare type ResultNode = {
|
|
|
349
394
|
*/
|
|
350
395
|
export declare function safeJsonStringify(obj: unknown): string;
|
|
351
396
|
|
|
397
|
+
/**
|
|
398
|
+
* `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
|
|
399
|
+
*/
|
|
400
|
+
export declare type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
|
|
401
|
+
|
|
352
402
|
declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
|
353
403
|
|
|
354
404
|
export declare interface TracingHelper {
|
|
@@ -366,11 +416,12 @@ export declare class TransactionManager {
|
|
|
366
416
|
private readonly driverAdapter;
|
|
367
417
|
private readonly transactionOptions;
|
|
368
418
|
private readonly tracingHelper;
|
|
369
|
-
constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, }: {
|
|
419
|
+
constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, provider, }: {
|
|
370
420
|
driverAdapter: SqlDriverAdapter;
|
|
371
421
|
transactionOptions: TransactionOptions;
|
|
372
422
|
tracingHelper: TracingHelper;
|
|
373
423
|
onQuery?: (event: QueryEvent) => void;
|
|
424
|
+
provider?: SchemaProvider;
|
|
374
425
|
});
|
|
375
426
|
startTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
|
|
376
427
|
commitTransaction(transactionId: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ import { SqlQueryable } from '@prisma/driver-adapter-utils';
|
|
|
7
7
|
import { SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
8
8
|
import { Transaction } from '@prisma/driver-adapter-utils';
|
|
9
9
|
|
|
10
|
+
export declare type BigIntTaggedValue = {
|
|
11
|
+
$type: 'BigInt';
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export declare type BytesTaggedValue = {
|
|
16
|
+
$type: 'Bytes';
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
export declare class DataMapperError extends Error {
|
|
11
21
|
name: string;
|
|
12
22
|
}
|
|
@@ -24,6 +34,16 @@ export declare type DataRule = {
|
|
|
24
34
|
type: 'never';
|
|
25
35
|
};
|
|
26
36
|
|
|
37
|
+
export declare type DateTaggedValue = {
|
|
38
|
+
$type: 'DateTime';
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare type DecimalTaggedValue = {
|
|
43
|
+
$type: 'Decimal';
|
|
44
|
+
value: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
27
47
|
/**
|
|
28
48
|
* Checks if two objects representing the names and values of key columns match. A match is
|
|
29
49
|
* defined by one of the sets of keys being a subset of the other. This function also
|
|
@@ -31,6 +51,11 @@ export declare type DataRule = {
|
|
|
31
51
|
*/
|
|
32
52
|
export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
|
|
33
53
|
|
|
54
|
+
export declare type EnumTaggedValue = {
|
|
55
|
+
$type: 'Enum';
|
|
56
|
+
value: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
34
59
|
declare type ExtendedSpanOptions = SpanOptions & {
|
|
35
60
|
name: string;
|
|
36
61
|
};
|
|
@@ -59,6 +84,13 @@ export declare type FieldOperation = {
|
|
|
59
84
|
value: PrismaValue;
|
|
60
85
|
};
|
|
61
86
|
|
|
87
|
+
export declare type FieldRefTaggedValue = {
|
|
88
|
+
$type: 'FieldRef';
|
|
89
|
+
value: {
|
|
90
|
+
_ref: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
62
94
|
export declare type Fragment = {
|
|
63
95
|
type: 'stringChunk';
|
|
64
96
|
chunk: string;
|
|
@@ -94,8 +126,19 @@ export declare type JoinExpression = {
|
|
|
94
126
|
isRelationUnique: boolean;
|
|
95
127
|
};
|
|
96
128
|
|
|
129
|
+
export declare type JsonInputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | FieldRefTaggedValue | JsonTaggedValue | EnumTaggedValue;
|
|
130
|
+
|
|
131
|
+
export declare type JsonOutputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | JsonTaggedValue;
|
|
132
|
+
|
|
133
|
+
export declare type JsonTaggedValue = {
|
|
134
|
+
$type: 'Json';
|
|
135
|
+
value: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
97
138
|
export declare const noopTracingHelper: TracingHelper;
|
|
98
139
|
|
|
140
|
+
export declare function normalizeJsonProtocolValues(result: unknown): unknown;
|
|
141
|
+
|
|
99
142
|
export declare type Pagination = {
|
|
100
143
|
cursor: Record<string, PrismaValue> | null;
|
|
101
144
|
take: number | null;
|
|
@@ -175,12 +218,13 @@ export declare type QueryEvent = {
|
|
|
175
218
|
|
|
176
219
|
export declare class QueryInterpreter {
|
|
177
220
|
#private;
|
|
178
|
-
constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, }: QueryInterpreterOptions);
|
|
221
|
+
constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, }: QueryInterpreterOptions);
|
|
179
222
|
static forSql(options: {
|
|
180
223
|
transactionManager: QueryInterpreterTransactionManager;
|
|
181
224
|
placeholderValues: Record<string, unknown>;
|
|
182
225
|
onQuery?: (event: QueryEvent) => void;
|
|
183
226
|
tracingHelper: TracingHelper;
|
|
227
|
+
provider?: SchemaProvider;
|
|
184
228
|
}): QueryInterpreter;
|
|
185
229
|
run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
|
|
186
230
|
private interpretNode;
|
|
@@ -193,6 +237,7 @@ export declare type QueryInterpreterOptions = {
|
|
|
193
237
|
tracingHelper: TracingHelper;
|
|
194
238
|
serializer: (results: SqlResultSet) => Value;
|
|
195
239
|
rawSerializer?: (results: SqlResultSet) => Value;
|
|
240
|
+
provider?: SchemaProvider;
|
|
196
241
|
};
|
|
197
242
|
|
|
198
243
|
export declare type QueryInterpreterTransactionManager = {
|
|
@@ -349,6 +394,11 @@ export declare type ResultNode = {
|
|
|
349
394
|
*/
|
|
350
395
|
export declare function safeJsonStringify(obj: unknown): string;
|
|
351
396
|
|
|
397
|
+
/**
|
|
398
|
+
* `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
|
|
399
|
+
*/
|
|
400
|
+
export declare type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
|
|
401
|
+
|
|
352
402
|
declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
|
353
403
|
|
|
354
404
|
export declare interface TracingHelper {
|
|
@@ -366,11 +416,12 @@ export declare class TransactionManager {
|
|
|
366
416
|
private readonly driverAdapter;
|
|
367
417
|
private readonly transactionOptions;
|
|
368
418
|
private readonly tracingHelper;
|
|
369
|
-
constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, }: {
|
|
419
|
+
constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, provider, }: {
|
|
370
420
|
driverAdapter: SqlDriverAdapter;
|
|
371
421
|
transactionOptions: TransactionOptions;
|
|
372
422
|
tracingHelper: TracingHelper;
|
|
373
423
|
onQuery?: (event: QueryEvent) => void;
|
|
424
|
+
provider?: SchemaProvider;
|
|
374
425
|
});
|
|
375
426
|
startTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
|
|
376
427
|
commitTransaction(transactionId: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
isPrismaValueGenerator: () => isPrismaValueGenerator,
|
|
43
43
|
isPrismaValuePlaceholder: () => isPrismaValuePlaceholder,
|
|
44
44
|
noopTracingHelper: () => noopTracingHelper,
|
|
45
|
+
normalizeJsonProtocolValues: () => normalizeJsonProtocolValues,
|
|
45
46
|
safeJsonStringify: () => safeJsonStringify
|
|
46
47
|
});
|
|
47
48
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -62,20 +63,74 @@ function doKeysMatch(lhs, rhs) {
|
|
|
62
63
|
const rhsKeys = Object.keys(rhs);
|
|
63
64
|
const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
|
|
64
65
|
return smallerKeyList.every((key) => {
|
|
65
|
-
if (typeof lhs[key]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
|
|
67
|
+
return lhs[key] === rhs[key];
|
|
68
|
+
}
|
|
69
|
+
if (import_decimal.default.isDecimal(lhs[key]) || import_decimal.default.isDecimal(rhs[key])) {
|
|
70
|
+
const lhsDecimal = asDecimal(lhs[key]);
|
|
71
|
+
const rhsDecimal = asDecimal(rhs[key]);
|
|
72
|
+
return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
|
|
73
|
+
} else if (lhs[key] instanceof Uint8Array || rhs[key] instanceof Uint8Array) {
|
|
74
|
+
const lhsBuffer = asBuffer(lhs[key]);
|
|
75
|
+
const rhsBuffer = asBuffer(rhs[key]);
|
|
76
|
+
return lhsBuffer && rhsBuffer && lhsBuffer.equals(rhsBuffer);
|
|
77
|
+
} else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
|
|
78
|
+
return asDate(lhs[key])?.getTime() === asDate(rhs[key])?.getTime();
|
|
79
|
+
} else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
|
|
80
|
+
return asBigInt(lhs[key]) === asBigInt(rhs[key]);
|
|
81
|
+
} else if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
|
|
82
|
+
return asNumber(lhs[key]) === asNumber(rhs[key]);
|
|
75
83
|
}
|
|
76
84
|
return isDeepStrictEqual(lhs[key], rhs[key]);
|
|
77
85
|
});
|
|
78
86
|
}
|
|
87
|
+
function asDecimal(value) {
|
|
88
|
+
if (import_decimal.default.isDecimal(value)) {
|
|
89
|
+
return value;
|
|
90
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
91
|
+
return new import_decimal.default(value);
|
|
92
|
+
} else {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function asBuffer(value) {
|
|
97
|
+
if (Buffer.isBuffer(value)) {
|
|
98
|
+
return value;
|
|
99
|
+
} else if (value instanceof Uint8Array) {
|
|
100
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
101
|
+
} else if (typeof value === "string") {
|
|
102
|
+
return Buffer.from(value, "base64");
|
|
103
|
+
} else {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function asDate(value) {
|
|
108
|
+
if (value instanceof Date) {
|
|
109
|
+
return value;
|
|
110
|
+
} else if (typeof value === "string" || typeof value === "number") {
|
|
111
|
+
return new Date(value);
|
|
112
|
+
} else {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function asBigInt(value) {
|
|
117
|
+
if (typeof value === "bigint") {
|
|
118
|
+
return value;
|
|
119
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
120
|
+
return BigInt(value);
|
|
121
|
+
} else {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function asNumber(value) {
|
|
126
|
+
if (typeof value === "number") {
|
|
127
|
+
return value;
|
|
128
|
+
} else if (typeof value === "string") {
|
|
129
|
+
return Number(value);
|
|
130
|
+
} else {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
79
134
|
function safeJsonStringify(obj) {
|
|
80
135
|
return JSON.stringify(obj, (_key, val) => {
|
|
81
136
|
if (typeof val === "bigint") {
|
|
@@ -314,22 +369,25 @@ var noopTracingHelper = {
|
|
|
314
369
|
};
|
|
315
370
|
function providerToOtelSystem(provider) {
|
|
316
371
|
switch (provider) {
|
|
372
|
+
case "postgresql":
|
|
317
373
|
case "postgres":
|
|
374
|
+
case "prisma+postgres":
|
|
318
375
|
return "postgresql";
|
|
319
|
-
case "mysql":
|
|
320
|
-
return "mysql";
|
|
321
|
-
case "sqlite":
|
|
322
|
-
return "sqlite";
|
|
323
376
|
case "sqlserver":
|
|
324
377
|
return "mssql";
|
|
378
|
+
case "mysql":
|
|
379
|
+
case "sqlite":
|
|
380
|
+
case "cockroachdb":
|
|
381
|
+
case "mongodb":
|
|
382
|
+
return provider;
|
|
325
383
|
default:
|
|
326
384
|
assertNever(provider, `Unknown provider: ${provider}`);
|
|
327
385
|
}
|
|
328
386
|
}
|
|
329
387
|
async function withQuerySpanAndEvent({
|
|
330
388
|
query,
|
|
331
|
-
queryable,
|
|
332
389
|
tracingHelper,
|
|
390
|
+
provider,
|
|
333
391
|
onQuery,
|
|
334
392
|
execute
|
|
335
393
|
}) {
|
|
@@ -339,7 +397,7 @@ async function withQuerySpanAndEvent({
|
|
|
339
397
|
kind: import_api.SpanKind.CLIENT,
|
|
340
398
|
attributes: {
|
|
341
399
|
"db.query.text": query.sql,
|
|
342
|
-
"db.system.name": providerToOtelSystem(
|
|
400
|
+
"db.system.name": providerToOtelSystem(provider)
|
|
343
401
|
}
|
|
344
402
|
},
|
|
345
403
|
async () => {
|
|
@@ -977,13 +1035,15 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
977
1035
|
#tracingHelper;
|
|
978
1036
|
#serializer;
|
|
979
1037
|
#rawSerializer;
|
|
1038
|
+
#provider;
|
|
980
1039
|
constructor({
|
|
981
1040
|
transactionManager,
|
|
982
1041
|
placeholderValues,
|
|
983
1042
|
onQuery,
|
|
984
1043
|
tracingHelper,
|
|
985
1044
|
serializer,
|
|
986
|
-
rawSerializer
|
|
1045
|
+
rawSerializer,
|
|
1046
|
+
provider
|
|
987
1047
|
}) {
|
|
988
1048
|
this.#transactionManager = transactionManager;
|
|
989
1049
|
this.#placeholderValues = placeholderValues;
|
|
@@ -991,6 +1051,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
991
1051
|
this.#tracingHelper = tracingHelper;
|
|
992
1052
|
this.#serializer = serializer;
|
|
993
1053
|
this.#rawSerializer = rawSerializer ?? serializer;
|
|
1054
|
+
this.#provider = provider;
|
|
994
1055
|
}
|
|
995
1056
|
static forSql(options) {
|
|
996
1057
|
return new _QueryInterpreter({
|
|
@@ -999,7 +1060,8 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
999
1060
|
onQuery: options.onQuery,
|
|
1000
1061
|
tracingHelper: options.tracingHelper,
|
|
1001
1062
|
serializer: serializeSql,
|
|
1002
|
-
rawSerializer: serializeRawSql
|
|
1063
|
+
rawSerializer: serializeRawSql,
|
|
1064
|
+
provider: options.provider
|
|
1003
1065
|
});
|
|
1004
1066
|
}
|
|
1005
1067
|
async run(queryPlan, queryable) {
|
|
@@ -1056,7 +1118,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1056
1118
|
node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
|
|
1057
1119
|
);
|
|
1058
1120
|
return {
|
|
1059
|
-
value: parts.length > 0 ? parts.reduce((acc, part) =>
|
|
1121
|
+
value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
|
|
1060
1122
|
};
|
|
1061
1123
|
}
|
|
1062
1124
|
case "execute": {
|
|
@@ -1214,8 +1276,8 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1214
1276
|
#withQuerySpanAndEvent(query, queryable, execute) {
|
|
1215
1277
|
return withQuerySpanAndEvent({
|
|
1216
1278
|
query,
|
|
1217
|
-
queryable,
|
|
1218
1279
|
execute,
|
|
1280
|
+
provider: this.#provider ?? queryable.provider,
|
|
1219
1281
|
tracingHelper: this.#tracingHelper,
|
|
1220
1282
|
onQuery: this.#onQuery
|
|
1221
1283
|
});
|
|
@@ -1230,7 +1292,7 @@ function isEmpty(value) {
|
|
|
1230
1292
|
function asList(value) {
|
|
1231
1293
|
return Array.isArray(value) ? value : [value];
|
|
1232
1294
|
}
|
|
1233
|
-
function
|
|
1295
|
+
function asNumber2(value) {
|
|
1234
1296
|
if (typeof value === "number") {
|
|
1235
1297
|
return value;
|
|
1236
1298
|
}
|
|
@@ -1315,14 +1377,14 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1315
1377
|
case "set":
|
|
1316
1378
|
return evaluateParam(op.value, scope, generators);
|
|
1317
1379
|
case "add":
|
|
1318
|
-
return
|
|
1380
|
+
return asNumber2(value) + asNumber2(evaluateParam(op.value, scope, generators));
|
|
1319
1381
|
case "subtract":
|
|
1320
|
-
return
|
|
1382
|
+
return asNumber2(value) - asNumber2(evaluateParam(op.value, scope, generators));
|
|
1321
1383
|
case "multiply":
|
|
1322
|
-
return
|
|
1384
|
+
return asNumber2(value) * asNumber2(evaluateParam(op.value, scope, generators));
|
|
1323
1385
|
case "divide": {
|
|
1324
|
-
const lhs =
|
|
1325
|
-
const rhs =
|
|
1386
|
+
const lhs = asNumber2(value);
|
|
1387
|
+
const rhs = asNumber2(evaluateParam(op.value, scope, generators));
|
|
1326
1388
|
if (rhs === 0) {
|
|
1327
1389
|
return null;
|
|
1328
1390
|
}
|
|
@@ -1333,6 +1395,53 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1333
1395
|
}
|
|
1334
1396
|
}
|
|
1335
1397
|
|
|
1398
|
+
// src/json-protocol.ts
|
|
1399
|
+
var import_decimal3 = require("decimal.js");
|
|
1400
|
+
function normalizeJsonProtocolValues(result) {
|
|
1401
|
+
if (result === null) {
|
|
1402
|
+
return result;
|
|
1403
|
+
}
|
|
1404
|
+
if (Array.isArray(result)) {
|
|
1405
|
+
return result.map(normalizeJsonProtocolValues);
|
|
1406
|
+
}
|
|
1407
|
+
if (typeof result === "object") {
|
|
1408
|
+
if (isTaggedValue(result)) {
|
|
1409
|
+
return normalizeTaggedValue(result);
|
|
1410
|
+
}
|
|
1411
|
+
if (result.constructor !== null && result.constructor.name !== "Object") {
|
|
1412
|
+
return result;
|
|
1413
|
+
}
|
|
1414
|
+
return mapObjectValues(result, normalizeJsonProtocolValues);
|
|
1415
|
+
}
|
|
1416
|
+
return result;
|
|
1417
|
+
}
|
|
1418
|
+
function isTaggedValue(value) {
|
|
1419
|
+
return value !== null && typeof value == "object" && typeof value["$type"] === "string";
|
|
1420
|
+
}
|
|
1421
|
+
function normalizeTaggedValue({ $type, value }) {
|
|
1422
|
+
switch ($type) {
|
|
1423
|
+
case "BigInt":
|
|
1424
|
+
return { $type, value: String(value) };
|
|
1425
|
+
case "Bytes":
|
|
1426
|
+
return { $type, value };
|
|
1427
|
+
case "DateTime":
|
|
1428
|
+
return { $type, value: new Date(value).toISOString() };
|
|
1429
|
+
case "Decimal":
|
|
1430
|
+
return { $type, value: String(new import_decimal3.Decimal(value)) };
|
|
1431
|
+
case "Json":
|
|
1432
|
+
return { $type, value: JSON.stringify(JSON.parse(value)) };
|
|
1433
|
+
default:
|
|
1434
|
+
assertNever(value, "Unknown tagged value");
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
function mapObjectValues(object, mapper) {
|
|
1438
|
+
const result = {};
|
|
1439
|
+
for (const key of Object.keys(object)) {
|
|
1440
|
+
result[key] = mapper(object[key], key);
|
|
1441
|
+
}
|
|
1442
|
+
return result;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1336
1445
|
// src/transactionManager/TransactionManager.ts
|
|
1337
1446
|
var import_debug = require("@prisma/debug");
|
|
1338
1447
|
|
|
@@ -1418,16 +1527,19 @@ var TransactionManager = class {
|
|
|
1418
1527
|
transactionOptions;
|
|
1419
1528
|
tracingHelper;
|
|
1420
1529
|
#onQuery;
|
|
1530
|
+
#provider;
|
|
1421
1531
|
constructor({
|
|
1422
1532
|
driverAdapter,
|
|
1423
1533
|
transactionOptions,
|
|
1424
1534
|
tracingHelper,
|
|
1425
|
-
onQuery
|
|
1535
|
+
onQuery,
|
|
1536
|
+
provider
|
|
1426
1537
|
}) {
|
|
1427
1538
|
this.driverAdapter = driverAdapter;
|
|
1428
1539
|
this.transactionOptions = transactionOptions;
|
|
1429
1540
|
this.tracingHelper = tracingHelper;
|
|
1430
1541
|
this.#onQuery = onQuery;
|
|
1542
|
+
this.#provider = provider;
|
|
1431
1543
|
}
|
|
1432
1544
|
async startTransaction(options) {
|
|
1433
1545
|
return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
|
|
@@ -1570,8 +1682,8 @@ var TransactionManager = class {
|
|
|
1570
1682
|
#withQuerySpanAndEvent(query, queryable, execute) {
|
|
1571
1683
|
return withQuerySpanAndEvent({
|
|
1572
1684
|
query,
|
|
1573
|
-
queryable,
|
|
1574
1685
|
execute,
|
|
1686
|
+
provider: this.#provider ?? queryable.provider,
|
|
1575
1687
|
tracingHelper: this.tracingHelper,
|
|
1576
1688
|
onQuery: this.#onQuery
|
|
1577
1689
|
});
|
|
@@ -1591,5 +1703,6 @@ var TransactionManager = class {
|
|
|
1591
1703
|
isPrismaValueGenerator,
|
|
1592
1704
|
isPrismaValuePlaceholder,
|
|
1593
1705
|
noopTracingHelper,
|
|
1706
|
+
normalizeJsonProtocolValues,
|
|
1594
1707
|
safeJsonStringify
|
|
1595
1708
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -14,20 +14,74 @@ function doKeysMatch(lhs, rhs) {
|
|
|
14
14
|
const rhsKeys = Object.keys(rhs);
|
|
15
15
|
const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
|
|
16
16
|
return smallerKeyList.every((key) => {
|
|
17
|
-
if (typeof lhs[key]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
|
|
18
|
+
return lhs[key] === rhs[key];
|
|
19
|
+
}
|
|
20
|
+
if (Decimal.isDecimal(lhs[key]) || Decimal.isDecimal(rhs[key])) {
|
|
21
|
+
const lhsDecimal = asDecimal(lhs[key]);
|
|
22
|
+
const rhsDecimal = asDecimal(rhs[key]);
|
|
23
|
+
return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
|
|
24
|
+
} else if (lhs[key] instanceof Uint8Array || rhs[key] instanceof Uint8Array) {
|
|
25
|
+
const lhsBuffer = asBuffer(lhs[key]);
|
|
26
|
+
const rhsBuffer = asBuffer(rhs[key]);
|
|
27
|
+
return lhsBuffer && rhsBuffer && lhsBuffer.equals(rhsBuffer);
|
|
28
|
+
} else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
|
|
29
|
+
return asDate(lhs[key])?.getTime() === asDate(rhs[key])?.getTime();
|
|
30
|
+
} else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
|
|
31
|
+
return asBigInt(lhs[key]) === asBigInt(rhs[key]);
|
|
32
|
+
} else if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
|
|
33
|
+
return asNumber(lhs[key]) === asNumber(rhs[key]);
|
|
27
34
|
}
|
|
28
35
|
return isDeepStrictEqual(lhs[key], rhs[key]);
|
|
29
36
|
});
|
|
30
37
|
}
|
|
38
|
+
function asDecimal(value) {
|
|
39
|
+
if (Decimal.isDecimal(value)) {
|
|
40
|
+
return value;
|
|
41
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
42
|
+
return new Decimal(value);
|
|
43
|
+
} else {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function asBuffer(value) {
|
|
48
|
+
if (Buffer.isBuffer(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
} else if (value instanceof Uint8Array) {
|
|
51
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
52
|
+
} else if (typeof value === "string") {
|
|
53
|
+
return Buffer.from(value, "base64");
|
|
54
|
+
} else {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function asDate(value) {
|
|
59
|
+
if (value instanceof Date) {
|
|
60
|
+
return value;
|
|
61
|
+
} else if (typeof value === "string" || typeof value === "number") {
|
|
62
|
+
return new Date(value);
|
|
63
|
+
} else {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function asBigInt(value) {
|
|
68
|
+
if (typeof value === "bigint") {
|
|
69
|
+
return value;
|
|
70
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
71
|
+
return BigInt(value);
|
|
72
|
+
} else {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function asNumber(value) {
|
|
77
|
+
if (typeof value === "number") {
|
|
78
|
+
return value;
|
|
79
|
+
} else if (typeof value === "string") {
|
|
80
|
+
return Number(value);
|
|
81
|
+
} else {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
31
85
|
function safeJsonStringify(obj) {
|
|
32
86
|
return JSON.stringify(obj, (_key, val) => {
|
|
33
87
|
if (typeof val === "bigint") {
|
|
@@ -266,22 +320,25 @@ var noopTracingHelper = {
|
|
|
266
320
|
};
|
|
267
321
|
function providerToOtelSystem(provider) {
|
|
268
322
|
switch (provider) {
|
|
323
|
+
case "postgresql":
|
|
269
324
|
case "postgres":
|
|
325
|
+
case "prisma+postgres":
|
|
270
326
|
return "postgresql";
|
|
271
|
-
case "mysql":
|
|
272
|
-
return "mysql";
|
|
273
|
-
case "sqlite":
|
|
274
|
-
return "sqlite";
|
|
275
327
|
case "sqlserver":
|
|
276
328
|
return "mssql";
|
|
329
|
+
case "mysql":
|
|
330
|
+
case "sqlite":
|
|
331
|
+
case "cockroachdb":
|
|
332
|
+
case "mongodb":
|
|
333
|
+
return provider;
|
|
277
334
|
default:
|
|
278
335
|
assertNever(provider, `Unknown provider: ${provider}`);
|
|
279
336
|
}
|
|
280
337
|
}
|
|
281
338
|
async function withQuerySpanAndEvent({
|
|
282
339
|
query,
|
|
283
|
-
queryable,
|
|
284
340
|
tracingHelper,
|
|
341
|
+
provider,
|
|
285
342
|
onQuery,
|
|
286
343
|
execute
|
|
287
344
|
}) {
|
|
@@ -291,7 +348,7 @@ async function withQuerySpanAndEvent({
|
|
|
291
348
|
kind: SpanKind.CLIENT,
|
|
292
349
|
attributes: {
|
|
293
350
|
"db.query.text": query.sql,
|
|
294
|
-
"db.system.name": providerToOtelSystem(
|
|
351
|
+
"db.system.name": providerToOtelSystem(provider)
|
|
295
352
|
}
|
|
296
353
|
},
|
|
297
354
|
async () => {
|
|
@@ -929,13 +986,15 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
929
986
|
#tracingHelper;
|
|
930
987
|
#serializer;
|
|
931
988
|
#rawSerializer;
|
|
989
|
+
#provider;
|
|
932
990
|
constructor({
|
|
933
991
|
transactionManager,
|
|
934
992
|
placeholderValues,
|
|
935
993
|
onQuery,
|
|
936
994
|
tracingHelper,
|
|
937
995
|
serializer,
|
|
938
|
-
rawSerializer
|
|
996
|
+
rawSerializer,
|
|
997
|
+
provider
|
|
939
998
|
}) {
|
|
940
999
|
this.#transactionManager = transactionManager;
|
|
941
1000
|
this.#placeholderValues = placeholderValues;
|
|
@@ -943,6 +1002,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
943
1002
|
this.#tracingHelper = tracingHelper;
|
|
944
1003
|
this.#serializer = serializer;
|
|
945
1004
|
this.#rawSerializer = rawSerializer ?? serializer;
|
|
1005
|
+
this.#provider = provider;
|
|
946
1006
|
}
|
|
947
1007
|
static forSql(options) {
|
|
948
1008
|
return new _QueryInterpreter({
|
|
@@ -951,7 +1011,8 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
951
1011
|
onQuery: options.onQuery,
|
|
952
1012
|
tracingHelper: options.tracingHelper,
|
|
953
1013
|
serializer: serializeSql,
|
|
954
|
-
rawSerializer: serializeRawSql
|
|
1014
|
+
rawSerializer: serializeRawSql,
|
|
1015
|
+
provider: options.provider
|
|
955
1016
|
});
|
|
956
1017
|
}
|
|
957
1018
|
async run(queryPlan, queryable) {
|
|
@@ -1008,7 +1069,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1008
1069
|
node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
|
|
1009
1070
|
);
|
|
1010
1071
|
return {
|
|
1011
|
-
value: parts.length > 0 ? parts.reduce((acc, part) =>
|
|
1072
|
+
value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
|
|
1012
1073
|
};
|
|
1013
1074
|
}
|
|
1014
1075
|
case "execute": {
|
|
@@ -1166,8 +1227,8 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1166
1227
|
#withQuerySpanAndEvent(query, queryable, execute) {
|
|
1167
1228
|
return withQuerySpanAndEvent({
|
|
1168
1229
|
query,
|
|
1169
|
-
queryable,
|
|
1170
1230
|
execute,
|
|
1231
|
+
provider: this.#provider ?? queryable.provider,
|
|
1171
1232
|
tracingHelper: this.#tracingHelper,
|
|
1172
1233
|
onQuery: this.#onQuery
|
|
1173
1234
|
});
|
|
@@ -1182,7 +1243,7 @@ function isEmpty(value) {
|
|
|
1182
1243
|
function asList(value) {
|
|
1183
1244
|
return Array.isArray(value) ? value : [value];
|
|
1184
1245
|
}
|
|
1185
|
-
function
|
|
1246
|
+
function asNumber2(value) {
|
|
1186
1247
|
if (typeof value === "number") {
|
|
1187
1248
|
return value;
|
|
1188
1249
|
}
|
|
@@ -1267,14 +1328,14 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1267
1328
|
case "set":
|
|
1268
1329
|
return evaluateParam(op.value, scope, generators);
|
|
1269
1330
|
case "add":
|
|
1270
|
-
return
|
|
1331
|
+
return asNumber2(value) + asNumber2(evaluateParam(op.value, scope, generators));
|
|
1271
1332
|
case "subtract":
|
|
1272
|
-
return
|
|
1333
|
+
return asNumber2(value) - asNumber2(evaluateParam(op.value, scope, generators));
|
|
1273
1334
|
case "multiply":
|
|
1274
|
-
return
|
|
1335
|
+
return asNumber2(value) * asNumber2(evaluateParam(op.value, scope, generators));
|
|
1275
1336
|
case "divide": {
|
|
1276
|
-
const lhs =
|
|
1277
|
-
const rhs =
|
|
1337
|
+
const lhs = asNumber2(value);
|
|
1338
|
+
const rhs = asNumber2(evaluateParam(op.value, scope, generators));
|
|
1278
1339
|
if (rhs === 0) {
|
|
1279
1340
|
return null;
|
|
1280
1341
|
}
|
|
@@ -1285,6 +1346,53 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1285
1346
|
}
|
|
1286
1347
|
}
|
|
1287
1348
|
|
|
1349
|
+
// src/json-protocol.ts
|
|
1350
|
+
import { Decimal as Decimal3 } from "decimal.js";
|
|
1351
|
+
function normalizeJsonProtocolValues(result) {
|
|
1352
|
+
if (result === null) {
|
|
1353
|
+
return result;
|
|
1354
|
+
}
|
|
1355
|
+
if (Array.isArray(result)) {
|
|
1356
|
+
return result.map(normalizeJsonProtocolValues);
|
|
1357
|
+
}
|
|
1358
|
+
if (typeof result === "object") {
|
|
1359
|
+
if (isTaggedValue(result)) {
|
|
1360
|
+
return normalizeTaggedValue(result);
|
|
1361
|
+
}
|
|
1362
|
+
if (result.constructor !== null && result.constructor.name !== "Object") {
|
|
1363
|
+
return result;
|
|
1364
|
+
}
|
|
1365
|
+
return mapObjectValues(result, normalizeJsonProtocolValues);
|
|
1366
|
+
}
|
|
1367
|
+
return result;
|
|
1368
|
+
}
|
|
1369
|
+
function isTaggedValue(value) {
|
|
1370
|
+
return value !== null && typeof value == "object" && typeof value["$type"] === "string";
|
|
1371
|
+
}
|
|
1372
|
+
function normalizeTaggedValue({ $type, value }) {
|
|
1373
|
+
switch ($type) {
|
|
1374
|
+
case "BigInt":
|
|
1375
|
+
return { $type, value: String(value) };
|
|
1376
|
+
case "Bytes":
|
|
1377
|
+
return { $type, value };
|
|
1378
|
+
case "DateTime":
|
|
1379
|
+
return { $type, value: new Date(value).toISOString() };
|
|
1380
|
+
case "Decimal":
|
|
1381
|
+
return { $type, value: String(new Decimal3(value)) };
|
|
1382
|
+
case "Json":
|
|
1383
|
+
return { $type, value: JSON.stringify(JSON.parse(value)) };
|
|
1384
|
+
default:
|
|
1385
|
+
assertNever(value, "Unknown tagged value");
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
function mapObjectValues(object, mapper) {
|
|
1389
|
+
const result = {};
|
|
1390
|
+
for (const key of Object.keys(object)) {
|
|
1391
|
+
result[key] = mapper(object[key], key);
|
|
1392
|
+
}
|
|
1393
|
+
return result;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1288
1396
|
// src/transactionManager/TransactionManager.ts
|
|
1289
1397
|
import { Debug } from "@prisma/debug";
|
|
1290
1398
|
|
|
@@ -1370,16 +1478,19 @@ var TransactionManager = class {
|
|
|
1370
1478
|
transactionOptions;
|
|
1371
1479
|
tracingHelper;
|
|
1372
1480
|
#onQuery;
|
|
1481
|
+
#provider;
|
|
1373
1482
|
constructor({
|
|
1374
1483
|
driverAdapter,
|
|
1375
1484
|
transactionOptions,
|
|
1376
1485
|
tracingHelper,
|
|
1377
|
-
onQuery
|
|
1486
|
+
onQuery,
|
|
1487
|
+
provider
|
|
1378
1488
|
}) {
|
|
1379
1489
|
this.driverAdapter = driverAdapter;
|
|
1380
1490
|
this.transactionOptions = transactionOptions;
|
|
1381
1491
|
this.tracingHelper = tracingHelper;
|
|
1382
1492
|
this.#onQuery = onQuery;
|
|
1493
|
+
this.#provider = provider;
|
|
1383
1494
|
}
|
|
1384
1495
|
async startTransaction(options) {
|
|
1385
1496
|
return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
|
|
@@ -1522,8 +1633,8 @@ var TransactionManager = class {
|
|
|
1522
1633
|
#withQuerySpanAndEvent(query, queryable, execute) {
|
|
1523
1634
|
return withQuerySpanAndEvent({
|
|
1524
1635
|
query,
|
|
1525
|
-
queryable,
|
|
1526
1636
|
execute,
|
|
1637
|
+
provider: this.#provider ?? queryable.provider,
|
|
1527
1638
|
tracingHelper: this.tracingHelper,
|
|
1528
1639
|
onQuery: this.#onQuery
|
|
1529
1640
|
});
|
|
@@ -1542,5 +1653,6 @@ export {
|
|
|
1542
1653
|
isPrismaValueGenerator,
|
|
1543
1654
|
isPrismaValuePlaceholder,
|
|
1544
1655
|
noopTracingHelper,
|
|
1656
|
+
normalizeJsonProtocolValues,
|
|
1545
1657
|
safeJsonStringify
|
|
1546
1658
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SqlQueryable, SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
2
2
|
import { QueryEvent } from '../events';
|
|
3
3
|
import { QueryPlanNode } from '../QueryPlan';
|
|
4
|
+
import { type SchemaProvider } from '../schema';
|
|
4
5
|
import { type TracingHelper } from '../tracing';
|
|
5
6
|
import { type TransactionManager } from '../transactionManager/TransactionManager';
|
|
6
7
|
import { Value } from './scope';
|
|
@@ -17,15 +18,17 @@ export type QueryInterpreterOptions = {
|
|
|
17
18
|
tracingHelper: TracingHelper;
|
|
18
19
|
serializer: (results: SqlResultSet) => Value;
|
|
19
20
|
rawSerializer?: (results: SqlResultSet) => Value;
|
|
21
|
+
provider?: SchemaProvider;
|
|
20
22
|
};
|
|
21
23
|
export declare class QueryInterpreter {
|
|
22
24
|
#private;
|
|
23
|
-
constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, }: QueryInterpreterOptions);
|
|
25
|
+
constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, }: QueryInterpreterOptions);
|
|
24
26
|
static forSql(options: {
|
|
25
27
|
transactionManager: QueryInterpreterTransactionManager;
|
|
26
28
|
placeholderValues: Record<string, unknown>;
|
|
27
29
|
onQuery?: (event: QueryEvent) => void;
|
|
28
30
|
tracingHelper: TracingHelper;
|
|
31
|
+
provider?: SchemaProvider;
|
|
29
32
|
}): QueryInterpreter;
|
|
30
33
|
run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
|
|
31
34
|
private interpretNode;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type DateTaggedValue = {
|
|
2
|
+
$type: 'DateTime';
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
export type DecimalTaggedValue = {
|
|
6
|
+
$type: 'Decimal';
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
export type BytesTaggedValue = {
|
|
10
|
+
$type: 'Bytes';
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export type BigIntTaggedValue = {
|
|
14
|
+
$type: 'BigInt';
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
export type FieldRefTaggedValue = {
|
|
18
|
+
$type: 'FieldRef';
|
|
19
|
+
value: {
|
|
20
|
+
_ref: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type EnumTaggedValue = {
|
|
24
|
+
$type: 'Enum';
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
export type JsonTaggedValue = {
|
|
28
|
+
$type: 'Json';
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
export type JsonInputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | FieldRefTaggedValue | JsonTaggedValue | EnumTaggedValue;
|
|
32
|
+
export type JsonOutputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | JsonTaggedValue;
|
|
33
|
+
export declare function normalizeJsonProtocolValues(result: unknown): unknown;
|
package/dist/schema.d.ts
ADDED
package/dist/tracing.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Context, type Span, type SpanOptions } from '@opentelemetry/api';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SqlQuery } from '@prisma/driver-adapter-utils';
|
|
3
3
|
import { QueryEvent } from './events';
|
|
4
|
+
import type { SchemaProvider } from './schema';
|
|
4
5
|
export type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
|
5
6
|
export type ExtendedSpanOptions = SpanOptions & {
|
|
6
7
|
name: string;
|
|
@@ -9,11 +10,11 @@ export interface TracingHelper {
|
|
|
9
10
|
runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R;
|
|
10
11
|
}
|
|
11
12
|
export declare const noopTracingHelper: TracingHelper;
|
|
12
|
-
export declare function providerToOtelSystem(provider:
|
|
13
|
-
export declare function withQuerySpanAndEvent<T>({ query,
|
|
13
|
+
export declare function providerToOtelSystem(provider: SchemaProvider): string;
|
|
14
|
+
export declare function withQuerySpanAndEvent<T>({ query, tracingHelper, provider, onQuery, execute, }: {
|
|
14
15
|
query: SqlQuery;
|
|
15
|
-
queryable: SqlQueryable;
|
|
16
16
|
tracingHelper: TracingHelper;
|
|
17
|
+
provider: SchemaProvider;
|
|
17
18
|
onQuery?: (event: QueryEvent) => void;
|
|
18
19
|
execute: () => Promise<T>;
|
|
19
20
|
}): Promise<T>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SqlDriverAdapter, Transaction } from '@prisma/driver-adapter-utils';
|
|
2
2
|
import { QueryEvent } from '../events';
|
|
3
|
+
import type { SchemaProvider } from '../schema';
|
|
3
4
|
import { TracingHelper } from '../tracing';
|
|
4
5
|
import { Options, TransactionInfo } from './Transaction';
|
|
5
6
|
export declare class TransactionManager {
|
|
@@ -9,11 +10,12 @@ export declare class TransactionManager {
|
|
|
9
10
|
private readonly driverAdapter;
|
|
10
11
|
private readonly transactionOptions;
|
|
11
12
|
private readonly tracingHelper;
|
|
12
|
-
constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, }: {
|
|
13
|
+
constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, provider, }: {
|
|
13
14
|
driverAdapter: SqlDriverAdapter;
|
|
14
15
|
transactionOptions: Options;
|
|
15
16
|
tracingHelper: TracingHelper;
|
|
16
17
|
onQuery?: (event: QueryEvent) => void;
|
|
18
|
+
provider?: SchemaProvider;
|
|
17
19
|
});
|
|
18
20
|
startTransaction(options?: Options): Promise<TransactionInfo>;
|
|
19
21
|
commitTransaction(transactionId: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-engine-runtime",
|
|
3
|
-
"version": "6.12.0-dev.
|
|
3
|
+
"version": "6.12.0-dev.30",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"nanoid": "5.1.5",
|
|
32
32
|
"ulid": "3.0.0",
|
|
33
33
|
"uuid": "11.1.0",
|
|
34
|
-
"@prisma/debug": "6.12.0-dev.
|
|
35
|
-
"@prisma/driver-adapter-utils": "6.12.0-dev.
|
|
34
|
+
"@prisma/debug": "6.12.0-dev.30",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.12.0-dev.30"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|