apitally 0.21.1 → 0.21.3

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 (89) hide show
  1. package/dist/adonisjs/provider.cjs +456 -612
  2. package/dist/adonisjs/provider.cjs.map +1 -1
  3. package/dist/adonisjs/provider.js +456 -612
  4. package/dist/adonisjs/provider.js.map +1 -1
  5. package/dist/common/client.cjs +14 -9
  6. package/dist/common/client.cjs.map +1 -1
  7. package/dist/common/client.d.cts +1 -1
  8. package/dist/common/client.d.ts +1 -1
  9. package/dist/common/client.js +14 -9
  10. package/dist/common/client.js.map +1 -1
  11. package/dist/common/response.cjs +21 -2
  12. package/dist/common/response.cjs.map +1 -1
  13. package/dist/common/response.d.cts +2 -1
  14. package/dist/common/response.d.ts +2 -1
  15. package/dist/common/response.js +19 -1
  16. package/dist/common/response.js.map +1 -1
  17. package/dist/elysia/index.cjs +40 -16
  18. package/dist/elysia/index.cjs.map +1 -1
  19. package/dist/elysia/index.js +40 -16
  20. package/dist/elysia/index.js.map +1 -1
  21. package/dist/elysia/plugin.cjs +40 -16
  22. package/dist/elysia/plugin.cjs.map +1 -1
  23. package/dist/elysia/plugin.js +40 -16
  24. package/dist/elysia/plugin.js.map +1 -1
  25. package/dist/express/index.cjs +450 -606
  26. package/dist/express/index.cjs.map +1 -1
  27. package/dist/express/index.js +450 -606
  28. package/dist/express/index.js.map +1 -1
  29. package/dist/express/middleware.cjs +450 -606
  30. package/dist/express/middleware.cjs.map +1 -1
  31. package/dist/express/middleware.js +450 -606
  32. package/dist/express/middleware.js.map +1 -1
  33. package/dist/fastify/index.cjs +450 -606
  34. package/dist/fastify/index.cjs.map +1 -1
  35. package/dist/fastify/index.js +450 -606
  36. package/dist/fastify/index.js.map +1 -1
  37. package/dist/fastify/plugin.cjs +450 -606
  38. package/dist/fastify/plugin.cjs.map +1 -1
  39. package/dist/fastify/plugin.js +450 -606
  40. package/dist/fastify/plugin.js.map +1 -1
  41. package/dist/h3/index.cjs +15 -9
  42. package/dist/h3/index.cjs.map +1 -1
  43. package/dist/h3/index.js +15 -9
  44. package/dist/h3/index.js.map +1 -1
  45. package/dist/h3/plugin.cjs +15 -9
  46. package/dist/h3/plugin.cjs.map +1 -1
  47. package/dist/h3/plugin.js +15 -9
  48. package/dist/h3/plugin.js.map +1 -1
  49. package/dist/hapi/index.cjs +456 -612
  50. package/dist/hapi/index.cjs.map +1 -1
  51. package/dist/hapi/index.js +456 -612
  52. package/dist/hapi/index.js.map +1 -1
  53. package/dist/hapi/plugin.cjs +456 -612
  54. package/dist/hapi/plugin.cjs.map +1 -1
  55. package/dist/hapi/plugin.js +456 -612
  56. package/dist/hapi/plugin.js.map +1 -1
  57. package/dist/hono/index.cjs +29 -19
  58. package/dist/hono/index.cjs.map +1 -1
  59. package/dist/hono/index.js +29 -19
  60. package/dist/hono/index.js.map +1 -1
  61. package/dist/hono/middleware.cjs +29 -19
  62. package/dist/hono/middleware.cjs.map +1 -1
  63. package/dist/hono/middleware.js +29 -19
  64. package/dist/hono/middleware.js.map +1 -1
  65. package/dist/hono/utils.cjs +14 -10
  66. package/dist/hono/utils.cjs.map +1 -1
  67. package/dist/hono/utils.js +14 -10
  68. package/dist/hono/utils.js.map +1 -1
  69. package/dist/koa/index.cjs +15 -9
  70. package/dist/koa/index.cjs.map +1 -1
  71. package/dist/koa/index.js +15 -9
  72. package/dist/koa/index.js.map +1 -1
  73. package/dist/koa/middleware.cjs +15 -9
  74. package/dist/koa/middleware.cjs.map +1 -1
  75. package/dist/koa/middleware.js +15 -9
  76. package/dist/koa/middleware.js.map +1 -1
  77. package/dist/loggers/index.cjs +441 -603
  78. package/dist/loggers/index.cjs.map +1 -1
  79. package/dist/loggers/index.js +441 -603
  80. package/dist/loggers/index.js.map +1 -1
  81. package/dist/loggers/pino.cjs +435 -597
  82. package/dist/loggers/pino.cjs.map +1 -1
  83. package/dist/loggers/pino.js +435 -597
  84. package/dist/loggers/pino.js.map +1 -1
  85. package/dist/nestjs/index.cjs +451 -606
  86. package/dist/nestjs/index.cjs.map +1 -1
  87. package/dist/nestjs/index.js +451 -606
  88. package/dist/nestjs/index.js.map +1 -1
  89. package/package.json +2 -2
@@ -440,619 +440,458 @@ var require_caller = __commonJS({
440
440
  }
441
441
  });
442
442
 
443
- // node_modules/fast-redact/lib/validator.js
444
- var require_validator = __commonJS({
445
- "node_modules/fast-redact/lib/validator.js"(exports2, module2) {
443
+ // node_modules/@pinojs/redact/index.js
444
+ var require_redact = __commonJS({
445
+ "node_modules/@pinojs/redact/index.js"(exports2, module2) {
446
446
  "use strict";
447
- module2.exports = validator;
448
- function validator(opts = {}) {
449
- const { ERR_PATHS_MUST_BE_STRINGS = /* @__PURE__ */ __name(() => "fast-redact - Paths must be (non-empty) strings", "ERR_PATHS_MUST_BE_STRINGS"), ERR_INVALID_PATH = /* @__PURE__ */ __name((s) => `fast-redact \u2013 Invalid path (${s})`, "ERR_INVALID_PATH") } = opts;
450
- return /* @__PURE__ */ __name(function validate({ paths }) {
451
- paths.forEach((s) => {
452
- if (typeof s !== "string") {
453
- throw Error(ERR_PATHS_MUST_BE_STRINGS());
447
+ function deepClone(obj) {
448
+ if (obj === null || typeof obj !== "object") {
449
+ return obj;
450
+ }
451
+ if (obj instanceof Date) {
452
+ return new Date(obj.getTime());
453
+ }
454
+ if (obj instanceof Array) {
455
+ const cloned = [];
456
+ for (let i = 0; i < obj.length; i++) {
457
+ cloned[i] = deepClone(obj[i]);
458
+ }
459
+ return cloned;
460
+ }
461
+ if (typeof obj === "object") {
462
+ const cloned = Object.create(Object.getPrototypeOf(obj));
463
+ for (const key in obj) {
464
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
465
+ cloned[key] = deepClone(obj[key]);
454
466
  }
455
- try {
456
- if (/〇/.test(s)) throw Error();
457
- const expr = (s[0] === "[" ? "" : ".") + s.replace(/^\*/, "\u3007").replace(/\.\*/g, ".\u3007").replace(/\[\*\]/g, "[\u3007]");
458
- if (/\n|\r|;/.test(expr)) throw Error();
459
- if (/\/\*/.test(expr)) throw Error();
460
- Function(`
461
- 'use strict'
462
- const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });
463
- const \u3007 = null;
464
- o${expr}
465
- if ([o${expr}].length !== 1) throw Error()`)();
466
- } catch (e) {
467
- throw Error(ERR_INVALID_PATH(s));
467
+ }
468
+ return cloned;
469
+ }
470
+ return obj;
471
+ }
472
+ __name(deepClone, "deepClone");
473
+ function parsePath(path) {
474
+ const parts = [];
475
+ let current = "";
476
+ let inBrackets = false;
477
+ let inQuotes = false;
478
+ let quoteChar = "";
479
+ for (let i = 0; i < path.length; i++) {
480
+ const char = path[i];
481
+ if (!inBrackets && char === ".") {
482
+ if (current) {
483
+ parts.push(current);
484
+ current = "";
485
+ }
486
+ } else if (char === "[") {
487
+ if (current) {
488
+ parts.push(current);
489
+ current = "";
490
+ }
491
+ inBrackets = true;
492
+ } else if (char === "]" && inBrackets) {
493
+ parts.push(current);
494
+ current = "";
495
+ inBrackets = false;
496
+ inQuotes = false;
497
+ } else if ((char === '"' || char === "'") && inBrackets) {
498
+ if (!inQuotes) {
499
+ inQuotes = true;
500
+ quoteChar = char;
501
+ } else if (char === quoteChar) {
502
+ inQuotes = false;
503
+ quoteChar = "";
504
+ } else {
505
+ current += char;
468
506
  }
469
- });
470
- }, "validate");
471
- }
472
- __name(validator, "validator");
473
- }
474
- });
475
-
476
- // node_modules/fast-redact/lib/rx.js
477
- var require_rx = __commonJS({
478
- "node_modules/fast-redact/lib/rx.js"(exports2, module2) {
479
- "use strict";
480
- module2.exports = /[^.[\]]+|\[((?:.)*?)\]/g;
481
- }
482
- });
483
-
484
- // node_modules/fast-redact/lib/parse.js
485
- var require_parse = __commonJS({
486
- "node_modules/fast-redact/lib/parse.js"(exports2, module2) {
487
- "use strict";
488
- var rx = require_rx();
489
- module2.exports = parse;
490
- function parse({ paths }) {
491
- const wildcards = [];
492
- var wcLen = 0;
493
- const secret = paths.reduce(function(o, strPath, ix) {
494
- var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
495
- const leadingBracket = strPath[0] === "[";
496
- path = path.map((p) => {
497
- if (p[0] === "[") return p.substr(1, p.length - 2);
498
- else return p;
499
- });
500
- const star = path.indexOf("*");
501
- if (star > -1) {
502
- const before = path.slice(0, star);
503
- const beforeStr = before.join(".");
504
- const after = path.slice(star + 1, path.length);
505
- const nested = after.length > 0;
506
- wcLen++;
507
- wildcards.push({
508
- before,
509
- beforeStr,
510
- after,
511
- nested
512
- });
513
507
  } else {
514
- o[strPath] = {
515
- path,
516
- val: void 0,
517
- precensored: false,
518
- circle: "",
519
- escPath: JSON.stringify(strPath),
520
- leadingBracket
521
- };
508
+ current += char;
522
509
  }
523
- return o;
524
- }, {});
525
- return {
526
- wildcards,
527
- wcLen,
528
- secret
529
- };
510
+ }
511
+ if (current) {
512
+ parts.push(current);
513
+ }
514
+ return parts;
530
515
  }
531
- __name(parse, "parse");
532
- }
533
- });
534
-
535
- // node_modules/fast-redact/lib/redactor.js
536
- var require_redactor = __commonJS({
537
- "node_modules/fast-redact/lib/redactor.js"(exports2, module2) {
538
- "use strict";
539
- var rx = require_rx();
540
- module2.exports = redactor;
541
- function redactor({ secret, serialize, wcLen, strict, isCensorFct, censorFctTakesPath }, state) {
542
- const redact = Function("o", `
543
- if (typeof o !== 'object' || o == null) {
544
- ${strictImpl(strict, serialize)}
545
- }
546
- const { censor, secret } = this
547
- const originalSecret = {}
548
- const secretKeys = Object.keys(secret)
549
- for (var i = 0; i < secretKeys.length; i++) {
550
- originalSecret[secretKeys[i]] = secret[secretKeys[i]]
516
+ __name(parsePath, "parsePath");
517
+ function setValue(obj, parts, value) {
518
+ let current = obj;
519
+ for (let i = 0; i < parts.length - 1; i++) {
520
+ const key = parts[i];
521
+ if (typeof current !== "object" || current === null || !(key in current)) {
522
+ return false;
523
+ }
524
+ if (typeof current[key] !== "object" || current[key] === null) {
525
+ return false;
526
+ }
527
+ current = current[key];
528
+ }
529
+ const lastKey = parts[parts.length - 1];
530
+ if (lastKey === "*") {
531
+ if (Array.isArray(current)) {
532
+ for (let i = 0; i < current.length; i++) {
533
+ current[i] = value;
534
+ }
535
+ } else if (typeof current === "object" && current !== null) {
536
+ for (const key in current) {
537
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
538
+ current[key] = value;
539
+ }
540
+ }
541
+ }
542
+ } else {
543
+ if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
544
+ current[lastKey] = value;
545
+ }
546
+ }
547
+ return true;
551
548
  }
552
-
553
- ${redactTmpl(secret, isCensorFct, censorFctTakesPath)}
554
- this.compileRestore()
555
- ${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)}
556
- this.secret = originalSecret
557
- ${resultTmpl(serialize)}
558
- `).bind(state);
559
- redact.state = state;
560
- if (serialize === false) {
561
- redact.restore = (o) => state.restore(o);
562
- }
563
- return redact;
564
- }
565
- __name(redactor, "redactor");
566
- function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
567
- return Object.keys(secret).map((path) => {
568
- const { escPath, leadingBracket, path: arrPath } = secret[path];
569
- const skip = leadingBracket ? 1 : 0;
570
- const delim = leadingBracket ? "" : ".";
571
- const hops = [];
572
- var match;
573
- while ((match = rx.exec(path)) !== null) {
574
- const [, ix] = match;
575
- const { index, input } = match;
576
- if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
577
- }
578
- var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
579
- if (existence.length === 0) existence += `o${delim}${path} != null`;
580
- else existence += ` && o${delim}${path} != null`;
581
- const circularDetection = `
582
- switch (true) {
583
- ${hops.reverse().map((p) => `
584
- case o${delim}${p} === censor:
585
- secret[${escPath}].circle = ${JSON.stringify(p)}
586
- break
587
- `).join("\n")}
588
- }
589
- `;
590
- const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
591
- return `
592
- if (${existence}) {
593
- const val = o${delim}${path}
594
- if (val === censor) {
595
- secret[${escPath}].precensored = true
596
- } else {
597
- secret[${escPath}].val = val
598
- o${delim}${path} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
599
- ${circularDetection}
600
- }
601
- }
602
- `;
603
- }).join("\n");
604
- }
605
- __name(redactTmpl, "redactTmpl");
606
- function dynamicRedactTmpl(hasWildcards, isCensorFct, censorFctTakesPath) {
607
- return hasWildcards === true ? `
608
- {
609
- const { wildcards, wcLen, groupRedact, nestedRedact } = this
610
- for (var i = 0; i < wcLen; i++) {
611
- const { before, beforeStr, after, nested } = wildcards[i]
612
- if (nested === true) {
613
- secret[beforeStr] = secret[beforeStr] || []
614
- nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct}, ${censorFctTakesPath})
615
- } else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct}, ${censorFctTakesPath})
616
- }
617
- }
618
- ` : "";
619
- }
620
- __name(dynamicRedactTmpl, "dynamicRedactTmpl");
621
- function resultTmpl(serialize) {
622
- return serialize === false ? `return o` : `
623
- var s = this.serialize(o)
624
- this.restore(o)
625
- return s
626
- `;
627
- }
628
- __name(resultTmpl, "resultTmpl");
629
- function strictImpl(strict, serialize) {
630
- return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : serialize === false ? `return o` : `return this.serialize(o)`;
631
- }
632
- __name(strictImpl, "strictImpl");
633
- }
634
- });
635
-
636
- // node_modules/fast-redact/lib/modifiers.js
637
- var require_modifiers = __commonJS({
638
- "node_modules/fast-redact/lib/modifiers.js"(exports2, module2) {
639
- "use strict";
640
- module2.exports = {
641
- groupRedact,
642
- groupRestore,
643
- nestedRedact,
644
- nestedRestore
645
- };
646
- function groupRestore({ keys, values, target }) {
647
- if (target == null || typeof target === "string") return;
648
- const length = keys.length;
649
- for (var i = 0; i < length; i++) {
650
- const k = keys[i];
651
- target[k] = values[i];
652
- }
653
- }
654
- __name(groupRestore, "groupRestore");
655
- function groupRedact(o, path, censor, isCensorFct, censorFctTakesPath) {
656
- const target = get(o, path);
657
- if (target == null || typeof target === "string") return {
658
- keys: null,
659
- values: null,
660
- target,
661
- flat: true
662
- };
663
- const keys = Object.keys(target);
664
- const keysLength = keys.length;
665
- const pathLength = path.length;
666
- const pathWithKey = censorFctTakesPath ? [
667
- ...path
668
- ] : void 0;
669
- const values = new Array(keysLength);
670
- for (var i = 0; i < keysLength; i++) {
671
- const key = keys[i];
672
- values[i] = target[key];
673
- if (censorFctTakesPath) {
674
- pathWithKey[pathLength] = key;
675
- target[key] = censor(target[key], pathWithKey);
676
- } else if (isCensorFct) {
677
- target[key] = censor(target[key]);
549
+ __name(setValue, "setValue");
550
+ function removeKey(obj, parts) {
551
+ let current = obj;
552
+ for (let i = 0; i < parts.length - 1; i++) {
553
+ const key = parts[i];
554
+ if (typeof current !== "object" || current === null || !(key in current)) {
555
+ return false;
556
+ }
557
+ if (typeof current[key] !== "object" || current[key] === null) {
558
+ return false;
559
+ }
560
+ current = current[key];
561
+ }
562
+ const lastKey = parts[parts.length - 1];
563
+ if (lastKey === "*") {
564
+ if (Array.isArray(current)) {
565
+ for (let i = 0; i < current.length; i++) {
566
+ current[i] = void 0;
567
+ }
568
+ } else if (typeof current === "object" && current !== null) {
569
+ for (const key in current) {
570
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
571
+ delete current[key];
572
+ }
573
+ }
574
+ }
575
+ } else {
576
+ if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
577
+ delete current[lastKey];
578
+ }
579
+ }
580
+ return true;
581
+ }
582
+ __name(removeKey, "removeKey");
583
+ var PATH_NOT_FOUND = Symbol("PATH_NOT_FOUND");
584
+ function getValueIfExists(obj, parts) {
585
+ let current = obj;
586
+ for (const part of parts) {
587
+ if (current === null || current === void 0) {
588
+ return PATH_NOT_FOUND;
589
+ }
590
+ if (typeof current !== "object" || current === null) {
591
+ return PATH_NOT_FOUND;
592
+ }
593
+ if (!(part in current)) {
594
+ return PATH_NOT_FOUND;
595
+ }
596
+ current = current[part];
597
+ }
598
+ return current;
599
+ }
600
+ __name(getValueIfExists, "getValueIfExists");
601
+ function getValue(obj, parts) {
602
+ let current = obj;
603
+ for (const part of parts) {
604
+ if (current === null || current === void 0) {
605
+ return void 0;
606
+ }
607
+ if (typeof current !== "object" || current === null) {
608
+ return void 0;
609
+ }
610
+ current = current[part];
611
+ }
612
+ return current;
613
+ }
614
+ __name(getValue, "getValue");
615
+ function redactPaths(obj, paths, censor, remove = false) {
616
+ for (const path of paths) {
617
+ const parts = parsePath(path);
618
+ if (parts.includes("*")) {
619
+ redactWildcardPath(obj, parts, censor, path, remove);
678
620
  } else {
679
- target[key] = censor;
621
+ if (remove) {
622
+ removeKey(obj, parts);
623
+ } else {
624
+ const value = getValueIfExists(obj, parts);
625
+ if (value === PATH_NOT_FOUND) {
626
+ continue;
627
+ }
628
+ const actualCensor = typeof censor === "function" ? censor(value, parts) : censor;
629
+ setValue(obj, parts, actualCensor);
630
+ }
680
631
  }
681
632
  }
682
- return {
683
- keys,
684
- values,
685
- target,
686
- flat: true
687
- };
688
633
  }
689
- __name(groupRedact, "groupRedact");
690
- function nestedRestore(instructions) {
691
- for (let i = 0; i < instructions.length; i++) {
692
- const { target, path, value } = instructions[i];
693
- let current = target;
694
- for (let i2 = path.length - 1; i2 > 0; i2--) {
695
- current = current[path[i2]];
696
- }
697
- current[path[0]] = value;
698
- }
699
- }
700
- __name(nestedRestore, "nestedRestore");
701
- function nestedRedact(store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
702
- const target = get(o, path);
703
- if (target == null) return;
704
- const keys = Object.keys(target);
705
- const keysLength = keys.length;
706
- for (var i = 0; i < keysLength; i++) {
707
- const key = keys[i];
708
- specialSet(store, target, key, path, ns, censor, isCensorFct, censorFctTakesPath);
709
- }
710
- return store;
711
- }
712
- __name(nestedRedact, "nestedRedact");
713
- function has(obj, prop) {
714
- return obj !== void 0 && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
715
- }
716
- __name(has, "has");
717
- function specialSet(store, o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
718
- const afterPathLen = afterPath.length;
719
- const lastPathIndex = afterPathLen - 1;
720
- const originalKey = k;
721
- var i = -1;
722
- var n;
723
- var nv;
724
- var ov;
725
- var oov = null;
726
- var wc = null;
727
- var kIsWc;
728
- var wcov;
729
- var consecutive = false;
730
- var level = 0;
731
- var depth = 0;
732
- var redactPathCurrent = tree();
733
- ov = n = o[k];
734
- if (typeof n !== "object") return;
735
- while (n != null && ++i < afterPathLen) {
736
- depth += 1;
737
- k = afterPath[i];
738
- oov = ov;
739
- if (k !== "*" && !wc && !(typeof n === "object" && k in n)) {
740
- break;
634
+ __name(redactPaths, "redactPaths");
635
+ function redactWildcardPath(obj, parts, censor, originalPath, remove = false) {
636
+ const wildcardIndex = parts.indexOf("*");
637
+ if (wildcardIndex === parts.length - 1) {
638
+ const parentParts = parts.slice(0, -1);
639
+ let current = obj;
640
+ for (const part of parentParts) {
641
+ if (current === null || current === void 0) return;
642
+ if (typeof current !== "object" || current === null) return;
643
+ current = current[part];
741
644
  }
742
- if (k === "*") {
743
- if (wc === "*") {
744
- consecutive = true;
645
+ if (Array.isArray(current)) {
646
+ if (remove) {
647
+ for (let i = 0; i < current.length; i++) {
648
+ current[i] = void 0;
649
+ }
650
+ } else {
651
+ for (let i = 0; i < current.length; i++) {
652
+ const indexPath = [
653
+ ...parentParts,
654
+ i.toString()
655
+ ];
656
+ const actualCensor = typeof censor === "function" ? censor(current[i], indexPath) : censor;
657
+ current[i] = actualCensor;
658
+ }
745
659
  }
746
- wc = k;
747
- if (i !== lastPathIndex) {
748
- continue;
660
+ } else if (typeof current === "object" && current !== null) {
661
+ if (remove) {
662
+ const keysToDelete = [];
663
+ for (const key in current) {
664
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
665
+ keysToDelete.push(key);
666
+ }
667
+ }
668
+ for (const key of keysToDelete) {
669
+ delete current[key];
670
+ }
671
+ } else {
672
+ for (const key in current) {
673
+ const keyPath = [
674
+ ...parentParts,
675
+ key
676
+ ];
677
+ const actualCensor = typeof censor === "function" ? censor(current[key], keyPath) : censor;
678
+ current[key] = actualCensor;
679
+ }
749
680
  }
750
681
  }
751
- if (wc) {
752
- const wcKeys = Object.keys(n);
753
- for (var j = 0; j < wcKeys.length; j++) {
754
- const wck = wcKeys[j];
755
- wcov = n[wck];
756
- kIsWc = k === "*";
757
- if (consecutive) {
758
- redactPathCurrent = node(redactPathCurrent, wck, depth);
759
- level = i;
760
- 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);
761
- } else {
762
- if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
763
- if (kIsWc) {
764
- ov = wcov;
765
- } else {
766
- ov = wcov[k];
767
- }
768
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [
769
- ...path,
770
- originalKey,
771
- ...afterPath
772
- ]) : censor(ov) : censor;
773
- if (kIsWc) {
774
- const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
775
- store.push(rv);
776
- n[wck] = nv;
777
- } else {
778
- if (wcov[k] === nv) {
779
- } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
780
- redactPathCurrent = node(redactPathCurrent, wck, depth);
781
- } else {
782
- redactPathCurrent = node(redactPathCurrent, wck, depth);
783
- const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, o[originalKey]);
784
- store.push(rv);
785
- wcov[k] = nv;
786
- }
787
- }
788
- }
682
+ } else {
683
+ redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove);
684
+ }
685
+ }
686
+ __name(redactWildcardPath, "redactWildcardPath");
687
+ function redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove = false) {
688
+ const beforeWildcard = parts.slice(0, wildcardIndex);
689
+ const afterWildcard = parts.slice(wildcardIndex + 1);
690
+ const pathArray = [];
691
+ function traverse(current, pathLength) {
692
+ if (pathLength === beforeWildcard.length) {
693
+ if (Array.isArray(current)) {
694
+ for (let i = 0; i < current.length; i++) {
695
+ pathArray[pathLength] = i.toString();
696
+ traverse(current[i], pathLength + 1);
697
+ }
698
+ } else if (typeof current === "object" && current !== null) {
699
+ for (const key in current) {
700
+ pathArray[pathLength] = key;
701
+ traverse(current[key], pathLength + 1);
789
702
  }
790
703
  }
791
- wc = null;
704
+ } else if (pathLength < beforeWildcard.length) {
705
+ const nextKey = beforeWildcard[pathLength];
706
+ if (current && typeof current === "object" && current !== null && nextKey in current) {
707
+ pathArray[pathLength] = nextKey;
708
+ traverse(current[nextKey], pathLength + 1);
709
+ }
792
710
  } else {
793
- ov = n[k];
794
- redactPathCurrent = node(redactPathCurrent, k, depth);
795
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [
796
- ...path,
797
- originalKey,
798
- ...afterPath
799
- ]) : censor(ov) : censor;
800
- if (has(n, k) && nv === ov || nv === void 0 && censor !== void 0) {
711
+ if (afterWildcard.includes("*")) {
712
+ const wrappedCensor = typeof censor === "function" ? (value, path) => {
713
+ const fullPath = [
714
+ ...pathArray.slice(0, pathLength),
715
+ ...path
716
+ ];
717
+ return censor(value, fullPath);
718
+ } : censor;
719
+ redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
801
720
  } else {
802
- const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
803
- store.push(rv);
804
- n[k] = nv;
721
+ if (remove) {
722
+ removeKey(current, afterWildcard);
723
+ } else {
724
+ const actualCensor = typeof censor === "function" ? censor(getValue(current, afterWildcard), [
725
+ ...pathArray.slice(0, pathLength),
726
+ ...afterWildcard
727
+ ]) : censor;
728
+ setValue(current, afterWildcard, actualCensor);
729
+ }
805
730
  }
806
- n = n[k];
807
731
  }
808
- if (typeof n !== "object") break;
809
- if (ov === oov || typeof ov === "undefined") {
732
+ }
733
+ __name(traverse, "traverse");
734
+ if (beforeWildcard.length === 0) {
735
+ traverse(obj, 0);
736
+ } else {
737
+ let current = obj;
738
+ for (let i = 0; i < beforeWildcard.length; i++) {
739
+ const part = beforeWildcard[i];
740
+ if (current === null || current === void 0) return;
741
+ if (typeof current !== "object" || current === null) return;
742
+ current = current[part];
743
+ pathArray[i] = part;
744
+ }
745
+ if (current !== null && current !== void 0) {
746
+ traverse(current, beforeWildcard.length);
747
+ }
748
+ }
749
+ }
750
+ __name(redactIntermediateWildcard, "redactIntermediateWildcard");
751
+ function buildPathStructure(pathsToClone) {
752
+ if (pathsToClone.length === 0) {
753
+ return null;
754
+ }
755
+ const pathStructure = /* @__PURE__ */ new Map();
756
+ for (const path of pathsToClone) {
757
+ const parts = parsePath(path);
758
+ let current = pathStructure;
759
+ for (let i = 0; i < parts.length; i++) {
760
+ const part = parts[i];
761
+ if (!current.has(part)) {
762
+ current.set(part, /* @__PURE__ */ new Map());
763
+ }
764
+ current = current.get(part);
810
765
  }
811
766
  }
767
+ return pathStructure;
812
768
  }
813
- __name(specialSet, "specialSet");
814
- function get(o, p) {
815
- var i = -1;
816
- var l = p.length;
817
- var n = o;
818
- while (n != null && ++i < l) {
819
- n = n[p[i]];
769
+ __name(buildPathStructure, "buildPathStructure");
770
+ function selectiveClone(obj, pathStructure) {
771
+ if (!pathStructure) {
772
+ return obj;
820
773
  }
821
- return n;
822
- }
823
- __name(get, "get");
824
- function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
825
- if (level === 0) {
826
- if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
827
- if (kIsWc) {
828
- ov = wcov;
829
- } else {
830
- ov = wcov[k];
774
+ function cloneSelectively(source, pathMap, depth = 0) {
775
+ if (!pathMap || pathMap.size === 0) {
776
+ return source;
777
+ }
778
+ if (source === null || typeof source !== "object") {
779
+ return source;
780
+ }
781
+ if (source instanceof Date) {
782
+ return new Date(source.getTime());
783
+ }
784
+ if (Array.isArray(source)) {
785
+ const cloned2 = [];
786
+ for (let i = 0; i < source.length; i++) {
787
+ const indexStr = i.toString();
788
+ if (pathMap.has(indexStr) || pathMap.has("*")) {
789
+ cloned2[i] = cloneSelectively(source[i], pathMap.get(indexStr) || pathMap.get("*"));
790
+ } else {
791
+ cloned2[i] = source[i];
792
+ }
831
793
  }
832
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [
833
- ...path,
834
- originalKey,
835
- ...afterPath
836
- ]) : censor(ov) : censor;
837
- if (kIsWc) {
838
- const rv = restoreInstr(redactPathCurrent, ov, parent);
839
- store.push(rv);
840
- n[wck] = nv;
841
- } else {
842
- if (wcov[k] === nv) {
843
- } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
794
+ return cloned2;
795
+ }
796
+ const cloned = Object.create(Object.getPrototypeOf(source));
797
+ for (const key in source) {
798
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
799
+ if (pathMap.has(key) || pathMap.has("*")) {
800
+ cloned[key] = cloneSelectively(source[key], pathMap.get(key) || pathMap.get("*"));
844
801
  } else {
845
- const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, parent);
846
- store.push(rv);
847
- wcov[k] = nv;
802
+ cloned[key] = source[key];
848
803
  }
849
804
  }
850
805
  }
851
- }
852
- for (const key in wcov) {
853
- if (typeof wcov[key] === "object") {
854
- redactPathCurrent = node(redactPathCurrent, key, depth);
855
- iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
806
+ return cloned;
807
+ }
808
+ __name(cloneSelectively, "cloneSelectively");
809
+ return cloneSelectively(obj, pathStructure);
810
+ }
811
+ __name(selectiveClone, "selectiveClone");
812
+ function validatePath(path) {
813
+ if (typeof path !== "string") {
814
+ throw new Error("Paths must be (non-empty) strings");
815
+ }
816
+ if (path === "") {
817
+ throw new Error("Invalid redaction path ()");
818
+ }
819
+ if (path.includes("..")) {
820
+ throw new Error(`Invalid redaction path (${path})`);
821
+ }
822
+ if (path.includes(",")) {
823
+ throw new Error(`Invalid redaction path (${path})`);
824
+ }
825
+ let bracketCount = 0;
826
+ let inQuotes = false;
827
+ let quoteChar = "";
828
+ for (let i = 0; i < path.length; i++) {
829
+ const char = path[i];
830
+ if ((char === '"' || char === "'") && bracketCount > 0) {
831
+ if (!inQuotes) {
832
+ inQuotes = true;
833
+ quoteChar = char;
834
+ } else if (char === quoteChar) {
835
+ inQuotes = false;
836
+ quoteChar = "";
837
+ }
838
+ } else if (char === "[" && !inQuotes) {
839
+ bracketCount++;
840
+ } else if (char === "]" && !inQuotes) {
841
+ bracketCount--;
842
+ if (bracketCount < 0) {
843
+ throw new Error(`Invalid redaction path (${path})`);
844
+ }
856
845
  }
857
846
  }
847
+ if (bracketCount !== 0) {
848
+ throw new Error(`Invalid redaction path (${path})`);
849
+ }
858
850
  }
859
- __name(iterateNthLevel, "iterateNthLevel");
860
- function tree() {
861
- return {
862
- parent: null,
863
- key: null,
864
- children: [],
865
- depth: 0
866
- };
867
- }
868
- __name(tree, "tree");
869
- function node(parent, key, depth) {
870
- if (parent.depth === depth) {
871
- return node(parent.parent, key, depth);
851
+ __name(validatePath, "validatePath");
852
+ function validatePaths(paths) {
853
+ if (!Array.isArray(paths)) {
854
+ throw new TypeError("paths must be an array");
855
+ }
856
+ for (const path of paths) {
857
+ validatePath(path);
872
858
  }
873
- var child = {
874
- parent,
875
- key,
876
- depth,
877
- children: []
878
- };
879
- parent.children.push(child);
880
- return child;
881
- }
882
- __name(node, "node");
883
- function restoreInstr(node2, value, target) {
884
- let current = node2;
885
- const path = [];
886
- do {
887
- path.push(current.key);
888
- current = current.parent;
889
- } while (current.parent != null);
890
- return {
891
- path,
892
- value,
893
- target
894
- };
895
859
  }
896
- __name(restoreInstr, "restoreInstr");
897
- }
898
- });
899
-
900
- // node_modules/fast-redact/lib/restorer.js
901
- var require_restorer = __commonJS({
902
- "node_modules/fast-redact/lib/restorer.js"(exports2, module2) {
903
- "use strict";
904
- var { groupRestore, nestedRestore } = require_modifiers();
905
- module2.exports = restorer;
906
- function restorer() {
907
- return /* @__PURE__ */ __name(function compileRestore() {
908
- if (this.restore) {
909
- this.restore.state.secret = this.secret;
910
- return;
860
+ __name(validatePaths, "validatePaths");
861
+ function slowRedact(options = {}) {
862
+ const { paths = [], censor = "[REDACTED]", serialize = JSON.stringify, strict = true, remove = false } = options;
863
+ validatePaths(paths);
864
+ const pathStructure = buildPathStructure(paths);
865
+ return /* @__PURE__ */ __name(function redact(obj) {
866
+ if (strict && (obj === null || typeof obj !== "object")) {
867
+ if (obj === null || obj === void 0) {
868
+ return serialize ? serialize(obj) : obj;
869
+ }
870
+ if (typeof obj !== "object") {
871
+ return serialize ? serialize(obj) : obj;
872
+ }
911
873
  }
912
- const { secret, wcLen } = this;
913
- const paths = Object.keys(secret);
914
- const resetters = resetTmpl(secret, paths);
915
- const hasWildcards = wcLen > 0;
916
- const state = hasWildcards ? {
917
- secret,
918
- groupRestore,
919
- nestedRestore
920
- } : {
921
- secret
922
- };
923
- this.restore = Function("o", restoreTmpl(resetters, paths, hasWildcards)).bind(state);
924
- this.restore.state = state;
925
- }, "compileRestore");
926
- }
927
- __name(restorer, "restorer");
928
- function resetTmpl(secret, paths) {
929
- return paths.map((path) => {
930
- const { circle, escPath, leadingBracket } = secret[path];
931
- const delim = leadingBracket ? "" : ".";
932
- const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path} = secret[${escPath}].val`;
933
- const clear = `secret[${escPath}].val = undefined`;
934
- return `
935
- if (secret[${escPath}].val !== undefined) {
936
- try { ${reset} } catch (e) {}
937
- ${clear}
938
- }
939
- `;
940
- }).join("");
941
- }
942
- __name(resetTmpl, "resetTmpl");
943
- function restoreTmpl(resetters, paths, hasWildcards) {
944
- const dynamicReset = hasWildcards === true ? `
945
- const keys = Object.keys(secret)
946
- const len = keys.length
947
- for (var i = len - 1; i >= ${paths.length}; i--) {
948
- const k = keys[i]
949
- const o = secret[k]
950
- if (o) {
951
- if (o.flat === true) this.groupRestore(o)
952
- else this.nestedRestore(o)
953
- secret[k] = null
954
- }
955
- }
956
- ` : "";
957
- return `
958
- const secret = this.secret
959
- ${dynamicReset}
960
- ${resetters}
961
- return o
962
- `;
963
- }
964
- __name(restoreTmpl, "restoreTmpl");
965
- }
966
- });
967
-
968
- // node_modules/fast-redact/lib/state.js
969
- var require_state = __commonJS({
970
- "node_modules/fast-redact/lib/state.js"(exports2, module2) {
971
- "use strict";
972
- module2.exports = state;
973
- function state(o) {
974
- const { secret, censor, compileRestore, serialize, groupRedact, nestedRedact, wildcards, wcLen } = o;
975
- const builder = [
976
- {
977
- secret,
978
- censor,
979
- compileRestore
874
+ const cloned = selectiveClone(obj, pathStructure);
875
+ const original = obj;
876
+ let actualCensor = censor;
877
+ if (typeof censor === "function") {
878
+ actualCensor = censor;
980
879
  }
981
- ];
982
- if (serialize !== false) builder.push({
983
- serialize
984
- });
985
- if (wcLen > 0) builder.push({
986
- groupRedact,
987
- nestedRedact,
988
- wildcards,
989
- wcLen
990
- });
991
- return Object.assign(...builder);
992
- }
993
- __name(state, "state");
994
- }
995
- });
996
-
997
- // node_modules/fast-redact/index.js
998
- var require_fast_redact = __commonJS({
999
- "node_modules/fast-redact/index.js"(exports2, module2) {
1000
- "use strict";
1001
- var validator = require_validator();
1002
- var parse = require_parse();
1003
- var redactor = require_redactor();
1004
- var restorer = require_restorer();
1005
- var { groupRedact, nestedRedact } = require_modifiers();
1006
- var state = require_state();
1007
- var rx = require_rx();
1008
- var validate = validator();
1009
- var noop = /* @__PURE__ */ __name((o) => o, "noop");
1010
- noop.restore = noop;
1011
- var DEFAULT_CENSOR = "[REDACTED]";
1012
- fastRedact.rx = rx;
1013
- fastRedact.validator = validator;
1014
- module2.exports = fastRedact;
1015
- function fastRedact(opts = {}) {
1016
- const paths = Array.from(new Set(opts.paths || []));
1017
- const serialize = "serialize" in opts ? opts.serialize === false ? opts.serialize : typeof opts.serialize === "function" ? opts.serialize : JSON.stringify : JSON.stringify;
1018
- const remove = opts.remove;
1019
- if (remove === true && serialize !== JSON.stringify) {
1020
- throw Error("fast-redact \u2013 remove option may only be set when serializer is JSON.stringify");
1021
- }
1022
- const censor = remove === true ? void 0 : "censor" in opts ? opts.censor : DEFAULT_CENSOR;
1023
- const isCensorFct = typeof censor === "function";
1024
- const censorFctTakesPath = isCensorFct && censor.length > 1;
1025
- if (paths.length === 0) return serialize || noop;
1026
- validate({
1027
- paths,
1028
- serialize,
1029
- censor
1030
- });
1031
- const { wildcards, wcLen, secret } = parse({
1032
- paths,
1033
- censor
1034
- });
1035
- const compileRestore = restorer();
1036
- const strict = "strict" in opts ? opts.strict : true;
1037
- return redactor({
1038
- secret,
1039
- wcLen,
1040
- serialize,
1041
- strict,
1042
- isCensorFct,
1043
- censorFctTakesPath
1044
- }, state({
1045
- secret,
1046
- censor,
1047
- compileRestore,
1048
- serialize,
1049
- groupRedact,
1050
- nestedRedact,
1051
- wildcards,
1052
- wcLen
1053
- }));
880
+ redactPaths(cloned, paths, actualCensor, remove);
881
+ if (serialize === false) {
882
+ cloned.restore = function() {
883
+ return deepClone(original);
884
+ };
885
+ return cloned;
886
+ }
887
+ if (typeof serialize === "function") {
888
+ return serialize(cloned);
889
+ }
890
+ return JSON.stringify(cloned);
891
+ }, "redact");
1054
892
  }
1055
- __name(fastRedact, "fastRedact");
893
+ __name(slowRedact, "slowRedact");
894
+ module2.exports = slowRedact;
1056
895
  }
1057
896
  });
1058
897
 
@@ -1131,17 +970,13 @@ var require_symbols = __commonJS({
1131
970
  var require_redaction = __commonJS({
1132
971
  "node_modules/pino/lib/redaction.js"(exports2, module2) {
1133
972
  "use strict";
1134
- var fastRedact = require_fast_redact();
973
+ var Redact = require_redact();
1135
974
  var { redactFmtSym, wildcardFirstSym } = require_symbols();
1136
- var { rx, validator } = fastRedact;
1137
- var validate = validator({
1138
- ERR_PATHS_MUST_BE_STRINGS: /* @__PURE__ */ __name(() => "pino \u2013 redacted paths must be strings", "ERR_PATHS_MUST_BE_STRINGS"),
1139
- ERR_INVALID_PATH: /* @__PURE__ */ __name((s) => `pino \u2013 redact paths array contains an invalid path (${s})`, "ERR_INVALID_PATH")
1140
- });
975
+ var rx = /[^.[\]]+|\[([^[\]]*?)\]/g;
1141
976
  var CENSOR = "[Redacted]";
1142
977
  var strict = false;
1143
978
  function redaction(opts, serialize) {
1144
- const { paths, censor } = handle(opts);
979
+ const { paths, censor, remove } = handle(opts);
1145
980
  const shape = paths.reduce((o, str) => {
1146
981
  rx.lastIndex = 0;
1147
982
  const first = rx.exec(str);
@@ -1174,11 +1009,12 @@ var require_redaction = __commonJS({
1174
1009
  return o;
1175
1010
  }, {});
1176
1011
  const result = {
1177
- [redactFmtSym]: fastRedact({
1012
+ [redactFmtSym]: Redact({
1178
1013
  paths,
1179
1014
  censor,
1180
1015
  serialize,
1181
- strict
1016
+ strict,
1017
+ remove
1182
1018
  })
1183
1019
  };
1184
1020
  const topCensor = /* @__PURE__ */ __name((...args) => {
@@ -1199,11 +1035,12 @@ var require_redaction = __commonJS({
1199
1035
  ...path
1200
1036
  ]);
1201
1037
  } : censor;
1202
- o[k] = fastRedact({
1038
+ o[k] = Redact({
1203
1039
  paths: shape[k],
1204
1040
  censor: wrappedCensor,
1205
1041
  serialize,
1206
- strict
1042
+ strict,
1043
+ remove
1207
1044
  });
1208
1045
  }
1209
1046
  return o;
@@ -1216,7 +1053,6 @@ var require_redaction = __commonJS({
1216
1053
  paths: opts,
1217
1054
  censor: CENSOR
1218
1055
  };
1219
- validate(opts);
1220
1056
  return opts;
1221
1057
  }
1222
1058
  let { paths, censor = CENSOR, remove } = opts;
@@ -1224,13 +1060,10 @@ var require_redaction = __commonJS({
1224
1060
  throw Error("pino \u2013 redact must contain an array of strings");
1225
1061
  }
1226
1062
  if (remove === true) censor = void 0;
1227
- validate({
1228
- paths,
1229
- censor
1230
- });
1231
1063
  return {
1232
1064
  paths,
1233
- censor
1065
+ censor,
1066
+ remove
1234
1067
  };
1235
1068
  }
1236
1069
  __name(handle, "handle");
@@ -3045,7 +2878,7 @@ var require_tools = __commonJS({
3045
2878
  bindings = formatter(bindings);
3046
2879
  for (const key in bindings) {
3047
2880
  value = bindings[key];
3048
- const valid = key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels" && bindings.hasOwnProperty(key) && value !== void 0;
2881
+ const valid = (key.length < 5 || key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels") && bindings.hasOwnProperty(key) && value !== void 0;
3049
2882
  if (valid === true) {
3050
2883
  value = serializers[key] ? serializers[key](value) : value;
3051
2884
  value = (stringifiers[key] || wildcardStringifier || stringify2)(value, stringifySafe);
@@ -3419,7 +3252,7 @@ var require_meta = __commonJS({
3419
3252
  "node_modules/pino/lib/meta.js"(exports2, module2) {
3420
3253
  "use strict";
3421
3254
  module2.exports = {
3422
- version: "9.11.0"
3255
+ version: "9.14.0"
3423
3256
  };
3424
3257
  }
3425
3258
  });
@@ -3431,7 +3264,7 @@ var require_proto = __commonJS({
3431
3264
  var { EventEmitter } = require("events");
3432
3265
  var { lsCacheSym, levelValSym, setLevelSym, getLevelSym, chindingsSym, parsedChindingsSym, mixinSym, asJsonSym, writeSym, mixinMergeStrategySym, timeSym, timeSliceIndexSym, streamSym, serializersSym, formattersSym, errorKeySym, messageKeySym, useOnlyCustomLevelsSym, needsMetadataGsym, redactFmtSym, stringifySym, formatOptsSym, stringifiersSym, msgPrefixSym, hooksSym } = require_symbols();
3433
3266
  var { getLevel, setLevel, isLevelEnabled, mappings, initialLsCache, genLsCache, assertNoLevelCollisions } = require_levels();
3434
- var { asChindings, asJson, buildFormatters, stringify } = require_tools();
3267
+ var { asChindings, asJson, buildFormatters, stringify, noop } = require_tools();
3435
3268
  var { version } = require_meta();
3436
3269
  var redaction = require_redaction();
3437
3270
  var _a3;
@@ -3478,10 +3311,20 @@ var require_proto = __commonJS({
3478
3311
  if (!bindings2) {
3479
3312
  throw Error("missing bindings for child Pino");
3480
3313
  }
3481
- options = options || {};
3482
3314
  const serializers = this[serializersSym];
3483
3315
  const formatters = this[formattersSym];
3484
3316
  const instance = Object.create(this);
3317
+ if (options == null) {
3318
+ if (instance[formattersSym].bindings !== resetChildingsFormatter) {
3319
+ instance[formattersSym] = buildFormatters(formatters.level, resetChildingsFormatter, formatters.log);
3320
+ }
3321
+ instance[chindingsSym] = asChindings(instance, bindings2);
3322
+ instance[setLevelSym](this.level);
3323
+ if (this.onChild !== noop) {
3324
+ this.onChild(instance);
3325
+ }
3326
+ return instance;
3327
+ }
3485
3328
  if (options.hasOwnProperty("serializers") === true) {
3486
3329
  instance[serializersSym] = /* @__PURE__ */ Object.create(null);
3487
3330
  for (const k in serializers) {
@@ -3526,10 +3369,8 @@ var require_proto = __commonJS({
3526
3369
  instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
3527
3370
  }
3528
3371
  instance[chindingsSym] = asChindings(instance, bindings2);
3529
- if (options.level !== void 0 && options.level !== this.level || options.hasOwnProperty("customLevels")) {
3530
- const childLevel = options.level || this.level;
3531
- instance[setLevelSym](childLevel);
3532
- }
3372
+ const childLevel = options.level || this.level;
3373
+ instance[setLevelSym](childLevel);
3533
3374
  this.onChild(instance);
3534
3375
  return instance;
3535
3376
  }
@@ -3591,9 +3432,6 @@ var require_proto = __commonJS({
3591
3432
  stream.write(streamWriteHook ? streamWriteHook(s) : s);
3592
3433
  }
3593
3434
  __name(write, "write");
3594
- function noop() {
3595
- }
3596
- __name(noop, "noop");
3597
3435
  function flush(cb) {
3598
3436
  if (cb != null && typeof cb !== "function") {
3599
3437
  throw Error("callback must be a function");
@@ -5387,11 +5225,14 @@ var _ApitallyClient = class _ApitallyClient {
5387
5225
  if (_ApitallyClient.instance) {
5388
5226
  throw new Error("Apitally client is already initialized");
5389
5227
  }
5228
+ this.logger = logger ?? getLogger();
5390
5229
  if (!isValidClientId(clientId)) {
5391
- throw new Error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
5230
+ this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
5231
+ this.enabled = false;
5392
5232
  }
5393
5233
  if (!isValidEnv(env)) {
5394
- throw new Error(`Invalid env '${env}' (expecting 1-32 alphanumeric lowercase characters and hyphens only)`);
5234
+ this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
5235
+ this.enabled = false;
5395
5236
  }
5396
5237
  if (requestLoggingConfig && !requestLogging) {
5397
5238
  console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
@@ -5406,8 +5247,6 @@ var _ApitallyClient = class _ApitallyClient {
5406
5247
  this.validationErrorCounter = new ValidationErrorCounter();
5407
5248
  this.serverErrorCounter = new ServerErrorCounter();
5408
5249
  this.consumerRegistry = new ConsumerRegistry();
5409
- this.logger = logger ?? getLogger();
5410
- this.startSync();
5411
5250
  this.handleShutdown = this.handleShutdown.bind(this);
5412
5251
  }
5413
5252
  static getInstance() {
@@ -5462,15 +5301,20 @@ var _ApitallyClient = class _ApitallyClient {
5462
5301
  }
5463
5302
  }
5464
5303
  startSync() {
5304
+ if (!this.enabled) {
5305
+ return;
5306
+ }
5465
5307
  this.sync();
5466
5308
  this.syncIntervalId = setInterval(() => {
5467
5309
  this.sync();
5468
5310
  }, INITIAL_SYNC_INTERVAL);
5469
5311
  setTimeout(() => {
5470
- clearInterval(this.syncIntervalId);
5471
- this.syncIntervalId = setInterval(() => {
5472
- this.sync();
5473
- }, SYNC_INTERVAL);
5312
+ if (this.syncIntervalId) {
5313
+ clearInterval(this.syncIntervalId);
5314
+ this.syncIntervalId = setInterval(() => {
5315
+ this.sync();
5316
+ }, SYNC_INTERVAL);
5317
+ }
5474
5318
  }, INITIAL_SYNC_INTERVAL_DURATION);
5475
5319
  }
5476
5320
  async sync() {
@@ -5498,7 +5342,6 @@ var _ApitallyClient = class _ApitallyClient {
5498
5342
  setStartupData(data) {
5499
5343
  this.startupData = data;
5500
5344
  this.startupDataSent = false;
5501
- this.sendStartupData();
5502
5345
  }
5503
5346
  async sendStartupData() {
5504
5347
  if (this.startupData) {
@@ -5871,6 +5714,7 @@ var _ApitallyProvider = class _ApitallyProvider {
5871
5714
  client: "js:adonisjs"
5872
5715
  };
5873
5716
  client.setStartupData(startupData);
5717
+ client.startSync();
5874
5718
  }
5875
5719
  async shutdown() {
5876
5720
  const client = await this.app.container.make("apitallyClient");