@prisma/client-engine-runtime 6.18.0-dev.2 → 6.18.0-dev.20

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
@@ -446,6 +446,12 @@ export declare class TransactionManager {
446
446
  onQuery?: (event: QueryEvent) => void;
447
447
  provider?: SchemaProvider;
448
448
  });
449
+ /**
450
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
451
+ * use the default transaction options from the `TransactionManager`, which in practice means
452
+ * that it does not apply the default timeouts.
453
+ */
454
+ startInternalTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
449
455
  startTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
450
456
  commitTransaction(transactionId: string): Promise<void>;
451
457
  rollbackTransaction(transactionId: string): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -446,6 +446,12 @@ export declare class TransactionManager {
446
446
  onQuery?: (event: QueryEvent) => void;
447
447
  provider?: SchemaProvider;
448
448
  });
449
+ /**
450
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
451
+ * use the default transaction options from the `TransactionManager`, which in practice means
452
+ * that it does not apply the default timeouts.
453
+ */
454
+ startInternalTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
449
455
  startTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
450
456
  commitTransaction(transactionId: string): Promise<void>;
451
457
  rollbackTransaction(transactionId: string): Promise<void>;
package/dist/index.js CHANGED
@@ -670,12 +670,12 @@ function mapValue(value, columnName, scalarType, enums) {
670
670
  }
671
671
  var TIME_TZ_PATTERN = /\d{2}:\d{2}:\d{2}(?:\.\d+)?(Z|[+-]\d{2}(:?\d{2})?)?$/;
672
672
  function normalizeDateTime(dt) {
673
- const matches = TIME_TZ_PATTERN.exec(dt);
674
- if (matches === null) {
675
- return `${dt}Z`;
673
+ const timeTzMatches = TIME_TZ_PATTERN.exec(dt);
674
+ if (timeTzMatches === null) {
675
+ return `${dt}T00:00:00Z`;
676
676
  }
677
677
  let dtWithTz = dt;
678
- const [timeTz, tz, tzMinuteOffset] = matches;
678
+ const [timeTz, tz, tzMinuteOffset] = timeTzMatches;
679
679
  if (tz !== void 0 && tz !== "Z" && tzMinuteOffset === void 0) {
680
680
  dtWithTz = `${dt}:00`;
681
681
  } else if (tz === void 0) {
@@ -684,6 +684,10 @@ function normalizeDateTime(dt) {
684
684
  if (timeTz.length === dt.length) {
685
685
  return `1970-01-01T${dtWithTz}`;
686
686
  }
687
+ const timeSeparatorIndex = timeTzMatches.index - 1;
688
+ if (dtWithTz[timeSeparatorIndex] === " ") {
689
+ dtWithTz = `${dtWithTz.slice(0, timeSeparatorIndex)}T${dtWithTz.slice(timeSeparatorIndex + 1)}`;
690
+ }
687
691
  return dtWithTz;
688
692
  }
689
693
 
@@ -1606,7 +1610,7 @@ var QueryInterpreter = class _QueryInterpreter {
1606
1610
  return this.interpretNode(node.args, queryable, scope, generators);
1607
1611
  }
1608
1612
  const transactionManager = this.#transactionManager.manager;
1609
- const transactionInfo = await transactionManager.startTransaction();
1613
+ const transactionInfo = await transactionManager.startInternalTransaction();
1610
1614
  const transaction = await transactionManager.getTransaction(transactionInfo, "query");
1611
1615
  try {
1612
1616
  const value = await this.interpretNode(node.args, transaction, scope, generators);
@@ -1934,24 +1938,39 @@ var TransactionManager = class {
1934
1938
  this.#onQuery = onQuery;
1935
1939
  this.#provider = provider;
1936
1940
  }
1941
+ /**
1942
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
1943
+ * use the default transaction options from the `TransactionManager`, which in practice means
1944
+ * that it does not apply the default timeouts.
1945
+ */
1946
+ async startInternalTransaction(options) {
1947
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : {};
1948
+ return await this.tracingHelper.runInChildSpan(
1949
+ "start_transaction",
1950
+ () => this.#startTransactionImpl(validatedOptions)
1951
+ );
1952
+ }
1937
1953
  async startTransaction(options) {
1938
- return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
1954
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1955
+ return await this.tracingHelper.runInChildSpan(
1956
+ "start_transaction",
1957
+ () => this.#startTransactionImpl(validatedOptions)
1958
+ );
1939
1959
  }
1940
1960
  async #startTransactionImpl(options) {
1941
- const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1942
1961
  const transaction = {
1943
1962
  id: await randomUUID(),
1944
1963
  status: "waiting",
1945
1964
  timer: void 0,
1946
- timeout: validatedOptions.timeout,
1965
+ timeout: options.timeout,
1947
1966
  startedAt: Date.now(),
1948
1967
  transaction: void 0
1949
1968
  };
1950
1969
  this.transactions.set(transaction.id, transaction);
1951
1970
  let hasTimedOut = false;
1952
- const startTimer = setTimeout(() => hasTimedOut = true, validatedOptions.maxWait);
1953
- startTimer.unref?.();
1954
- transaction.transaction = await this.driverAdapter.startTransaction(validatedOptions.isolationLevel).catch(rethrowAsUserFacing);
1971
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1972
+ startTimer?.unref?.();
1973
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1955
1974
  clearTimeout(startTimer);
1956
1975
  switch (transaction.status) {
1957
1976
  case "waiting":
@@ -1960,7 +1979,7 @@ var TransactionManager = class {
1960
1979
  throw new TransactionStartTimeoutError();
1961
1980
  }
1962
1981
  transaction.status = "running";
1963
- transaction.timer = this.#startTransactionTimeout(transaction.id, validatedOptions.timeout);
1982
+ transaction.timer = this.#startTransactionTimeout(transaction.id, options.timeout);
1964
1983
  return { id: transaction.id };
1965
1984
  case "timed_out":
1966
1985
  case "running":
@@ -2030,7 +2049,7 @@ var TransactionManager = class {
2030
2049
  }
2031
2050
  #startTransactionTimeout(transactionId, timeout) {
2032
2051
  const timeoutStartedAt = Date.now();
2033
- const timer = setTimeout(async () => {
2052
+ const timer = createTimeoutIfDefined(async () => {
2034
2053
  debug("Transaction timed out.", { transactionId, timeoutStartedAt, timeout });
2035
2054
  const tx = this.transactions.get(transactionId);
2036
2055
  if (tx && ["running", "waiting"].includes(tx.status)) {
@@ -2039,7 +2058,7 @@ var TransactionManager = class {
2039
2058
  debug("Transaction already committed or rolled back when timeout happened.", transactionId);
2040
2059
  }
2041
2060
  }, timeout);
2042
- timer.unref?.();
2061
+ timer?.unref?.();
2043
2062
  return timer;
2044
2063
  }
2045
2064
  async #closeTransaction(tx, status) {
@@ -2109,6 +2128,9 @@ var TransactionManager = class {
2109
2128
  });
2110
2129
  }
2111
2130
  };
2131
+ function createTimeoutIfDefined(cb, ms) {
2132
+ return ms !== void 0 ? setTimeout(cb, ms) : void 0;
2133
+ }
2112
2134
  // Annotate the CommonJS export names for ESM import in node:
2113
2135
  0 && (module.exports = {
2114
2136
  DataMapperError,
package/dist/index.mjs CHANGED
@@ -620,12 +620,12 @@ function mapValue(value, columnName, scalarType, enums) {
620
620
  }
621
621
  var TIME_TZ_PATTERN = /\d{2}:\d{2}:\d{2}(?:\.\d+)?(Z|[+-]\d{2}(:?\d{2})?)?$/;
622
622
  function normalizeDateTime(dt) {
623
- const matches = TIME_TZ_PATTERN.exec(dt);
624
- if (matches === null) {
625
- return `${dt}Z`;
623
+ const timeTzMatches = TIME_TZ_PATTERN.exec(dt);
624
+ if (timeTzMatches === null) {
625
+ return `${dt}T00:00:00Z`;
626
626
  }
627
627
  let dtWithTz = dt;
628
- const [timeTz, tz, tzMinuteOffset] = matches;
628
+ const [timeTz, tz, tzMinuteOffset] = timeTzMatches;
629
629
  if (tz !== void 0 && tz !== "Z" && tzMinuteOffset === void 0) {
630
630
  dtWithTz = `${dt}:00`;
631
631
  } else if (tz === void 0) {
@@ -634,6 +634,10 @@ function normalizeDateTime(dt) {
634
634
  if (timeTz.length === dt.length) {
635
635
  return `1970-01-01T${dtWithTz}`;
636
636
  }
637
+ const timeSeparatorIndex = timeTzMatches.index - 1;
638
+ if (dtWithTz[timeSeparatorIndex] === " ") {
639
+ dtWithTz = `${dtWithTz.slice(0, timeSeparatorIndex)}T${dtWithTz.slice(timeSeparatorIndex + 1)}`;
640
+ }
637
641
  return dtWithTz;
638
642
  }
639
643
 
@@ -1556,7 +1560,7 @@ var QueryInterpreter = class _QueryInterpreter {
1556
1560
  return this.interpretNode(node.args, queryable, scope, generators);
1557
1561
  }
1558
1562
  const transactionManager = this.#transactionManager.manager;
1559
- const transactionInfo = await transactionManager.startTransaction();
1563
+ const transactionInfo = await transactionManager.startInternalTransaction();
1560
1564
  const transaction = await transactionManager.getTransaction(transactionInfo, "query");
1561
1565
  try {
1562
1566
  const value = await this.interpretNode(node.args, transaction, scope, generators);
@@ -1884,24 +1888,39 @@ var TransactionManager = class {
1884
1888
  this.#onQuery = onQuery;
1885
1889
  this.#provider = provider;
1886
1890
  }
1891
+ /**
1892
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
1893
+ * use the default transaction options from the `TransactionManager`, which in practice means
1894
+ * that it does not apply the default timeouts.
1895
+ */
1896
+ async startInternalTransaction(options) {
1897
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : {};
1898
+ return await this.tracingHelper.runInChildSpan(
1899
+ "start_transaction",
1900
+ () => this.#startTransactionImpl(validatedOptions)
1901
+ );
1902
+ }
1887
1903
  async startTransaction(options) {
1888
- return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
1904
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1905
+ return await this.tracingHelper.runInChildSpan(
1906
+ "start_transaction",
1907
+ () => this.#startTransactionImpl(validatedOptions)
1908
+ );
1889
1909
  }
1890
1910
  async #startTransactionImpl(options) {
1891
- const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1892
1911
  const transaction = {
1893
1912
  id: await randomUUID(),
1894
1913
  status: "waiting",
1895
1914
  timer: void 0,
1896
- timeout: validatedOptions.timeout,
1915
+ timeout: options.timeout,
1897
1916
  startedAt: Date.now(),
1898
1917
  transaction: void 0
1899
1918
  };
1900
1919
  this.transactions.set(transaction.id, transaction);
1901
1920
  let hasTimedOut = false;
1902
- const startTimer = setTimeout(() => hasTimedOut = true, validatedOptions.maxWait);
1903
- startTimer.unref?.();
1904
- transaction.transaction = await this.driverAdapter.startTransaction(validatedOptions.isolationLevel).catch(rethrowAsUserFacing);
1921
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1922
+ startTimer?.unref?.();
1923
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1905
1924
  clearTimeout(startTimer);
1906
1925
  switch (transaction.status) {
1907
1926
  case "waiting":
@@ -1910,7 +1929,7 @@ var TransactionManager = class {
1910
1929
  throw new TransactionStartTimeoutError();
1911
1930
  }
1912
1931
  transaction.status = "running";
1913
- transaction.timer = this.#startTransactionTimeout(transaction.id, validatedOptions.timeout);
1932
+ transaction.timer = this.#startTransactionTimeout(transaction.id, options.timeout);
1914
1933
  return { id: transaction.id };
1915
1934
  case "timed_out":
1916
1935
  case "running":
@@ -1980,7 +1999,7 @@ var TransactionManager = class {
1980
1999
  }
1981
2000
  #startTransactionTimeout(transactionId, timeout) {
1982
2001
  const timeoutStartedAt = Date.now();
1983
- const timer = setTimeout(async () => {
2002
+ const timer = createTimeoutIfDefined(async () => {
1984
2003
  debug("Transaction timed out.", { transactionId, timeoutStartedAt, timeout });
1985
2004
  const tx = this.transactions.get(transactionId);
1986
2005
  if (tx && ["running", "waiting"].includes(tx.status)) {
@@ -1989,7 +2008,7 @@ var TransactionManager = class {
1989
2008
  debug("Transaction already committed or rolled back when timeout happened.", transactionId);
1990
2009
  }
1991
2010
  }, timeout);
1992
- timer.unref?.();
2011
+ timer?.unref?.();
1993
2012
  return timer;
1994
2013
  }
1995
2014
  async #closeTransaction(tx, status) {
@@ -2059,6 +2078,9 @@ var TransactionManager = class {
2059
2078
  });
2060
2079
  }
2061
2080
  };
2081
+ function createTimeoutIfDefined(cb, ms) {
2082
+ return ms !== void 0 ? setTimeout(cb, ms) : void 0;
2083
+ }
2062
2084
  export {
2063
2085
  DataMapperError,
2064
2086
  QueryInterpreter,
@@ -17,6 +17,12 @@ export declare class TransactionManager {
17
17
  onQuery?: (event: QueryEvent) => void;
18
18
  provider?: SchemaProvider;
19
19
  });
20
+ /**
21
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
22
+ * use the default transaction options from the `TransactionManager`, which in practice means
23
+ * that it does not apply the default timeouts.
24
+ */
25
+ startInternalTransaction(options?: Options): Promise<TransactionInfo>;
20
26
  startTransaction(options?: Options): Promise<TransactionInfo>;
21
27
  commitTransaction(transactionId: string): Promise<void>;
22
28
  rollbackTransaction(transactionId: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.18.0-dev.2",
3
+ "version": "6.18.0-dev.20",
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.18.0-dev.2",
35
- "@prisma/driver-adapter-utils": "6.18.0-dev.2"
34
+ "@prisma/debug": "6.18.0-dev.20",
35
+ "@prisma/driver-adapter-utils": "6.18.0-dev.20"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",