joist-core 2.4.0-next.39 → 2.4.0-next.40
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 -3
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +18 -12
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +18 -12
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +15 -3
- 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
|
@@ -527,14 +527,14 @@ var EntityManager = class EntityManager {
|
|
|
527
527
|
const todo = /* @__PURE__ */ new Set();
|
|
528
528
|
const skipMap = /* @__PURE__ */ new WeakMap();
|
|
529
529
|
await crawl(todo, skipMap, Array.isArray(entityOrArray) ? entityOrArray : [entityOrArray], deep, {
|
|
530
|
-
skipIf,
|
|
530
|
+
skipIf: (entity) => invokeCloneCallback(skipIf, entity) ?? false,
|
|
531
531
|
skip
|
|
532
532
|
});
|
|
533
533
|
const deferredRelations = [];
|
|
534
534
|
const overrideMap = /* @__PURE__ */ new WeakMap();
|
|
535
535
|
const clones = [...todo].map((entity) => {
|
|
536
536
|
const skip = skipMap.get(entity) ?? [];
|
|
537
|
-
const override = overrides
|
|
537
|
+
const override = invokeCloneCallback(overrides, entity) ?? {};
|
|
538
538
|
overrideMap.set(entity, override);
|
|
539
539
|
const meta = require_EntityMetadata.getMetadata(entity);
|
|
540
540
|
const copy = Object.fromEntries(Object.values(meta.allFields).map((f) => {
|
|
@@ -587,7 +587,7 @@ var EntityManager = class EntityManager {
|
|
|
587
587
|
deferredRelations.forEach(([source, fieldName, target]) => {
|
|
588
588
|
entityToClone.get(source)[fieldName].set(entityToClone.get(target));
|
|
589
589
|
});
|
|
590
|
-
if (postClone) await Promise.all(clones.map((
|
|
590
|
+
if (postClone) await Promise.all(clones.map((pair) => invokeCloneCallback(postClone, ...pair)));
|
|
591
591
|
return Array.isArray(entityOrArray) ? entityOrArray.filter((original) => entityToClone.has(original)).map((original) => entityToClone.get(original)) : clones[0] ? clones[0][1] : require_utils.fail("no entities were cloned given the provided options");
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
@@ -1775,6 +1775,18 @@ function recalcSynchronousDerivedFields(todos) {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
}
|
|
1777
1777
|
}
|
|
1778
|
+
/** Invokes only the most specific handler, falling back to a base type when no concrete-type handler exists. */
|
|
1779
|
+
function invokeCloneCallback(callback, ...args) {
|
|
1780
|
+
if (typeof callback === "function") return callback(...args);
|
|
1781
|
+
if (!callback) return void 0;
|
|
1782
|
+
const handlers = callback;
|
|
1783
|
+
let meta = require_EntityMetadata.getMetadata(args[0]);
|
|
1784
|
+
while (meta) {
|
|
1785
|
+
const handler = Object.hasOwn(handlers, meta.type) ? handlers[meta.type] : void 0;
|
|
1786
|
+
if (handler) return handler(...args);
|
|
1787
|
+
meta = meta.baseType ? require_configure.getMetadataForType(meta.baseType) : void 0;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1778
1790
|
/** Recursively crawls through `entity`, with the given populate `deep` hint, and adds anything found to `found`. */
|
|
1779
1791
|
async function crawl(found, skipMap, entities, deep, opts = {}) {
|
|
1780
1792
|
const { skipIf = () => false } = opts ?? {};
|