@adviser/cement 0.2.35 → 0.2.37

Sign up to get free protection for your applications and to get access to all the features.
package/index.d.cts CHANGED
@@ -40,6 +40,19 @@ declare function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): W
40
40
  type StripCommand = string | RegExp;
41
41
 
42
42
  type NullOrUndef = null | undefined;
43
+ type OneKey<K extends string, V = string> = Record<K, V>;
44
+ interface URIInterface<R extends URIInterface<R>> {
45
+ readonly getParams: Iterable<[string, string]>;
46
+ hasParam(key: string): boolean;
47
+ getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
48
+ getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
49
+ getParamsResult(...keys: keysParam): Result<Record<string, string>>;
50
+ clone(): R;
51
+ asURL(): URL;
52
+ toString(): string;
53
+ toJSON(): string;
54
+ asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
55
+ }
43
56
  interface URIObject {
44
57
  readonly style: "host" | "path";
45
58
  readonly protocol: string;
@@ -75,8 +88,9 @@ declare class MutableURL extends URL {
75
88
  get searchParams(): URLSearchParams;
76
89
  toString(): string;
77
90
  }
78
- type keysParam = (string | ((...keys: string[]) => string))[];
79
- declare class BuildURI {
91
+ type msgFn = (...keys: string[]) => string;
92
+ type keysParam = (string | msgFn | Record<string, unknown>)[];
93
+ declare class BuildURI implements URIInterface<BuildURI> {
80
94
  _url: MutableURL;
81
95
  private constructor();
82
96
  static is(value: unknown): value is BuildURI;
@@ -90,18 +104,20 @@ declare class BuildURI {
90
104
  defParam(key: string, str: string): BuildURI;
91
105
  setParam(key: string, str: string): BuildURI;
92
106
  hasParam(key: string): boolean;
93
- getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
107
+ get getParams(): Iterable<[string, string]>;
108
+ getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
94
109
  getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
95
110
  getParamsResult(...keys: keysParam): Result<Record<string, string>>;
96
111
  toString(): string;
97
112
  toJSON(): string;
98
113
  asURL(): URL;
99
114
  asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
115
+ clone(): BuildURI;
100
116
  URI(): URI;
101
117
  }
102
118
  type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
103
119
  declare const hasHostPartProtocols: Set<string>;
104
- declare class URI {
120
+ declare class URI implements URIInterface<URI> {
105
121
  static protocolHasHostpart(protocol: string): () => void;
106
122
  static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
107
123
  static is(value: unknown): value is URI;
@@ -117,7 +133,7 @@ declare class URI {
117
133
  get pathname(): string;
118
134
  get getParams(): Iterable<[string, string]>;
119
135
  hasParam(key: string): boolean;
120
- getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
136
+ getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
121
137
  getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
122
138
  getParamsResult(...keys: keysParam): Result<Record<string, string>>;
123
139
  clone(): URI;
@@ -163,6 +179,7 @@ interface LevelHandler {
163
179
  setDebug(...modules: (string | string[])[]): void;
164
180
  isEnabled(ilevel: unknown, module: unknown): boolean;
165
181
  }
182
+ type HttpType = Response | Result<Response> | Request | Result<Request>;
166
183
  interface LoggerInterface<R> {
167
184
  TxtEnDe(): TxtEnDecoder;
168
185
  Module(key: string): R;
@@ -179,8 +196,12 @@ interface LoggerInterface<R> {
179
196
  Url(url: CoerceURI, key?: string): R;
180
197
  Len(value: unknown, key?: string): R;
181
198
  Hash(value: unknown, key?: string): R;
182
- Str(key: string, value?: string): R;
183
- Http(res: Response | Result<Response>, req?: Request, key?: string): R;
199
+ Str<T extends string | Record<string, string>>(key: T, value?: T extends string ? string : undefined): R;
200
+ Uint64<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;
201
+ Int<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;
202
+ Bool<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
203
+ Any<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
204
+ Http(...mix: (HttpType | string)[]): R;
184
205
  Pair(x: Record<string, unknown>): R;
185
206
  Error(): R;
186
207
  Warn(): R;
@@ -190,11 +211,7 @@ interface LoggerInterface<R> {
190
211
  Err(err: unknown | Result<unknown> | Error): R;
191
212
  Info(): R;
192
213
  Timestamp(): R;
193
- Any(key: string, value: unknown): R;
194
214
  Dur(key: string, nsec: number): R;
195
- Uint64(key: string, value: number): R;
196
- Int(key: string, value: number): R;
197
- Bool(key: string, value: unknown): R;
198
215
  }
199
216
  declare function IsLogger(obj: unknown): obj is Logger;
200
217
  interface WithLogger extends LoggerInterface<WithLogger> {
@@ -269,18 +286,19 @@ declare class LoggerImpl implements Logger {
269
286
  Ref(key: string, action: {
270
287
  toString: () => string;
271
288
  } | FnSerialized): Logger;
272
- Bool(key: string, value: unknown): Logger;
273
- Http(res: Response | Result<Response>, req?: Request, key?: string): Logger;
289
+ Bool(key: string | Record<string, unknown>, value: unknown): Logger;
290
+ Http(...mix: (HttpType | string)[]): Logger;
274
291
  Pair(x: Record<string, unknown>): Logger;
275
292
  Result<T>(key: string, res: Result<T, Error>): Logger;
276
293
  Len(value: unknown, key?: string): Logger;
277
294
  Hash(value: unknown, key?: string): Logger;
278
295
  Url(url: CoerceURI, key?: string): Logger;
279
- Str(key: string, value?: string): Logger;
280
- Any(key: string, value?: string | number | boolean | LogSerializable): Logger;
296
+ private coerceKey;
297
+ Str(key: string | Record<string, string>, value?: string): Logger;
298
+ Any(key: string | Record<string, unknown>, value?: unknown): Logger;
281
299
  Dur(key: string, nsec: number): Logger;
282
- Uint64(key: string, value: number): Logger;
283
- Int(key: string, value: number): Logger;
300
+ Uint64(key: string | Record<string, number>, value?: number): Logger;
301
+ Int(key: string | Record<string, number>, value?: number): Logger;
284
302
  Flush(): Promise<void>;
285
303
  With(): WithLogger;
286
304
  _resetAttributes(fn: () => () => Uint8Array): () => Uint8Array;
@@ -558,4 +576,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
558
576
 
559
577
  declare const VERSION: string;
560
578
 
561
- export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, runtimeFn, toCryptoRuntime };
579
+ export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type HttpType, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIInterface, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, runtimeFn, toCryptoRuntime };
package/index.d.ts CHANGED
@@ -40,6 +40,19 @@ declare function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): W
40
40
  type StripCommand = string | RegExp;
41
41
 
42
42
  type NullOrUndef = null | undefined;
43
+ type OneKey<K extends string, V = string> = Record<K, V>;
44
+ interface URIInterface<R extends URIInterface<R>> {
45
+ readonly getParams: Iterable<[string, string]>;
46
+ hasParam(key: string): boolean;
47
+ getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
48
+ getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
49
+ getParamsResult(...keys: keysParam): Result<Record<string, string>>;
50
+ clone(): R;
51
+ asURL(): URL;
52
+ toString(): string;
53
+ toJSON(): string;
54
+ asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
55
+ }
43
56
  interface URIObject {
44
57
  readonly style: "host" | "path";
45
58
  readonly protocol: string;
@@ -75,8 +88,9 @@ declare class MutableURL extends URL {
75
88
  get searchParams(): URLSearchParams;
76
89
  toString(): string;
77
90
  }
78
- type keysParam = (string | ((...keys: string[]) => string))[];
79
- declare class BuildURI {
91
+ type msgFn = (...keys: string[]) => string;
92
+ type keysParam = (string | msgFn | Record<string, unknown>)[];
93
+ declare class BuildURI implements URIInterface<BuildURI> {
80
94
  _url: MutableURL;
81
95
  private constructor();
82
96
  static is(value: unknown): value is BuildURI;
@@ -90,18 +104,20 @@ declare class BuildURI {
90
104
  defParam(key: string, str: string): BuildURI;
91
105
  setParam(key: string, str: string): BuildURI;
92
106
  hasParam(key: string): boolean;
93
- getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
107
+ get getParams(): Iterable<[string, string]>;
108
+ getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
94
109
  getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
95
110
  getParamsResult(...keys: keysParam): Result<Record<string, string>>;
96
111
  toString(): string;
97
112
  toJSON(): string;
98
113
  asURL(): URL;
99
114
  asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;
115
+ clone(): BuildURI;
100
116
  URI(): URI;
101
117
  }
102
118
  type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;
103
119
  declare const hasHostPartProtocols: Set<string>;
104
- declare class URI {
120
+ declare class URI implements URIInterface<URI> {
105
121
  static protocolHasHostpart(protocol: string): () => void;
106
122
  static merge(into: CoerceURI, from: CoerceURI, defaultProtocol?: string): URI;
107
123
  static is(value: unknown): value is URI;
@@ -117,7 +133,7 @@ declare class URI {
117
133
  get pathname(): string;
118
134
  get getParams(): Iterable<[string, string]>;
119
135
  hasParam(key: string): boolean;
120
- getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined;
136
+ getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
121
137
  getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
122
138
  getParamsResult(...keys: keysParam): Result<Record<string, string>>;
123
139
  clone(): URI;
@@ -163,6 +179,7 @@ interface LevelHandler {
163
179
  setDebug(...modules: (string | string[])[]): void;
164
180
  isEnabled(ilevel: unknown, module: unknown): boolean;
165
181
  }
182
+ type HttpType = Response | Result<Response> | Request | Result<Request>;
166
183
  interface LoggerInterface<R> {
167
184
  TxtEnDe(): TxtEnDecoder;
168
185
  Module(key: string): R;
@@ -179,8 +196,12 @@ interface LoggerInterface<R> {
179
196
  Url(url: CoerceURI, key?: string): R;
180
197
  Len(value: unknown, key?: string): R;
181
198
  Hash(value: unknown, key?: string): R;
182
- Str(key: string, value?: string): R;
183
- Http(res: Response | Result<Response>, req?: Request, key?: string): R;
199
+ Str<T extends string | Record<string, string>>(key: T, value?: T extends string ? string : undefined): R;
200
+ Uint64<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;
201
+ Int<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;
202
+ Bool<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
203
+ Any<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
204
+ Http(...mix: (HttpType | string)[]): R;
184
205
  Pair(x: Record<string, unknown>): R;
185
206
  Error(): R;
186
207
  Warn(): R;
@@ -190,11 +211,7 @@ interface LoggerInterface<R> {
190
211
  Err(err: unknown | Result<unknown> | Error): R;
191
212
  Info(): R;
192
213
  Timestamp(): R;
193
- Any(key: string, value: unknown): R;
194
214
  Dur(key: string, nsec: number): R;
195
- Uint64(key: string, value: number): R;
196
- Int(key: string, value: number): R;
197
- Bool(key: string, value: unknown): R;
198
215
  }
199
216
  declare function IsLogger(obj: unknown): obj is Logger;
200
217
  interface WithLogger extends LoggerInterface<WithLogger> {
@@ -269,18 +286,19 @@ declare class LoggerImpl implements Logger {
269
286
  Ref(key: string, action: {
270
287
  toString: () => string;
271
288
  } | FnSerialized): Logger;
272
- Bool(key: string, value: unknown): Logger;
273
- Http(res: Response | Result<Response>, req?: Request, key?: string): Logger;
289
+ Bool(key: string | Record<string, unknown>, value: unknown): Logger;
290
+ Http(...mix: (HttpType | string)[]): Logger;
274
291
  Pair(x: Record<string, unknown>): Logger;
275
292
  Result<T>(key: string, res: Result<T, Error>): Logger;
276
293
  Len(value: unknown, key?: string): Logger;
277
294
  Hash(value: unknown, key?: string): Logger;
278
295
  Url(url: CoerceURI, key?: string): Logger;
279
- Str(key: string, value?: string): Logger;
280
- Any(key: string, value?: string | number | boolean | LogSerializable): Logger;
296
+ private coerceKey;
297
+ Str(key: string | Record<string, string>, value?: string): Logger;
298
+ Any(key: string | Record<string, unknown>, value?: unknown): Logger;
281
299
  Dur(key: string, nsec: number): Logger;
282
- Uint64(key: string, value: number): Logger;
283
- Int(key: string, value: number): Logger;
300
+ Uint64(key: string | Record<string, number>, value?: number): Logger;
301
+ Int(key: string | Record<string, number>, value?: number): Logger;
284
302
  Flush(): Promise<void>;
285
303
  With(): WithLogger;
286
304
  _resetAttributes(fn: () => () => Uint8Array): () => Uint8Array;
@@ -558,4 +576,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
558
576
 
559
577
  declare const VERSION: string;
560
578
 
561
- export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, runtimeFn, toCryptoRuntime };
579
+ export { type AsError, BuildURI, type CTAesKeyAlgorithm, type CTAlgorithm, type CTAlgorithmIdentifier, type CTArrayBufferView, type CTBufferSource, type CTCryptoKey, type CTEcKeyImportParams, type CTHmacImportParams, type CTJsonWebKey, type CTKeyFormat, type CTKeyType, type CTKeyUsage, type CTNamedCurve, type CTRsaHashedImportParams, type CleanCtx, type CoerceURI, type CryptoRuntime, type FnSerialized, Future, type HostURIObject, type HttpType, type Invokaction, IsLogger, JSONFormatter, Keyed, KeyedResolvOnce, KeyedResolvSeq, type Lengthed, Level, type LevelHandler, LevelHandlerImpl, LevelHandlerSingleton, LogCollector, type LogFormatter, type LogSerializable, LogValue, type LogValueArg, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, MutableURL, None, Option, type PathURIObject, ResolveOnce, ResolveSeq, Result, ResultError, ResultOK, type Runtime, type Serialized, type SizeOrLength, type Sized, Some, SysAbstraction, Time, type TraceCtx, type TraceCtxParam, TraceNode, type TraceNodeMap, TxtEnDecoder, URI, type URIInterface, type URIObject, VERSION, type WithLogger, type WithoutOption, type WithoutResult, YAMLFormatter, asyncLogValue, bin2string, bin2text, exception2Result, hasHostPartProtocols, isURL, logValue, runtimeFn, toCryptoRuntime };
package/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  ConsoleWriterStream,
3
3
  FanoutWriteStream,
4
4
  utils_exports
5
- } from "./chunk-7KFVMTOS.js";
5
+ } from "./chunk-USQXEZHL.js";
6
6
  import {
7
7
  WebSysAbstraction
8
8
  } from "./chunk-WMMUXBDX.js";
@@ -348,6 +348,16 @@ function localStripper(path, restrips, obj) {
348
348
  }
349
349
 
350
350
  // src/uri.ts
351
+ function coerceKey(key, def) {
352
+ if (typeof key === "object") {
353
+ const keys = Object.keys(key);
354
+ if (keys.length !== 1) {
355
+ throw new Error(`Invalid key: ${JSON.stringify(key)}`);
356
+ }
357
+ return { key: keys[0], def: key[keys[0]] };
358
+ }
359
+ return { key, def };
360
+ }
351
361
  function falsy2undef(value) {
352
362
  return value === void 0 || value === null ? void 0 : value;
353
363
  }
@@ -494,19 +504,33 @@ function getParamResult(key, val, msgFn = (key2) => {
494
504
  return Result.Ok(val);
495
505
  }
496
506
  function getParamsResult(keys, getParam) {
497
- const keyStrs = keys.flat().filter((k) => typeof k === "string");
507
+ const keyDef = keys.flat().reduce(
508
+ (acc, i) => {
509
+ if (typeof i === "string") {
510
+ acc.push({ key: i });
511
+ } else if (typeof i === "object") {
512
+ acc.push(...Object.keys(i).map((k) => ({ key: k, def: typeof i[k] === "string" ? i[k] : void 0 })));
513
+ }
514
+ return acc;
515
+ },
516
+ []
517
+ );
498
518
  const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
499
519
  const msg = keys2.join(",");
500
520
  return `missing parameters: ${msg}`;
501
521
  });
502
522
  const errors = [];
503
523
  const result = {};
504
- for (const key of keyStrs) {
505
- const val = getParam.getParam(key);
524
+ for (const kd of keyDef) {
525
+ const val = getParam.getParam(kd.key);
506
526
  if (val === void 0) {
507
- errors.push(key);
527
+ if (typeof kd.def === "string") {
528
+ result[kd.key] = kd.def;
529
+ } else {
530
+ errors.push(kd.key);
531
+ }
508
532
  } else {
509
- result[key] = val;
533
+ result[kd.key] = val;
510
534
  }
511
535
  }
512
536
  if (errors.length) {
@@ -598,10 +622,14 @@ var BuildURI = class _BuildURI {
598
622
  hasParam(key) {
599
623
  return this._url.searchParams.has(key);
600
624
  }
625
+ get getParams() {
626
+ return this._url.searchParams.entries();
627
+ }
601
628
  getParam(key, def) {
602
- let val = this._url.searchParams.get(key);
603
- if (!falsy2undef(val) && def) {
604
- val = def;
629
+ const { key: k, def: d } = coerceKey(key, def);
630
+ let val = this._url.searchParams.get(k);
631
+ if (!falsy2undef(val) && d) {
632
+ val = d;
605
633
  }
606
634
  return falsy2undef(val);
607
635
  }
@@ -624,6 +652,9 @@ var BuildURI = class _BuildURI {
624
652
  asObj(...strips) {
625
653
  return this.URI().asObj(...strips);
626
654
  }
655
+ clone() {
656
+ return _BuildURI.from(this.toString());
657
+ }
627
658
  URI() {
628
659
  return URI.from(this._url);
629
660
  }
@@ -704,9 +735,10 @@ var URI = class _URI {
704
735
  return this._url.searchParams.has(key);
705
736
  }
706
737
  getParam(key, def) {
707
- let val = this._url.searchParams.get(key);
708
- if (!falsy2undef(val) && def) {
709
- val = def;
738
+ const { key: k, def: d } = coerceKey(key, def);
739
+ let val = this._url.searchParams.get(k);
740
+ if (!falsy2undef(val) && d) {
741
+ val = d;
710
742
  }
711
743
  return falsy2undef(val);
712
744
  }
@@ -1089,22 +1121,32 @@ var LoggerImpl = class _LoggerImpl {
1089
1121
  return this;
1090
1122
  }
1091
1123
  Bool(key, value) {
1092
- this._attributes[key] = logValue(!!value);
1124
+ this.coerceKey(key, !!value);
1093
1125
  return this;
1094
1126
  }
1095
- Http(res, req, key) {
1096
- if (Result.Is(res)) {
1097
- if (res.isErr()) {
1098
- this.Err(res.Err());
1099
- return this;
1100
- }
1101
- res = res.Ok();
1127
+ Http(...mix) {
1128
+ const key = mix.find((x) => typeof x === "string");
1129
+ mix = mix.filter((x) => typeof x !== "string");
1130
+ const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
1131
+ if (resErrors.length) {
1132
+ this.Err(resErrors.map((x) => x.Err().message).join("\n"));
1133
+ return this;
1134
+ }
1135
+ const req = mix.map((reqOrResult) => Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult).find((req2) => typeof req2.status !== "number");
1136
+ const res = mix.map((resOrResult) => Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult).find((res2) => typeof res2.status === "number");
1137
+ let reqAndOrres;
1138
+ if (res && req) {
1139
+ reqAndOrres = { res, req };
1140
+ } else if (!res && !req) {
1141
+ reqAndOrres = void 0;
1142
+ } else if (res) {
1143
+ reqAndOrres = res;
1144
+ } else if (req) {
1145
+ reqAndOrres = req;
1146
+ }
1147
+ if (reqAndOrres) {
1148
+ this.Any(key || "Http", reqAndOrres);
1102
1149
  }
1103
- let reqRes = res;
1104
- if (req) {
1105
- reqRes = { res, req };
1106
- }
1107
- this.Any(key || "Http", reqRes);
1108
1150
  return this;
1109
1151
  }
1110
1152
  Pair(x) {
@@ -1142,12 +1184,19 @@ var LoggerImpl = class _LoggerImpl {
1142
1184
  this.Ref(key, () => URI.from(url).toString());
1143
1185
  return this;
1144
1186
  }
1187
+ coerceKey(key, value) {
1188
+ if (typeof key === "string") {
1189
+ this._attributes[key] = logValue(value);
1190
+ } else {
1191
+ this.Pair(key);
1192
+ }
1193
+ }
1145
1194
  Str(key, value) {
1146
- this._attributes[key] = logValue(value);
1195
+ this.coerceKey(key, value);
1147
1196
  return this;
1148
1197
  }
1149
1198
  Any(key, value) {
1150
- this._attributes[key] = logValue(value);
1199
+ this.coerceKey(key, value);
1151
1200
  return this;
1152
1201
  }
1153
1202
  Dur(key, nsec) {
@@ -1155,7 +1204,7 @@ var LoggerImpl = class _LoggerImpl {
1155
1204
  return this;
1156
1205
  }
1157
1206
  Uint64(key, value) {
1158
- this._attributes[key] = logValue(value);
1207
+ this.coerceKey(key, value);
1159
1208
  return this;
1160
1209
  }
1161
1210
  Int(key, value) {
@@ -1252,8 +1301,8 @@ var WithLoggerBuilder = class {
1252
1301
  this._li.SetDebug(...modules);
1253
1302
  return this;
1254
1303
  }
1255
- Http(res, req, key) {
1256
- this._li.Http(res, req, key);
1304
+ Http(...mix) {
1305
+ this._li.Http(...mix);
1257
1306
  return this;
1258
1307
  }
1259
1308
  Pair(x) {