@adviser/cement 0.2.36 → 0.2.37
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +26 -16
- package/index.cjs.map +1 -1
- package/index.d.cts +5 -4
- package/index.d.ts +5 -4
- package/index.js +26 -16
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/jsr.json +1 -1
- package/src/logger-impl.ts +28 -13
- package/src/logger.ts +6 -1
- package/src/uri.ts +4 -3
- 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.map +1 -1
- package/ts/logger.test.js +324 -64
- package/ts/logger.test.js.map +1 -1
- package/ts/uri.d.ts +1 -1
- 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/index.d.cts
CHANGED
@@ -89,7 +89,7 @@ declare class MutableURL extends URL {
|
|
89
89
|
toString(): string;
|
90
90
|
}
|
91
91
|
type msgFn = (...keys: string[]) => string;
|
92
|
-
type keysParam = (string | msgFn | Record<string,
|
92
|
+
type keysParam = (string | msgFn | Record<string, unknown>)[];
|
93
93
|
declare class BuildURI implements URIInterface<BuildURI> {
|
94
94
|
_url: MutableURL;
|
95
95
|
private constructor();
|
@@ -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 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
@@ -89,7 +89,7 @@ declare class MutableURL extends URL {
|
|
89
89
|
toString(): string;
|
90
90
|
}
|
91
91
|
type msgFn = (...keys: string[]) => string;
|
92
|
-
type keysParam = (string | msgFn | Record<string,
|
92
|
+
type keysParam = (string | msgFn | Record<string, unknown>)[];
|
93
93
|
declare class BuildURI implements URIInterface<BuildURI> {
|
94
94
|
_url: MutableURL;
|
95
95
|
private constructor();
|
@@ -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 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
@@ -509,7 +509,7 @@ function getParamsResult(keys, getParam) {
|
|
509
509
|
if (typeof i === "string") {
|
510
510
|
acc.push({ key: i });
|
511
511
|
} else if (typeof i === "object") {
|
512
|
-
acc.push(...Object.keys(i).map((k) => ({ key: k, def: i[k] })));
|
512
|
+
acc.push(...Object.keys(i).map((k) => ({ key: k, def: typeof i[k] === "string" ? i[k] : void 0 })));
|
513
513
|
}
|
514
514
|
return acc;
|
515
515
|
},
|
@@ -524,7 +524,7 @@ function getParamsResult(keys, getParam) {
|
|
524
524
|
for (const kd of keyDef) {
|
525
525
|
const val = getParam.getParam(kd.key);
|
526
526
|
if (val === void 0) {
|
527
|
-
if (kd.def) {
|
527
|
+
if (typeof kd.def === "string") {
|
528
528
|
result[kd.key] = kd.def;
|
529
529
|
} else {
|
530
530
|
errors.push(kd.key);
|
@@ -1124,19 +1124,29 @@ var LoggerImpl = class _LoggerImpl {
|
|
1124
1124
|
this.coerceKey(key, !!value);
|
1125
1125
|
return this;
|
1126
1126
|
}
|
1127
|
-
Http(
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
}
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
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);
|
1138
1149
|
}
|
1139
|
-
this.Any(key || "Http", reqRes);
|
1140
1150
|
return this;
|
1141
1151
|
}
|
1142
1152
|
Pair(x) {
|
@@ -1291,8 +1301,8 @@ var WithLoggerBuilder = class {
|
|
1291
1301
|
this._li.SetDebug(...modules);
|
1292
1302
|
return this;
|
1293
1303
|
}
|
1294
|
-
Http(
|
1295
|
-
this._li.Http(
|
1304
|
+
Http(...mix) {
|
1305
|
+
this._li.Http(...mix);
|
1296
1306
|
return this;
|
1297
1307
|
}
|
1298
1308
|
Pair(x) {
|