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

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
@@ -1606,7 +1606,7 @@ var QueryInterpreter = class _QueryInterpreter {
1606
1606
  return this.interpretNode(node.args, queryable, scope, generators);
1607
1607
  }
1608
1608
  const transactionManager = this.#transactionManager.manager;
1609
- const transactionInfo = await transactionManager.startTransaction();
1609
+ const transactionInfo = await transactionManager.startInternalTransaction();
1610
1610
  const transaction = await transactionManager.getTransaction(transactionInfo, "query");
1611
1611
  try {
1612
1612
  const value = await this.interpretNode(node.args, transaction, scope, generators);
@@ -1934,24 +1934,39 @@ var TransactionManager = class {
1934
1934
  this.#onQuery = onQuery;
1935
1935
  this.#provider = provider;
1936
1936
  }
1937
+ /**
1938
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
1939
+ * use the default transaction options from the `TransactionManager`, which in practice means
1940
+ * that it does not apply the default timeouts.
1941
+ */
1942
+ async startInternalTransaction(options) {
1943
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : {};
1944
+ return await this.tracingHelper.runInChildSpan(
1945
+ "start_transaction",
1946
+ () => this.#startTransactionImpl(validatedOptions)
1947
+ );
1948
+ }
1937
1949
  async startTransaction(options) {
1938
- return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
1950
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1951
+ return await this.tracingHelper.runInChildSpan(
1952
+ "start_transaction",
1953
+ () => this.#startTransactionImpl(validatedOptions)
1954
+ );
1939
1955
  }
1940
1956
  async #startTransactionImpl(options) {
1941
- const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1942
1957
  const transaction = {
1943
1958
  id: await randomUUID(),
1944
1959
  status: "waiting",
1945
1960
  timer: void 0,
1946
- timeout: validatedOptions.timeout,
1961
+ timeout: options.timeout,
1947
1962
  startedAt: Date.now(),
1948
1963
  transaction: void 0
1949
1964
  };
1950
1965
  this.transactions.set(transaction.id, transaction);
1951
1966
  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);
1967
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1968
+ startTimer?.unref?.();
1969
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1955
1970
  clearTimeout(startTimer);
1956
1971
  switch (transaction.status) {
1957
1972
  case "waiting":
@@ -1960,7 +1975,7 @@ var TransactionManager = class {
1960
1975
  throw new TransactionStartTimeoutError();
1961
1976
  }
1962
1977
  transaction.status = "running";
1963
- transaction.timer = this.#startTransactionTimeout(transaction.id, validatedOptions.timeout);
1978
+ transaction.timer = this.#startTransactionTimeout(transaction.id, options.timeout);
1964
1979
  return { id: transaction.id };
1965
1980
  case "timed_out":
1966
1981
  case "running":
@@ -2030,7 +2045,7 @@ var TransactionManager = class {
2030
2045
  }
2031
2046
  #startTransactionTimeout(transactionId, timeout) {
2032
2047
  const timeoutStartedAt = Date.now();
2033
- const timer = setTimeout(async () => {
2048
+ const timer = createTimeoutIfDefined(async () => {
2034
2049
  debug("Transaction timed out.", { transactionId, timeoutStartedAt, timeout });
2035
2050
  const tx = this.transactions.get(transactionId);
2036
2051
  if (tx && ["running", "waiting"].includes(tx.status)) {
@@ -2039,7 +2054,7 @@ var TransactionManager = class {
2039
2054
  debug("Transaction already committed or rolled back when timeout happened.", transactionId);
2040
2055
  }
2041
2056
  }, timeout);
2042
- timer.unref?.();
2057
+ timer?.unref?.();
2043
2058
  return timer;
2044
2059
  }
2045
2060
  async #closeTransaction(tx, status) {
@@ -2109,6 +2124,9 @@ var TransactionManager = class {
2109
2124
  });
2110
2125
  }
2111
2126
  };
2127
+ function createTimeoutIfDefined(cb, ms) {
2128
+ return ms !== void 0 ? setTimeout(cb, ms) : void 0;
2129
+ }
2112
2130
  // Annotate the CommonJS export names for ESM import in node:
2113
2131
  0 && (module.exports = {
2114
2132
  DataMapperError,
package/dist/index.mjs CHANGED
@@ -1556,7 +1556,7 @@ var QueryInterpreter = class _QueryInterpreter {
1556
1556
  return this.interpretNode(node.args, queryable, scope, generators);
1557
1557
  }
1558
1558
  const transactionManager = this.#transactionManager.manager;
1559
- const transactionInfo = await transactionManager.startTransaction();
1559
+ const transactionInfo = await transactionManager.startInternalTransaction();
1560
1560
  const transaction = await transactionManager.getTransaction(transactionInfo, "query");
1561
1561
  try {
1562
1562
  const value = await this.interpretNode(node.args, transaction, scope, generators);
@@ -1884,24 +1884,39 @@ var TransactionManager = class {
1884
1884
  this.#onQuery = onQuery;
1885
1885
  this.#provider = provider;
1886
1886
  }
1887
+ /**
1888
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
1889
+ * use the default transaction options from the `TransactionManager`, which in practice means
1890
+ * that it does not apply the default timeouts.
1891
+ */
1892
+ async startInternalTransaction(options) {
1893
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : {};
1894
+ return await this.tracingHelper.runInChildSpan(
1895
+ "start_transaction",
1896
+ () => this.#startTransactionImpl(validatedOptions)
1897
+ );
1898
+ }
1887
1899
  async startTransaction(options) {
1888
- return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
1900
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1901
+ return await this.tracingHelper.runInChildSpan(
1902
+ "start_transaction",
1903
+ () => this.#startTransactionImpl(validatedOptions)
1904
+ );
1889
1905
  }
1890
1906
  async #startTransactionImpl(options) {
1891
- const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
1892
1907
  const transaction = {
1893
1908
  id: await randomUUID(),
1894
1909
  status: "waiting",
1895
1910
  timer: void 0,
1896
- timeout: validatedOptions.timeout,
1911
+ timeout: options.timeout,
1897
1912
  startedAt: Date.now(),
1898
1913
  transaction: void 0
1899
1914
  };
1900
1915
  this.transactions.set(transaction.id, transaction);
1901
1916
  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);
1917
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1918
+ startTimer?.unref?.();
1919
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1905
1920
  clearTimeout(startTimer);
1906
1921
  switch (transaction.status) {
1907
1922
  case "waiting":
@@ -1910,7 +1925,7 @@ var TransactionManager = class {
1910
1925
  throw new TransactionStartTimeoutError();
1911
1926
  }
1912
1927
  transaction.status = "running";
1913
- transaction.timer = this.#startTransactionTimeout(transaction.id, validatedOptions.timeout);
1928
+ transaction.timer = this.#startTransactionTimeout(transaction.id, options.timeout);
1914
1929
  return { id: transaction.id };
1915
1930
  case "timed_out":
1916
1931
  case "running":
@@ -1980,7 +1995,7 @@ var TransactionManager = class {
1980
1995
  }
1981
1996
  #startTransactionTimeout(transactionId, timeout) {
1982
1997
  const timeoutStartedAt = Date.now();
1983
- const timer = setTimeout(async () => {
1998
+ const timer = createTimeoutIfDefined(async () => {
1984
1999
  debug("Transaction timed out.", { transactionId, timeoutStartedAt, timeout });
1985
2000
  const tx = this.transactions.get(transactionId);
1986
2001
  if (tx && ["running", "waiting"].includes(tx.status)) {
@@ -1989,7 +2004,7 @@ var TransactionManager = class {
1989
2004
  debug("Transaction already committed or rolled back when timeout happened.", transactionId);
1990
2005
  }
1991
2006
  }, timeout);
1992
- timer.unref?.();
2007
+ timer?.unref?.();
1993
2008
  return timer;
1994
2009
  }
1995
2010
  async #closeTransaction(tx, status) {
@@ -2059,6 +2074,9 @@ var TransactionManager = class {
2059
2074
  });
2060
2075
  }
2061
2076
  };
2077
+ function createTimeoutIfDefined(cb, ms) {
2078
+ return ms !== void 0 ? setTimeout(cb, ms) : void 0;
2079
+ }
2062
2080
  export {
2063
2081
  DataMapperError,
2064
2082
  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.4",
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.4",
35
+ "@prisma/driver-adapter-utils": "6.18.0-dev.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",