@prisma/client-engine-runtime 6.9.0-dev.16 → 6.9.0-dev.18

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
@@ -24,6 +24,13 @@ export declare type DataRule = {
24
24
  type: 'never';
25
25
  };
26
26
 
27
+ /**
28
+ * Checks if two objects representing the names and values of key columns match. A match is
29
+ * defined by one of the sets of keys being a subset of the other. This function also
30
+ * converts arguments to the types used by driver adapters if necessary.
31
+ */
32
+ export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
33
+
27
34
  declare type ExtendedSpanOptions = SpanOptions & {
28
35
  name: string;
29
36
  };
package/dist/index.d.ts CHANGED
@@ -24,6 +24,13 @@ export declare type DataRule = {
24
24
  type: 'never';
25
25
  };
26
26
 
27
+ /**
28
+ * Checks if two objects representing the names and values of key columns match. A match is
29
+ * defined by one of the sets of keys being a subset of the other. This function also
30
+ * converts arguments to the types used by driver adapters if necessary.
31
+ */
32
+ export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
33
+
27
34
  declare type ExtendedSpanOptions = SpanOptions & {
28
35
  name: string;
29
36
  };
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  TransactionManager: () => TransactionManager,
36
36
  TransactionManagerError: () => TransactionManagerError,
37
37
  UserFacingError: () => UserFacingError,
38
+ doKeysMatch: () => doKeysMatch,
38
39
  isDeepStrictEqual: () => isDeepStrictEqual,
39
40
  isPrismaValueBigInt: () => isPrismaValueBigInt,
40
41
  isPrismaValueBytes: () => isPrismaValueBytes,
@@ -45,15 +46,35 @@ __export(index_exports, {
45
46
  module.exports = __toCommonJS(index_exports);
46
47
 
47
48
  // src/interpreter/DataMapper.ts
48
- var import_decimal = __toESM(require("decimal.js"));
49
+ var import_decimal2 = __toESM(require("decimal.js"));
49
50
 
50
51
  // src/utils.ts
52
+ var import_decimal = __toESM(require("decimal.js"));
51
53
  function assertNever(_, message) {
52
54
  throw new Error(message);
53
55
  }
54
56
  function isDeepStrictEqual(a, b) {
55
57
  return a === b || a !== null && b !== null && typeof a === "object" && typeof b === "object" && Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((key) => isDeepStrictEqual(a[key], b[key]));
56
58
  }
59
+ function doKeysMatch(lhs, rhs) {
60
+ const lhsKeys = Object.keys(lhs);
61
+ const rhsKeys = Object.keys(rhs);
62
+ const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
63
+ return smallerKeyList.every((key) => {
64
+ if (typeof lhs[key] !== typeof rhs[key]) {
65
+ if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
66
+ return `${lhs[key]}` === `${rhs[key]}`;
67
+ } else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
68
+ return BigInt(`${lhs[key]}`) === BigInt(`${rhs[key]}`);
69
+ } else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
70
+ return (/* @__PURE__ */ new Date(`${lhs[key]}`)).getTime() === (/* @__PURE__ */ new Date(`${rhs[key]}`)).getTime();
71
+ } else if (import_decimal.default.isDecimal(lhs[key]) || import_decimal.default.isDecimal(rhs[key])) {
72
+ return new import_decimal.default(`${lhs[key]}`).equals(new import_decimal.default(`${rhs[key]}`));
73
+ }
74
+ }
75
+ return isDeepStrictEqual(lhs[key], rhs[key]);
76
+ });
77
+ }
57
78
 
58
79
  // src/interpreter/DataMapper.ts
59
80
  var DataMapperError = class extends Error {
@@ -143,7 +164,7 @@ function mapValue(value, resultType) {
143
164
  case "Boolean":
144
165
  return typeof value === "boolean" ? value : value !== "0";
145
166
  case "Decimal":
146
- return typeof value === "number" ? new import_decimal.default(value) : new import_decimal.default(`${value}`);
167
+ return typeof value === "number" ? new import_decimal2.default(value) : new import_decimal2.default(`${value}`);
147
168
  case "Date":
148
169
  return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
149
170
  case "Array": {
@@ -954,7 +975,7 @@ function childRecordMatchesParent(childRecord, parentRecord, joinExpr) {
954
975
  return true;
955
976
  }
956
977
  function paginate(list, { cursor, skip, take }) {
957
- const cursorIndex = cursor !== null ? list.findIndex((item) => doesMatchCursor(item, cursor)) : 0;
978
+ const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
958
979
  if (cursorIndex === -1) {
959
980
  return [];
960
981
  }
@@ -965,14 +986,6 @@ function paginate(list, { cursor, skip, take }) {
965
986
  function getRecordKey(record, fields) {
966
987
  return JSON.stringify(fields.map((field) => record[field]));
967
988
  }
968
- function doesMatchCursor(item, cursor) {
969
- return Object.keys(cursor).every((key) => {
970
- if (typeof item[key] !== typeof cursor[key] && (typeof item[key] === "number" || typeof cursor[key] === "number")) {
971
- return `${item[key]}` === `${cursor[key]}`;
972
- }
973
- return isDeepStrictEqual(cursor[key], item[key]);
974
- });
975
- }
976
989
 
977
990
  // src/transactionManager/TransactionManager.ts
978
991
  var import_debug = require("@prisma/debug");
@@ -1002,12 +1015,12 @@ var TransactionNotFoundError = class extends TransactionManagerError {
1002
1015
  };
1003
1016
  var TransactionClosedError = class extends TransactionManagerError {
1004
1017
  constructor(operation) {
1005
- super(`Transaction already closed: A ${operation} cannot be executed on a committed transaction`);
1018
+ super(`Transaction already closed: A ${operation} cannot be executed on a committed transaction.`);
1006
1019
  }
1007
1020
  };
1008
1021
  var TransactionRolledBackError = class extends TransactionManagerError {
1009
1022
  constructor(operation) {
1010
- super(`Transaction already closed: A ${operation} cannot be executed on a transaction that was rolled back`);
1023
+ super(`Transaction already closed: A ${operation} cannot be executed on a transaction that was rolled back.`);
1011
1024
  }
1012
1025
  };
1013
1026
  var TransactionStartTimeoutError = class extends TransactionManagerError {
@@ -1195,6 +1208,7 @@ var TransactionManager = class {
1195
1208
  TransactionManager,
1196
1209
  TransactionManagerError,
1197
1210
  UserFacingError,
1211
+ doKeysMatch,
1198
1212
  isDeepStrictEqual,
1199
1213
  isPrismaValueBigInt,
1200
1214
  isPrismaValueBytes,
package/dist/index.mjs CHANGED
@@ -1,13 +1,33 @@
1
1
  // src/interpreter/DataMapper.ts
2
- import Decimal from "decimal.js";
2
+ import Decimal2 from "decimal.js";
3
3
 
4
4
  // src/utils.ts
5
+ import Decimal from "decimal.js";
5
6
  function assertNever(_, message) {
6
7
  throw new Error(message);
7
8
  }
8
9
  function isDeepStrictEqual(a, b) {
9
10
  return a === b || a !== null && b !== null && typeof a === "object" && typeof b === "object" && Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((key) => isDeepStrictEqual(a[key], b[key]));
10
11
  }
12
+ function doKeysMatch(lhs, rhs) {
13
+ const lhsKeys = Object.keys(lhs);
14
+ const rhsKeys = Object.keys(rhs);
15
+ const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
16
+ return smallerKeyList.every((key) => {
17
+ if (typeof lhs[key] !== typeof rhs[key]) {
18
+ if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
19
+ return `${lhs[key]}` === `${rhs[key]}`;
20
+ } else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
21
+ return BigInt(`${lhs[key]}`) === BigInt(`${rhs[key]}`);
22
+ } else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
23
+ return (/* @__PURE__ */ new Date(`${lhs[key]}`)).getTime() === (/* @__PURE__ */ new Date(`${rhs[key]}`)).getTime();
24
+ } else if (Decimal.isDecimal(lhs[key]) || Decimal.isDecimal(rhs[key])) {
25
+ return new Decimal(`${lhs[key]}`).equals(new Decimal(`${rhs[key]}`));
26
+ }
27
+ }
28
+ return isDeepStrictEqual(lhs[key], rhs[key]);
29
+ });
30
+ }
11
31
 
12
32
  // src/interpreter/DataMapper.ts
13
33
  var DataMapperError = class extends Error {
@@ -97,7 +117,7 @@ function mapValue(value, resultType) {
97
117
  case "Boolean":
98
118
  return typeof value === "boolean" ? value : value !== "0";
99
119
  case "Decimal":
100
- return typeof value === "number" ? new Decimal(value) : new Decimal(`${value}`);
120
+ return typeof value === "number" ? new Decimal2(value) : new Decimal2(`${value}`);
101
121
  case "Date":
102
122
  return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
103
123
  case "Array": {
@@ -908,7 +928,7 @@ function childRecordMatchesParent(childRecord, parentRecord, joinExpr) {
908
928
  return true;
909
929
  }
910
930
  function paginate(list, { cursor, skip, take }) {
911
- const cursorIndex = cursor !== null ? list.findIndex((item) => doesMatchCursor(item, cursor)) : 0;
931
+ const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
912
932
  if (cursorIndex === -1) {
913
933
  return [];
914
934
  }
@@ -919,14 +939,6 @@ function paginate(list, { cursor, skip, take }) {
919
939
  function getRecordKey(record, fields) {
920
940
  return JSON.stringify(fields.map((field) => record[field]));
921
941
  }
922
- function doesMatchCursor(item, cursor) {
923
- return Object.keys(cursor).every((key) => {
924
- if (typeof item[key] !== typeof cursor[key] && (typeof item[key] === "number" || typeof cursor[key] === "number")) {
925
- return `${item[key]}` === `${cursor[key]}`;
926
- }
927
- return isDeepStrictEqual(cursor[key], item[key]);
928
- });
929
- }
930
942
 
931
943
  // src/transactionManager/TransactionManager.ts
932
944
  import { Debug } from "@prisma/debug";
@@ -956,12 +968,12 @@ var TransactionNotFoundError = class extends TransactionManagerError {
956
968
  };
957
969
  var TransactionClosedError = class extends TransactionManagerError {
958
970
  constructor(operation) {
959
- super(`Transaction already closed: A ${operation} cannot be executed on a committed transaction`);
971
+ super(`Transaction already closed: A ${operation} cannot be executed on a committed transaction.`);
960
972
  }
961
973
  };
962
974
  var TransactionRolledBackError = class extends TransactionManagerError {
963
975
  constructor(operation) {
964
- super(`Transaction already closed: A ${operation} cannot be executed on a transaction that was rolled back`);
976
+ super(`Transaction already closed: A ${operation} cannot be executed on a transaction that was rolled back.`);
965
977
  }
966
978
  };
967
979
  var TransactionStartTimeoutError = class extends TransactionManagerError {
@@ -1148,6 +1160,7 @@ export {
1148
1160
  TransactionManager,
1149
1161
  TransactionManagerError,
1150
1162
  UserFacingError,
1163
+ doKeysMatch,
1151
1164
  isDeepStrictEqual,
1152
1165
  isPrismaValueBigInt,
1153
1166
  isPrismaValueBytes,
package/dist/utils.d.ts CHANGED
@@ -3,3 +3,9 @@ export declare function assertNever(_: never, message: string): never;
3
3
  * Checks if two objects are deeply equal, recursively checking all properties for strict equality.
4
4
  */
5
5
  export declare function isDeepStrictEqual(a: unknown, b: unknown): boolean;
6
+ /**
7
+ * Checks if two objects representing the names and values of key columns match. A match is
8
+ * defined by one of the sets of keys being a subset of the other. This function also
9
+ * converts arguments to the types used by driver adapters if necessary.
10
+ */
11
+ export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.9.0-dev.16",
3
+ "version": "6.9.0-dev.18",
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.9.0-dev.16",
35
- "@prisma/driver-adapter-utils": "6.9.0-dev.16"
34
+ "@prisma/debug": "6.9.0-dev.18",
35
+ "@prisma/driver-adapter-utils": "6.9.0-dev.18"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",