@adviser/cement 0.2.36 → 0.2.38
Sign up to get free protection for your applications and to get access to all the features.
- package/{chunk-Q65HLCNL.js → chunk-F5W6VELE.js} +26 -17
- package/chunk-F5W6VELE.js.map +1 -0
- package/{chunk-WMMUXBDX.js → chunk-W2GV5KXV.js} +2 -2
- package/index.cjs +59 -33
- package/index.cjs.map +1 -1
- package/index.d.cts +9 -8
- package/index.d.ts +9 -8
- package/index.js +36 -19
- package/index.js.map +1 -1
- package/node/index.cjs +25 -16
- package/node/index.cjs.map +1 -1
- package/node/index.js +1 -1
- package/package.json +2 -2
- package/src/base-sys-abstraction.ts +44 -0
- package/src/jsr.json +1 -1
- package/src/log-writer-impl.ts +1 -1
- package/src/logger-impl.ts +28 -13
- package/src/logger.ts +16 -2
- package/src/uri.ts +23 -9
- package/ts/base-sys-abstraction.d.ts.map +1 -1
- package/ts/base-sys-abstraction.js +30 -16
- package/ts/base-sys-abstraction.js.map +1 -1
- package/ts/logger-impl.d.ts +2 -2
- package/ts/logger-impl.d.ts.map +1 -1
- package/ts/logger-impl.js +30 -13
- package/ts/logger-impl.js.map +1 -1
- package/ts/logger.d.ts +2 -1
- package/ts/logger.d.ts.map +1 -1
- package/ts/logger.js +9 -1
- package/ts/logger.js.map +1 -1
- package/ts/logger.test.js +343 -64
- package/ts/logger.test.js.map +1 -1
- package/ts/uri.d.ts +5 -5
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +2 -2
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +47 -0
- package/ts/uri.test.js.map +1 -1
- package/web/index.cjs +25 -16
- package/web/index.cjs.map +1 -1
- package/web/index.js +2 -2
- package/chunk-Q65HLCNL.js.map +0 -1
- /package/{chunk-WMMUXBDX.js.map → chunk-W2GV5KXV.js.map} +0 -0
package/index.d.cts
CHANGED
@@ -41,12 +41,14 @@ type StripCommand = string | RegExp;
|
|
41
41
|
|
42
42
|
type NullOrUndef = null | undefined;
|
43
43
|
type OneKey<K extends string, V = string> = Record<K, V>;
|
44
|
+
type MsgFn = (...keys: string[]) => string;
|
45
|
+
type KeysParam = (string | MsgFn | Record<string, unknown>)[];
|
44
46
|
interface URIInterface<R extends URIInterface<R>> {
|
45
47
|
readonly getParams: Iterable<[string, string]>;
|
46
48
|
hasParam(key: string): boolean;
|
47
49
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
48
50
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
49
|
-
getParamsResult(...keys:
|
51
|
+
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
50
52
|
clone(): R;
|
51
53
|
asURL(): URL;
|
52
54
|
toString(): string;
|
@@ -88,8 +90,6 @@ declare class MutableURL extends URL {
|
|
88
90
|
get searchParams(): URLSearchParams;
|
89
91
|
toString(): string;
|
90
92
|
}
|
91
|
-
type msgFn = (...keys: string[]) => string;
|
92
|
-
type keysParam = (string | msgFn | Record<string, string>)[];
|
93
93
|
declare class BuildURI implements URIInterface<BuildURI> {
|
94
94
|
_url: MutableURL;
|
95
95
|
private constructor();
|
@@ -107,7 +107,7 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
107
107
|
get getParams(): Iterable<[string, string]>;
|
108
108
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
109
109
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
110
|
-
getParamsResult(...keys:
|
110
|
+
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
111
111
|
toString(): string;
|
112
112
|
toJSON(): string;
|
113
113
|
asURL(): URL;
|
@@ -135,7 +135,7 @@ declare class URI implements URIInterface<URI> {
|
|
135
135
|
hasParam(key: string): boolean;
|
136
136
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
137
137
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
138
|
-
getParamsResult(...keys:
|
138
|
+
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
139
139
|
clone(): URI;
|
140
140
|
asURL(): URL;
|
141
141
|
toString(): string;
|
@@ -179,6 +179,7 @@ interface LevelHandler {
|
|
179
179
|
setDebug(...modules: (string | string[])[]): void;
|
180
180
|
isEnabled(ilevel: unknown, module: unknown): boolean;
|
181
181
|
}
|
182
|
+
type HttpType = Response | Result<Response> | Request | Result<Request>;
|
182
183
|
interface LoggerInterface<R> {
|
183
184
|
TxtEnDe(): TxtEnDecoder;
|
184
185
|
Module(key: string): R;
|
@@ -200,7 +201,7 @@ interface LoggerInterface<R> {
|
|
200
201
|
Int<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;
|
201
202
|
Bool<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
|
202
203
|
Any<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
|
203
|
-
Http(
|
204
|
+
Http(...mix: (HttpType | string)[]): R;
|
204
205
|
Pair(x: Record<string, unknown>): R;
|
205
206
|
Error(): R;
|
206
207
|
Warn(): R;
|
@@ -286,7 +287,7 @@ declare class LoggerImpl implements Logger {
|
|
286
287
|
toString: () => string;
|
287
288
|
} | FnSerialized): Logger;
|
288
289
|
Bool(key: string | Record<string, unknown>, value: unknown): Logger;
|
289
|
-
Http(
|
290
|
+
Http(...mix: (HttpType | string)[]): Logger;
|
290
291
|
Pair(x: Record<string, unknown>): Logger;
|
291
292
|
Result<T>(key: string, res: Result<T, Error>): Logger;
|
292
293
|
Len(value: unknown, key?: string): Logger;
|
@@ -575,4 +576,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
575
576
|
|
576
577
|
declare const VERSION: string;
|
577
578
|
|
578
|
-
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 URIInterface, 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 KeysParam, 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, type MsgFn, 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
@@ -41,12 +41,14 @@ type StripCommand = string | RegExp;
|
|
41
41
|
|
42
42
|
type NullOrUndef = null | undefined;
|
43
43
|
type OneKey<K extends string, V = string> = Record<K, V>;
|
44
|
+
type MsgFn = (...keys: string[]) => string;
|
45
|
+
type KeysParam = (string | MsgFn | Record<string, unknown>)[];
|
44
46
|
interface URIInterface<R extends URIInterface<R>> {
|
45
47
|
readonly getParams: Iterable<[string, string]>;
|
46
48
|
hasParam(key: string): boolean;
|
47
49
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
48
50
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
49
|
-
getParamsResult(...keys:
|
51
|
+
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
50
52
|
clone(): R;
|
51
53
|
asURL(): URL;
|
52
54
|
toString(): string;
|
@@ -88,8 +90,6 @@ declare class MutableURL extends URL {
|
|
88
90
|
get searchParams(): URLSearchParams;
|
89
91
|
toString(): string;
|
90
92
|
}
|
91
|
-
type msgFn = (...keys: string[]) => string;
|
92
|
-
type keysParam = (string | msgFn | Record<string, string>)[];
|
93
93
|
declare class BuildURI implements URIInterface<BuildURI> {
|
94
94
|
_url: MutableURL;
|
95
95
|
private constructor();
|
@@ -107,7 +107,7 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
107
107
|
get getParams(): Iterable<[string, string]>;
|
108
108
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
109
109
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
110
|
-
getParamsResult(...keys:
|
110
|
+
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
111
111
|
toString(): string;
|
112
112
|
toJSON(): string;
|
113
113
|
asURL(): URL;
|
@@ -135,7 +135,7 @@ declare class URI implements URIInterface<URI> {
|
|
135
135
|
hasParam(key: string): boolean;
|
136
136
|
getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;
|
137
137
|
getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;
|
138
|
-
getParamsResult(...keys:
|
138
|
+
getParamsResult(...keys: KeysParam): Result<Record<string, string>>;
|
139
139
|
clone(): URI;
|
140
140
|
asURL(): URL;
|
141
141
|
toString(): string;
|
@@ -179,6 +179,7 @@ interface LevelHandler {
|
|
179
179
|
setDebug(...modules: (string | string[])[]): void;
|
180
180
|
isEnabled(ilevel: unknown, module: unknown): boolean;
|
181
181
|
}
|
182
|
+
type HttpType = Response | Result<Response> | Request | Result<Request>;
|
182
183
|
interface LoggerInterface<R> {
|
183
184
|
TxtEnDe(): TxtEnDecoder;
|
184
185
|
Module(key: string): R;
|
@@ -200,7 +201,7 @@ interface LoggerInterface<R> {
|
|
200
201
|
Int<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;
|
201
202
|
Bool<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
|
202
203
|
Any<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;
|
203
|
-
Http(
|
204
|
+
Http(...mix: (HttpType | string)[]): R;
|
204
205
|
Pair(x: Record<string, unknown>): R;
|
205
206
|
Error(): R;
|
206
207
|
Warn(): R;
|
@@ -286,7 +287,7 @@ declare class LoggerImpl implements Logger {
|
|
286
287
|
toString: () => string;
|
287
288
|
} | FnSerialized): Logger;
|
288
289
|
Bool(key: string | Record<string, unknown>, value: unknown): Logger;
|
289
|
-
Http(
|
290
|
+
Http(...mix: (HttpType | string)[]): Logger;
|
290
291
|
Pair(x: Record<string, unknown>): Logger;
|
291
292
|
Result<T>(key: string, res: Result<T, Error>): Logger;
|
292
293
|
Len(value: unknown, key?: string): Logger;
|
@@ -575,4 +576,4 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
575
576
|
|
576
577
|
declare const VERSION: string;
|
577
578
|
|
578
|
-
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 URIInterface, 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 KeysParam, 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, type MsgFn, 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
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
} from "./chunk-USQXEZHL.js";
|
6
6
|
import {
|
7
7
|
WebSysAbstraction
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-W2GV5KXV.js";
|
9
9
|
import {
|
10
10
|
BaseSysAbstraction,
|
11
11
|
BrowserEnvActions,
|
@@ -30,7 +30,7 @@ import {
|
|
30
30
|
TimeUnits,
|
31
31
|
WrapperSysAbstraction,
|
32
32
|
envFactory
|
33
|
-
} from "./chunk-
|
33
|
+
} from "./chunk-F5W6VELE.js";
|
34
34
|
import {
|
35
35
|
Utf8EnDecoder,
|
36
36
|
Utf8EnDecoderSingleton,
|
@@ -141,7 +141,14 @@ function logValue(val, state = /* @__PURE__ */ new Set([Math.random()])) {
|
|
141
141
|
return new LogValue(() => "null");
|
142
142
|
}
|
143
143
|
if (ArrayBuffer.isView(val)) {
|
144
|
-
|
144
|
+
try {
|
145
|
+
const decoder = new TextDecoder();
|
146
|
+
const asStr = decoder.decode(val);
|
147
|
+
const obj = JSON.parse(asStr);
|
148
|
+
return logValue(obj, state);
|
149
|
+
} catch (e) {
|
150
|
+
return logValue(bin2string(val, 512));
|
151
|
+
}
|
145
152
|
}
|
146
153
|
if (Array.isArray(val)) {
|
147
154
|
return new LogValue(() => val.map((v) => logValue(v).value()));
|
@@ -509,7 +516,7 @@ function getParamsResult(keys, getParam) {
|
|
509
516
|
if (typeof i === "string") {
|
510
517
|
acc.push({ key: i });
|
511
518
|
} else if (typeof i === "object") {
|
512
|
-
acc.push(...Object.keys(i).map((k) => ({ key: k, def: i[k] })));
|
519
|
+
acc.push(...Object.keys(i).map((k) => ({ key: k, def: typeof i[k] === "string" ? i[k] : void 0 })));
|
513
520
|
}
|
514
521
|
return acc;
|
515
522
|
},
|
@@ -524,7 +531,7 @@ function getParamsResult(keys, getParam) {
|
|
524
531
|
for (const kd of keyDef) {
|
525
532
|
const val = getParam.getParam(kd.key);
|
526
533
|
if (val === void 0) {
|
527
|
-
if (kd.def) {
|
534
|
+
if (typeof kd.def === "string") {
|
528
535
|
result[kd.key] = kd.def;
|
529
536
|
} else {
|
530
537
|
errors.push(kd.key);
|
@@ -1124,19 +1131,29 @@ var LoggerImpl = class _LoggerImpl {
|
|
1124
1131
|
this.coerceKey(key, !!value);
|
1125
1132
|
return this;
|
1126
1133
|
}
|
1127
|
-
Http(
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
}
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1134
|
+
Http(...mix) {
|
1135
|
+
const key = mix.find((x) => typeof x === "string");
|
1136
|
+
mix = mix.filter((x) => typeof x !== "string");
|
1137
|
+
const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
|
1138
|
+
if (resErrors.length) {
|
1139
|
+
this.Err(resErrors.map((x) => x.Err().message).join("\n"));
|
1140
|
+
return this;
|
1141
|
+
}
|
1142
|
+
const req = mix.map((reqOrResult) => Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult).find((req2) => typeof req2.status !== "number");
|
1143
|
+
const res = mix.map((resOrResult) => Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult).find((res2) => typeof res2.status === "number");
|
1144
|
+
let reqAndOrres;
|
1145
|
+
if (res && req) {
|
1146
|
+
reqAndOrres = { res, req };
|
1147
|
+
} else if (!res && !req) {
|
1148
|
+
reqAndOrres = void 0;
|
1149
|
+
} else if (res) {
|
1150
|
+
reqAndOrres = res;
|
1151
|
+
} else if (req) {
|
1152
|
+
reqAndOrres = req;
|
1153
|
+
}
|
1154
|
+
if (reqAndOrres) {
|
1155
|
+
this.Any(key || "Http", reqAndOrres);
|
1138
1156
|
}
|
1139
|
-
this.Any(key || "Http", reqRes);
|
1140
1157
|
return this;
|
1141
1158
|
}
|
1142
1159
|
Pair(x) {
|
@@ -1291,8 +1308,8 @@ var WithLoggerBuilder = class {
|
|
1291
1308
|
this._li.SetDebug(...modules);
|
1292
1309
|
return this;
|
1293
1310
|
}
|
1294
|
-
Http(
|
1295
|
-
this._li.Http(
|
1311
|
+
Http(...mix) {
|
1312
|
+
this._li.Http(...mix);
|
1296
1313
|
return this;
|
1297
1314
|
}
|
1298
1315
|
Pair(x) {
|