joist-test-utils 2.3.0-next.41 → 2.3.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/RunPlugin.cjs +219 -0
- package/build/RunPlugin.cjs.map +1 -0
- package/build/RunPlugin.d.cts +12 -0
- package/build/RunPlugin.d.cts.map +1 -0
- package/build/RunPlugin.d.mts +12 -0
- package/build/RunPlugin.d.mts.map +1 -0
- package/build/RunPlugin.js +203 -341
- package/build/RunPlugin.js.map +1 -1
- package/build/_virtual/_rolldown/runtime.cjs +23 -0
- package/build/context.cjs +2 -0
- package/build/context.d.cts +9 -0
- package/build/context.d.cts.map +1 -0
- package/build/context.d.mts +9 -0
- package/build/context.d.mts.map +1 -0
- package/build/context.js +2 -3
- package/build/index.cjs +38 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +52 -0
- package/build/index.d.cts.map +1 -0
- package/build/index.d.mts +52 -0
- package/build/index.d.mts.map +1 -0
- package/build/index.js +25 -41
- package/build/index.js.map +1 -1
- package/build/run.cjs +77 -0
- package/build/run.cjs.map +1 -0
- package/build/run.d.cts +17 -0
- package/build/run.d.cts.map +1 -0
- package/build/run.d.mts +17 -0
- package/build/run.d.mts.map +1 -0
- package/build/run.js +52 -76
- package/build/run.js.map +1 -1
- package/build/seed.cjs +54 -0
- package/build/seed.cjs.map +1 -0
- package/build/{seed.d.ts → seed.d.cts} +9 -5
- package/build/seed.d.cts.map +1 -0
- package/build/seed.d.mts +35 -0
- package/build/seed.d.mts.map +1 -0
- package/build/seed.js +47 -53
- package/build/seed.js.map +1 -1
- package/build/toMatchEntity.cjs +95 -0
- package/build/toMatchEntity.cjs.map +1 -0
- package/build/toMatchEntity.d.cts +28 -0
- package/build/toMatchEntity.d.cts.map +1 -0
- package/build/toMatchEntity.d.mts +28 -0
- package/build/toMatchEntity.d.mts.map +1 -0
- package/build/toMatchEntity.js +72 -130
- package/build/toMatchEntity.js.map +1 -1
- package/package.json +28 -5
- package/build/RunPlugin.d.ts +0 -8
- package/build/context.d.ts +0 -5
- package/build/context.js.map +0 -1
- package/build/index.d.ts +0 -49
- package/build/run.d.ts +0 -14
- package/build/toMatchEntity.d.ts +0 -26
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let joist_core = require("joist-core");
|
|
3
|
+
//#region src/RunPlugin.ts
|
|
4
|
+
var RunPlugin = class extends joist_core.Plugin {
|
|
5
|
+
em;
|
|
6
|
+
constructor(em) {
|
|
7
|
+
super();
|
|
8
|
+
this.em = em;
|
|
9
|
+
}
|
|
10
|
+
maybeCloneForNewEm() {
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
afterWrite(entityTodos, joinRowTodos) {
|
|
14
|
+
const api = (0, joist_core.getEmInternalApi)(this.em);
|
|
15
|
+
api.clearPreloadedRelations();
|
|
16
|
+
api.clearDataloaders();
|
|
17
|
+
this.#syncEntityData(entityTodos);
|
|
18
|
+
this.#syncReferences(entityTodos);
|
|
19
|
+
this.#syncManyToManys(joinRowTodos);
|
|
20
|
+
this.#syncEnumCollections(joinRowTodos);
|
|
21
|
+
this.#preloadUnloadedRelations(entityTodos);
|
|
22
|
+
}
|
|
23
|
+
#syncEntityData(entityTodos) {
|
|
24
|
+
const { em } = this;
|
|
25
|
+
Object.values(entityTodos).forEach((todo) => {
|
|
26
|
+
todo.inserts.forEach((newEntity) => {
|
|
27
|
+
const row = (0, joist_core.createRowFromEntityData)(newEntity, { preferOriginalData: false });
|
|
28
|
+
em.hydrate(newEntity.constructor, [row]);
|
|
29
|
+
});
|
|
30
|
+
todo.updates.forEach((newEntity) => {
|
|
31
|
+
const oldEntity = em.findExistingInstance(newEntity.idTagged);
|
|
32
|
+
if (!oldEntity) fail(`Expected to find existing entity for $ {e.idTagged}`);
|
|
33
|
+
const { data: newData } = (0, joist_core.getInstanceData)(newEntity);
|
|
34
|
+
const { data: oldData } = (0, joist_core.getInstanceData)(oldEntity);
|
|
35
|
+
const meta = (0, joist_core.getMetadata)(newEntity);
|
|
36
|
+
newEntity.changes.fields.values().filter((fieldName) => fieldName in newData).filter((fieldName) => !!meta.allFields[fieldName].serde).forEach((fieldName) => {
|
|
37
|
+
const serde = meta.allFields[fieldName].serde;
|
|
38
|
+
let column;
|
|
39
|
+
let value;
|
|
40
|
+
if (serde instanceof joist_core.PolymorphicKeySerde) [column, value] = serde.columns.values().map((c) => [c, c.rowValue(newData)]).find(([, v]) => v !== void 0) ?? [];
|
|
41
|
+
else {
|
|
42
|
+
[column] = serde.columns;
|
|
43
|
+
value = column.rowValue(newData);
|
|
44
|
+
}
|
|
45
|
+
serde.setOnEntityFromRowData(oldData, new joist_core.PojoRowData([column ? { [column.columnName]: value } : {}]), 0);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
todo.deletes.forEach((newEntity) => {
|
|
49
|
+
const existing = em.findExistingInstance(newEntity.idTagged);
|
|
50
|
+
if (!existing) fail(`Expected to find existing entity for $ {e.idTagged}`);
|
|
51
|
+
(0, joist_core.getInstanceData)(existing).markDeletedBecauseNotFound();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
#syncReferences(entityTodos) {
|
|
56
|
+
const { em } = this;
|
|
57
|
+
Object.values(entityTodos).forEach((todo) => {
|
|
58
|
+
todo.inserts.forEach((newEntity) => {
|
|
59
|
+
const oldEntity = em.findExistingInstance(newEntity.idTagged);
|
|
60
|
+
getReferences(newEntity).forEach((r) => {
|
|
61
|
+
const other = r.isSet ? em.findExistingInstance(r.idTaggedMaybe) : void 0;
|
|
62
|
+
preloadReference(em, r.fieldName, oldEntity, other);
|
|
63
|
+
if (other) maybePreloadOtherSide(em, r.fieldName, oldEntity, other);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
todo.updates.forEach((newEntity) => {
|
|
67
|
+
const oldEntity = em.findExistingInstance(newEntity.idTagged);
|
|
68
|
+
getReferences(newEntity).filter((r) => newEntity.changes[r.fieldName].hasChanged).forEach((r) => {
|
|
69
|
+
const other = r.isSet ? em.findExistingInstance(r.idTaggedMaybe) : void 0;
|
|
70
|
+
preloadReference(em, r.fieldName, oldEntity, other);
|
|
71
|
+
if (other) maybePreloadOtherSide(em, r.fieldName, oldEntity, other);
|
|
72
|
+
const originalId = newEntity.changes[r.fieldName].originalValue;
|
|
73
|
+
const originalOther = originalId ? em.findExistingInstance(originalId) : void 0;
|
|
74
|
+
if (originalOther) maybePreloadOtherSide(em, r.fieldName, oldEntity, originalOther, true);
|
|
75
|
+
});
|
|
76
|
+
if ("deletedAt" in newEntity && newEntity.changes.deletedAt.hasChanged) getReferences(oldEntity).forEach((r) => {
|
|
77
|
+
const other = r.isSet ? em.findExistingInstance(r.idTaggedMaybe) : void 0;
|
|
78
|
+
if (other) {
|
|
79
|
+
const otherSide = getOtherSide(r.fieldName, oldEntity, other);
|
|
80
|
+
if (otherSide instanceof joist_core.OneToManyCollection) otherSide.resetIsLoaded();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
todo.deletes.forEach((newEntity) => {
|
|
85
|
+
const oldEntity = em.findExistingInstance(newEntity.idTagged);
|
|
86
|
+
getReferences(newEntity).forEach((r) => {
|
|
87
|
+
const entityOrId = (0, joist_core.getInstanceData)(oldEntity).data[r.fieldName];
|
|
88
|
+
const originalOther = entityOrId ? em.findExistingInstance((0, joist_core.isEntity)(entityOrId) ? entityOrId.idTagged : entityOrId) : void 0;
|
|
89
|
+
if (originalOther) maybePreloadOtherSide(em, r.fieldName, oldEntity, originalOther, true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
#syncManyToManys(joinRowTodos) {
|
|
95
|
+
const { em } = this;
|
|
96
|
+
const api = (0, joist_core.getEmInternalApi)(em);
|
|
97
|
+
Object.entries(joinRowTodos).forEach(([joinTable, todo]) => {
|
|
98
|
+
if (todo.m2m.otherEnum) return;
|
|
99
|
+
const preloads = /* @__PURE__ */ new Set();
|
|
100
|
+
processJoinRows(em, joinTable, todo.newRows, preloads, (oldEntity, entities) => entities.push(oldEntity));
|
|
101
|
+
processJoinRows(em, joinTable, todo.deletedRows, preloads, (oldEntity, entities) => entities.splice(entities.indexOf(oldEntity), 1));
|
|
102
|
+
preloads.values().forEach((r) => {
|
|
103
|
+
const id = r.entity.idTagged;
|
|
104
|
+
const entities = api.getPreloadedRelation(id, r.fieldName);
|
|
105
|
+
api.setPreloadedRelation(id, r.fieldName, [...new Set(entities)]);
|
|
106
|
+
r.preload();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
#syncEnumCollections(joinRowTodos) {
|
|
111
|
+
const { em } = this;
|
|
112
|
+
const api = (0, joist_core.getEmInternalApi)(em);
|
|
113
|
+
const touched = /* @__PURE__ */ new Set();
|
|
114
|
+
Object.values(joinRowTodos).forEach((todo) => {
|
|
115
|
+
if (!todo.m2m.otherEnum) return;
|
|
116
|
+
const { columnName, otherColumnName, fieldName } = todo.m2m;
|
|
117
|
+
const sync = (rows, add) => {
|
|
118
|
+
rows.forEach((row) => {
|
|
119
|
+
const newEntity = row.columns[columnName];
|
|
120
|
+
const enumId = row.columns[otherColumnName];
|
|
121
|
+
const oldEntity = em.findExistingInstance(newEntity.idTagged);
|
|
122
|
+
if (!oldEntity || oldEntity.isDeletedEntity) return;
|
|
123
|
+
const oldCollection = oldEntity[fieldName];
|
|
124
|
+
if (!oldCollection.isLoaded && !newEntity.isNewEntity) return;
|
|
125
|
+
const joinRows = api.joinRows(oldCollection);
|
|
126
|
+
if (add) joinRows.addPreloadedRow(oldCollection, void 0, oldEntity, enumId);
|
|
127
|
+
else joinRows.removePreloadedRow(oldCollection, oldEntity, enumId);
|
|
128
|
+
touched.add(oldCollection);
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
sync(todo.newRows, true);
|
|
132
|
+
sync(todo.deletedRows, false);
|
|
133
|
+
});
|
|
134
|
+
touched.forEach((oldCollection) => {
|
|
135
|
+
const codes = api.joinRows(oldCollection).getOthers(oldCollection.columnName, oldCollection.entity).map((id) => oldCollection.otherEnum.findById(id).code);
|
|
136
|
+
api.setPreloadedRelation(oldCollection.entity.idTagged, oldCollection.fieldName, codes);
|
|
137
|
+
oldCollection.preload();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
#preloadUnloadedRelations(entityTodos) {
|
|
141
|
+
const { em } = this;
|
|
142
|
+
Object.entries(entityTodos).forEach(([, todo]) => {
|
|
143
|
+
todo.inserts.forEach((newEntity) => {
|
|
144
|
+
const oldEntity = em.findExistingInstance(newEntity.idTagged);
|
|
145
|
+
getCollections(oldEntity).filter((r) => !r.isPreloaded).forEach((r) => {
|
|
146
|
+
(0, joist_core.getEmInternalApi)(em).setPreloadedRelation(oldEntity.idTagged, r.fieldName, []);
|
|
147
|
+
r.preload();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
function preloadReference(em, fieldName, entity, other) {
|
|
154
|
+
const reference = entity[fieldName];
|
|
155
|
+
reference.unload();
|
|
156
|
+
const { data } = (0, joist_core.getInstanceData)(entity);
|
|
157
|
+
data[fieldName] = other?.idTagged;
|
|
158
|
+
if (!entity.isDeletedEntity) reference.preload();
|
|
159
|
+
}
|
|
160
|
+
function getOtherSide(fieldName, entity, other) {
|
|
161
|
+
const meta = (0, joist_core.getMetadata)(entity);
|
|
162
|
+
const metas = /* @__PURE__ */ new Set([meta, ...meta.baseTypes]);
|
|
163
|
+
return (0, joist_core.getRelations)(other).values().filter((r) => r instanceof joist_core.OneToOneReferenceImpl || r instanceof joist_core.OneToManyCollection).find((r) => metas.has(r.otherMeta) && r.otherFieldName === fieldName);
|
|
164
|
+
}
|
|
165
|
+
function maybePreloadOtherSide(em, fieldName, entity, other, remove = false) {
|
|
166
|
+
const meta = (0, joist_core.getMetadata)(entity);
|
|
167
|
+
const otherSide = getOtherSide(fieldName, entity, other);
|
|
168
|
+
if (!otherSide) return;
|
|
169
|
+
if (otherSide.isPreloaded) return;
|
|
170
|
+
let otherEntities;
|
|
171
|
+
if (otherSide instanceof joist_core.OneToOneReferenceImpl) otherEntities = remove ? [] : [entity];
|
|
172
|
+
else if (otherSide instanceof joist_core.OneToManyCollection) otherEntities = em.getEntities(meta.cstr).values().filter((e) => !e.isDeletedEntity).filter((e) => e[otherSide.otherFieldName].idTaggedMaybe === other.idTagged).toArray();
|
|
173
|
+
else (0, joist_core.assertNever)(otherSide);
|
|
174
|
+
(0, joist_core.getEmInternalApi)(em).setPreloadedRelation(other.idTagged, otherSide.fieldName, otherEntities);
|
|
175
|
+
otherSide.preload();
|
|
176
|
+
if (otherSide instanceof joist_core.OneToManyCollection) otherSide.resetIsLoaded();
|
|
177
|
+
}
|
|
178
|
+
function processJoinRows(em, joinTable, rows, preloads, callback) {
|
|
179
|
+
const api = (0, joist_core.getEmInternalApi)(em);
|
|
180
|
+
rows.forEach((row) => {
|
|
181
|
+
const [[col1, e1], [col2, e2]] = Object.entries(row.columns);
|
|
182
|
+
[[
|
|
183
|
+
col1,
|
|
184
|
+
e1,
|
|
185
|
+
e2
|
|
186
|
+
], [
|
|
187
|
+
col2,
|
|
188
|
+
e2,
|
|
189
|
+
e1
|
|
190
|
+
]].forEach(([column, newEntity, newOther]) => {
|
|
191
|
+
const { idTagged: id } = newEntity;
|
|
192
|
+
const oldEntity = em.findExistingInstance(id);
|
|
193
|
+
if (oldEntity.isDeletedEntity) return;
|
|
194
|
+
const { fieldName } = getManyToManys(newEntity).find((r) => r.joinTableName === joinTable && r.columnName === column);
|
|
195
|
+
const oldM2m = oldEntity[fieldName];
|
|
196
|
+
let entities;
|
|
197
|
+
if (preloads.has(oldM2m)) entities = api.getPreloadedRelation(id, fieldName);
|
|
198
|
+
else if (oldM2m.isLoaded) entities = oldM2m.get;
|
|
199
|
+
else if (newEntity.isNewEntity) entities = [];
|
|
200
|
+
else fail(`Expected ${fieldName} to be loaded`);
|
|
201
|
+
callback(em.findExistingInstance(newOther.idTagged), entities);
|
|
202
|
+
api.setPreloadedRelation(id, fieldName, entities);
|
|
203
|
+
preloads.add(oldM2m);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function getReferences(entity) {
|
|
208
|
+
return (0, joist_core.getRelations)(entity).values().filter((r) => r instanceof joist_core.ManyToOneReferenceImpl || r instanceof joist_core.ReactiveReferenceImpl || r instanceof joist_core.PolymorphicReferenceImpl);
|
|
209
|
+
}
|
|
210
|
+
function getManyToManys(entity) {
|
|
211
|
+
return (0, joist_core.getRelations)(entity).values().filter((r) => r instanceof joist_core.ManyToManyCollection || r instanceof joist_core.ReactiveManyToManyImpl || r instanceof joist_core.ReactiveManyToManyOtherSideImpl);
|
|
212
|
+
}
|
|
213
|
+
function getCollections(entity) {
|
|
214
|
+
return (0, joist_core.getRelations)(entity).values().filter((r) => r instanceof joist_core.ManyToManyCollection || r instanceof joist_core.OneToManyCollection || r instanceof joist_core.OneToOneReferenceImpl || r instanceof joist_core.ReactiveManyToManyImpl || r instanceof joist_core.ReactiveManyToManyOtherSideImpl || r instanceof joist_core.EnumCollectionImpl);
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
exports.RunPlugin = RunPlugin;
|
|
218
|
+
|
|
219
|
+
//# sourceMappingURL=RunPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunPlugin.cjs","names":["Plugin","getEmInternalApi","#syncEntityData","#syncReferences","#syncManyToManys","#syncEnumCollections","#preloadUnloadedRelations","createRowFromEntityData","getInstanceData","getMetadata","PolymorphicKeySerde","PojoRowData","OneToManyCollection","isEntity","getRelations","OneToOneReferenceImpl","ManyToOneReferenceImpl","ReactiveReferenceImpl","PolymorphicReferenceImpl","ManyToManyCollection","ReactiveManyToManyImpl","ReactiveManyToManyOtherSideImpl","EnumCollectionImpl"],"sources":["../src/RunPlugin.ts"],"sourcesContent":["import {\n type Column,\n type Entity,\n type EntityManager,\n EnumCollectionImpl,\n type JoinRow,\n type JoinRowTodo,\n ManyToManyCollection,\n ManyToOneReferenceImpl,\n type MaybeAbstractEntityConstructor,\n OneToManyCollection,\n OneToOneReferenceImpl,\n Plugin,\n PojoRowData,\n PolymorphicKeySerde,\n PolymorphicReferenceImpl,\n ReactiveManyToManyImpl,\n ReactiveManyToManyOtherSideImpl,\n ReactiveReferenceImpl,\n type Todo,\n assertNever,\n createRowFromEntityData,\n getEmInternalApi,\n getInstanceData,\n getMetadata,\n getRelations,\n isEntity,\n} from \"joist-core\";\n\n/*\n * `run...` helpers use this plugin to mirror any changes made to their isolated entity manager inside to the original\n * entity manager they were passed. This allows changes to be synchronously reflected between the two entity managers\n * without needing to query the database.\n */\nexport class RunPlugin extends Plugin {\n // The em passed here is the target which we'll mirror changes to. The plugin should not be added to it, but rather\n // to the new em `run..` helpers create or by downstream ems created by implementation code\n constructor(public readonly em: EntityManager) {\n super();\n }\n\n maybeCloneForNewEm() {\n return this;\n }\n\n afterWrite(entityTodos: Record<string, Todo>, joinRowTodos: Record<string, JoinRowTodo>) {\n const api = getEmInternalApi(this.em);\n // We don't want any old preloaded data leaking into our changes, so we clear it out before we start as a precaution\n api.clearPreloadedRelations();\n // Likewise, any data loaders in memory will have stale data, so we clear them out as well\n api.clearDataloaders();\n this.#syncEntityData(entityTodos);\n this.#syncReferences(entityTodos);\n this.#syncManyToManys(joinRowTodos);\n this.#syncEnumCollections(joinRowTodos);\n this.#preloadUnloadedRelations(entityTodos);\n }\n\n #syncEntityData(entityTodos: Record<string, Todo>) {\n const { em } = this;\n Object.values(entityTodos).forEach((todo) => {\n todo.inserts.forEach((newEntity) => {\n const row = createRowFromEntityData(newEntity, { preferOriginalData: false });\n em.hydrate(newEntity.constructor as MaybeAbstractEntityConstructor<any>, [row]);\n });\n todo.updates.forEach((newEntity) => {\n const oldEntity = em.findExistingInstance(newEntity.idTagged);\n // This fail shouldn't really be possible, since any entity should either have been created:\n // * via factory or em.create in the original em\n // * by the new em inside the `run` call, in which case it'd be an insert instead of an update\n // * by a previous afterWrite call, which would have already been an insert and added to the original em\n // * by a previous `run` call, which would have already been an insert as well\n if (!oldEntity) fail(`Expected to find existing entity for $ {e.idTagged}`);\n const { data: newData } = getInstanceData(newEntity);\n const { data: oldData } = getInstanceData(oldEntity);\n const meta = getMetadata(newEntity);\n (newEntity as any).changes.fields\n .values()\n .filter((fieldName: string) => fieldName in newData)\n .filter((fieldName: string) => !!meta.allFields[fieldName].serde)\n .forEach((fieldName: string) => {\n // We're imitating a round trip to the database here, so we use our field's serde to map the value back\n // and forth.\n const serde = meta.allFields[fieldName].serde!;\n let column: Column | undefined;\n let value: any;\n if (serde instanceof PolymorphicKeySerde) {\n [column, value] =\n serde.columns\n .values()\n .map((c) => [c, c.rowValue(newData)] as const)\n .find(([, v]) => v !== undefined) ?? [];\n } else {\n [column] = serde.columns;\n // the 2nd and 3rd arguments are only used if the 4th argument is defined, so it's OK to pass undefined here\n value = column.rowValue(newData);\n }\n serde.setOnEntityFromRowData(oldData, new PojoRowData([column ? { [column.columnName]: value } : {}]), 0);\n });\n });\n todo.deletes.forEach((newEntity) => {\n const existing = em.findExistingInstance(newEntity.idTagged);\n // Again it shouldn't really be possible for a deletion to happen without the entity being present in the\n // original em, but just in case we'll skip if we don't find it\n if (!existing) fail(`Expected to find existing entity for $ {e.idTagged}`);\n getInstanceData(existing).markDeletedBecauseNotFound();\n });\n });\n }\n\n // Ensure m2o/rr/poly changes from the new em are reflected in the original em\n #syncReferences(entityTodos: Record<string, Todo>) {\n const { em } = this;\n Object.values(entityTodos).forEach((todo) => {\n todo.inserts.forEach((newEntity) => {\n const oldEntity = em.findExistingInstance(newEntity.idTagged)!;\n getReferences(newEntity).forEach((r) => {\n const other = r.isSet ? em.findExistingInstance(r.idTaggedMaybe) : undefined;\n preloadReference(em, r.fieldName, oldEntity, other);\n if (other) maybePreloadOtherSide(em, r.fieldName, oldEntity, other);\n });\n });\n todo.updates.forEach((newEntity) => {\n const oldEntity = em.findExistingInstance(newEntity.idTagged)!;\n getReferences(newEntity)\n .filter((r) => (newEntity as any).changes[r.fieldName].hasChanged)\n .forEach((r) => {\n const other = r.isSet ? em.findExistingInstance(r.idTaggedMaybe) : undefined;\n preloadReference(em, r.fieldName, oldEntity, other);\n if (other) maybePreloadOtherSide(em, r.fieldName, oldEntity, other);\n const originalId = (newEntity as any).changes[r.fieldName].originalValue;\n const originalOther = originalId ? em.findExistingInstance(originalId) : undefined;\n if (originalOther) maybePreloadOtherSide(em, r.fieldName, oldEntity, originalOther, true);\n });\n // If the entity was soft-deleted, then we need to clear out the caches for any o2m collections that contain it\n if (\"deletedAt\" in newEntity && (newEntity as any).changes.deletedAt.hasChanged) {\n getReferences(oldEntity).forEach((r) => {\n const other = r.isSet ? em.findExistingInstance(r.idTaggedMaybe) : undefined;\n if (other) {\n const otherSide = getOtherSide(r.fieldName, oldEntity, other);\n if (otherSide instanceof OneToManyCollection) otherSide.resetIsLoaded();\n }\n });\n }\n });\n todo.deletes.forEach((newEntity) => {\n const oldEntity = em.findExistingInstance(newEntity.idTagged)!;\n getReferences(newEntity).forEach((r) => {\n // Since both old and new entities are marked as deleted, we can't just go looking through their relations\n // for the other side's id since this will error. Likewise, we only care about the collection that this\n // entity used to belong to in the old em so we can remove it. So just grab the other id directly from the\n // old entity's data and then preload its other side relation.\n const entityOrId = getInstanceData(oldEntity).data[r.fieldName];\n const originalOther = entityOrId\n ? em.findExistingInstance(isEntity(entityOrId) ? entityOrId.idTagged : entityOrId)\n : undefined;\n if (originalOther) maybePreloadOtherSide(em, r.fieldName, oldEntity, originalOther, true);\n });\n });\n });\n }\n\n // Ensure m2m changes are propagated from the new em to the original em\n #syncManyToManys(joinRowTodos: Record<string, JoinRowTodo>) {\n const { em } = this;\n const api = getEmInternalApi(em);\n Object.entries(joinRowTodos).forEach(([joinTable, todo]) => {\n // Enum m2ms (EnumCollections) aren't entity-to-entity, so there's nothing to mirror between ems.\n if (todo.m2m.otherEnum) return;\n const preloads = new Set<ManyToManyCollection<Entity, Entity>>();\n processJoinRows(em, joinTable, todo.newRows, preloads, (oldEntity, entities) => entities.push(oldEntity));\n processJoinRows(em, joinTable, todo.deletedRows, preloads, (oldEntity, entities) =>\n entities.splice(entities.indexOf(oldEntity), 1),\n );\n // Since multiple join rows could reference the same m2m, our processJoinRows doesn't actually call preload() so\n // we need to do it now\n preloads.values().forEach((r) => {\n const id = r.entity.idTagged;\n const entities = api.getPreloadedRelation(id, r.fieldName) as Entity[];\n // unique our entities in case somehow an entity was inserted by multiple join rows\n api.setPreloadedRelation(id, r.fieldName, [...new Set(entities)]);\n r.preload();\n });\n });\n }\n\n // Ensure enum m2m (EnumCollection) membership changes are propagated from the new em to the original em\n #syncEnumCollections(joinRowTodos: Record<string, JoinRowTodo>) {\n const { em } = this;\n const api = getEmInternalApi(em);\n const touched = new Set<EnumCollectionImpl<Entity, any>>();\n Object.values(joinRowTodos).forEach((todo) => {\n // Only enum m2ms; entity-to-entity m2ms are handled by `#syncManyToManys`.\n if (!todo.m2m.otherEnum) return;\n const { columnName, otherColumnName, fieldName } = todo.m2m;\n const sync = (rows: JoinRow[], add: boolean) => {\n rows.forEach((row) => {\n const newEntity = row.columns[columnName] as Entity;\n const enumId = row.columns[otherColumnName] as number;\n const oldEntity = em.findExistingInstance(newEntity.idTagged);\n if (!oldEntity || oldEntity.isDeletedEntity) return;\n const oldCollection = (oldEntity as any)[fieldName] as EnumCollectionImpl<Entity, any>;\n // Only mirror collections the original em has loaded (or new entities, whose rows are all\n // adds); otherwise a later `.load()` will read the (same-txn) db and see the change itself.\n if (!oldCollection.isLoaded && !newEntity.isNewEntity) return;\n const joinRows = api.joinRows(oldCollection);\n if (add) {\n joinRows.addPreloadedRow(oldCollection, undefined, oldEntity, enumId);\n } else {\n joinRows.removePreloadedRow(oldCollection, oldEntity, enumId);\n }\n touched.add(oldCollection);\n });\n };\n sync(todo.newRows, true);\n sync(todo.deletedRows, false);\n });\n // Re-publish each touched collection's codes and mark it loaded.\n touched.forEach((oldCollection) => {\n const joinRows = api.joinRows(oldCollection);\n const codes = (joinRows.getOthers(oldCollection.columnName, oldCollection.entity) as number[]).map(\n (id) => oldCollection.otherEnum!.findById(id)!.code,\n );\n api.setPreloadedRelation(oldCollection.entity.idTagged, oldCollection.fieldName, codes);\n oldCollection.preload();\n });\n }\n\n // Make sure any unloaded relations on net new entities are marked as loaded. We should have already preloaded all\n // concrete references in a previous step. So we just need to load collections (plus o2os) if they haven't already\n // been preloaded by another step. Since nothing else preloaded them, they must have no data so we can just set\n // them to an empty array.\n #preloadUnloadedRelations(entityTodos: Record<string, Todo>) {\n const { em } = this;\n Object.entries(entityTodos).forEach(([, todo]) => {\n todo.inserts.forEach((newEntity) => {\n const oldEntity = em.findExistingInstance(newEntity.idTagged)!;\n getCollections(oldEntity)\n .filter((r) => !r.isPreloaded)\n .forEach((r) => {\n getEmInternalApi(em).setPreloadedRelation(oldEntity.idTagged, r.fieldName, []);\n r.preload();\n });\n });\n });\n }\n}\n\n// References that represent one (or more) foreign keys directly on the entity\ntype ConcreteReference =\n | ManyToOneReferenceImpl<Entity, Entity, any>\n | ReactiveReferenceImpl<Entity, Entity, any, any>\n | PolymorphicReferenceImpl<Entity, Entity, any>;\n\nfunction preloadReference(em: EntityManager, fieldName: string, entity: Entity, other: Entity | undefined) {\n // Preload for concrete references doesn't make us of the global preloaded cache. It just looks at its owner's data\n // to get a key, then checks if that entity is already in the em and uses that if so. So we just need to set the\n // owner's data to have the correct key then we can call preload since all entities should already be in the original\n // em\n const reference = (entity as any)[fieldName] as ConcreteReference;\n (reference as any).unload();\n const { data } = getInstanceData(entity);\n data[fieldName] = other?.idTagged;\n if (!entity.isDeletedEntity) reference.preload();\n}\n\nfunction getOtherSide(fieldName: string, entity: Entity, other: Entity) {\n const meta = getMetadata(entity);\n const metas = new Set([meta, ...meta.baseTypes]);\n return getRelations(other)\n .values()\n .filter((r) => r instanceof OneToOneReferenceImpl || r instanceof OneToManyCollection)\n .find((r) => metas.has(r.otherMeta) && r.otherFieldName === fieldName);\n}\n\nfunction maybePreloadOtherSide(\n em: EntityManager,\n fieldName: string,\n entity: Entity,\n other: Entity,\n remove: boolean = false,\n): void {\n const meta = getMetadata(entity);\n const otherSide = getOtherSide(fieldName, entity, other);\n // If our other side is a large o2m then we can just ignore it, since it isn't loadable regardless\n if (!otherSide) return;\n // Since our preload scans the entire em, we only need to run it once per collection/o2o. We clear out preloads\n // when we start the afterWrite, so if anything is preloaded we know we put it there.\n if (otherSide.isPreloaded) return;\n let otherEntities: Entity[];\n if (otherSide instanceof OneToOneReferenceImpl) {\n otherEntities = remove ? [] : [entity];\n } else if (otherSide instanceof OneToManyCollection) {\n // Scan the entire em for (non-deleted) entities of our type that reference the other side\n otherEntities = em\n .getEntities(meta.cstr)\n .values()\n .filter((e) => !e.isDeletedEntity)\n .filter((e) => ((e as any)[otherSide.otherFieldName] as ConcreteReference).idTaggedMaybe === other.idTagged)\n .toArray();\n } else {\n assertNever(otherSide);\n }\n // We don't need to worry about order here because o2ms do their own sorting internally and o2os are inherently\n // unordered (since it's just a single entity)\n getEmInternalApi(em).setPreloadedRelation(other.idTagged, otherSide.fieldName, otherEntities);\n otherSide.preload();\n // This method is confusingly name, what it actually does is clear out the sorted caches that m2m uses to avoid\n // sorting on every `.get` call. Since we just preloaded the collection with new data, we know these caches need to\n // be cleared\n if (otherSide instanceof OneToManyCollection) otherSide.resetIsLoaded();\n}\n\nfunction processJoinRows(\n em: EntityManager,\n joinTable: string,\n rows: JoinRow[],\n preloads: Set<ManyToManyCollection<Entity, Entity>>,\n callback: (oldEntity: Entity, entities: Entity[]) => void,\n) {\n const api = getEmInternalApi(em);\n rows.forEach((row) => {\n // A join row's `columns` is always an object with two key/value pairs, one for each side of the m2m.\n // This only runs for entity-to-entity m2ms (enum m2ms are skipped by the caller), so both are entities.\n const [[col1, e1], [col2, e2]] = Object.entries(row.columns) as [[string, Entity], [string, Entity]];\n (\n [\n // Each join row needs to append/remove from both sides of the m2m. So we need to do the same operation once for\n // each side.\n [col1, e1, e2],\n [col2, e2, e1],\n ] as const\n ).forEach(([column, newEntity, newOther]) => {\n const { idTagged: id } = newEntity;\n const oldEntity = em.findExistingInstance(id)!;\n if (oldEntity.isDeletedEntity) return;\n const newM2m = getManyToManys(newEntity).find((r) => r.joinTableName === joinTable && r.columnName === column)!;\n const { fieldName } = newM2m;\n const oldM2m = (oldEntity as any)[fieldName] as ManyToManyCollection<Entity, Entity>;\n let entities: Entity[];\n if (preloads.has(oldM2m)) {\n // If a previous join row has already preloaded this relation, then we can just append/remove from the\n // existing preloaded data.\n entities = api.getPreloadedRelation(id, fieldName) as Entity[];\n } else if (oldM2m.isLoaded) {\n // The order here is important. M2ms are returned in the order their join rows were inserted, so we need to\n // make sure we match that behavior here. So we get all the extant rows first and then append each new row\n // in order from there. Removals are fine since they'll modify the array in place and the correct order will\n // be preserved.\n entities = oldM2m.get;\n } else if (newEntity.isNewEntity) {\n // If this is a new entity, then all the join rows referencing it must also be inserts. So we can just use an\n // empty array initially and inserts will be appended to it.\n entities = [];\n } else {\n fail(`Expected ${fieldName} to be loaded`);\n }\n callback(em.findExistingInstance(newOther.idTagged)!, entities);\n api.setPreloadedRelation(id, fieldName, entities);\n // We only need to preload the m2m once, but multiple join rows could reference it, so we keep track of which m2ms\n // need to be preloaded as we work, then actually call preload() at the end once we're done.\n preloads.add(oldM2m);\n });\n });\n}\n\nfunction getReferences(entity: Entity): IteratorObject<ConcreteReference> {\n return getRelations(entity)\n .values()\n .filter(\n (r) =>\n r instanceof ManyToOneReferenceImpl ||\n r instanceof ReactiveReferenceImpl ||\n r instanceof PolymorphicReferenceImpl,\n );\n}\n\nfunction getManyToManys(\n entity: Entity,\n): IteratorObject<\n | ManyToManyCollection<Entity, Entity>\n | ReactiveManyToManyImpl<any, any, any>\n | ReactiveManyToManyOtherSideImpl<any, any>\n> {\n return getRelations(entity)\n .values()\n .filter(\n (r) =>\n r instanceof ManyToManyCollection ||\n r instanceof ReactiveManyToManyImpl ||\n r instanceof ReactiveManyToManyOtherSideImpl,\n );\n}\n\nfunction getCollections(entity: Entity) {\n return getRelations(entity)\n .values()\n .filter(\n (r) =>\n r instanceof ManyToManyCollection ||\n r instanceof OneToManyCollection ||\n r instanceof OneToOneReferenceImpl ||\n r instanceof ReactiveManyToManyImpl ||\n r instanceof ReactiveManyToManyOtherSideImpl ||\n r instanceof EnumCollectionImpl,\n );\n}\n"],"mappings":";;;AAkCA,IAAa,YAAb,cAA+BA,WAAAA,OAAO;CAGR;CAA5B,YAAY,IAAmC;EAC7C,MAAM;EADoB,KAAA,KAAA;CAE5B;CAEA,qBAAqB;EACnB,OAAO;CACT;CAEA,WAAW,aAAmC,cAA2C;EACvF,MAAM,OAAA,GAAMC,WAAAA,iBAAAA,CAAiB,KAAK,EAAE;EAEpC,IAAI,wBAAwB;EAE5B,IAAI,iBAAiB;EACrB,KAAKC,gBAAgB,WAAW;EAChC,KAAKC,gBAAgB,WAAW;EAChC,KAAKC,iBAAiB,YAAY;EAClC,KAAKC,qBAAqB,YAAY;EACtC,KAAKC,0BAA0B,WAAW;CAC5C;CAEA,gBAAgB,aAAmC;EACjD,MAAM,EAAE,OAAO;EACf,OAAO,OAAO,WAAW,CAAC,CAAC,SAAS,SAAS;GAC3C,KAAK,QAAQ,SAAS,cAAc;IAClC,MAAM,OAAA,GAAMC,WAAAA,wBAAAA,CAAwB,WAAW,EAAE,oBAAoB,MAAM,CAAC;IAC5E,GAAG,QAAQ,UAAU,aAAoD,CAAC,GAAG,CAAC;GAChF,CAAC;GACD,KAAK,QAAQ,SAAS,cAAc;IAClC,MAAM,YAAY,GAAG,qBAAqB,UAAU,QAAQ;IAM5D,IAAI,CAAC,WAAW,KAAK,qDAAqD;IAC1E,MAAM,EAAE,MAAM,aAAA,GAAYC,WAAAA,gBAAAA,CAAgB,SAAS;IACnD,MAAM,EAAE,MAA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AAa,MAAM,CAAC,CACxB,OAAO,CAAC,CACR,QACE,MACC,aAAaK,WAAAA,wBACb,aAAaP,WAAAA,uBACb,aAAaG,WAAAA,yBACb,aAAaK,WAAAA,0BACb,aAAaC,WAAAA,mCACb,aAAaC,WAAAA,kBACjB;AACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EntityManager, JoinRowTodo, Plugin, Todo } from "joist-core";
|
|
2
|
+
//#region src/RunPlugin.d.ts
|
|
3
|
+
declare class RunPlugin extends Plugin {
|
|
4
|
+
#private;
|
|
5
|
+
readonly em: EntityManager;
|
|
6
|
+
constructor(em: EntityManager);
|
|
7
|
+
maybeCloneForNewEm(): this;
|
|
8
|
+
afterWrite(entityTodos: Record<string, Todo>, joinRowTodos: Record<string, JoinRowTodo>): void;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { RunPlugin };
|
|
12
|
+
//# sourceMappingURL=RunPlugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunPlugin.d.cts","names":[],"sources":["../src/RunPlugin.ts"],"mappings":";;cAkCa,kBAAkB;;WAGD,IAAI;EAAhC,YAA4B,IAAI;EAIhC;EAIA,WAAW,aAAa,eAAe,OAAO,cAAc,eAAe"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EntityManager, JoinRowTodo, Plugin, Todo } from "joist-core";
|
|
2
|
+
//#region src/RunPlugin.d.ts
|
|
3
|
+
declare class RunPlugin extends Plugin {
|
|
4
|
+
#private;
|
|
5
|
+
readonly em: EntityManager;
|
|
6
|
+
constructor(em: EntityManager);
|
|
7
|
+
maybeCloneForNewEm(): this;
|
|
8
|
+
afterWrite(entityTodos: Record<string, Todo>, joinRowTodos: Record<string, JoinRowTodo>): void;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { RunPlugin };
|
|
12
|
+
//# sourceMappingURL=RunPlugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunPlugin.d.mts","names":[],"sources":["../src/RunPlugin.ts"],"mappings":";;cAkCa,kBAAkB;;WAGD,IAAI;EAAhC,YAA4B,IAAI;EAIhC;EAIA,WAAW,aAAa,eAAe,OAAO,cAAc,eAAe"}
|