@prisma/client-engine-runtime 6.9.0-dev.15 → 6.9.0-dev.17

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.
@@ -200,6 +200,9 @@ export type DataRule = {
200
200
  } | {
201
201
  type: 'rowCountNeq';
202
202
  args: number;
203
+ } | {
204
+ type: 'affectedRowCountEq';
205
+ args: number;
203
206
  } | {
204
207
  type: 'never';
205
208
  };
@@ -229,6 +232,13 @@ export type ValidationError = {
229
232
  context: {
230
233
  expectedRows: number;
231
234
  };
235
+ } | {
236
+ error_identifier: 'INCOMPLETE_CONNECT_OUTPUT';
237
+ context: {
238
+ expectedRows: number;
239
+ relation: string;
240
+ relationType: string;
241
+ };
232
242
  } | {
233
243
  error_identifier: 'RECORDS_NOT_CONNECTED';
234
244
  context: {
package/dist/index.d.mts CHANGED
@@ -17,10 +17,20 @@ export declare type DataRule = {
17
17
  } | {
18
18
  type: 'rowCountNeq';
19
19
  args: number;
20
+ } | {
21
+ type: 'affectedRowCountEq';
22
+ args: number;
20
23
  } | {
21
24
  type: 'never';
22
25
  };
23
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
+
24
34
  declare type ExtendedSpanOptions = SpanOptions & {
25
35
  name: string;
26
36
  };
@@ -367,6 +377,13 @@ export declare type ValidationError = {
367
377
  context: {
368
378
  expectedRows: number;
369
379
  };
380
+ } | {
381
+ error_identifier: 'INCOMPLETE_CONNECT_OUTPUT';
382
+ context: {
383
+ expectedRows: number;
384
+ relation: string;
385
+ relationType: string;
386
+ };
370
387
  } | {
371
388
  error_identifier: 'RECORDS_NOT_CONNECTED';
372
389
  context: {
package/dist/index.d.ts CHANGED
@@ -17,10 +17,20 @@ export declare type DataRule = {
17
17
  } | {
18
18
  type: 'rowCountNeq';
19
19
  args: number;
20
+ } | {
21
+ type: 'affectedRowCountEq';
22
+ args: number;
20
23
  } | {
21
24
  type: 'never';
22
25
  };
23
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
+
24
34
  declare type ExtendedSpanOptions = SpanOptions & {
25
35
  name: string;
26
36
  };
@@ -367,6 +377,13 @@ export declare type ValidationError = {
367
377
  context: {
368
378
  expectedRows: number;
369
379
  };
380
+ } | {
381
+ error_identifier: 'INCOMPLETE_CONNECT_OUTPUT';
382
+ context: {
383
+ expectedRows: number;
384
+ relation: string;
385
+ relationType: string;
386
+ };
370
387
  } | {
371
388
  error_identifier: 'RECORDS_NOT_CONNECTED';
372
389
  context: {
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": {
@@ -621,6 +642,8 @@ function doesSatisfyRule(data, rule) {
621
642
  return rule.args !== 0;
622
643
  }
623
644
  return rule.args !== 1;
645
+ case "affectedRowCountEq":
646
+ return data === rule.args;
624
647
  case "never":
625
648
  return false;
626
649
  default:
@@ -638,7 +661,9 @@ function renderMessage(data, error) {
638
661
  return `An operation failed because it depends on one or more records that were required but not found. No '${error.context.model}' record${hint} was found for ${error.context.operation} on ${error.context.relationType} relation '${error.context.relation}'.`;
639
662
  }
640
663
  case "INCOMPLETE_CONNECT_INPUT":
641
- return `An operation failed because it depends on one or more records that were required but not found. Expected ${error.context.expectedRows} records to be connected, found only ${Array.isArray(data) ? data.length : 0}.`;
664
+ return `An operation failed because it depends on one or more records that were required but not found. Expected ${error.context.expectedRows} records to be connected, found only ${Array.isArray(data) ? data.length : data}.`;
665
+ case "INCOMPLETE_CONNECT_OUTPUT":
666
+ return `The required connected records were not found. Expected ${error.context.expectedRows} records to be connected after connect operation on ${error.context.relationType} relation '${error.context.relation}', found ${Array.isArray(data) ? data.length : data}.`;
642
667
  case "RECORDS_NOT_CONNECTED":
643
668
  return `The records for relation \`${error.context.relation}\` between the \`${error.context.parent}\` and \`${error.context.child}\` models are not connected.`;
644
669
  default:
@@ -651,6 +676,8 @@ function getErrorCode2(error) {
651
676
  return "P2014";
652
677
  case "RECORDS_NOT_CONNECTED":
653
678
  return "P2017";
679
+ case "INCOMPLETE_CONNECT_OUTPUT":
680
+ return "P2018";
654
681
  case "MISSING_RECORD":
655
682
  case "MISSING_RELATED_RECORD":
656
683
  case "INCOMPLETE_CONNECT_INPUT":
@@ -948,7 +975,7 @@ function childRecordMatchesParent(childRecord, parentRecord, joinExpr) {
948
975
  return true;
949
976
  }
950
977
  function paginate(list, { cursor, skip, take }) {
951
- const cursorIndex = cursor !== null ? list.findIndex((item) => doesMatchCursor(item, cursor)) : 0;
978
+ const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
952
979
  if (cursorIndex === -1) {
953
980
  return [];
954
981
  }
@@ -959,14 +986,6 @@ function paginate(list, { cursor, skip, take }) {
959
986
  function getRecordKey(record, fields) {
960
987
  return JSON.stringify(fields.map((field) => record[field]));
961
988
  }
962
- function doesMatchCursor(item, cursor) {
963
- return Object.keys(cursor).every((key) => {
964
- if (typeof item[key] !== typeof cursor[key] && (typeof item[key] === "number" || typeof cursor[key] === "number")) {
965
- return `${item[key]}` === `${cursor[key]}`;
966
- }
967
- return isDeepStrictEqual(cursor[key], item[key]);
968
- });
969
- }
970
989
 
971
990
  // src/transactionManager/TransactionManager.ts
972
991
  var import_debug = require("@prisma/debug");
@@ -996,12 +1015,12 @@ var TransactionNotFoundError = class extends TransactionManagerError {
996
1015
  };
997
1016
  var TransactionClosedError = class extends TransactionManagerError {
998
1017
  constructor(operation) {
999
- 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.`);
1000
1019
  }
1001
1020
  };
1002
1021
  var TransactionRolledBackError = class extends TransactionManagerError {
1003
1022
  constructor(operation) {
1004
- 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.`);
1005
1024
  }
1006
1025
  };
1007
1026
  var TransactionStartTimeoutError = class extends TransactionManagerError {
@@ -1189,6 +1208,7 @@ var TransactionManager = class {
1189
1208
  TransactionManager,
1190
1209
  TransactionManagerError,
1191
1210
  UserFacingError,
1211
+ doKeysMatch,
1192
1212
  isDeepStrictEqual,
1193
1213
  isPrismaValueBigInt,
1194
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": {
@@ -575,6 +595,8 @@ function doesSatisfyRule(data, rule) {
575
595
  return rule.args !== 0;
576
596
  }
577
597
  return rule.args !== 1;
598
+ case "affectedRowCountEq":
599
+ return data === rule.args;
578
600
  case "never":
579
601
  return false;
580
602
  default:
@@ -592,7 +614,9 @@ function renderMessage(data, error) {
592
614
  return `An operation failed because it depends on one or more records that were required but not found. No '${error.context.model}' record${hint} was found for ${error.context.operation} on ${error.context.relationType} relation '${error.context.relation}'.`;
593
615
  }
594
616
  case "INCOMPLETE_CONNECT_INPUT":
595
- return `An operation failed because it depends on one or more records that were required but not found. Expected ${error.context.expectedRows} records to be connected, found only ${Array.isArray(data) ? data.length : 0}.`;
617
+ return `An operation failed because it depends on one or more records that were required but not found. Expected ${error.context.expectedRows} records to be connected, found only ${Array.isArray(data) ? data.length : data}.`;
618
+ case "INCOMPLETE_CONNECT_OUTPUT":
619
+ return `The required connected records were not found. Expected ${error.context.expectedRows} records to be connected after connect operation on ${error.context.relationType} relation '${error.context.relation}', found ${Array.isArray(data) ? data.length : data}.`;
596
620
  case "RECORDS_NOT_CONNECTED":
597
621
  return `The records for relation \`${error.context.relation}\` between the \`${error.context.parent}\` and \`${error.context.child}\` models are not connected.`;
598
622
  default:
@@ -605,6 +629,8 @@ function getErrorCode2(error) {
605
629
  return "P2014";
606
630
  case "RECORDS_NOT_CONNECTED":
607
631
  return "P2017";
632
+ case "INCOMPLETE_CONNECT_OUTPUT":
633
+ return "P2018";
608
634
  case "MISSING_RECORD":
609
635
  case "MISSING_RELATED_RECORD":
610
636
  case "INCOMPLETE_CONNECT_INPUT":
@@ -902,7 +928,7 @@ function childRecordMatchesParent(childRecord, parentRecord, joinExpr) {
902
928
  return true;
903
929
  }
904
930
  function paginate(list, { cursor, skip, take }) {
905
- const cursorIndex = cursor !== null ? list.findIndex((item) => doesMatchCursor(item, cursor)) : 0;
931
+ const cursorIndex = cursor !== null ? list.findIndex((item) => doKeysMatch(item, cursor)) : 0;
906
932
  if (cursorIndex === -1) {
907
933
  return [];
908
934
  }
@@ -913,14 +939,6 @@ function paginate(list, { cursor, skip, take }) {
913
939
  function getRecordKey(record, fields) {
914
940
  return JSON.stringify(fields.map((field) => record[field]));
915
941
  }
916
- function doesMatchCursor(item, cursor) {
917
- return Object.keys(cursor).every((key) => {
918
- if (typeof item[key] !== typeof cursor[key] && (typeof item[key] === "number" || typeof cursor[key] === "number")) {
919
- return `${item[key]}` === `${cursor[key]}`;
920
- }
921
- return isDeepStrictEqual(cursor[key], item[key]);
922
- });
923
- }
924
942
 
925
943
  // src/transactionManager/TransactionManager.ts
926
944
  import { Debug } from "@prisma/debug";
@@ -950,12 +968,12 @@ var TransactionNotFoundError = class extends TransactionManagerError {
950
968
  };
951
969
  var TransactionClosedError = class extends TransactionManagerError {
952
970
  constructor(operation) {
953
- 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.`);
954
972
  }
955
973
  };
956
974
  var TransactionRolledBackError = class extends TransactionManagerError {
957
975
  constructor(operation) {
958
- 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.`);
959
977
  }
960
978
  };
961
979
  var TransactionStartTimeoutError = class extends TransactionManagerError {
@@ -1142,6 +1160,7 @@ export {
1142
1160
  TransactionManager,
1143
1161
  TransactionManagerError,
1144
1162
  UserFacingError,
1163
+ doKeysMatch,
1145
1164
  isDeepStrictEqual,
1146
1165
  isPrismaValueBigInt,
1147
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.15",
3
+ "version": "6.9.0-dev.17",
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.15",
35
- "@prisma/driver-adapter-utils": "6.9.0-dev.15"
34
+ "@prisma/debug": "6.9.0-dev.17",
35
+ "@prisma/driver-adapter-utils": "6.9.0-dev.17"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",