@jskit-ai/database-runtime 0.1.252 → 0.1.254

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.
@@ -11,6 +11,6 @@ test("database-runtime exposes migration configuration without authoring mutatio
11
11
  assert.equal(Object.hasOwn(packageJson.jskit.metadata.apiSummary, "containerTokens"), false);
12
12
  assert.deepEqual(packageJson.jskit.capabilities, {
13
13
  provides: ["runtime.database"],
14
- requires: ["runtime.database.driver"]
14
+ requires: ["runtime.database.driver", "runtime.env"]
15
15
  });
16
16
  });
@@ -14,8 +14,7 @@ function driverProvider(dialectId = "mysql2") {
14
14
  setup() {
15
15
  return {
16
16
  driver: Object.freeze({
17
- DIALECT_ID: dialectId,
18
- getDialectId: () => dialectId
17
+ DIALECT_ID: dialectId
19
18
  })
20
19
  };
21
20
  }
@@ -2,6 +2,7 @@ import test from "node:test";
2
2
  import assert from "node:assert/strict";
3
3
  import {
4
4
  isDeadlockError,
5
+ joinOrOpenTransaction,
5
6
  lockScopedRecordId,
6
7
  normalizeDbRecordId,
7
8
  parseJsonValue,
@@ -135,3 +136,17 @@ test("runInTransaction retries only deadlocks of the outermost transaction, a fe
135
136
  assert.equal(await attemptsUntilRejected(fakeKnex(), victim, { retries: 0 }), 1);
136
137
  assert.equal(await attemptsUntilRejected(fakeKnex({ isTransaction: true }), victim), 1, "A savepoint leaves the retry to its outermost transaction");
137
138
  });
139
+
140
+ test("joinOrOpenTransaction runs work in the caller's transaction, else in one it opens", async () => {
141
+ const opened = [];
142
+ const withTransaction = async (work) => {
143
+ opened.push("opened");
144
+ return work("new-trx");
145
+ };
146
+ const work = async (trx) => `ran in ${trx}`;
147
+
148
+ assert.equal(await joinOrOpenTransaction({ trx: "caller-trx" }, withTransaction, work), "ran in caller-trx");
149
+ assert.deepEqual(opened, []);
150
+ assert.equal(await joinOrOpenTransaction({}, withTransaction, work), "ran in new-trx");
151
+ assert.deepEqual(opened, ["opened"]);
152
+ });