@adviser/cement 0.3.13 → 0.3.15
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-ZUGYGT2Z.js → chunk-WGRZHIFK.js} +174 -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-EnKo_jNv.d.cts → index-Cp1NspHH.d.cts} +11 -10
- package/{index-CbOCsgzP.d.ts → index-D1j1fPYg.d.ts} +11 -10
- package/index-LQOsS7gM.d.cts +97 -0
- package/index.cjs +337 -317
- package/index.cjs.map +1 -1
- package/index.d.cts +9 -11
- package/index.d.ts +9 -11
- package/index.js +37 -40
- 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 +6 -5
- package/src/index.ts +3 -2
- package/src/jsr.json +1 -1
- package/src/logger.ts +8 -6
- package/src/sys-abstraction.ts +18 -15
- package/src/time.ts +7 -9
- package/src/types.ts +19 -0
- package/src/uri.ts +24 -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 +1 -2
- package/ts/src/index.d.ts.map +1 -1
- package/ts/src/index.js +1 -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/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 +1 -1
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +19 -2
- package/ts/src/uri.js.map +1 -1
- package/ts/src/uri.test.js +11 -1
- package/ts/src/uri.test.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-ZUGYGT2Z.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);
|
@@ -837,6 +841,24 @@ var BuildURI = class _BuildURI {
|
|
837
841
|
return URI.from(this._url);
|
838
842
|
}
|
839
843
|
};
|
844
|
+
function isCoerceURI(value) {
|
845
|
+
if (!value) {
|
846
|
+
return false;
|
847
|
+
}
|
848
|
+
if (isURL(value)) {
|
849
|
+
return true;
|
850
|
+
}
|
851
|
+
if (URI.is(value)) {
|
852
|
+
return true;
|
853
|
+
}
|
854
|
+
if (BuildURI.is(value)) {
|
855
|
+
return true;
|
856
|
+
}
|
857
|
+
if (typeof value === "string") {
|
858
|
+
return true;
|
859
|
+
}
|
860
|
+
return false;
|
861
|
+
}
|
840
862
|
var hasHostPartProtocols = /* @__PURE__ */ new Set(["http", "https", "ws", "wss"]);
|
841
863
|
var URI = class _URI {
|
842
864
|
static protocolHasHostpart(protocol) {
|
@@ -855,8 +877,8 @@ var URI = class _URI {
|
|
855
877
|
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
856
878
|
intoUrl.pathname(fromUrl.pathname);
|
857
879
|
}
|
858
|
-
for (const [
|
859
|
-
intoUrl.setParam(
|
880
|
+
for (const [key, value] of fromUrl.getParams) {
|
881
|
+
intoUrl.setParam(key, value);
|
860
882
|
}
|
861
883
|
return intoUrl.URI();
|
862
884
|
}
|
@@ -909,19 +931,19 @@ var URI = class _URI {
|
|
909
931
|
get getParams() {
|
910
932
|
return this._url.searchParams.entries();
|
911
933
|
}
|
912
|
-
hasParam(
|
913
|
-
return this._url.searchParams.has(
|
934
|
+
hasParam(key) {
|
935
|
+
return this._url.searchParams.has(key);
|
914
936
|
}
|
915
|
-
getParam(
|
916
|
-
const { key: k, def: d } = coerceKey(
|
937
|
+
getParam(key, def) {
|
938
|
+
const { key: k, def: d } = coerceKey(key, def);
|
917
939
|
let val = this._url.searchParams.get(k);
|
918
940
|
if (!falsy2undef(val) && d) {
|
919
941
|
val = d;
|
920
942
|
}
|
921
943
|
return falsy2undef(val);
|
922
944
|
}
|
923
|
-
getParamResult(
|
924
|
-
return getParamResult(
|
945
|
+
getParamResult(key, msgFn) {
|
946
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
925
947
|
}
|
926
948
|
getParamsResult(...keys) {
|
927
949
|
return getParamsResult(keys, this);
|
@@ -1126,9 +1148,9 @@ var LoggerImpl = class _LoggerImpl {
|
|
1126
1148
|
this.levelHandler.disableLevel(level, ...modules);
|
1127
1149
|
return this;
|
1128
1150
|
}
|
1129
|
-
Module(
|
1130
|
-
this._attributes["module"] = logValue(
|
1131
|
-
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));
|
1132
1154
|
return this;
|
1133
1155
|
}
|
1134
1156
|
// if the string is "*" it will enable for all modules
|
@@ -1149,30 +1171,30 @@ var LoggerImpl = class _LoggerImpl {
|
|
1149
1171
|
return this;
|
1150
1172
|
}
|
1151
1173
|
Warn() {
|
1152
|
-
this._attributes["level"] = logValue(
|
1174
|
+
this._attributes["level"] = logValue(Level.WARN, toLogValueCtx(this.levelHandler));
|
1153
1175
|
return this;
|
1154
1176
|
}
|
1155
1177
|
Log() {
|
1156
1178
|
return this;
|
1157
1179
|
}
|
1158
1180
|
Debug() {
|
1159
|
-
this._attributes["level"] = logValue(
|
1181
|
+
this._attributes["level"] = logValue(Level.DEBUG, toLogValueCtx(this.levelHandler));
|
1160
1182
|
return this;
|
1161
1183
|
}
|
1162
1184
|
Error() {
|
1163
|
-
this._attributes["level"] = logValue(
|
1185
|
+
this._attributes["level"] = logValue(Level.ERROR, toLogValueCtx(this.levelHandler));
|
1164
1186
|
return this;
|
1165
1187
|
}
|
1166
1188
|
Info() {
|
1167
|
-
this._attributes["level"] = logValue(
|
1189
|
+
this._attributes["level"] = logValue(Level.INFO, toLogValueCtx(this.levelHandler));
|
1168
1190
|
return this;
|
1169
1191
|
}
|
1170
1192
|
Err(err) {
|
1171
1193
|
var _a;
|
1172
|
-
let
|
1194
|
+
let key = "error";
|
1173
1195
|
if (Result.Is(err)) {
|
1174
1196
|
if (err.isOk()) {
|
1175
|
-
|
1197
|
+
key = "noerror";
|
1176
1198
|
err = err.Ok();
|
1177
1199
|
} else {
|
1178
1200
|
err = err.Err();
|
@@ -1180,12 +1202,12 @@ var LoggerImpl = class _LoggerImpl {
|
|
1180
1202
|
}
|
1181
1203
|
if (err instanceof Error) {
|
1182
1204
|
if (err.cause) {
|
1183
|
-
this.coerceKey(
|
1205
|
+
this.coerceKey(key, {
|
1184
1206
|
message: err.message,
|
1185
1207
|
cause: err.cause
|
1186
1208
|
});
|
1187
1209
|
} else {
|
1188
|
-
this._attributes[
|
1210
|
+
this._attributes[key] = logValue(err.message, toLogValueCtx(this.levelHandler));
|
1189
1211
|
}
|
1190
1212
|
if (this.levelHandler.isStackExposed) {
|
1191
1213
|
this._attributes["stack"] = logValue(
|
@@ -1194,7 +1216,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
1194
1216
|
);
|
1195
1217
|
}
|
1196
1218
|
} else {
|
1197
|
-
this.Any(
|
1219
|
+
this.Any(key, err);
|
1198
1220
|
}
|
1199
1221
|
return this;
|
1200
1222
|
}
|
@@ -1202,22 +1224,22 @@ var LoggerImpl = class _LoggerImpl {
|
|
1202
1224
|
this._attributes["level"] = logValue(l, toLogValueCtx(this.levelHandler));
|
1203
1225
|
return this;
|
1204
1226
|
}
|
1205
|
-
Ref(
|
1227
|
+
Ref(key, action) {
|
1206
1228
|
if (typeof action === "function") {
|
1207
|
-
this._attributes[
|
1229
|
+
this._attributes[key] = logValue(action, toLogValueCtx(this.levelHandler));
|
1208
1230
|
} else if (typeof action.toString === "function") {
|
1209
|
-
this._attributes[
|
1231
|
+
this._attributes[key] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));
|
1210
1232
|
} else {
|
1211
|
-
this._attributes[
|
1233
|
+
this._attributes[key] = logValue("INVALID REF", toLogValueCtx(this.levelHandler));
|
1212
1234
|
}
|
1213
1235
|
return this;
|
1214
1236
|
}
|
1215
|
-
Bool(
|
1216
|
-
this.coerceKey(
|
1237
|
+
Bool(key, value) {
|
1238
|
+
this.coerceKey(key, !!value);
|
1217
1239
|
return this;
|
1218
1240
|
}
|
1219
1241
|
Http(...mix) {
|
1220
|
-
const
|
1242
|
+
const key = mix.find((x) => typeof x === "string");
|
1221
1243
|
mix = mix.filter((x) => typeof x !== "string");
|
1222
1244
|
const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
|
1223
1245
|
if (resErrors.length) {
|
@@ -1237,70 +1259,70 @@ var LoggerImpl = class _LoggerImpl {
|
|
1237
1259
|
reqAndOrres = req;
|
1238
1260
|
}
|
1239
1261
|
if (reqAndOrres) {
|
1240
|
-
this.Any(
|
1262
|
+
this.Any(key || "Http", reqAndOrres);
|
1241
1263
|
}
|
1242
1264
|
return this;
|
1243
1265
|
}
|
1244
1266
|
Pair(x) {
|
1245
|
-
for (const
|
1246
|
-
const value = x[
|
1267
|
+
for (const key of Object.keys(x)) {
|
1268
|
+
const value = x[key];
|
1247
1269
|
if (value instanceof LogValue) {
|
1248
|
-
this._attributes[
|
1270
|
+
this._attributes[key] = value;
|
1249
1271
|
continue;
|
1250
1272
|
}
|
1251
1273
|
if (Result.Is(value)) {
|
1252
|
-
this.Result(
|
1274
|
+
this.Result(key, value);
|
1253
1275
|
continue;
|
1254
1276
|
}
|
1255
|
-
this.Any(
|
1277
|
+
this.Any(key, value);
|
1256
1278
|
}
|
1257
1279
|
return this;
|
1258
1280
|
}
|
1259
|
-
Result(
|
1281
|
+
Result(key, res) {
|
1260
1282
|
if (res.isOk()) {
|
1261
|
-
this._attributes[
|
1283
|
+
this._attributes[key] = logValue(res.Ok(), toLogValueCtx(this.levelHandler));
|
1262
1284
|
} else {
|
1263
1285
|
this.Err(res.Err());
|
1264
1286
|
}
|
1265
1287
|
return this;
|
1266
1288
|
}
|
1267
|
-
Len(value,
|
1268
|
-
this._attributes[
|
1289
|
+
Len(value, key = "len") {
|
1290
|
+
this._attributes[key] = getLen(value, toLogValueCtx(this.levelHandler));
|
1269
1291
|
return this;
|
1270
1292
|
}
|
1271
1293
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1272
|
-
Hash(value,
|
1294
|
+
Hash(value, key = "hash") {
|
1273
1295
|
throw new Error("Not implemented");
|
1274
1296
|
}
|
1275
|
-
Url(url,
|
1276
|
-
this.Ref(
|
1297
|
+
Url(url, key = "url") {
|
1298
|
+
this.Ref(key, () => URI.from(url).toString());
|
1277
1299
|
return this;
|
1278
1300
|
}
|
1279
|
-
coerceKey(
|
1280
|
-
if (typeof
|
1281
|
-
this._attributes[
|
1301
|
+
coerceKey(key, value) {
|
1302
|
+
if (typeof key === "string") {
|
1303
|
+
this._attributes[key] = logValue(value, toLogValueCtx(this.levelHandler));
|
1282
1304
|
} else {
|
1283
|
-
this.Pair(
|
1305
|
+
this.Pair(key);
|
1284
1306
|
}
|
1285
1307
|
}
|
1286
|
-
Str(
|
1287
|
-
this.coerceKey(
|
1308
|
+
Str(key, value) {
|
1309
|
+
this.coerceKey(key, value);
|
1288
1310
|
return this;
|
1289
1311
|
}
|
1290
|
-
Any(
|
1291
|
-
this.coerceKey(
|
1312
|
+
Any(key, value) {
|
1313
|
+
this.coerceKey(key, value);
|
1292
1314
|
return this;
|
1293
1315
|
}
|
1294
|
-
Dur(
|
1295
|
-
this._attributes[
|
1316
|
+
Dur(key, nsec) {
|
1317
|
+
this._attributes[key] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));
|
1296
1318
|
return this;
|
1297
1319
|
}
|
1298
|
-
Uint64(
|
1299
|
-
this.coerceKey(
|
1320
|
+
Uint64(key, value) {
|
1321
|
+
this.coerceKey(key, value);
|
1300
1322
|
return this;
|
1301
1323
|
}
|
1302
|
-
Int(
|
1303
|
-
return this.Uint64(
|
1324
|
+
Int(key, value) {
|
1325
|
+
return this.Uint64(key, value);
|
1304
1326
|
}
|
1305
1327
|
async Flush() {
|
1306
1328
|
return new Promise((resolve) => {
|
@@ -1323,8 +1345,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
1323
1345
|
}
|
1324
1346
|
_resetAttributes(fn) {
|
1325
1347
|
const ret = fn();
|
1326
|
-
Object.keys(this._attributes).forEach((
|
1327
|
-
delete this._attributes[
|
1348
|
+
Object.keys(this._attributes).forEach((key) => {
|
1349
|
+
delete this._attributes[key];
|
1328
1350
|
});
|
1329
1351
|
Object.assign(this._attributes, this._withAttributes);
|
1330
1352
|
return ret;
|
@@ -1391,8 +1413,8 @@ var WithLoggerBuilder = class {
|
|
1391
1413
|
this._li.levelHandler.enableLevel(level, ...modules);
|
1392
1414
|
return this;
|
1393
1415
|
}
|
1394
|
-
Module(
|
1395
|
-
this._li.Module(
|
1416
|
+
Module(key) {
|
1417
|
+
this._li.Module(key);
|
1396
1418
|
return this;
|
1397
1419
|
}
|
1398
1420
|
SetDebug(...modules) {
|
@@ -1407,36 +1429,36 @@ var WithLoggerBuilder = class {
|
|
1407
1429
|
this._li.Pair(x);
|
1408
1430
|
return this;
|
1409
1431
|
}
|
1410
|
-
Str(
|
1411
|
-
this._li.Str(
|
1432
|
+
Str(key, value) {
|
1433
|
+
this._li.Str(key, value);
|
1412
1434
|
return this;
|
1413
1435
|
}
|
1414
|
-
Len(value,
|
1415
|
-
this._li.Len(value,
|
1436
|
+
Len(value, key) {
|
1437
|
+
this._li.Len(value, key);
|
1416
1438
|
return this;
|
1417
1439
|
}
|
1418
|
-
Hash(value,
|
1419
|
-
this._li.Hash(value,
|
1440
|
+
Hash(value, key) {
|
1441
|
+
this._li.Hash(value, key);
|
1420
1442
|
return this;
|
1421
1443
|
}
|
1422
|
-
Ref(
|
1423
|
-
this._li.Ref(
|
1444
|
+
Ref(key, action) {
|
1445
|
+
this._li.Ref(key, action);
|
1424
1446
|
return this;
|
1425
1447
|
}
|
1426
|
-
Bool(
|
1427
|
-
this._li.Bool(
|
1448
|
+
Bool(key, value) {
|
1449
|
+
this._li.Bool(key, value);
|
1428
1450
|
return this;
|
1429
1451
|
}
|
1430
|
-
Result(
|
1431
|
-
this._li.Result(
|
1452
|
+
Result(key, res) {
|
1453
|
+
this._li.Result(key, res);
|
1432
1454
|
return this;
|
1433
1455
|
}
|
1434
|
-
Url(url,
|
1435
|
-
this._li.Url(url,
|
1456
|
+
Url(url, key) {
|
1457
|
+
this._li.Url(url, key);
|
1436
1458
|
return this;
|
1437
1459
|
}
|
1438
|
-
Int(
|
1439
|
-
this._li.Int(
|
1460
|
+
Int(key, value) {
|
1461
|
+
this._li.Int(key, value);
|
1440
1462
|
return this;
|
1441
1463
|
}
|
1442
1464
|
Log() {
|
@@ -1471,16 +1493,16 @@ var WithLoggerBuilder = class {
|
|
1471
1493
|
this._li.Timestamp();
|
1472
1494
|
return this;
|
1473
1495
|
}
|
1474
|
-
Any(
|
1475
|
-
this._li.Any(
|
1496
|
+
Any(key, value) {
|
1497
|
+
this._li.Any(key, value);
|
1476
1498
|
return this;
|
1477
1499
|
}
|
1478
|
-
Dur(
|
1479
|
-
this._li.Dur(
|
1500
|
+
Dur(key, nsec) {
|
1501
|
+
this._li.Dur(key, nsec);
|
1480
1502
|
return this;
|
1481
1503
|
}
|
1482
|
-
Uint64(
|
1483
|
-
this._li.Uint64(
|
1504
|
+
Uint64(key, value) {
|
1505
|
+
this._li.Uint64(key, value);
|
1484
1506
|
return this;
|
1485
1507
|
}
|
1486
1508
|
};
|
@@ -1516,10 +1538,10 @@ export {
|
|
1516
1538
|
asyncLogValue,
|
1517
1539
|
logValue,
|
1518
1540
|
IsLogger,
|
1519
|
-
key,
|
1520
1541
|
isURL,
|
1521
1542
|
MutableURL,
|
1522
1543
|
BuildURI,
|
1544
|
+
isCoerceURI,
|
1523
1545
|
hasHostPartProtocols,
|
1524
1546
|
URI,
|
1525
1547
|
Option,
|
@@ -1534,4 +1556,4 @@ export {
|
|
1534
1556
|
LogCollector,
|
1535
1557
|
MockLogger
|
1536
1558
|
};
|
1537
|
-
//# sourceMappingURL=chunk-
|
1559
|
+
//# sourceMappingURL=chunk-WGRZHIFK.js.map
|