joist-core 2.4.0-next.41 → 2.4.0-next.43
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 +26 -11
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +8 -0
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +8 -0
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +26 -11
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.cjs.map +1 -1
- package/build/EntityMetadata.d.cts +4 -1
- package/build/EntityMetadata.d.cts.map +1 -1
- package/build/EntityMetadata.d.mts +4 -1
- package/build/EntityMetadata.d.mts.map +1 -1
- package/build/EntityMetadata.js.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.cjs +1 -1
- package/build/batchloaders/oneToManyBatchLoader.js +1 -1
- package/build/batchloaders/oneToOneBatchLoader.cjs +1 -1
- package/build/batchloaders/oneToOneBatchLoader.js +1 -1
- package/build/batchloaders/populateBatchLoader.cjs +2 -2
- package/build/batchloaders/populateBatchLoader.js +2 -2
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs +2 -2
- package/build/batchloaders/recursiveChildrenBatchLoader.js +2 -2
- package/build/batchloaders/recursiveM2mBatchLoader.cjs +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.js +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.cjs +2 -2
- package/build/batchloaders/recursiveParentsBatchLoader.js +2 -2
- package/build/changes.cjs +1 -1
- package/build/changes.js +1 -1
- package/build/config.cjs +17 -13
- package/build/config.cjs.map +1 -1
- package/build/config.d.cts +7 -1
- package/build/config.d.cts.map +1 -1
- package/build/config.d.mts +7 -1
- package/build/config.d.mts.map +1 -1
- package/build/config.js +17 -13
- package/build/config.js.map +1 -1
- package/build/configure.cjs +2 -2
- package/build/configure.js +2 -2
- package/build/dataloaders/findDataLoader.cjs +2 -2
- package/build/dataloaders/findDataLoader.js +2 -2
- package/build/dataloaders/findOrCreateDataLoader.cjs +1 -1
- package/build/dataloaders/findOrCreateDataLoader.js +1 -1
- package/build/dataloaders/findPaginatedDataLoader.cjs +1 -1
- package/build/dataloaders/findPaginatedDataLoader.js +1 -1
- package/build/defaults.cjs +3 -3
- package/build/defaults.js +3 -3
- package/build/drivers/EntityWriter.cjs +2 -2
- package/build/drivers/EntityWriter.cjs.map +1 -1
- package/build/drivers/EntityWriter.js +2 -2
- package/build/drivers/EntityWriter.js.map +1 -1
- package/build/fields.cjs +10 -8
- package/build/fields.cjs.map +1 -1
- package/build/fields.d.cts +5 -5
- package/build/fields.d.cts.map +1 -1
- package/build/fields.d.mts +5 -5
- package/build/fields.d.mts.map +1 -1
- package/build/fields.js +10 -8
- package/build/fields.js.map +1 -1
- package/build/flush/ReadDrift.cjs +90 -0
- package/build/flush/ReadDrift.cjs.map +1 -0
- package/build/flush/ReadDrift.d.cts +25 -0
- package/build/flush/ReadDrift.d.cts.map +1 -0
- package/build/flush/ReadDrift.d.mts +25 -0
- package/build/flush/ReadDrift.d.mts.map +1 -0
- package/build/flush/ReadDrift.js +87 -0
- package/build/flush/ReadDrift.js.map +1 -0
- package/build/getProperties.cjs +1 -1
- package/build/getProperties.js +1 -1
- package/build/index.cjs +16 -13
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +2 -1
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +2 -1
- package/build/index.d.mts.map +1 -1
- package/build/index.js +16 -14
- package/build/index.js.map +1 -1
- package/build/json.cjs +3 -3
- package/build/json.js +3 -3
- package/build/loading/loadHints.cjs +1 -1
- package/build/loading/loadHints.js +1 -1
- package/build/loading/withLoaded.cjs +2 -2
- package/build/loading/withLoaded.js +2 -2
- package/build/newEntity.cjs +1 -1
- package/build/newEntity.js +1 -1
- package/build/preloading/partitionHint.cjs +2 -2
- package/build/preloading/partitionHint.js +2 -2
- package/build/reactivity/ReactionsManager.cjs +1 -1
- package/build/reactivity/ReactionsManager.js +1 -1
- package/build/reactivity/reactiveHints.cjs +3 -3
- package/build/reactivity/reactiveHints.js +3 -3
- package/build/relations/AsyncProperty.cjs +1 -1
- package/build/relations/AsyncProperty.js +1 -1
- package/build/relations/AsyncReactiveField.cjs +5 -5
- package/build/relations/AsyncReactiveField.js +5 -5
- package/build/relations/CustomCollection.cjs +1 -1
- package/build/relations/CustomCollection.js +1 -1
- package/build/relations/CustomReference.cjs +2 -2
- package/build/relations/CustomReference.js +2 -2
- package/build/relations/EnumCollection.cjs +1 -1
- package/build/relations/EnumCollection.js +1 -1
- package/build/relations/LazyField.cjs +2 -2
- package/build/relations/LazyField.js +2 -2
- package/build/relations/ManyToManyCollection.cjs +1 -1
- package/build/relations/ManyToManyCollection.js +1 -1
- package/build/relations/ManyToManyLargeCollection.cjs +1 -1
- package/build/relations/ManyToManyLargeCollection.js +1 -1
- package/build/relations/ManyToOneReference.cjs +2 -2
- package/build/relations/ManyToOneReference.js +2 -2
- package/build/relations/OneToManyCollection.cjs +1 -1
- package/build/relations/OneToManyCollection.js +1 -1
- package/build/relations/OneToManyLargeCollection.cjs +1 -1
- package/build/relations/OneToManyLargeCollection.js +1 -1
- package/build/relations/OneToOneReference.cjs +2 -2
- package/build/relations/OneToOneReference.js +2 -2
- package/build/relations/PolymorphicReference.cjs +2 -2
- package/build/relations/PolymorphicReference.js +2 -2
- package/build/relations/ReactiveField.cjs +3 -3
- package/build/relations/ReactiveField.js +3 -3
- package/build/relations/ReactiveGetter.cjs +1 -1
- package/build/relations/ReactiveGetter.js +1 -1
- package/build/relations/ReactiveManyToMany.cjs +2 -2
- package/build/relations/ReactiveManyToMany.js +2 -2
- package/build/relations/ReactiveManyToManyOtherSide.cjs +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +1 -1
- package/build/relations/ReactiveReference.cjs +3 -3
- package/build/relations/ReactiveReference.js +3 -3
- package/build/relations/RecursiveCollection.cjs +4 -4
- package/build/relations/RecursiveCollection.js +4 -4
- package/build/relations/hasAsyncMethod.cjs +1 -1
- package/build/relations/hasAsyncMethod.js +1 -1
- package/build/relations/hasManyDerived.cjs +1 -1
- package/build/relations/hasManyDerived.js +1 -1
- package/build/relations/hasManyThrough.cjs +1 -1
- package/build/relations/hasManyThrough.js +1 -1
- package/build/relations/hasOneDerived.cjs +1 -1
- package/build/relations/hasOneDerived.js +1 -1
- package/build/relations/hasOneThrough.cjs +1 -1
- package/build/relations/hasOneThrough.js +1 -1
- package/build/relations/hasProperty.cjs +3 -3
- package/build/relations/hasProperty.js +3 -3
- package/build/relations/index.cjs +5 -5
- package/build/relations/index.js +5 -5
- package/build/rules.cjs +1 -1
- package/build/rules.js +1 -1
- package/build/upsert.cjs +1 -1
- package/build/upsert.js +1 -1
- package/package.json +3 -3
package/build/EntityManager.cjs
CHANGED
|
@@ -2,13 +2,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_batchloaders_BatchLoader = require("./batchloaders/BatchLoader.cjs");
|
|
4
4
|
require("./relations/Collection.cjs");
|
|
5
|
+
const require_newEntity = require("./newEntity.cjs");
|
|
5
6
|
const require_relations_CustomCollection = require("./relations/CustomCollection.cjs");
|
|
6
7
|
const require_relations_CustomReference = require("./relations/CustomReference.cjs");
|
|
8
|
+
const require_normalizeHints = require("./normalizeHints.cjs");
|
|
9
|
+
require("./batchloaders/recursiveChildrenBatchLoader.cjs");
|
|
10
|
+
require("./batchloaders/recursiveM2mBatchLoader.cjs");
|
|
11
|
+
require("./batchloaders/recursiveParentsBatchLoader.cjs");
|
|
12
|
+
const require_relations_RecursiveCycleError = require("./relations/RecursiveCycleError.cjs");
|
|
13
|
+
require("./relations/RecursiveCollection.cjs");
|
|
14
|
+
const require_reactivity_reactiveHints = require("./reactivity/reactiveHints.cjs");
|
|
7
15
|
const require_loading_loadHints = require("./loading/loadHints.cjs");
|
|
8
16
|
const require_relations_hasAsyncMethod = require("./relations/hasAsyncMethod.cjs");
|
|
9
|
-
const require_relations_RecursiveCycleError = require("./relations/RecursiveCycleError.cjs");
|
|
10
17
|
const require_relations_AsyncProperty = require("./relations/AsyncProperty.cjs");
|
|
11
|
-
const require_fields = require("./fields.cjs");
|
|
12
18
|
const require_keys = require("./keys.cjs");
|
|
13
19
|
const require_RowData = require("./RowData.cjs");
|
|
14
20
|
const require_relations_LazyField = require("./relations/LazyField.cjs");
|
|
@@ -22,15 +28,10 @@ require("./batchloaders/oneToOneBatchLoader.cjs");
|
|
|
22
28
|
const require_relations_ReactiveReference = require("./relations/ReactiveReference.cjs");
|
|
23
29
|
const require_relations_OneToOneReference = require("./relations/OneToOneReference.cjs");
|
|
24
30
|
const require_relations_PolymorphicReference = require("./relations/PolymorphicReference.cjs");
|
|
25
|
-
require("./batchloaders/recursiveChildrenBatchLoader.cjs");
|
|
26
|
-
require("./batchloaders/recursiveM2mBatchLoader.cjs");
|
|
27
|
-
require("./batchloaders/recursiveParentsBatchLoader.cjs");
|
|
28
|
-
require("./relations/RecursiveCollection.cjs");
|
|
29
31
|
require("./relations/index.cjs");
|
|
30
32
|
const require_utils = require("./utils.cjs");
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const require_reactivity_reactiveHints = require("./reactivity/reactiveHints.cjs");
|
|
33
|
+
const require_fields = require("./fields.cjs");
|
|
34
|
+
const require_flush_ReadDrift = require("./flush/ReadDrift.cjs");
|
|
34
35
|
require("./typeMap.cjs");
|
|
35
36
|
const require_rules = require("./rules.cjs");
|
|
36
37
|
const require_config = require("./config.cjs");
|
|
@@ -138,6 +139,7 @@ var EntityManager = class EntityManager {
|
|
|
138
139
|
afterCommit: []
|
|
139
140
|
};
|
|
140
141
|
#forceTransaction = false;
|
|
142
|
+
#readSet = /* @__PURE__ */ new Set();
|
|
141
143
|
#preloader;
|
|
142
144
|
#fieldLogger = require_logging_FieldLogger.noopFieldLogger;
|
|
143
145
|
#isLoadedCache = new require_loading_IsLoadedCache.IsLoadedCache();
|
|
@@ -1003,9 +1005,11 @@ var EntityManager = class EntityManager {
|
|
|
1003
1005
|
await runValidation(entityTodos, joinRowTodos, !skipValidation);
|
|
1004
1006
|
this.#rm.throwIfAnySuppressedTypeErrors();
|
|
1005
1007
|
if (suppressedDefaultTypeErrors.length > 0) throw suppressedDefaultTypeErrors[0];
|
|
1006
|
-
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0 || this.#rm.hasPendingCommitTransitions() || this.#forceTransaction) {
|
|
1008
|
+
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0 || this.#rm.hasPendingCommitTransitions() || this.#readSet.size > 0 || this.#forceTransaction) {
|
|
1009
|
+
const checkedReads = /* @__PURE__ */ new Set();
|
|
1007
1010
|
await this.driver.transaction(this, async () => {
|
|
1008
1011
|
do {
|
|
1012
|
+
if (this.#readSet.size > 0) await require_flush_ReadDrift.checkReadDrift(this, this.#readSet, allFlushedEntities, checkedReads);
|
|
1009
1013
|
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
|
|
1010
1014
|
await this.driver.flush(this, entityTodos, joinRowTodos);
|
|
1011
1015
|
collectCommitRuleTodos(entityTodos, joinRowTodos);
|
|
@@ -1035,6 +1039,7 @@ var EntityManager = class EntityManager {
|
|
|
1035
1039
|
}
|
|
1036
1040
|
await beforeCommit(this.ctx, allFlushedEntities);
|
|
1037
1041
|
await this.#rm.runCommitTransitions();
|
|
1042
|
+
if (this.#readSet.size > 0) await require_flush_ReadDrift.checkReadDrift(this, this.#readSet, allFlushedEntities, checkedReads);
|
|
1038
1043
|
if (this.mode === "in-memory-writes") throw new InMemoryRollbackError();
|
|
1039
1044
|
});
|
|
1040
1045
|
await afterCommit(this.ctx, allFlushedEntities);
|
|
@@ -1058,6 +1063,7 @@ var EntityManager = class EntityManager {
|
|
|
1058
1063
|
for (const e of createdThenDeleted) require_BaseEntity.getInstanceData(e).fixupCreatedThenDeleted();
|
|
1059
1064
|
this.#merging?.clear();
|
|
1060
1065
|
this.#rm.clear();
|
|
1066
|
+
this.#readSet.clear();
|
|
1061
1067
|
return [...allFlushedEntities].sort((a, b) => require_BaseEntity.getInstanceData(a).entityIndex - require_BaseEntity.getInstanceData(b).entityIndex);
|
|
1062
1068
|
} catch (e) {
|
|
1063
1069
|
if (!(e instanceof InMemoryRollbackError)) this.#flushError = e;
|
|
@@ -1217,6 +1223,15 @@ var EntityManager = class EntityManager {
|
|
|
1217
1223
|
}
|
|
1218
1224
|
return entities;
|
|
1219
1225
|
}
|
|
1226
|
+
assertUnchanged(entityOrEntities) {
|
|
1227
|
+
const entities = require_Entity.isEntity(entityOrEntities) ? [entityOrEntities] : entityOrEntities;
|
|
1228
|
+
for (const entity of entities) {
|
|
1229
|
+
if (entity.em !== this) throw new Error("assertUnchanged requires entities from this EntityManager");
|
|
1230
|
+
if (entity.isNewEntity) continue;
|
|
1231
|
+
if (!require_EntityMetadata.getBaseMeta(require_EntityMetadata.getMetadata(entity)).timestampFields?.updatedAt) throw new Error(`assertUnchanged requires updatedAt on ${entity}`);
|
|
1232
|
+
this.#readSet.add(entity);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1220
1235
|
touch(entityOrEntities) {
|
|
1221
1236
|
for (const entity of require_utils.toArray(entityOrEntities)) require_BaseEntity.getInstanceData(entity).markTouched();
|
|
1222
1237
|
}
|
|
@@ -1837,7 +1852,7 @@ function maybeBumpUpdatedAt(rm, todos, now) {
|
|
|
1837
1852
|
const { updatedAt } = todo.metadata.timestampFields ?? {};
|
|
1838
1853
|
if (updatedAt) for (const e of todo.updates) {
|
|
1839
1854
|
const orm = require_BaseEntity.getInstanceData(e);
|
|
1840
|
-
orm.markFieldDirty(updatedAt, require_fields.getField(e, updatedAt));
|
|
1855
|
+
orm.markFieldDirty(updatedAt, require_fields.getField(e, updatedAt, true));
|
|
1841
1856
|
const serde = todo.metadata.fields[updatedAt].serde;
|
|
1842
1857
|
orm.data[updatedAt] = serde.mapFromNow(now);
|
|
1843
1858
|
rm.queueDownstreamReactables(e, updatedAt);
|