@snowtop/ent 0.1.0-alpha144 → 0.1.0-alpha145

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.
Files changed (2) hide show
  1. package/core/ent.js +4 -3
  2. package/package.json +1 -1
package/core/ent.js CHANGED
@@ -509,11 +509,12 @@ async function doFieldPrivacy(viewer, ent, data, options) {
509
509
  }
510
510
  const promises = [];
511
511
  let somethingChanged = false;
512
+ const clone = { ...data };
512
513
  const origData = {
513
514
  ...data,
514
515
  };
515
516
  for (const [k, policy] of options.fieldPrivacy) {
516
- const curr = data[k];
517
+ const curr = clone[k];
517
518
  if (curr === null || curr === undefined) {
518
519
  continue;
519
520
  }
@@ -521,7 +522,7 @@ async function doFieldPrivacy(viewer, ent, data, options) {
521
522
  // don't do anything if key is null or for some reason missing
522
523
  const r = await (0, privacy_1.applyPrivacyPolicy)(viewer, policy, ent);
523
524
  if (!r) {
524
- data[k] = null;
525
+ clone[k] = null;
525
526
  somethingChanged = true;
526
527
  }
527
528
  })());
@@ -529,7 +530,7 @@ async function doFieldPrivacy(viewer, ent, data, options) {
529
530
  await Promise.all(promises);
530
531
  if (somethingChanged) {
531
532
  // have to create new instance
532
- const ent = new options.ent(viewer, data);
533
+ const ent = new options.ent(viewer, clone);
533
534
  ent.__setRawDBData(origData);
534
535
  return ent;
535
536
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha144",
3
+ "version": "0.1.0-alpha145",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",