@adviser/cement 0.3.14 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{base-sys-abstraction-8v83VyEU.d.ts → base-sys-abstraction-BnBZ6zd0.d.ts} +2 -2
- package/{base-sys-abstraction-4Vw4QGaI.d.cts → base-sys-abstraction-DAZ8tx5F.d.cts} +2 -2
- package/cf/index.cjs +46 -18
- package/cf/index.cjs.map +1 -1
- package/cf/index.d.cts +3 -3
- package/cf/index.d.ts +3 -3
- package/cf/index.js +3 -3
- package/{chunk-W53WEZWY.js → chunk-55W4AK2Z.js} +3 -5
- package/{chunk-W53WEZWY.js.map → chunk-55W4AK2Z.js.map} +1 -1
- package/{chunk-22GI5ETU.js → chunk-H3CAVBMO.js} +41 -42
- package/chunk-H3CAVBMO.js.map +1 -0
- package/{chunk-A57BAYWU.js → chunk-LXTKPZ6M.js} +10 -8
- package/chunk-LXTKPZ6M.js.map +1 -0
- package/{chunk-KY47QBK3.js → chunk-WGRZHIFK.js} +155 -152
- package/chunk-WGRZHIFK.js.map +1 -0
- package/{chunk-GLUGMVET.js → chunk-Z3IR6QEZ.js} +3 -3
- package/deno/index.cjs +46 -18
- package/deno/index.cjs.map +1 -1
- package/deno/index.d.cts +3 -3
- package/deno/index.d.ts +3 -3
- package/deno/index.js +2 -2
- package/{get-params-result-C2cbgB78.d.ts → get-params-result-4xHM5s4_.d.cts} +14 -10
- package/{get-params-result-C2cbgB78.d.cts → get-params-result-4xHM5s4_.d.ts} +14 -10
- package/index-CMLb7JSe.d.ts +97 -0
- package/{index-DixRvifF.d.cts → index-Cp1NspHH.d.cts} +10 -10
- package/{index-D2WPDt4R.d.ts → index-D1j1fPYg.d.ts} +10 -10
- package/index-LQOsS7gM.d.cts +97 -0
- package/index.cjs +370 -317
- package/index.cjs.map +1 -1
- package/index.d.cts +23 -10
- package/index.d.ts +23 -10
- package/index.js +86 -39
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/index.cjs +46 -18
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -3
- package/node/index.d.ts +3 -3
- package/node/index.js +2 -2
- package/package.json +5 -4
- package/src/index.ts +4 -2
- package/src/jsr.json +1 -1
- package/src/logger.ts +8 -6
- package/src/lru-cache.ts +68 -0
- package/src/sys-abstraction.ts +18 -15
- package/src/time.ts +7 -9
- package/src/types.ts +19 -0
- package/src/uri.ts +4 -3
- package/src/utils/get-params-result.ts +2 -18
- package/src/utils/relative-path.ts +8 -6
- package/{sys-abstraction-3OXhCVsu.d.cts → sys-abstraction-B0x6IE7r.d.ts} +27 -23
- package/{sys-abstraction-DXeSUn9x.d.ts → sys-abstraction-BTs3Vzy4.d.cts} +27 -23
- package/test/index.cjs +87 -46
- package/test/index.cjs.map +1 -1
- package/test/index.d.cts +3 -3
- package/test/index.d.ts +3 -3
- package/test/index.js +4 -4
- package/ts/src/index.d.ts +2 -2
- package/ts/src/index.d.ts.map +1 -1
- package/ts/src/index.js +2 -2
- package/ts/src/index.js.map +1 -1
- package/ts/src/logger.d.ts +7 -6
- package/ts/src/logger.d.ts.map +1 -1
- package/ts/src/logger.js +6 -7
- package/ts/src/logger.js.map +1 -1
- package/ts/src/lru-cache.d.ts +15 -0
- package/ts/src/lru-cache.d.ts.map +1 -0
- package/ts/src/lru-cache.js +46 -0
- package/ts/src/lru-cache.js.map +1 -0
- package/ts/src/lru-cache.test.d.ts +2 -0
- package/ts/src/lru-cache.test.d.ts.map +1 -0
- package/ts/src/lru-cache.test.js +54 -0
- package/ts/src/lru-cache.test.js.map +1 -0
- package/ts/src/sys-abstraction.d.ts +18 -15
- package/ts/src/sys-abstraction.d.ts.map +1 -1
- package/ts/src/sys-abstraction.js +15 -18
- package/ts/src/sys-abstraction.js.map +1 -1
- package/ts/src/sys-env.test.js +1 -2
- package/ts/src/sys-env.test.js.map +1 -1
- package/ts/src/time.d.ts +7 -6
- package/ts/src/time.d.ts.map +1 -1
- package/ts/src/time.js +6 -7
- package/ts/src/time.js.map +1 -1
- package/ts/src/types.d.ts +16 -0
- package/ts/src/types.d.ts.map +1 -0
- package/ts/src/types.js +15 -0
- package/ts/src/types.js.map +1 -0
- package/ts/src/uri.d.ts +0 -1
- package/ts/src/uri.d.ts.map +1 -1
- package/ts/src/uri.js +1 -2
- package/ts/src/uri.js.map +1 -1
- package/ts/src/utils/get-params-result.d.ts +2 -13
- package/ts/src/utils/get-params-result.d.ts.map +1 -1
- package/ts/src/utils/get-params-result.js +1 -14
- package/ts/src/utils/get-params-result.js.map +1 -1
- package/ts/src/utils/relative-path.d.ts +7 -6
- package/ts/src/utils/relative-path.d.ts.map +1 -1
- package/ts/src/utils/relative-path.js +6 -7
- package/ts/src/utils/relative-path.js.map +1 -1
- package/utils/index.cjs +9 -9
- package/utils/index.cjs.map +1 -1
- package/utils/index.d.cts +2 -2
- package/utils/index.d.ts +2 -2
- package/utils/index.js +3 -5
- package/web/index.cjs +46 -18
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +3 -3
- package/web/index.d.ts +3 -3
- package/web/index.js +3 -3
- package/chunk-22GI5ETU.js.map +0 -1
- package/chunk-A57BAYWU.js.map +0 -1
- package/chunk-KY47QBK3.js.map +0 -1
- package/index-Dpc3oVOD.d.cts +0 -99
- package/index-MWn9Xel9.d.ts +0 -99
- /package/{chunk-GLUGMVET.js.map → chunk-Z3IR6QEZ.js.map} +0 -0
package/index.cjs
CHANGED
@@ -14,9 +14,9 @@ var __export = (target, all) => {
|
|
14
14
|
};
|
15
15
|
var __copyProps = (to, from2, except, desc) => {
|
16
16
|
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
17
|
-
for (let
|
18
|
-
if (!__hasOwnProp.call(to,
|
19
|
-
__defProp(to,
|
17
|
+
for (let key of __getOwnPropNames(from2))
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
19
|
+
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
20
20
|
}
|
21
21
|
return to;
|
22
22
|
};
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
53
53
|
Keyed: () => Keyed,
|
54
54
|
KeyedResolvOnce: () => KeyedResolvOnce,
|
55
55
|
KeyedResolvSeq: () => KeyedResolvSeq,
|
56
|
+
LRUCache: () => LRUCache,
|
56
57
|
Level: () => Level,
|
57
58
|
LevelHandlerImpl: () => LevelHandlerImpl,
|
58
59
|
LevelHandlerSingleton: () => LevelHandlerSingleton,
|
@@ -95,9 +96,8 @@ __export(index_exports, {
|
|
95
96
|
hasHostPartProtocols: () => hasHostPartProtocols,
|
96
97
|
isCoerceURI: () => isCoerceURI,
|
97
98
|
isURL: () => isURL,
|
98
|
-
key: () => key,
|
99
99
|
logValue: () => logValue,
|
100
|
-
param: () =>
|
100
|
+
param: () => param,
|
101
101
|
pathOps: () => pathOps,
|
102
102
|
registerEnvAction: () => registerEnvAction,
|
103
103
|
runtimeFn: () => runtimeFn,
|
@@ -156,13 +156,12 @@ function bin2string(hex, size = 0) {
|
|
156
156
|
}
|
157
157
|
|
158
158
|
// src/logger.ts
|
159
|
-
var Level =
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
})(Level || {});
|
159
|
+
var Level = {
|
160
|
+
WARN: "warn",
|
161
|
+
DEBUG: "debug",
|
162
|
+
INFO: "info",
|
163
|
+
ERROR: "error"
|
164
|
+
};
|
166
165
|
var LogValue = class {
|
167
166
|
constructor(fn) {
|
168
167
|
this.fn = fn;
|
@@ -256,16 +255,16 @@ function logValueInternal(val, ctx) {
|
|
256
255
|
}
|
257
256
|
const res = {};
|
258
257
|
const typedVal = val;
|
259
|
-
for (const
|
260
|
-
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(
|
258
|
+
for (const key in typedVal) {
|
259
|
+
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(key)) {
|
261
260
|
continue;
|
262
261
|
}
|
263
|
-
const element = typedVal[
|
262
|
+
const element = typedVal[key];
|
264
263
|
if (element instanceof LogValue) {
|
265
|
-
res[
|
264
|
+
res[key] = element;
|
266
265
|
} else {
|
267
266
|
if (typeof element !== "function") {
|
268
|
-
res[
|
267
|
+
res[key] = logValueInternal(element, ctx);
|
269
268
|
}
|
270
269
|
}
|
271
270
|
}
|
@@ -300,34 +299,31 @@ function IsLogger(obj) {
|
|
300
299
|
}
|
301
300
|
|
302
301
|
// src/sys-abstraction.ts
|
303
|
-
var TimeMode =
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
IDMode2["STEP"] = "step";
|
319
|
-
return IDMode2;
|
320
|
-
})(IDMode || {});
|
302
|
+
var TimeMode = {
|
303
|
+
REAL: "real",
|
304
|
+
CONST: "const",
|
305
|
+
STEP: "step"
|
306
|
+
};
|
307
|
+
var RandomMode = {
|
308
|
+
CONST: "const",
|
309
|
+
STEP: "step",
|
310
|
+
RANDOM: "random"
|
311
|
+
};
|
312
|
+
var IDMode = {
|
313
|
+
UUID: "uuid",
|
314
|
+
CONST: "const",
|
315
|
+
STEP: "step"
|
316
|
+
};
|
321
317
|
function String2TimeMode(s) {
|
322
318
|
switch (s == null ? void 0 : s.toLowerCase()) {
|
323
319
|
case "real":
|
324
|
-
return
|
320
|
+
return TimeMode.REAL;
|
325
321
|
case "const":
|
326
|
-
return
|
322
|
+
return TimeMode.CONST;
|
327
323
|
case "step":
|
328
|
-
return
|
324
|
+
return TimeMode.STEP;
|
329
325
|
default:
|
330
|
-
return
|
326
|
+
return TimeMode.REAL;
|
331
327
|
}
|
332
328
|
}
|
333
329
|
|
@@ -338,13 +334,15 @@ var Time = class {
|
|
338
334
|
return now.getTime() - start.getTime();
|
339
335
|
}
|
340
336
|
};
|
341
|
-
var TimeUnits =
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
337
|
+
var TimeUnits = {
|
338
|
+
Microsecond: 1,
|
339
|
+
Second: 1e3 * 1,
|
340
|
+
//Microsecond,
|
341
|
+
Minute: 60 * 1e3 * 1,
|
342
|
+
//Second,
|
343
|
+
Hour: 60 * 60 * 1e3 * 1
|
344
|
+
// Minute,
|
345
|
+
};
|
348
346
|
|
349
347
|
// src/base-sys-abstraction.ts
|
350
348
|
var SysTime = class extends Time {
|
@@ -390,11 +388,11 @@ var StepTime = class extends Time {
|
|
390
388
|
};
|
391
389
|
function TimeFactory(timeMode) {
|
392
390
|
switch (timeMode) {
|
393
|
-
case
|
391
|
+
case TimeMode.REAL:
|
394
392
|
return new SysTime();
|
395
|
-
case
|
393
|
+
case TimeMode.CONST:
|
396
394
|
return new ConstTime();
|
397
|
-
case
|
395
|
+
case TimeMode.STEP:
|
398
396
|
return new StepTime();
|
399
397
|
}
|
400
398
|
return new SysTime();
|
@@ -406,12 +404,12 @@ var RandomService = class {
|
|
406
404
|
}
|
407
405
|
Random0ToValue(value) {
|
408
406
|
switch (this._mode) {
|
409
|
-
case
|
407
|
+
case RandomMode.CONST:
|
410
408
|
return 0.5 * value;
|
411
|
-
case
|
409
|
+
case RandomMode.STEP:
|
412
410
|
this._step += 1e-4;
|
413
411
|
return this._step * value;
|
414
|
-
case
|
412
|
+
case RandomMode.RANDOM:
|
415
413
|
return Math.random() * value;
|
416
414
|
default:
|
417
415
|
throw new Error("Unknown RandomMode");
|
@@ -422,17 +420,17 @@ var IdService = class {
|
|
422
420
|
constructor(mode) {
|
423
421
|
this._step = 0;
|
424
422
|
if (!mode) {
|
425
|
-
mode =
|
423
|
+
mode = IDMode.UUID;
|
426
424
|
}
|
427
425
|
this._mode = mode;
|
428
426
|
}
|
429
427
|
NextId() {
|
430
428
|
switch (this._mode) {
|
431
|
-
case
|
429
|
+
case IDMode.UUID:
|
432
430
|
return crypto.randomUUID();
|
433
|
-
case
|
431
|
+
case IDMode.CONST:
|
434
432
|
return "VeryUniqueID";
|
435
|
-
case
|
433
|
+
case IDMode.STEP:
|
436
434
|
return `STEPId-${this._step++}`;
|
437
435
|
default:
|
438
436
|
throw new Error("Unknown IDMode");
|
@@ -462,7 +460,7 @@ var BaseSysAbstraction = class {
|
|
462
460
|
constructor(params) {
|
463
461
|
this._time = new SysTime();
|
464
462
|
this._idService = new IdService();
|
465
|
-
this._randomService = new RandomService(
|
463
|
+
this._randomService = new RandomService(RandomMode.RANDOM);
|
466
464
|
this._fileSystem = params.FileSystem;
|
467
465
|
this._systemService = params.SystemService;
|
468
466
|
this._txtEnDe = params.TxtEnDecoder;
|
@@ -792,24 +790,24 @@ var Keyed = class {
|
|
792
790
|
this._map = /* @__PURE__ */ new Map();
|
793
791
|
this.factory = factory;
|
794
792
|
}
|
795
|
-
async asyncGet(
|
796
|
-
return this.get(await
|
793
|
+
async asyncGet(key) {
|
794
|
+
return this.get(await key());
|
797
795
|
}
|
798
|
-
get(
|
799
|
-
if (typeof
|
800
|
-
|
796
|
+
get(key) {
|
797
|
+
if (typeof key === "function") {
|
798
|
+
key = key();
|
801
799
|
}
|
802
|
-
let keyed = this._map.get(
|
800
|
+
let keyed = this._map.get(key);
|
803
801
|
if (!keyed) {
|
804
|
-
keyed = this.factory(
|
805
|
-
this._map.set(
|
802
|
+
keyed = this.factory(key);
|
803
|
+
this._map.set(key, keyed);
|
806
804
|
}
|
807
805
|
return keyed;
|
808
806
|
}
|
809
|
-
unget(
|
810
|
-
const keyed = this._map.get(
|
807
|
+
unget(key) {
|
808
|
+
const keyed = this._map.get(key);
|
811
809
|
keyed == null ? void 0 : keyed.reset();
|
812
|
-
this._map.delete(
|
810
|
+
this._map.delete(key);
|
813
811
|
}
|
814
812
|
reset() {
|
815
813
|
this._map.forEach((keyed) => keyed.reset());
|
@@ -818,7 +816,7 @@ var Keyed = class {
|
|
818
816
|
};
|
819
817
|
var KeyedResolvOnce = class extends Keyed {
|
820
818
|
constructor() {
|
821
|
-
super((
|
819
|
+
super((key) => new ResolveOnce(key));
|
822
820
|
}
|
823
821
|
/**
|
824
822
|
*
|
@@ -844,7 +842,7 @@ var KeyedResolvOnce = class extends Keyed {
|
|
844
842
|
};
|
845
843
|
var KeyedResolvSeq = class extends Keyed {
|
846
844
|
constructor() {
|
847
|
-
super((
|
845
|
+
super((key) => new ResolveSeq(key));
|
848
846
|
}
|
849
847
|
};
|
850
848
|
|
@@ -900,8 +898,8 @@ var _DenoEnvActions = class _DenoEnvActions {
|
|
900
898
|
return __privateGet(this, _deno).Deno.env;
|
901
899
|
}
|
902
900
|
register(env) {
|
903
|
-
for (const
|
904
|
-
this._env.set(
|
901
|
+
for (const key of env.keys()) {
|
902
|
+
this._env.set(key, env.get(key) || "");
|
905
903
|
}
|
906
904
|
return env;
|
907
905
|
}
|
@@ -911,16 +909,16 @@ var _DenoEnvActions = class _DenoEnvActions {
|
|
911
909
|
keys() {
|
912
910
|
return Object.keys(this._env.toObject());
|
913
911
|
}
|
914
|
-
get(
|
915
|
-
return this._env.get(
|
912
|
+
get(key) {
|
913
|
+
return this._env.get(key);
|
916
914
|
}
|
917
|
-
set(
|
915
|
+
set(key, value) {
|
918
916
|
if (value) {
|
919
|
-
this._env.set(
|
917
|
+
this._env.set(key, value);
|
920
918
|
}
|
921
919
|
}
|
922
|
-
delete(
|
923
|
-
this._env.delete(
|
920
|
+
delete(key) {
|
921
|
+
this._env.delete(key);
|
924
922
|
}
|
925
923
|
};
|
926
924
|
_deno = new WeakMap();
|
@@ -939,8 +937,8 @@ var _NodeEnvActions = class _NodeEnvActions {
|
|
939
937
|
return once2.once(() => new _NodeEnvActions(opts));
|
940
938
|
}
|
941
939
|
register(env) {
|
942
|
-
for (const
|
943
|
-
this._env[
|
940
|
+
for (const key of env.keys()) {
|
941
|
+
this._env[key] = env.get(key) || "";
|
944
942
|
}
|
945
943
|
return env;
|
946
944
|
}
|
@@ -950,16 +948,16 @@ var _NodeEnvActions = class _NodeEnvActions {
|
|
950
948
|
keys() {
|
951
949
|
return Object.keys(this._env);
|
952
950
|
}
|
953
|
-
get(
|
954
|
-
return this._env[
|
951
|
+
get(key) {
|
952
|
+
return this._env[key];
|
955
953
|
}
|
956
|
-
set(
|
954
|
+
set(key, value) {
|
957
955
|
if (value) {
|
958
|
-
this._env[
|
956
|
+
this._env[key] = value;
|
959
957
|
}
|
960
958
|
}
|
961
|
-
delete(
|
962
|
-
delete this._env[
|
959
|
+
delete(key) {
|
960
|
+
delete this._env[key];
|
963
961
|
}
|
964
962
|
};
|
965
963
|
_node = new WeakMap();
|
@@ -975,16 +973,16 @@ var BrowserEnvActions = class _BrowserEnvActions {
|
|
975
973
|
static new(opts) {
|
976
974
|
return once3.once(() => new _BrowserEnvActions(opts));
|
977
975
|
}
|
978
|
-
get(
|
979
|
-
return this.env.get(
|
976
|
+
get(key) {
|
977
|
+
return this.env.get(key);
|
980
978
|
}
|
981
|
-
set(
|
979
|
+
set(key, value) {
|
982
980
|
if (value) {
|
983
|
-
this.env.set(
|
981
|
+
this.env.set(key, value);
|
984
982
|
}
|
985
983
|
}
|
986
|
-
delete(
|
987
|
-
this.env.delete(
|
984
|
+
delete(key) {
|
985
|
+
this.env.delete(key);
|
988
986
|
}
|
989
987
|
keys() {
|
990
988
|
return Array.from(this.env.keys());
|
@@ -1012,13 +1010,13 @@ var CFEnvActions = class _CFEnvActions {
|
|
1012
1010
|
}
|
1013
1011
|
static inject(o) {
|
1014
1012
|
const env = _CFEnvActions.new({});
|
1015
|
-
for (const
|
1016
|
-
const value = o[
|
1013
|
+
for (const key in o) {
|
1014
|
+
const value = o[key];
|
1017
1015
|
if (typeof value === "string") {
|
1018
1016
|
if (env.env) {
|
1019
|
-
env.env.set(
|
1017
|
+
env.env.set(key, value);
|
1020
1018
|
} else {
|
1021
|
-
env.injectOnRegister[
|
1019
|
+
env.injectOnRegister[key] = value;
|
1022
1020
|
}
|
1023
1021
|
}
|
1024
1022
|
}
|
@@ -1028,42 +1026,44 @@ var CFEnvActions = class _CFEnvActions {
|
|
1028
1026
|
}
|
1029
1027
|
register(env) {
|
1030
1028
|
this.env = env;
|
1031
|
-
for (const
|
1032
|
-
env.set(
|
1029
|
+
for (const key in this.injectOnRegister) {
|
1030
|
+
env.set(key, this.injectOnRegister[key]);
|
1033
1031
|
}
|
1034
1032
|
return env;
|
1035
1033
|
}
|
1036
|
-
get(
|
1037
|
-
return this.cfEnv.get(
|
1034
|
+
get(key) {
|
1035
|
+
return this.cfEnv.get(key);
|
1038
1036
|
}
|
1039
|
-
set(
|
1037
|
+
set(key, value) {
|
1040
1038
|
if (value) {
|
1041
|
-
this.cfEnv.set(
|
1039
|
+
this.cfEnv.set(key, value);
|
1042
1040
|
}
|
1043
1041
|
}
|
1044
|
-
delete(
|
1045
|
-
this.cfEnv.delete(
|
1042
|
+
delete(key) {
|
1043
|
+
this.cfEnv.delete(key);
|
1046
1044
|
}
|
1047
1045
|
keys() {
|
1048
1046
|
return Array.from(this.cfEnv.keys());
|
1049
1047
|
}
|
1050
1048
|
};
|
1051
1049
|
|
1052
|
-
// src/
|
1053
|
-
var
|
1050
|
+
// src/types.ts
|
1051
|
+
var _Required = class {
|
1054
1052
|
constructor() {
|
1055
|
-
this.
|
1053
|
+
this.type = "REQUIRED";
|
1056
1054
|
}
|
1057
1055
|
};
|
1058
|
-
var
|
1056
|
+
var _Optional = class {
|
1059
1057
|
constructor() {
|
1060
|
-
this.
|
1058
|
+
this.type = "OPTIONAL";
|
1061
1059
|
}
|
1062
1060
|
};
|
1063
1061
|
var param = {
|
1064
|
-
REQUIRED: new
|
1065
|
-
OPTIONAL: new
|
1062
|
+
REQUIRED: new _Required(),
|
1063
|
+
OPTIONAL: new _Optional()
|
1066
1064
|
};
|
1065
|
+
|
1066
|
+
// src/utils/get-params-result.ts
|
1067
1067
|
function getParamsResult(keys, getParam) {
|
1068
1068
|
const keyDef = keys.flat().reduce(
|
1069
1069
|
(acc, i) => {
|
@@ -1157,16 +1157,16 @@ var EnvImpl = class {
|
|
1157
1157
|
});
|
1158
1158
|
}
|
1159
1159
|
sets(...keys) {
|
1160
|
-
keys.forEach((
|
1161
|
-
if (Array.isArray(
|
1162
|
-
if (
|
1163
|
-
const [k, v] =
|
1160
|
+
keys.forEach((key) => {
|
1161
|
+
if (Array.isArray(key)) {
|
1162
|
+
if (key.length === 2) {
|
1163
|
+
const [k, v] = key;
|
1164
1164
|
if (typeof k === "string" && typeof v === "string") {
|
1165
1165
|
this.set(k, v);
|
1166
1166
|
return;
|
1167
1167
|
}
|
1168
1168
|
}
|
1169
|
-
for (const item of
|
1169
|
+
for (const item of key) {
|
1170
1170
|
if (Array.isArray(item)) {
|
1171
1171
|
if (item.length === 2) {
|
1172
1172
|
const [k, v] = item;
|
@@ -1177,14 +1177,14 @@ var EnvImpl = class {
|
|
1177
1177
|
}
|
1178
1178
|
}
|
1179
1179
|
} else {
|
1180
|
-
if (isIterable(
|
1181
|
-
for (const [k, v] of
|
1180
|
+
if (isIterable(key)) {
|
1181
|
+
for (const [k, v] of key) {
|
1182
1182
|
if (typeof k === "string" && typeof v === "string") {
|
1183
1183
|
this.set(k, v);
|
1184
1184
|
}
|
1185
1185
|
}
|
1186
1186
|
} else {
|
1187
|
-
const rKey =
|
1187
|
+
const rKey = key;
|
1188
1188
|
for (const k in rKey) {
|
1189
1189
|
const v = rKey[k];
|
1190
1190
|
if (typeof k === "string" && typeof v === "string") {
|
@@ -1199,15 +1199,15 @@ var EnvImpl = class {
|
|
1199
1199
|
if (!presetEnv) {
|
1200
1200
|
return;
|
1201
1201
|
}
|
1202
|
-
for (const [
|
1203
|
-
this._map.set(
|
1202
|
+
for (const [key, value] of presetEnv) {
|
1203
|
+
this._map.set(key, value);
|
1204
1204
|
}
|
1205
1205
|
}
|
1206
|
-
_applyOnSet(onSet,
|
1206
|
+
_applyOnSet(onSet, key, value) {
|
1207
1207
|
onSet.forEach((item) => {
|
1208
1208
|
let keys = [];
|
1209
|
-
if (
|
1210
|
-
keys = [
|
1209
|
+
if (key) {
|
1210
|
+
keys = [key];
|
1211
1211
|
} else {
|
1212
1212
|
keys = this._map.keys();
|
1213
1213
|
}
|
@@ -1221,9 +1221,9 @@ var EnvImpl = class {
|
|
1221
1221
|
return false;
|
1222
1222
|
}).forEach((k) => {
|
1223
1223
|
let v;
|
1224
|
-
if (!
|
1224
|
+
if (!key && !value) {
|
1225
1225
|
v = this._map.get(k);
|
1226
|
-
} else if (
|
1226
|
+
} else if (key && !value) {
|
1227
1227
|
v = void 0;
|
1228
1228
|
} else {
|
1229
1229
|
v = value;
|
@@ -1241,19 +1241,19 @@ var EnvImpl = class {
|
|
1241
1241
|
this._onSet.push(item);
|
1242
1242
|
this._applyOnSet([item]);
|
1243
1243
|
}
|
1244
|
-
get(
|
1245
|
-
return this._map.get(
|
1244
|
+
get(key) {
|
1245
|
+
return this._map.get(key);
|
1246
1246
|
}
|
1247
|
-
set(
|
1247
|
+
set(key, value) {
|
1248
1248
|
if (!value) {
|
1249
1249
|
return;
|
1250
1250
|
}
|
1251
|
-
this._map.set(
|
1252
|
-
this._applyOnSet(this._onSet,
|
1251
|
+
this._map.set(key, value);
|
1252
|
+
this._applyOnSet(this._onSet, key, value);
|
1253
1253
|
}
|
1254
|
-
delete(
|
1255
|
-
this._map.delete(
|
1256
|
-
this._applyOnSet(this._onSet,
|
1254
|
+
delete(key) {
|
1255
|
+
this._map.delete(key);
|
1256
|
+
this._applyOnSet(this._onSet, key);
|
1257
1257
|
}
|
1258
1258
|
};
|
1259
1259
|
|
@@ -1392,18 +1392,25 @@ var WebSystemService = class {
|
|
1392
1392
|
}
|
1393
1393
|
};
|
1394
1394
|
var my = void 0;
|
1395
|
-
function WebSysAbstraction(
|
1395
|
+
function WebSysAbstraction(param2) {
|
1396
1396
|
if (!my) {
|
1397
1397
|
my = new BaseSysAbstraction({
|
1398
|
-
TxtEnDecoder: (
|
1398
|
+
TxtEnDecoder: (param2 == null ? void 0 : param2.TxtEnDecoder) || TxtEnDecoderSingleton(),
|
1399
1399
|
FileSystem: new WebFileService(),
|
1400
1400
|
SystemService: new WebSystemService()
|
1401
1401
|
});
|
1402
1402
|
}
|
1403
|
-
return new WrapperSysAbstraction(my,
|
1403
|
+
return new WrapperSysAbstraction(my, param2);
|
1404
1404
|
}
|
1405
1405
|
|
1406
1406
|
// src/utils/relative-path.ts
|
1407
|
+
var PartType = {
|
1408
|
+
Slash: 1,
|
1409
|
+
Root: 3,
|
1410
|
+
Up: 4,
|
1411
|
+
Noop: 8
|
1412
|
+
// RootUp = 0x8 /* ../ */,
|
1413
|
+
};
|
1407
1414
|
var Path = class {
|
1408
1415
|
constructor(parts = []) {
|
1409
1416
|
this.parts = parts;
|
@@ -1414,10 +1421,10 @@ var Path = class {
|
|
1414
1421
|
return part;
|
1415
1422
|
} else {
|
1416
1423
|
switch (part) {
|
1417
|
-
case
|
1418
|
-
case
|
1424
|
+
case PartType.Slash:
|
1425
|
+
case PartType.Root:
|
1419
1426
|
return "/";
|
1420
|
-
case
|
1427
|
+
case PartType.Up:
|
1421
1428
|
return "..";
|
1422
1429
|
default:
|
1423
1430
|
return part;
|
@@ -1426,22 +1433,22 @@ var Path = class {
|
|
1426
1433
|
}).join("");
|
1427
1434
|
}
|
1428
1435
|
add(part) {
|
1429
|
-
if (this.parts.includes(
|
1436
|
+
if (this.parts.includes(PartType.Root) && part === PartType.Root) {
|
1430
1437
|
throw new Error("Cannot add absolute part to absolute path");
|
1431
1438
|
}
|
1432
1439
|
const last = this.parts[this.parts.length - 1];
|
1433
|
-
if (last &
|
1440
|
+
if (last & PartType.Slash && part === PartType.Slash) {
|
1434
1441
|
return;
|
1435
1442
|
}
|
1436
1443
|
switch (part) {
|
1437
1444
|
case ".":
|
1438
|
-
this.parts.push(
|
1445
|
+
this.parts.push(PartType.Noop);
|
1439
1446
|
return;
|
1440
1447
|
case "..":
|
1441
|
-
part =
|
1448
|
+
part = PartType.Up;
|
1442
1449
|
}
|
1443
|
-
if (last ===
|
1444
|
-
if (last ===
|
1450
|
+
if (last === PartType.Noop && part === PartType.Slash) {
|
1451
|
+
if (last === PartType.Noop) {
|
1445
1452
|
this.parts.pop();
|
1446
1453
|
}
|
1447
1454
|
return;
|
@@ -1457,9 +1464,9 @@ function splitPath(path) {
|
|
1457
1464
|
for (let count = 0; path.length; count++) {
|
1458
1465
|
if (path.match(/^\/+/)) {
|
1459
1466
|
if (count === 0) {
|
1460
|
-
p.add(
|
1467
|
+
p.add(PartType.Root);
|
1461
1468
|
} else {
|
1462
|
-
p.add(
|
1469
|
+
p.add(PartType.Slash);
|
1463
1470
|
}
|
1464
1471
|
path = path.replace(/^\/+/, "");
|
1465
1472
|
} else {
|
@@ -1493,7 +1500,7 @@ function pathJoin(...paths) {
|
|
1493
1500
|
function relativePath(path, relative) {
|
1494
1501
|
const relativeParts = splitPath(relative);
|
1495
1502
|
let result;
|
1496
|
-
if (relativeParts.parts[0] ===
|
1503
|
+
if (relativeParts.parts[0] === PartType.Root) {
|
1497
1504
|
result = relative;
|
1498
1505
|
} else {
|
1499
1506
|
result = pathJoin(path, relative);
|
@@ -1503,13 +1510,13 @@ function relativePath(path, relative) {
|
|
1503
1510
|
let topUp = false;
|
1504
1511
|
for (const part of unoptPath.parts) {
|
1505
1512
|
switch (part) {
|
1506
|
-
case
|
1507
|
-
out.push(
|
1513
|
+
case PartType.Root:
|
1514
|
+
out.push(PartType.Root);
|
1508
1515
|
break;
|
1509
|
-
case
|
1516
|
+
case PartType.Up:
|
1510
1517
|
if (out.length && !topUp) {
|
1511
1518
|
const last = out.length - 1;
|
1512
|
-
if (typeof out[last] === "string" && out[last - 1] ==
|
1519
|
+
if (typeof out[last] === "string" && out[last - 1] == PartType.Root) {
|
1513
1520
|
out.pop();
|
1514
1521
|
} else {
|
1515
1522
|
out.pop();
|
@@ -1517,15 +1524,15 @@ function relativePath(path, relative) {
|
|
1517
1524
|
}
|
1518
1525
|
if (out.length === 0) {
|
1519
1526
|
topUp = !topUp ? true : topUp;
|
1520
|
-
out.push(
|
1527
|
+
out.push(PartType.Up);
|
1521
1528
|
}
|
1522
1529
|
} else {
|
1523
|
-
out.push(
|
1530
|
+
out.push(PartType.Up);
|
1524
1531
|
}
|
1525
1532
|
break;
|
1526
|
-
case
|
1527
|
-
if (!(out[out.length - 1] &
|
1528
|
-
out.push(
|
1533
|
+
case PartType.Slash:
|
1534
|
+
if (!(out[out.length - 1] & PartType.Slash)) {
|
1535
|
+
out.push(PartType.Slash);
|
1529
1536
|
}
|
1530
1537
|
break;
|
1531
1538
|
default:
|
@@ -1556,37 +1563,37 @@ function localStripper(path, restrips, obj) {
|
|
1556
1563
|
return obj.map((i) => localStripper(path, restrips, i));
|
1557
1564
|
}
|
1558
1565
|
const ret = { ...obj };
|
1559
|
-
const matcher = (
|
1566
|
+
const matcher = (key, nextPath) => {
|
1560
1567
|
for (const re of restrips) {
|
1561
|
-
if (re.test(
|
1568
|
+
if (re.test(key) || re.test(nextPath)) {
|
1562
1569
|
return true;
|
1563
1570
|
}
|
1564
1571
|
}
|
1565
1572
|
return false;
|
1566
1573
|
};
|
1567
|
-
for (const
|
1568
|
-
if (Object.prototype.hasOwnProperty.call(ret,
|
1574
|
+
for (const key in ret) {
|
1575
|
+
if (Object.prototype.hasOwnProperty.call(ret, key)) {
|
1569
1576
|
let nextPath;
|
1570
1577
|
if (path) {
|
1571
|
-
nextPath = [path,
|
1578
|
+
nextPath = [path, key].join(".");
|
1572
1579
|
} else {
|
1573
|
-
nextPath =
|
1580
|
+
nextPath = key;
|
1574
1581
|
}
|
1575
|
-
if (matcher(
|
1576
|
-
delete ret[
|
1582
|
+
if (matcher(key, nextPath)) {
|
1583
|
+
delete ret[key];
|
1577
1584
|
continue;
|
1578
1585
|
}
|
1579
|
-
if (typeof ret[
|
1580
|
-
if (Array.isArray(ret[
|
1581
|
-
ret[
|
1582
|
-
const toDelete = matcher(
|
1586
|
+
if (typeof ret[key] === "object") {
|
1587
|
+
if (Array.isArray(ret[key])) {
|
1588
|
+
ret[key] = ret[key].reduce((acc, v, i) => {
|
1589
|
+
const toDelete = matcher(key, `${nextPath}[${i}]`);
|
1583
1590
|
if (!toDelete) {
|
1584
1591
|
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
1585
1592
|
}
|
1586
1593
|
return acc;
|
1587
1594
|
}, []);
|
1588
1595
|
} else {
|
1589
|
-
ret[
|
1596
|
+
ret[key] = localStripper(nextPath, restrips, ret[key]);
|
1590
1597
|
}
|
1591
1598
|
}
|
1592
1599
|
}
|
@@ -1595,16 +1602,15 @@ function localStripper(path, restrips, obj) {
|
|
1595
1602
|
}
|
1596
1603
|
|
1597
1604
|
// src/uri.ts
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
const keys = Object.keys(key2);
|
1605
|
+
function coerceKey(key, def) {
|
1606
|
+
if (typeof key === "object") {
|
1607
|
+
const keys = Object.keys(key);
|
1602
1608
|
if (keys.length !== 1) {
|
1603
|
-
throw new Error(`Invalid key: ${JSON.stringify(
|
1609
|
+
throw new Error(`Invalid key: ${JSON.stringify(key)}`);
|
1604
1610
|
}
|
1605
|
-
return { key: keys[0], def:
|
1611
|
+
return { key: keys[0], def: key[keys[0]] };
|
1606
1612
|
}
|
1607
|
-
return { key
|
1613
|
+
return { key, def };
|
1608
1614
|
}
|
1609
1615
|
function falsy2undef(value) {
|
1610
1616
|
return value === void 0 || value === null ? void 0 : value;
|
@@ -1707,8 +1713,8 @@ var MutableURL = class _MutableURL extends URL {
|
|
1707
1713
|
toString() {
|
1708
1714
|
let search = "";
|
1709
1715
|
if (this._sysURL.searchParams.size) {
|
1710
|
-
for (const [
|
1711
|
-
search += `${!search.length ? "?" : "&"}${
|
1716
|
+
for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
1717
|
+
search += `${!search.length ? "?" : "&"}${key}=${encodeURIComponent(value)}`;
|
1712
1718
|
}
|
1713
1719
|
}
|
1714
1720
|
let hostpart = "";
|
@@ -1743,11 +1749,11 @@ function from(fac, strURLUri, defaultProtocol) {
|
|
1743
1749
|
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
1744
1750
|
}
|
1745
1751
|
}
|
1746
|
-
function getParamResult(
|
1747
|
-
return `missing parameter: ${
|
1752
|
+
function getParamResult(key, val, msgFn = (key2) => {
|
1753
|
+
return `missing parameter: ${key2}`;
|
1748
1754
|
}) {
|
1749
1755
|
if (val === void 0) {
|
1750
|
-
return Result.Err(msgFn(
|
1756
|
+
return Result.Err(msgFn(key));
|
1751
1757
|
}
|
1752
1758
|
return Result.Ok(val);
|
1753
1759
|
}
|
@@ -1804,47 +1810,47 @@ var BuildURI = class _BuildURI {
|
|
1804
1810
|
const pathname = "./" + appendUrl.pathname;
|
1805
1811
|
const basePath = this._url.pathname;
|
1806
1812
|
this.pathname(relativePath(basePath, pathname));
|
1807
|
-
for (const [
|
1808
|
-
this.setParam(
|
1813
|
+
for (const [key, value] of appendUrl.getParams) {
|
1814
|
+
this.setParam(key, value);
|
1809
1815
|
}
|
1810
1816
|
return this;
|
1811
1817
|
}
|
1812
1818
|
cleanParams() {
|
1813
|
-
for (const
|
1814
|
-
this._url.searchParams.delete(
|
1819
|
+
for (const key of Array.from(this._url.searchParams.keys())) {
|
1820
|
+
this._url.searchParams.delete(key);
|
1815
1821
|
}
|
1816
1822
|
return this;
|
1817
1823
|
}
|
1818
|
-
delParam(
|
1819
|
-
this._url.searchParams.delete(
|
1824
|
+
delParam(key) {
|
1825
|
+
this._url.searchParams.delete(key);
|
1820
1826
|
return this;
|
1821
1827
|
}
|
1822
|
-
defParam(
|
1823
|
-
if (!this._url.searchParams.has(
|
1824
|
-
this._url.searchParams.set(
|
1828
|
+
defParam(key, str) {
|
1829
|
+
if (!this._url.searchParams.has(key)) {
|
1830
|
+
this._url.searchParams.set(key, str);
|
1825
1831
|
}
|
1826
1832
|
return this;
|
1827
1833
|
}
|
1828
|
-
setParam(
|
1829
|
-
this._url.searchParams.set(
|
1834
|
+
setParam(key, str) {
|
1835
|
+
this._url.searchParams.set(key, str);
|
1830
1836
|
return this;
|
1831
1837
|
}
|
1832
|
-
hasParam(
|
1833
|
-
return this._url.searchParams.has(
|
1838
|
+
hasParam(key) {
|
1839
|
+
return this._url.searchParams.has(key);
|
1834
1840
|
}
|
1835
1841
|
get getParams() {
|
1836
1842
|
return this._url.searchParams.entries();
|
1837
1843
|
}
|
1838
|
-
getParam(
|
1839
|
-
const { key: k, def: d } = coerceKey(
|
1844
|
+
getParam(key, def) {
|
1845
|
+
const { key: k, def: d } = coerceKey(key, def);
|
1840
1846
|
let val = this._url.searchParams.get(k);
|
1841
1847
|
if (!falsy2undef(val) && d) {
|
1842
1848
|
val = d;
|
1843
1849
|
}
|
1844
1850
|
return falsy2undef(val);
|
1845
1851
|
}
|
1846
|
-
getParamResult(
|
1847
|
-
return getParamResult(
|
1852
|
+
getParamResult(key, msgFn) {
|
1853
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
1848
1854
|
}
|
1849
1855
|
getParamsResult(...keys) {
|
1850
1856
|
return getParamsResult(keys, this);
|
@@ -1905,8 +1911,8 @@ var URI = class _URI {
|
|
1905
1911
|
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
1906
1912
|
intoUrl.pathname(fromUrl.pathname);
|
1907
1913
|
}
|
1908
|
-
for (const [
|
1909
|
-
intoUrl.setParam(
|
1914
|
+
for (const [key, value] of fromUrl.getParams) {
|
1915
|
+
intoUrl.setParam(key, value);
|
1910
1916
|
}
|
1911
1917
|
return intoUrl.URI();
|
1912
1918
|
}
|
@@ -1959,19 +1965,19 @@ var URI = class _URI {
|
|
1959
1965
|
get getParams() {
|
1960
1966
|
return this._url.searchParams.entries();
|
1961
1967
|
}
|
1962
|
-
hasParam(
|
1963
|
-
return this._url.searchParams.has(
|
1968
|
+
hasParam(key) {
|
1969
|
+
return this._url.searchParams.has(key);
|
1964
1970
|
}
|
1965
|
-
getParam(
|
1966
|
-
const { key: k, def: d } = coerceKey(
|
1971
|
+
getParam(key, def) {
|
1972
|
+
const { key: k, def: d } = coerceKey(key, def);
|
1967
1973
|
let val = this._url.searchParams.get(k);
|
1968
1974
|
if (!falsy2undef(val) && d) {
|
1969
1975
|
val = d;
|
1970
1976
|
}
|
1971
1977
|
return falsy2undef(val);
|
1972
1978
|
}
|
1973
|
-
getParamResult(
|
1974
|
-
return getParamResult(
|
1979
|
+
getParamResult(key, msgFn) {
|
1980
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
1975
1981
|
}
|
1976
1982
|
getParamsResult(...keys) {
|
1977
1983
|
return getParamsResult(keys, this);
|
@@ -2175,7 +2181,7 @@ var None = class extends Option {
|
|
2175
2181
|
// src/log-level-impl.ts
|
2176
2182
|
var LevelHandlerImpl = class {
|
2177
2183
|
constructor() {
|
2178
|
-
this._globalLevels = /* @__PURE__ */ new Set([
|
2184
|
+
this._globalLevels = /* @__PURE__ */ new Set([Level.INFO, Level.ERROR, Level.WARN]);
|
2179
2185
|
this._modules = /* @__PURE__ */ new Map();
|
2180
2186
|
this.ignoreAttr = Option.Some(/^_/);
|
2181
2187
|
this.isStackExposed = false;
|
@@ -2225,9 +2231,9 @@ var LevelHandlerImpl = class {
|
|
2225
2231
|
}
|
2226
2232
|
setDebug(...modules) {
|
2227
2233
|
this.forModules(
|
2228
|
-
|
2234
|
+
Level.DEBUG,
|
2229
2235
|
(p) => {
|
2230
|
-
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels,
|
2236
|
+
this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, Level.DEBUG]));
|
2231
2237
|
},
|
2232
2238
|
...modules
|
2233
2239
|
);
|
@@ -2380,9 +2386,9 @@ var LoggerImpl = class _LoggerImpl {
|
|
2380
2386
|
this.levelHandler.disableLevel(level, ...modules);
|
2381
2387
|
return this;
|
2382
2388
|
}
|
2383
|
-
Module(
|
2384
|
-
this._attributes["module"] = logValue(
|
2385
|
-
this._withAttributes["module"] = logValue(
|
2389
|
+
Module(key) {
|
2390
|
+
this._attributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
|
2391
|
+
this._withAttributes["module"] = logValue(key, toLogValueCtx(this.levelHandler));
|
2386
2392
|
return this;
|
2387
2393
|
}
|
2388
2394
|
// if the string is "*" it will enable for all modules
|
@@ -2403,30 +2409,30 @@ var LoggerImpl = class _LoggerImpl {
|
|
2403
2409
|
return this;
|
2404
2410
|
}
|
2405
2411
|
Warn() {
|
2406
|
-
this._attributes["level"] = logValue(
|
2412
|
+
this._attributes["level"] = logValue(Level.WARN, toLogValueCtx(this.levelHandler));
|
2407
2413
|
return this;
|
2408
2414
|
}
|
2409
2415
|
Log() {
|
2410
2416
|
return this;
|
2411
2417
|
}
|
2412
2418
|
Debug() {
|
2413
|
-
this._attributes["level"] = logValue(
|
2419
|
+
this._attributes["level"] = logValue(Level.DEBUG, toLogValueCtx(this.levelHandler));
|
2414
2420
|
return this;
|
2415
2421
|
}
|
2416
2422
|
Error() {
|
2417
|
-
this._attributes["level"] = logValue(
|
2423
|
+
this._attributes["level"] = logValue(Level.ERROR, toLogValueCtx(this.levelHandler));
|
2418
2424
|
return this;
|
2419
2425
|
}
|
2420
2426
|
Info() {
|
2421
|
-
this._attributes["level"] = logValue(
|
2427
|
+
this._attributes["level"] = logValue(Level.INFO, toLogValueCtx(this.levelHandler));
|
2422
2428
|
return this;
|
2423
2429
|
}
|
2424
2430
|
Err(err) {
|
2425
2431
|
var _a;
|
2426
|
-
let
|
2432
|
+
let key = "error";
|
2427
2433
|
if (Result.Is(err)) {
|
2428
2434
|
if (err.isOk()) {
|
2429
|
-
|
2435
|
+
key = "noerror";
|
2430
2436
|
err = err.Ok();
|
2431
2437
|
} else {
|
2432
2438
|
err = err.Err();
|
@@ -2434,12 +2440,12 @@ var LoggerImpl = class _LoggerImpl {
|
|
2434
2440
|
}
|
2435
2441
|
if (err instanceof Error) {
|
2436
2442
|
if (err.cause) {
|
2437
|
-
this.coerceKey(
|
2443
|
+
this.coerceKey(key, {
|
2438
2444
|
message: err.message,
|
2439
2445
|
cause: err.cause
|
2440
2446
|
});
|
2441
2447
|
} else {
|
2442
|
-
this._attributes[
|
2448
|
+
this._attributes[key] = logValue(err.message, toLogValueCtx(this.levelHandler));
|
2443
2449
|
}
|
2444
2450
|
if (this.levelHandler.isStackExposed) {
|
2445
2451
|
this._attributes["stack"] = logValue(
|
@@ -2448,7 +2454,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2448
2454
|
);
|
2449
2455
|
}
|
2450
2456
|
} else {
|
2451
|
-
this.Any(
|
2457
|
+
this.Any(key, err);
|
2452
2458
|
}
|
2453
2459
|
return this;
|
2454
2460
|
}
|
@@ -2456,22 +2462,22 @@ var LoggerImpl = class _LoggerImpl {
|
|
2456
2462
|
this._attributes["level"] = logValue(l, toLogValueCtx(this.levelHandler));
|
2457
2463
|
return this;
|
2458
2464
|
}
|
2459
|
-
Ref(
|
2465
|
+
Ref(key, action) {
|
2460
2466
|
if (typeof action === "function") {
|
2461
|
-
this._attributes[
|
2467
|
+
this._attributes[key] = logValue(action, toLogValueCtx(this.levelHandler));
|
2462
2468
|
} else if (typeof action.toString === "function") {
|
2463
|
-
this._attributes[
|
2469
|
+
this._attributes[key] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));
|
2464
2470
|
} else {
|
2465
|
-
this._attributes[
|
2471
|
+
this._attributes[key] = logValue("INVALID REF", toLogValueCtx(this.levelHandler));
|
2466
2472
|
}
|
2467
2473
|
return this;
|
2468
2474
|
}
|
2469
|
-
Bool(
|
2470
|
-
this.coerceKey(
|
2475
|
+
Bool(key, value) {
|
2476
|
+
this.coerceKey(key, !!value);
|
2471
2477
|
return this;
|
2472
2478
|
}
|
2473
2479
|
Http(...mix) {
|
2474
|
-
const
|
2480
|
+
const key = mix.find((x) => typeof x === "string");
|
2475
2481
|
mix = mix.filter((x) => typeof x !== "string");
|
2476
2482
|
const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
|
2477
2483
|
if (resErrors.length) {
|
@@ -2491,70 +2497,70 @@ var LoggerImpl = class _LoggerImpl {
|
|
2491
2497
|
reqAndOrres = req;
|
2492
2498
|
}
|
2493
2499
|
if (reqAndOrres) {
|
2494
|
-
this.Any(
|
2500
|
+
this.Any(key || "Http", reqAndOrres);
|
2495
2501
|
}
|
2496
2502
|
return this;
|
2497
2503
|
}
|
2498
2504
|
Pair(x) {
|
2499
|
-
for (const
|
2500
|
-
const value = x[
|
2505
|
+
for (const key of Object.keys(x)) {
|
2506
|
+
const value = x[key];
|
2501
2507
|
if (value instanceof LogValue) {
|
2502
|
-
this._attributes[
|
2508
|
+
this._attributes[key] = value;
|
2503
2509
|
continue;
|
2504
2510
|
}
|
2505
2511
|
if (Result.Is(value)) {
|
2506
|
-
this.Result(
|
2512
|
+
this.Result(key, value);
|
2507
2513
|
continue;
|
2508
2514
|
}
|
2509
|
-
this.Any(
|
2515
|
+
this.Any(key, value);
|
2510
2516
|
}
|
2511
2517
|
return this;
|
2512
2518
|
}
|
2513
|
-
Result(
|
2519
|
+
Result(key, res) {
|
2514
2520
|
if (res.isOk()) {
|
2515
|
-
this._attributes[
|
2521
|
+
this._attributes[key] = logValue(res.Ok(), toLogValueCtx(this.levelHandler));
|
2516
2522
|
} else {
|
2517
2523
|
this.Err(res.Err());
|
2518
2524
|
}
|
2519
2525
|
return this;
|
2520
2526
|
}
|
2521
|
-
Len(value,
|
2522
|
-
this._attributes[
|
2527
|
+
Len(value, key = "len") {
|
2528
|
+
this._attributes[key] = getLen(value, toLogValueCtx(this.levelHandler));
|
2523
2529
|
return this;
|
2524
2530
|
}
|
2525
2531
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2526
|
-
Hash(value,
|
2532
|
+
Hash(value, key = "hash") {
|
2527
2533
|
throw new Error("Not implemented");
|
2528
2534
|
}
|
2529
|
-
Url(url,
|
2530
|
-
this.Ref(
|
2535
|
+
Url(url, key = "url") {
|
2536
|
+
this.Ref(key, () => URI.from(url).toString());
|
2531
2537
|
return this;
|
2532
2538
|
}
|
2533
|
-
coerceKey(
|
2534
|
-
if (typeof
|
2535
|
-
this._attributes[
|
2539
|
+
coerceKey(key, value) {
|
2540
|
+
if (typeof key === "string") {
|
2541
|
+
this._attributes[key] = logValue(value, toLogValueCtx(this.levelHandler));
|
2536
2542
|
} else {
|
2537
|
-
this.Pair(
|
2543
|
+
this.Pair(key);
|
2538
2544
|
}
|
2539
2545
|
}
|
2540
|
-
Str(
|
2541
|
-
this.coerceKey(
|
2546
|
+
Str(key, value) {
|
2547
|
+
this.coerceKey(key, value);
|
2542
2548
|
return this;
|
2543
2549
|
}
|
2544
|
-
Any(
|
2545
|
-
this.coerceKey(
|
2550
|
+
Any(key, value) {
|
2551
|
+
this.coerceKey(key, value);
|
2546
2552
|
return this;
|
2547
2553
|
}
|
2548
|
-
Dur(
|
2549
|
-
this._attributes[
|
2554
|
+
Dur(key, nsec) {
|
2555
|
+
this._attributes[key] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));
|
2550
2556
|
return this;
|
2551
2557
|
}
|
2552
|
-
Uint64(
|
2553
|
-
this.coerceKey(
|
2558
|
+
Uint64(key, value) {
|
2559
|
+
this.coerceKey(key, value);
|
2554
2560
|
return this;
|
2555
2561
|
}
|
2556
|
-
Int(
|
2557
|
-
return this.Uint64(
|
2562
|
+
Int(key, value) {
|
2563
|
+
return this.Uint64(key, value);
|
2558
2564
|
}
|
2559
2565
|
async Flush() {
|
2560
2566
|
return new Promise((resolve) => {
|
@@ -2577,8 +2583,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
2577
2583
|
}
|
2578
2584
|
_resetAttributes(fn) {
|
2579
2585
|
const ret = fn();
|
2580
|
-
Object.keys(this._attributes).forEach((
|
2581
|
-
delete this._attributes[
|
2586
|
+
Object.keys(this._attributes).forEach((key) => {
|
2587
|
+
delete this._attributes[key];
|
2582
2588
|
});
|
2583
2589
|
Object.assign(this._attributes, this._withAttributes);
|
2584
2590
|
return ret;
|
@@ -2645,8 +2651,8 @@ var WithLoggerBuilder = class {
|
|
2645
2651
|
this._li.levelHandler.enableLevel(level, ...modules);
|
2646
2652
|
return this;
|
2647
2653
|
}
|
2648
|
-
Module(
|
2649
|
-
this._li.Module(
|
2654
|
+
Module(key) {
|
2655
|
+
this._li.Module(key);
|
2650
2656
|
return this;
|
2651
2657
|
}
|
2652
2658
|
SetDebug(...modules) {
|
@@ -2661,36 +2667,36 @@ var WithLoggerBuilder = class {
|
|
2661
2667
|
this._li.Pair(x);
|
2662
2668
|
return this;
|
2663
2669
|
}
|
2664
|
-
Str(
|
2665
|
-
this._li.Str(
|
2670
|
+
Str(key, value) {
|
2671
|
+
this._li.Str(key, value);
|
2666
2672
|
return this;
|
2667
2673
|
}
|
2668
|
-
Len(value,
|
2669
|
-
this._li.Len(value,
|
2674
|
+
Len(value, key) {
|
2675
|
+
this._li.Len(value, key);
|
2670
2676
|
return this;
|
2671
2677
|
}
|
2672
|
-
Hash(value,
|
2673
|
-
this._li.Hash(value,
|
2678
|
+
Hash(value, key) {
|
2679
|
+
this._li.Hash(value, key);
|
2674
2680
|
return this;
|
2675
2681
|
}
|
2676
|
-
Ref(
|
2677
|
-
this._li.Ref(
|
2682
|
+
Ref(key, action) {
|
2683
|
+
this._li.Ref(key, action);
|
2678
2684
|
return this;
|
2679
2685
|
}
|
2680
|
-
Bool(
|
2681
|
-
this._li.Bool(
|
2686
|
+
Bool(key, value) {
|
2687
|
+
this._li.Bool(key, value);
|
2682
2688
|
return this;
|
2683
2689
|
}
|
2684
|
-
Result(
|
2685
|
-
this._li.Result(
|
2690
|
+
Result(key, res) {
|
2691
|
+
this._li.Result(key, res);
|
2686
2692
|
return this;
|
2687
2693
|
}
|
2688
|
-
Url(url,
|
2689
|
-
this._li.Url(url,
|
2694
|
+
Url(url, key) {
|
2695
|
+
this._li.Url(url, key);
|
2690
2696
|
return this;
|
2691
2697
|
}
|
2692
|
-
Int(
|
2693
|
-
this._li.Int(
|
2698
|
+
Int(key, value) {
|
2699
|
+
this._li.Int(key, value);
|
2694
2700
|
return this;
|
2695
2701
|
}
|
2696
2702
|
Log() {
|
@@ -2725,16 +2731,16 @@ var WithLoggerBuilder = class {
|
|
2725
2731
|
this._li.Timestamp();
|
2726
2732
|
return this;
|
2727
2733
|
}
|
2728
|
-
Any(
|
2729
|
-
this._li.Any(
|
2734
|
+
Any(key, value) {
|
2735
|
+
this._li.Any(key, value);
|
2730
2736
|
return this;
|
2731
2737
|
}
|
2732
|
-
Dur(
|
2733
|
-
this._li.Dur(
|
2738
|
+
Dur(key, nsec) {
|
2739
|
+
this._li.Dur(key, nsec);
|
2734
2740
|
return this;
|
2735
2741
|
}
|
2736
|
-
Uint64(
|
2737
|
-
this._li.Uint64(
|
2742
|
+
Uint64(key, value) {
|
2743
|
+
this._li.Uint64(key, value);
|
2738
2744
|
return this;
|
2739
2745
|
}
|
2740
2746
|
};
|
@@ -2899,8 +2905,8 @@ var Metrics = class {
|
|
2899
2905
|
}
|
2900
2906
|
toJSON() {
|
2901
2907
|
const obj = {};
|
2902
|
-
for (const [
|
2903
|
-
obj[
|
2908
|
+
for (const [key, value] of this.map) {
|
2909
|
+
obj[key] = value.value;
|
2904
2910
|
}
|
2905
2911
|
return obj;
|
2906
2912
|
}
|
@@ -3073,15 +3079,15 @@ var HeadersImpl = class extends Headers {
|
|
3073
3079
|
values() {
|
3074
3080
|
return this._headers.values();
|
3075
3081
|
}
|
3076
|
-
append(
|
3077
|
-
const values = this._headers.get(
|
3082
|
+
append(key, value) {
|
3083
|
+
const values = this._headers.get(key);
|
3078
3084
|
if (typeof value === "undefined") {
|
3079
3085
|
value = "";
|
3080
3086
|
}
|
3081
3087
|
if (Array.isArray(value)) {
|
3082
|
-
this._headers.set(
|
3088
|
+
this._headers.set(key, [values, ...value].filter((i) => i).join(", "));
|
3083
3089
|
} else {
|
3084
|
-
this._headers.set(
|
3090
|
+
this._headers.set(key, [values, value].filter((i) => i).join(", "));
|
3085
3091
|
}
|
3086
3092
|
return this;
|
3087
3093
|
}
|
@@ -3124,38 +3130,38 @@ var HttpHeader = class _HttpHeader {
|
|
3124
3130
|
}
|
3125
3131
|
_asStringString() {
|
3126
3132
|
const ret = /* @__PURE__ */ new Map();
|
3127
|
-
for (const [
|
3128
|
-
ret.set(
|
3133
|
+
for (const [key, values] of this._headers) {
|
3134
|
+
ret.set(key, values.join(", "));
|
3129
3135
|
}
|
3130
3136
|
return ret;
|
3131
3137
|
}
|
3132
|
-
_key(
|
3133
|
-
return
|
3138
|
+
_key(key) {
|
3139
|
+
return key.toLowerCase();
|
3134
3140
|
}
|
3135
|
-
Values(
|
3136
|
-
const values = this._headers.get(this._key(
|
3141
|
+
Values(key) {
|
3142
|
+
const values = this._headers.get(this._key(key));
|
3137
3143
|
return values || [];
|
3138
3144
|
}
|
3139
|
-
Get(
|
3140
|
-
const values = this._headers.get(this._key(
|
3145
|
+
Get(key) {
|
3146
|
+
const values = this._headers.get(this._key(key));
|
3141
3147
|
if (values === void 0 || values.length === 0) {
|
3142
3148
|
return void 0;
|
3143
3149
|
}
|
3144
3150
|
return values[0];
|
3145
3151
|
}
|
3146
|
-
Set(
|
3152
|
+
Set(key, valueOr) {
|
3147
3153
|
const value = Array.isArray(valueOr) ? valueOr : [valueOr];
|
3148
|
-
this._headers.set(this._key(
|
3154
|
+
this._headers.set(this._key(key), value);
|
3149
3155
|
return this;
|
3150
3156
|
}
|
3151
|
-
Add(
|
3157
|
+
Add(key, value) {
|
3152
3158
|
if (typeof value === "undefined") {
|
3153
3159
|
return this;
|
3154
3160
|
}
|
3155
3161
|
const vs = Array.isArray(value) ? value : [value];
|
3156
|
-
const values = this._headers.get(this._key(
|
3162
|
+
const values = this._headers.get(this._key(key));
|
3157
3163
|
if (values === void 0) {
|
3158
|
-
this._headers.set(this._key(
|
3164
|
+
this._headers.set(this._key(key), vs);
|
3159
3165
|
} else {
|
3160
3166
|
values.push(...vs);
|
3161
3167
|
}
|
@@ -3173,29 +3179,29 @@ var HttpHeader = class _HttpHeader {
|
|
3173
3179
|
}
|
3174
3180
|
Clone() {
|
3175
3181
|
const clone = new _HttpHeader();
|
3176
|
-
for (const [
|
3177
|
-
clone._headers.set(
|
3182
|
+
for (const [key, values] of this._headers.entries()) {
|
3183
|
+
clone._headers.set(key, values.slice());
|
3178
3184
|
}
|
3179
3185
|
return clone;
|
3180
3186
|
}
|
3181
3187
|
AsRecordStringStringArray() {
|
3182
3188
|
const obj = {};
|
3183
|
-
for (const [
|
3184
|
-
obj[
|
3189
|
+
for (const [key, values] of this._headers.entries()) {
|
3190
|
+
obj[key] = [...values];
|
3185
3191
|
}
|
3186
3192
|
return obj;
|
3187
3193
|
}
|
3188
3194
|
AsRecordStringString() {
|
3189
3195
|
const obj = {};
|
3190
|
-
for (const [
|
3191
|
-
obj[
|
3196
|
+
for (const [key, values] of this._headers.entries()) {
|
3197
|
+
obj[key] = values.join(", ");
|
3192
3198
|
}
|
3193
3199
|
return obj;
|
3194
3200
|
}
|
3195
3201
|
AsHeaderInit() {
|
3196
3202
|
const obj = {};
|
3197
|
-
for (const [
|
3198
|
-
obj[
|
3203
|
+
for (const [key, values] of this._headers.entries()) {
|
3204
|
+
obj[key] = values[0];
|
3199
3205
|
}
|
3200
3206
|
return obj;
|
3201
3207
|
}
|
@@ -3205,8 +3211,8 @@ var HttpHeader = class _HttpHeader {
|
|
3205
3211
|
Merge(other) {
|
3206
3212
|
const ret = this.Clone();
|
3207
3213
|
if (other) {
|
3208
|
-
for (const [
|
3209
|
-
ret.Add(
|
3214
|
+
for (const [key, values] of other.Items()) {
|
3215
|
+
ret.Add(key, values);
|
3210
3216
|
}
|
3211
3217
|
}
|
3212
3218
|
return ret;
|
@@ -3287,6 +3293,57 @@ function JSONEnDecoderSingleton(txtEnde) {
|
|
3287
3293
|
return jsonEnDecoder;
|
3288
3294
|
}
|
3289
3295
|
|
3296
|
+
// src/lru-cache.ts
|
3297
|
+
var LRUCache = class {
|
3298
|
+
constructor(c = {}) {
|
3299
|
+
this.cache = /* @__PURE__ */ new Map();
|
3300
|
+
this.param = {
|
3301
|
+
maxEntries: c.maxEntries || 100,
|
3302
|
+
maxAge: c.maxAge || 0
|
3303
|
+
};
|
3304
|
+
}
|
3305
|
+
touch(key) {
|
3306
|
+
const value = this.cache.get(key);
|
3307
|
+
this.cache.delete(key);
|
3308
|
+
this.cache.set(key, value);
|
3309
|
+
return value;
|
3310
|
+
}
|
3311
|
+
get size() {
|
3312
|
+
return this.cache.size;
|
3313
|
+
}
|
3314
|
+
async getPut(key, createFN) {
|
3315
|
+
const val = this.get(key);
|
3316
|
+
if (val) {
|
3317
|
+
return val;
|
3318
|
+
} else {
|
3319
|
+
const val2 = await createFN(key);
|
3320
|
+
this.put(key, val2);
|
3321
|
+
return val2;
|
3322
|
+
}
|
3323
|
+
}
|
3324
|
+
get(key) {
|
3325
|
+
if (this.cache.has(key)) {
|
3326
|
+
return this.touch(key);
|
3327
|
+
}
|
3328
|
+
return this.cache.get(key);
|
3329
|
+
}
|
3330
|
+
put(key, value) {
|
3331
|
+
this.cache.delete(key);
|
3332
|
+
if (this.cache.size >= this.param.maxEntries) {
|
3333
|
+
this.cache.delete(this.cache.keys().next().value);
|
3334
|
+
this.cache.set(key, value);
|
3335
|
+
} else {
|
3336
|
+
this.cache.set(key, value);
|
3337
|
+
}
|
3338
|
+
}
|
3339
|
+
// getLeastRecent(): K {
|
3340
|
+
// return Array.from(this.cache)[0];
|
3341
|
+
// }
|
3342
|
+
// getMostRecent(): K {
|
3343
|
+
// return Array.from(this.cache)[this.cache.size - 1];
|
3344
|
+
// }
|
3345
|
+
};
|
3346
|
+
|
3290
3347
|
// src/utils/index.ts
|
3291
3348
|
var utils_exports = {};
|
3292
3349
|
__export(utils_exports, {
|
@@ -3299,7 +3356,6 @@ __export(utils_exports, {
|
|
3299
3356
|
coerceIntoUint8: () => coerceIntoUint8,
|
3300
3357
|
devnull: () => devnull,
|
3301
3358
|
getParamsResult: () => getParamsResult,
|
3302
|
-
param: () => param,
|
3303
3359
|
rebuffer: () => rebuffer,
|
3304
3360
|
rebufferArray: () => rebufferArray,
|
3305
3361
|
stream2array: () => stream2array,
|
@@ -3524,9 +3580,6 @@ function UInt8ArrayEqual(a, b) {
|
|
3524
3580
|
}
|
3525
3581
|
return true;
|
3526
3582
|
}
|
3527
|
-
|
3528
|
-
// src/index.ts
|
3529
|
-
var param2 = param;
|
3530
3583
|
// Annotate the CommonJS export names for ESM import in node:
|
3531
3584
|
0 && (module.exports = {
|
3532
3585
|
BaseSysAbstraction,
|
@@ -3544,6 +3597,7 @@ var param2 = param;
|
|
3544
3597
|
Keyed,
|
3545
3598
|
KeyedResolvOnce,
|
3546
3599
|
KeyedResolvSeq,
|
3600
|
+
LRUCache,
|
3547
3601
|
Level,
|
3548
3602
|
LevelHandlerImpl,
|
3549
3603
|
LevelHandlerSingleton,
|
@@ -3586,7 +3640,6 @@ var param2 = param;
|
|
3586
3640
|
hasHostPartProtocols,
|
3587
3641
|
isCoerceURI,
|
3588
3642
|
isURL,
|
3589
|
-
key,
|
3590
3643
|
logValue,
|
3591
3644
|
param,
|
3592
3645
|
pathOps,
|