joist-core 2.4.0-next.36 → 2.4.0-next.37
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/build/EntityManager.cjs +15 -5
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +19 -5
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +19 -5
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +15 -5
- package/build/EntityManager.js.map +1 -1
- package/build/index.d.cts +2 -2
- package/build/index.d.mts +2 -2
- package/package.json +2 -2
package/build/EntityManager.cjs
CHANGED
|
@@ -137,6 +137,7 @@ var EntityManager = class EntityManager {
|
|
|
137
137
|
beforeCommit: [],
|
|
138
138
|
afterCommit: []
|
|
139
139
|
};
|
|
140
|
+
#forceTransaction = false;
|
|
140
141
|
#preloader;
|
|
141
142
|
#fieldLogger = require_logging_FieldLogger.noopFieldLogger;
|
|
142
143
|
#isLoadedCache = new require_loading_IsLoadedCache.IsLoadedCache();
|
|
@@ -159,6 +160,7 @@ var EntityManager = class EntityManager {
|
|
|
159
160
|
beforeCommit: [...opts.em.#hooks.beforeCommit],
|
|
160
161
|
afterCommit: [...opts.em.#hooks.afterCommit]
|
|
161
162
|
};
|
|
163
|
+
this.#forceTransaction = opts.em.#forceTransaction;
|
|
162
164
|
opts.em.__api.pluginManager.cloneTo(pluginManager);
|
|
163
165
|
}
|
|
164
166
|
const em = this;
|
|
@@ -993,7 +995,7 @@ var EntityManager = class EntityManager {
|
|
|
993
995
|
await runValidation(entityTodos, joinRowTodos, !skipValidation);
|
|
994
996
|
this.#rm.throwIfAnySuppressedTypeErrors();
|
|
995
997
|
if (suppressedDefaultTypeErrors.length > 0) throw suppressedDefaultTypeErrors[0];
|
|
996
|
-
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0 || this.#rm.hasPendingCommitTransitions()) {
|
|
998
|
+
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0 || this.#rm.hasPendingCommitTransitions() || this.#forceTransaction) {
|
|
997
999
|
await this.driver.transaction(this, async () => {
|
|
998
1000
|
do {
|
|
999
1001
|
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
|
|
@@ -1242,17 +1244,25 @@ var EntityManager = class EntityManager {
|
|
|
1242
1244
|
}));
|
|
1243
1245
|
await this.#rm.recalcPendingReactables("reactables");
|
|
1244
1246
|
}
|
|
1245
|
-
|
|
1247
|
+
/** Registers a hook to run before the transaction begins. */
|
|
1248
|
+
beforeBegin(fn, opts = {}) {
|
|
1246
1249
|
this.#hooks.beforeBegin.push(fn);
|
|
1250
|
+
this.#forceTransaction ||= opts.forceTransaction ?? false;
|
|
1247
1251
|
}
|
|
1248
|
-
|
|
1252
|
+
/** Registers a hook to run after the transaction begins. */
|
|
1253
|
+
afterBegin(fn, opts = {}) {
|
|
1249
1254
|
this.#hooks.afterBegin.push(fn);
|
|
1255
|
+
this.#forceTransaction ||= opts.forceTransaction ?? false;
|
|
1250
1256
|
}
|
|
1251
|
-
|
|
1257
|
+
/** Registers a hook to run before the transaction commits. */
|
|
1258
|
+
beforeCommit(fn, opts = {}) {
|
|
1252
1259
|
this.#hooks.beforeCommit.push(fn);
|
|
1260
|
+
this.#forceTransaction ||= opts.forceTransaction ?? false;
|
|
1253
1261
|
}
|
|
1254
|
-
|
|
1262
|
+
/** Registers a hook to run after the transaction commits. */
|
|
1263
|
+
afterCommit(fn, opts = {}) {
|
|
1255
1264
|
this.#hooks.afterCommit.push(fn);
|
|
1265
|
+
this.#forceTransaction ||= opts.forceTransaction ?? false;
|
|
1256
1266
|
}
|
|
1257
1267
|
/**
|
|
1258
1268
|
* Returns an EntityManager-scoped (i.e. request scoped) data loader.
|