@heyhru/app-dms-server 0.5.2 → 0.5.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 (2) hide show
  1. package/dist/index.js +3 -4419
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,4418 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- // ../../node_modules/pino-std-serializers/lib/err-helpers.js
34
- var require_err_helpers = __commonJS({
35
- "../../node_modules/pino-std-serializers/lib/err-helpers.js"(exports, module) {
36
- "use strict";
37
- var isErrorLike = (err) => {
38
- return err && typeof err.message === "string";
39
- };
40
- var getErrorCause = (err) => {
41
- if (!err) return;
42
- const cause = err.cause;
43
- if (typeof cause === "function") {
44
- const causeResult = err.cause();
45
- return isErrorLike(causeResult) ? causeResult : void 0;
46
- } else {
47
- return isErrorLike(cause) ? cause : void 0;
48
- }
49
- };
50
- var _stackWithCauses = (err, seen) => {
51
- if (!isErrorLike(err)) return "";
52
- const stack = err.stack || "";
53
- if (seen.has(err)) {
54
- return stack + "\ncauses have become circular...";
55
- }
56
- const cause = getErrorCause(err);
57
- if (cause) {
58
- seen.add(err);
59
- return stack + "\ncaused by: " + _stackWithCauses(cause, seen);
60
- } else {
61
- return stack;
62
- }
63
- };
64
- var stackWithCauses = (err) => _stackWithCauses(err, /* @__PURE__ */ new Set());
65
- var _messageWithCauses = (err, seen, skip) => {
66
- if (!isErrorLike(err)) return "";
67
- const message = skip ? "" : err.message || "";
68
- if (seen.has(err)) {
69
- return message + ": ...";
70
- }
71
- const cause = getErrorCause(err);
72
- if (cause) {
73
- seen.add(err);
74
- const skipIfVErrorStyleCause = typeof err.cause === "function";
75
- return message + (skipIfVErrorStyleCause ? "" : ": ") + _messageWithCauses(cause, seen, skipIfVErrorStyleCause);
76
- } else {
77
- return message;
78
- }
79
- };
80
- var messageWithCauses = (err) => _messageWithCauses(err, /* @__PURE__ */ new Set());
81
- module.exports = {
82
- isErrorLike,
83
- getErrorCause,
84
- stackWithCauses,
85
- messageWithCauses
86
- };
87
- }
88
- });
89
-
90
- // ../../node_modules/pino-std-serializers/lib/err-proto.js
91
- var require_err_proto = __commonJS({
92
- "../../node_modules/pino-std-serializers/lib/err-proto.js"(exports, module) {
93
- "use strict";
94
- var seen = /* @__PURE__ */ Symbol("circular-ref-tag");
95
- var rawSymbol = /* @__PURE__ */ Symbol("pino-raw-err-ref");
96
- var pinoErrProto = Object.create({}, {
97
- type: {
98
- enumerable: true,
99
- writable: true,
100
- value: void 0
101
- },
102
- message: {
103
- enumerable: true,
104
- writable: true,
105
- value: void 0
106
- },
107
- stack: {
108
- enumerable: true,
109
- writable: true,
110
- value: void 0
111
- },
112
- aggregateErrors: {
113
- enumerable: true,
114
- writable: true,
115
- value: void 0
116
- },
117
- raw: {
118
- enumerable: false,
119
- get: function() {
120
- return this[rawSymbol];
121
- },
122
- set: function(val) {
123
- this[rawSymbol] = val;
124
- }
125
- }
126
- });
127
- Object.defineProperty(pinoErrProto, rawSymbol, {
128
- writable: true,
129
- value: {}
130
- });
131
- module.exports = {
132
- pinoErrProto,
133
- pinoErrorSymbols: {
134
- seen,
135
- rawSymbol
136
- }
137
- };
138
- }
139
- });
140
-
141
- // ../../node_modules/pino-std-serializers/lib/err.js
142
- var require_err = __commonJS({
143
- "../../node_modules/pino-std-serializers/lib/err.js"(exports, module) {
144
- "use strict";
145
- module.exports = errSerializer;
146
- var { messageWithCauses, stackWithCauses, isErrorLike } = require_err_helpers();
147
- var { pinoErrProto, pinoErrorSymbols } = require_err_proto();
148
- var { seen } = pinoErrorSymbols;
149
- var { toString } = Object.prototype;
150
- function errSerializer(err) {
151
- if (!isErrorLike(err)) {
152
- return err;
153
- }
154
- err[seen] = void 0;
155
- const _err = Object.create(pinoErrProto);
156
- _err.type = toString.call(err.constructor) === "[object Function]" ? err.constructor.name : err.name;
157
- _err.message = messageWithCauses(err);
158
- _err.stack = stackWithCauses(err);
159
- if (Array.isArray(err.errors)) {
160
- _err.aggregateErrors = err.errors.map((err2) => errSerializer(err2));
161
- }
162
- for (const key in err) {
163
- if (_err[key] === void 0) {
164
- const val = err[key];
165
- if (isErrorLike(val)) {
166
- if (key !== "cause" && !Object.prototype.hasOwnProperty.call(val, seen)) {
167
- _err[key] = errSerializer(val);
168
- }
169
- } else {
170
- _err[key] = val;
171
- }
172
- }
173
- }
174
- delete err[seen];
175
- _err.raw = err;
176
- return _err;
177
- }
178
- }
179
- });
180
-
181
- // ../../node_modules/pino-std-serializers/lib/err-with-cause.js
182
- var require_err_with_cause = __commonJS({
183
- "../../node_modules/pino-std-serializers/lib/err-with-cause.js"(exports, module) {
184
- "use strict";
185
- module.exports = errWithCauseSerializer;
186
- var { isErrorLike } = require_err_helpers();
187
- var { pinoErrProto, pinoErrorSymbols } = require_err_proto();
188
- var { seen } = pinoErrorSymbols;
189
- var { toString } = Object.prototype;
190
- function errWithCauseSerializer(err) {
191
- if (!isErrorLike(err)) {
192
- return err;
193
- }
194
- err[seen] = void 0;
195
- const _err = Object.create(pinoErrProto);
196
- _err.type = toString.call(err.constructor) === "[object Function]" ? err.constructor.name : err.name;
197
- _err.message = err.message;
198
- _err.stack = err.stack;
199
- if (Array.isArray(err.errors)) {
200
- _err.aggregateErrors = err.errors.map((err2) => errWithCauseSerializer(err2));
201
- }
202
- if (isErrorLike(err.cause) && !Object.prototype.hasOwnProperty.call(err.cause, seen)) {
203
- _err.cause = errWithCauseSerializer(err.cause);
204
- }
205
- for (const key in err) {
206
- if (_err[key] === void 0) {
207
- const val = err[key];
208
- if (isErrorLike(val)) {
209
- if (!Object.prototype.hasOwnProperty.call(val, seen)) {
210
- _err[key] = errWithCauseSerializer(val);
211
- }
212
- } else {
213
- _err[key] = val;
214
- }
215
- }
216
- }
217
- delete err[seen];
218
- _err.raw = err;
219
- return _err;
220
- }
221
- }
222
- });
223
-
224
- // ../../node_modules/pino-std-serializers/lib/req.js
225
- var require_req = __commonJS({
226
- "../../node_modules/pino-std-serializers/lib/req.js"(exports, module) {
227
- "use strict";
228
- module.exports = {
229
- mapHttpRequest,
230
- reqSerializer
231
- };
232
- var rawSymbol = /* @__PURE__ */ Symbol("pino-raw-req-ref");
233
- var pinoReqProto = Object.create({}, {
234
- id: {
235
- enumerable: true,
236
- writable: true,
237
- value: ""
238
- },
239
- method: {
240
- enumerable: true,
241
- writable: true,
242
- value: ""
243
- },
244
- url: {
245
- enumerable: true,
246
- writable: true,
247
- value: ""
248
- },
249
- query: {
250
- enumerable: true,
251
- writable: true,
252
- value: ""
253
- },
254
- params: {
255
- enumerable: true,
256
- writable: true,
257
- value: ""
258
- },
259
- headers: {
260
- enumerable: true,
261
- writable: true,
262
- value: {}
263
- },
264
- remoteAddress: {
265
- enumerable: true,
266
- writable: true,
267
- value: ""
268
- },
269
- remotePort: {
270
- enumerable: true,
271
- writable: true,
272
- value: ""
273
- },
274
- raw: {
275
- enumerable: false,
276
- get: function() {
277
- return this[rawSymbol];
278
- },
279
- set: function(val) {
280
- this[rawSymbol] = val;
281
- }
282
- }
283
- });
284
- Object.defineProperty(pinoReqProto, rawSymbol, {
285
- writable: true,
286
- value: {}
287
- });
288
- function reqSerializer(req) {
289
- const connection = req.info || req.socket;
290
- const _req = Object.create(pinoReqProto);
291
- _req.id = typeof req.id === "function" ? req.id() : req.id || (req.info ? req.info.id : void 0);
292
- _req.method = req.method;
293
- if (req.originalUrl) {
294
- _req.url = req.originalUrl;
295
- } else {
296
- const path = req.path;
297
- _req.url = typeof path === "string" ? path : req.url ? req.url.path || req.url : void 0;
298
- }
299
- if (req.query) {
300
- _req.query = req.query;
301
- }
302
- if (req.params) {
303
- _req.params = req.params;
304
- }
305
- _req.headers = req.headers;
306
- _req.remoteAddress = connection && connection.remoteAddress;
307
- _req.remotePort = connection && connection.remotePort;
308
- _req.raw = req.raw || req;
309
- return _req;
310
- }
311
- function mapHttpRequest(req) {
312
- return {
313
- req: reqSerializer(req)
314
- };
315
- }
316
- }
317
- });
318
-
319
- // ../../node_modules/pino-std-serializers/lib/res.js
320
- var require_res = __commonJS({
321
- "../../node_modules/pino-std-serializers/lib/res.js"(exports, module) {
322
- "use strict";
323
- module.exports = {
324
- mapHttpResponse,
325
- resSerializer
326
- };
327
- var rawSymbol = /* @__PURE__ */ Symbol("pino-raw-res-ref");
328
- var pinoResProto = Object.create({}, {
329
- statusCode: {
330
- enumerable: true,
331
- writable: true,
332
- value: 0
333
- },
334
- headers: {
335
- enumerable: true,
336
- writable: true,
337
- value: ""
338
- },
339
- raw: {
340
- enumerable: false,
341
- get: function() {
342
- return this[rawSymbol];
343
- },
344
- set: function(val) {
345
- this[rawSymbol] = val;
346
- }
347
- }
348
- });
349
- Object.defineProperty(pinoResProto, rawSymbol, {
350
- writable: true,
351
- value: {}
352
- });
353
- function resSerializer(res) {
354
- const _res = Object.create(pinoResProto);
355
- _res.statusCode = res.headersSent ? res.statusCode : null;
356
- _res.headers = res.getHeaders ? res.getHeaders() : res._headers;
357
- _res.raw = res;
358
- return _res;
359
- }
360
- function mapHttpResponse(res) {
361
- return {
362
- res: resSerializer(res)
363
- };
364
- }
365
- }
366
- });
367
-
368
- // ../../node_modules/pino-std-serializers/index.js
369
- var require_pino_std_serializers = __commonJS({
370
- "../../node_modules/pino-std-serializers/index.js"(exports, module) {
371
- "use strict";
372
- var errSerializer = require_err();
373
- var errWithCauseSerializer = require_err_with_cause();
374
- var reqSerializers = require_req();
375
- var resSerializers = require_res();
376
- module.exports = {
377
- err: errSerializer,
378
- errWithCause: errWithCauseSerializer,
379
- mapHttpRequest: reqSerializers.mapHttpRequest,
380
- mapHttpResponse: resSerializers.mapHttpResponse,
381
- req: reqSerializers.reqSerializer,
382
- res: resSerializers.resSerializer,
383
- wrapErrorSerializer: function wrapErrorSerializer(customSerializer) {
384
- if (customSerializer === errSerializer) return customSerializer;
385
- return function wrapErrSerializer(err) {
386
- return customSerializer(errSerializer(err));
387
- };
388
- },
389
- wrapRequestSerializer: function wrapRequestSerializer(customSerializer) {
390
- if (customSerializer === reqSerializers.reqSerializer) return customSerializer;
391
- return function wrappedReqSerializer(req) {
392
- return customSerializer(reqSerializers.reqSerializer(req));
393
- };
394
- },
395
- wrapResponseSerializer: function wrapResponseSerializer(customSerializer) {
396
- if (customSerializer === resSerializers.resSerializer) return customSerializer;
397
- return function wrappedResSerializer(res) {
398
- return customSerializer(resSerializers.resSerializer(res));
399
- };
400
- }
401
- };
402
- }
403
- });
404
-
405
- // ../../node_modules/pino/lib/caller.js
406
- var require_caller = __commonJS({
407
- "../../node_modules/pino/lib/caller.js"(exports, module) {
408
- "use strict";
409
- function noOpPrepareStackTrace(_, stack) {
410
- return stack;
411
- }
412
- module.exports = function getCallers() {
413
- const originalPrepare = Error.prepareStackTrace;
414
- Error.prepareStackTrace = noOpPrepareStackTrace;
415
- const stack = new Error().stack;
416
- Error.prepareStackTrace = originalPrepare;
417
- if (!Array.isArray(stack)) {
418
- return void 0;
419
- }
420
- const entries = stack.slice(2);
421
- const fileNames = [];
422
- for (const entry of entries) {
423
- if (!entry) {
424
- continue;
425
- }
426
- fileNames.push(entry.getFileName());
427
- }
428
- return fileNames;
429
- };
430
- }
431
- });
432
-
433
- // ../../node_modules/@pinojs/redact/index.js
434
- var require_redact = __commonJS({
435
- "../../node_modules/@pinojs/redact/index.js"(exports, module) {
436
- "use strict";
437
- function deepClone(obj) {
438
- if (obj === null || typeof obj !== "object") {
439
- return obj;
440
- }
441
- if (obj instanceof Date) {
442
- return new Date(obj.getTime());
443
- }
444
- if (obj instanceof Array) {
445
- const cloned = [];
446
- for (let i = 0; i < obj.length; i++) {
447
- cloned[i] = deepClone(obj[i]);
448
- }
449
- return cloned;
450
- }
451
- if (typeof obj === "object") {
452
- const cloned = Object.create(Object.getPrototypeOf(obj));
453
- for (const key in obj) {
454
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
455
- cloned[key] = deepClone(obj[key]);
456
- }
457
- }
458
- return cloned;
459
- }
460
- return obj;
461
- }
462
- function parsePath(path) {
463
- const parts = [];
464
- let current = "";
465
- let inBrackets = false;
466
- let inQuotes = false;
467
- let quoteChar = "";
468
- for (let i = 0; i < path.length; i++) {
469
- const char = path[i];
470
- if (!inBrackets && char === ".") {
471
- if (current) {
472
- parts.push(current);
473
- current = "";
474
- }
475
- } else if (char === "[") {
476
- if (current) {
477
- parts.push(current);
478
- current = "";
479
- }
480
- inBrackets = true;
481
- } else if (char === "]" && inBrackets) {
482
- parts.push(current);
483
- current = "";
484
- inBrackets = false;
485
- inQuotes = false;
486
- } else if ((char === '"' || char === "'") && inBrackets) {
487
- if (!inQuotes) {
488
- inQuotes = true;
489
- quoteChar = char;
490
- } else if (char === quoteChar) {
491
- inQuotes = false;
492
- quoteChar = "";
493
- } else {
494
- current += char;
495
- }
496
- } else {
497
- current += char;
498
- }
499
- }
500
- if (current) {
501
- parts.push(current);
502
- }
503
- return parts;
504
- }
505
- function setValue(obj, parts, value) {
506
- let current = obj;
507
- for (let i = 0; i < parts.length - 1; i++) {
508
- const key = parts[i];
509
- if (typeof current !== "object" || current === null || !(key in current)) {
510
- return false;
511
- }
512
- if (typeof current[key] !== "object" || current[key] === null) {
513
- return false;
514
- }
515
- current = current[key];
516
- }
517
- const lastKey = parts[parts.length - 1];
518
- if (lastKey === "*") {
519
- if (Array.isArray(current)) {
520
- for (let i = 0; i < current.length; i++) {
521
- current[i] = value;
522
- }
523
- } else if (typeof current === "object" && current !== null) {
524
- for (const key in current) {
525
- if (Object.prototype.hasOwnProperty.call(current, key)) {
526
- current[key] = value;
527
- }
528
- }
529
- }
530
- } else {
531
- if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
532
- current[lastKey] = value;
533
- }
534
- }
535
- return true;
536
- }
537
- function removeKey(obj, parts) {
538
- let current = obj;
539
- for (let i = 0; i < parts.length - 1; i++) {
540
- const key = parts[i];
541
- if (typeof current !== "object" || current === null || !(key in current)) {
542
- return false;
543
- }
544
- if (typeof current[key] !== "object" || current[key] === null) {
545
- return false;
546
- }
547
- current = current[key];
548
- }
549
- const lastKey = parts[parts.length - 1];
550
- if (lastKey === "*") {
551
- if (Array.isArray(current)) {
552
- for (let i = 0; i < current.length; i++) {
553
- current[i] = void 0;
554
- }
555
- } else if (typeof current === "object" && current !== null) {
556
- for (const key in current) {
557
- if (Object.prototype.hasOwnProperty.call(current, key)) {
558
- delete current[key];
559
- }
560
- }
561
- }
562
- } else {
563
- if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
564
- delete current[lastKey];
565
- }
566
- }
567
- return true;
568
- }
569
- var PATH_NOT_FOUND = /* @__PURE__ */ Symbol("PATH_NOT_FOUND");
570
- function getValueIfExists(obj, parts) {
571
- let current = obj;
572
- for (const part of parts) {
573
- if (current === null || current === void 0) {
574
- return PATH_NOT_FOUND;
575
- }
576
- if (typeof current !== "object" || current === null) {
577
- return PATH_NOT_FOUND;
578
- }
579
- if (!(part in current)) {
580
- return PATH_NOT_FOUND;
581
- }
582
- current = current[part];
583
- }
584
- return current;
585
- }
586
- function getValue(obj, parts) {
587
- let current = obj;
588
- for (const part of parts) {
589
- if (current === null || current === void 0) {
590
- return void 0;
591
- }
592
- if (typeof current !== "object" || current === null) {
593
- return void 0;
594
- }
595
- current = current[part];
596
- }
597
- return current;
598
- }
599
- function redactPaths(obj, paths, censor, remove = false) {
600
- for (const path of paths) {
601
- const parts = parsePath(path);
602
- if (parts.includes("*")) {
603
- redactWildcardPath(obj, parts, censor, path, remove);
604
- } else {
605
- if (remove) {
606
- removeKey(obj, parts);
607
- } else {
608
- const value = getValueIfExists(obj, parts);
609
- if (value === PATH_NOT_FOUND) {
610
- continue;
611
- }
612
- const actualCensor = typeof censor === "function" ? censor(value, parts) : censor;
613
- setValue(obj, parts, actualCensor);
614
- }
615
- }
616
- }
617
- }
618
- function redactWildcardPath(obj, parts, censor, originalPath, remove = false) {
619
- const wildcardIndex = parts.indexOf("*");
620
- if (wildcardIndex === parts.length - 1) {
621
- const parentParts = parts.slice(0, -1);
622
- let current = obj;
623
- for (const part of parentParts) {
624
- if (current === null || current === void 0) return;
625
- if (typeof current !== "object" || current === null) return;
626
- current = current[part];
627
- }
628
- if (Array.isArray(current)) {
629
- if (remove) {
630
- for (let i = 0; i < current.length; i++) {
631
- current[i] = void 0;
632
- }
633
- } else {
634
- for (let i = 0; i < current.length; i++) {
635
- const indexPath = [...parentParts, i.toString()];
636
- const actualCensor = typeof censor === "function" ? censor(current[i], indexPath) : censor;
637
- current[i] = actualCensor;
638
- }
639
- }
640
- } else if (typeof current === "object" && current !== null) {
641
- if (remove) {
642
- const keysToDelete = [];
643
- for (const key in current) {
644
- if (Object.prototype.hasOwnProperty.call(current, key)) {
645
- keysToDelete.push(key);
646
- }
647
- }
648
- for (const key of keysToDelete) {
649
- delete current[key];
650
- }
651
- } else {
652
- for (const key in current) {
653
- const keyPath = [...parentParts, key];
654
- const actualCensor = typeof censor === "function" ? censor(current[key], keyPath) : censor;
655
- current[key] = actualCensor;
656
- }
657
- }
658
- }
659
- } else {
660
- redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove);
661
- }
662
- }
663
- function redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove = false) {
664
- const beforeWildcard = parts.slice(0, wildcardIndex);
665
- const afterWildcard = parts.slice(wildcardIndex + 1);
666
- const pathArray = [];
667
- function traverse(current, pathLength) {
668
- if (pathLength === beforeWildcard.length) {
669
- if (Array.isArray(current)) {
670
- for (let i = 0; i < current.length; i++) {
671
- pathArray[pathLength] = i.toString();
672
- traverse(current[i], pathLength + 1);
673
- }
674
- } else if (typeof current === "object" && current !== null) {
675
- for (const key in current) {
676
- pathArray[pathLength] = key;
677
- traverse(current[key], pathLength + 1);
678
- }
679
- }
680
- } else if (pathLength < beforeWildcard.length) {
681
- const nextKey = beforeWildcard[pathLength];
682
- if (current && typeof current === "object" && current !== null && nextKey in current) {
683
- pathArray[pathLength] = nextKey;
684
- traverse(current[nextKey], pathLength + 1);
685
- }
686
- } else {
687
- if (afterWildcard.includes("*")) {
688
- const wrappedCensor = typeof censor === "function" ? (value, path) => {
689
- const fullPath = [...pathArray.slice(0, pathLength), ...path];
690
- return censor(value, fullPath);
691
- } : censor;
692
- redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
693
- } else {
694
- if (remove) {
695
- removeKey(current, afterWildcard);
696
- } else {
697
- const actualCensor = typeof censor === "function" ? censor(getValue(current, afterWildcard), [...pathArray.slice(0, pathLength), ...afterWildcard]) : censor;
698
- setValue(current, afterWildcard, actualCensor);
699
- }
700
- }
701
- }
702
- }
703
- if (beforeWildcard.length === 0) {
704
- traverse(obj, 0);
705
- } else {
706
- let current = obj;
707
- for (let i = 0; i < beforeWildcard.length; i++) {
708
- const part = beforeWildcard[i];
709
- if (current === null || current === void 0) return;
710
- if (typeof current !== "object" || current === null) return;
711
- current = current[part];
712
- pathArray[i] = part;
713
- }
714
- if (current !== null && current !== void 0) {
715
- traverse(current, beforeWildcard.length);
716
- }
717
- }
718
- }
719
- function buildPathStructure(pathsToClone) {
720
- if (pathsToClone.length === 0) {
721
- return null;
722
- }
723
- const pathStructure = /* @__PURE__ */ new Map();
724
- for (const path of pathsToClone) {
725
- const parts = parsePath(path);
726
- let current = pathStructure;
727
- for (let i = 0; i < parts.length; i++) {
728
- const part = parts[i];
729
- if (!current.has(part)) {
730
- current.set(part, /* @__PURE__ */ new Map());
731
- }
732
- current = current.get(part);
733
- }
734
- }
735
- return pathStructure;
736
- }
737
- function selectiveClone(obj, pathStructure) {
738
- if (!pathStructure) {
739
- return obj;
740
- }
741
- function cloneSelectively(source, pathMap, depth = 0) {
742
- if (!pathMap || pathMap.size === 0) {
743
- return source;
744
- }
745
- if (source === null || typeof source !== "object") {
746
- return source;
747
- }
748
- if (source instanceof Date) {
749
- return new Date(source.getTime());
750
- }
751
- if (Array.isArray(source)) {
752
- const cloned2 = [];
753
- for (let i = 0; i < source.length; i++) {
754
- const indexStr = i.toString();
755
- if (pathMap.has(indexStr) || pathMap.has("*")) {
756
- cloned2[i] = cloneSelectively(source[i], pathMap.get(indexStr) || pathMap.get("*"));
757
- } else {
758
- cloned2[i] = source[i];
759
- }
760
- }
761
- return cloned2;
762
- }
763
- const cloned = Object.create(Object.getPrototypeOf(source));
764
- for (const key in source) {
765
- if (Object.prototype.hasOwnProperty.call(source, key)) {
766
- if (pathMap.has(key) || pathMap.has("*")) {
767
- cloned[key] = cloneSelectively(source[key], pathMap.get(key) || pathMap.get("*"));
768
- } else {
769
- cloned[key] = source[key];
770
- }
771
- }
772
- }
773
- return cloned;
774
- }
775
- return cloneSelectively(obj, pathStructure);
776
- }
777
- function validatePath(path) {
778
- if (typeof path !== "string") {
779
- throw new Error("Paths must be (non-empty) strings");
780
- }
781
- if (path === "") {
782
- throw new Error("Invalid redaction path ()");
783
- }
784
- if (path.includes("..")) {
785
- throw new Error(`Invalid redaction path (${path})`);
786
- }
787
- if (path.includes(",")) {
788
- throw new Error(`Invalid redaction path (${path})`);
789
- }
790
- let bracketCount = 0;
791
- let inQuotes = false;
792
- let quoteChar = "";
793
- for (let i = 0; i < path.length; i++) {
794
- const char = path[i];
795
- if ((char === '"' || char === "'") && bracketCount > 0) {
796
- if (!inQuotes) {
797
- inQuotes = true;
798
- quoteChar = char;
799
- } else if (char === quoteChar) {
800
- inQuotes = false;
801
- quoteChar = "";
802
- }
803
- } else if (char === "[" && !inQuotes) {
804
- bracketCount++;
805
- } else if (char === "]" && !inQuotes) {
806
- bracketCount--;
807
- if (bracketCount < 0) {
808
- throw new Error(`Invalid redaction path (${path})`);
809
- }
810
- }
811
- }
812
- if (bracketCount !== 0) {
813
- throw new Error(`Invalid redaction path (${path})`);
814
- }
815
- }
816
- function validatePaths(paths) {
817
- if (!Array.isArray(paths)) {
818
- throw new TypeError("paths must be an array");
819
- }
820
- for (const path of paths) {
821
- validatePath(path);
822
- }
823
- }
824
- function slowRedact(options = {}) {
825
- const {
826
- paths = [],
827
- censor = "[REDACTED]",
828
- serialize = JSON.stringify,
829
- strict = true,
830
- remove = false
831
- } = options;
832
- validatePaths(paths);
833
- const pathStructure = buildPathStructure(paths);
834
- return function redact(obj) {
835
- if (strict && (obj === null || typeof obj !== "object")) {
836
- if (obj === null || obj === void 0) {
837
- return serialize ? serialize(obj) : obj;
838
- }
839
- if (typeof obj !== "object") {
840
- return serialize ? serialize(obj) : obj;
841
- }
842
- }
843
- const cloned = selectiveClone(obj, pathStructure);
844
- const original = obj;
845
- let actualCensor = censor;
846
- if (typeof censor === "function") {
847
- actualCensor = censor;
848
- }
849
- redactPaths(cloned, paths, actualCensor, remove);
850
- if (serialize === false) {
851
- cloned.restore = function() {
852
- return deepClone(original);
853
- };
854
- return cloned;
855
- }
856
- if (typeof serialize === "function") {
857
- return serialize(cloned);
858
- }
859
- return JSON.stringify(cloned);
860
- };
861
- }
862
- module.exports = slowRedact;
863
- }
864
- });
865
-
866
- // ../../node_modules/pino/lib/symbols.js
867
- var require_symbols = __commonJS({
868
- "../../node_modules/pino/lib/symbols.js"(exports, module) {
869
- "use strict";
870
- var setLevelSym = /* @__PURE__ */ Symbol("pino.setLevel");
871
- var getLevelSym = /* @__PURE__ */ Symbol("pino.getLevel");
872
- var levelValSym = /* @__PURE__ */ Symbol("pino.levelVal");
873
- var levelCompSym = /* @__PURE__ */ Symbol("pino.levelComp");
874
- var useLevelLabelsSym = /* @__PURE__ */ Symbol("pino.useLevelLabels");
875
- var useOnlyCustomLevelsSym = /* @__PURE__ */ Symbol("pino.useOnlyCustomLevels");
876
- var mixinSym = /* @__PURE__ */ Symbol("pino.mixin");
877
- var lsCacheSym = /* @__PURE__ */ Symbol("pino.lsCache");
878
- var chindingsSym = /* @__PURE__ */ Symbol("pino.chindings");
879
- var asJsonSym = /* @__PURE__ */ Symbol("pino.asJson");
880
- var writeSym = /* @__PURE__ */ Symbol("pino.write");
881
- var redactFmtSym = /* @__PURE__ */ Symbol("pino.redactFmt");
882
- var timeSym = /* @__PURE__ */ Symbol("pino.time");
883
- var timeSliceIndexSym = /* @__PURE__ */ Symbol("pino.timeSliceIndex");
884
- var streamSym = /* @__PURE__ */ Symbol("pino.stream");
885
- var stringifySym = /* @__PURE__ */ Symbol("pino.stringify");
886
- var stringifySafeSym = /* @__PURE__ */ Symbol("pino.stringifySafe");
887
- var stringifiersSym = /* @__PURE__ */ Symbol("pino.stringifiers");
888
- var endSym = /* @__PURE__ */ Symbol("pino.end");
889
- var formatOptsSym = /* @__PURE__ */ Symbol("pino.formatOpts");
890
- var messageKeySym = /* @__PURE__ */ Symbol("pino.messageKey");
891
- var errorKeySym = /* @__PURE__ */ Symbol("pino.errorKey");
892
- var nestedKeySym = /* @__PURE__ */ Symbol("pino.nestedKey");
893
- var nestedKeyStrSym = /* @__PURE__ */ Symbol("pino.nestedKeyStr");
894
- var mixinMergeStrategySym = /* @__PURE__ */ Symbol("pino.mixinMergeStrategy");
895
- var msgPrefixSym = /* @__PURE__ */ Symbol("pino.msgPrefix");
896
- var wildcardFirstSym = /* @__PURE__ */ Symbol("pino.wildcardFirst");
897
- var serializersSym = /* @__PURE__ */ Symbol.for("pino.serializers");
898
- var formattersSym = /* @__PURE__ */ Symbol.for("pino.formatters");
899
- var hooksSym = /* @__PURE__ */ Symbol.for("pino.hooks");
900
- var needsMetadataGsym = /* @__PURE__ */ Symbol.for("pino.metadata");
901
- module.exports = {
902
- setLevelSym,
903
- getLevelSym,
904
- levelValSym,
905
- levelCompSym,
906
- useLevelLabelsSym,
907
- mixinSym,
908
- lsCacheSym,
909
- chindingsSym,
910
- asJsonSym,
911
- writeSym,
912
- serializersSym,
913
- redactFmtSym,
914
- timeSym,
915
- timeSliceIndexSym,
916
- streamSym,
917
- stringifySym,
918
- stringifySafeSym,
919
- stringifiersSym,
920
- endSym,
921
- formatOptsSym,
922
- messageKeySym,
923
- errorKeySym,
924
- nestedKeySym,
925
- wildcardFirstSym,
926
- needsMetadataGsym,
927
- useOnlyCustomLevelsSym,
928
- formattersSym,
929
- hooksSym,
930
- nestedKeyStrSym,
931
- mixinMergeStrategySym,
932
- msgPrefixSym
933
- };
934
- }
935
- });
936
-
937
- // ../../node_modules/pino/lib/redaction.js
938
- var require_redaction = __commonJS({
939
- "../../node_modules/pino/lib/redaction.js"(exports, module) {
940
- "use strict";
941
- var Redact = require_redact();
942
- var { redactFmtSym, wildcardFirstSym } = require_symbols();
943
- var rx = /[^.[\]]+|\[([^[\]]*?)\]/g;
944
- var CENSOR = "[Redacted]";
945
- var strict = false;
946
- function redaction(opts, serialize) {
947
- const { paths, censor, remove } = handle(opts);
948
- const shape = paths.reduce((o, str) => {
949
- rx.lastIndex = 0;
950
- const first = rx.exec(str);
951
- const next = rx.exec(str);
952
- let ns = first[1] !== void 0 ? first[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/, "$1") : first[0];
953
- if (ns === "*") {
954
- ns = wildcardFirstSym;
955
- }
956
- if (next === null) {
957
- o[ns] = null;
958
- return o;
959
- }
960
- if (o[ns] === null) {
961
- return o;
962
- }
963
- const { index } = next;
964
- const nextPath = `${str.substr(index, str.length - 1)}`;
965
- o[ns] = o[ns] || [];
966
- if (ns !== wildcardFirstSym && o[ns].length === 0) {
967
- o[ns].push(...o[wildcardFirstSym] || []);
968
- }
969
- if (ns === wildcardFirstSym) {
970
- Object.keys(o).forEach(function(k) {
971
- if (o[k]) {
972
- o[k].push(nextPath);
973
- }
974
- });
975
- }
976
- o[ns].push(nextPath);
977
- return o;
978
- }, {});
979
- const result = {
980
- [redactFmtSym]: Redact({ paths, censor, serialize, strict, remove })
981
- };
982
- const topCensor = (...args) => {
983
- return typeof censor === "function" ? serialize(censor(...args)) : serialize(censor);
984
- };
985
- return [...Object.keys(shape), ...Object.getOwnPropertySymbols(shape)].reduce((o, k) => {
986
- if (shape[k] === null) {
987
- o[k] = (value) => topCensor(value, [k]);
988
- } else {
989
- const wrappedCensor = typeof censor === "function" ? (value, path) => {
990
- return censor(value, [k, ...path]);
991
- } : censor;
992
- o[k] = Redact({
993
- paths: shape[k],
994
- censor: wrappedCensor,
995
- serialize,
996
- strict,
997
- remove
998
- });
999
- }
1000
- return o;
1001
- }, result);
1002
- }
1003
- function handle(opts) {
1004
- if (Array.isArray(opts)) {
1005
- opts = { paths: opts, censor: CENSOR };
1006
- return opts;
1007
- }
1008
- let { paths, censor = CENSOR, remove } = opts;
1009
- if (Array.isArray(paths) === false) {
1010
- throw Error("pino \u2013 redact must contain an array of strings");
1011
- }
1012
- if (remove === true) censor = void 0;
1013
- return { paths, censor, remove };
1014
- }
1015
- module.exports = redaction;
1016
- }
1017
- });
1018
-
1019
- // ../../node_modules/pino/lib/time.js
1020
- var require_time = __commonJS({
1021
- "../../node_modules/pino/lib/time.js"(exports, module) {
1022
- "use strict";
1023
- var nullTime = () => "";
1024
- var epochTime = () => `,"time":${Date.now()}`;
1025
- var unixTime = () => `,"time":${Math.round(Date.now() / 1e3)}`;
1026
- var isoTime = () => `,"time":"${new Date(Date.now()).toISOString()}"`;
1027
- var NS_PER_MS = 1000000n;
1028
- var NS_PER_SEC = 1000000000n;
1029
- var startWallTimeNs = BigInt(Date.now()) * NS_PER_MS;
1030
- var startHrTime = process.hrtime.bigint();
1031
- var isoTimeNano = () => {
1032
- const elapsedNs = process.hrtime.bigint() - startHrTime;
1033
- const currentTimeNs = startWallTimeNs + elapsedNs;
1034
- const secondsSinceEpoch = currentTimeNs / NS_PER_SEC;
1035
- const nanosWithinSecond = currentTimeNs % NS_PER_SEC;
1036
- const msSinceEpoch = Number(secondsSinceEpoch * 1000n + nanosWithinSecond / 1000000n);
1037
- const date = new Date(msSinceEpoch);
1038
- const year = date.getUTCFullYear();
1039
- const month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
1040
- const day = date.getUTCDate().toString().padStart(2, "0");
1041
- const hours = date.getUTCHours().toString().padStart(2, "0");
1042
- const minutes = date.getUTCMinutes().toString().padStart(2, "0");
1043
- const seconds = date.getUTCSeconds().toString().padStart(2, "0");
1044
- return `,"time":"${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${nanosWithinSecond.toString().padStart(9, "0")}Z"`;
1045
- };
1046
- module.exports = { nullTime, epochTime, unixTime, isoTime, isoTimeNano };
1047
- }
1048
- });
1049
-
1050
- // ../../node_modules/quick-format-unescaped/index.js
1051
- var require_quick_format_unescaped = __commonJS({
1052
- "../../node_modules/quick-format-unescaped/index.js"(exports, module) {
1053
- "use strict";
1054
- function tryStringify(o) {
1055
- try {
1056
- return JSON.stringify(o);
1057
- } catch (e) {
1058
- return '"[Circular]"';
1059
- }
1060
- }
1061
- module.exports = format;
1062
- function format(f, args, opts) {
1063
- var ss = opts && opts.stringify || tryStringify;
1064
- var offset = 1;
1065
- if (typeof f === "object" && f !== null) {
1066
- var len = args.length + offset;
1067
- if (len === 1) return f;
1068
- var objects = new Array(len);
1069
- objects[0] = ss(f);
1070
- for (var index = 1; index < len; index++) {
1071
- objects[index] = ss(args[index]);
1072
- }
1073
- return objects.join(" ");
1074
- }
1075
- if (typeof f !== "string") {
1076
- return f;
1077
- }
1078
- var argLen = args.length;
1079
- if (argLen === 0) return f;
1080
- var str = "";
1081
- var a = 1 - offset;
1082
- var lastPos = -1;
1083
- var flen = f && f.length || 0;
1084
- for (var i = 0; i < flen; ) {
1085
- if (f.charCodeAt(i) === 37 && i + 1 < flen) {
1086
- lastPos = lastPos > -1 ? lastPos : 0;
1087
- switch (f.charCodeAt(i + 1)) {
1088
- case 100:
1089
- // 'd'
1090
- case 102:
1091
- if (a >= argLen)
1092
- break;
1093
- if (args[a] == null) break;
1094
- if (lastPos < i)
1095
- str += f.slice(lastPos, i);
1096
- str += Number(args[a]);
1097
- lastPos = i + 2;
1098
- i++;
1099
- break;
1100
- case 105:
1101
- if (a >= argLen)
1102
- break;
1103
- if (args[a] == null) break;
1104
- if (lastPos < i)
1105
- str += f.slice(lastPos, i);
1106
- str += Math.floor(Number(args[a]));
1107
- lastPos = i + 2;
1108
- i++;
1109
- break;
1110
- case 79:
1111
- // 'O'
1112
- case 111:
1113
- // 'o'
1114
- case 106:
1115
- if (a >= argLen)
1116
- break;
1117
- if (args[a] === void 0) break;
1118
- if (lastPos < i)
1119
- str += f.slice(lastPos, i);
1120
- var type = typeof args[a];
1121
- if (type === "string") {
1122
- str += "'" + args[a] + "'";
1123
- lastPos = i + 2;
1124
- i++;
1125
- break;
1126
- }
1127
- if (type === "function") {
1128
- str += args[a].name || "<anonymous>";
1129
- lastPos = i + 2;
1130
- i++;
1131
- break;
1132
- }
1133
- str += ss(args[a]);
1134
- lastPos = i + 2;
1135
- i++;
1136
- break;
1137
- case 115:
1138
- if (a >= argLen)
1139
- break;
1140
- if (lastPos < i)
1141
- str += f.slice(lastPos, i);
1142
- str += String(args[a]);
1143
- lastPos = i + 2;
1144
- i++;
1145
- break;
1146
- case 37:
1147
- if (lastPos < i)
1148
- str += f.slice(lastPos, i);
1149
- str += "%";
1150
- lastPos = i + 2;
1151
- i++;
1152
- a--;
1153
- break;
1154
- }
1155
- ++a;
1156
- }
1157
- ++i;
1158
- }
1159
- if (lastPos === -1)
1160
- return f;
1161
- else if (lastPos < flen) {
1162
- str += f.slice(lastPos);
1163
- }
1164
- return str;
1165
- }
1166
- }
1167
- });
1168
-
1169
- // ../../node_modules/atomic-sleep/index.js
1170
- var require_atomic_sleep = __commonJS({
1171
- "../../node_modules/atomic-sleep/index.js"(exports, module) {
1172
- "use strict";
1173
- if (typeof SharedArrayBuffer !== "undefined" && typeof Atomics !== "undefined") {
1174
- let sleep = function(ms) {
1175
- const valid = ms > 0 && ms < Infinity;
1176
- if (valid === false) {
1177
- if (typeof ms !== "number" && typeof ms !== "bigint") {
1178
- throw TypeError("sleep: ms must be a number");
1179
- }
1180
- throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");
1181
- }
1182
- Atomics.wait(nil, 0, 0, Number(ms));
1183
- };
1184
- const nil = new Int32Array(new SharedArrayBuffer(4));
1185
- module.exports = sleep;
1186
- } else {
1187
- let sleep = function(ms) {
1188
- const valid = ms > 0 && ms < Infinity;
1189
- if (valid === false) {
1190
- if (typeof ms !== "number" && typeof ms !== "bigint") {
1191
- throw TypeError("sleep: ms must be a number");
1192
- }
1193
- throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");
1194
- }
1195
- const target = Date.now() + Number(ms);
1196
- while (target > Date.now()) {
1197
- }
1198
- };
1199
- module.exports = sleep;
1200
- }
1201
- }
1202
- });
1203
-
1204
- // ../../node_modules/sonic-boom/index.js
1205
- var require_sonic_boom = __commonJS({
1206
- "../../node_modules/sonic-boom/index.js"(exports, module) {
1207
- "use strict";
1208
- var fs = __require("fs");
1209
- var EventEmitter = __require("events");
1210
- var inherits = __require("util").inherits;
1211
- var path = __require("path");
1212
- var sleep = require_atomic_sleep();
1213
- var assert = __require("assert");
1214
- var BUSY_WRITE_TIMEOUT = 100;
1215
- var kEmptyBuffer = Buffer.allocUnsafe(0);
1216
- var MAX_WRITE = 16 * 1024;
1217
- var kContentModeBuffer = "buffer";
1218
- var kContentModeUtf8 = "utf8";
1219
- var [major, minor] = (process.versions.node || "0.0").split(".").map(Number);
1220
- var kCopyBuffer = major >= 22 && minor >= 7;
1221
- function openFile(file, sonic) {
1222
- sonic._opening = true;
1223
- sonic._writing = true;
1224
- sonic._asyncDrainScheduled = false;
1225
- function fileOpened(err, fd) {
1226
- if (err) {
1227
- sonic._reopening = false;
1228
- sonic._writing = false;
1229
- sonic._opening = false;
1230
- if (sonic.sync) {
1231
- process.nextTick(() => {
1232
- if (sonic.listenerCount("error") > 0) {
1233
- sonic.emit("error", err);
1234
- }
1235
- });
1236
- } else {
1237
- sonic.emit("error", err);
1238
- }
1239
- return;
1240
- }
1241
- const reopening = sonic._reopening;
1242
- sonic.fd = fd;
1243
- sonic.file = file;
1244
- sonic._reopening = false;
1245
- sonic._opening = false;
1246
- sonic._writing = false;
1247
- if (sonic.sync) {
1248
- process.nextTick(() => sonic.emit("ready"));
1249
- } else {
1250
- sonic.emit("ready");
1251
- }
1252
- if (sonic.destroyed) {
1253
- return;
1254
- }
1255
- if (!sonic._writing && sonic._len > sonic.minLength || sonic._flushPending) {
1256
- sonic._actualWrite();
1257
- } else if (reopening) {
1258
- process.nextTick(() => sonic.emit("drain"));
1259
- }
1260
- }
1261
- const flags = sonic.append ? "a" : "w";
1262
- const mode = sonic.mode;
1263
- if (sonic.sync) {
1264
- try {
1265
- if (sonic.mkdir) fs.mkdirSync(path.dirname(file), { recursive: true });
1266
- const fd = fs.openSync(file, flags, mode);
1267
- fileOpened(null, fd);
1268
- } catch (err) {
1269
- fileOpened(err);
1270
- throw err;
1271
- }
1272
- } else if (sonic.mkdir) {
1273
- fs.mkdir(path.dirname(file), { recursive: true }, (err) => {
1274
- if (err) return fileOpened(err);
1275
- fs.open(file, flags, mode, fileOpened);
1276
- });
1277
- } else {
1278
- fs.open(file, flags, mode, fileOpened);
1279
- }
1280
- }
1281
- function SonicBoom(opts) {
1282
- if (!(this instanceof SonicBoom)) {
1283
- return new SonicBoom(opts);
1284
- }
1285
- let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
1286
- fd = fd || dest;
1287
- this._len = 0;
1288
- this.fd = -1;
1289
- this._bufs = [];
1290
- this._lens = [];
1291
- this._writing = false;
1292
- this._ending = false;
1293
- this._reopening = false;
1294
- this._asyncDrainScheduled = false;
1295
- this._flushPending = false;
1296
- this._hwm = Math.max(minLength || 0, 16387);
1297
- this.file = null;
1298
- this.destroyed = false;
1299
- this.minLength = minLength || 0;
1300
- this.maxLength = maxLength || 0;
1301
- this.maxWrite = maxWrite || MAX_WRITE;
1302
- this._periodicFlush = periodicFlush || 0;
1303
- this._periodicFlushTimer = void 0;
1304
- this.sync = sync || false;
1305
- this.writable = true;
1306
- this._fsync = fsync || false;
1307
- this.append = append || false;
1308
- this.mode = mode;
1309
- this.retryEAGAIN = retryEAGAIN || (() => true);
1310
- this.mkdir = mkdir || false;
1311
- let fsWriteSync;
1312
- let fsWrite;
1313
- if (contentMode === kContentModeBuffer) {
1314
- this._writingBuf = kEmptyBuffer;
1315
- this.write = writeBuffer;
1316
- this.flush = flushBuffer;
1317
- this.flushSync = flushBufferSync;
1318
- this._actualWrite = actualWriteBuffer;
1319
- fsWriteSync = () => fs.writeSync(this.fd, this._writingBuf);
1320
- fsWrite = () => fs.write(this.fd, this._writingBuf, this.release);
1321
- } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
1322
- this._writingBuf = "";
1323
- this.write = write;
1324
- this.flush = flush;
1325
- this.flushSync = flushSync;
1326
- this._actualWrite = actualWrite;
1327
- fsWriteSync = () => {
1328
- if (Buffer.isBuffer(this._writingBuf)) {
1329
- return fs.writeSync(this.fd, this._writingBuf);
1330
- }
1331
- return fs.writeSync(this.fd, this._writingBuf, "utf8");
1332
- };
1333
- fsWrite = () => {
1334
- if (Buffer.isBuffer(this._writingBuf)) {
1335
- return fs.write(this.fd, this._writingBuf, this.release);
1336
- }
1337
- return fs.write(this.fd, this._writingBuf, "utf8", this.release);
1338
- };
1339
- } else {
1340
- throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
1341
- }
1342
- if (typeof fd === "number") {
1343
- this.fd = fd;
1344
- process.nextTick(() => this.emit("ready"));
1345
- } else if (typeof fd === "string") {
1346
- openFile(fd, this);
1347
- } else {
1348
- throw new Error("SonicBoom supports only file descriptors and files");
1349
- }
1350
- if (this.minLength >= this.maxWrite) {
1351
- throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);
1352
- }
1353
- this.release = (err, n) => {
1354
- if (err) {
1355
- if ((err.code === "EAGAIN" || err.code === "EBUSY") && this.retryEAGAIN(err, this._writingBuf.length, this._len - this._writingBuf.length)) {
1356
- if (this.sync) {
1357
- try {
1358
- sleep(BUSY_WRITE_TIMEOUT);
1359
- this.release(void 0, 0);
1360
- } catch (err2) {
1361
- this.release(err2);
1362
- }
1363
- } else {
1364
- setTimeout(fsWrite, BUSY_WRITE_TIMEOUT);
1365
- }
1366
- } else {
1367
- this._writing = false;
1368
- this.emit("error", err);
1369
- }
1370
- return;
1371
- }
1372
- this.emit("write", n);
1373
- const releasedBufObj = releaseWritingBuf(this._writingBuf, this._len, n);
1374
- this._len = releasedBufObj.len;
1375
- this._writingBuf = releasedBufObj.writingBuf;
1376
- if (this._writingBuf.length) {
1377
- if (!this.sync) {
1378
- fsWrite();
1379
- return;
1380
- }
1381
- try {
1382
- do {
1383
- const n2 = fsWriteSync();
1384
- const releasedBufObj2 = releaseWritingBuf(this._writingBuf, this._len, n2);
1385
- this._len = releasedBufObj2.len;
1386
- this._writingBuf = releasedBufObj2.writingBuf;
1387
- } while (this._writingBuf.length);
1388
- } catch (err2) {
1389
- this.release(err2);
1390
- return;
1391
- }
1392
- }
1393
- if (this._fsync) {
1394
- fs.fsyncSync(this.fd);
1395
- }
1396
- const len = this._len;
1397
- if (this._reopening) {
1398
- this._writing = false;
1399
- this._reopening = false;
1400
- this.reopen();
1401
- } else if (len > this.minLength) {
1402
- this._actualWrite();
1403
- } else if (this._ending) {
1404
- if (len > 0) {
1405
- this._actualWrite();
1406
- } else {
1407
- this._writing = false;
1408
- actualClose(this);
1409
- }
1410
- } else {
1411
- this._writing = false;
1412
- if (this.sync) {
1413
- if (!this._asyncDrainScheduled) {
1414
- this._asyncDrainScheduled = true;
1415
- process.nextTick(emitDrain, this);
1416
- }
1417
- } else {
1418
- this.emit("drain");
1419
- }
1420
- }
1421
- };
1422
- this.on("newListener", function(name) {
1423
- if (name === "drain") {
1424
- this._asyncDrainScheduled = false;
1425
- }
1426
- });
1427
- if (this._periodicFlush !== 0) {
1428
- this._periodicFlushTimer = setInterval(() => this.flush(null), this._periodicFlush);
1429
- this._periodicFlushTimer.unref();
1430
- }
1431
- }
1432
- function releaseWritingBuf(writingBuf, len, n) {
1433
- if (typeof writingBuf === "string") {
1434
- writingBuf = Buffer.from(writingBuf);
1435
- }
1436
- len = Math.max(len - n, 0);
1437
- writingBuf = writingBuf.subarray(n);
1438
- return { writingBuf, len };
1439
- }
1440
- function emitDrain(sonic) {
1441
- const hasListeners = sonic.listenerCount("drain") > 0;
1442
- if (!hasListeners) return;
1443
- sonic._asyncDrainScheduled = false;
1444
- sonic.emit("drain");
1445
- }
1446
- inherits(SonicBoom, EventEmitter);
1447
- function mergeBuf(bufs, len) {
1448
- if (bufs.length === 0) {
1449
- return kEmptyBuffer;
1450
- }
1451
- if (bufs.length === 1) {
1452
- return bufs[0];
1453
- }
1454
- return Buffer.concat(bufs, len);
1455
- }
1456
- function write(data) {
1457
- if (this.destroyed) {
1458
- throw new Error("SonicBoom destroyed");
1459
- }
1460
- data = "" + data;
1461
- const dataLen = Buffer.byteLength(data);
1462
- const len = this._len + dataLen;
1463
- const bufs = this._bufs;
1464
- if (this.maxLength && len > this.maxLength) {
1465
- this.emit("drop", data);
1466
- return this._len < this._hwm;
1467
- }
1468
- if (bufs.length === 0 || Buffer.byteLength(bufs[bufs.length - 1]) + dataLen > this.maxWrite) {
1469
- bufs.push(data);
1470
- } else {
1471
- bufs[bufs.length - 1] += data;
1472
- }
1473
- this._len = len;
1474
- if (!this._writing && this._len >= this.minLength) {
1475
- this._actualWrite();
1476
- }
1477
- return this._len < this._hwm;
1478
- }
1479
- function writeBuffer(data) {
1480
- if (this.destroyed) {
1481
- throw new Error("SonicBoom destroyed");
1482
- }
1483
- const len = this._len + data.length;
1484
- const bufs = this._bufs;
1485
- const lens = this._lens;
1486
- if (this.maxLength && len > this.maxLength) {
1487
- this.emit("drop", data);
1488
- return this._len < this._hwm;
1489
- }
1490
- if (bufs.length === 0 || lens[lens.length - 1] + data.length > this.maxWrite) {
1491
- bufs.push([data]);
1492
- lens.push(data.length);
1493
- } else {
1494
- bufs[bufs.length - 1].push(data);
1495
- lens[lens.length - 1] += data.length;
1496
- }
1497
- this._len = len;
1498
- if (!this._writing && this._len >= this.minLength) {
1499
- this._actualWrite();
1500
- }
1501
- return this._len < this._hwm;
1502
- }
1503
- function callFlushCallbackOnDrain(cb) {
1504
- this._flushPending = true;
1505
- const onDrain = () => {
1506
- if (!this._fsync) {
1507
- try {
1508
- fs.fsync(this.fd, (err) => {
1509
- this._flushPending = false;
1510
- cb(err);
1511
- });
1512
- } catch (err) {
1513
- cb(err);
1514
- }
1515
- } else {
1516
- this._flushPending = false;
1517
- cb();
1518
- }
1519
- this.off("error", onError);
1520
- };
1521
- const onError = (err) => {
1522
- this._flushPending = false;
1523
- cb(err);
1524
- this.off("drain", onDrain);
1525
- };
1526
- this.once("drain", onDrain);
1527
- this.once("error", onError);
1528
- }
1529
- function flush(cb) {
1530
- if (cb != null && typeof cb !== "function") {
1531
- throw new Error("flush cb must be a function");
1532
- }
1533
- if (this.destroyed) {
1534
- const error = new Error("SonicBoom destroyed");
1535
- if (cb) {
1536
- cb(error);
1537
- return;
1538
- }
1539
- throw error;
1540
- }
1541
- if (this.minLength <= 0) {
1542
- cb?.();
1543
- return;
1544
- }
1545
- if (cb) {
1546
- callFlushCallbackOnDrain.call(this, cb);
1547
- }
1548
- if (this._writing) {
1549
- return;
1550
- }
1551
- if (this._bufs.length === 0) {
1552
- this._bufs.push("");
1553
- }
1554
- this._actualWrite();
1555
- }
1556
- function flushBuffer(cb) {
1557
- if (cb != null && typeof cb !== "function") {
1558
- throw new Error("flush cb must be a function");
1559
- }
1560
- if (this.destroyed) {
1561
- const error = new Error("SonicBoom destroyed");
1562
- if (cb) {
1563
- cb(error);
1564
- return;
1565
- }
1566
- throw error;
1567
- }
1568
- if (this.minLength <= 0) {
1569
- cb?.();
1570
- return;
1571
- }
1572
- if (cb) {
1573
- callFlushCallbackOnDrain.call(this, cb);
1574
- }
1575
- if (this._writing) {
1576
- return;
1577
- }
1578
- if (this._bufs.length === 0) {
1579
- this._bufs.push([]);
1580
- this._lens.push(0);
1581
- }
1582
- this._actualWrite();
1583
- }
1584
- SonicBoom.prototype.reopen = function(file) {
1585
- if (this.destroyed) {
1586
- throw new Error("SonicBoom destroyed");
1587
- }
1588
- if (this._opening) {
1589
- this.once("ready", () => {
1590
- this.reopen(file);
1591
- });
1592
- return;
1593
- }
1594
- if (this._ending) {
1595
- return;
1596
- }
1597
- if (!this.file) {
1598
- throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");
1599
- }
1600
- if (file) {
1601
- this.file = file;
1602
- }
1603
- this._reopening = true;
1604
- if (this._writing) {
1605
- return;
1606
- }
1607
- const fd = this.fd;
1608
- this.once("ready", () => {
1609
- if (fd !== this.fd) {
1610
- fs.close(fd, (err) => {
1611
- if (err) {
1612
- return this.emit("error", err);
1613
- }
1614
- });
1615
- }
1616
- });
1617
- openFile(this.file, this);
1618
- };
1619
- SonicBoom.prototype.end = function() {
1620
- if (this.destroyed) {
1621
- throw new Error("SonicBoom destroyed");
1622
- }
1623
- if (this._opening) {
1624
- this.once("ready", () => {
1625
- this.end();
1626
- });
1627
- return;
1628
- }
1629
- if (this._ending) {
1630
- return;
1631
- }
1632
- this._ending = true;
1633
- if (this._writing) {
1634
- return;
1635
- }
1636
- if (this._len > 0 && this.fd >= 0) {
1637
- this._actualWrite();
1638
- } else {
1639
- actualClose(this);
1640
- }
1641
- };
1642
- function flushSync() {
1643
- if (this.destroyed) {
1644
- throw new Error("SonicBoom destroyed");
1645
- }
1646
- if (this.fd < 0) {
1647
- throw new Error("sonic boom is not ready yet");
1648
- }
1649
- if (!this._writing && this._writingBuf.length > 0) {
1650
- this._bufs.unshift(this._writingBuf);
1651
- this._writingBuf = "";
1652
- }
1653
- let buf = "";
1654
- while (this._bufs.length || buf.length) {
1655
- if (buf.length <= 0) {
1656
- buf = this._bufs[0];
1657
- }
1658
- try {
1659
- const n = Buffer.isBuffer(buf) ? fs.writeSync(this.fd, buf) : fs.writeSync(this.fd, buf, "utf8");
1660
- const releasedBufObj = releaseWritingBuf(buf, this._len, n);
1661
- buf = releasedBufObj.writingBuf;
1662
- this._len = releasedBufObj.len;
1663
- if (buf.length <= 0) {
1664
- this._bufs.shift();
1665
- }
1666
- } catch (err) {
1667
- const shouldRetry = err.code === "EAGAIN" || err.code === "EBUSY";
1668
- if (shouldRetry && !this.retryEAGAIN(err, buf.length, this._len - buf.length)) {
1669
- throw err;
1670
- }
1671
- sleep(BUSY_WRITE_TIMEOUT);
1672
- }
1673
- }
1674
- try {
1675
- fs.fsyncSync(this.fd);
1676
- } catch {
1677
- }
1678
- }
1679
- function flushBufferSync() {
1680
- if (this.destroyed) {
1681
- throw new Error("SonicBoom destroyed");
1682
- }
1683
- if (this.fd < 0) {
1684
- throw new Error("sonic boom is not ready yet");
1685
- }
1686
- if (!this._writing && this._writingBuf.length > 0) {
1687
- this._bufs.unshift([this._writingBuf]);
1688
- this._writingBuf = kEmptyBuffer;
1689
- }
1690
- let buf = kEmptyBuffer;
1691
- while (this._bufs.length || buf.length) {
1692
- if (buf.length <= 0) {
1693
- buf = mergeBuf(this._bufs[0], this._lens[0]);
1694
- }
1695
- try {
1696
- const n = fs.writeSync(this.fd, buf);
1697
- buf = buf.subarray(n);
1698
- this._len = Math.max(this._len - n, 0);
1699
- if (buf.length <= 0) {
1700
- this._bufs.shift();
1701
- this._lens.shift();
1702
- }
1703
- } catch (err) {
1704
- const shouldRetry = err.code === "EAGAIN" || err.code === "EBUSY";
1705
- if (shouldRetry && !this.retryEAGAIN(err, buf.length, this._len - buf.length)) {
1706
- throw err;
1707
- }
1708
- sleep(BUSY_WRITE_TIMEOUT);
1709
- }
1710
- }
1711
- }
1712
- SonicBoom.prototype.destroy = function() {
1713
- if (this.destroyed) {
1714
- return;
1715
- }
1716
- actualClose(this);
1717
- };
1718
- function actualWrite() {
1719
- const release = this.release;
1720
- this._writing = true;
1721
- this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
1722
- if (this.sync) {
1723
- try {
1724
- const written = Buffer.isBuffer(this._writingBuf) ? fs.writeSync(this.fd, this._writingBuf) : fs.writeSync(this.fd, this._writingBuf, "utf8");
1725
- release(null, written);
1726
- } catch (err) {
1727
- release(err);
1728
- }
1729
- } else {
1730
- fs.write(this.fd, this._writingBuf, release);
1731
- }
1732
- }
1733
- function actualWriteBuffer() {
1734
- const release = this.release;
1735
- this._writing = true;
1736
- this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
1737
- if (this.sync) {
1738
- try {
1739
- const written = fs.writeSync(this.fd, this._writingBuf);
1740
- release(null, written);
1741
- } catch (err) {
1742
- release(err);
1743
- }
1744
- } else {
1745
- if (kCopyBuffer) {
1746
- this._writingBuf = Buffer.from(this._writingBuf);
1747
- }
1748
- fs.write(this.fd, this._writingBuf, release);
1749
- }
1750
- }
1751
- function actualClose(sonic) {
1752
- if (sonic.fd === -1) {
1753
- sonic.once("ready", actualClose.bind(null, sonic));
1754
- return;
1755
- }
1756
- if (sonic._periodicFlushTimer !== void 0) {
1757
- clearInterval(sonic._periodicFlushTimer);
1758
- }
1759
- sonic.destroyed = true;
1760
- sonic._bufs = [];
1761
- sonic._lens = [];
1762
- assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
1763
- try {
1764
- fs.fsync(sonic.fd, closeWrapped);
1765
- } catch {
1766
- }
1767
- function closeWrapped() {
1768
- if (sonic.fd !== 1 && sonic.fd !== 2) {
1769
- fs.close(sonic.fd, done);
1770
- } else {
1771
- done();
1772
- }
1773
- }
1774
- function done(err) {
1775
- if (err) {
1776
- sonic.emit("error", err);
1777
- return;
1778
- }
1779
- if (sonic._ending && !sonic._writing) {
1780
- sonic.emit("finish");
1781
- }
1782
- sonic.emit("close");
1783
- }
1784
- }
1785
- SonicBoom.SonicBoom = SonicBoom;
1786
- SonicBoom.default = SonicBoom;
1787
- module.exports = SonicBoom;
1788
- }
1789
- });
1790
-
1791
- // ../../node_modules/on-exit-leak-free/index.js
1792
- var require_on_exit_leak_free = __commonJS({
1793
- "../../node_modules/on-exit-leak-free/index.js"(exports, module) {
1794
- "use strict";
1795
- var refs = {
1796
- exit: [],
1797
- beforeExit: []
1798
- };
1799
- var functions = {
1800
- exit: onExit,
1801
- beforeExit: onBeforeExit
1802
- };
1803
- var registry;
1804
- function ensureRegistry() {
1805
- if (registry === void 0) {
1806
- registry = new FinalizationRegistry(clear);
1807
- }
1808
- }
1809
- function install(event) {
1810
- if (refs[event].length > 0) {
1811
- return;
1812
- }
1813
- process.on(event, functions[event]);
1814
- }
1815
- function uninstall(event) {
1816
- if (refs[event].length > 0) {
1817
- return;
1818
- }
1819
- process.removeListener(event, functions[event]);
1820
- if (refs.exit.length === 0 && refs.beforeExit.length === 0) {
1821
- registry = void 0;
1822
- }
1823
- }
1824
- function onExit() {
1825
- callRefs("exit");
1826
- }
1827
- function onBeforeExit() {
1828
- callRefs("beforeExit");
1829
- }
1830
- function callRefs(event) {
1831
- for (const ref of refs[event]) {
1832
- const obj = ref.deref();
1833
- const fn = ref.fn;
1834
- if (obj !== void 0) {
1835
- fn(obj, event);
1836
- }
1837
- }
1838
- refs[event] = [];
1839
- }
1840
- function clear(ref) {
1841
- for (const event of ["exit", "beforeExit"]) {
1842
- const index = refs[event].indexOf(ref);
1843
- refs[event].splice(index, index + 1);
1844
- uninstall(event);
1845
- }
1846
- }
1847
- function _register(event, obj, fn) {
1848
- if (obj === void 0) {
1849
- throw new Error("the object can't be undefined");
1850
- }
1851
- install(event);
1852
- const ref = new WeakRef(obj);
1853
- ref.fn = fn;
1854
- ensureRegistry();
1855
- registry.register(obj, ref);
1856
- refs[event].push(ref);
1857
- }
1858
- function register(obj, fn) {
1859
- _register("exit", obj, fn);
1860
- }
1861
- function registerBeforeExit(obj, fn) {
1862
- _register("beforeExit", obj, fn);
1863
- }
1864
- function unregister(obj) {
1865
- if (registry === void 0) {
1866
- return;
1867
- }
1868
- registry.unregister(obj);
1869
- for (const event of ["exit", "beforeExit"]) {
1870
- refs[event] = refs[event].filter((ref) => {
1871
- const _obj = ref.deref();
1872
- return _obj && _obj !== obj;
1873
- });
1874
- uninstall(event);
1875
- }
1876
- }
1877
- module.exports = {
1878
- register,
1879
- registerBeforeExit,
1880
- unregister
1881
- };
1882
- }
1883
- });
1884
-
1885
- // ../../node_modules/thread-stream/package.json
1886
- var require_package = __commonJS({
1887
- "../../node_modules/thread-stream/package.json"(exports, module) {
1888
- module.exports = {
1889
- name: "thread-stream",
1890
- version: "4.0.0",
1891
- description: "A streaming way to send data to a Node.js Worker Thread",
1892
- main: "index.js",
1893
- types: "index.d.ts",
1894
- engines: {
1895
- node: ">=20"
1896
- },
1897
- dependencies: {
1898
- "real-require": "^0.2.0"
1899
- },
1900
- devDependencies: {
1901
- "@types/node": "^22.0.0",
1902
- "@yao-pkg/pkg": "^6.0.0",
1903
- borp: "^0.21.0",
1904
- desm: "^1.3.0",
1905
- eslint: "^9.39.1",
1906
- fastbench: "^1.0.1",
1907
- husky: "^9.0.6",
1908
- neostandard: "^0.12.2",
1909
- "pino-elasticsearch": "^8.0.0",
1910
- "sonic-boom": "^4.0.1",
1911
- "ts-node": "^10.8.0",
1912
- typescript: "~5.7.3"
1913
- },
1914
- scripts: {
1915
- build: "tsc --noEmit",
1916
- lint: "eslint",
1917
- test: "npm run lint && npm run build && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'",
1918
- "test:ci": "npm run lint && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'",
1919
- "test:yarn": "npm run transpile && borp --pattern 'test/*.test.js'",
1920
- transpile: "sh ./test/ts/transpile.sh",
1921
- prepare: "husky install"
1922
- },
1923
- repository: {
1924
- type: "git",
1925
- url: "git+https://github.com/mcollina/thread-stream.git"
1926
- },
1927
- keywords: [
1928
- "worker",
1929
- "thread",
1930
- "threads",
1931
- "stream"
1932
- ],
1933
- author: "Matteo Collina <hello@matteocollina.com>",
1934
- license: "MIT",
1935
- bugs: {
1936
- url: "https://github.com/mcollina/thread-stream/issues"
1937
- },
1938
- homepage: "https://github.com/mcollina/thread-stream#readme"
1939
- };
1940
- }
1941
- });
1942
-
1943
- // ../../node_modules/thread-stream/lib/wait.js
1944
- var require_wait = __commonJS({
1945
- "../../node_modules/thread-stream/lib/wait.js"(exports, module) {
1946
- "use strict";
1947
- var WAIT_MS = 1e4;
1948
- function wait(state, index, expected, timeout, done) {
1949
- const max = timeout === Infinity ? Infinity : Date.now() + timeout;
1950
- const check = () => {
1951
- const current = Atomics.load(state, index);
1952
- if (current === expected) {
1953
- done(null, "ok");
1954
- return;
1955
- }
1956
- if (max !== Infinity && Date.now() > max) {
1957
- done(null, "timed-out");
1958
- return;
1959
- }
1960
- const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
1961
- const result = Atomics.waitAsync(state, index, current, remaining);
1962
- if (result.async) {
1963
- result.value.then(check);
1964
- } else {
1965
- setImmediate(check);
1966
- }
1967
- };
1968
- check();
1969
- }
1970
- function waitDiff(state, index, expected, timeout, done) {
1971
- const max = timeout === Infinity ? Infinity : Date.now() + timeout;
1972
- const check = () => {
1973
- const current = Atomics.load(state, index);
1974
- if (current !== expected) {
1975
- done(null, "ok");
1976
- return;
1977
- }
1978
- if (max !== Infinity && Date.now() > max) {
1979
- done(null, "timed-out");
1980
- return;
1981
- }
1982
- const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
1983
- const result = Atomics.waitAsync(state, index, expected, remaining);
1984
- if (result.async) {
1985
- result.value.then(check);
1986
- } else {
1987
- setImmediate(check);
1988
- }
1989
- };
1990
- check();
1991
- }
1992
- module.exports = { wait, waitDiff };
1993
- }
1994
- });
1995
-
1996
- // ../../node_modules/thread-stream/lib/indexes.js
1997
- var require_indexes = __commonJS({
1998
- "../../node_modules/thread-stream/lib/indexes.js"(exports, module) {
1999
- "use strict";
2000
- var WRITE_INDEX = 4;
2001
- var READ_INDEX = 8;
2002
- module.exports = {
2003
- WRITE_INDEX,
2004
- READ_INDEX
2005
- };
2006
- }
2007
- });
2008
-
2009
- // ../../node_modules/thread-stream/index.js
2010
- var require_thread_stream = __commonJS({
2011
- "../../node_modules/thread-stream/index.js"(exports, module) {
2012
- "use strict";
2013
- var { version } = require_package();
2014
- var { EventEmitter } = __require("events");
2015
- var { Worker } = __require("worker_threads");
2016
- var { join } = __require("path");
2017
- var { pathToFileURL } = __require("url");
2018
- var { wait } = require_wait();
2019
- var {
2020
- WRITE_INDEX,
2021
- READ_INDEX
2022
- } = require_indexes();
2023
- var buffer = __require("buffer");
2024
- var assert = __require("assert");
2025
- var kImpl = /* @__PURE__ */ Symbol("kImpl");
2026
- var MAX_STRING = buffer.constants.MAX_STRING_LENGTH;
2027
- var FakeWeakRef = class {
2028
- constructor(value) {
2029
- this._value = value;
2030
- }
2031
- deref() {
2032
- return this._value;
2033
- }
2034
- };
2035
- var FakeFinalizationRegistry = class {
2036
- register() {
2037
- }
2038
- unregister() {
2039
- }
2040
- };
2041
- var FinalizationRegistry2 = process.env.NODE_V8_COVERAGE ? FakeFinalizationRegistry : global.FinalizationRegistry || FakeFinalizationRegistry;
2042
- var WeakRef2 = process.env.NODE_V8_COVERAGE ? FakeWeakRef : global.WeakRef || FakeWeakRef;
2043
- var registry = new FinalizationRegistry2((worker) => {
2044
- if (worker.exited) {
2045
- return;
2046
- }
2047
- worker.terminate();
2048
- });
2049
- function createWorker(stream, opts) {
2050
- const { filename, workerData } = opts;
2051
- const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2052
- const toExecute = bundlerOverrides["thread-stream-worker"] || join(__dirname, "lib", "worker.js");
2053
- const worker = new Worker(toExecute, {
2054
- ...opts.workerOpts,
2055
- trackUnmanagedFds: false,
2056
- workerData: {
2057
- filename: filename.indexOf("file://") === 0 ? filename : pathToFileURL(filename).href,
2058
- dataBuf: stream[kImpl].dataBuf,
2059
- stateBuf: stream[kImpl].stateBuf,
2060
- workerData: {
2061
- $context: {
2062
- threadStreamVersion: version
2063
- },
2064
- ...workerData
2065
- }
2066
- }
2067
- });
2068
- worker.stream = new FakeWeakRef(stream);
2069
- worker.on("message", onWorkerMessage);
2070
- worker.on("exit", onWorkerExit);
2071
- registry.register(stream, worker);
2072
- return worker;
2073
- }
2074
- function drain(stream) {
2075
- assert(!stream[kImpl].sync);
2076
- if (stream[kImpl].needDrain) {
2077
- stream[kImpl].needDrain = false;
2078
- stream.emit("drain");
2079
- }
2080
- }
2081
- function nextFlush(stream) {
2082
- const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
2083
- let leftover = stream[kImpl].data.length - writeIndex;
2084
- if (leftover > 0) {
2085
- if (stream[kImpl].buf.length === 0) {
2086
- stream[kImpl].flushing = false;
2087
- if (stream[kImpl].ending) {
2088
- end(stream);
2089
- } else if (stream[kImpl].needDrain) {
2090
- process.nextTick(drain, stream);
2091
- }
2092
- return;
2093
- }
2094
- let toWrite = stream[kImpl].buf.slice(0, leftover);
2095
- let toWriteBytes = Buffer.byteLength(toWrite);
2096
- if (toWriteBytes <= leftover) {
2097
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
2098
- write(stream, toWrite, nextFlush.bind(null, stream));
2099
- } else {
2100
- stream.flush(() => {
2101
- if (stream.destroyed) {
2102
- return;
2103
- }
2104
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
2105
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
2106
- Atomics.notify(stream[kImpl].state, READ_INDEX);
2107
- while (toWriteBytes > stream[kImpl].data.length) {
2108
- leftover = leftover / 2;
2109
- toWrite = stream[kImpl].buf.slice(0, leftover);
2110
- toWriteBytes = Buffer.byteLength(toWrite);
2111
- }
2112
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
2113
- write(stream, toWrite, nextFlush.bind(null, stream));
2114
- });
2115
- }
2116
- } else if (leftover === 0) {
2117
- if (writeIndex === 0 && stream[kImpl].buf.length === 0) {
2118
- return;
2119
- }
2120
- stream.flush(() => {
2121
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
2122
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
2123
- Atomics.notify(stream[kImpl].state, READ_INDEX);
2124
- nextFlush(stream);
2125
- });
2126
- } else {
2127
- destroy(stream, new Error("overwritten"));
2128
- }
2129
- }
2130
- function onWorkerMessage(msg) {
2131
- const stream = this.stream.deref();
2132
- if (stream === void 0) {
2133
- this.exited = true;
2134
- this.terminate();
2135
- return;
2136
- }
2137
- switch (msg.code) {
2138
- case "READY":
2139
- this.stream = new WeakRef2(stream);
2140
- stream.flush(() => {
2141
- stream[kImpl].ready = true;
2142
- stream.emit("ready");
2143
- });
2144
- break;
2145
- case "ERROR":
2146
- destroy(stream, msg.err);
2147
- break;
2148
- case "EVENT":
2149
- if (Array.isArray(msg.args)) {
2150
- stream.emit(msg.name, ...msg.args);
2151
- } else {
2152
- stream.emit(msg.name, msg.args);
2153
- }
2154
- break;
2155
- case "WARNING":
2156
- process.emitWarning(msg.err);
2157
- break;
2158
- default:
2159
- destroy(stream, new Error("this should not happen: " + msg.code));
2160
- }
2161
- }
2162
- function onWorkerExit(code) {
2163
- const stream = this.stream.deref();
2164
- if (stream === void 0) {
2165
- return;
2166
- }
2167
- registry.unregister(stream);
2168
- stream.worker.exited = true;
2169
- stream.worker.off("exit", onWorkerExit);
2170
- destroy(stream, code !== 0 ? new Error("the worker thread exited") : null);
2171
- }
2172
- var ThreadStream = class extends EventEmitter {
2173
- constructor(opts = {}) {
2174
- super();
2175
- if (opts.bufferSize < 4) {
2176
- throw new Error("bufferSize must at least fit a 4-byte utf-8 char");
2177
- }
2178
- this[kImpl] = {};
2179
- this[kImpl].stateBuf = new SharedArrayBuffer(128);
2180
- this[kImpl].state = new Int32Array(this[kImpl].stateBuf);
2181
- this[kImpl].dataBuf = new SharedArrayBuffer(opts.bufferSize || 4 * 1024 * 1024);
2182
- this[kImpl].data = Buffer.from(this[kImpl].dataBuf);
2183
- this[kImpl].sync = opts.sync || false;
2184
- this[kImpl].ending = false;
2185
- this[kImpl].ended = false;
2186
- this[kImpl].needDrain = false;
2187
- this[kImpl].destroyed = false;
2188
- this[kImpl].flushing = false;
2189
- this[kImpl].ready = false;
2190
- this[kImpl].finished = false;
2191
- this[kImpl].errored = null;
2192
- this[kImpl].closed = false;
2193
- this[kImpl].buf = "";
2194
- this.worker = createWorker(this, opts);
2195
- this.on("message", (message, transferList) => {
2196
- this.worker.postMessage(message, transferList);
2197
- });
2198
- }
2199
- write(data) {
2200
- if (this[kImpl].destroyed) {
2201
- error(this, new Error("the worker has exited"));
2202
- return false;
2203
- }
2204
- if (this[kImpl].ending) {
2205
- error(this, new Error("the worker is ending"));
2206
- return false;
2207
- }
2208
- if (this[kImpl].flushing && this[kImpl].buf.length + data.length >= MAX_STRING) {
2209
- try {
2210
- writeSync(this);
2211
- this[kImpl].flushing = true;
2212
- } catch (err) {
2213
- destroy(this, err);
2214
- return false;
2215
- }
2216
- }
2217
- this[kImpl].buf += data;
2218
- if (this[kImpl].sync) {
2219
- try {
2220
- writeSync(this);
2221
- return true;
2222
- } catch (err) {
2223
- destroy(this, err);
2224
- return false;
2225
- }
2226
- }
2227
- if (!this[kImpl].flushing) {
2228
- this[kImpl].flushing = true;
2229
- setImmediate(nextFlush, this);
2230
- }
2231
- this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].buf.length - Atomics.load(this[kImpl].state, WRITE_INDEX) <= 0;
2232
- return !this[kImpl].needDrain;
2233
- }
2234
- end() {
2235
- if (this[kImpl].destroyed) {
2236
- return;
2237
- }
2238
- this[kImpl].ending = true;
2239
- end(this);
2240
- }
2241
- flush(cb) {
2242
- if (this[kImpl].destroyed) {
2243
- if (typeof cb === "function") {
2244
- process.nextTick(cb, new Error("the worker has exited"));
2245
- }
2246
- return;
2247
- }
2248
- const writeIndex = Atomics.load(this[kImpl].state, WRITE_INDEX);
2249
- wait(this[kImpl].state, READ_INDEX, writeIndex, Infinity, (err, res) => {
2250
- if (err) {
2251
- destroy(this, err);
2252
- process.nextTick(cb, err);
2253
- return;
2254
- }
2255
- if (res === "not-equal") {
2256
- this.flush(cb);
2257
- return;
2258
- }
2259
- process.nextTick(cb);
2260
- });
2261
- }
2262
- flushSync() {
2263
- if (this[kImpl].destroyed) {
2264
- return;
2265
- }
2266
- writeSync(this);
2267
- flushSync(this);
2268
- }
2269
- unref() {
2270
- this.worker.unref();
2271
- }
2272
- ref() {
2273
- this.worker.ref();
2274
- }
2275
- get ready() {
2276
- return this[kImpl].ready;
2277
- }
2278
- get destroyed() {
2279
- return this[kImpl].destroyed;
2280
- }
2281
- get closed() {
2282
- return this[kImpl].closed;
2283
- }
2284
- get writable() {
2285
- return !this[kImpl].destroyed && !this[kImpl].ending;
2286
- }
2287
- get writableEnded() {
2288
- return this[kImpl].ending;
2289
- }
2290
- get writableFinished() {
2291
- return this[kImpl].finished;
2292
- }
2293
- get writableNeedDrain() {
2294
- return this[kImpl].needDrain;
2295
- }
2296
- get writableObjectMode() {
2297
- return false;
2298
- }
2299
- get writableErrored() {
2300
- return this[kImpl].errored;
2301
- }
2302
- };
2303
- function error(stream, err) {
2304
- setImmediate(() => {
2305
- stream.emit("error", err);
2306
- });
2307
- }
2308
- function destroy(stream, err) {
2309
- if (stream[kImpl].destroyed) {
2310
- return;
2311
- }
2312
- stream[kImpl].destroyed = true;
2313
- if (err) {
2314
- stream[kImpl].errored = err;
2315
- error(stream, err);
2316
- }
2317
- if (!stream.worker.exited) {
2318
- stream.worker.terminate().catch(() => {
2319
- }).then(() => {
2320
- stream[kImpl].closed = true;
2321
- stream.emit("close");
2322
- });
2323
- } else {
2324
- setImmediate(() => {
2325
- stream[kImpl].closed = true;
2326
- stream.emit("close");
2327
- });
2328
- }
2329
- }
2330
- function write(stream, data, cb) {
2331
- const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
2332
- const length = Buffer.byteLength(data);
2333
- stream[kImpl].data.write(data, current);
2334
- Atomics.store(stream[kImpl].state, WRITE_INDEX, current + length);
2335
- Atomics.notify(stream[kImpl].state, WRITE_INDEX);
2336
- cb();
2337
- return true;
2338
- }
2339
- function end(stream) {
2340
- if (stream[kImpl].ended || !stream[kImpl].ending || stream[kImpl].flushing) {
2341
- return;
2342
- }
2343
- stream[kImpl].ended = true;
2344
- try {
2345
- stream.flushSync();
2346
- let readIndex = Atomics.load(stream[kImpl].state, READ_INDEX);
2347
- Atomics.store(stream[kImpl].state, WRITE_INDEX, -1);
2348
- Atomics.notify(stream[kImpl].state, WRITE_INDEX);
2349
- let spins = 0;
2350
- while (readIndex !== -1) {
2351
- Atomics.wait(stream[kImpl].state, READ_INDEX, readIndex, 1e3);
2352
- readIndex = Atomics.load(stream[kImpl].state, READ_INDEX);
2353
- if (readIndex === -2) {
2354
- destroy(stream, new Error("end() failed"));
2355
- return;
2356
- }
2357
- if (++spins === 10) {
2358
- destroy(stream, new Error("end() took too long (10s)"));
2359
- return;
2360
- }
2361
- }
2362
- process.nextTick(() => {
2363
- stream[kImpl].finished = true;
2364
- stream.emit("finish");
2365
- });
2366
- } catch (err) {
2367
- destroy(stream, err);
2368
- }
2369
- }
2370
- function writeSync(stream) {
2371
- const cb = () => {
2372
- if (stream[kImpl].ending) {
2373
- end(stream);
2374
- } else if (stream[kImpl].needDrain) {
2375
- process.nextTick(drain, stream);
2376
- }
2377
- };
2378
- stream[kImpl].flushing = false;
2379
- while (stream[kImpl].buf.length !== 0) {
2380
- const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
2381
- let leftover = stream[kImpl].data.length - writeIndex;
2382
- if (leftover === 0) {
2383
- flushSync(stream);
2384
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
2385
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
2386
- Atomics.notify(stream[kImpl].state, READ_INDEX);
2387
- continue;
2388
- } else if (leftover < 0) {
2389
- throw new Error("overwritten");
2390
- }
2391
- let toWrite = stream[kImpl].buf.slice(0, leftover);
2392
- let toWriteBytes = Buffer.byteLength(toWrite);
2393
- if (toWriteBytes <= leftover) {
2394
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
2395
- write(stream, toWrite, cb);
2396
- } else {
2397
- flushSync(stream);
2398
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
2399
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
2400
- Atomics.notify(stream[kImpl].state, READ_INDEX);
2401
- while (toWriteBytes > stream[kImpl].buf.length) {
2402
- leftover = leftover / 2;
2403
- toWrite = stream[kImpl].buf.slice(0, leftover);
2404
- toWriteBytes = Buffer.byteLength(toWrite);
2405
- }
2406
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
2407
- write(stream, toWrite, cb);
2408
- }
2409
- }
2410
- }
2411
- function flushSync(stream) {
2412
- if (stream[kImpl].flushing) {
2413
- throw new Error("unable to flush while flushing");
2414
- }
2415
- const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
2416
- let spins = 0;
2417
- while (true) {
2418
- const readIndex = Atomics.load(stream[kImpl].state, READ_INDEX);
2419
- if (readIndex === -2) {
2420
- throw Error("_flushSync failed");
2421
- }
2422
- if (readIndex !== writeIndex) {
2423
- Atomics.wait(stream[kImpl].state, READ_INDEX, readIndex, 1e3);
2424
- } else {
2425
- break;
2426
- }
2427
- if (++spins === 10) {
2428
- throw new Error("_flushSync took too long (10s)");
2429
- }
2430
- }
2431
- }
2432
- module.exports = ThreadStream;
2433
- }
2434
- });
2435
-
2436
- // ../../node_modules/pino/lib/transport.js
2437
- var require_transport = __commonJS({
2438
- "../../node_modules/pino/lib/transport.js"(exports, module) {
2439
- "use strict";
2440
- var { createRequire } = __require("module");
2441
- var { existsSync } = __require("fs");
2442
- var getCallers = require_caller();
2443
- var { join, isAbsolute, sep } = __require("path");
2444
- var { fileURLToPath } = __require("url");
2445
- var sleep = require_atomic_sleep();
2446
- var onExit = require_on_exit_leak_free();
2447
- var ThreadStream = require_thread_stream();
2448
- function setupOnExit(stream) {
2449
- onExit.register(stream, autoEnd);
2450
- onExit.registerBeforeExit(stream, flush);
2451
- stream.on("close", function() {
2452
- onExit.unregister(stream);
2453
- });
2454
- }
2455
- function hasPreloadFlags() {
2456
- const execArgv = process.execArgv;
2457
- for (let i = 0; i < execArgv.length; i++) {
2458
- const arg = execArgv[i];
2459
- if (arg === "--import" || arg === "--require" || arg === "-r") {
2460
- return true;
2461
- }
2462
- if (arg.startsWith("--import=") || arg.startsWith("--require=") || arg.startsWith("-r=")) {
2463
- return true;
2464
- }
2465
- }
2466
- return false;
2467
- }
2468
- function sanitizeNodeOptions(nodeOptions) {
2469
- const tokens = nodeOptions.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);
2470
- if (!tokens) {
2471
- return nodeOptions;
2472
- }
2473
- const sanitized = [];
2474
- let changed = false;
2475
- for (let i = 0; i < tokens.length; i++) {
2476
- const token = tokens[i];
2477
- if (token === "--require" || token === "-r" || token === "--import") {
2478
- const next = tokens[i + 1];
2479
- if (next && shouldDropPreload(next)) {
2480
- changed = true;
2481
- i++;
2482
- continue;
2483
- }
2484
- sanitized.push(token);
2485
- if (next) {
2486
- sanitized.push(next);
2487
- i++;
2488
- }
2489
- continue;
2490
- }
2491
- if (token.startsWith("--require=") || token.startsWith("-r=") || token.startsWith("--import=")) {
2492
- const value = token.slice(token.indexOf("=") + 1);
2493
- if (shouldDropPreload(value)) {
2494
- changed = true;
2495
- continue;
2496
- }
2497
- }
2498
- sanitized.push(token);
2499
- }
2500
- return changed ? sanitized.join(" ") : nodeOptions;
2501
- }
2502
- function shouldDropPreload(value) {
2503
- const unquoted = stripQuotes(value);
2504
- if (!unquoted) {
2505
- return false;
2506
- }
2507
- let path = unquoted;
2508
- if (path.startsWith("file://")) {
2509
- try {
2510
- path = fileURLToPath(path);
2511
- } catch {
2512
- return false;
2513
- }
2514
- }
2515
- return isAbsolute(path) && !existsSync(path);
2516
- }
2517
- function stripQuotes(value) {
2518
- const first = value[0];
2519
- const last = value[value.length - 1];
2520
- if (first === '"' && last === '"' || first === "'" && last === "'") {
2521
- return value.slice(1, -1);
2522
- }
2523
- return value;
2524
- }
2525
- function buildStream(filename, workerData, workerOpts, sync, name) {
2526
- if (!workerOpts.execArgv && hasPreloadFlags() && __require.main === void 0) {
2527
- workerOpts = {
2528
- ...workerOpts,
2529
- execArgv: []
2530
- };
2531
- }
2532
- if (!workerOpts.env && process.env.NODE_OPTIONS) {
2533
- const nodeOptions = sanitizeNodeOptions(process.env.NODE_OPTIONS);
2534
- if (nodeOptions !== process.env.NODE_OPTIONS) {
2535
- workerOpts = {
2536
- ...workerOpts,
2537
- env: {
2538
- ...process.env,
2539
- NODE_OPTIONS: nodeOptions
2540
- }
2541
- };
2542
- }
2543
- }
2544
- workerOpts = { ...workerOpts, name };
2545
- const stream = new ThreadStream({
2546
- filename,
2547
- workerData,
2548
- workerOpts,
2549
- sync
2550
- });
2551
- stream.on("ready", onReady);
2552
- stream.on("close", function() {
2553
- process.removeListener("exit", onExit2);
2554
- });
2555
- process.on("exit", onExit2);
2556
- function onReady() {
2557
- process.removeListener("exit", onExit2);
2558
- stream.unref();
2559
- if (workerOpts.autoEnd !== false) {
2560
- setupOnExit(stream);
2561
- }
2562
- }
2563
- function onExit2() {
2564
- if (stream.closed) {
2565
- return;
2566
- }
2567
- stream.flushSync();
2568
- sleep(100);
2569
- stream.end();
2570
- }
2571
- return stream;
2572
- }
2573
- function autoEnd(stream) {
2574
- stream.ref();
2575
- stream.flushSync();
2576
- stream.end();
2577
- stream.once("close", function() {
2578
- stream.unref();
2579
- });
2580
- }
2581
- function flush(stream) {
2582
- stream.flushSync();
2583
- }
2584
- function transport(fullOptions) {
2585
- const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
2586
- const options = {
2587
- ...fullOptions.options
2588
- };
2589
- const callers = typeof caller === "string" ? [caller] : caller;
2590
- const bundlerOverrides = typeof globalThis === "object" && Object.prototype.hasOwnProperty.call(globalThis, "__bundlerPathsOverrides") && globalThis.__bundlerPathsOverrides && typeof globalThis.__bundlerPathsOverrides === "object" ? globalThis.__bundlerPathsOverrides : /* @__PURE__ */ Object.create(null);
2591
- let target = fullOptions.target;
2592
- if (target && targets) {
2593
- throw new Error("only one of target or targets can be specified");
2594
- }
2595
- if (targets) {
2596
- target = bundlerOverrides["pino-worker"] || join(__dirname, "worker.js");
2597
- options.targets = targets.filter((dest) => dest.target).map((dest) => {
2598
- return {
2599
- ...dest,
2600
- target: fixTarget(dest.target)
2601
- };
2602
- });
2603
- options.pipelines = targets.filter((dest) => dest.pipeline).map((dest) => {
2604
- return dest.pipeline.map((t) => {
2605
- return {
2606
- ...t,
2607
- level: dest.level,
2608
- // duplicate the pipeline `level` property defined in the upper level
2609
- target: fixTarget(t.target)
2610
- };
2611
- });
2612
- });
2613
- } else if (pipeline) {
2614
- target = bundlerOverrides["pino-worker"] || join(__dirname, "worker.js");
2615
- options.pipelines = [pipeline.map((dest) => {
2616
- return {
2617
- ...dest,
2618
- target: fixTarget(dest.target)
2619
- };
2620
- })];
2621
- }
2622
- if (levels) {
2623
- options.levels = levels;
2624
- }
2625
- if (dedupe) {
2626
- options.dedupe = dedupe;
2627
- }
2628
- options.pinoWillSendConfig = true;
2629
- const name = targets || pipeline ? "pino.transport" : target;
2630
- return buildStream(fixTarget(target), options, worker, sync, name);
2631
- function fixTarget(origin) {
2632
- origin = bundlerOverrides[origin] || origin;
2633
- if (isAbsolute(origin) || origin.indexOf("file://") === 0) {
2634
- return origin;
2635
- }
2636
- if (origin === "pino/file") {
2637
- return join(__dirname, "..", "file.js");
2638
- }
2639
- let fixTarget2;
2640
- for (const filePath of callers) {
2641
- try {
2642
- const context = filePath === "node:repl" ? process.cwd() + sep : filePath;
2643
- fixTarget2 = createRequire(context).resolve(origin);
2644
- break;
2645
- } catch (err) {
2646
- continue;
2647
- }
2648
- }
2649
- if (!fixTarget2) {
2650
- throw new Error(`unable to determine transport target for "${origin}"`);
2651
- }
2652
- return fixTarget2;
2653
- }
2654
- }
2655
- module.exports = transport;
2656
- }
2657
- });
2658
-
2659
- // ../../node_modules/pino/lib/tools.js
2660
- var require_tools = __commonJS({
2661
- "../../node_modules/pino/lib/tools.js"(exports, module) {
2662
- "use strict";
2663
- var diagChan = __require("diagnostics_channel");
2664
- var format = require_quick_format_unescaped();
2665
- var { mapHttpRequest, mapHttpResponse } = require_pino_std_serializers();
2666
- var SonicBoom = require_sonic_boom();
2667
- var onExit = require_on_exit_leak_free();
2668
- var {
2669
- lsCacheSym,
2670
- chindingsSym,
2671
- writeSym,
2672
- serializersSym,
2673
- formatOptsSym,
2674
- endSym,
2675
- stringifiersSym,
2676
- stringifySym,
2677
- stringifySafeSym,
2678
- wildcardFirstSym,
2679
- nestedKeySym,
2680
- formattersSym,
2681
- messageKeySym,
2682
- errorKeySym,
2683
- nestedKeyStrSym,
2684
- msgPrefixSym
2685
- } = require_symbols();
2686
- var { isMainThread } = __require("worker_threads");
2687
- var transport = require_transport();
2688
- var [nodeMajor] = process.versions.node.split(".").map((v) => Number(v));
2689
- var asJsonChan = diagChan.tracingChannel("pino_asJson");
2690
- var asString = nodeMajor >= 25 ? (str) => JSON.stringify(str) : _asString;
2691
- function noop() {
2692
- }
2693
- function genLog(level, hook) {
2694
- if (!hook) return LOG;
2695
- return function hookWrappedLog(...args) {
2696
- hook.call(this, args, LOG, level);
2697
- };
2698
- function LOG(o, ...n) {
2699
- if (typeof o === "object") {
2700
- let msg = o;
2701
- if (o !== null) {
2702
- if (o.method && o.headers && o.socket) {
2703
- o = mapHttpRequest(o);
2704
- } else if (typeof o.setHeader === "function") {
2705
- o = mapHttpResponse(o);
2706
- }
2707
- }
2708
- let formatParams;
2709
- if (msg === null && n.length === 0) {
2710
- formatParams = [null];
2711
- } else {
2712
- msg = n.shift();
2713
- formatParams = n;
2714
- }
2715
- if (typeof this[msgPrefixSym] === "string" && msg !== void 0 && msg !== null) {
2716
- msg = this[msgPrefixSym] + msg;
2717
- }
2718
- this[writeSym](o, format(msg, formatParams, this[formatOptsSym]), level);
2719
- } else {
2720
- let msg = o === void 0 ? n.shift() : o;
2721
- if (typeof this[msgPrefixSym] === "string" && msg !== void 0 && msg !== null) {
2722
- msg = this[msgPrefixSym] + msg;
2723
- }
2724
- this[writeSym](null, format(msg, n, this[formatOptsSym]), level);
2725
- }
2726
- }
2727
- }
2728
- function _asString(str) {
2729
- let result = "";
2730
- let last = 0;
2731
- let found = false;
2732
- let point = 255;
2733
- const l = str.length;
2734
- if (l > 100) {
2735
- return JSON.stringify(str);
2736
- }
2737
- for (var i = 0; i < l && point >= 32; i++) {
2738
- point = str.charCodeAt(i);
2739
- if (point === 34 || point === 92) {
2740
- result += str.slice(last, i) + "\\";
2741
- last = i;
2742
- found = true;
2743
- }
2744
- }
2745
- if (!found) {
2746
- result = str;
2747
- } else {
2748
- result += str.slice(last);
2749
- }
2750
- return point < 32 ? JSON.stringify(str) : '"' + result + '"';
2751
- }
2752
- function asJson(obj, msg, num, time) {
2753
- if (asJsonChan.hasSubscribers === false) {
2754
- return _asJson.call(this, obj, msg, num, time);
2755
- }
2756
- const store = { instance: this, arguments };
2757
- return asJsonChan.traceSync(_asJson, store, this, obj, msg, num, time);
2758
- }
2759
- function _asJson(obj, msg, num, time) {
2760
- const stringify2 = this[stringifySym];
2761
- const stringifySafe = this[stringifySafeSym];
2762
- const stringifiers = this[stringifiersSym];
2763
- const end = this[endSym];
2764
- const chindings = this[chindingsSym];
2765
- const serializers = this[serializersSym];
2766
- const formatters = this[formattersSym];
2767
- const messageKey = this[messageKeySym];
2768
- const errorKey = this[errorKeySym];
2769
- let data = this[lsCacheSym][num] + time;
2770
- data = data + chindings;
2771
- let value;
2772
- if (formatters.log) {
2773
- obj = formatters.log(obj);
2774
- }
2775
- const wildcardStringifier = stringifiers[wildcardFirstSym];
2776
- let propStr = "";
2777
- for (const key in obj) {
2778
- value = obj[key];
2779
- if (Object.prototype.hasOwnProperty.call(obj, key) && value !== void 0) {
2780
- if (serializers[key]) {
2781
- value = serializers[key](value);
2782
- } else if (key === errorKey && serializers.err) {
2783
- value = serializers.err(value);
2784
- }
2785
- const stringifier = stringifiers[key] || wildcardStringifier;
2786
- switch (typeof value) {
2787
- case "undefined":
2788
- case "function":
2789
- continue;
2790
- case "number":
2791
- if (Number.isFinite(value) === false) {
2792
- value = null;
2793
- }
2794
- // this case explicitly falls through to the next one
2795
- case "boolean":
2796
- if (stringifier) value = stringifier(value);
2797
- break;
2798
- case "string":
2799
- value = (stringifier || asString)(value);
2800
- break;
2801
- default:
2802
- value = (stringifier || stringify2)(value, stringifySafe);
2803
- }
2804
- if (value === void 0) continue;
2805
- const strKey = asString(key);
2806
- propStr += "," + strKey + ":" + value;
2807
- }
2808
- }
2809
- let msgStr = "";
2810
- if (msg !== void 0) {
2811
- value = serializers[messageKey] ? serializers[messageKey](msg) : msg;
2812
- const stringifier = stringifiers[messageKey] || wildcardStringifier;
2813
- switch (typeof value) {
2814
- case "function":
2815
- break;
2816
- case "number":
2817
- if (Number.isFinite(value) === false) {
2818
- value = null;
2819
- }
2820
- // this case explicitly falls through to the next one
2821
- case "boolean":
2822
- if (stringifier) value = stringifier(value);
2823
- msgStr = ',"' + messageKey + '":' + value;
2824
- break;
2825
- case "string":
2826
- value = (stringifier || asString)(value);
2827
- msgStr = ',"' + messageKey + '":' + value;
2828
- break;
2829
- default:
2830
- value = (stringifier || stringify2)(value, stringifySafe);
2831
- msgStr = ',"' + messageKey + '":' + value;
2832
- }
2833
- }
2834
- if (this[nestedKeySym] && propStr) {
2835
- return data + this[nestedKeyStrSym] + propStr.slice(1) + "}" + msgStr + end;
2836
- } else {
2837
- return data + propStr + msgStr + end;
2838
- }
2839
- }
2840
- function asChindings(instance, bindings) {
2841
- let value;
2842
- let data = instance[chindingsSym];
2843
- const stringify2 = instance[stringifySym];
2844
- const stringifySafe = instance[stringifySafeSym];
2845
- const stringifiers = instance[stringifiersSym];
2846
- const wildcardStringifier = stringifiers[wildcardFirstSym];
2847
- const serializers = instance[serializersSym];
2848
- const formatter = instance[formattersSym].bindings;
2849
- bindings = formatter(bindings);
2850
- for (const key in bindings) {
2851
- value = bindings[key];
2852
- const valid = (key.length < 5 || key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels") && bindings.hasOwnProperty(key) && value !== void 0;
2853
- if (valid === true) {
2854
- value = serializers[key] ? serializers[key](value) : value;
2855
- value = (stringifiers[key] || wildcardStringifier || stringify2)(value, stringifySafe);
2856
- if (value === void 0) continue;
2857
- data += ',"' + key + '":' + value;
2858
- }
2859
- }
2860
- return data;
2861
- }
2862
- function hasBeenTampered(stream) {
2863
- return stream.write !== stream.constructor.prototype.write;
2864
- }
2865
- function buildSafeSonicBoom(opts) {
2866
- const stream = new SonicBoom(opts);
2867
- stream.on("error", filterBrokenPipe);
2868
- if (!opts.sync && isMainThread) {
2869
- onExit.register(stream, autoEnd);
2870
- stream.on("close", function() {
2871
- onExit.unregister(stream);
2872
- });
2873
- }
2874
- return stream;
2875
- function filterBrokenPipe(err) {
2876
- if (err.code === "EPIPE") {
2877
- stream.write = noop;
2878
- stream.end = noop;
2879
- stream.flushSync = noop;
2880
- stream.destroy = noop;
2881
- return;
2882
- }
2883
- stream.removeListener("error", filterBrokenPipe);
2884
- stream.emit("error", err);
2885
- }
2886
- }
2887
- function autoEnd(stream, eventName) {
2888
- if (stream.destroyed) {
2889
- return;
2890
- }
2891
- if (eventName === "beforeExit") {
2892
- stream.flush();
2893
- stream.on("drain", function() {
2894
- stream.end();
2895
- });
2896
- } else {
2897
- stream.flushSync();
2898
- }
2899
- }
2900
- function createArgsNormalizer(defaultOptions) {
2901
- return function normalizeArgs(instance, caller, opts = {}, stream) {
2902
- if (typeof opts === "string") {
2903
- stream = buildSafeSonicBoom({ dest: opts });
2904
- opts = {};
2905
- } else if (typeof stream === "string") {
2906
- if (opts && opts.transport) {
2907
- throw Error("only one of option.transport or stream can be specified");
2908
- }
2909
- stream = buildSafeSonicBoom({ dest: stream });
2910
- } else if (opts instanceof SonicBoom || opts.writable || opts._writableState) {
2911
- stream = opts;
2912
- opts = {};
2913
- } else if (opts.transport) {
2914
- if (opts.transport instanceof SonicBoom || opts.transport.writable || opts.transport._writableState) {
2915
- throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");
2916
- }
2917
- if (opts.transport.targets && opts.transport.targets.length && opts.formatters && typeof opts.formatters.level === "function") {
2918
- throw Error("option.transport.targets do not allow custom level formatters");
2919
- }
2920
- let customLevels;
2921
- if (opts.customLevels) {
2922
- customLevels = opts.useOnlyCustomLevels ? opts.customLevels : Object.assign({}, opts.levels, opts.customLevels);
2923
- }
2924
- stream = transport({ caller, ...opts.transport, levels: customLevels });
2925
- }
2926
- opts = Object.assign({}, defaultOptions, opts);
2927
- opts.serializers = Object.assign({}, defaultOptions.serializers, opts.serializers);
2928
- opts.formatters = Object.assign({}, defaultOptions.formatters, opts.formatters);
2929
- if (opts.prettyPrint) {
2930
- throw new Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)");
2931
- }
2932
- const { enabled, onChild } = opts;
2933
- if (enabled === false) opts.level = "silent";
2934
- if (!onChild) opts.onChild = noop;
2935
- if (!stream) {
2936
- if (!hasBeenTampered(process.stdout)) {
2937
- stream = buildSafeSonicBoom({ fd: process.stdout.fd || 1 });
2938
- } else {
2939
- stream = process.stdout;
2940
- }
2941
- }
2942
- return { opts, stream };
2943
- };
2944
- }
2945
- function stringify(obj, stringifySafeFn) {
2946
- try {
2947
- return JSON.stringify(obj);
2948
- } catch (_) {
2949
- try {
2950
- const stringify2 = stringifySafeFn || this[stringifySafeSym];
2951
- return stringify2(obj);
2952
- } catch (_2) {
2953
- return '"[unable to serialize, circular reference is too complex to analyze]"';
2954
- }
2955
- }
2956
- }
2957
- function buildFormatters(level, bindings, log) {
2958
- return {
2959
- level,
2960
- bindings,
2961
- log
2962
- };
2963
- }
2964
- function normalizeDestFileDescriptor(destination) {
2965
- const fd = Number(destination);
2966
- if (typeof destination === "string" && Number.isFinite(fd)) {
2967
- return fd;
2968
- }
2969
- if (destination === void 0) {
2970
- return 1;
2971
- }
2972
- return destination;
2973
- }
2974
- module.exports = {
2975
- noop,
2976
- buildSafeSonicBoom,
2977
- asChindings,
2978
- asJson,
2979
- genLog,
2980
- createArgsNormalizer,
2981
- stringify,
2982
- buildFormatters,
2983
- normalizeDestFileDescriptor
2984
- };
2985
- }
2986
- });
2987
-
2988
- // ../../node_modules/pino/lib/constants.js
2989
- var require_constants = __commonJS({
2990
- "../../node_modules/pino/lib/constants.js"(exports, module) {
2991
- "use strict";
2992
- var DEFAULT_LEVELS = {
2993
- trace: 10,
2994
- debug: 20,
2995
- info: 30,
2996
- warn: 40,
2997
- error: 50,
2998
- fatal: 60
2999
- };
3000
- var SORTING_ORDER = {
3001
- ASC: "ASC",
3002
- DESC: "DESC"
3003
- };
3004
- module.exports = {
3005
- DEFAULT_LEVELS,
3006
- SORTING_ORDER
3007
- };
3008
- }
3009
- });
3010
-
3011
- // ../../node_modules/pino/lib/levels.js
3012
- var require_levels = __commonJS({
3013
- "../../node_modules/pino/lib/levels.js"(exports, module) {
3014
- "use strict";
3015
- var {
3016
- lsCacheSym,
3017
- levelValSym,
3018
- useOnlyCustomLevelsSym,
3019
- streamSym,
3020
- formattersSym,
3021
- hooksSym,
3022
- levelCompSym
3023
- } = require_symbols();
3024
- var { noop, genLog } = require_tools();
3025
- var { DEFAULT_LEVELS, SORTING_ORDER } = require_constants();
3026
- var levelMethods = {
3027
- fatal: (hook) => {
3028
- const logFatal = genLog(DEFAULT_LEVELS.fatal, hook);
3029
- return function(...args) {
3030
- const stream = this[streamSym];
3031
- logFatal.call(this, ...args);
3032
- if (typeof stream.flushSync === "function") {
3033
- try {
3034
- stream.flushSync();
3035
- } catch (e) {
3036
- }
3037
- }
3038
- };
3039
- },
3040
- error: (hook) => genLog(DEFAULT_LEVELS.error, hook),
3041
- warn: (hook) => genLog(DEFAULT_LEVELS.warn, hook),
3042
- info: (hook) => genLog(DEFAULT_LEVELS.info, hook),
3043
- debug: (hook) => genLog(DEFAULT_LEVELS.debug, hook),
3044
- trace: (hook) => genLog(DEFAULT_LEVELS.trace, hook)
3045
- };
3046
- var nums = Object.keys(DEFAULT_LEVELS).reduce((o, k) => {
3047
- o[DEFAULT_LEVELS[k]] = k;
3048
- return o;
3049
- }, {});
3050
- var initialLsCache = Object.keys(nums).reduce((o, k) => {
3051
- o[k] = '{"level":' + Number(k);
3052
- return o;
3053
- }, {});
3054
- function genLsCache(instance) {
3055
- const formatter = instance[formattersSym].level;
3056
- const { labels } = instance.levels;
3057
- const cache = {};
3058
- for (const label in labels) {
3059
- const level = formatter(labels[label], Number(label));
3060
- cache[label] = JSON.stringify(level).slice(0, -1);
3061
- }
3062
- instance[lsCacheSym] = cache;
3063
- return instance;
3064
- }
3065
- function isStandardLevel(level, useOnlyCustomLevels) {
3066
- if (useOnlyCustomLevels) {
3067
- return false;
3068
- }
3069
- switch (level) {
3070
- case "fatal":
3071
- case "error":
3072
- case "warn":
3073
- case "info":
3074
- case "debug":
3075
- case "trace":
3076
- return true;
3077
- default:
3078
- return false;
3079
- }
3080
- }
3081
- function setLevel(level) {
3082
- const { labels, values } = this.levels;
3083
- if (typeof level === "number") {
3084
- if (labels[level] === void 0) throw Error("unknown level value" + level);
3085
- level = labels[level];
3086
- }
3087
- if (values[level] === void 0) throw Error("unknown level " + level);
3088
- const preLevelVal = this[levelValSym];
3089
- const levelVal = this[levelValSym] = values[level];
3090
- const useOnlyCustomLevelsVal = this[useOnlyCustomLevelsSym];
3091
- const levelComparison = this[levelCompSym];
3092
- const hook = this[hooksSym].logMethod;
3093
- for (const key in values) {
3094
- if (levelComparison(values[key], levelVal) === false) {
3095
- this[key] = noop;
3096
- continue;
3097
- }
3098
- this[key] = isStandardLevel(key, useOnlyCustomLevelsVal) ? levelMethods[key](hook) : genLog(values[key], hook);
3099
- }
3100
- this.emit(
3101
- "level-change",
3102
- level,
3103
- levelVal,
3104
- labels[preLevelVal],
3105
- preLevelVal,
3106
- this
3107
- );
3108
- }
3109
- function getLevel(level) {
3110
- const { levels, levelVal } = this;
3111
- return levels && levels.labels ? levels.labels[levelVal] : "";
3112
- }
3113
- function isLevelEnabled(logLevel) {
3114
- const { values } = this.levels;
3115
- const logLevelVal = values[logLevel];
3116
- return logLevelVal !== void 0 && this[levelCompSym](logLevelVal, this[levelValSym]);
3117
- }
3118
- function compareLevel(direction, current, expected) {
3119
- if (direction === SORTING_ORDER.DESC) {
3120
- return current <= expected;
3121
- }
3122
- return current >= expected;
3123
- }
3124
- function genLevelComparison(levelComparison) {
3125
- if (typeof levelComparison === "string") {
3126
- return compareLevel.bind(null, levelComparison);
3127
- }
3128
- return levelComparison;
3129
- }
3130
- function mappings(customLevels = null, useOnlyCustomLevels = false) {
3131
- const customNums = customLevels ? Object.keys(customLevels).reduce((o, k) => {
3132
- o[customLevels[k]] = k;
3133
- return o;
3134
- }, {}) : null;
3135
- const labels = Object.assign(
3136
- Object.create(Object.prototype, { Infinity: { value: "silent" } }),
3137
- useOnlyCustomLevels ? null : nums,
3138
- customNums
3139
- );
3140
- const values = Object.assign(
3141
- Object.create(Object.prototype, { silent: { value: Infinity } }),
3142
- useOnlyCustomLevels ? null : DEFAULT_LEVELS,
3143
- customLevels
3144
- );
3145
- return { labels, values };
3146
- }
3147
- function assertDefaultLevelFound(defaultLevel, customLevels, useOnlyCustomLevels) {
3148
- if (typeof defaultLevel === "number") {
3149
- const values = [].concat(
3150
- Object.keys(customLevels || {}).map((key) => customLevels[key]),
3151
- useOnlyCustomLevels ? [] : Object.keys(nums).map((level) => +level),
3152
- Infinity
3153
- );
3154
- if (!values.includes(defaultLevel)) {
3155
- throw Error(`default level:${defaultLevel} must be included in custom levels`);
3156
- }
3157
- return;
3158
- }
3159
- const labels = Object.assign(
3160
- Object.create(Object.prototype, { silent: { value: Infinity } }),
3161
- useOnlyCustomLevels ? null : DEFAULT_LEVELS,
3162
- customLevels
3163
- );
3164
- if (!(defaultLevel in labels)) {
3165
- throw Error(`default level:${defaultLevel} must be included in custom levels`);
3166
- }
3167
- }
3168
- function assertNoLevelCollisions(levels, customLevels) {
3169
- const { labels, values } = levels;
3170
- for (const k in customLevels) {
3171
- if (k in values) {
3172
- throw Error("levels cannot be overridden");
3173
- }
3174
- if (customLevels[k] in labels) {
3175
- throw Error("pre-existing level values cannot be used for new levels");
3176
- }
3177
- }
3178
- }
3179
- function assertLevelComparison(levelComparison) {
3180
- if (typeof levelComparison === "function") {
3181
- return;
3182
- }
3183
- if (typeof levelComparison === "string" && Object.values(SORTING_ORDER).includes(levelComparison)) {
3184
- return;
3185
- }
3186
- throw new Error('Levels comparison should be one of "ASC", "DESC" or "function" type');
3187
- }
3188
- module.exports = {
3189
- initialLsCache,
3190
- genLsCache,
3191
- levelMethods,
3192
- getLevel,
3193
- setLevel,
3194
- isLevelEnabled,
3195
- mappings,
3196
- assertNoLevelCollisions,
3197
- assertDefaultLevelFound,
3198
- genLevelComparison,
3199
- assertLevelComparison
3200
- };
3201
- }
3202
- });
3203
-
3204
- // ../../node_modules/pino/lib/meta.js
3205
- var require_meta = __commonJS({
3206
- "../../node_modules/pino/lib/meta.js"(exports, module) {
3207
- "use strict";
3208
- module.exports = { version: "10.3.1" };
3209
- }
3210
- });
3211
-
3212
- // ../../node_modules/pino/lib/proto.js
3213
- var require_proto = __commonJS({
3214
- "../../node_modules/pino/lib/proto.js"(exports, module) {
3215
- "use strict";
3216
- var { EventEmitter } = __require("events");
3217
- var {
3218
- lsCacheSym,
3219
- levelValSym,
3220
- setLevelSym,
3221
- getLevelSym,
3222
- chindingsSym,
3223
- mixinSym,
3224
- asJsonSym,
3225
- writeSym,
3226
- mixinMergeStrategySym,
3227
- timeSym,
3228
- timeSliceIndexSym,
3229
- streamSym,
3230
- serializersSym,
3231
- formattersSym,
3232
- errorKeySym,
3233
- messageKeySym,
3234
- useOnlyCustomLevelsSym,
3235
- needsMetadataGsym,
3236
- redactFmtSym,
3237
- stringifySym,
3238
- formatOptsSym,
3239
- stringifiersSym,
3240
- msgPrefixSym,
3241
- hooksSym
3242
- } = require_symbols();
3243
- var {
3244
- getLevel,
3245
- setLevel,
3246
- isLevelEnabled,
3247
- mappings,
3248
- initialLsCache,
3249
- genLsCache,
3250
- assertNoLevelCollisions
3251
- } = require_levels();
3252
- var {
3253
- asChindings,
3254
- asJson,
3255
- buildFormatters,
3256
- stringify,
3257
- noop
3258
- } = require_tools();
3259
- var {
3260
- version
3261
- } = require_meta();
3262
- var redaction = require_redaction();
3263
- var constructor = class Pino {
3264
- };
3265
- var prototype = {
3266
- constructor,
3267
- child,
3268
- bindings,
3269
- setBindings,
3270
- flush,
3271
- isLevelEnabled,
3272
- version,
3273
- get level() {
3274
- return this[getLevelSym]();
3275
- },
3276
- set level(lvl) {
3277
- this[setLevelSym](lvl);
3278
- },
3279
- get levelVal() {
3280
- return this[levelValSym];
3281
- },
3282
- set levelVal(n) {
3283
- throw Error("levelVal is read-only");
3284
- },
3285
- get msgPrefix() {
3286
- return this[msgPrefixSym];
3287
- },
3288
- get [Symbol.toStringTag]() {
3289
- return "Pino";
3290
- },
3291
- [lsCacheSym]: initialLsCache,
3292
- [writeSym]: write,
3293
- [asJsonSym]: asJson,
3294
- [getLevelSym]: getLevel,
3295
- [setLevelSym]: setLevel
3296
- };
3297
- Object.setPrototypeOf(prototype, EventEmitter.prototype);
3298
- module.exports = function() {
3299
- return Object.create(prototype);
3300
- };
3301
- var resetChildingsFormatter = (bindings2) => bindings2;
3302
- function child(bindings2, options) {
3303
- if (!bindings2) {
3304
- throw Error("missing bindings for child Pino");
3305
- }
3306
- const serializers = this[serializersSym];
3307
- const formatters = this[formattersSym];
3308
- const instance = Object.create(this);
3309
- if (options == null) {
3310
- if (instance[formattersSym].bindings !== resetChildingsFormatter) {
3311
- instance[formattersSym] = buildFormatters(
3312
- formatters.level,
3313
- resetChildingsFormatter,
3314
- formatters.log
3315
- );
3316
- }
3317
- instance[chindingsSym] = asChindings(instance, bindings2);
3318
- if (this.onChild !== noop) {
3319
- this.onChild(instance);
3320
- }
3321
- return instance;
3322
- }
3323
- if (options.hasOwnProperty("serializers") === true) {
3324
- instance[serializersSym] = /* @__PURE__ */ Object.create(null);
3325
- for (const k in serializers) {
3326
- instance[serializersSym][k] = serializers[k];
3327
- }
3328
- const parentSymbols = Object.getOwnPropertySymbols(serializers);
3329
- for (var i = 0; i < parentSymbols.length; i++) {
3330
- const ks = parentSymbols[i];
3331
- instance[serializersSym][ks] = serializers[ks];
3332
- }
3333
- for (const bk in options.serializers) {
3334
- instance[serializersSym][bk] = options.serializers[bk];
3335
- }
3336
- const bindingsSymbols = Object.getOwnPropertySymbols(options.serializers);
3337
- for (var bi = 0; bi < bindingsSymbols.length; bi++) {
3338
- const bks = bindingsSymbols[bi];
3339
- instance[serializersSym][bks] = options.serializers[bks];
3340
- }
3341
- } else instance[serializersSym] = serializers;
3342
- if (options.hasOwnProperty("formatters")) {
3343
- const { level, bindings: chindings, log } = options.formatters;
3344
- instance[formattersSym] = buildFormatters(
3345
- level || formatters.level,
3346
- chindings || resetChildingsFormatter,
3347
- log || formatters.log
3348
- );
3349
- } else {
3350
- instance[formattersSym] = buildFormatters(
3351
- formatters.level,
3352
- resetChildingsFormatter,
3353
- formatters.log
3354
- );
3355
- }
3356
- if (options.hasOwnProperty("customLevels") === true) {
3357
- assertNoLevelCollisions(this.levels, options.customLevels);
3358
- instance.levels = mappings(options.customLevels, instance[useOnlyCustomLevelsSym]);
3359
- genLsCache(instance);
3360
- }
3361
- if (typeof options.redact === "object" && options.redact !== null || Array.isArray(options.redact)) {
3362
- instance.redact = options.redact;
3363
- const stringifiers = redaction(instance.redact, stringify);
3364
- const formatOpts = { stringify: stringifiers[redactFmtSym] };
3365
- instance[stringifySym] = stringify;
3366
- instance[stringifiersSym] = stringifiers;
3367
- instance[formatOptsSym] = formatOpts;
3368
- }
3369
- if (typeof options.msgPrefix === "string") {
3370
- instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
3371
- }
3372
- instance[chindingsSym] = asChindings(instance, bindings2);
3373
- if (options.level !== void 0 && options.level !== this.level || options.hasOwnProperty("customLevels")) {
3374
- const childLevel = options.level || this.level;
3375
- instance[setLevelSym](childLevel);
3376
- }
3377
- this.onChild(instance);
3378
- return instance;
3379
- }
3380
- function bindings() {
3381
- const chindings = this[chindingsSym];
3382
- const chindingsJson = `{${chindings.substr(1)}}`;
3383
- const bindingsFromJson = JSON.parse(chindingsJson);
3384
- delete bindingsFromJson.pid;
3385
- delete bindingsFromJson.hostname;
3386
- return bindingsFromJson;
3387
- }
3388
- function setBindings(newBindings) {
3389
- const chindings = asChindings(this, newBindings);
3390
- this[chindingsSym] = chindings;
3391
- }
3392
- function defaultMixinMergeStrategy(mergeObject, mixinObject) {
3393
- return Object.assign(mixinObject, mergeObject);
3394
- }
3395
- function write(_obj, msg, num) {
3396
- const t = this[timeSym]();
3397
- const mixin = this[mixinSym];
3398
- const errorKey = this[errorKeySym];
3399
- const messageKey = this[messageKeySym];
3400
- const mixinMergeStrategy = this[mixinMergeStrategySym] || defaultMixinMergeStrategy;
3401
- let obj;
3402
- const streamWriteHook = this[hooksSym].streamWrite;
3403
- if (_obj === void 0 || _obj === null) {
3404
- obj = {};
3405
- } else if (_obj instanceof Error) {
3406
- obj = { [errorKey]: _obj };
3407
- if (msg === void 0) {
3408
- msg = _obj.message;
3409
- }
3410
- } else {
3411
- obj = _obj;
3412
- if (msg === void 0 && _obj[messageKey] === void 0 && _obj[errorKey]) {
3413
- msg = _obj[errorKey].message;
3414
- }
3415
- }
3416
- if (mixin) {
3417
- obj = mixinMergeStrategy(obj, mixin(obj, num, this));
3418
- }
3419
- const s = this[asJsonSym](obj, msg, num, t);
3420
- const stream = this[streamSym];
3421
- if (stream[needsMetadataGsym] === true) {
3422
- stream.lastLevel = num;
3423
- stream.lastObj = obj;
3424
- stream.lastMsg = msg;
3425
- stream.lastTime = t.slice(this[timeSliceIndexSym]);
3426
- stream.lastLogger = this;
3427
- }
3428
- stream.write(streamWriteHook ? streamWriteHook(s) : s);
3429
- }
3430
- function flush(cb) {
3431
- if (cb != null && typeof cb !== "function") {
3432
- throw Error("callback must be a function");
3433
- }
3434
- const stream = this[streamSym];
3435
- if (typeof stream.flush === "function") {
3436
- stream.flush(cb || noop);
3437
- } else if (cb) cb();
3438
- }
3439
- }
3440
- });
3441
-
3442
- // ../../node_modules/safe-stable-stringify/index.js
3443
- var require_safe_stable_stringify = __commonJS({
3444
- "../../node_modules/safe-stable-stringify/index.js"(exports, module) {
3445
- "use strict";
3446
- var { hasOwnProperty } = Object.prototype;
3447
- var stringify = configure();
3448
- stringify.configure = configure;
3449
- stringify.stringify = stringify;
3450
- stringify.default = stringify;
3451
- exports.stringify = stringify;
3452
- exports.configure = configure;
3453
- module.exports = stringify;
3454
- var strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
3455
- function strEscape(str) {
3456
- if (str.length < 5e3 && !strEscapeSequencesRegExp.test(str)) {
3457
- return `"${str}"`;
3458
- }
3459
- return JSON.stringify(str);
3460
- }
3461
- function sort(array, comparator) {
3462
- if (array.length > 200 || comparator) {
3463
- return array.sort(comparator);
3464
- }
3465
- for (let i = 1; i < array.length; i++) {
3466
- const currentValue = array[i];
3467
- let position = i;
3468
- while (position !== 0 && array[position - 1] > currentValue) {
3469
- array[position] = array[position - 1];
3470
- position--;
3471
- }
3472
- array[position] = currentValue;
3473
- }
3474
- return array;
3475
- }
3476
- var typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(
3477
- Object.getPrototypeOf(
3478
- Object.getPrototypeOf(
3479
- new Int8Array()
3480
- )
3481
- ),
3482
- Symbol.toStringTag
3483
- ).get;
3484
- function isTypedArrayWithEntries(value) {
3485
- return typedArrayPrototypeGetSymbolToStringTag.call(value) !== void 0 && value.length !== 0;
3486
- }
3487
- function stringifyTypedArray(array, separator, maximumBreadth) {
3488
- if (array.length < maximumBreadth) {
3489
- maximumBreadth = array.length;
3490
- }
3491
- const whitespace = separator === "," ? "" : " ";
3492
- let res = `"0":${whitespace}${array[0]}`;
3493
- for (let i = 1; i < maximumBreadth; i++) {
3494
- res += `${separator}"${i}":${whitespace}${array[i]}`;
3495
- }
3496
- return res;
3497
- }
3498
- function getCircularValueOption(options) {
3499
- if (hasOwnProperty.call(options, "circularValue")) {
3500
- const circularValue = options.circularValue;
3501
- if (typeof circularValue === "string") {
3502
- return `"${circularValue}"`;
3503
- }
3504
- if (circularValue == null) {
3505
- return circularValue;
3506
- }
3507
- if (circularValue === Error || circularValue === TypeError) {
3508
- return {
3509
- toString() {
3510
- throw new TypeError("Converting circular structure to JSON");
3511
- }
3512
- };
3513
- }
3514
- throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
3515
- }
3516
- return '"[Circular]"';
3517
- }
3518
- function getDeterministicOption(options) {
3519
- let value;
3520
- if (hasOwnProperty.call(options, "deterministic")) {
3521
- value = options.deterministic;
3522
- if (typeof value !== "boolean" && typeof value !== "function") {
3523
- throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');
3524
- }
3525
- }
3526
- return value === void 0 ? true : value;
3527
- }
3528
- function getBooleanOption(options, key) {
3529
- let value;
3530
- if (hasOwnProperty.call(options, key)) {
3531
- value = options[key];
3532
- if (typeof value !== "boolean") {
3533
- throw new TypeError(`The "${key}" argument must be of type boolean`);
3534
- }
3535
- }
3536
- return value === void 0 ? true : value;
3537
- }
3538
- function getPositiveIntegerOption(options, key) {
3539
- let value;
3540
- if (hasOwnProperty.call(options, key)) {
3541
- value = options[key];
3542
- if (typeof value !== "number") {
3543
- throw new TypeError(`The "${key}" argument must be of type number`);
3544
- }
3545
- if (!Number.isInteger(value)) {
3546
- throw new TypeError(`The "${key}" argument must be an integer`);
3547
- }
3548
- if (value < 1) {
3549
- throw new RangeError(`The "${key}" argument must be >= 1`);
3550
- }
3551
- }
3552
- return value === void 0 ? Infinity : value;
3553
- }
3554
- function getItemCount(number) {
3555
- if (number === 1) {
3556
- return "1 item";
3557
- }
3558
- return `${number} items`;
3559
- }
3560
- function getUniqueReplacerSet(replacerArray) {
3561
- const replacerSet = /* @__PURE__ */ new Set();
3562
- for (const value of replacerArray) {
3563
- if (typeof value === "string" || typeof value === "number") {
3564
- replacerSet.add(String(value));
3565
- }
3566
- }
3567
- return replacerSet;
3568
- }
3569
- function getStrictOption(options) {
3570
- if (hasOwnProperty.call(options, "strict")) {
3571
- const value = options.strict;
3572
- if (typeof value !== "boolean") {
3573
- throw new TypeError('The "strict" argument must be of type boolean');
3574
- }
3575
- if (value) {
3576
- return (value2) => {
3577
- let message = `Object can not safely be stringified. Received type ${typeof value2}`;
3578
- if (typeof value2 !== "function") message += ` (${value2.toString()})`;
3579
- throw new Error(message);
3580
- };
3581
- }
3582
- }
3583
- }
3584
- function configure(options) {
3585
- options = { ...options };
3586
- const fail = getStrictOption(options);
3587
- if (fail) {
3588
- if (options.bigint === void 0) {
3589
- options.bigint = false;
3590
- }
3591
- if (!("circularValue" in options)) {
3592
- options.circularValue = Error;
3593
- }
3594
- }
3595
- const circularValue = getCircularValueOption(options);
3596
- const bigint = getBooleanOption(options, "bigint");
3597
- const deterministic = getDeterministicOption(options);
3598
- const comparator = typeof deterministic === "function" ? deterministic : void 0;
3599
- const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
3600
- const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
3601
- function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
3602
- let value = parent[key];
3603
- if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
3604
- value = value.toJSON(key);
3605
- }
3606
- value = replacer.call(parent, key, value);
3607
- switch (typeof value) {
3608
- case "string":
3609
- return strEscape(value);
3610
- case "object": {
3611
- if (value === null) {
3612
- return "null";
3613
- }
3614
- if (stack.indexOf(value) !== -1) {
3615
- return circularValue;
3616
- }
3617
- let res = "";
3618
- let join = ",";
3619
- const originalIndentation = indentation;
3620
- if (Array.isArray(value)) {
3621
- if (value.length === 0) {
3622
- return "[]";
3623
- }
3624
- if (maximumDepth < stack.length + 1) {
3625
- return '"[Array]"';
3626
- }
3627
- stack.push(value);
3628
- if (spacer !== "") {
3629
- indentation += spacer;
3630
- res += `
3631
- ${indentation}`;
3632
- join = `,
3633
- ${indentation}`;
3634
- }
3635
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3636
- let i = 0;
3637
- for (; i < maximumValuesToStringify - 1; i++) {
3638
- const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3639
- res += tmp2 !== void 0 ? tmp2 : "null";
3640
- res += join;
3641
- }
3642
- const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3643
- res += tmp !== void 0 ? tmp : "null";
3644
- if (value.length - 1 > maximumBreadth) {
3645
- const removedKeys = value.length - maximumBreadth - 1;
3646
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
3647
- }
3648
- if (spacer !== "") {
3649
- res += `
3650
- ${originalIndentation}`;
3651
- }
3652
- stack.pop();
3653
- return `[${res}]`;
3654
- }
3655
- let keys = Object.keys(value);
3656
- const keyLength = keys.length;
3657
- if (keyLength === 0) {
3658
- return "{}";
3659
- }
3660
- if (maximumDepth < stack.length + 1) {
3661
- return '"[Object]"';
3662
- }
3663
- let whitespace = "";
3664
- let separator = "";
3665
- if (spacer !== "") {
3666
- indentation += spacer;
3667
- join = `,
3668
- ${indentation}`;
3669
- whitespace = " ";
3670
- }
3671
- const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3672
- if (deterministic && !isTypedArrayWithEntries(value)) {
3673
- keys = sort(keys, comparator);
3674
- }
3675
- stack.push(value);
3676
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
3677
- const key2 = keys[i];
3678
- const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
3679
- if (tmp !== void 0) {
3680
- res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3681
- separator = join;
3682
- }
3683
- }
3684
- if (keyLength > maximumBreadth) {
3685
- const removedKeys = keyLength - maximumBreadth;
3686
- res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3687
- separator = join;
3688
- }
3689
- if (spacer !== "" && separator.length > 1) {
3690
- res = `
3691
- ${indentation}${res}
3692
- ${originalIndentation}`;
3693
- }
3694
- stack.pop();
3695
- return `{${res}}`;
3696
- }
3697
- case "number":
3698
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
3699
- case "boolean":
3700
- return value === true ? "true" : "false";
3701
- case "undefined":
3702
- return void 0;
3703
- case "bigint":
3704
- if (bigint) {
3705
- return String(value);
3706
- }
3707
- // fallthrough
3708
- default:
3709
- return fail ? fail(value) : void 0;
3710
- }
3711
- }
3712
- function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
3713
- if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
3714
- value = value.toJSON(key);
3715
- }
3716
- switch (typeof value) {
3717
- case "string":
3718
- return strEscape(value);
3719
- case "object": {
3720
- if (value === null) {
3721
- return "null";
3722
- }
3723
- if (stack.indexOf(value) !== -1) {
3724
- return circularValue;
3725
- }
3726
- const originalIndentation = indentation;
3727
- let res = "";
3728
- let join = ",";
3729
- if (Array.isArray(value)) {
3730
- if (value.length === 0) {
3731
- return "[]";
3732
- }
3733
- if (maximumDepth < stack.length + 1) {
3734
- return '"[Array]"';
3735
- }
3736
- stack.push(value);
3737
- if (spacer !== "") {
3738
- indentation += spacer;
3739
- res += `
3740
- ${indentation}`;
3741
- join = `,
3742
- ${indentation}`;
3743
- }
3744
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3745
- let i = 0;
3746
- for (; i < maximumValuesToStringify - 1; i++) {
3747
- const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3748
- res += tmp2 !== void 0 ? tmp2 : "null";
3749
- res += join;
3750
- }
3751
- const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3752
- res += tmp !== void 0 ? tmp : "null";
3753
- if (value.length - 1 > maximumBreadth) {
3754
- const removedKeys = value.length - maximumBreadth - 1;
3755
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
3756
- }
3757
- if (spacer !== "") {
3758
- res += `
3759
- ${originalIndentation}`;
3760
- }
3761
- stack.pop();
3762
- return `[${res}]`;
3763
- }
3764
- stack.push(value);
3765
- let whitespace = "";
3766
- if (spacer !== "") {
3767
- indentation += spacer;
3768
- join = `,
3769
- ${indentation}`;
3770
- whitespace = " ";
3771
- }
3772
- let separator = "";
3773
- for (const key2 of replacer) {
3774
- const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
3775
- if (tmp !== void 0) {
3776
- res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3777
- separator = join;
3778
- }
3779
- }
3780
- if (spacer !== "" && separator.length > 1) {
3781
- res = `
3782
- ${indentation}${res}
3783
- ${originalIndentation}`;
3784
- }
3785
- stack.pop();
3786
- return `{${res}}`;
3787
- }
3788
- case "number":
3789
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
3790
- case "boolean":
3791
- return value === true ? "true" : "false";
3792
- case "undefined":
3793
- return void 0;
3794
- case "bigint":
3795
- if (bigint) {
3796
- return String(value);
3797
- }
3798
- // fallthrough
3799
- default:
3800
- return fail ? fail(value) : void 0;
3801
- }
3802
- }
3803
- function stringifyIndent(key, value, stack, spacer, indentation) {
3804
- switch (typeof value) {
3805
- case "string":
3806
- return strEscape(value);
3807
- case "object": {
3808
- if (value === null) {
3809
- return "null";
3810
- }
3811
- if (typeof value.toJSON === "function") {
3812
- value = value.toJSON(key);
3813
- if (typeof value !== "object") {
3814
- return stringifyIndent(key, value, stack, spacer, indentation);
3815
- }
3816
- if (value === null) {
3817
- return "null";
3818
- }
3819
- }
3820
- if (stack.indexOf(value) !== -1) {
3821
- return circularValue;
3822
- }
3823
- const originalIndentation = indentation;
3824
- if (Array.isArray(value)) {
3825
- if (value.length === 0) {
3826
- return "[]";
3827
- }
3828
- if (maximumDepth < stack.length + 1) {
3829
- return '"[Array]"';
3830
- }
3831
- stack.push(value);
3832
- indentation += spacer;
3833
- let res2 = `
3834
- ${indentation}`;
3835
- const join2 = `,
3836
- ${indentation}`;
3837
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3838
- let i = 0;
3839
- for (; i < maximumValuesToStringify - 1; i++) {
3840
- const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3841
- res2 += tmp2 !== void 0 ? tmp2 : "null";
3842
- res2 += join2;
3843
- }
3844
- const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3845
- res2 += tmp !== void 0 ? tmp : "null";
3846
- if (value.length - 1 > maximumBreadth) {
3847
- const removedKeys = value.length - maximumBreadth - 1;
3848
- res2 += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
3849
- }
3850
- res2 += `
3851
- ${originalIndentation}`;
3852
- stack.pop();
3853
- return `[${res2}]`;
3854
- }
3855
- let keys = Object.keys(value);
3856
- const keyLength = keys.length;
3857
- if (keyLength === 0) {
3858
- return "{}";
3859
- }
3860
- if (maximumDepth < stack.length + 1) {
3861
- return '"[Object]"';
3862
- }
3863
- indentation += spacer;
3864
- const join = `,
3865
- ${indentation}`;
3866
- let res = "";
3867
- let separator = "";
3868
- let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3869
- if (isTypedArrayWithEntries(value)) {
3870
- res += stringifyTypedArray(value, join, maximumBreadth);
3871
- keys = keys.slice(value.length);
3872
- maximumPropertiesToStringify -= value.length;
3873
- separator = join;
3874
- }
3875
- if (deterministic) {
3876
- keys = sort(keys, comparator);
3877
- }
3878
- stack.push(value);
3879
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
3880
- const key2 = keys[i];
3881
- const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
3882
- if (tmp !== void 0) {
3883
- res += `${separator}${strEscape(key2)}: ${tmp}`;
3884
- separator = join;
3885
- }
3886
- }
3887
- if (keyLength > maximumBreadth) {
3888
- const removedKeys = keyLength - maximumBreadth;
3889
- res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
3890
- separator = join;
3891
- }
3892
- if (separator !== "") {
3893
- res = `
3894
- ${indentation}${res}
3895
- ${originalIndentation}`;
3896
- }
3897
- stack.pop();
3898
- return `{${res}}`;
3899
- }
3900
- case "number":
3901
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
3902
- case "boolean":
3903
- return value === true ? "true" : "false";
3904
- case "undefined":
3905
- return void 0;
3906
- case "bigint":
3907
- if (bigint) {
3908
- return String(value);
3909
- }
3910
- // fallthrough
3911
- default:
3912
- return fail ? fail(value) : void 0;
3913
- }
3914
- }
3915
- function stringifySimple(key, value, stack) {
3916
- switch (typeof value) {
3917
- case "string":
3918
- return strEscape(value);
3919
- case "object": {
3920
- if (value === null) {
3921
- return "null";
3922
- }
3923
- if (typeof value.toJSON === "function") {
3924
- value = value.toJSON(key);
3925
- if (typeof value !== "object") {
3926
- return stringifySimple(key, value, stack);
3927
- }
3928
- if (value === null) {
3929
- return "null";
3930
- }
3931
- }
3932
- if (stack.indexOf(value) !== -1) {
3933
- return circularValue;
3934
- }
3935
- let res = "";
3936
- const hasLength = value.length !== void 0;
3937
- if (hasLength && Array.isArray(value)) {
3938
- if (value.length === 0) {
3939
- return "[]";
3940
- }
3941
- if (maximumDepth < stack.length + 1) {
3942
- return '"[Array]"';
3943
- }
3944
- stack.push(value);
3945
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3946
- let i = 0;
3947
- for (; i < maximumValuesToStringify - 1; i++) {
3948
- const tmp2 = stringifySimple(String(i), value[i], stack);
3949
- res += tmp2 !== void 0 ? tmp2 : "null";
3950
- res += ",";
3951
- }
3952
- const tmp = stringifySimple(String(i), value[i], stack);
3953
- res += tmp !== void 0 ? tmp : "null";
3954
- if (value.length - 1 > maximumBreadth) {
3955
- const removedKeys = value.length - maximumBreadth - 1;
3956
- res += `,"... ${getItemCount(removedKeys)} not stringified"`;
3957
- }
3958
- stack.pop();
3959
- return `[${res}]`;
3960
- }
3961
- let keys = Object.keys(value);
3962
- const keyLength = keys.length;
3963
- if (keyLength === 0) {
3964
- return "{}";
3965
- }
3966
- if (maximumDepth < stack.length + 1) {
3967
- return '"[Object]"';
3968
- }
3969
- let separator = "";
3970
- let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3971
- if (hasLength && isTypedArrayWithEntries(value)) {
3972
- res += stringifyTypedArray(value, ",", maximumBreadth);
3973
- keys = keys.slice(value.length);
3974
- maximumPropertiesToStringify -= value.length;
3975
- separator = ",";
3976
- }
3977
- if (deterministic) {
3978
- keys = sort(keys, comparator);
3979
- }
3980
- stack.push(value);
3981
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
3982
- const key2 = keys[i];
3983
- const tmp = stringifySimple(key2, value[key2], stack);
3984
- if (tmp !== void 0) {
3985
- res += `${separator}${strEscape(key2)}:${tmp}`;
3986
- separator = ",";
3987
- }
3988
- }
3989
- if (keyLength > maximumBreadth) {
3990
- const removedKeys = keyLength - maximumBreadth;
3991
- res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
3992
- }
3993
- stack.pop();
3994
- return `{${res}}`;
3995
- }
3996
- case "number":
3997
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
3998
- case "boolean":
3999
- return value === true ? "true" : "false";
4000
- case "undefined":
4001
- return void 0;
4002
- case "bigint":
4003
- if (bigint) {
4004
- return String(value);
4005
- }
4006
- // fallthrough
4007
- default:
4008
- return fail ? fail(value) : void 0;
4009
- }
4010
- }
4011
- function stringify2(value, replacer, space) {
4012
- if (arguments.length > 1) {
4013
- let spacer = "";
4014
- if (typeof space === "number") {
4015
- spacer = " ".repeat(Math.min(space, 10));
4016
- } else if (typeof space === "string") {
4017
- spacer = space.slice(0, 10);
4018
- }
4019
- if (replacer != null) {
4020
- if (typeof replacer === "function") {
4021
- return stringifyFnReplacer("", { "": value }, [], replacer, spacer, "");
4022
- }
4023
- if (Array.isArray(replacer)) {
4024
- return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
4025
- }
4026
- }
4027
- if (spacer.length !== 0) {
4028
- return stringifyIndent("", value, [], spacer, "");
4029
- }
4030
- }
4031
- return stringifySimple("", value, []);
4032
- }
4033
- return stringify2;
4034
- }
4035
- }
4036
- });
4037
-
4038
- // ../../node_modules/pino/lib/multistream.js
4039
- var require_multistream = __commonJS({
4040
- "../../node_modules/pino/lib/multistream.js"(exports, module) {
4041
- "use strict";
4042
- var metadata = /* @__PURE__ */ Symbol.for("pino.metadata");
4043
- var { DEFAULT_LEVELS } = require_constants();
4044
- var DEFAULT_INFO_LEVEL = DEFAULT_LEVELS.info;
4045
- function multistream(streamsArray, opts) {
4046
- streamsArray = streamsArray || [];
4047
- opts = opts || { dedupe: false };
4048
- const streamLevels = Object.create(DEFAULT_LEVELS);
4049
- streamLevels.silent = Infinity;
4050
- if (opts.levels && typeof opts.levels === "object") {
4051
- Object.keys(opts.levels).forEach((i) => {
4052
- streamLevels[i] = opts.levels[i];
4053
- });
4054
- }
4055
- const res = {
4056
- write,
4057
- add,
4058
- remove,
4059
- emit,
4060
- flushSync,
4061
- end,
4062
- minLevel: 0,
4063
- lastId: 0,
4064
- streams: [],
4065
- clone,
4066
- [metadata]: true,
4067
- streamLevels
4068
- };
4069
- if (Array.isArray(streamsArray)) {
4070
- streamsArray.forEach(add, res);
4071
- } else {
4072
- add.call(res, streamsArray);
4073
- }
4074
- streamsArray = null;
4075
- return res;
4076
- function write(data) {
4077
- let dest;
4078
- const level = this.lastLevel;
4079
- const { streams } = this;
4080
- let recordedLevel = 0;
4081
- let stream;
4082
- for (let i = initLoopVar(streams.length, opts.dedupe); checkLoopVar(i, streams.length, opts.dedupe); i = adjustLoopVar(i, opts.dedupe)) {
4083
- dest = streams[i];
4084
- if (dest.level <= level) {
4085
- if (recordedLevel !== 0 && recordedLevel !== dest.level) {
4086
- break;
4087
- }
4088
- stream = dest.stream;
4089
- if (stream[metadata]) {
4090
- const { lastTime, lastMsg, lastObj, lastLogger } = this;
4091
- stream.lastLevel = level;
4092
- stream.lastTime = lastTime;
4093
- stream.lastMsg = lastMsg;
4094
- stream.lastObj = lastObj;
4095
- stream.lastLogger = lastLogger;
4096
- }
4097
- stream.write(data);
4098
- if (opts.dedupe) {
4099
- recordedLevel = dest.level;
4100
- }
4101
- } else if (!opts.dedupe) {
4102
- break;
4103
- }
4104
- }
4105
- }
4106
- function emit(...args) {
4107
- for (const { stream } of this.streams) {
4108
- if (typeof stream.emit === "function") {
4109
- stream.emit(...args);
4110
- }
4111
- }
4112
- }
4113
- function flushSync() {
4114
- for (const { stream } of this.streams) {
4115
- if (typeof stream.flushSync === "function") {
4116
- stream.flushSync();
4117
- }
4118
- }
4119
- }
4120
- function add(dest) {
4121
- if (!dest) {
4122
- return res;
4123
- }
4124
- const isStream = typeof dest.write === "function" || dest.stream;
4125
- const stream_ = dest.write ? dest : dest.stream;
4126
- if (!isStream) {
4127
- throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");
4128
- }
4129
- const { streams, streamLevels: streamLevels2 } = this;
4130
- let level;
4131
- if (typeof dest.levelVal === "number") {
4132
- level = dest.levelVal;
4133
- } else if (typeof dest.level === "string") {
4134
- level = streamLevels2[dest.level];
4135
- } else if (typeof dest.level === "number") {
4136
- level = dest.level;
4137
- } else {
4138
- level = DEFAULT_INFO_LEVEL;
4139
- }
4140
- const dest_ = {
4141
- stream: stream_,
4142
- level,
4143
- levelVal: void 0,
4144
- id: ++res.lastId
4145
- };
4146
- streams.unshift(dest_);
4147
- streams.sort(compareByLevel);
4148
- this.minLevel = streams[0].level;
4149
- return res;
4150
- }
4151
- function remove(id) {
4152
- const { streams } = this;
4153
- const index = streams.findIndex((s) => s.id === id);
4154
- if (index >= 0) {
4155
- streams.splice(index, 1);
4156
- streams.sort(compareByLevel);
4157
- this.minLevel = streams.length > 0 ? streams[0].level : -1;
4158
- }
4159
- return res;
4160
- }
4161
- function end() {
4162
- for (const { stream } of this.streams) {
4163
- if (typeof stream.flushSync === "function") {
4164
- stream.flushSync();
4165
- }
4166
- stream.end();
4167
- }
4168
- }
4169
- function clone(level) {
4170
- const streams = new Array(this.streams.length);
4171
- for (let i = 0; i < streams.length; i++) {
4172
- streams[i] = {
4173
- level,
4174
- stream: this.streams[i].stream
4175
- };
4176
- }
4177
- return {
4178
- write,
4179
- add,
4180
- remove,
4181
- minLevel: level,
4182
- streams,
4183
- clone,
4184
- emit,
4185
- flushSync,
4186
- [metadata]: true
4187
- };
4188
- }
4189
- }
4190
- function compareByLevel(a, b) {
4191
- return a.level - b.level;
4192
- }
4193
- function initLoopVar(length, dedupe) {
4194
- return dedupe ? length - 1 : 0;
4195
- }
4196
- function adjustLoopVar(i, dedupe) {
4197
- return dedupe ? i - 1 : i + 1;
4198
- }
4199
- function checkLoopVar(i, length, dedupe) {
4200
- return dedupe ? i >= 0 : i < length;
4201
- }
4202
- module.exports = multistream;
4203
- }
4204
- });
4205
-
4206
- // ../../node_modules/pino/pino.js
4207
- var require_pino = __commonJS({
4208
- "../../node_modules/pino/pino.js"(exports, module) {
4209
- "use strict";
4210
- var os = __require("os");
4211
- var stdSerializers = require_pino_std_serializers();
4212
- var caller = require_caller();
4213
- var redaction = require_redaction();
4214
- var time = require_time();
4215
- var proto = require_proto();
4216
- var symbols = require_symbols();
4217
- var { configure } = require_safe_stable_stringify();
4218
- var { assertDefaultLevelFound, mappings, genLsCache, genLevelComparison, assertLevelComparison } = require_levels();
4219
- var { DEFAULT_LEVELS, SORTING_ORDER } = require_constants();
4220
- var {
4221
- createArgsNormalizer,
4222
- asChindings,
4223
- buildSafeSonicBoom,
4224
- buildFormatters,
4225
- stringify,
4226
- normalizeDestFileDescriptor,
4227
- noop
4228
- } = require_tools();
4229
- var { version } = require_meta();
4230
- var {
4231
- chindingsSym,
4232
- redactFmtSym,
4233
- serializersSym,
4234
- timeSym,
4235
- timeSliceIndexSym,
4236
- streamSym,
4237
- stringifySym,
4238
- stringifySafeSym,
4239
- stringifiersSym,
4240
- setLevelSym,
4241
- endSym,
4242
- formatOptsSym,
4243
- messageKeySym,
4244
- errorKeySym,
4245
- nestedKeySym,
4246
- mixinSym,
4247
- levelCompSym,
4248
- useOnlyCustomLevelsSym,
4249
- formattersSym,
4250
- hooksSym,
4251
- nestedKeyStrSym,
4252
- mixinMergeStrategySym,
4253
- msgPrefixSym
4254
- } = symbols;
4255
- var { epochTime, nullTime } = time;
4256
- var { pid } = process;
4257
- var hostname = os.hostname();
4258
- var defaultErrorSerializer = stdSerializers.err;
4259
- var defaultOptions = {
4260
- level: "info",
4261
- levelComparison: SORTING_ORDER.ASC,
4262
- levels: DEFAULT_LEVELS,
4263
- messageKey: "msg",
4264
- errorKey: "err",
4265
- nestedKey: null,
4266
- enabled: true,
4267
- base: { pid, hostname },
4268
- serializers: Object.assign(/* @__PURE__ */ Object.create(null), {
4269
- err: defaultErrorSerializer
4270
- }),
4271
- formatters: Object.assign(/* @__PURE__ */ Object.create(null), {
4272
- bindings(bindings) {
4273
- return bindings;
4274
- },
4275
- level(label, number) {
4276
- return { level: number };
4277
- }
4278
- }),
4279
- hooks: {
4280
- logMethod: void 0,
4281
- streamWrite: void 0
4282
- },
4283
- timestamp: epochTime,
4284
- name: void 0,
4285
- redact: null,
4286
- customLevels: null,
4287
- useOnlyCustomLevels: false,
4288
- depthLimit: 5,
4289
- edgeLimit: 100
4290
- };
4291
- var normalize = createArgsNormalizer(defaultOptions);
4292
- var serializers = Object.assign(/* @__PURE__ */ Object.create(null), stdSerializers);
4293
- function pino2(...args) {
4294
- const instance = {};
4295
- const { opts, stream } = normalize(instance, caller(), ...args);
4296
- if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
4297
- const {
4298
- redact,
4299
- crlf,
4300
- serializers: serializers2,
4301
- timestamp,
4302
- messageKey,
4303
- errorKey,
4304
- nestedKey,
4305
- base,
4306
- name,
4307
- level,
4308
- customLevels,
4309
- levelComparison,
4310
- mixin,
4311
- mixinMergeStrategy,
4312
- useOnlyCustomLevels,
4313
- formatters,
4314
- hooks,
4315
- depthLimit,
4316
- edgeLimit,
4317
- onChild,
4318
- msgPrefix
4319
- } = opts;
4320
- const stringifySafe = configure({
4321
- maximumDepth: depthLimit,
4322
- maximumBreadth: edgeLimit
4323
- });
4324
- const allFormatters = buildFormatters(
4325
- formatters.level,
4326
- formatters.bindings,
4327
- formatters.log
4328
- );
4329
- const stringifyFn = stringify.bind({
4330
- [stringifySafeSym]: stringifySafe
4331
- });
4332
- const stringifiers = redact ? redaction(redact, stringifyFn) : {};
4333
- const formatOpts = redact ? { stringify: stringifiers[redactFmtSym] } : { stringify: stringifyFn };
4334
- const end = "}" + (crlf ? "\r\n" : "\n");
4335
- const coreChindings = asChindings.bind(null, {
4336
- [chindingsSym]: "",
4337
- [serializersSym]: serializers2,
4338
- [stringifiersSym]: stringifiers,
4339
- [stringifySym]: stringify,
4340
- [stringifySafeSym]: stringifySafe,
4341
- [formattersSym]: allFormatters
4342
- });
4343
- let chindings = "";
4344
- if (base !== null) {
4345
- if (name === void 0) {
4346
- chindings = coreChindings(base);
4347
- } else {
4348
- chindings = coreChindings(Object.assign({}, base, { name }));
4349
- }
4350
- }
4351
- const time2 = timestamp instanceof Function ? timestamp : timestamp ? epochTime : nullTime;
4352
- const timeSliceIndex = time2().indexOf(":") + 1;
4353
- if (useOnlyCustomLevels && !customLevels) throw Error("customLevels is required if useOnlyCustomLevels is set true");
4354
- if (mixin && typeof mixin !== "function") throw Error(`Unknown mixin type "${typeof mixin}" - expected "function"`);
4355
- if (msgPrefix && typeof msgPrefix !== "string") throw Error(`Unknown msgPrefix type "${typeof msgPrefix}" - expected "string"`);
4356
- assertDefaultLevelFound(level, customLevels, useOnlyCustomLevels);
4357
- const levels = mappings(customLevels, useOnlyCustomLevels);
4358
- if (typeof stream.emit === "function") {
4359
- stream.emit("message", { code: "PINO_CONFIG", config: { levels, messageKey, errorKey } });
4360
- }
4361
- assertLevelComparison(levelComparison);
4362
- const levelCompFunc = genLevelComparison(levelComparison);
4363
- Object.assign(instance, {
4364
- levels,
4365
- [levelCompSym]: levelCompFunc,
4366
- [useOnlyCustomLevelsSym]: useOnlyCustomLevels,
4367
- [streamSym]: stream,
4368
- [timeSym]: time2,
4369
- [timeSliceIndexSym]: timeSliceIndex,
4370
- [stringifySym]: stringify,
4371
- [stringifySafeSym]: stringifySafe,
4372
- [stringifiersSym]: stringifiers,
4373
- [endSym]: end,
4374
- [formatOptsSym]: formatOpts,
4375
- [messageKeySym]: messageKey,
4376
- [errorKeySym]: errorKey,
4377
- [nestedKeySym]: nestedKey,
4378
- // protect against injection
4379
- [nestedKeyStrSym]: nestedKey ? `,${JSON.stringify(nestedKey)}:{` : "",
4380
- [serializersSym]: serializers2,
4381
- [mixinSym]: mixin,
4382
- [mixinMergeStrategySym]: mixinMergeStrategy,
4383
- [chindingsSym]: chindings,
4384
- [formattersSym]: allFormatters,
4385
- [hooksSym]: hooks,
4386
- silent: noop,
4387
- onChild,
4388
- [msgPrefixSym]: msgPrefix
4389
- });
4390
- Object.setPrototypeOf(instance, proto());
4391
- genLsCache(instance);
4392
- instance[setLevelSym](level);
4393
- return instance;
4394
- }
4395
- module.exports = pino2;
4396
- module.exports.destination = (dest = process.stdout.fd) => {
4397
- if (typeof dest === "object") {
4398
- dest.dest = normalizeDestFileDescriptor(dest.dest || process.stdout.fd);
4399
- return buildSafeSonicBoom(dest);
4400
- } else {
4401
- return buildSafeSonicBoom({ dest: normalizeDestFileDescriptor(dest), minLength: 0 });
4402
- }
4403
- };
4404
- module.exports.transport = require_transport();
4405
- module.exports.multistream = require_multistream();
4406
- module.exports.levels = mappings();
4407
- module.exports.stdSerializers = serializers;
4408
- module.exports.stdTimeFunctions = Object.assign({}, time);
4409
- module.exports.symbols = symbols;
4410
- module.exports.version = version;
4411
- module.exports.default = pino2;
4412
- module.exports.pino = pino2;
4413
- }
4414
- });
4415
-
4416
1
  // src/index.ts
4417
2
  import { createPgDb } from "@heyhru/server-plugin-pg";
4418
3
 
@@ -4447,11 +32,10 @@ function verifyToken(token) {
4447
32
  }
4448
33
 
4449
34
  // src/logger.ts
4450
- var import_pino = __toESM(require_pino(), 1);
4451
35
  import pinoRoll from "pino-roll";
4452
36
  import { createLogger } from "@heyhru/common-util-logger";
4453
37
  var { createWriteStream } = pinoRoll;
4454
- async function buildDestination() {
38
+ async function buildStreams() {
4455
39
  if (config.nodeEnv !== "production" || !config.logDir) {
4456
40
  return void 0;
4457
41
  }
@@ -4461,11 +45,11 @@ async function buildDestination() {
4461
45
  size: "500m",
4462
46
  mkdir: true
4463
47
  });
4464
- return import_pino.default.multistream([{ stream: process.stdout }, { stream: fileStream }]);
48
+ return [{ stream: process.stdout }, { stream: fileStream }];
4465
49
  }
4466
50
  var logger = createLogger({
4467
51
  name: "dms-server",
4468
- destination: await buildDestination()
52
+ streams: await buildStreams()
4469
53
  });
4470
54
 
4471
55
  // src/auth/auth.permissions.ts