@adviser/cement 0.1.20 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +128 -20
- package/index.cjs.map +1 -1
- package/index.d.cts +60 -34
- package/index.d.ts +60 -34
- package/index.js +127 -20
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
@@ -77,6 +77,7 @@ __export(src_exports, {
|
|
77
77
|
Future: () => Future,
|
78
78
|
IDMode: () => IDMode,
|
79
79
|
IsLogger: () => IsLogger,
|
80
|
+
KeyedResolvOnce: () => KeyedResolvOnce,
|
80
81
|
Level: () => Level,
|
81
82
|
LevelHandlerImpl: () => LevelHandlerImpl,
|
82
83
|
LogCollector: () => LogCollector,
|
@@ -424,6 +425,41 @@ function WebSysAbstraction(param) {
|
|
424
425
|
|
425
426
|
// src/logger_impl.ts
|
426
427
|
var encoder = new TextEncoder();
|
428
|
+
var LogValue = class {
|
429
|
+
constructor(fn) {
|
430
|
+
this.fn = fn;
|
431
|
+
}
|
432
|
+
value() {
|
433
|
+
return this.fn();
|
434
|
+
}
|
435
|
+
};
|
436
|
+
function resolveLogValue(val) {
|
437
|
+
const ret = {};
|
438
|
+
Object.keys(val).forEach((key) => {
|
439
|
+
const v = val[key];
|
440
|
+
if (v instanceof LogValue) {
|
441
|
+
ret[key] = v.value();
|
442
|
+
}
|
443
|
+
});
|
444
|
+
return ret;
|
445
|
+
}
|
446
|
+
function logValue(val) {
|
447
|
+
if (typeof val === "function") {
|
448
|
+
return new LogValue(val);
|
449
|
+
}
|
450
|
+
switch (typeof val) {
|
451
|
+
case "string":
|
452
|
+
return new LogValue(() => val.toString());
|
453
|
+
case "number":
|
454
|
+
return new LogValue(() => val);
|
455
|
+
case "boolean":
|
456
|
+
return new LogValue(() => val);
|
457
|
+
case "object":
|
458
|
+
return new LogValue(() => JSON.stringify(val));
|
459
|
+
default:
|
460
|
+
throw new Error(`Invalid type:${typeof val}`);
|
461
|
+
}
|
462
|
+
}
|
427
463
|
var LevelHandlerImpl = class {
|
428
464
|
constructor() {
|
429
465
|
this._globalLevels = /* @__PURE__ */ new Set(["info" /* INFO */, "error" /* ERROR */, "warn" /* WARN */]);
|
@@ -571,8 +607,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
571
607
|
return this;
|
572
608
|
}
|
573
609
|
Module(key) {
|
574
|
-
this._attributes["module"] = key;
|
575
|
-
this._withAttributes["module"] = key;
|
610
|
+
this._attributes["module"] = logValue(key);
|
611
|
+
this._withAttributes["module"] = logValue(key);
|
576
612
|
return this;
|
577
613
|
}
|
578
614
|
SetDebug(...modules) {
|
@@ -580,56 +616,85 @@ var LoggerImpl = class _LoggerImpl {
|
|
580
616
|
return this;
|
581
617
|
}
|
582
618
|
Timestamp() {
|
583
|
-
this._attributes["ts"] = this._sys.Time().Now().toISOString();
|
619
|
+
this._attributes["ts"] = logValue(this._sys.Time().Now().toISOString());
|
584
620
|
return this;
|
585
621
|
}
|
586
622
|
Warn() {
|
587
|
-
this._attributes["level"] = "warn" /* WARN
|
623
|
+
this._attributes["level"] = logValue("warn" /* WARN */);
|
588
624
|
return this;
|
589
625
|
}
|
590
626
|
Log() {
|
591
627
|
return this;
|
592
628
|
}
|
593
629
|
Debug() {
|
594
|
-
this._attributes["level"] = "debug" /* DEBUG
|
630
|
+
this._attributes["level"] = logValue("debug" /* DEBUG */);
|
595
631
|
return this;
|
596
632
|
}
|
597
633
|
Error() {
|
598
|
-
this._attributes["level"] = "error" /* ERROR
|
634
|
+
this._attributes["level"] = logValue("error" /* ERROR */);
|
599
635
|
return this;
|
600
636
|
}
|
601
637
|
Info() {
|
602
|
-
this._attributes["level"] = "info" /* INFO
|
638
|
+
this._attributes["level"] = logValue("info" /* INFO */);
|
603
639
|
return this;
|
604
640
|
}
|
605
641
|
Err(err) {
|
606
642
|
if (err instanceof Error) {
|
607
|
-
this._attributes["error"] = err.message;
|
643
|
+
this._attributes["error"] = logValue(err.message);
|
608
644
|
} else {
|
609
|
-
this._attributes["error"] = "" + err;
|
645
|
+
this._attributes["error"] = logValue("" + err);
|
610
646
|
}
|
611
647
|
return this;
|
612
648
|
}
|
613
649
|
WithLevel(l) {
|
614
|
-
this._attributes["level"] = l;
|
650
|
+
this._attributes["level"] = logValue(l);
|
651
|
+
return this;
|
652
|
+
}
|
653
|
+
Ref(key, action) {
|
654
|
+
if (typeof action === "function") {
|
655
|
+
this._attributes[key] = logValue(action);
|
656
|
+
} else if (typeof action.toString === "function") {
|
657
|
+
this._attributes[key] = logValue(() => action.toString());
|
658
|
+
} else {
|
659
|
+
this._attributes[key] = logValue("INVALID REF");
|
660
|
+
}
|
661
|
+
return this;
|
662
|
+
}
|
663
|
+
Bool(key, value) {
|
664
|
+
this._attributes[key] = logValue(!!value);
|
665
|
+
return this;
|
666
|
+
}
|
667
|
+
Result(key, res) {
|
668
|
+
if (res.isOk()) {
|
669
|
+
this._attributes[key] = logValue(res.Ok());
|
670
|
+
} else {
|
671
|
+
this.Err(res.Err());
|
672
|
+
}
|
673
|
+
return this;
|
674
|
+
}
|
675
|
+
Url(url, key = "url") {
|
676
|
+
this.Ref(key, () => url.toString());
|
615
677
|
return this;
|
616
678
|
}
|
617
679
|
Str(key, value) {
|
618
|
-
this._attributes[key] = value;
|
680
|
+
this._attributes[key] = logValue(value);
|
619
681
|
return this;
|
620
682
|
}
|
621
683
|
Any(key, value) {
|
622
|
-
this._attributes[key] = value;
|
684
|
+
this._attributes[key] = logValue(value);
|
623
685
|
return this;
|
624
686
|
}
|
625
687
|
Dur(key, nsec) {
|
626
|
-
this._attributes[key] = `${nsec}ms
|
688
|
+
this._attributes[key] = logValue(`${nsec}ms`);
|
627
689
|
return this;
|
628
690
|
}
|
629
691
|
Uint64(key, value) {
|
630
|
-
this._attributes[key] = value;
|
692
|
+
this._attributes[key] = logValue(value);
|
631
693
|
return this;
|
632
694
|
}
|
695
|
+
Int(key, value) {
|
696
|
+
return this.Uint64(key, value);
|
697
|
+
}
|
633
698
|
async Flush() {
|
634
699
|
return new Promise((resolve) => {
|
635
700
|
this._logWriter._flush(void 0, resolve);
|
@@ -657,15 +722,17 @@ var LoggerImpl = class _LoggerImpl {
|
|
657
722
|
}
|
658
723
|
Msg(...args) {
|
659
724
|
const error = this._resetAttributes(() => {
|
660
|
-
|
661
|
-
this._attributes["
|
662
|
-
|
725
|
+
var _a, _b, _c;
|
726
|
+
const doWrite = this._levelHandler.isEnabled((_a = this._attributes["level"]) == null ? void 0 : _a.value(), (_b = this._attributes["module"]) == null ? void 0 : _b.value());
|
727
|
+
this._attributes["msg"] = logValue(args.join(" "));
|
728
|
+
const msg = this._attributes["msg"].value();
|
729
|
+
if (typeof msg === "string" && !msg.trim().length) {
|
663
730
|
delete this._attributes["msg"];
|
664
731
|
}
|
665
|
-
if (this._attributes["ts"] === "ETERNITY") {
|
732
|
+
if (((_c = this._attributes["ts"]) == null ? void 0 : _c.value()) === "ETERNITY") {
|
666
733
|
this.Timestamp();
|
667
734
|
}
|
668
|
-
const str = JSON.stringify(this._attributes);
|
735
|
+
const str = JSON.stringify(resolveLogValue(this._attributes));
|
669
736
|
if (doWrite) {
|
670
737
|
const encoded = encoder.encode(str + "\n");
|
671
738
|
this._logWriter.write(encoded);
|
@@ -705,6 +772,26 @@ var WithLoggerBuilder = class {
|
|
705
772
|
this._li.Str(key, value);
|
706
773
|
return this;
|
707
774
|
}
|
775
|
+
Ref(key, action) {
|
776
|
+
this._li.Ref(key, action);
|
777
|
+
return this;
|
778
|
+
}
|
779
|
+
Bool(key, value) {
|
780
|
+
this._li.Bool(key, value);
|
781
|
+
return this;
|
782
|
+
}
|
783
|
+
Result(key, res) {
|
784
|
+
this._li.Result(key, res);
|
785
|
+
return this;
|
786
|
+
}
|
787
|
+
Url(url, key) {
|
788
|
+
this._li.Url(url, key);
|
789
|
+
return this;
|
790
|
+
}
|
791
|
+
Int(key, value) {
|
792
|
+
this._li.Int(key, value);
|
793
|
+
return this;
|
794
|
+
}
|
708
795
|
Log() {
|
709
796
|
this._li.Log();
|
710
797
|
return this;
|
@@ -734,7 +821,7 @@ var WithLoggerBuilder = class {
|
|
734
821
|
return this;
|
735
822
|
}
|
736
823
|
Timestamp() {
|
737
|
-
this._li._attributes["ts"] = "ETERNITY";
|
824
|
+
this._li._attributes["ts"] = logValue("ETERNITY");
|
738
825
|
return this;
|
739
826
|
}
|
740
827
|
Any(key, value) {
|
@@ -1030,11 +1117,32 @@ var ResolveOnce = class {
|
|
1030
1117
|
return future.asPromise();
|
1031
1118
|
}
|
1032
1119
|
};
|
1120
|
+
var KeyedResolvOnce = class {
|
1121
|
+
constructor() {
|
1122
|
+
this._map = /* @__PURE__ */ new Map();
|
1123
|
+
}
|
1124
|
+
get(key) {
|
1125
|
+
if (typeof key === "function") {
|
1126
|
+
key = key();
|
1127
|
+
}
|
1128
|
+
let resolveOnce = this._map.get(key);
|
1129
|
+
if (!resolveOnce) {
|
1130
|
+
resolveOnce = new ResolveOnce();
|
1131
|
+
this._map.set(key, resolveOnce);
|
1132
|
+
}
|
1133
|
+
return resolveOnce;
|
1134
|
+
}
|
1135
|
+
reset() {
|
1136
|
+
this._map.forEach((resolveOnce) => resolveOnce.reset());
|
1137
|
+
this._map.clear();
|
1138
|
+
}
|
1139
|
+
};
|
1033
1140
|
// Annotate the CommonJS export names for ESM import in node:
|
1034
1141
|
0 && (module.exports = {
|
1035
1142
|
Future,
|
1036
1143
|
IDMode,
|
1037
1144
|
IsLogger,
|
1145
|
+
KeyedResolvOnce,
|
1038
1146
|
Level,
|
1039
1147
|
LevelHandlerImpl,
|
1040
1148
|
LogCollector,
|
package/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/logger.ts","../../src/sys_abstraction.ts","../../src/time.ts","../../src/base_sys_abstraction.ts","../../src/web/web_sys_abstraction.ts","../../src/logger_impl.ts","../../src/test/log_collector.ts","../../src/test/mock_logger.ts","../../src/result.ts","../../src/option.ts","../../src/future.ts","../../src/resolve-once.ts"],"sourcesContent":["export * from \"./file_service\";\nexport * from \"./logger_impl\";\nexport * from \"./logger\";\nexport * from \"./sys_abstraction\";\nexport * from \"./time\";\nexport * from \"./test/log_collector\";\nexport * from \"./test/mock_logger\";\nexport * from \"./result\";\nexport * from \"./option\";\nexport * from \"./future\";\nexport * from \"./resolve-once\";\n","export enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport interface LoggerInterface<R> {\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n SetDebug(...modules: (string | string[])[]): R;\n\n Str(key: string, value: string): R;\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","import { FileService } from \"./file_service\";\nimport { Time } from \"./time\";\n\nexport enum TimeMode {\n REAL = \"real\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport enum RandomMode {\n CONST = \"const\",\n STEP = \"step\",\n RANDOM = \"random\",\n}\n\nexport enum IDMode {\n UUID = \"uuid\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport function String2TimeMode(s?: string): TimeMode {\n switch (s?.toLowerCase()) {\n case \"real\":\n return TimeMode.REAL;\n case \"const\":\n return TimeMode.CONST;\n case \"step\":\n return TimeMode.STEP;\n default:\n return TimeMode.REAL;\n }\n}\n\nexport type VoidFunc = () => void | Promise<void>;\n\nexport interface SystemService {\n Env(): Record<string, string>;\n Args(): string[];\n OnExit(hdl: VoidFunc): VoidFunc;\n Exit(code: number): void;\n}\n\nexport interface SysAbstraction {\n Time(): Time;\n Stdout(): WritableStream<Uint8Array>;\n Stderr(): WritableStream<Uint8Array>;\n NextId(): string;\n Random0ToValue(value: number): number;\n System(): SystemService;\n FileSystem(): FileService;\n}\n","export abstract class Time {\n abstract Now(): Date;\n abstract Sleep(duration: Duration): Promise<void>;\n TimeSince(start: Date): Duration {\n const now = this.Now();\n return now.getTime() - start.getTime();\n }\n}\n\nexport type Duration = number;\n\nexport enum TimeUnits {\n Microsecond = 1,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Second = 1000 * Microsecond,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Minute = 60 * Second,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Hour = 60 * Minute,\n}\n","import { FileService } from \"./file_service\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys_abstraction\";\nimport { Time } from \"./time\";\n\nexport class SysTime extends Time {\n Now(): Date {\n return new Date();\n }\n Sleep(duration: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, duration);\n });\n }\n}\n\nexport class ConstTime extends Time {\n Now(): Date {\n return new Date(2021, 1, 1, 0, 0, 0, 0);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Sleep(duration: number): Promise<void> {\n return Promise.resolve();\n }\n}\n\nexport class StepTime extends Time {\n _step: Date;\n constructor() {\n super();\n this._step = new ConstTime().Now();\n }\n Now() {\n if (this._step.getTime() === 0) {\n this._step = new ConstTime().Now();\n return this._step;\n }\n this._step = new Date(this._step.getTime() + 1000);\n return this._step;\n }\n Sleep(duration: number): Promise<void> {\n this._step = new Date(this._step.getTime() + duration);\n return Promise.resolve();\n }\n}\n\nexport function TimeFactory(timeMode: TimeMode): Time {\n switch (timeMode) {\n case TimeMode.REAL:\n return new SysTime();\n case TimeMode.CONST:\n return new ConstTime();\n case TimeMode.STEP:\n return new StepTime();\n }\n return new SysTime();\n}\n\nexport class RandomService {\n readonly _mode: RandomMode;\n _step = 0;\n constructor(mode: RandomMode) {\n this._mode = mode;\n }\n Random0ToValue(value: number): number {\n switch (this._mode) {\n case RandomMode.CONST:\n return 0.5 * value;\n case RandomMode.STEP:\n this._step += 0.0001;\n return this._step * value;\n case RandomMode.RANDOM:\n return Math.random() * value;\n default:\n throw new Error(\"Unknown RandomMode\");\n }\n }\n}\n\nexport class IdService {\n readonly _mode: IDMode;\n _step = 0;\n constructor(mode?: IDMode) {\n if (!mode) {\n mode = IDMode.UUID;\n }\n this._mode = mode;\n }\n NextId(): string {\n switch (this._mode) {\n case IDMode.UUID:\n return crypto.randomUUID();\n case IDMode.CONST:\n return \"VeryUniqueID\";\n case IDMode.STEP:\n return `STEPId-${this._step++}`;\n default:\n throw new Error(\"Unknown IDMode\");\n }\n }\n}\n\nexport interface BaseSysAbstractionParams {\n readonly FileSystem: FileService;\n readonly SystemService: SystemService;\n}\n\nexport interface ExitHandler {\n readonly hdl: VoidFunc;\n readonly id: string;\n}\n\nexport interface ExitService {\n injectExitHandlers(hdls: ExitHandler[]): void;\n exit(code: number): void;\n}\n\nconst decoder = new TextDecoder();\nexport class BaseSysAbstraction {\n readonly _time = new SysTime();\n readonly _stdout = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n readonly _stderr = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\n\n readonly _idService = new IdService();\n readonly _randomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\n }\n}\n\nexport interface WrapperSysAbstractionParams {\n readonly TimeMode?: TimeMode;\n readonly IdMode?: IDMode;\n readonly Stdout?: WritableStream<Uint8Array>;\n readonly Stderr?: WritableStream<Uint8Array>;\n readonly RandomMode?: RandomMode;\n readonly FileSystem?: FileService;\n readonly SystemService?: SystemService;\n}\n\nexport class WrapperSysAbstraction implements SysAbstraction {\n readonly _time: Time;\n readonly _stdout: WritableStream<Uint8Array>;\n readonly _stderr: WritableStream<Uint8Array>;\n readonly _idService: IdService;\n readonly _randomService: RandomService;\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams) {\n this._time = base._time;\n this._stdout = base._stdout;\n this._stderr = base._stderr;\n this._idService = base._idService;\n this._randomService = base._randomService;\n this._fileSystem = base._fileSystem;\n this._systemService = base._systemService;\n if (params) {\n if (params.TimeMode) {\n this._time = TimeFactory(params.TimeMode);\n }\n if (params.Stdout) {\n this._stdout = params.Stdout;\n }\n if (params.Stderr) {\n this._stderr = params.Stderr;\n }\n if (params.IdMode) {\n this._idService = new IdService(params.IdMode);\n }\n if (params.RandomMode) {\n this._randomService = new RandomService(params.RandomMode);\n }\n if (params.FileSystem) {\n this._fileSystem = params.FileSystem;\n }\n if (params.SystemService) {\n this._systemService = params.SystemService;\n }\n }\n }\n Time(): Time {\n return this._time;\n }\n NextId(): string {\n return this._idService.NextId();\n }\n Random0ToValue(value: number): number {\n return this._randomService.Random0ToValue(value);\n }\n Stdout(): WritableStream {\n return this._stdout;\n }\n Stderr(): WritableStream {\n return this._stderr;\n }\n\n System(): SystemService {\n return this._systemService;\n }\n FileSystem(): FileService {\n return this._fileSystem;\n }\n}\n// export const BaseSysAbstraction = new BaseSysAbstractionImpl()\n","import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from \"../base_sys_abstraction\";\nimport { FileService, NamedWritableStream } from \"../file_service\";\nimport { SysAbstraction, SystemService, VoidFunc } from \"../sys_abstraction\";\n\nclass WebFileService implements FileService {\n get baseDir(): string {\n throw new Error(\"basedir-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n create(fname: string): Promise<NamedWritableStream> {\n throw new Error(\"create-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n readFileString(fname: string): Promise<string> {\n throw new Error(\"readFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n writeFileString(fname: string, content: string): Promise<void> {\n throw new Error(\"writeFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abs(fname: string): string {\n throw new Error(\"abs-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n join(...paths: string[]): string {\n throw new Error(\"join-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n relative(from: string, to?: string | undefined): string {\n throw new Error(\"relative-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dirname(fname: string): string {\n throw new Error(\"dirname-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n basename(fname: string): string {\n throw new Error(\"basename-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n nodeImport(fname: string): string {\n throw new Error(\"nodeImport-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isAbsolute(fname: string): boolean {\n throw new Error(\"isAbsolute-Method not implemented.\");\n }\n}\n\nclass WebSystemService implements SystemService {\n Env(): Record<string, string> {\n throw new Error(\"Env-Method not implemented.\");\n }\n Args(): string[] {\n throw new Error(\"Args-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n OnExit(hdl: VoidFunc): VoidFunc {\n throw new Error(\"OnExit-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Exit(code: number): void {\n throw new Error(\"Exit-Method not implemented.\");\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new WebFileService(),\n SystemService: new WebSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","// import { v4 } from \"uuid\";\nimport { AsError, Level, Logger, WithLogger } from \"./logger\";\nimport { WebSysAbstraction } from \"./web/web_sys_abstraction\";\nimport { SysAbstraction } from \"./sys_abstraction\";\n\nconst encoder = new TextEncoder();\n\ntype JsonRecord = Record<string, string | number | boolean | unknown>;\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules = new Map<string, Set<Level>>();\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (module !== undefined) {\n const levels = this._modules.get(module as string);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n if (level === undefined) {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\n// globalThis[Symbol(\"levelSingleton\")] = new LevelHandlerImpl()\n\nexport class LogWriter {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array) {\n const my = async () => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns = Array<() => void>();\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriter;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: JsonRecord;\n readonly levelHandler?: LevelHandler;\n}\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: JsonRecord = {};\n readonly _withAttributes: JsonRecord;\n readonly _logWriter: LogWriter;\n readonly _levelHandler: LevelHandler;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n this._logWriter = new LogWriter(this._sys.Stdout());\n } else {\n this._logWriter = new LogWriter(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = levelSingleton;\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = key;\n this._withAttributes[\"module\"] = key;\n return this;\n }\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = this._sys.Time().Now().toISOString();\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = Level.WARN;\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = Level.DEBUG;\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = Level.ERROR;\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = Level.INFO;\n return this;\n }\n Err(err: unknown): Logger {\n if (err instanceof Error) {\n this._attributes[\"error\"] = err.message;\n } else {\n this._attributes[\"error\"] = \"\" + err;\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = l;\n return this;\n }\n\n Str(key: string, value: string): Logger {\n this._attributes[key] = value;\n return this;\n }\n\n Any(key: string, value: string | number | boolean | JsonRecord): Logger {\n this._attributes[key] = value;\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = `${nsec}ms`;\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = value;\n return this;\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => Error): Error {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n Msg(...args: string[]): AsError {\n const error = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(this._attributes[\"level\"], this._attributes[\"module\"]);\n this._attributes[\"msg\"] = args.join(\" \");\n if (typeof this._attributes[\"msg\"] === \"string\" && !this._attributes[\"msg\"].trim().length) {\n delete this._attributes[\"msg\"];\n }\n if (this._attributes[\"ts\"] === \"ETERNITY\") {\n this.Timestamp();\n }\n const str = JSON.stringify(this._attributes);\n if (doWrite) {\n const encoded = encoder.encode(str + \"\\n\");\n this._logWriter.write(encoded);\n }\n return new Error(str);\n });\n return {\n AsError: () => error,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Str(key: string, value: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li._attributes[\"ts\"] = \"ETERNITY\";\n return this;\n }\n Any(key: string, value: JsonRecord): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","class LogWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _bufferArr: Uint8Array[] = [];\n\n _resolveClosed: (value?: PromiseLike<undefined>) => void;\n closed: Promise<undefined>;\n desiredSize: number | null = null;\n ready: Promise<undefined> = Promise.resolve(undefined);\n\n constructor() {\n this._resolveClosed = () => {\n // do nothing\n };\n this.closed = new Promise((resolve) => {\n this._resolveClosed = resolve;\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n close(): Promise<void> {\n this._resolveClosed();\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n write(chunk?: Uint8Array): Promise<void> {\n chunk && this._bufferArr.push(chunk);\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n _writer?: LogWriter;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n this._writer = new LogWriter();\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = new TextDecoder().decode(\n new Uint8Array(\n (function* (res: Uint8Array[]) {\n for (const x of res) {\n yield* x;\n }\n })(this._writer._bufferArr),\n ),\n );\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n}\n","import { Logger } from \"../logger\";\nimport { LevelHandlerImpl, LoggerImpl } from \"../logger_impl\";\nimport { SysAbstraction } from \"../sys_abstraction\";\nimport { LogCollector } from \"./log_collector\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector();\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n !params?.disableDebug && logger.SetDebug(...modNames);\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T extends Error = Error>(t: T | string): Result<never, T> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as T);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n return t instanceof Result;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T) {\n this.#resolveFn(value);\n }\n reject(reason: unknown) {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future\";\n\nexport class ResolveOnce<T> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n\n get ready() {\n return this._onceDone;\n }\n\n reset() {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n async once(fn: () => Promise<T>): Promise<T> {\n if (this._onceDone) {\n if (this._onceError) {\n return Promise.reject(this._onceError);\n }\n if (this._onceOk) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!);\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n fn()\n .then((value) => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n this._onceFutures.length = 0;\n })\n .catch((e) => {\n this._onceError = e as Error;\n this._onceDone = true;\n this._onceFutures.forEach((f) => f.reject(this._onceError));\n this._onceFutures.length = 0;\n });\n }\n return future.asPromise();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAS,eAA4B,CAAC;AACtC,mBAAU;AAAA;AAAA,EAIV,IAAI,QAAQ;AACV,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAQ;AACN,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,aAAa;AAClB,SAAK,aAAa,SAAS;AAAA,EAC7B;AAAA,EAEA,MAAM,KAAK,IAAkC;AAC3C,QAAI,KAAK,WAAW;AAClB,UAAI,KAAK,YAAY;AACnB,eAAO,QAAQ,OAAO,KAAK,UAAU;AAAA,MACvC;AACA,UAAI,KAAK,SAAS;AAEhB,eAAO,QAAQ,QAAQ,KAAK,UAAW;AAAA,MACzC;AACA,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC/C;AACA,UAAM,SAAS,IAAI,OAAU;AAC7B,SAAK,aAAa,KAAK,MAAM;AAC7B,QAAI,KAAK,aAAa,WAAW,GAAG;AAClC,SAAG,EACA,KAAK,CAAC,UAAU;AACf,aAAK,aAAa;AAClB,aAAK,UAAU;AACf,aAAK,YAAY;AAEjB,aAAK,aAAa,QAAQ,CAAC,MAAM,EAAE,QAAQ,KAAK,UAAW,CAAC;AAC5D,aAAK,aAAa,SAAS;AAAA,MAC7B,CAAC,EACA,MAAM,CAAC,MAAM;AACZ,aAAK,aAAa;AAClB,aAAK,YAAY;AACjB,aAAK,aAAa,QAAQ,CAAC,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;AAC1D,aAAK,aAAa,SAAS;AAAA,MAC7B,CAAC;AAAA,IACL;AACA,WAAO,OAAO,UAAU;AAAA,EAC1B;AACF;","names":["Level","TimeMode","RandomMode","IDMode","TimeUnits","module","my","LogWriter"]}
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/logger.ts","../../src/sys_abstraction.ts","../../src/time.ts","../../src/base_sys_abstraction.ts","../../src/web/web_sys_abstraction.ts","../../src/logger_impl.ts","../../src/test/log_collector.ts","../../src/test/mock_logger.ts","../../src/result.ts","../../src/option.ts","../../src/future.ts","../../src/resolve-once.ts"],"sourcesContent":["export * from \"./file_service\";\nexport * from \"./logger_impl\";\nexport * from \"./logger\";\nexport * from \"./sys_abstraction\";\nexport * from \"./time\";\nexport * from \"./test/log_collector\";\nexport * from \"./test/mock_logger\";\nexport * from \"./result\";\nexport * from \"./option\";\nexport * from \"./future\";\nexport * from \"./resolve-once\";\n","import { Result } from \"./result\";\n\nexport enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport type Serialized = string | number | boolean;\nexport type FnSerialized = () => Serialized;\nexport interface LoggerInterface<R> {\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n SetDebug(...modules: (string | string[])[]): R;\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): R;\n Result<T>(key: string, res: Result<T>): R;\n // default key url\n Url(url: URL, key?: string): R;\n\n Str(key: string, value?: string): R;\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n Int(key: string, value: number): R;\n Bool(key: string, value: unknown): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","import { FileService } from \"./file_service\";\nimport { Time } from \"./time\";\n\nexport enum TimeMode {\n REAL = \"real\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport enum RandomMode {\n CONST = \"const\",\n STEP = \"step\",\n RANDOM = \"random\",\n}\n\nexport enum IDMode {\n UUID = \"uuid\",\n CONST = \"const\",\n STEP = \"step\",\n}\n\nexport function String2TimeMode(s?: string): TimeMode {\n switch (s?.toLowerCase()) {\n case \"real\":\n return TimeMode.REAL;\n case \"const\":\n return TimeMode.CONST;\n case \"step\":\n return TimeMode.STEP;\n default:\n return TimeMode.REAL;\n }\n}\n\nexport type VoidFunc = () => void | Promise<void>;\n\nexport interface SystemService {\n Env(): Record<string, string>;\n Args(): string[];\n OnExit(hdl: VoidFunc): VoidFunc;\n Exit(code: number): void;\n}\n\nexport interface SysAbstraction {\n Time(): Time;\n Stdout(): WritableStream<Uint8Array>;\n Stderr(): WritableStream<Uint8Array>;\n NextId(): string;\n Random0ToValue(value: number): number;\n System(): SystemService;\n FileSystem(): FileService;\n}\n","export abstract class Time {\n abstract Now(): Date;\n abstract Sleep(duration: Duration): Promise<void>;\n TimeSince(start: Date): Duration {\n const now = this.Now();\n return now.getTime() - start.getTime();\n }\n}\n\nexport type Duration = number;\n\nexport enum TimeUnits {\n Microsecond = 1,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Second = 1000 * Microsecond,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Minute = 60 * Second,\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Hour = 60 * Minute,\n}\n","import { FileService } from \"./file_service\";\nimport { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from \"./sys_abstraction\";\nimport { Time } from \"./time\";\n\nexport class SysTime extends Time {\n Now(): Date {\n return new Date();\n }\n Sleep(duration: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, duration);\n });\n }\n}\n\nexport class ConstTime extends Time {\n Now(): Date {\n return new Date(2021, 1, 1, 0, 0, 0, 0);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Sleep(duration: number): Promise<void> {\n return Promise.resolve();\n }\n}\n\nexport class StepTime extends Time {\n _step: Date;\n constructor() {\n super();\n this._step = new ConstTime().Now();\n }\n Now() {\n if (this._step.getTime() === 0) {\n this._step = new ConstTime().Now();\n return this._step;\n }\n this._step = new Date(this._step.getTime() + 1000);\n return this._step;\n }\n Sleep(duration: number): Promise<void> {\n this._step = new Date(this._step.getTime() + duration);\n return Promise.resolve();\n }\n}\n\nexport function TimeFactory(timeMode: TimeMode): Time {\n switch (timeMode) {\n case TimeMode.REAL:\n return new SysTime();\n case TimeMode.CONST:\n return new ConstTime();\n case TimeMode.STEP:\n return new StepTime();\n }\n return new SysTime();\n}\n\nexport class RandomService {\n readonly _mode: RandomMode;\n _step = 0;\n constructor(mode: RandomMode) {\n this._mode = mode;\n }\n Random0ToValue(value: number): number {\n switch (this._mode) {\n case RandomMode.CONST:\n return 0.5 * value;\n case RandomMode.STEP:\n this._step += 0.0001;\n return this._step * value;\n case RandomMode.RANDOM:\n return Math.random() * value;\n default:\n throw new Error(\"Unknown RandomMode\");\n }\n }\n}\n\nexport class IdService {\n readonly _mode: IDMode;\n _step = 0;\n constructor(mode?: IDMode) {\n if (!mode) {\n mode = IDMode.UUID;\n }\n this._mode = mode;\n }\n NextId(): string {\n switch (this._mode) {\n case IDMode.UUID:\n return crypto.randomUUID();\n case IDMode.CONST:\n return \"VeryUniqueID\";\n case IDMode.STEP:\n return `STEPId-${this._step++}`;\n default:\n throw new Error(\"Unknown IDMode\");\n }\n }\n}\n\nexport interface BaseSysAbstractionParams {\n readonly FileSystem: FileService;\n readonly SystemService: SystemService;\n}\n\nexport interface ExitHandler {\n readonly hdl: VoidFunc;\n readonly id: string;\n}\n\nexport interface ExitService {\n injectExitHandlers(hdls: ExitHandler[]): void;\n exit(code: number): void;\n}\n\nconst decoder = new TextDecoder();\nexport class BaseSysAbstraction {\n readonly _time = new SysTime();\n readonly _stdout = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n console.log(decoded.trimEnd());\n resolve();\n });\n },\n });\n readonly _stderr = new WritableStream({\n write(chunk) {\n return new Promise((resolve) => {\n const decoded = decoder.decode(chunk);\n console.error(decoded.trimEnd());\n resolve();\n });\n },\n });\n\n readonly _idService = new IdService();\n readonly _randomService = new RandomService(RandomMode.RANDOM);\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n\n constructor(params: BaseSysAbstractionParams) {\n this._fileSystem = params.FileSystem;\n this._systemService = params.SystemService;\n }\n}\n\nexport interface WrapperSysAbstractionParams {\n readonly TimeMode?: TimeMode;\n readonly IdMode?: IDMode;\n readonly Stdout?: WritableStream<Uint8Array>;\n readonly Stderr?: WritableStream<Uint8Array>;\n readonly RandomMode?: RandomMode;\n readonly FileSystem?: FileService;\n readonly SystemService?: SystemService;\n}\n\nexport class WrapperSysAbstraction implements SysAbstraction {\n readonly _time: Time;\n readonly _stdout: WritableStream<Uint8Array>;\n readonly _stderr: WritableStream<Uint8Array>;\n readonly _idService: IdService;\n readonly _randomService: RandomService;\n readonly _fileSystem: FileService;\n readonly _systemService: SystemService;\n constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams) {\n this._time = base._time;\n this._stdout = base._stdout;\n this._stderr = base._stderr;\n this._idService = base._idService;\n this._randomService = base._randomService;\n this._fileSystem = base._fileSystem;\n this._systemService = base._systemService;\n if (params) {\n if (params.TimeMode) {\n this._time = TimeFactory(params.TimeMode);\n }\n if (params.Stdout) {\n this._stdout = params.Stdout;\n }\n if (params.Stderr) {\n this._stderr = params.Stderr;\n }\n if (params.IdMode) {\n this._idService = new IdService(params.IdMode);\n }\n if (params.RandomMode) {\n this._randomService = new RandomService(params.RandomMode);\n }\n if (params.FileSystem) {\n this._fileSystem = params.FileSystem;\n }\n if (params.SystemService) {\n this._systemService = params.SystemService;\n }\n }\n }\n Time(): Time {\n return this._time;\n }\n NextId(): string {\n return this._idService.NextId();\n }\n Random0ToValue(value: number): number {\n return this._randomService.Random0ToValue(value);\n }\n Stdout(): WritableStream {\n return this._stdout;\n }\n Stderr(): WritableStream {\n return this._stderr;\n }\n\n System(): SystemService {\n return this._systemService;\n }\n FileSystem(): FileService {\n return this._fileSystem;\n }\n}\n// export const BaseSysAbstraction = new BaseSysAbstractionImpl()\n","import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from \"../base_sys_abstraction\";\nimport { FileService, NamedWritableStream } from \"../file_service\";\nimport { SysAbstraction, SystemService, VoidFunc } from \"../sys_abstraction\";\n\nclass WebFileService implements FileService {\n get baseDir(): string {\n throw new Error(\"basedir-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n create(fname: string): Promise<NamedWritableStream> {\n throw new Error(\"create-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n readFileString(fname: string): Promise<string> {\n throw new Error(\"readFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n writeFileString(fname: string, content: string): Promise<void> {\n throw new Error(\"writeFileString-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abs(fname: string): string {\n throw new Error(\"abs-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n join(...paths: string[]): string {\n throw new Error(\"join-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n relative(from: string, to?: string | undefined): string {\n throw new Error(\"relative-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n dirname(fname: string): string {\n throw new Error(\"dirname-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n basename(fname: string): string {\n throw new Error(\"basename-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n nodeImport(fname: string): string {\n throw new Error(\"nodeImport-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isAbsolute(fname: string): boolean {\n throw new Error(\"isAbsolute-Method not implemented.\");\n }\n}\n\nclass WebSystemService implements SystemService {\n Env(): Record<string, string> {\n throw new Error(\"Env-Method not implemented.\");\n }\n Args(): string[] {\n throw new Error(\"Args-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n OnExit(hdl: VoidFunc): VoidFunc {\n throw new Error(\"OnExit-Method not implemented.\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Exit(code: number): void {\n throw new Error(\"Exit-Method not implemented.\");\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new WebFileService(),\n SystemService: new WebSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","// import { v4 } from \"uuid\";\nimport { AsError, FnSerialized, Level, Logger, Serialized, WithLogger } from \"./logger\";\nimport { WebSysAbstraction } from \"./web/web_sys_abstraction\";\nimport { SysAbstraction } from \"./sys_abstraction\";\nimport { Result } from \"./result\";\n\nconst encoder = new TextEncoder();\n\nclass LogValue {\n constructor(readonly fn: FnSerialized) {}\n value(): Serialized {\n return this.fn();\n }\n}\n\nfunction resolveLogValue(val: JsonRecord): Record<string, Serialized> {\n const ret: Record<string, Serialized> = {};\n Object.keys(val).forEach((key) => {\n const v = val[key];\n if (v instanceof LogValue) {\n ret[key] = v.value();\n }\n });\n return ret;\n}\n\nfunction logValue(val: Serialized | FnSerialized | JsonRecord): LogValue {\n if (typeof val === \"function\") {\n return new LogValue(val);\n }\n switch (typeof val) {\n case \"string\":\n return new LogValue(() => val.toString());\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\":\n return new LogValue(() => JSON.stringify(val));\n default:\n throw new Error(`Invalid type:${typeof val}`);\n }\n}\n\ntype JsonRecord = Record<string, LogValue>;\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules = new Map<string, Set<Level>>();\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (module !== undefined) {\n const levels = this._modules.get(module as string);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n if (level === undefined) {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\n// globalThis[Symbol(\"levelSingleton\")] = new LevelHandlerImpl()\n\nexport class LogWriter {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array) {\n const my = async () => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns = Array<() => void>();\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriter;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: JsonRecord;\n readonly levelHandler?: LevelHandler;\n}\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: JsonRecord = {};\n readonly _withAttributes: JsonRecord;\n readonly _logWriter: LogWriter;\n readonly _levelHandler: LevelHandler;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n this._logWriter = new LogWriter(this._sys.Stdout());\n } else {\n this._logWriter = new LogWriter(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = levelSingleton;\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = logValue(key);\n this._withAttributes[\"module\"] = logValue(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = logValue(this._sys.Time().Now().toISOString());\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN);\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG);\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR);\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO);\n return this;\n }\n Err(err: unknown): Logger {\n if (err instanceof Error) {\n this._attributes[\"error\"] = logValue(err.message);\n } else {\n this._attributes[\"error\"] = logValue(\"\" + err);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l);\n return this;\n }\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): Logger {\n if (typeof action === \"function\") {\n this._attributes[key] = logValue(action as FnSerialized);\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString());\n } else {\n this._attributes[key] = logValue(\"INVALID REF\");\n }\n return this;\n }\n Bool(key: string, value: unknown): Logger {\n this._attributes[key] = logValue(!!value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized);\n } else {\n this.Err(res.Err());\n }\n return this;\n }\n\n Url(url: URL, key = \"url\"): Logger {\n this.Ref(key, () => url.toString());\n return this;\n }\n\n Str(key: string, value: string): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n\n Any(key: string, value: string | number | boolean | JsonRecord): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`);\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Int(key: string, value: number): Logger {\n return this.Uint64(key, value);\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => Error): Error {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n Msg(...args: string[]): AsError {\n const error = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(this._attributes[\"level\"]?.value(), this._attributes[\"module\"]?.value());\n this._attributes[\"msg\"] = logValue(args.join(\" \"));\n const msg = this._attributes[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete this._attributes[\"msg\"];\n }\n if (this._attributes[\"ts\"]?.value() === \"ETERNITY\") {\n this.Timestamp();\n }\n const str = JSON.stringify(resolveLogValue(this._attributes));\n if (doWrite) {\n const encoded = encoder.encode(str + \"\\n\");\n this._logWriter.write(encoded);\n }\n return new Error(str);\n });\n return {\n AsError: () => error,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Str(key: string, value: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Ref(key: string, action: Serialized | FnSerialized): WithLogger {\n this._li.Ref(key, action);\n return this;\n }\n Bool(key: string, value: unknown): WithLogger {\n this._li.Bool(key, value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): WithLogger {\n this._li.Result(key, res);\n return this;\n }\n Url(url: URL, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string, value: number): WithLogger {\n this._li.Int(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li._attributes[\"ts\"] = logValue(\"ETERNITY\");\n return this;\n }\n Any(key: string, value: JsonRecord): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","class LogWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _bufferArr: Uint8Array[] = [];\n\n _resolveClosed: (value?: PromiseLike<undefined>) => void;\n closed: Promise<undefined>;\n desiredSize: number | null = null;\n ready: Promise<undefined> = Promise.resolve(undefined);\n\n constructor() {\n this._resolveClosed = () => {\n // do nothing\n };\n this.closed = new Promise((resolve) => {\n this._resolveClosed = resolve;\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n close(): Promise<void> {\n this._resolveClosed();\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n write(chunk?: Uint8Array): Promise<void> {\n chunk && this._bufferArr.push(chunk);\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n _writer?: LogWriter;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n this._writer = new LogWriter();\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = new TextDecoder().decode(\n new Uint8Array(\n (function* (res: Uint8Array[]) {\n for (const x of res) {\n yield* x;\n }\n })(this._writer._bufferArr),\n ),\n );\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n}\n","import { Logger } from \"../logger\";\nimport { LevelHandlerImpl, LoggerImpl } from \"../logger_impl\";\nimport { SysAbstraction } from \"../sys_abstraction\";\nimport { LogCollector } from \"./log_collector\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector();\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n !params?.disableDebug && logger.SetDebug(...modNames);\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T extends Error = Error>(t: T | string): Result<never, T> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as T);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n return t instanceof Result;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T) {\n this.#resolveFn(value);\n }\n reject(reason: unknown) {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future\";\n\nexport class ResolveOnce<T> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n\n get ready() {\n return this._onceDone;\n }\n\n reset() {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n async once(fn: () => Promise<T>): Promise<T> {\n if (this._onceDone) {\n if (this._onceError) {\n return Promise.reject(this._onceError);\n }\n if (this._onceOk) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!);\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n fn()\n .then((value) => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n this._onceFutures.length = 0;\n })\n .catch((e) => {\n this._onceError = e as Error;\n this._onceDone = true;\n this._onceFutures.forEach((f) => f.reject(this._onceError));\n this._onceFutures.length = 0;\n });\n }\n return future.asPromise();\n }\n}\n\nexport class KeyedResolvOnce<T> {\n private readonly _map = new Map<string, ResolveOnce<T>>();\n\n get(key: string | (() => string)): ResolveOnce<T> {\n if (typeof key === \"function\") {\n key = key();\n }\n let resolveOnce = this._map.get(key);\n if (!resolveOnce) {\n resolveOnce = new ResolveOnce<T>();\n this._map.set(key, resolveOnce);\n }\n return resolveOnce;\n }\n\n reset() {\n this._map.forEach((resolveOnce) => resolveOnce.reset());\n this._map.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AACR,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAuCL,SAAS,SAAS,KAA6B;AACpD,SACE,OAAO,QAAQ,YACf;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAEG,IAAI,CAAC,OAAO,OAAQ,IAAY,EAAE,MAAM,UAAU,EAClD,OAAO,CAAC,GAAG,MAAM,KAAK,GAAG,IAAI;AAEpC;;;AC/DO,IAAK,WAAL,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KAAK,UAAW,CAAC;AAC5D,aAAK,aAAa,SAAS;AAAA,MAC7B,CAAC,EACA,MAAM,CAAC,MAAM;AACZ,aAAK,aAAa;AAClB,aAAK,YAAY;AACjB,aAAK,aAAa,QAAQ,CAAC,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;AAC1D,aAAK,aAAa,SAAS;AAAA,MAC7B,CAAC;AAAA,IACL;AACA,WAAO,OAAO,UAAU;AAAA,EAC1B;AACF;AAEO,IAAM,kBAAN,MAAyB;AAAA,EAAzB;AACL,SAAiB,OAAO,oBAAI,IAA4B;AAAA;AAAA,EAExD,IAAI,KAA8C;AAChD,QAAI,OAAO,QAAQ,YAAY;AAC7B,YAAM,IAAI;AAAA,IACZ;AACA,QAAI,cAAc,KAAK,KAAK,IAAI,GAAG;AACnC,QAAI,CAAC,aAAa;AAChB,oBAAc,IAAI,YAAe;AACjC,WAAK,KAAK,IAAI,KAAK,WAAW;AAAA,IAChC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,SAAK,KAAK,QAAQ,CAAC,gBAAgB,YAAY,MAAM,CAAC;AACtD,SAAK,KAAK,MAAM;AAAA,EAClB;AACF;","names":["Level","TimeMode","RandomMode","IDMode","TimeUnits","module","my","LogWriter"]}
|
package/index.d.cts
CHANGED
@@ -1,18 +1,56 @@
|
|
1
1
|
import { S as SysAbstraction } from './sys_abstraction-CjljYIkv.cjs';
|
2
2
|
export { D as Duration, F as FileService, I as IDMode, N as NamedWritableStream, R as RandomMode, a as String2TimeMode, b as SystemService, c as Time, T as TimeMode, d as TimeUnits, V as VoidFunc } from './sys_abstraction-CjljYIkv.cjs';
|
3
3
|
|
4
|
+
declare abstract class Result<T, E = Error> {
|
5
|
+
static Ok<T>(t: T): Result<T, Error>;
|
6
|
+
static Err<T extends Error = Error>(t: T | string): Result<never, T>;
|
7
|
+
static Is<T>(t: unknown): t is Result<T>;
|
8
|
+
isOk(): boolean;
|
9
|
+
isErr(): boolean;
|
10
|
+
Ok(): T;
|
11
|
+
Err(): E;
|
12
|
+
abstract is_ok(): boolean;
|
13
|
+
abstract is_err(): boolean;
|
14
|
+
abstract unwrap(): T;
|
15
|
+
abstract unwrap_err(): E;
|
16
|
+
}
|
17
|
+
declare class ResultOK<T> extends Result<T, Error> {
|
18
|
+
private _t;
|
19
|
+
constructor(t: T);
|
20
|
+
is_ok(): boolean;
|
21
|
+
is_err(): boolean;
|
22
|
+
unwrap_err(): Error;
|
23
|
+
unwrap(): T;
|
24
|
+
}
|
25
|
+
declare class ResultError<T extends Error> extends Result<never, T> {
|
26
|
+
private _error;
|
27
|
+
constructor(t: T);
|
28
|
+
is_ok(): boolean;
|
29
|
+
is_err(): boolean;
|
30
|
+
unwrap(): never;
|
31
|
+
unwrap_err(): T;
|
32
|
+
}
|
33
|
+
type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
34
|
+
|
4
35
|
declare enum Level {
|
5
36
|
WARN = "warn",
|
6
37
|
DEBUG = "debug",
|
7
38
|
INFO = "info",
|
8
39
|
ERROR = "error"
|
9
40
|
}
|
41
|
+
type Serialized = string | number | boolean;
|
42
|
+
type FnSerialized = () => Serialized;
|
10
43
|
interface LoggerInterface<R> {
|
11
44
|
Module(key: string): R;
|
12
45
|
EnableLevel(level: Level, ...modules: string[]): R;
|
13
46
|
DisableLevel(level: Level, ...modules: string[]): R;
|
14
47
|
SetDebug(...modules: (string | string[])[]): R;
|
15
|
-
|
48
|
+
Ref(key: string, action: {
|
49
|
+
toString: () => string;
|
50
|
+
} | FnSerialized): R;
|
51
|
+
Result<T>(key: string, res: Result<T>): R;
|
52
|
+
Url(url: URL, key?: string): R;
|
53
|
+
Str(key: string, value?: string): R;
|
16
54
|
Error(): R;
|
17
55
|
Warn(): R;
|
18
56
|
Debug(): R;
|
@@ -24,6 +62,8 @@ interface LoggerInterface<R> {
|
|
24
62
|
Any(key: string, value: unknown): R;
|
25
63
|
Dur(key: string, nsec: number): R;
|
26
64
|
Uint64(key: string, value: number): R;
|
65
|
+
Int(key: string, value: number): R;
|
66
|
+
Bool(key: string, value: unknown): R;
|
27
67
|
}
|
28
68
|
declare function IsLogger(obj: unknown): obj is Logger;
|
29
69
|
interface WithLogger extends LoggerInterface<WithLogger> {
|
@@ -38,7 +78,12 @@ interface Logger extends LoggerInterface<Logger> {
|
|
38
78
|
Flush(): Promise<void>;
|
39
79
|
}
|
40
80
|
|
41
|
-
|
81
|
+
declare class LogValue {
|
82
|
+
readonly fn: FnSerialized;
|
83
|
+
constructor(fn: FnSerialized);
|
84
|
+
value(): Serialized;
|
85
|
+
}
|
86
|
+
type JsonRecord = Record<string, LogValue>;
|
42
87
|
interface LevelHandler {
|
43
88
|
enableLevel(level: Level, ...modules: string[]): void;
|
44
89
|
disableLevel(level: Level, ...modules: string[]): void;
|
@@ -89,10 +134,17 @@ declare class LoggerImpl implements Logger {
|
|
89
134
|
Info(): Logger;
|
90
135
|
Err(err: unknown): Logger;
|
91
136
|
WithLevel(l: Level): Logger;
|
137
|
+
Ref(key: string, action: {
|
138
|
+
toString: () => string;
|
139
|
+
} | FnSerialized): Logger;
|
140
|
+
Bool(key: string, value: unknown): Logger;
|
141
|
+
Result<T>(key: string, res: Result<T, Error>): Logger;
|
142
|
+
Url(url: URL, key?: string): Logger;
|
92
143
|
Str(key: string, value: string): Logger;
|
93
144
|
Any(key: string, value: string | number | boolean | JsonRecord): Logger;
|
94
145
|
Dur(key: string, nsec: number): Logger;
|
95
146
|
Uint64(key: string, value: number): Logger;
|
147
|
+
Int(key: string, value: number): Logger;
|
96
148
|
Flush(): Promise<void>;
|
97
149
|
With(): WithLogger;
|
98
150
|
_resetAttributes(fn: () => Error): Error;
|
@@ -130,37 +182,6 @@ declare function MockLogger(params?: {
|
|
130
182
|
readonly disableDebug?: boolean;
|
131
183
|
}): MockLoggerReturn;
|
132
184
|
|
133
|
-
declare abstract class Result<T, E = Error> {
|
134
|
-
static Ok<T>(t: T): Result<T, Error>;
|
135
|
-
static Err<T extends Error = Error>(t: T | string): Result<never, T>;
|
136
|
-
static Is<T>(t: unknown): t is Result<T>;
|
137
|
-
isOk(): boolean;
|
138
|
-
isErr(): boolean;
|
139
|
-
Ok(): T;
|
140
|
-
Err(): E;
|
141
|
-
abstract is_ok(): boolean;
|
142
|
-
abstract is_err(): boolean;
|
143
|
-
abstract unwrap(): T;
|
144
|
-
abstract unwrap_err(): E;
|
145
|
-
}
|
146
|
-
declare class ResultOK<T> extends Result<T, Error> {
|
147
|
-
private _t;
|
148
|
-
constructor(t: T);
|
149
|
-
is_ok(): boolean;
|
150
|
-
is_err(): boolean;
|
151
|
-
unwrap_err(): Error;
|
152
|
-
unwrap(): T;
|
153
|
-
}
|
154
|
-
declare class ResultError<T extends Error> extends Result<never, T> {
|
155
|
-
private _error;
|
156
|
-
constructor(t: T);
|
157
|
-
is_ok(): boolean;
|
158
|
-
is_err(): boolean;
|
159
|
-
unwrap(): never;
|
160
|
-
unwrap_err(): T;
|
161
|
-
}
|
162
|
-
type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
163
|
-
|
164
185
|
declare abstract class Option<T> {
|
165
186
|
static Some<T>(t: T): Option<T>;
|
166
187
|
static None<T>(): Option<T>;
|
@@ -204,5 +225,10 @@ declare class ResolveOnce<T> {
|
|
204
225
|
reset(): void;
|
205
226
|
once(fn: () => Promise<T>): Promise<T>;
|
206
227
|
}
|
228
|
+
declare class KeyedResolvOnce<T> {
|
229
|
+
private readonly _map;
|
230
|
+
get(key: string | (() => string)): ResolveOnce<T>;
|
231
|
+
reset(): void;
|
232
|
+
}
|
207
233
|
|
208
|
-
export { type AsError, Future, IsLogger, Level, type LevelHandler, LevelHandlerImpl, LogCollector, LogWriter$1 as LogWriter, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, MockLogger, type MockLoggerReturn, None, Option, ResolveOnce, Result, ResultError, ResultOK, Some, SysAbstraction, type WithLogger, type WithoutOption, type WithoutResult };
|
234
|
+
export { type AsError, type FnSerialized, Future, IsLogger, KeyedResolvOnce, Level, type LevelHandler, LevelHandlerImpl, LogCollector, LogWriter$1 as LogWriter, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, MockLogger, type MockLoggerReturn, None, Option, ResolveOnce, Result, ResultError, ResultOK, type Serialized, Some, SysAbstraction, type WithLogger, type WithoutOption, type WithoutResult };
|
package/index.d.ts
CHANGED
@@ -1,18 +1,56 @@
|
|
1
1
|
import { S as SysAbstraction } from './sys_abstraction-CjljYIkv.js';
|
2
2
|
export { D as Duration, F as FileService, I as IDMode, N as NamedWritableStream, R as RandomMode, a as String2TimeMode, b as SystemService, c as Time, T as TimeMode, d as TimeUnits, V as VoidFunc } from './sys_abstraction-CjljYIkv.js';
|
3
3
|
|
4
|
+
declare abstract class Result<T, E = Error> {
|
5
|
+
static Ok<T>(t: T): Result<T, Error>;
|
6
|
+
static Err<T extends Error = Error>(t: T | string): Result<never, T>;
|
7
|
+
static Is<T>(t: unknown): t is Result<T>;
|
8
|
+
isOk(): boolean;
|
9
|
+
isErr(): boolean;
|
10
|
+
Ok(): T;
|
11
|
+
Err(): E;
|
12
|
+
abstract is_ok(): boolean;
|
13
|
+
abstract is_err(): boolean;
|
14
|
+
abstract unwrap(): T;
|
15
|
+
abstract unwrap_err(): E;
|
16
|
+
}
|
17
|
+
declare class ResultOK<T> extends Result<T, Error> {
|
18
|
+
private _t;
|
19
|
+
constructor(t: T);
|
20
|
+
is_ok(): boolean;
|
21
|
+
is_err(): boolean;
|
22
|
+
unwrap_err(): Error;
|
23
|
+
unwrap(): T;
|
24
|
+
}
|
25
|
+
declare class ResultError<T extends Error> extends Result<never, T> {
|
26
|
+
private _error;
|
27
|
+
constructor(t: T);
|
28
|
+
is_ok(): boolean;
|
29
|
+
is_err(): boolean;
|
30
|
+
unwrap(): never;
|
31
|
+
unwrap_err(): T;
|
32
|
+
}
|
33
|
+
type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
34
|
+
|
4
35
|
declare enum Level {
|
5
36
|
WARN = "warn",
|
6
37
|
DEBUG = "debug",
|
7
38
|
INFO = "info",
|
8
39
|
ERROR = "error"
|
9
40
|
}
|
41
|
+
type Serialized = string | number | boolean;
|
42
|
+
type FnSerialized = () => Serialized;
|
10
43
|
interface LoggerInterface<R> {
|
11
44
|
Module(key: string): R;
|
12
45
|
EnableLevel(level: Level, ...modules: string[]): R;
|
13
46
|
DisableLevel(level: Level, ...modules: string[]): R;
|
14
47
|
SetDebug(...modules: (string | string[])[]): R;
|
15
|
-
|
48
|
+
Ref(key: string, action: {
|
49
|
+
toString: () => string;
|
50
|
+
} | FnSerialized): R;
|
51
|
+
Result<T>(key: string, res: Result<T>): R;
|
52
|
+
Url(url: URL, key?: string): R;
|
53
|
+
Str(key: string, value?: string): R;
|
16
54
|
Error(): R;
|
17
55
|
Warn(): R;
|
18
56
|
Debug(): R;
|
@@ -24,6 +62,8 @@ interface LoggerInterface<R> {
|
|
24
62
|
Any(key: string, value: unknown): R;
|
25
63
|
Dur(key: string, nsec: number): R;
|
26
64
|
Uint64(key: string, value: number): R;
|
65
|
+
Int(key: string, value: number): R;
|
66
|
+
Bool(key: string, value: unknown): R;
|
27
67
|
}
|
28
68
|
declare function IsLogger(obj: unknown): obj is Logger;
|
29
69
|
interface WithLogger extends LoggerInterface<WithLogger> {
|
@@ -38,7 +78,12 @@ interface Logger extends LoggerInterface<Logger> {
|
|
38
78
|
Flush(): Promise<void>;
|
39
79
|
}
|
40
80
|
|
41
|
-
|
81
|
+
declare class LogValue {
|
82
|
+
readonly fn: FnSerialized;
|
83
|
+
constructor(fn: FnSerialized);
|
84
|
+
value(): Serialized;
|
85
|
+
}
|
86
|
+
type JsonRecord = Record<string, LogValue>;
|
42
87
|
interface LevelHandler {
|
43
88
|
enableLevel(level: Level, ...modules: string[]): void;
|
44
89
|
disableLevel(level: Level, ...modules: string[]): void;
|
@@ -89,10 +134,17 @@ declare class LoggerImpl implements Logger {
|
|
89
134
|
Info(): Logger;
|
90
135
|
Err(err: unknown): Logger;
|
91
136
|
WithLevel(l: Level): Logger;
|
137
|
+
Ref(key: string, action: {
|
138
|
+
toString: () => string;
|
139
|
+
} | FnSerialized): Logger;
|
140
|
+
Bool(key: string, value: unknown): Logger;
|
141
|
+
Result<T>(key: string, res: Result<T, Error>): Logger;
|
142
|
+
Url(url: URL, key?: string): Logger;
|
92
143
|
Str(key: string, value: string): Logger;
|
93
144
|
Any(key: string, value: string | number | boolean | JsonRecord): Logger;
|
94
145
|
Dur(key: string, nsec: number): Logger;
|
95
146
|
Uint64(key: string, value: number): Logger;
|
147
|
+
Int(key: string, value: number): Logger;
|
96
148
|
Flush(): Promise<void>;
|
97
149
|
With(): WithLogger;
|
98
150
|
_resetAttributes(fn: () => Error): Error;
|
@@ -130,37 +182,6 @@ declare function MockLogger(params?: {
|
|
130
182
|
readonly disableDebug?: boolean;
|
131
183
|
}): MockLoggerReturn;
|
132
184
|
|
133
|
-
declare abstract class Result<T, E = Error> {
|
134
|
-
static Ok<T>(t: T): Result<T, Error>;
|
135
|
-
static Err<T extends Error = Error>(t: T | string): Result<never, T>;
|
136
|
-
static Is<T>(t: unknown): t is Result<T>;
|
137
|
-
isOk(): boolean;
|
138
|
-
isErr(): boolean;
|
139
|
-
Ok(): T;
|
140
|
-
Err(): E;
|
141
|
-
abstract is_ok(): boolean;
|
142
|
-
abstract is_err(): boolean;
|
143
|
-
abstract unwrap(): T;
|
144
|
-
abstract unwrap_err(): E;
|
145
|
-
}
|
146
|
-
declare class ResultOK<T> extends Result<T, Error> {
|
147
|
-
private _t;
|
148
|
-
constructor(t: T);
|
149
|
-
is_ok(): boolean;
|
150
|
-
is_err(): boolean;
|
151
|
-
unwrap_err(): Error;
|
152
|
-
unwrap(): T;
|
153
|
-
}
|
154
|
-
declare class ResultError<T extends Error> extends Result<never, T> {
|
155
|
-
private _error;
|
156
|
-
constructor(t: T);
|
157
|
-
is_ok(): boolean;
|
158
|
-
is_err(): boolean;
|
159
|
-
unwrap(): never;
|
160
|
-
unwrap_err(): T;
|
161
|
-
}
|
162
|
-
type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
163
|
-
|
164
185
|
declare abstract class Option<T> {
|
165
186
|
static Some<T>(t: T): Option<T>;
|
166
187
|
static None<T>(): Option<T>;
|
@@ -204,5 +225,10 @@ declare class ResolveOnce<T> {
|
|
204
225
|
reset(): void;
|
205
226
|
once(fn: () => Promise<T>): Promise<T>;
|
206
227
|
}
|
228
|
+
declare class KeyedResolvOnce<T> {
|
229
|
+
private readonly _map;
|
230
|
+
get(key: string | (() => string)): ResolveOnce<T>;
|
231
|
+
reset(): void;
|
232
|
+
}
|
207
233
|
|
208
|
-
export { type AsError, Future, IsLogger, Level, type LevelHandler, LevelHandlerImpl, LogCollector, LogWriter$1 as LogWriter, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, MockLogger, type MockLoggerReturn, None, Option, ResolveOnce, Result, ResultError, ResultOK, Some, SysAbstraction, type WithLogger, type WithoutOption, type WithoutResult };
|
234
|
+
export { type AsError, type FnSerialized, Future, IsLogger, KeyedResolvOnce, Level, type LevelHandler, LevelHandlerImpl, LogCollector, LogWriter$1 as LogWriter, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, MockLogger, type MockLoggerReturn, None, Option, ResolveOnce, Result, ResultError, ResultOK, type Serialized, Some, SysAbstraction, type WithLogger, type WithoutOption, type WithoutResult };
|
package/index.js
CHANGED
@@ -48,6 +48,41 @@ function IsLogger(obj) {
|
|
48
48
|
|
49
49
|
// src/logger_impl.ts
|
50
50
|
var encoder = new TextEncoder();
|
51
|
+
var LogValue = class {
|
52
|
+
constructor(fn) {
|
53
|
+
this.fn = fn;
|
54
|
+
}
|
55
|
+
value() {
|
56
|
+
return this.fn();
|
57
|
+
}
|
58
|
+
};
|
59
|
+
function resolveLogValue(val) {
|
60
|
+
const ret = {};
|
61
|
+
Object.keys(val).forEach((key) => {
|
62
|
+
const v = val[key];
|
63
|
+
if (v instanceof LogValue) {
|
64
|
+
ret[key] = v.value();
|
65
|
+
}
|
66
|
+
});
|
67
|
+
return ret;
|
68
|
+
}
|
69
|
+
function logValue(val) {
|
70
|
+
if (typeof val === "function") {
|
71
|
+
return new LogValue(val);
|
72
|
+
}
|
73
|
+
switch (typeof val) {
|
74
|
+
case "string":
|
75
|
+
return new LogValue(() => val.toString());
|
76
|
+
case "number":
|
77
|
+
return new LogValue(() => val);
|
78
|
+
case "boolean":
|
79
|
+
return new LogValue(() => val);
|
80
|
+
case "object":
|
81
|
+
return new LogValue(() => JSON.stringify(val));
|
82
|
+
default:
|
83
|
+
throw new Error(`Invalid type:${typeof val}`);
|
84
|
+
}
|
85
|
+
}
|
51
86
|
var LevelHandlerImpl = class {
|
52
87
|
constructor() {
|
53
88
|
this._globalLevels = /* @__PURE__ */ new Set(["info" /* INFO */, "error" /* ERROR */, "warn" /* WARN */]);
|
@@ -195,8 +230,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
195
230
|
return this;
|
196
231
|
}
|
197
232
|
Module(key) {
|
198
|
-
this._attributes["module"] = key;
|
199
|
-
this._withAttributes["module"] = key;
|
233
|
+
this._attributes["module"] = logValue(key);
|
234
|
+
this._withAttributes["module"] = logValue(key);
|
200
235
|
return this;
|
201
236
|
}
|
202
237
|
SetDebug(...modules) {
|
@@ -204,56 +239,85 @@ var LoggerImpl = class _LoggerImpl {
|
|
204
239
|
return this;
|
205
240
|
}
|
206
241
|
Timestamp() {
|
207
|
-
this._attributes["ts"] = this._sys.Time().Now().toISOString();
|
242
|
+
this._attributes["ts"] = logValue(this._sys.Time().Now().toISOString());
|
208
243
|
return this;
|
209
244
|
}
|
210
245
|
Warn() {
|
211
|
-
this._attributes["level"] = "warn" /* WARN
|
246
|
+
this._attributes["level"] = logValue("warn" /* WARN */);
|
212
247
|
return this;
|
213
248
|
}
|
214
249
|
Log() {
|
215
250
|
return this;
|
216
251
|
}
|
217
252
|
Debug() {
|
218
|
-
this._attributes["level"] = "debug" /* DEBUG
|
253
|
+
this._attributes["level"] = logValue("debug" /* DEBUG */);
|
219
254
|
return this;
|
220
255
|
}
|
221
256
|
Error() {
|
222
|
-
this._attributes["level"] = "error" /* ERROR
|
257
|
+
this._attributes["level"] = logValue("error" /* ERROR */);
|
223
258
|
return this;
|
224
259
|
}
|
225
260
|
Info() {
|
226
|
-
this._attributes["level"] = "info" /* INFO
|
261
|
+
this._attributes["level"] = logValue("info" /* INFO */);
|
227
262
|
return this;
|
228
263
|
}
|
229
264
|
Err(err) {
|
230
265
|
if (err instanceof Error) {
|
231
|
-
this._attributes["error"] = err.message;
|
266
|
+
this._attributes["error"] = logValue(err.message);
|
232
267
|
} else {
|
233
|
-
this._attributes["error"] = "" + err;
|
268
|
+
this._attributes["error"] = logValue("" + err);
|
234
269
|
}
|
235
270
|
return this;
|
236
271
|
}
|
237
272
|
WithLevel(l) {
|
238
|
-
this._attributes["level"] = l;
|
273
|
+
this._attributes["level"] = logValue(l);
|
274
|
+
return this;
|
275
|
+
}
|
276
|
+
Ref(key, action) {
|
277
|
+
if (typeof action === "function") {
|
278
|
+
this._attributes[key] = logValue(action);
|
279
|
+
} else if (typeof action.toString === "function") {
|
280
|
+
this._attributes[key] = logValue(() => action.toString());
|
281
|
+
} else {
|
282
|
+
this._attributes[key] = logValue("INVALID REF");
|
283
|
+
}
|
284
|
+
return this;
|
285
|
+
}
|
286
|
+
Bool(key, value) {
|
287
|
+
this._attributes[key] = logValue(!!value);
|
288
|
+
return this;
|
289
|
+
}
|
290
|
+
Result(key, res) {
|
291
|
+
if (res.isOk()) {
|
292
|
+
this._attributes[key] = logValue(res.Ok());
|
293
|
+
} else {
|
294
|
+
this.Err(res.Err());
|
295
|
+
}
|
296
|
+
return this;
|
297
|
+
}
|
298
|
+
Url(url, key = "url") {
|
299
|
+
this.Ref(key, () => url.toString());
|
239
300
|
return this;
|
240
301
|
}
|
241
302
|
Str(key, value) {
|
242
|
-
this._attributes[key] = value;
|
303
|
+
this._attributes[key] = logValue(value);
|
243
304
|
return this;
|
244
305
|
}
|
245
306
|
Any(key, value) {
|
246
|
-
this._attributes[key] = value;
|
307
|
+
this._attributes[key] = logValue(value);
|
247
308
|
return this;
|
248
309
|
}
|
249
310
|
Dur(key, nsec) {
|
250
|
-
this._attributes[key] = `${nsec}ms
|
311
|
+
this._attributes[key] = logValue(`${nsec}ms`);
|
251
312
|
return this;
|
252
313
|
}
|
253
314
|
Uint64(key, value) {
|
254
|
-
this._attributes[key] = value;
|
315
|
+
this._attributes[key] = logValue(value);
|
255
316
|
return this;
|
256
317
|
}
|
318
|
+
Int(key, value) {
|
319
|
+
return this.Uint64(key, value);
|
320
|
+
}
|
257
321
|
async Flush() {
|
258
322
|
return new Promise((resolve) => {
|
259
323
|
this._logWriter._flush(void 0, resolve);
|
@@ -281,15 +345,17 @@ var LoggerImpl = class _LoggerImpl {
|
|
281
345
|
}
|
282
346
|
Msg(...args) {
|
283
347
|
const error = this._resetAttributes(() => {
|
284
|
-
|
285
|
-
this._attributes["
|
286
|
-
|
348
|
+
var _a, _b, _c;
|
349
|
+
const doWrite = this._levelHandler.isEnabled((_a = this._attributes["level"]) == null ? void 0 : _a.value(), (_b = this._attributes["module"]) == null ? void 0 : _b.value());
|
350
|
+
this._attributes["msg"] = logValue(args.join(" "));
|
351
|
+
const msg = this._attributes["msg"].value();
|
352
|
+
if (typeof msg === "string" && !msg.trim().length) {
|
287
353
|
delete this._attributes["msg"];
|
288
354
|
}
|
289
|
-
if (this._attributes["ts"] === "ETERNITY") {
|
355
|
+
if (((_c = this._attributes["ts"]) == null ? void 0 : _c.value()) === "ETERNITY") {
|
290
356
|
this.Timestamp();
|
291
357
|
}
|
292
|
-
const str = JSON.stringify(this._attributes);
|
358
|
+
const str = JSON.stringify(resolveLogValue(this._attributes));
|
293
359
|
if (doWrite) {
|
294
360
|
const encoded = encoder.encode(str + "\n");
|
295
361
|
this._logWriter.write(encoded);
|
@@ -329,6 +395,26 @@ var WithLoggerBuilder = class {
|
|
329
395
|
this._li.Str(key, value);
|
330
396
|
return this;
|
331
397
|
}
|
398
|
+
Ref(key, action) {
|
399
|
+
this._li.Ref(key, action);
|
400
|
+
return this;
|
401
|
+
}
|
402
|
+
Bool(key, value) {
|
403
|
+
this._li.Bool(key, value);
|
404
|
+
return this;
|
405
|
+
}
|
406
|
+
Result(key, res) {
|
407
|
+
this._li.Result(key, res);
|
408
|
+
return this;
|
409
|
+
}
|
410
|
+
Url(url, key) {
|
411
|
+
this._li.Url(url, key);
|
412
|
+
return this;
|
413
|
+
}
|
414
|
+
Int(key, value) {
|
415
|
+
this._li.Int(key, value);
|
416
|
+
return this;
|
417
|
+
}
|
332
418
|
Log() {
|
333
419
|
this._li.Log();
|
334
420
|
return this;
|
@@ -358,7 +444,7 @@ var WithLoggerBuilder = class {
|
|
358
444
|
return this;
|
359
445
|
}
|
360
446
|
Timestamp() {
|
361
|
-
this._li._attributes["ts"] = "ETERNITY";
|
447
|
+
this._li._attributes["ts"] = logValue("ETERNITY");
|
362
448
|
return this;
|
363
449
|
}
|
364
450
|
Any(key, value) {
|
@@ -654,10 +740,31 @@ var ResolveOnce = class {
|
|
654
740
|
return future.asPromise();
|
655
741
|
}
|
656
742
|
};
|
743
|
+
var KeyedResolvOnce = class {
|
744
|
+
constructor() {
|
745
|
+
this._map = /* @__PURE__ */ new Map();
|
746
|
+
}
|
747
|
+
get(key) {
|
748
|
+
if (typeof key === "function") {
|
749
|
+
key = key();
|
750
|
+
}
|
751
|
+
let resolveOnce = this._map.get(key);
|
752
|
+
if (!resolveOnce) {
|
753
|
+
resolveOnce = new ResolveOnce();
|
754
|
+
this._map.set(key, resolveOnce);
|
755
|
+
}
|
756
|
+
return resolveOnce;
|
757
|
+
}
|
758
|
+
reset() {
|
759
|
+
this._map.forEach((resolveOnce) => resolveOnce.reset());
|
760
|
+
this._map.clear();
|
761
|
+
}
|
762
|
+
};
|
657
763
|
export {
|
658
764
|
Future,
|
659
765
|
IDMode,
|
660
766
|
IsLogger,
|
767
|
+
KeyedResolvOnce,
|
661
768
|
Level,
|
662
769
|
LevelHandlerImpl,
|
663
770
|
LogCollector,
|
package/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/logger.ts","../../src/logger_impl.ts","../../src/test/log_collector.ts","../../src/test/mock_logger.ts","../../src/result.ts","../../src/option.ts","../../src/future.ts","../../src/resolve-once.ts"],"sourcesContent":["export enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport interface LoggerInterface<R> {\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n SetDebug(...modules: (string | string[])[]): R;\n\n Str(key: string, value: string): R;\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","// import { v4 } from \"uuid\";\nimport { AsError, Level, Logger, WithLogger } from \"./logger\";\nimport { WebSysAbstraction } from \"./web/web_sys_abstraction\";\nimport { SysAbstraction } from \"./sys_abstraction\";\n\nconst encoder = new TextEncoder();\n\ntype JsonRecord = Record<string, string | number | boolean | unknown>;\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules = new Map<string, Set<Level>>();\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (module !== undefined) {\n const levels = this._modules.get(module as string);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n if (level === undefined) {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\n// globalThis[Symbol(\"levelSingleton\")] = new LevelHandlerImpl()\n\nexport class LogWriter {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array) {\n const my = async () => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns = Array<() => void>();\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriter;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: JsonRecord;\n readonly levelHandler?: LevelHandler;\n}\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: JsonRecord = {};\n readonly _withAttributes: JsonRecord;\n readonly _logWriter: LogWriter;\n readonly _levelHandler: LevelHandler;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n this._logWriter = new LogWriter(this._sys.Stdout());\n } else {\n this._logWriter = new LogWriter(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = levelSingleton;\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = key;\n this._withAttributes[\"module\"] = key;\n return this;\n }\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = this._sys.Time().Now().toISOString();\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = Level.WARN;\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = Level.DEBUG;\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = Level.ERROR;\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = Level.INFO;\n return this;\n }\n Err(err: unknown): Logger {\n if (err instanceof Error) {\n this._attributes[\"error\"] = err.message;\n } else {\n this._attributes[\"error\"] = \"\" + err;\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = l;\n return this;\n }\n\n Str(key: string, value: string): Logger {\n this._attributes[key] = value;\n return this;\n }\n\n Any(key: string, value: string | number | boolean | JsonRecord): Logger {\n this._attributes[key] = value;\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = `${nsec}ms`;\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = value;\n return this;\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => Error): Error {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n Msg(...args: string[]): AsError {\n const error = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(this._attributes[\"level\"], this._attributes[\"module\"]);\n this._attributes[\"msg\"] = args.join(\" \");\n if (typeof this._attributes[\"msg\"] === \"string\" && !this._attributes[\"msg\"].trim().length) {\n delete this._attributes[\"msg\"];\n }\n if (this._attributes[\"ts\"] === \"ETERNITY\") {\n this.Timestamp();\n }\n const str = JSON.stringify(this._attributes);\n if (doWrite) {\n const encoded = encoder.encode(str + \"\\n\");\n this._logWriter.write(encoded);\n }\n return new Error(str);\n });\n return {\n AsError: () => error,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Str(key: string, value: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li._attributes[\"ts\"] = \"ETERNITY\";\n return this;\n }\n Any(key: string, value: JsonRecord): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","class LogWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _bufferArr: Uint8Array[] = [];\n\n _resolveClosed: (value?: PromiseLike<undefined>) => void;\n closed: Promise<undefined>;\n desiredSize: number | null = null;\n ready: Promise<undefined> = Promise.resolve(undefined);\n\n constructor() {\n this._resolveClosed = () => {\n // do nothing\n };\n this.closed = new Promise((resolve) => {\n this._resolveClosed = resolve;\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n close(): Promise<void> {\n this._resolveClosed();\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n write(chunk?: Uint8Array): Promise<void> {\n chunk && this._bufferArr.push(chunk);\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n _writer?: LogWriter;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n this._writer = new LogWriter();\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = new TextDecoder().decode(\n new Uint8Array(\n (function* (res: Uint8Array[]) {\n for (const x of res) {\n yield* x;\n }\n })(this._writer._bufferArr),\n ),\n );\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n}\n","import { Logger } from \"../logger\";\nimport { LevelHandlerImpl, LoggerImpl } from \"../logger_impl\";\nimport { SysAbstraction } from \"../sys_abstraction\";\nimport { LogCollector } from \"./log_collector\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector();\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n !params?.disableDebug && logger.SetDebug(...modNames);\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T extends Error = Error>(t: T | string): Result<never, T> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as T);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n return t instanceof Result;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T) {\n this.#resolveFn(value);\n }\n reject(reason: unknown) {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future\";\n\nexport class ResolveOnce<T> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n\n get ready() {\n return this._onceDone;\n }\n\n reset() {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n async once(fn: () => Promise<T>): Promise<T> {\n if (this._onceDone) {\n if (this._onceError) {\n return Promise.reject(this._onceError);\n }\n if (this._onceOk) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!);\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n fn()\n .then((value) => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n this._onceFutures.length = 0;\n })\n .catch((e) => {\n this._onceError = e as Error;\n this._onceDone = true;\n this._onceFutures.forEach((f) => f.reject(this._onceError));\n this._onceFutures.length = 0;\n });\n }\n return future.asPromise();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AACR,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AA8BL,SAAS,SAAS,KAA6B;AACpD,SACE,OAAO,QAAQ,YACf;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAEG,IAAI,CAAC,OAAO,OAAQ,IAAY,EAAE,MAAM,UAAU,EAClD,OAAO,CAAC,GAAG,MAAM,KAAK,GAAG,IAAI;AAEpC;;;AClDA,IAAM,UAAU,IAAI,YAAY;AAWzB,IAAM,mBAAN,MAA+C;AAAA,EAA/C;AACL,SAAS,gBAAgB,oBAAI,IAAW,0DAAoC,CAAC;AAC7E,SAAS,WAAW,oBAAI,IAAwB;AAAA;AAAA,EAChD,YAAY,UAAiB,SAAyB;AACpD,QAAI,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B,aAAK,UAAU;AACf,aAAK,YAAY;AAEjB,aAAK,aAAa,QAAQ,CAAC,MAAM,EAAE,QAAQ,KAAK,UAAW,CAAC;AAC5D,aAAK,aAAa,SAAS;AAAA,MAC7B,CAAC,EACA,MAAM,CAAC,MAAM;AACZ,aAAK,aAAa;AAClB,aAAK,YAAY;AACjB,aAAK,aAAa,QAAQ,CAAC,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;AAC1D,aAAK,aAAa,SAAS;AAAA,MAC7B,CAAC;AAAA,IACL;AACA,WAAO,OAAO,UAAU;AAAA,EAC1B;AACF;","names":["Level","LogWriter"]}
|
1
|
+
{"version":3,"sources":["../../src/logger.ts","../../src/logger_impl.ts","../../src/test/log_collector.ts","../../src/test/mock_logger.ts","../../src/result.ts","../../src/option.ts","../../src/future.ts","../../src/resolve-once.ts"],"sourcesContent":["import { Result } from \"./result\";\n\nexport enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport type Serialized = string | number | boolean;\nexport type FnSerialized = () => Serialized;\nexport interface LoggerInterface<R> {\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n SetDebug(...modules: (string | string[])[]): R;\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): R;\n Result<T>(key: string, res: Result<T>): R;\n // default key url\n Url(url: URL, key?: string): R;\n\n Str(key: string, value?: string): R;\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n Int(key: string, value: number): R;\n Bool(key: string, value: unknown): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","// import { v4 } from \"uuid\";\nimport { AsError, FnSerialized, Level, Logger, Serialized, WithLogger } from \"./logger\";\nimport { WebSysAbstraction } from \"./web/web_sys_abstraction\";\nimport { SysAbstraction } from \"./sys_abstraction\";\nimport { Result } from \"./result\";\n\nconst encoder = new TextEncoder();\n\nclass LogValue {\n constructor(readonly fn: FnSerialized) {}\n value(): Serialized {\n return this.fn();\n }\n}\n\nfunction resolveLogValue(val: JsonRecord): Record<string, Serialized> {\n const ret: Record<string, Serialized> = {};\n Object.keys(val).forEach((key) => {\n const v = val[key];\n if (v instanceof LogValue) {\n ret[key] = v.value();\n }\n });\n return ret;\n}\n\nfunction logValue(val: Serialized | FnSerialized | JsonRecord): LogValue {\n if (typeof val === \"function\") {\n return new LogValue(val);\n }\n switch (typeof val) {\n case \"string\":\n return new LogValue(() => val.toString());\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\":\n return new LogValue(() => JSON.stringify(val));\n default:\n throw new Error(`Invalid type:${typeof val}`);\n }\n}\n\ntype JsonRecord = Record<string, LogValue>;\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules = new Map<string, Set<Level>>();\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (module !== undefined) {\n const levels = this._modules.get(module as string);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n if (level === undefined) {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\n// globalThis[Symbol(\"levelSingleton\")] = new LevelHandlerImpl()\n\nexport class LogWriter {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array) {\n const my = async () => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns = Array<() => void>();\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriter;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: JsonRecord;\n readonly levelHandler?: LevelHandler;\n}\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: JsonRecord = {};\n readonly _withAttributes: JsonRecord;\n readonly _logWriter: LogWriter;\n readonly _levelHandler: LevelHandler;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n this._logWriter = new LogWriter(this._sys.Stdout());\n } else {\n this._logWriter = new LogWriter(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = levelSingleton;\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = logValue(key);\n this._withAttributes[\"module\"] = logValue(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = logValue(this._sys.Time().Now().toISOString());\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN);\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG);\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR);\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO);\n return this;\n }\n Err(err: unknown): Logger {\n if (err instanceof Error) {\n this._attributes[\"error\"] = logValue(err.message);\n } else {\n this._attributes[\"error\"] = logValue(\"\" + err);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l);\n return this;\n }\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): Logger {\n if (typeof action === \"function\") {\n this._attributes[key] = logValue(action as FnSerialized);\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString());\n } else {\n this._attributes[key] = logValue(\"INVALID REF\");\n }\n return this;\n }\n Bool(key: string, value: unknown): Logger {\n this._attributes[key] = logValue(!!value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized);\n } else {\n this.Err(res.Err());\n }\n return this;\n }\n\n Url(url: URL, key = \"url\"): Logger {\n this.Ref(key, () => url.toString());\n return this;\n }\n\n Str(key: string, value: string): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n\n Any(key: string, value: string | number | boolean | JsonRecord): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`);\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Int(key: string, value: number): Logger {\n return this.Uint64(key, value);\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => Error): Error {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n Msg(...args: string[]): AsError {\n const error = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(this._attributes[\"level\"]?.value(), this._attributes[\"module\"]?.value());\n this._attributes[\"msg\"] = logValue(args.join(\" \"));\n const msg = this._attributes[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete this._attributes[\"msg\"];\n }\n if (this._attributes[\"ts\"]?.value() === \"ETERNITY\") {\n this.Timestamp();\n }\n const str = JSON.stringify(resolveLogValue(this._attributes));\n if (doWrite) {\n const encoded = encoder.encode(str + \"\\n\");\n this._logWriter.write(encoded);\n }\n return new Error(str);\n });\n return {\n AsError: () => error,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Str(key: string, value: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Ref(key: string, action: Serialized | FnSerialized): WithLogger {\n this._li.Ref(key, action);\n return this;\n }\n Bool(key: string, value: unknown): WithLogger {\n this._li.Bool(key, value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): WithLogger {\n this._li.Result(key, res);\n return this;\n }\n Url(url: URL, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string, value: number): WithLogger {\n this._li.Int(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li._attributes[\"ts\"] = logValue(\"ETERNITY\");\n return this;\n }\n Any(key: string, value: JsonRecord): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","class LogWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _bufferArr: Uint8Array[] = [];\n\n _resolveClosed: (value?: PromiseLike<undefined>) => void;\n closed: Promise<undefined>;\n desiredSize: number | null = null;\n ready: Promise<undefined> = Promise.resolve(undefined);\n\n constructor() {\n this._resolveClosed = () => {\n // do nothing\n };\n this.closed = new Promise((resolve) => {\n this._resolveClosed = resolve;\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n close(): Promise<void> {\n this._resolveClosed();\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n write(chunk?: Uint8Array): Promise<void> {\n chunk && this._bufferArr.push(chunk);\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n _writer?: LogWriter;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n this._writer = new LogWriter();\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = new TextDecoder().decode(\n new Uint8Array(\n (function* (res: Uint8Array[]) {\n for (const x of res) {\n yield* x;\n }\n })(this._writer._bufferArr),\n ),\n );\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n}\n","import { Logger } from \"../logger\";\nimport { LevelHandlerImpl, LoggerImpl } from \"../logger_impl\";\nimport { SysAbstraction } from \"../sys_abstraction\";\nimport { LogCollector } from \"./log_collector\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector();\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n !params?.disableDebug && logger.SetDebug(...modNames);\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T extends Error = Error>(t: T | string): Result<never, T> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as T);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n return t instanceof Result;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","export class Future<T> {\n readonly #promise: Promise<T>;\n #resolveFn: (value: T) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n #rejectFn: (reason: unknown) => void = () => {\n throw new Error(\"This Promise is not working as expected.\");\n };\n\n constructor() {\n this.#promise = new Promise<T>((resolve, reject) => {\n this.#resolveFn = resolve;\n this.#rejectFn = reject;\n });\n }\n\n async asPromise(): Promise<T> {\n return this.#promise;\n }\n\n resolve(value: T) {\n this.#resolveFn(value);\n }\n reject(reason: unknown) {\n this.#rejectFn(reason);\n }\n}\n","import { Future } from \"./future\";\n\nexport class ResolveOnce<T> {\n _onceDone = false;\n readonly _onceFutures: Future<T>[] = [];\n _onceOk = false;\n _onceValue?: T;\n _onceError?: Error;\n\n get ready() {\n return this._onceDone;\n }\n\n reset() {\n this._onceDone = false;\n this._onceOk = false;\n this._onceValue = undefined;\n this._onceError = undefined;\n this._onceFutures.length = 0;\n }\n\n async once(fn: () => Promise<T>): Promise<T> {\n if (this._onceDone) {\n if (this._onceError) {\n return Promise.reject(this._onceError);\n }\n if (this._onceOk) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return Promise.resolve(this._onceValue!);\n }\n throw new Error(\"ResolveOnce.once impossible\");\n }\n const future = new Future<T>();\n this._onceFutures.push(future);\n if (this._onceFutures.length === 1) {\n fn()\n .then((value) => {\n this._onceValue = value;\n this._onceOk = true;\n this._onceDone = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._onceFutures.forEach((f) => f.resolve(this._onceValue!));\n this._onceFutures.length = 0;\n })\n .catch((e) => {\n this._onceError = e as Error;\n this._onceDone = true;\n this._onceFutures.forEach((f) => f.reject(this._onceError));\n this._onceFutures.length = 0;\n });\n }\n return future.asPromise();\n }\n}\n\nexport class KeyedResolvOnce<T> {\n private readonly _map = new Map<string, ResolveOnce<T>>();\n\n get(key: string | (() => string)): ResolveOnce<T> {\n if (typeof key === \"function\") {\n key = key();\n }\n let resolveOnce = this._map.get(key);\n if (!resolveOnce) {\n resolveOnce = new ResolveOnce<T>();\n this._map.set(key, resolveOnce);\n }\n return resolveOnce;\n }\n\n reset() {\n this._map.forEach((resolveOnce) => resolveOnce.reset());\n this._map.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AACR,EAAAA,OAAA,UAAO;AACP,EAAAA,OAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAuCL,SAAS,SAAS,KAA6B;AACpD,SACE,OAAO,QAAQ,YACf;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAEG,IAAI,CAAC,OAAO,OAAQ,IAAY,EAAE,MAAM,UAAU,EAClD,OAAO,CAAC,GAAG,MAAM,KAAK,GAAG,IAAI;AAEpC;;;AC5DA,IAAM,UAAU,IAAI,YAAY;AAEhC,IAAM,WAAN,MAAe;AAAA,EACb,YAAqB,IAAkB;AAAlB;AAAA,EAAmB;AAAA,EACxC,QAAoB;AAClB,WAAO,KAAK,GAAG;AAAA,EACjB;AACF;AAEA,SAAS,gBAAgB,KAA6C;AACpE,QAAM,MAAkC,CAAC;AACzC,SAAO,KAAK,GAAG,EAAE,QAAQ,CAAC,QAAQ;AAChC,UAAM,IAAI,IAAI,GAAG;AACjB,QAAI,aAAa,UAAU;AACzB,UAAI,GAAG,IAAI,EAAE,MAAM;AAAA,IACrB;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAEA,SAAS,SAAS,KAAuD;AACvE,MAAI,OAAO,QAAQ,YAAY;AAC7B,WAAO,IAAI,SAAS,GAAG;AAAA,EACzB;AACA,UAAQ,OAAO,KAAK;AA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