@adviser/cement 0.2.44 → 0.3.0
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/index.cjs +231 -207
- package/index.cjs.map +1 -1
- package/index.d.cts +14 -4
- package/index.d.ts +14 -4
- package/index.js +181 -157
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/http_header.ts +4 -1
- package/src/jsr.json +1 -1
- package/src/uri.ts +29 -6
- package/ts/http_header.d.ts +1 -1
- package/ts/http_header.d.ts.map +1 -1
- package/ts/http_header.js +3 -0
- package/ts/http_header.js.map +1 -1
- package/ts/http_header.test.js +6 -0
- package/ts/http_header.test.js.map +1 -1
- package/ts/uri.d.ts +12 -2
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +23 -4
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +21 -4
- package/ts/uri.test.js.map +1 -1
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 key2 of __getOwnPropNames(from2))
|
18
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
19
|
+
__defProp(to, key2, { get: () => from2[key2], enumerable: !(desc = __getOwnPropDesc(from2, key2)) || desc.enumerable });
|
20
20
|
}
|
21
21
|
return to;
|
22
22
|
};
|
@@ -65,7 +65,6 @@ __export(src_exports, {
|
|
65
65
|
MutableURL: () => MutableURL,
|
66
66
|
None: () => None,
|
67
67
|
Option: () => Option,
|
68
|
-
REQUIRED: () => REQUIRED,
|
69
68
|
RandomMode: () => RandomMode,
|
70
69
|
RandomService: () => RandomService,
|
71
70
|
ResolveOnce: () => ResolveOnce,
|
@@ -95,6 +94,7 @@ __export(src_exports, {
|
|
95
94
|
exception2Result: () => exception2Result,
|
96
95
|
hasHostPartProtocols: () => hasHostPartProtocols,
|
97
96
|
isURL: () => isURL,
|
97
|
+
key: () => key,
|
98
98
|
logValue: () => logValue,
|
99
99
|
runtimeFn: () => runtimeFn,
|
100
100
|
toCryptoRuntime: () => toCryptoRuntime,
|
@@ -247,16 +247,16 @@ function logValueInternal(val, ctx) {
|
|
247
247
|
}
|
248
248
|
const res = {};
|
249
249
|
const typedVal = val;
|
250
|
-
for (const
|
251
|
-
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(
|
250
|
+
for (const key2 in typedVal) {
|
251
|
+
if (ctx.ignoreAttr.IsSome() && ctx.ignoreAttr.unwrap().test(key2)) {
|
252
252
|
continue;
|
253
253
|
}
|
254
|
-
const element = typedVal[
|
254
|
+
const element = typedVal[key2];
|
255
255
|
if (element instanceof LogValue) {
|
256
|
-
res[
|
256
|
+
res[key2] = element;
|
257
257
|
} else {
|
258
258
|
if (typeof element !== "function") {
|
259
|
-
res[
|
259
|
+
res[key2] = logValueInternal(element, ctx);
|
260
260
|
}
|
261
261
|
}
|
262
262
|
}
|
@@ -663,24 +663,24 @@ var Keyed = class {
|
|
663
663
|
this._map = /* @__PURE__ */ new Map();
|
664
664
|
this.factory = factory;
|
665
665
|
}
|
666
|
-
async asyncGet(
|
667
|
-
return this.get(await
|
666
|
+
async asyncGet(key2) {
|
667
|
+
return this.get(await key2());
|
668
668
|
}
|
669
|
-
get(
|
670
|
-
if (typeof
|
671
|
-
|
669
|
+
get(key2) {
|
670
|
+
if (typeof key2 === "function") {
|
671
|
+
key2 = key2();
|
672
672
|
}
|
673
|
-
let keyed = this._map.get(
|
673
|
+
let keyed = this._map.get(key2);
|
674
674
|
if (!keyed) {
|
675
|
-
keyed = this.factory(
|
676
|
-
this._map.set(
|
675
|
+
keyed = this.factory(key2);
|
676
|
+
this._map.set(key2, keyed);
|
677
677
|
}
|
678
678
|
return keyed;
|
679
679
|
}
|
680
|
-
unget(
|
681
|
-
const keyed = this._map.get(
|
680
|
+
unget(key2) {
|
681
|
+
const keyed = this._map.get(key2);
|
682
682
|
keyed == null ? void 0 : keyed.reset();
|
683
|
-
this._map.delete(
|
683
|
+
this._map.delete(key2);
|
684
684
|
}
|
685
685
|
reset() {
|
686
686
|
this._map.forEach((keyed) => keyed.reset());
|
@@ -689,12 +689,12 @@ var Keyed = class {
|
|
689
689
|
};
|
690
690
|
var KeyedResolvOnce = class extends Keyed {
|
691
691
|
constructor() {
|
692
|
-
super((
|
692
|
+
super((key2) => new ResolveOnce(key2));
|
693
693
|
}
|
694
694
|
};
|
695
695
|
var KeyedResolvSeq = class extends Keyed {
|
696
696
|
constructor() {
|
697
|
-
super((
|
697
|
+
super((key2) => new ResolveSeq(key2));
|
698
698
|
}
|
699
699
|
};
|
700
700
|
|
@@ -715,16 +715,16 @@ var NodeEnvActions = class {
|
|
715
715
|
keys() {
|
716
716
|
return Object.keys(this._env);
|
717
717
|
}
|
718
|
-
get(
|
719
|
-
return this._env[
|
718
|
+
get(key2) {
|
719
|
+
return this._env[key2];
|
720
720
|
}
|
721
|
-
set(
|
721
|
+
set(key2, value) {
|
722
722
|
if (value) {
|
723
|
-
this._env[
|
723
|
+
this._env[key2] = value;
|
724
724
|
}
|
725
725
|
}
|
726
|
-
delete(
|
727
|
-
delete this._env[
|
726
|
+
delete(key2) {
|
727
|
+
delete this._env[key2];
|
728
728
|
}
|
729
729
|
};
|
730
730
|
_node = new WeakMap();
|
@@ -746,16 +746,16 @@ var DenoEnvActions = class {
|
|
746
746
|
keys() {
|
747
747
|
return Array.from(this._env.keys());
|
748
748
|
}
|
749
|
-
get(
|
750
|
-
return this._env.get(
|
749
|
+
get(key2) {
|
750
|
+
return this._env.get(key2);
|
751
751
|
}
|
752
|
-
set(
|
752
|
+
set(key2, value) {
|
753
753
|
if (value) {
|
754
|
-
this._env.set(
|
754
|
+
this._env.set(key2, value);
|
755
755
|
}
|
756
756
|
}
|
757
|
-
delete(
|
758
|
-
this._env.delete(
|
757
|
+
delete(key2) {
|
758
|
+
this._env.delete(key2);
|
759
759
|
}
|
760
760
|
};
|
761
761
|
_deno = new WeakMap();
|
@@ -764,16 +764,16 @@ var BrowserEnvActions = class {
|
|
764
764
|
this.env = /* @__PURE__ */ new Map();
|
765
765
|
this.opts = opts;
|
766
766
|
}
|
767
|
-
get(
|
768
|
-
return this.env.get(
|
767
|
+
get(key2) {
|
768
|
+
return this.env.get(key2);
|
769
769
|
}
|
770
|
-
set(
|
770
|
+
set(key2, value) {
|
771
771
|
if (value) {
|
772
|
-
this.env.set(
|
772
|
+
this.env.set(key2, value);
|
773
773
|
}
|
774
774
|
}
|
775
|
-
delete(
|
776
|
-
this.env.delete(
|
775
|
+
delete(key2) {
|
776
|
+
this.env.delete(key2);
|
777
777
|
}
|
778
778
|
keys() {
|
779
779
|
return Array.from(this.env.keys());
|
@@ -810,15 +810,15 @@ var EnvImpl = class {
|
|
810
810
|
if (!presetEnv) {
|
811
811
|
return;
|
812
812
|
}
|
813
|
-
for (const [
|
814
|
-
this._map.set(
|
813
|
+
for (const [key2, value] of presetEnv) {
|
814
|
+
this._map.set(key2, value);
|
815
815
|
}
|
816
816
|
}
|
817
|
-
_applyOnSet(onSet,
|
817
|
+
_applyOnSet(onSet, key2, value) {
|
818
818
|
onSet.forEach((item) => {
|
819
819
|
let keys = [];
|
820
|
-
if (
|
821
|
-
keys = [
|
820
|
+
if (key2) {
|
821
|
+
keys = [key2];
|
822
822
|
} else {
|
823
823
|
keys = this._map.keys();
|
824
824
|
}
|
@@ -832,9 +832,9 @@ var EnvImpl = class {
|
|
832
832
|
return false;
|
833
833
|
}).forEach((k) => {
|
834
834
|
let v;
|
835
|
-
if (!
|
835
|
+
if (!key2 && !value) {
|
836
836
|
v = this._map.get(k);
|
837
|
-
} else if (
|
837
|
+
} else if (key2 && !value) {
|
838
838
|
v = void 0;
|
839
839
|
} else {
|
840
840
|
v = value;
|
@@ -852,19 +852,19 @@ var EnvImpl = class {
|
|
852
852
|
this._onSet.push(item);
|
853
853
|
this._applyOnSet([item]);
|
854
854
|
}
|
855
|
-
get(
|
856
|
-
return this._map.get(
|
855
|
+
get(key2) {
|
856
|
+
return this._map.get(key2);
|
857
857
|
}
|
858
|
-
set(
|
858
|
+
set(key2, value) {
|
859
859
|
if (!value) {
|
860
860
|
return;
|
861
861
|
}
|
862
|
-
this._map.set(
|
863
|
-
this._applyOnSet(this._onSet,
|
862
|
+
this._map.set(key2, value);
|
863
|
+
this._applyOnSet(this._onSet, key2, value);
|
864
864
|
}
|
865
|
-
delete(
|
866
|
-
this._map.delete(
|
867
|
-
this._applyOnSet(this._onSet,
|
865
|
+
delete(key2) {
|
866
|
+
this._map.delete(key2);
|
867
|
+
this._applyOnSet(this._onSet, key2);
|
868
868
|
}
|
869
869
|
};
|
870
870
|
|
@@ -1202,37 +1202,37 @@ function localStripper(path, restrips, obj) {
|
|
1202
1202
|
return obj.map((i) => localStripper(path, restrips, i));
|
1203
1203
|
}
|
1204
1204
|
const ret = { ...obj };
|
1205
|
-
const matcher = (
|
1205
|
+
const matcher = (key2, nextPath) => {
|
1206
1206
|
for (const re of restrips) {
|
1207
|
-
if (re.test(
|
1207
|
+
if (re.test(key2) || re.test(nextPath)) {
|
1208
1208
|
return true;
|
1209
1209
|
}
|
1210
1210
|
}
|
1211
1211
|
return false;
|
1212
1212
|
};
|
1213
|
-
for (const
|
1214
|
-
if (Object.prototype.hasOwnProperty.call(ret,
|
1213
|
+
for (const key2 in ret) {
|
1214
|
+
if (Object.prototype.hasOwnProperty.call(ret, key2)) {
|
1215
1215
|
let nextPath;
|
1216
1216
|
if (path) {
|
1217
|
-
nextPath = [path,
|
1217
|
+
nextPath = [path, key2].join(".");
|
1218
1218
|
} else {
|
1219
|
-
nextPath =
|
1219
|
+
nextPath = key2;
|
1220
1220
|
}
|
1221
|
-
if (matcher(
|
1222
|
-
delete ret[
|
1221
|
+
if (matcher(key2, nextPath)) {
|
1222
|
+
delete ret[key2];
|
1223
1223
|
continue;
|
1224
1224
|
}
|
1225
|
-
if (typeof ret[
|
1226
|
-
if (Array.isArray(ret[
|
1227
|
-
ret[
|
1228
|
-
const toDelete = matcher(
|
1225
|
+
if (typeof ret[key2] === "object") {
|
1226
|
+
if (Array.isArray(ret[key2])) {
|
1227
|
+
ret[key2] = ret[key2].reduce((acc, v, i) => {
|
1228
|
+
const toDelete = matcher(key2, `${nextPath}[${i}]`);
|
1229
1229
|
if (!toDelete) {
|
1230
1230
|
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
1231
1231
|
}
|
1232
1232
|
return acc;
|
1233
1233
|
}, []);
|
1234
1234
|
} else {
|
1235
|
-
ret[
|
1235
|
+
ret[key2] = localStripper(nextPath, restrips, ret[key2]);
|
1236
1236
|
}
|
1237
1237
|
}
|
1238
1238
|
}
|
@@ -1241,16 +1241,29 @@ function localStripper(path, restrips, obj) {
|
|
1241
1241
|
}
|
1242
1242
|
|
1243
1243
|
// src/uri.ts
|
1244
|
-
var
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1244
|
+
var _REQUIRED = class {
|
1245
|
+
constructor() {
|
1246
|
+
this.val = "REQUIRED";
|
1247
|
+
}
|
1248
|
+
};
|
1249
|
+
var _OPTIONAL = class {
|
1250
|
+
constructor() {
|
1251
|
+
this.val = "OPTIONAL";
|
1252
|
+
}
|
1253
|
+
};
|
1254
|
+
var key = {
|
1255
|
+
REQUIRED: new _REQUIRED(),
|
1256
|
+
OPTIONAL: new _OPTIONAL()
|
1257
|
+
};
|
1258
|
+
function coerceKey(key2, def) {
|
1259
|
+
if (typeof key2 === "object") {
|
1260
|
+
const keys = Object.keys(key2);
|
1248
1261
|
if (keys.length !== 1) {
|
1249
|
-
throw new Error(`Invalid key: ${JSON.stringify(
|
1262
|
+
throw new Error(`Invalid key: ${JSON.stringify(key2)}`);
|
1250
1263
|
}
|
1251
|
-
return { key: keys[0], def:
|
1264
|
+
return { key: keys[0], def: key2[keys[0]] };
|
1252
1265
|
}
|
1253
|
-
return { key, def };
|
1266
|
+
return { key: key2, def };
|
1254
1267
|
}
|
1255
1268
|
function falsy2undef(value) {
|
1256
1269
|
return value === void 0 || value === null ? void 0 : value;
|
@@ -1353,8 +1366,8 @@ var MutableURL = class _MutableURL extends URL {
|
|
1353
1366
|
toString() {
|
1354
1367
|
let search = "";
|
1355
1368
|
if (this._sysURL.searchParams.size) {
|
1356
|
-
for (const [
|
1357
|
-
search += `${!search.length ? "?" : "&"}${
|
1369
|
+
for (const [key2, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {
|
1370
|
+
search += `${!search.length ? "?" : "&"}${key2}=${encodeURIComponent(value)}`;
|
1358
1371
|
}
|
1359
1372
|
}
|
1360
1373
|
let hostpart = "";
|
@@ -1389,11 +1402,11 @@ function from(fac, strURLUri, defaultProtocol) {
|
|
1389
1402
|
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
1390
1403
|
}
|
1391
1404
|
}
|
1392
|
-
function getParamResult(
|
1393
|
-
return `missing parameter: ${
|
1405
|
+
function getParamResult(key2, val, msgFn = (key3) => {
|
1406
|
+
return `missing parameter: ${key3}`;
|
1394
1407
|
}) {
|
1395
1408
|
if (val === void 0) {
|
1396
|
-
return Result.Err(msgFn(
|
1409
|
+
return Result.Err(msgFn(key2));
|
1397
1410
|
}
|
1398
1411
|
return Result.Ok(val);
|
1399
1412
|
}
|
@@ -1401,9 +1414,15 @@ function getParamsResult(keys, getParam) {
|
|
1401
1414
|
const keyDef = keys.flat().reduce(
|
1402
1415
|
(acc, i) => {
|
1403
1416
|
if (typeof i === "string") {
|
1404
|
-
acc.push({ key: i });
|
1417
|
+
acc.push({ key: i, def: void 0, isOptional: false });
|
1405
1418
|
} else if (typeof i === "object") {
|
1406
|
-
acc.push(
|
1419
|
+
acc.push(
|
1420
|
+
...Object.keys(i).map((k) => ({
|
1421
|
+
key: k,
|
1422
|
+
def: typeof i[k] === "string" ? i[k] : void 0,
|
1423
|
+
isOptional: i[k] instanceof _OPTIONAL
|
1424
|
+
}))
|
1425
|
+
);
|
1407
1426
|
}
|
1408
1427
|
return acc;
|
1409
1428
|
},
|
@@ -1421,7 +1440,9 @@ function getParamsResult(keys, getParam) {
|
|
1421
1440
|
if (typeof kd.def === "string") {
|
1422
1441
|
result[kd.key] = kd.def;
|
1423
1442
|
} else {
|
1424
|
-
|
1443
|
+
if (!kd.isOptional) {
|
1444
|
+
errors.push(kd.key);
|
1445
|
+
}
|
1425
1446
|
}
|
1426
1447
|
} else {
|
1427
1448
|
result[kd.key] = val;
|
@@ -1485,47 +1506,47 @@ var BuildURI = class _BuildURI {
|
|
1485
1506
|
const pathname = "./" + appendUrl.pathname;
|
1486
1507
|
const basePath = this._url.pathname;
|
1487
1508
|
this.pathname(relativePath(basePath, pathname));
|
1488
|
-
for (const [
|
1489
|
-
this.setParam(
|
1509
|
+
for (const [key2, value] of appendUrl.getParams) {
|
1510
|
+
this.setParam(key2, value);
|
1490
1511
|
}
|
1491
1512
|
return this;
|
1492
1513
|
}
|
1493
1514
|
cleanParams() {
|
1494
|
-
for (const
|
1495
|
-
this._url.searchParams.delete(
|
1515
|
+
for (const key2 of Array.from(this._url.searchParams.keys())) {
|
1516
|
+
this._url.searchParams.delete(key2);
|
1496
1517
|
}
|
1497
1518
|
return this;
|
1498
1519
|
}
|
1499
|
-
delParam(
|
1500
|
-
this._url.searchParams.delete(
|
1520
|
+
delParam(key2) {
|
1521
|
+
this._url.searchParams.delete(key2);
|
1501
1522
|
return this;
|
1502
1523
|
}
|
1503
|
-
defParam(
|
1504
|
-
if (!this._url.searchParams.has(
|
1505
|
-
this._url.searchParams.set(
|
1524
|
+
defParam(key2, str) {
|
1525
|
+
if (!this._url.searchParams.has(key2)) {
|
1526
|
+
this._url.searchParams.set(key2, str);
|
1506
1527
|
}
|
1507
1528
|
return this;
|
1508
1529
|
}
|
1509
|
-
setParam(
|
1510
|
-
this._url.searchParams.set(
|
1530
|
+
setParam(key2, str) {
|
1531
|
+
this._url.searchParams.set(key2, str);
|
1511
1532
|
return this;
|
1512
1533
|
}
|
1513
|
-
hasParam(
|
1514
|
-
return this._url.searchParams.has(
|
1534
|
+
hasParam(key2) {
|
1535
|
+
return this._url.searchParams.has(key2);
|
1515
1536
|
}
|
1516
1537
|
get getParams() {
|
1517
1538
|
return this._url.searchParams.entries();
|
1518
1539
|
}
|
1519
|
-
getParam(
|
1520
|
-
const { key: k, def: d } = coerceKey(
|
1540
|
+
getParam(key2, def) {
|
1541
|
+
const { key: k, def: d } = coerceKey(key2, def);
|
1521
1542
|
let val = this._url.searchParams.get(k);
|
1522
1543
|
if (!falsy2undef(val) && d) {
|
1523
1544
|
val = d;
|
1524
1545
|
}
|
1525
1546
|
return falsy2undef(val);
|
1526
1547
|
}
|
1527
|
-
getParamResult(
|
1528
|
-
return getParamResult(
|
1548
|
+
getParamResult(key2, msgFn) {
|
1549
|
+
return getParamResult(key2, this.getParam(key2), msgFn);
|
1529
1550
|
}
|
1530
1551
|
getParamsResult(...keys) {
|
1531
1552
|
return getParamsResult(keys, this);
|
@@ -1568,8 +1589,8 @@ var URI = class _URI {
|
|
1568
1589
|
if (!(fPath.length === 0 || fPath === "/" || fPath === "./")) {
|
1569
1590
|
intoUrl.pathname(fromUrl.pathname);
|
1570
1591
|
}
|
1571
|
-
for (const [
|
1572
|
-
intoUrl.setParam(
|
1592
|
+
for (const [key2, value] of fromUrl.getParams) {
|
1593
|
+
intoUrl.setParam(key2, value);
|
1573
1594
|
}
|
1574
1595
|
return intoUrl.URI();
|
1575
1596
|
}
|
@@ -1622,19 +1643,19 @@ var URI = class _URI {
|
|
1622
1643
|
get getParams() {
|
1623
1644
|
return this._url.searchParams.entries();
|
1624
1645
|
}
|
1625
|
-
hasParam(
|
1626
|
-
return this._url.searchParams.has(
|
1646
|
+
hasParam(key2) {
|
1647
|
+
return this._url.searchParams.has(key2);
|
1627
1648
|
}
|
1628
|
-
getParam(
|
1629
|
-
const { key: k, def: d } = coerceKey(
|
1649
|
+
getParam(key2, def) {
|
1650
|
+
const { key: k, def: d } = coerceKey(key2, def);
|
1630
1651
|
let val = this._url.searchParams.get(k);
|
1631
1652
|
if (!falsy2undef(val) && d) {
|
1632
1653
|
val = d;
|
1633
1654
|
}
|
1634
1655
|
return falsy2undef(val);
|
1635
1656
|
}
|
1636
|
-
getParamResult(
|
1637
|
-
return getParamResult(
|
1657
|
+
getParamResult(key2, msgFn) {
|
1658
|
+
return getParamResult(key2, this.getParam(key2), msgFn);
|
1638
1659
|
}
|
1639
1660
|
getParamsResult(...keys) {
|
1640
1661
|
return getParamsResult(keys, this);
|
@@ -2070,9 +2091,9 @@ var LoggerImpl = class _LoggerImpl {
|
|
2070
2091
|
this.levelHandler.disableLevel(level, ...modules);
|
2071
2092
|
return this;
|
2072
2093
|
}
|
2073
|
-
Module(
|
2074
|
-
this._attributes["module"] = logValue(
|
2075
|
-
this._withAttributes["module"] = logValue(
|
2094
|
+
Module(key2) {
|
2095
|
+
this._attributes["module"] = logValue(key2, toLogValueCtx(this.levelHandler));
|
2096
|
+
this._withAttributes["module"] = logValue(key2, toLogValueCtx(this.levelHandler));
|
2076
2097
|
return this;
|
2077
2098
|
}
|
2078
2099
|
// if the string is "*" it will enable for all modules
|
@@ -2113,10 +2134,10 @@ var LoggerImpl = class _LoggerImpl {
|
|
2113
2134
|
}
|
2114
2135
|
Err(err) {
|
2115
2136
|
var _a;
|
2116
|
-
let
|
2137
|
+
let key2 = "error";
|
2117
2138
|
if (Result.Is(err)) {
|
2118
2139
|
if (err.isOk()) {
|
2119
|
-
|
2140
|
+
key2 = "noerror";
|
2120
2141
|
err = err.Ok();
|
2121
2142
|
} else {
|
2122
2143
|
err = err.Err();
|
@@ -2124,12 +2145,12 @@ var LoggerImpl = class _LoggerImpl {
|
|
2124
2145
|
}
|
2125
2146
|
if (err instanceof Error) {
|
2126
2147
|
if (err.cause) {
|
2127
|
-
this.coerceKey(
|
2148
|
+
this.coerceKey(key2, {
|
2128
2149
|
message: err.message,
|
2129
2150
|
cause: err.cause
|
2130
2151
|
});
|
2131
2152
|
} else {
|
2132
|
-
this._attributes[
|
2153
|
+
this._attributes[key2] = logValue(err.message, toLogValueCtx(this.levelHandler));
|
2133
2154
|
}
|
2134
2155
|
if (this.levelHandler.isStackExposed) {
|
2135
2156
|
this._attributes["stack"] = logValue(
|
@@ -2138,7 +2159,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2138
2159
|
);
|
2139
2160
|
}
|
2140
2161
|
} else {
|
2141
|
-
this.Any(
|
2162
|
+
this.Any(key2, err);
|
2142
2163
|
}
|
2143
2164
|
return this;
|
2144
2165
|
}
|
@@ -2146,22 +2167,22 @@ var LoggerImpl = class _LoggerImpl {
|
|
2146
2167
|
this._attributes["level"] = logValue(l, toLogValueCtx(this.levelHandler));
|
2147
2168
|
return this;
|
2148
2169
|
}
|
2149
|
-
Ref(
|
2170
|
+
Ref(key2, action) {
|
2150
2171
|
if (typeof action === "function") {
|
2151
|
-
this._attributes[
|
2172
|
+
this._attributes[key2] = logValue(action, toLogValueCtx(this.levelHandler));
|
2152
2173
|
} else if (typeof action.toString === "function") {
|
2153
|
-
this._attributes[
|
2174
|
+
this._attributes[key2] = logValue(() => action.toString(), toLogValueCtx(this.levelHandler));
|
2154
2175
|
} else {
|
2155
|
-
this._attributes[
|
2176
|
+
this._attributes[key2] = logValue("INVALID REF", toLogValueCtx(this.levelHandler));
|
2156
2177
|
}
|
2157
2178
|
return this;
|
2158
2179
|
}
|
2159
|
-
Bool(
|
2160
|
-
this.coerceKey(
|
2180
|
+
Bool(key2, value) {
|
2181
|
+
this.coerceKey(key2, !!value);
|
2161
2182
|
return this;
|
2162
2183
|
}
|
2163
2184
|
Http(...mix) {
|
2164
|
-
const
|
2185
|
+
const key2 = mix.find((x) => typeof x === "string");
|
2165
2186
|
mix = mix.filter((x) => typeof x !== "string");
|
2166
2187
|
const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
|
2167
2188
|
if (resErrors.length) {
|
@@ -2181,72 +2202,72 @@ var LoggerImpl = class _LoggerImpl {
|
|
2181
2202
|
reqAndOrres = req;
|
2182
2203
|
}
|
2183
2204
|
if (reqAndOrres) {
|
2184
|
-
this.Any(
|
2205
|
+
this.Any(key2 || "Http", reqAndOrres);
|
2185
2206
|
}
|
2186
2207
|
return this;
|
2187
2208
|
}
|
2188
2209
|
Pair(x) {
|
2189
|
-
for (const
|
2190
|
-
const value = x[
|
2210
|
+
for (const key2 of Object.keys(x)) {
|
2211
|
+
const value = x[key2];
|
2191
2212
|
if (value instanceof LogValue) {
|
2192
|
-
this._attributes[
|
2213
|
+
this._attributes[key2] = value;
|
2193
2214
|
continue;
|
2194
2215
|
}
|
2195
2216
|
if (Result.Is(value)) {
|
2196
|
-
this.Result(
|
2217
|
+
this.Result(key2, value);
|
2197
2218
|
continue;
|
2198
2219
|
}
|
2199
|
-
this.Any(
|
2220
|
+
this.Any(key2, value);
|
2200
2221
|
}
|
2201
2222
|
return this;
|
2202
2223
|
}
|
2203
|
-
Result(
|
2224
|
+
Result(key2, res) {
|
2204
2225
|
if (res.isOk()) {
|
2205
|
-
this._attributes[
|
2226
|
+
this._attributes[key2] = logValue(res.Ok(), toLogValueCtx(this.levelHandler));
|
2206
2227
|
} else {
|
2207
2228
|
this.Err(res.Err());
|
2208
2229
|
}
|
2209
2230
|
return this;
|
2210
2231
|
}
|
2211
|
-
Len(value,
|
2212
|
-
this._attributes[
|
2232
|
+
Len(value, key2 = "len") {
|
2233
|
+
this._attributes[key2] = getLen(value, toLogValueCtx(this.levelHandler));
|
2213
2234
|
return this;
|
2214
2235
|
}
|
2215
|
-
Hash(value,
|
2216
|
-
this._attributes[
|
2236
|
+
Hash(value, key2 = "hash") {
|
2237
|
+
this._attributes[key2] = asyncLogValue(
|
2217
2238
|
async () => `${getLen(value, toLogValueCtx(this.levelHandler)).value()}:${await hash(value)}`
|
2218
2239
|
);
|
2219
2240
|
return this;
|
2220
2241
|
}
|
2221
|
-
Url(url,
|
2222
|
-
this.Ref(
|
2242
|
+
Url(url, key2 = "url") {
|
2243
|
+
this.Ref(key2, () => URI.from(url).toString());
|
2223
2244
|
return this;
|
2224
2245
|
}
|
2225
|
-
coerceKey(
|
2226
|
-
if (typeof
|
2227
|
-
this._attributes[
|
2246
|
+
coerceKey(key2, value) {
|
2247
|
+
if (typeof key2 === "string") {
|
2248
|
+
this._attributes[key2] = logValue(value, toLogValueCtx(this.levelHandler));
|
2228
2249
|
} else {
|
2229
|
-
this.Pair(
|
2250
|
+
this.Pair(key2);
|
2230
2251
|
}
|
2231
2252
|
}
|
2232
|
-
Str(
|
2233
|
-
this.coerceKey(
|
2253
|
+
Str(key2, value) {
|
2254
|
+
this.coerceKey(key2, value);
|
2234
2255
|
return this;
|
2235
2256
|
}
|
2236
|
-
Any(
|
2237
|
-
this.coerceKey(
|
2257
|
+
Any(key2, value) {
|
2258
|
+
this.coerceKey(key2, value);
|
2238
2259
|
return this;
|
2239
2260
|
}
|
2240
|
-
Dur(
|
2241
|
-
this._attributes[
|
2261
|
+
Dur(key2, nsec) {
|
2262
|
+
this._attributes[key2] = logValue(`${nsec}ms`, toLogValueCtx(this.levelHandler));
|
2242
2263
|
return this;
|
2243
2264
|
}
|
2244
|
-
Uint64(
|
2245
|
-
this.coerceKey(
|
2265
|
+
Uint64(key2, value) {
|
2266
|
+
this.coerceKey(key2, value);
|
2246
2267
|
return this;
|
2247
2268
|
}
|
2248
|
-
Int(
|
2249
|
-
return this.Uint64(
|
2269
|
+
Int(key2, value) {
|
2270
|
+
return this.Uint64(key2, value);
|
2250
2271
|
}
|
2251
2272
|
async Flush() {
|
2252
2273
|
return new Promise((resolve) => {
|
@@ -2269,8 +2290,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
2269
2290
|
}
|
2270
2291
|
_resetAttributes(fn) {
|
2271
2292
|
const ret = fn();
|
2272
|
-
Object.keys(this._attributes).forEach((
|
2273
|
-
delete this._attributes[
|
2293
|
+
Object.keys(this._attributes).forEach((key2) => {
|
2294
|
+
delete this._attributes[key2];
|
2274
2295
|
});
|
2275
2296
|
Object.assign(this._attributes, this._withAttributes);
|
2276
2297
|
return ret;
|
@@ -2337,8 +2358,8 @@ var WithLoggerBuilder = class {
|
|
2337
2358
|
this._li.levelHandler.enableLevel(level, ...modules);
|
2338
2359
|
return this;
|
2339
2360
|
}
|
2340
|
-
Module(
|
2341
|
-
this._li.Module(
|
2361
|
+
Module(key2) {
|
2362
|
+
this._li.Module(key2);
|
2342
2363
|
return this;
|
2343
2364
|
}
|
2344
2365
|
SetDebug(...modules) {
|
@@ -2353,36 +2374,36 @@ var WithLoggerBuilder = class {
|
|
2353
2374
|
this._li.Pair(x);
|
2354
2375
|
return this;
|
2355
2376
|
}
|
2356
|
-
Str(
|
2357
|
-
this._li.Str(
|
2377
|
+
Str(key2, value) {
|
2378
|
+
this._li.Str(key2, value);
|
2358
2379
|
return this;
|
2359
2380
|
}
|
2360
|
-
Len(value,
|
2361
|
-
this._li.Len(value,
|
2381
|
+
Len(value, key2) {
|
2382
|
+
this._li.Len(value, key2);
|
2362
2383
|
return this;
|
2363
2384
|
}
|
2364
|
-
Hash(value,
|
2365
|
-
this._li.Hash(value,
|
2385
|
+
Hash(value, key2) {
|
2386
|
+
this._li.Hash(value, key2);
|
2366
2387
|
return this;
|
2367
2388
|
}
|
2368
|
-
Ref(
|
2369
|
-
this._li.Ref(
|
2389
|
+
Ref(key2, action) {
|
2390
|
+
this._li.Ref(key2, action);
|
2370
2391
|
return this;
|
2371
2392
|
}
|
2372
|
-
Bool(
|
2373
|
-
this._li.Bool(
|
2393
|
+
Bool(key2, value) {
|
2394
|
+
this._li.Bool(key2, value);
|
2374
2395
|
return this;
|
2375
2396
|
}
|
2376
|
-
Result(
|
2377
|
-
this._li.Result(
|
2397
|
+
Result(key2, res) {
|
2398
|
+
this._li.Result(key2, res);
|
2378
2399
|
return this;
|
2379
2400
|
}
|
2380
|
-
Url(url,
|
2381
|
-
this._li.Url(url,
|
2401
|
+
Url(url, key2) {
|
2402
|
+
this._li.Url(url, key2);
|
2382
2403
|
return this;
|
2383
2404
|
}
|
2384
|
-
Int(
|
2385
|
-
this._li.Int(
|
2405
|
+
Int(key2, value) {
|
2406
|
+
this._li.Int(key2, value);
|
2386
2407
|
return this;
|
2387
2408
|
}
|
2388
2409
|
Log() {
|
@@ -2417,16 +2438,16 @@ var WithLoggerBuilder = class {
|
|
2417
2438
|
this._li.Timestamp();
|
2418
2439
|
return this;
|
2419
2440
|
}
|
2420
|
-
Any(
|
2421
|
-
this._li.Any(
|
2441
|
+
Any(key2, value) {
|
2442
|
+
this._li.Any(key2, value);
|
2422
2443
|
return this;
|
2423
2444
|
}
|
2424
|
-
Dur(
|
2425
|
-
this._li.Dur(
|
2445
|
+
Dur(key2, nsec) {
|
2446
|
+
this._li.Dur(key2, nsec);
|
2426
2447
|
return this;
|
2427
2448
|
}
|
2428
|
-
Uint64(
|
2429
|
-
this._li.Uint64(
|
2449
|
+
Uint64(key2, value) {
|
2450
|
+
this._li.Uint64(key2, value);
|
2430
2451
|
return this;
|
2431
2452
|
}
|
2432
2453
|
};
|
@@ -2591,8 +2612,8 @@ var Metrics = class {
|
|
2591
2612
|
}
|
2592
2613
|
toJSON() {
|
2593
2614
|
const obj = {};
|
2594
|
-
for (const [
|
2595
|
-
obj[
|
2615
|
+
for (const [key2, value] of this.map) {
|
2616
|
+
obj[key2] = value.value;
|
2596
2617
|
}
|
2597
2618
|
return obj;
|
2598
2619
|
}
|
@@ -2765,15 +2786,15 @@ var HeadersImpl = class extends Headers {
|
|
2765
2786
|
values() {
|
2766
2787
|
return this._headers.values();
|
2767
2788
|
}
|
2768
|
-
append(
|
2769
|
-
const values = this._headers.get(
|
2789
|
+
append(key2, value) {
|
2790
|
+
const values = this._headers.get(key2);
|
2770
2791
|
if (typeof value === "undefined") {
|
2771
2792
|
value = "";
|
2772
2793
|
}
|
2773
2794
|
if (Array.isArray(value)) {
|
2774
|
-
this._headers.set(
|
2795
|
+
this._headers.set(key2, [values, ...value].filter((i) => i).join(", "));
|
2775
2796
|
} else {
|
2776
|
-
this._headers.set(
|
2797
|
+
this._headers.set(key2, [values, value].filter((i) => i).join(", "));
|
2777
2798
|
}
|
2778
2799
|
return this;
|
2779
2800
|
}
|
@@ -2783,6 +2804,9 @@ var HttpHeader = class _HttpHeader {
|
|
2783
2804
|
this._headers = /* @__PURE__ */ new Map();
|
2784
2805
|
}
|
2785
2806
|
static from(headers) {
|
2807
|
+
if (headers instanceof _HttpHeader) {
|
2808
|
+
return headers.Clone();
|
2809
|
+
}
|
2786
2810
|
const h = new _HttpHeader();
|
2787
2811
|
if (headers) {
|
2788
2812
|
if (Array.isArray(headers)) {
|
@@ -2813,38 +2837,38 @@ var HttpHeader = class _HttpHeader {
|
|
2813
2837
|
}
|
2814
2838
|
_asStringString() {
|
2815
2839
|
const ret = /* @__PURE__ */ new Map();
|
2816
|
-
for (const [
|
2817
|
-
ret.set(
|
2840
|
+
for (const [key2, values] of this._headers) {
|
2841
|
+
ret.set(key2, values.join(", "));
|
2818
2842
|
}
|
2819
2843
|
return ret;
|
2820
2844
|
}
|
2821
|
-
_key(
|
2822
|
-
return
|
2845
|
+
_key(key2) {
|
2846
|
+
return key2.toLowerCase();
|
2823
2847
|
}
|
2824
|
-
Values(
|
2825
|
-
const values = this._headers.get(this._key(
|
2848
|
+
Values(key2) {
|
2849
|
+
const values = this._headers.get(this._key(key2));
|
2826
2850
|
return values || [];
|
2827
2851
|
}
|
2828
|
-
Get(
|
2829
|
-
const values = this._headers.get(this._key(
|
2852
|
+
Get(key2) {
|
2853
|
+
const values = this._headers.get(this._key(key2));
|
2830
2854
|
if (values === void 0 || values.length === 0) {
|
2831
2855
|
return void 0;
|
2832
2856
|
}
|
2833
2857
|
return values[0];
|
2834
2858
|
}
|
2835
|
-
Set(
|
2859
|
+
Set(key2, valueOr) {
|
2836
2860
|
const value = Array.isArray(valueOr) ? valueOr : [valueOr];
|
2837
|
-
this._headers.set(this._key(
|
2861
|
+
this._headers.set(this._key(key2), value);
|
2838
2862
|
return this;
|
2839
2863
|
}
|
2840
|
-
Add(
|
2864
|
+
Add(key2, value) {
|
2841
2865
|
if (typeof value === "undefined") {
|
2842
2866
|
return this;
|
2843
2867
|
}
|
2844
2868
|
const vs = Array.isArray(value) ? value : [value];
|
2845
|
-
const values = this._headers.get(this._key(
|
2869
|
+
const values = this._headers.get(this._key(key2));
|
2846
2870
|
if (values === void 0) {
|
2847
|
-
this._headers.set(this._key(
|
2871
|
+
this._headers.set(this._key(key2), vs);
|
2848
2872
|
} else {
|
2849
2873
|
values.push(...vs);
|
2850
2874
|
}
|
@@ -2862,29 +2886,29 @@ var HttpHeader = class _HttpHeader {
|
|
2862
2886
|
}
|
2863
2887
|
Clone() {
|
2864
2888
|
const clone = new _HttpHeader();
|
2865
|
-
for (const [
|
2866
|
-
clone._headers.set(
|
2889
|
+
for (const [key2, values] of this._headers.entries()) {
|
2890
|
+
clone._headers.set(key2, values.slice());
|
2867
2891
|
}
|
2868
2892
|
return clone;
|
2869
2893
|
}
|
2870
2894
|
AsRecordStringStringArray() {
|
2871
2895
|
const obj = {};
|
2872
|
-
for (const [
|
2873
|
-
obj[
|
2896
|
+
for (const [key2, values] of this._headers.entries()) {
|
2897
|
+
obj[key2] = [...values];
|
2874
2898
|
}
|
2875
2899
|
return obj;
|
2876
2900
|
}
|
2877
2901
|
AsRecordStringString() {
|
2878
2902
|
const obj = {};
|
2879
|
-
for (const [
|
2880
|
-
obj[
|
2903
|
+
for (const [key2, values] of this._headers.entries()) {
|
2904
|
+
obj[key2] = values.join(", ");
|
2881
2905
|
}
|
2882
2906
|
return obj;
|
2883
2907
|
}
|
2884
2908
|
AsHeaderInit() {
|
2885
2909
|
const obj = {};
|
2886
|
-
for (const [
|
2887
|
-
obj[
|
2910
|
+
for (const [key2, values] of this._headers.entries()) {
|
2911
|
+
obj[key2] = values[0];
|
2888
2912
|
}
|
2889
2913
|
return obj;
|
2890
2914
|
}
|
@@ -2894,8 +2918,8 @@ var HttpHeader = class _HttpHeader {
|
|
2894
2918
|
Merge(other) {
|
2895
2919
|
const ret = this.Clone();
|
2896
2920
|
if (other) {
|
2897
|
-
for (const [
|
2898
|
-
ret.Add(
|
2921
|
+
for (const [key2, values] of other.Items()) {
|
2922
|
+
ret.Add(key2, values);
|
2899
2923
|
}
|
2900
2924
|
}
|
2901
2925
|
return ret;
|
@@ -3130,7 +3154,6 @@ function uint8array2stream(str) {
|
|
3130
3154
|
MutableURL,
|
3131
3155
|
None,
|
3132
3156
|
Option,
|
3133
|
-
REQUIRED,
|
3134
3157
|
RandomMode,
|
3135
3158
|
RandomService,
|
3136
3159
|
ResolveOnce,
|
@@ -3160,6 +3183,7 @@ function uint8array2stream(str) {
|
|
3160
3183
|
exception2Result,
|
3161
3184
|
hasHostPartProtocols,
|
3162
3185
|
isURL,
|
3186
|
+
key,
|
3163
3187
|
logValue,
|
3164
3188
|
runtimeFn,
|
3165
3189
|
toCryptoRuntime,
|