@forklaunch/core 1.6.5 → 1.6.7

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.
@@ -1200,20 +1200,25 @@ function wrapEmWithTenantContext(em, tenantId) {
1200
1200
  if (tenantId) {
1201
1201
  em.setFilterParams("tenant", { tenantId });
1202
1202
  }
1203
- return new Proxy(em, {
1203
+ const proxy = new Proxy(em, {
1204
1204
  get(target, prop, receiver) {
1205
1205
  const value = Reflect.get(target, prop, receiver);
1206
1206
  if (typeof value !== "function") {
1207
1207
  return value;
1208
1208
  }
1209
1209
  return function tenantBoundMethod(...args) {
1210
- return withEncryptionContext(
1210
+ const result = withEncryptionContext(
1211
1211
  tenantId,
1212
1212
  () => value.apply(target, args)
1213
1213
  );
1214
+ return rebind(result, target, proxy);
1214
1215
  };
1215
1216
  }
1216
1217
  });
1218
+ return proxy;
1219
+ }
1220
+ function rebind(result, target, proxy) {
1221
+ return result === target ? proxy : result;
1217
1222
  }
1218
1223
  export {
1219
1224
  ComplianceLevel,