@salesforce/core-bundle 7.3.3 → 7.3.10

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/lib/pino-file.js CHANGED
@@ -516,11 +516,19 @@ var require_redactor = __commonJS({
516
516
  ${strictImpl(strict, serialize)}
517
517
  }
518
518
  const { censor, secret } = this
519
+ const originalSecret = {}
520
+ const secretKeys = Object.keys(secret)
521
+ for (var i = 0; i < secretKeys.length; i++) {
522
+ originalSecret[secretKeys[i]] = secret[secretKeys[i]]
523
+ }
524
+
519
525
  ${redactTmpl(secret, isCensorFct, censorFctTakesPath)}
520
526
  this.compileRestore()
521
527
  ${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)}
528
+ this.secret = originalSecret
522
529
  ${resultTmpl(serialize)}
523
530
  `).bind(state);
531
+ redact.state = state;
524
532
  if (serialize === false) {
525
533
  redact.restore = (o) => state.restore(o);
526
534
  }
@@ -606,7 +614,7 @@ var require_modifiers = __commonJS({
606
614
  nestedRestore
607
615
  };
608
616
  function groupRestore({ keys, values, target }) {
609
- if (target == null)
617
+ if (target == null || typeof target === "string")
610
618
  return;
611
619
  const length = keys.length;
612
620
  for (var i = 0; i < length; i++) {
@@ -616,8 +624,8 @@ var require_modifiers = __commonJS({
616
624
  }
617
625
  function groupRedact(o, path, censor, isCensorFct, censorFctTakesPath) {
618
626
  const target = get(o, path);
619
- if (target == null)
620
- return { keys: null, values: null, target: null, flat: true };
627
+ if (target == null || typeof target === "string")
628
+ return { keys: null, values: null, target, flat: true };
621
629
  const keys = Object.keys(target);
622
630
  const keysLength = keys.length;
623
631
  const pathLength = path.length;
@@ -637,27 +645,14 @@ var require_modifiers = __commonJS({
637
645
  }
638
646
  return { keys, values, target, flat: true };
639
647
  }
640
- function nestedRestore(arr) {
641
- const length = arr.length;
642
- for (var i = 0; i < length; i++) {
643
- const { key, target, value, level } = arr[i];
644
- if (level === 0 || level === 1) {
645
- if (has(target, key)) {
646
- target[key] = value;
647
- }
648
- if (typeof target === "object") {
649
- const targetKeys = Object.keys(target);
650
- for (var j = 0; j < targetKeys.length; j++) {
651
- const tKey = targetKeys[j];
652
- const subTarget = target[tKey];
653
- if (has(subTarget, key)) {
654
- subTarget[key] = value;
655
- }
656
- }
657
- }
658
- } else {
659
- restoreNthLevel(key, target, value, level);
648
+ function nestedRestore(instructions) {
649
+ for (let i = 0; i < instructions.length; i++) {
650
+ const { target, path, value } = instructions[i];
651
+ let current = target;
652
+ for (let i2 = path.length - 1; i2 > 0; i2--) {
653
+ current = current[path[i2]];
660
654
  }
655
+ current[path[0]] = value;
661
656
  }
662
657
  }
663
658
  function nestedRedact(store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
@@ -668,17 +663,14 @@ var require_modifiers = __commonJS({
668
663
  const keysLength = keys.length;
669
664
  for (var i = 0; i < keysLength; i++) {
670
665
  const key = keys[i];
671
- const { value, parent, exists, level } = specialSet(target, key, path, ns, censor, isCensorFct, censorFctTakesPath);
672
- if (exists === true && parent !== null) {
673
- store.push({ key: ns[ns.length - 1], target: parent, value, level });
674
- }
666
+ specialSet(store, target, key, path, ns, censor, isCensorFct, censorFctTakesPath);
675
667
  }
676
668
  return store;
677
669
  }
678
670
  function has(obj, prop) {
679
671
  return obj !== void 0 && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
680
672
  }
681
- function specialSet(o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
673
+ function specialSet(store, o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
682
674
  const afterPathLen = afterPath.length;
683
675
  const lastPathIndex = afterPathLen - 1;
684
676
  const originalKey = k;
@@ -687,20 +679,21 @@ var require_modifiers = __commonJS({
687
679
  var nv;
688
680
  var ov;
689
681
  var oov = null;
690
- var exists = true;
691
682
  var wc = null;
692
683
  var kIsWc;
693
684
  var wcov;
694
685
  var consecutive = false;
695
686
  var level = 0;
687
+ var depth = 0;
688
+ var redactPathCurrent = tree();
696
689
  ov = n = o[k];
697
690
  if (typeof n !== "object")
698
- return { value: null, parent: null, exists };
691
+ return;
699
692
  while (n != null && ++i < afterPathLen) {
693
+ depth += 1;
700
694
  k = afterPath[i];
701
695
  oov = ov;
702
696
  if (k !== "*" && !wc && !(typeof n === "object" && k in n)) {
703
- exists = false;
704
697
  break;
705
698
  }
706
699
  if (k === "*") {
@@ -719,8 +712,9 @@ var require_modifiers = __commonJS({
719
712
  wcov = n[wck];
720
713
  kIsWc = k === "*";
721
714
  if (consecutive) {
715
+ redactPathCurrent = node(redactPathCurrent, wck, depth);
722
716
  level = i;
723
- ov = iterateNthLevel(wcov, level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, exists);
717
+ ov = iterateNthLevel(wcov, level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
724
718
  } else {
725
719
  if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
726
720
  if (kIsWc) {
@@ -730,12 +724,18 @@ var require_modifiers = __commonJS({
730
724
  }
731
725
  nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
732
726
  if (kIsWc) {
727
+ const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
728
+ store.push(rv);
733
729
  n[wck] = nv;
734
730
  } else {
735
731
  if (wcov[k] === nv) {
736
- exists = false;
732
+ } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
733
+ redactPathCurrent = node(redactPathCurrent, wck, depth);
737
734
  } else {
738
- wcov[k] = nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov ? wcov[k] : nv;
735
+ redactPathCurrent = node(redactPathCurrent, wck, depth);
736
+ const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, o[originalKey]);
737
+ store.push(rv);
738
+ wcov[k] = nv;
739
739
  }
740
740
  }
741
741
  }
@@ -744,17 +744,21 @@ var require_modifiers = __commonJS({
744
744
  wc = null;
745
745
  } else {
746
746
  ov = n[k];
747
+ redactPathCurrent = node(redactPathCurrent, k, depth);
747
748
  nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
748
- n[k] = has(n, k) && nv === ov || nv === void 0 && censor !== void 0 ? n[k] : nv;
749
+ if (has(n, k) && nv === ov || nv === void 0 && censor !== void 0) {
750
+ } else {
751
+ const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
752
+ store.push(rv);
753
+ n[k] = nv;
754
+ }
749
755
  n = n[k];
750
756
  }
751
757
  if (typeof n !== "object")
752
758
  break;
753
759
  if (ov === oov || typeof ov === "undefined") {
754
- exists = false;
755
760
  }
756
761
  }
757
- return { value: ov, parent: oov, exists, level };
758
762
  }
759
763
  function get(o, p) {
760
764
  var i = -1;
@@ -765,7 +769,7 @@ var require_modifiers = __commonJS({
765
769
  }
766
770
  return n;
767
771
  }
768
- function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, exists) {
772
+ function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
769
773
  if (level === 0) {
770
774
  if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
771
775
  if (kIsWc) {
@@ -775,36 +779,51 @@ var require_modifiers = __commonJS({
775
779
  }
776
780
  nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
777
781
  if (kIsWc) {
782
+ const rv = restoreInstr(redactPathCurrent, ov, parent);
783
+ store.push(rv);
778
784
  n[wck] = nv;
779
785
  } else {
780
786
  if (wcov[k] === nv) {
781
- exists = false;
787
+ } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
782
788
  } else {
783
- wcov[k] = nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov ? wcov[k] : nv;
789
+ const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, parent);
790
+ store.push(rv);
791
+ wcov[k] = nv;
784
792
  }
785
793
  }
786
794
  }
787
- return ov;
788
795
  }
789
796
  for (const key in wcov) {
790
797
  if (typeof wcov[key] === "object") {
791
- var temp = iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, exists);
792
- return temp;
798
+ redactPathCurrent = node(redactPathCurrent, key, depth);
799
+ iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
793
800
  }
794
801
  }
795
802
  }
796
- function restoreNthLevel(key, target, value, level) {
797
- if (level === 0) {
798
- if (has(target, key)) {
799
- target[key] = value;
800
- }
801
- return;
802
- }
803
- for (const objKey in target) {
804
- if (typeof target[objKey] === "object") {
805
- restoreNthLevel(key, target[objKey], value, level - 1);
806
- }
807
- }
803
+ function tree() {
804
+ return { parent: null, key: null, children: [], depth: 0 };
805
+ }
806
+ function node(parent, key, depth) {
807
+ if (parent.depth === depth) {
808
+ return node(parent.parent, key, depth);
809
+ }
810
+ var child = {
811
+ parent,
812
+ key,
813
+ depth,
814
+ children: []
815
+ };
816
+ parent.children.push(child);
817
+ return child;
818
+ }
819
+ function restoreInstr(node2, value, target) {
820
+ let current = node2;
821
+ const path = [];
822
+ do {
823
+ path.push(current.key);
824
+ current = current.parent;
825
+ } while (current.parent != null);
826
+ return { path, value, target };
808
827
  }
809
828
  }
810
829
  });
@@ -815,10 +834,13 @@ var require_restorer = __commonJS({
815
834
  "use strict";
816
835
  var { groupRestore, nestedRestore } = require_modifiers();
817
836
  module2.exports = restorer;
818
- function restorer({ secret, wcLen }) {
837
+ function restorer() {
819
838
  return function compileRestore() {
820
- if (this.restore)
839
+ if (this.restore) {
840
+ this.restore.state.secret = this.secret;
821
841
  return;
842
+ }
843
+ const { secret, wcLen } = this;
822
844
  const paths = Object.keys(secret);
823
845
  const resetters = resetTmpl(secret, paths);
824
846
  const hasWildcards = wcLen > 0;
@@ -827,6 +849,7 @@ var require_restorer = __commonJS({
827
849
  "o",
828
850
  restoreTmpl(resetters, paths, hasWildcards)
829
851
  ).bind(state);
852
+ this.restore.state = state;
830
853
  };
831
854
  }
832
855
  function resetTmpl(secret, paths) {
@@ -850,9 +873,11 @@ var require_restorer = __commonJS({
850
873
  for (var i = len - 1; i >= ${paths.length}; i--) {
851
874
  const k = keys[i]
852
875
  const o = secret[k]
853
- if (o.flat === true) this.groupRestore(o)
854
- else this.nestedRestore(o)
855
- secret[k] = null
876
+ if (o) {
877
+ if (o.flat === true) this.groupRestore(o)
878
+ else this.nestedRestore(o)
879
+ secret[k] = null
880
+ }
856
881
  }
857
882
  ` : "";
858
883
  return `
@@ -923,7 +948,7 @@ var require_fast_redact = __commonJS({
923
948
  return serialize || noop;
924
949
  validate({ paths, serialize, censor });
925
950
  const { wildcards, wcLen, secret } = parse({ paths, censor });
926
- const compileRestore = restorer({ secret, wcLen });
951
+ const compileRestore = restorer();
927
952
  const strict = "strict" in opts ? opts.strict : true;
928
953
  return redactor({ secret, wcLen, serialize, strict, isCensorFct, censorFctTakesPath }, state({
929
954
  secret,
@@ -1300,6 +1325,7 @@ var require_sonic_boom = __commonJS({
1300
1325
  }
1301
1326
  return;
1302
1327
  }
1328
+ const reopening = sonic._reopening;
1303
1329
  sonic.fd = fd;
1304
1330
  sonic.file = file;
1305
1331
  sonic._reopening = false;
@@ -1310,11 +1336,13 @@ var require_sonic_boom = __commonJS({
1310
1336
  } else {
1311
1337
  sonic.emit("ready");
1312
1338
  }
1313
- if (sonic._reopening || sonic.destroyed) {
1339
+ if (sonic.destroyed) {
1314
1340
  return;
1315
1341
  }
1316
1342
  if (!sonic._writing && sonic._len > sonic.minLength || sonic._flushPending) {
1317
1343
  sonic._actualWrite();
1344
+ } else if (reopening) {
1345
+ process.nextTick(() => sonic.emit("drain"));
1318
1346
  }
1319
1347
  }
1320
1348
  const flags = sonic.append ? "a" : "w";
@@ -1419,11 +1447,9 @@ var require_sonic_boom = __commonJS({
1419
1447
  return;
1420
1448
  }
1421
1449
  this.emit("write", n);
1422
- this._len -= n;
1423
- if (this._len < 0) {
1424
- this._len = 0;
1425
- }
1426
- this._writingBuf = this._writingBuf.slice(n);
1450
+ const releasedBufObj = releaseWritingBuf(this._writingBuf, this._len, n);
1451
+ this._len = releasedBufObj.len;
1452
+ this._writingBuf = releasedBufObj.writingBuf;
1427
1453
  if (this._writingBuf.length) {
1428
1454
  if (!this.sync) {
1429
1455
  fsWrite();
@@ -1432,8 +1458,9 @@ var require_sonic_boom = __commonJS({
1432
1458
  try {
1433
1459
  do {
1434
1460
  const n2 = fsWriteSync();
1435
- this._len -= n2;
1436
- this._writingBuf = this._writingBuf.slice(n2);
1461
+ const releasedBufObj2 = releaseWritingBuf(this._writingBuf, this._len, n2);
1462
+ this._len = releasedBufObj2.len;
1463
+ this._writingBuf = releasedBufObj2.writingBuf;
1437
1464
  } while (this._writingBuf.length);
1438
1465
  } catch (err2) {
1439
1466
  this.release(err2);
@@ -1475,6 +1502,14 @@ var require_sonic_boom = __commonJS({
1475
1502
  }
1476
1503
  });
1477
1504
  }
1505
+ function releaseWritingBuf(writingBuf, len, n) {
1506
+ if (typeof writingBuf === "string" && Buffer.byteLength(writingBuf) !== n) {
1507
+ n = Buffer.from(writingBuf).subarray(0, n).toString().length;
1508
+ }
1509
+ len = Math.max(len - n, 0);
1510
+ writingBuf = writingBuf.slice(n);
1511
+ return { writingBuf, len };
1512
+ }
1478
1513
  function emitDrain(sonic) {
1479
1514
  const hasListeners = sonic.listenerCount("drain") > 0;
1480
1515
  if (!hasListeners)
@@ -1630,6 +1665,9 @@ var require_sonic_boom = __commonJS({
1630
1665
  if (!this.file) {
1631
1666
  throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");
1632
1667
  }
1668
+ if (file) {
1669
+ this.file = file;
1670
+ }
1633
1671
  this._reopening = true;
1634
1672
  if (this._writing) {
1635
1673
  return;
@@ -1644,7 +1682,7 @@ var require_sonic_boom = __commonJS({
1644
1682
  });
1645
1683
  }
1646
1684
  });
1647
- openFile(file || this.file, this);
1685
+ openFile(this.file, this);
1648
1686
  };
1649
1687
  SonicBoom.prototype.end = function() {
1650
1688
  if (this.destroyed) {
@@ -1687,8 +1725,9 @@ var require_sonic_boom = __commonJS({
1687
1725
  }
1688
1726
  try {
1689
1727
  const n = fs.writeSync(this.fd, buf, "utf8");
1690
- buf = buf.slice(n);
1691
- this._len = Math.max(this._len - n, 0);
1728
+ const releasedBufObj = releaseWritingBuf(buf, this._len, n);
1729
+ buf = releasedBufObj.writingBuf;
1730
+ this._len = releasedBufObj.len;
1692
1731
  if (buf.length <= 0) {
1693
1732
  this._bufs.shift();
1694
1733
  }
@@ -1819,7 +1858,12 @@ var require_on_exit_leak_free = __commonJS({
1819
1858
  exit: onExit,
1820
1859
  beforeExit: onBeforeExit
1821
1860
  };
1822
- var registry = new FinalizationRegistry(clear);
1861
+ var registry;
1862
+ function ensureRegistry() {
1863
+ if (registry === void 0) {
1864
+ registry = new FinalizationRegistry(clear);
1865
+ }
1866
+ }
1823
1867
  function install(event) {
1824
1868
  if (refs[event].length > 0) {
1825
1869
  return;
@@ -1831,6 +1875,9 @@ var require_on_exit_leak_free = __commonJS({
1831
1875
  return;
1832
1876
  }
1833
1877
  process.removeListener(event, functions[event]);
1878
+ if (refs.exit.length === 0 && refs.beforeExit.length === 0) {
1879
+ registry = void 0;
1880
+ }
1834
1881
  }
1835
1882
  function onExit() {
1836
1883
  callRefs("exit");
@@ -1846,6 +1893,7 @@ var require_on_exit_leak_free = __commonJS({
1846
1893
  fn(obj, event);
1847
1894
  }
1848
1895
  }
1896
+ refs[event] = [];
1849
1897
  }
1850
1898
  function clear(ref) {
1851
1899
  for (const event of ["exit", "beforeExit"]) {
@@ -1861,6 +1909,7 @@ var require_on_exit_leak_free = __commonJS({
1861
1909
  install(event);
1862
1910
  const ref = new WeakRef(obj);
1863
1911
  ref.fn = fn;
1912
+ ensureRegistry();
1864
1913
  registry.register(obj, ref);
1865
1914
  refs[event].push(ref);
1866
1915
  }
@@ -1871,6 +1920,9 @@ var require_on_exit_leak_free = __commonJS({
1871
1920
  _register("beforeExit", obj, fn);
1872
1921
  }
1873
1922
  function unregister(obj) {
1923
+ if (registry === void 0) {
1924
+ return;
1925
+ }
1874
1926
  registry.unregister(obj);
1875
1927
  for (const event of ["exit", "beforeExit"]) {
1876
1928
  refs[event] = refs[event].filter((ref) => {