@adviser/cement 0.3.14 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{base-sys-abstraction-8v83VyEU.d.ts → base-sys-abstraction-BnBZ6zd0.d.ts} +2 -2
- package/{base-sys-abstraction-4Vw4QGaI.d.cts → base-sys-abstraction-DAZ8tx5F.d.cts} +2 -2
- package/cf/index.cjs +46 -18
- package/cf/index.cjs.map +1 -1
- package/cf/index.d.cts +3 -3
- package/cf/index.d.ts +3 -3
- package/cf/index.js +3 -3
- package/{chunk-W53WEZWY.js → chunk-55W4AK2Z.js} +3 -5
- package/{chunk-W53WEZWY.js.map → chunk-55W4AK2Z.js.map} +1 -1
- package/{chunk-22GI5ETU.js → chunk-H3CAVBMO.js} +41 -42
- package/chunk-H3CAVBMO.js.map +1 -0
- package/{chunk-A57BAYWU.js → chunk-LXTKPZ6M.js} +10 -8
- package/chunk-LXTKPZ6M.js.map +1 -0
- package/{chunk-KY47QBK3.js → chunk-WGRZHIFK.js} +155 -152
- package/chunk-WGRZHIFK.js.map +1 -0
- package/{chunk-GLUGMVET.js → chunk-Z3IR6QEZ.js} +3 -3
- package/deno/index.cjs +46 -18
- package/deno/index.cjs.map +1 -1
- package/deno/index.d.cts +3 -3
- package/deno/index.d.ts +3 -3
- package/deno/index.js +2 -2
- package/{get-params-result-C2cbgB78.d.ts → get-params-result-4xHM5s4_.d.cts} +14 -10
- package/{get-params-result-C2cbgB78.d.cts → get-params-result-4xHM5s4_.d.ts} +14 -10
- package/index-CMLb7JSe.d.ts +97 -0
- package/{index-DixRvifF.d.cts → index-Cp1NspHH.d.cts} +10 -10
- package/{index-D2WPDt4R.d.ts → index-D1j1fPYg.d.ts} +10 -10
- package/index-LQOsS7gM.d.cts +97 -0
- package/index.cjs +370 -317
- package/index.cjs.map +1 -1
- package/index.d.cts +23 -10
- package/index.d.ts +23 -10
- package/index.js +86 -39
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/index.cjs +46 -18
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -3
- package/node/index.d.ts +3 -3
- package/node/index.js +2 -2
- package/package.json +5 -4
- package/src/index.ts +4 -2
- package/src/jsr.json +1 -1
- package/src/logger.ts +8 -6
- package/src/lru-cache.ts +68 -0
- package/src/sys-abstraction.ts +18 -15
- package/src/time.ts +7 -9
- package/src/types.ts +19 -0
- package/src/uri.ts +4 -3
- package/src/utils/get-params-result.ts +2 -18
- package/src/utils/relative-path.ts +8 -6
- package/{sys-abstraction-3OXhCVsu.d.cts → sys-abstraction-B0x6IE7r.d.ts} +27 -23
- package/{sys-abstraction-DXeSUn9x.d.ts → sys-abstraction-BTs3Vzy4.d.cts} +27 -23
- package/test/index.cjs +87 -46
- package/test/index.cjs.map +1 -1
- package/test/index.d.cts +3 -3
- package/test/index.d.ts +3 -3
- package/test/index.js +4 -4
- package/ts/src/index.d.ts +2 -2
- package/ts/src/index.d.ts.map +1 -1
- package/ts/src/index.js +2 -2
- package/ts/src/index.js.map +1 -1
- package/ts/src/logger.d.ts +7 -6
- package/ts/src/logger.d.ts.map +1 -1
- package/ts/src/logger.js +6 -7
- package/ts/src/logger.js.map +1 -1
- package/ts/src/lru-cache.d.ts +15 -0
- package/ts/src/lru-cache.d.ts.map +1 -0
- package/ts/src/lru-cache.js +46 -0
- package/ts/src/lru-cache.js.map +1 -0
- package/ts/src/lru-cache.test.d.ts +2 -0
- package/ts/src/lru-cache.test.d.ts.map +1 -0
- package/ts/src/lru-cache.test.js +54 -0
- package/ts/src/lru-cache.test.js.map +1 -0
- package/ts/src/sys-abstraction.d.ts +18 -15
- package/ts/src/sys-abstraction.d.ts.map +1 -1
- package/ts/src/sys-abstraction.js +15 -18
- package/ts/src/sys-abstraction.js.map +1 -1
- package/ts/src/sys-env.test.js +1 -2
- package/ts/src/sys-env.test.js.map +1 -1
- package/ts/src/time.d.ts +7 -6
- package/ts/src/time.d.ts.map +1 -1
- package/ts/src/time.js +6 -7
- package/ts/src/time.js.map +1 -1
- package/ts/src/types.d.ts +16 -0
- package/ts/src/types.d.ts.map +1 -0
- package/ts/src/types.js +15 -0
- package/ts/src/types.js.map +1 -0
- package/ts/src/uri.d.ts +0 -1
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +1 -2
- package/ts/src/uri.js.map +1 -1
- package/ts/src/utils/get-params-result.d.ts +2 -13
- package/ts/src/utils/get-params-result.d.ts.map +1 -1
- package/ts/src/utils/get-params-result.js +1 -14
- package/ts/src/utils/get-params-result.js.map +1 -1
- package/ts/src/utils/relative-path.d.ts +7 -6
- package/ts/src/utils/relative-path.d.ts.map +1 -1
- package/ts/src/utils/relative-path.js +6 -7
- package/ts/src/utils/relative-path.js.map +1 -1
- package/utils/index.cjs +9 -9
- package/utils/index.cjs.map +1 -1
- package/utils/index.d.cts +2 -2
- package/utils/index.d.ts +2 -2
- package/utils/index.js +3 -5
- package/web/index.cjs +46 -18
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +3 -3
- package/web/index.d.ts +3 -3
- package/web/index.js +3 -3
- package/chunk-22GI5ETU.js.map +0 -1
- package/chunk-A57BAYWU.js.map +0 -1
- package/chunk-KY47QBK3.js.map +0 -1
- package/index-Dpc3oVOD.d.cts +0 -99
- package/index-MWn9Xel9.d.ts +0 -99
- /package/{chunk-GLUGMVET.js.map → chunk-Z3IR6QEZ.js.map} +0 -0
@@ -5,18 +5,17 @@ import {
|
|
5
5
|
} from "./chunk-PHS255C5.js";
|
6
6
|
import {
|
7
7
|
WebSysAbstraction
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-Z3IR6QEZ.js";
|
9
9
|
import {
|
10
10
|
Future,
|
11
11
|
runtimeFn
|
12
|
-
} from "./chunk-
|
12
|
+
} from "./chunk-H3CAVBMO.js";
|
13
13
|
import {
|
14
14
|
Result,
|
15
15
|
TxtEnDecoderSingleton,
|
16
16
|
exception2Result,
|
17
|
-
getParamsResult
|
18
|
-
|
19
|
-
} from "./chunk-A57BAYWU.js";
|
17
|
+
getParamsResult
|
18
|
+
} from "./chunk-LXTKPZ6M.js";
|
20
19
|
|
21
20
|
// src/test/log-write-stream.ts
|
22
21
|
var LogWriteStream = class {
|
@@ -144,13 +143,12 @@ function bin2string(hex, size = 0) {
|
|
144
143
|
}
|
145
144
|
|
146
145
|
// src/logger.ts
|
147
|
-
var Level =
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
})(Level || {});
|
146
|
+
var Level = {
|
147
|
+
WARN: "warn",
|
148
|
+
DEBUG: "debug",
|
149
|
+
INFO: "info",
|
150
|
+
ERROR: "error"
|
151
|
+
};
|
154
152
|
var LogValue = class {
|
155
153
|
constructor(fn) {
|
156
154
|
this.fn = fn;
|
@@ -244,16 +242,16 @@ function logValueInternal(val, ctx) {
|
|
244
242
|
}
|
245
243
|
const res = {};
|
246
244
|
const typedVal = val;
|
247
|
-
for (const
|
248
|
-
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(
|
245
|
+
for (const key in typedVal) {
|
246
|
+
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(key)) {
|
249
247
|
continue;
|
250
248
|
}
|
251
|
-
const element = typedVal[
|
249
|
+
const element = typedVal[key];
|
252
250
|
if (element instanceof LogValue) {
|
253
|
-
res[
|
251
|
+
res[key] = element;
|
254
252
|
} else {
|
255
253
|
if (typeof element !== "function") {
|
256
|
-
res[
|
254
|
+
res[key] = logValueInternal(element, ctx);
|
257
255
|
}
|
258
256
|
}
|
259
257
|
}
|
@@ -344,7 +342,7 @@ var None = class extends Option {
|
|
344
342
|
// src/log-level-impl.ts
|
345
343
|
var LevelHandlerImpl = class {
|
346
344
|
constructor() {
|
347
|
-
this._globalLevels = /* @__PURE__ */ new Set([
|
345
|
+
this._globalLevels = /* @__PURE__ */ new Set([Level.INFO, Level.ERROR, Level.WARN]);
|
348
346
|
this._modules = /* @__PURE__ */ new Map();
|
349
347
|
this.ignoreAttr = Option.Some(/^_/);
|
350
348
|
this.isStackExposed = false;
|
@@ -394,9 +392,9 @@ var LevelHandlerImpl = class {
|
|
394
392
|
}
|
395
393
|
setDebug(...modules) {
|
396
394
|
this.forModules(
|
397
|
-
|
395
|
+
Level.DEBUG,
|
398
396
|
(p) => {
|
399
|
-
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels,
|
397
|
+
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, Level.DEBUG]));
|
400
398
|
},
|
401
399
|
...modules
|
402
400
|
);
|
@@ -430,6 +428,13 @@ function LevelHandlerSingleton() {
|
|
430
428
|
import YAML from "yaml";
|
431
429
|
|
432
430
|
// src/utils/relative-path.ts
|
431
|
+
var PartType = {
|
432
|
+
Slash: 1,
|
433
|
+
Root: 3,
|
434
|
+
Up: 4,
|
435
|
+
Noop: 8
|
436
|
+
// RootUp = 0x8 /* ../ */,
|
437
|
+
};
|
433
438
|
var Path = class {
|
434
439
|
constructor(parts = []) {
|
435
440
|
this.parts = parts;
|
@@ -440,10 +445,10 @@ var Path = class {
|
|
440
445
|
return part;
|
441
446
|
} else {
|
442
447
|
switch (part) {
|
443
|
-
case
|
444
|
-
case
|
448
|
+
case PartType.Slash:
|
449
|
+
case PartType.Root:
|
445
450
|
return "/";
|
446
|
-
case
|
451
|
+
case PartType.Up:
|
447
452
|
return "..";
|
448
453
|
default:
|
449
454
|
return part;
|
@@ -452,22 +457,22 @@ var Path = class {
|
|
452
457
|
}).join("");
|
453
458
|
}
|
454
459
|
add(part) {
|
455
|
-
if (this.parts.includes(
|
460
|
+
if (this.parts.includes(PartType.Root) && part === PartType.Root) {
|
456
461
|
throw new Error("Cannot add absolute part to absolute path");
|
457
462
|
}
|
458
463
|
const last = this.parts[this.parts.length - 1];
|
459
|
-
if (last &
|
464
|
+
if (last & PartType.Slash && part === PartType.Slash) {
|
460
465
|
return;
|
461
466
|
}
|
462
467
|
switch (part) {
|
463
468
|
case ".":
|
464
|
-
this.parts.push(
|
469
|
+
this.parts.push(PartType.Noop);
|
465
470
|
return;
|
466
471
|
case "..":
|
467
|
-
part =
|
472
|
+
part = PartType.Up;
|
468
473
|
}
|
469
|
-
if (last ===
|
470
|
-
if (last ===
|
474
|
+
if (last === PartType.Noop && part === PartType.Slash) {
|
475
|
+
if (last === PartType.Noop) {
|
471
476
|
this.parts.pop();
|
472
477
|
}
|
473
478
|
return;
|
@@ -483,9 +488,9 @@ function splitPath(path) {
|
|
483
488
|
for (let count = 0; path.length; count++) {
|
484
489
|
if (path.match(/^\/+/)) {
|
485
490
|
if (count === 0) {
|
486
|
-
p.add(
|
491
|
+
p.add(PartType.Root);
|
487
492
|
} else {
|
488
|
-
p.add(
|
493
|
+
p.add(PartType.Slash);
|
489
494
|
}
|
490
495
|
path = path.replace(/^\/+/, "");
|
491
496
|
} else {
|
@@ -519,7 +524,7 @@ function pathJoin(...paths) {
|
|
519
524
|
function relativePath(path, relative) {
|
520
525
|
const relativeParts = splitPath(relative);
|
521
526
|
let result;
|
522
|
-
if (relativeParts.parts[0] ===
|
527
|
+
if (relativeParts.parts[0] === PartType.Root) {
|
523
528
|
result = relative;
|
524
529
|
} else {
|
525
530
|
result = pathJoin(path, relative);
|
@@ -529,13 +534,13 @@ function relativePath(path, relative) {
|
|
529
534
|
let topUp = false;
|
530
535
|
for (const part of unoptPath.parts) {
|
531
536
|
switch (part) {
|
532
|
-
case
|
533
|
-
out.push(
|
537
|
+
case PartType.Root:
|
538
|
+
out.push(PartType.Root);
|
534
539
|
break;
|
535
|
-
case
|
540
|
+
case PartType.Up:
|
536
541
|
if (out.length && !topUp) {
|
537
542
|
const last = out.length - 1;
|
538
|
-
if (typeof out[last] === "string" && out[last - 1] ==
|
543
|
+
if (typeof out[last] === "string" && out[last - 1] == PartType.Root) {
|
539
544
|
out.pop();
|
540
545
|
} else {
|
541
546
|
out.pop();
|
@@ -543,15 +548,15 @@ function relativePath(path, relative) {
|
|
543
548
|
}
|
544
549
|
if (out.length === 0) {
|
545
550
|
topUp = !topUp ? true : topUp;
|
546
|
-
out.push(
|
551
|
+
out.push(PartType.Up);
|
547
552
|
}
|
548
553
|
} else {
|
549
|
-
out.push(
|
554
|
+
out.push(PartType.Up);
|
550
555
|
}
|
551
556
|
break;
|
552
|
-
case
|
553
|
-
if (!(out[out.length - 1] &
|
554
|
-
out.push(
|
557
|
+
case PartType.Slash:
|
558
|
+
if (!(out[out.length - 1] & PartType.Slash)) {
|
559
|
+
out.push(PartType.Slash);
|
555
560
|
}
|
556
561
|
break;
|
557
562
|
default:
|
@@ -563,16 +568,15 @@ function relativePath(path, relative) {
|
|
563
568
|
}
|
564
569
|
|
565
570
|
// src/uri.ts
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
const keys = Object.keys(key2);
|
571
|
+
function coerceKey(key, def) {
|
572
|
+
if (typeof key === "object") {
|
573
|
+
const keys = Object.keys(key);
|
570
574
|
if (keys.length !== 1) {
|
571
|
-
throw new Error(`Invalid key: ${JSON.stringify(
|
575
|
+
throw new Error(`Invalid key: ${JSON.stringify(key)}`);
|
572
576
|
}
|
573
|
-
return { key: keys[0], def:
|
577
|
+
return { key: keys[0], def: key[keys[0]] };
|
574
578
|
}
|
575
|
-
return { key
|
579
|
+
return { key, def };
|
576
580
|
}
|
577
581
|
function falsy2undef(value) {
|
578
582
|
return value === void 0 || value === null ? void 0 : value;
|
@@ -675,8 +679,8 @@ var MutableURL = class _MutableURL extends URL {
|
|
675
679
|
toString() {
|
676
680
|
let search = "";
|
677
681
|
if (this._sysURL.searchParams.size) {
|
678
|
-
for (const [
|
679
|
-
search += `${!search.length ? "?" : "&"}${
|
682
|
+
for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
683
|
+
search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
|
680
684
|
}
|
681
685
|
}
|
682
686
|
let hostpart = "";
|
@@ -711,11 +715,11 @@ function from(fac, strURLUri, defaultProtocol) {
|
|
711
715
|
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
712
716
|
}
|
713
717
|
}
|
714
|
-
function getParamResult(
|
715
|
-
return `missing parameter: ${
|
718
|
+
function getParamResult(key, val, msgFn = (key2) => {
|
719
|
+
return `missing parameter: ${key2}`;
|
716
720
|
}) {
|
717
721
|
if (val === void 0) {
|
718
|
-
return Result.Err(msgFn(
|
722
|
+
return Result.Err(msgFn(key));
|
719
723
|
}
|
720
724
|
return Result.Ok(val);
|
721
725
|
}
|
@@ -772,47 +776,47 @@ var BuildURI = class _BuildURI {
|
|
772
776
|
const pathname = "./" + appendUrl.pathname;
|
773
777
|
const basePath = this._url.pathname;
|
774
778
|
this.pathname(relativePath(basePath, pathname));
|
775
|
-
for (const [
|
776
|
-
this.setParam(
|
779
|
+
for (const [key, value] of appendUrl.getParams) {
|
780
|
+
this.setParam(key, value);
|
777
781
|
}
|
778
782
|
return this;
|
779
783
|
}
|
780
784
|
cleanParams() {
|
781
|
-
for (const
|
782
|
-
this._url.searchParams.delete(
|
785
|
+
for (const key of Array.from(this._url.searchParams.keys())) {
|
786
|
+
this._url.searchParams.delete(key);
|
783
787
|
}
|
784
788
|
return this;
|
785
789
|
}
|
786
|
-
delParam(
|
787
|
-
this._url.searchParams.delete(
|
790
|
+
delParam(key) {
|
791
|
+
this._url.searchParams.delete(key);
|
788
792
|
return this;
|
789
793
|
}
|
790
|
-
defParam(
|
791
|
-
if (!this._url.searchParams.has(
|
792
|
-
this._url.searchParams.set(
|
794
|
+
defParam(key, str) {
|
795
|
+
if (!this._url.searchParams.has(key)) {
|
796
|
+
this._url.searchParams.set(key, str);
|
793
797
|
}
|
794
798
|
return this;
|
795
799
|
}
|
796
|
-
setParam(
|
797
|
-
this._url.searchParams.set(
|
800
|
+
setParam(key, str) {
|
801
|
+
this._url.searchParams.set(key, str);
|
798
802
|
return this;
|
799
803
|
}
|
800
|
-
hasParam(
|
801
|
-
return this._url.searchParams.has(
|
804
|
+
hasParam(key) {
|
805
|
+
return this._url.searchParams.has(key);
|
802
806
|
}
|
803
807
|
get getParams() {
|
804
808
|
return this._url.searchParams.entries();
|
805
809
|
}
|
806
|
-
getParam(
|
807
|
-
const { key: k, def: d } = coerceKey(
|
810
|
+
getParam(key, def) {
|
811
|
+
const { key: k, def: d } = coerceKey(key, def);
|
808
812
|
let val = this._url.searchParams.get(k);
|
809
813
|
if (!falsy2undef(val) && d) {
|
810
814
|
val = d;
|
811
815
|
}
|
812
816
|
return falsy2undef(val);
|
813
817
|
}
|
814
|
-
getParamResult(
|
815
|
-
return getParamResult(
|
818
|
+
getParamResult(key, msgFn) {
|
819
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
816
820
|
}
|
817
821
|
getParamsResult(...keys) {
|
818
822
|
return getParamsResult(keys, this);
|
@@ -873,8 +877,8 @@ var URI = class _URI {
|
|
873
877
|
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
874
878
|
intoUrl.pathname(fromUrl.pathname);
|
875
879
|
}
|
876
|
-
for (const [
|
877
|
-
intoUrl.setParam(
|
880
|
+
for (const [key, value] of fromUrl.getParams) {
|
881
|
+
intoUrl.setParam(key, value);
|
878
882
|
}
|
879
883
|
return intoUrl.URI();
|
880
884
|
}
|
@@ -927,19 +931,19 @@ var URI = class _URI {
|
|
927
931
|
get getParams() {
|
928
932
|
return this._url.searchParams.entries();
|
929
933
|
}
|
930
|
-
hasParam(
|
931
|
-
return this._url.searchParams.has(
|
934
|
+
hasParam(key) {
|
935
|
+
return this._url.searchParams.has(key);
|
932
936
|
}
|
933
|
-
getParam(
|
934
|
-
const { key: k, def: d } = coerceKey(
|
937
|
+
getParam(key, def) {
|
938
|
+
const { key: k, def: d } = coerceKey(key, def);
|
935
939
|
let val = this._url.searchParams.get(k);
|
936
940
|
if (!falsy2undef(val) && d) {
|
937
941
|
val = d;
|
938
942
|
}
|
939
943
|
return falsy2undef(val);
|
940
944
|
}
|
941
|
-
getParamResult(
|
942
|
-
return getParamResult(
|
945
|
+
getParamResult(key, msgFn) {
|
946
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
943
947
|
}
|
944
948
|
getParamsResult(...keys) {
|
945
949
|
return getParamsResult(keys, this);
|
@@ -1144,9 +1148,9 @@ var LoggerImpl = class _LoggerImpl {
|
|
1144
1148
|
this.levelHandler.disableLevel(level, ...modules);
|
1145
1149
|
return this;
|
1146
1150
|
}
|
1147
|
-
Module(
|
1148
|
-
this._attributes["module"] = logValue(
|
1149
|
-
this._withAttributes["module"] = logValue(
|
1151
|
+
Module(key) {
|
1152
|
+
this._attributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
|
1153
|
+
this._withAttributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
|
1150
1154
|
return this;
|
1151
1155
|
}
|
1152
1156
|
// if the string is "*" it will enable for all modules
|
@@ -1167,30 +1171,30 @@ var LoggerImpl = class _LoggerImpl {
|
|
1167
1171
|
return this;
|
1168
1172
|
}
|
1169
1173
|
Warn() {
|
1170
|
-
this._attributes["level"] = logValue(
|
1174
|
+
this._attributes["level"] = logValue(Level.WARN, toLogValueCtx(this.levelHandler));
|
1171
1175
|
return this;
|
1172
1176
|
}
|
1173
1177
|
Log() {
|
1174
1178
|
return this;
|
1175
1179
|
}
|
1176
1180
|
Debug() {
|
1177
|
-
this._attributes["level"] = logValue(
|
1181
|
+
this._attributes["level"] = logValue(Level.DEBUG, toLogValueCtx(this.levelHandler));
|
1178
1182
|
return this;
|
1179
1183
|
}
|
1180
1184
|
Error() {
|
1181
|
-
this._attributes["level"] = logValue(
|
1185
|
+
this._attributes["level"] = logValue(Level.ERROR, toLogValueCtx(this.levelHandler));
|
1182
1186
|
return this;
|
1183
1187
|
}
|
1184
1188
|
Info() {
|
1185
|
-
this._attributes["level"] = logValue(
|
1189
|
+
this._attributes["level"] = logValue(Level.INFO, toLogValueCtx(this.levelHandler));
|
1186
1190
|
return this;
|
1187
1191
|
}
|
1188
1192
|
Err(err) {
|
1189
1193
|
var _a;
|
1190
|
-
let
|
1194
|
+
let key = "error";
|
1191
1195
|
if (Result.Is(err)) {
|
1192
1196
|
if (err.isOk()) {
|
1193
|
-
|
1197
|
+
key = "noerror";
|
1194
1198
|
err = err.Ok();
|
1195
1199
|
} else {
|
1196
1200
|
err = err.Err();
|
@@ -1198,12 +1202,12 @@ var LoggerImpl = class _LoggerImpl {
|
|
1198
1202
|
}
|
1199
1203
|
if (err instanceof Error) {
|
1200
1204
|
if (err.cause) {
|
1201
|
-
this.coerceKey(
|
1205
|
+
this.coerceKey(key, {
|
1202
1206
|
message: err.message,
|
1203
1207
|
cause: err.cause
|
1204
1208
|
});
|
1205
1209
|
} else {
|
1206
|
-
this._attributes[
|
1210
|
+
this._attributes[key] = logValue(err.message, toLogValueCtx(this.levelHandler));
|
1207
1211
|
}
|
1208
1212
|
if (this.levelHandler.isStackExposed) {
|
1209
1213
|
this._attributes["stack"] = logValue(
|
@@ -1212,7 +1216,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
1212
1216
|
);
|
1213
1217
|
}
|
1214
1218
|
} else {
|
1215
|
-
this.Any(
|
1219
|
+
this.Any(key, err);
|
1216
1220
|
}
|
1217
1221
|
return this;
|
1218
1222
|
}
|
@@ -1220,22 +1224,22 @@ var LoggerImpl = class _LoggerImpl {
|
|
1220
1224
|
this._attributes["level"] = logValue(l, toLogValueCtx(this.levelHandler));
|
1221
1225
|
return this;
|
1222
1226
|
}
|
1223
|
-
Ref(
|
1227
|
+
Ref(key, action) {
|
1224
1228
|
if (typeof action === "function") {
|
1225
|
-
this._attributes[
|
1229
|
+
this._attributes[key] = logValue(action, toLogValueCtx(this.levelHandler));
|
1226
1230
|
} else if (typeof action.toString === "function") {
|
1227
|
-
this._attributes[
|
1231
|
+
this._attributes[key] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));
|
1228
1232
|
} else {
|
1229
|
-
this._attributes[
|
1233
|
+
this._attributes[key] = logValue("INVALID REF", toLogValueCtx(this.levelHandler));
|
1230
1234
|
}
|
1231
1235
|
return this;
|
1232
1236
|
}
|
1233
|
-
Bool(
|
1234
|
-
this.coerceKey(
|
1237
|
+
Bool(key, value) {
|
1238
|
+
this.coerceKey(key, !!value);
|
1235
1239
|
return this;
|
1236
1240
|
}
|
1237
1241
|
Http(...mix) {
|
1238
|
-
const
|
1242
|
+
const key = mix.find((x) => typeof x === "string");
|
1239
1243
|
mix = mix.filter((x) => typeof x !== "string");
|
1240
1244
|
const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
|
1241
1245
|
if (resErrors.length) {
|
@@ -1255,70 +1259,70 @@ var LoggerImpl = class _LoggerImpl {
|
|
1255
1259
|
reqAndOrres = req;
|
1256
1260
|
}
|
1257
1261
|
if (reqAndOrres) {
|
1258
|
-
this.Any(
|
1262
|
+
this.Any(key || "Http", reqAndOrres);
|
1259
1263
|
}
|
1260
1264
|
return this;
|
1261
1265
|
}
|
1262
1266
|
Pair(x) {
|
1263
|
-
for (const
|
1264
|
-
const value = x[
|
1267
|
+
for (const key of Object.keys(x)) {
|
1268
|
+
const value = x[key];
|
1265
1269
|
if (value instanceof LogValue) {
|
1266
|
-
this._attributes[
|
1270
|
+
this._attributes[key] = value;
|
1267
1271
|
continue;
|
1268
1272
|
}
|
1269
1273
|
if (Result.Is(value)) {
|
1270
|
-
this.Result(
|
1274
|
+
this.Result(key, value);
|
1271
1275
|
continue;
|
1272
1276
|
}
|
1273
|
-
this.Any(
|
1277
|
+
this.Any(key, value);
|
1274
1278
|
}
|
1275
1279
|
return this;
|
1276
1280
|
}
|
1277
|
-
Result(
|
1281
|
+
Result(key, res) {
|
1278
1282
|
if (res.isOk()) {
|
1279
|
-
this._attributes[
|
1283
|
+
this._attributes[key] = logValue(res.Ok(), toLogValueCtx(this.levelHandler));
|
1280
1284
|
} else {
|
1281
1285
|
this.Err(res.Err());
|
1282
1286
|
}
|
1283
1287
|
return this;
|
1284
1288
|
}
|
1285
|
-
Len(value,
|
1286
|
-
this._attributes[
|
1289
|
+
Len(value, key = "len") {
|
1290
|
+
this._attributes[key] = getLen(value, toLogValueCtx(this.levelHandler));
|
1287
1291
|
return this;
|
1288
1292
|
}
|
1289
1293
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1290
|
-
Hash(value,
|
1294
|
+
Hash(value, key = "hash") {
|
1291
1295
|
throw new Error("Not implemented");
|
1292
1296
|
}
|
1293
|
-
Url(url,
|
1294
|
-
this.Ref(
|
1297
|
+
Url(url, key = "url") {
|
1298
|
+
this.Ref(key, () => URI.from(url).toString());
|
1295
1299
|
return this;
|
1296
1300
|
}
|
1297
|
-
coerceKey(
|
1298
|
-
if (typeof
|
1299
|
-
this._attributes[
|
1301
|
+
coerceKey(key, value) {
|
1302
|
+
if (typeof key === "string") {
|
1303
|
+
this._attributes[key] = logValue(value, toLogValueCtx(this.levelHandler));
|
1300
1304
|
} else {
|
1301
|
-
this.Pair(
|
1305
|
+
this.Pair(key);
|
1302
1306
|
}
|
1303
1307
|
}
|
1304
|
-
Str(
|
1305
|
-
this.coerceKey(
|
1308
|
+
Str(key, value) {
|
1309
|
+
this.coerceKey(key, value);
|
1306
1310
|
return this;
|
1307
1311
|
}
|
1308
|
-
Any(
|
1309
|
-
this.coerceKey(
|
1312
|
+
Any(key, value) {
|
1313
|
+
this.coerceKey(key, value);
|
1310
1314
|
return this;
|
1311
1315
|
}
|
1312
|
-
Dur(
|
1313
|
-
this._attributes[
|
1316
|
+
Dur(key, nsec) {
|
1317
|
+
this._attributes[key] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));
|
1314
1318
|
return this;
|
1315
1319
|
}
|
1316
|
-
Uint64(
|
1317
|
-
this.coerceKey(
|
1320
|
+
Uint64(key, value) {
|
1321
|
+
this.coerceKey(key, value);
|
1318
1322
|
return this;
|
1319
1323
|
}
|
1320
|
-
Int(
|
1321
|
-
return this.Uint64(
|
1324
|
+
Int(key, value) {
|
1325
|
+
return this.Uint64(key, value);
|
1322
1326
|
}
|
1323
1327
|
async Flush() {
|
1324
1328
|
return new Promise((resolve) => {
|
@@ -1341,8 +1345,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
1341
1345
|
}
|
1342
1346
|
_resetAttributes(fn) {
|
1343
1347
|
const ret = fn();
|
1344
|
-
Object.keys(this._attributes).forEach((
|
1345
|
-
delete this._attributes[
|
1348
|
+
Object.keys(this._attributes).forEach((key) => {
|
1349
|
+
delete this._attributes[key];
|
1346
1350
|
});
|
1347
1351
|
Object.assign(this._attributes, this._withAttributes);
|
1348
1352
|
return ret;
|
@@ -1409,8 +1413,8 @@ var WithLoggerBuilder = class {
|
|
1409
1413
|
this._li.levelHandler.enableLevel(level, ...modules);
|
1410
1414
|
return this;
|
1411
1415
|
}
|
1412
|
-
Module(
|
1413
|
-
this._li.Module(
|
1416
|
+
Module(key) {
|
1417
|
+
this._li.Module(key);
|
1414
1418
|
return this;
|
1415
1419
|
}
|
1416
1420
|
SetDebug(...modules) {
|
@@ -1425,36 +1429,36 @@ var WithLoggerBuilder = class {
|
|
1425
1429
|
this._li.Pair(x);
|
1426
1430
|
return this;
|
1427
1431
|
}
|
1428
|
-
Str(
|
1429
|
-
this._li.Str(
|
1432
|
+
Str(key, value) {
|
1433
|
+
this._li.Str(key, value);
|
1430
1434
|
return this;
|
1431
1435
|
}
|
1432
|
-
Len(value,
|
1433
|
-
this._li.Len(value,
|
1436
|
+
Len(value, key) {
|
1437
|
+
this._li.Len(value, key);
|
1434
1438
|
return this;
|
1435
1439
|
}
|
1436
|
-
Hash(value,
|
1437
|
-
this._li.Hash(value,
|
1440
|
+
Hash(value, key) {
|
1441
|
+
this._li.Hash(value, key);
|
1438
1442
|
return this;
|
1439
1443
|
}
|
1440
|
-
Ref(
|
1441
|
-
this._li.Ref(
|
1444
|
+
Ref(key, action) {
|
1445
|
+
this._li.Ref(key, action);
|
1442
1446
|
return this;
|
1443
1447
|
}
|
1444
|
-
Bool(
|
1445
|
-
this._li.Bool(
|
1448
|
+
Bool(key, value) {
|
1449
|
+
this._li.Bool(key, value);
|
1446
1450
|
return this;
|
1447
1451
|
}
|
1448
|
-
Result(
|
1449
|
-
this._li.Result(
|
1452
|
+
Result(key, res) {
|
1453
|
+
this._li.Result(key, res);
|
1450
1454
|
return this;
|
1451
1455
|
}
|
1452
|
-
Url(url,
|
1453
|
-
this._li.Url(url,
|
1456
|
+
Url(url, key) {
|
1457
|
+
this._li.Url(url, key);
|
1454
1458
|
return this;
|
1455
1459
|
}
|
1456
|
-
Int(
|
1457
|
-
this._li.Int(
|
1460
|
+
Int(key, value) {
|
1461
|
+
this._li.Int(key, value);
|
1458
1462
|
return this;
|
1459
1463
|
}
|
1460
1464
|
Log() {
|
@@ -1489,16 +1493,16 @@ var WithLoggerBuilder = class {
|
|
1489
1493
|
this._li.Timestamp();
|
1490
1494
|
return this;
|
1491
1495
|
}
|
1492
|
-
Any(
|
1493
|
-
this._li.Any(
|
1496
|
+
Any(key, value) {
|
1497
|
+
this._li.Any(key, value);
|
1494
1498
|
return this;
|
1495
1499
|
}
|
1496
|
-
Dur(
|
1497
|
-
this._li.Dur(
|
1500
|
+
Dur(key, nsec) {
|
1501
|
+
this._li.Dur(key, nsec);
|
1498
1502
|
return this;
|
1499
1503
|
}
|
1500
|
-
Uint64(
|
1501
|
-
this._li.Uint64(
|
1504
|
+
Uint64(key, value) {
|
1505
|
+
this._li.Uint64(key, value);
|
1502
1506
|
return this;
|
1503
1507
|
}
|
1504
1508
|
};
|
@@ -1534,7 +1538,6 @@ export {
|
|
1534
1538
|
asyncLogValue,
|
1535
1539
|
logValue,
|
1536
1540
|
IsLogger,
|
1537
|
-
key,
|
1538
1541
|
isURL,
|
1539
1542
|
MutableURL,
|
1540
1543
|
BuildURI,
|
@@ -1553,4 +1556,4 @@ export {
|
|
1553
1556
|
LogCollector,
|
1554
1557
|
MockLogger
|
1555
1558
|
};
|
1556
|
-
//# sourceMappingURL=chunk-
|
1559
|
+
//# sourceMappingURL=chunk-WGRZHIFK.js.map
|