@adviser/cement 0.2.41 → 0.2.42
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/{chunk-USQXEZHL.js → chunk-3RHIVQAA.js} +2 -2
- package/{chunk-W2GV5KXV.js → chunk-N3NUTN4B.js} +3 -3
- package/{chunk-F5W6VELE.js → chunk-N5LQQXOU.js} +2 -2
- package/chunk-PPS4L4VW.js +38 -0
- package/{chunk-GES3MUGV.js.map → chunk-PPS4L4VW.js.map} +1 -1
- package/index.cjs +352 -86
- package/index.cjs.map +1 -1
- package/index.d.cts +31 -1
- package/index.d.ts +31 -1
- package/index.js +355 -44
- package/index.js.map +1 -1
- package/node/index.js +2 -2
- package/package.json +2 -2
- package/src/http_header.ts +161 -0
- package/src/index.ts +1 -0
- package/src/jsr.json +1 -1
- package/src/uri.ts +31 -9
- package/src/utils/relative-path.ts +161 -0
- package/ts/http_header.d.ts +29 -0
- package/ts/http_header.d.ts.map +1 -0
- package/ts/http_header.js +155 -0
- package/ts/http_header.js.map +1 -0
- package/ts/http_header.test.d.ts +2 -0
- package/ts/http_header.test.d.ts.map +1 -0
- package/ts/http_header.test.js +90 -0
- package/ts/http_header.test.js.map +1 -0
- package/ts/index.d.ts +1 -0
- package/ts/index.d.ts.map +1 -1
- package/ts/index.js +1 -0
- package/ts/index.js.map +1 -1
- package/ts/logger-impl.js +8 -5
- package/ts/logger-impl.js.map +1 -1
- package/ts/logger.js +9 -3
- package/ts/logger.js.map +1 -1
- package/ts/tracer.js +24 -6
- package/ts/tracer.js.map +1 -1
- package/ts/uri.d.ts +1 -0
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +26 -10
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +34 -5
- package/ts/uri.test.js.map +1 -1
- package/ts/utils/relative-path.d.ts +17 -0
- package/ts/utils/relative-path.d.ts.map +1 -0
- package/ts/utils/relative-path.js +148 -0
- package/ts/utils/relative-path.js.map +1 -0
- package/ts/utils/relative-path.test.d.ts +2 -0
- package/ts/utils/relative-path.test.d.ts.map +1 -0
- package/ts/utils/relative-path.test.js +187 -0
- package/ts/utils/relative-path.test.js.map +1 -0
- package/ts/utils/stripper.js +1 -1
- package/ts/utils/stripper.js.map +1 -1
- package/utils/index.js +2 -2
- package/web/index.js +3 -3
- package/chunk-GES3MUGV.js +0 -92
- /package/{chunk-USQXEZHL.js.map → chunk-3RHIVQAA.js.map} +0 -0
- /package/{chunk-W2GV5KXV.js.map → chunk-N3NUTN4B.js.map} +0 -0
- /package/{chunk-F5W6VELE.js.map → chunk-N5LQQXOU.js.map} +0 -0
package/index.d.cts
CHANGED
@@ -126,6 +126,7 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
126
126
|
hostname(h: string): BuildURI;
|
127
127
|
protocol(p: string): BuildURI;
|
128
128
|
pathname(p: string): BuildURI;
|
129
|
+
resolve(p: CoerceURI): BuildURI;
|
129
130
|
appendRelative(p: CoerceURI): BuildURI;
|
130
131
|
cleanParams(): BuildURI;
|
131
132
|
delParam(key: string): BuildURI;
|
@@ -590,4 +591,33 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
590
591
|
|
591
592
|
declare const VERSION: string;
|
592
593
|
|
593
|
-
|
594
|
+
declare class HeadersImpl extends Headers {
|
595
|
+
readonly _headers: Map<string, string>;
|
596
|
+
constructor(init: Map<string, string>);
|
597
|
+
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
598
|
+
entries(): HeadersIterator<[string, string]>;
|
599
|
+
keys(): HeadersIterator<string>;
|
600
|
+
values(): HeadersIterator<string>;
|
601
|
+
append(key: string, value: string | string[] | undefined): HeadersImpl;
|
602
|
+
}
|
603
|
+
declare class HttpHeader {
|
604
|
+
readonly _headers: Map<string, string[]>;
|
605
|
+
static from(headers?: HeadersInit | NodeJS.Dict<string | string[]> | Headers): HttpHeader;
|
606
|
+
_asStringString(): Map<string, string>;
|
607
|
+
_key(key: string): string;
|
608
|
+
Values(key: string): string[];
|
609
|
+
Get(key: string): string | undefined;
|
610
|
+
Set(key: string, valueOr: string | string[]): HttpHeader;
|
611
|
+
Add(key: string, value: string | string[] | undefined): HttpHeader;
|
612
|
+
Del(ey: string): HttpHeader;
|
613
|
+
Items(): [string, string[]][];
|
614
|
+
SortItems(): [string, string[]][];
|
615
|
+
Clone(): HttpHeader;
|
616
|
+
AsRecordStringStringArray(): Record<string, string[]>;
|
617
|
+
AsRecordStringString(): Record<string, string>;
|
618
|
+
AsHeaderInit(): HeadersInit;
|
619
|
+
AsHeaders(): Headers;
|
620
|
+
Merge(other?: HttpHeader): HttpHeader;
|
621
|
+
}
|
622
|
+
|
623
|
+
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, HeadersImpl, type HostURIObject, HttpHeader, 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, type LogValueState, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, type MsgFn, MutableURL, None, Option, type PathURIObject, REQUIRED, 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
@@ -126,6 +126,7 @@ declare class BuildURI implements URIInterface<BuildURI> {
|
|
126
126
|
hostname(h: string): BuildURI;
|
127
127
|
protocol(p: string): BuildURI;
|
128
128
|
pathname(p: string): BuildURI;
|
129
|
+
resolve(p: CoerceURI): BuildURI;
|
129
130
|
appendRelative(p: CoerceURI): BuildURI;
|
130
131
|
cleanParams(): BuildURI;
|
131
132
|
delParam(key: string): BuildURI;
|
@@ -590,4 +591,33 @@ declare function bin2string(hex: ArrayBufferView, size?: number): string;
|
|
590
591
|
|
591
592
|
declare const VERSION: string;
|
592
593
|
|
593
|
-
|
594
|
+
declare class HeadersImpl extends Headers {
|
595
|
+
readonly _headers: Map<string, string>;
|
596
|
+
constructor(init: Map<string, string>);
|
597
|
+
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
598
|
+
entries(): HeadersIterator<[string, string]>;
|
599
|
+
keys(): HeadersIterator<string>;
|
600
|
+
values(): HeadersIterator<string>;
|
601
|
+
append(key: string, value: string | string[] | undefined): HeadersImpl;
|
602
|
+
}
|
603
|
+
declare class HttpHeader {
|
604
|
+
readonly _headers: Map<string, string[]>;
|
605
|
+
static from(headers?: HeadersInit | NodeJS.Dict<string | string[]> | Headers): HttpHeader;
|
606
|
+
_asStringString(): Map<string, string>;
|
607
|
+
_key(key: string): string;
|
608
|
+
Values(key: string): string[];
|
609
|
+
Get(key: string): string | undefined;
|
610
|
+
Set(key: string, valueOr: string | string[]): HttpHeader;
|
611
|
+
Add(key: string, value: string | string[] | undefined): HttpHeader;
|
612
|
+
Del(ey: string): HttpHeader;
|
613
|
+
Items(): [string, string[]][];
|
614
|
+
SortItems(): [string, string[]][];
|
615
|
+
Clone(): HttpHeader;
|
616
|
+
AsRecordStringStringArray(): Record<string, string[]>;
|
617
|
+
AsRecordStringString(): Record<string, string>;
|
618
|
+
AsHeaderInit(): HeadersInit;
|
619
|
+
AsHeaders(): Headers;
|
620
|
+
Merge(other?: HttpHeader): HttpHeader;
|
621
|
+
}
|
622
|
+
|
623
|
+
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, HeadersImpl, type HostURIObject, HttpHeader, 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, type LogValueState, LogWriteStream, type Logger, LoggerImpl, type LoggerImplParams, type LoggerInterface, Metric, type MetricMap, Metrics, MockLogger, type MockLoggerReturn, type MsgFn, MutableURL, None, Option, type PathURIObject, REQUIRED, 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,10 +2,10 @@ import {
|
|
2
2
|
ConsoleWriterStream,
|
3
3
|
FanoutWriteStream,
|
4
4
|
utils_exports
|
5
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-3RHIVQAA.js";
|
6
6
|
import {
|
7
7
|
WebSysAbstraction
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-N3NUTN4B.js";
|
9
9
|
import {
|
10
10
|
BaseSysAbstraction,
|
11
11
|
BrowserEnvActions,
|
@@ -30,14 +30,11 @@ import {
|
|
30
30
|
TimeUnits,
|
31
31
|
WrapperSysAbstraction,
|
32
32
|
envFactory
|
33
|
-
} from "./chunk-
|
33
|
+
} from "./chunk-N5LQQXOU.js";
|
34
34
|
import {
|
35
35
|
Utf8EnDecoder,
|
36
|
-
Utf8EnDecoderSingleton
|
37
|
-
|
38
|
-
__spreadValues,
|
39
|
-
__yieldStar
|
40
|
-
} from "./chunk-GES3MUGV.js";
|
36
|
+
Utf8EnDecoderSingleton
|
37
|
+
} from "./chunk-PPS4L4VW.js";
|
41
38
|
|
42
39
|
// src/logger-impl.ts
|
43
40
|
import YAML from "yaml";
|
@@ -115,15 +112,17 @@ function asyncLogValue(val) {
|
|
115
112
|
throw new Error("Not implemented");
|
116
113
|
}
|
117
114
|
function logValue(val, ctx) {
|
118
|
-
return logValueInternal(val,
|
115
|
+
return logValueInternal(val, {
|
116
|
+
...ctx,
|
119
117
|
state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
|
120
|
-
})
|
118
|
+
});
|
121
119
|
}
|
122
120
|
function logValueInternal(val, ctx) {
|
123
121
|
var _a, _b;
|
124
|
-
ctx =
|
122
|
+
ctx = {
|
123
|
+
...ctx,
|
125
124
|
state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
|
126
|
-
}
|
125
|
+
};
|
127
126
|
switch (typeof val) {
|
128
127
|
case "function":
|
129
128
|
return new LogValue(val);
|
@@ -161,7 +160,7 @@ function logValueInternal(val, ctx) {
|
|
161
160
|
}
|
162
161
|
if (Array.isArray(val)) {
|
163
162
|
return new LogValue(
|
164
|
-
() => val.map((v) => logValue(v,
|
163
|
+
() => val.map((v) => logValue(v, { ...ctx, state: void 0 }).value())
|
165
164
|
);
|
166
165
|
}
|
167
166
|
if (val instanceof Headers) {
|
@@ -316,6 +315,139 @@ function exception2Result(fn) {
|
|
316
315
|
}
|
317
316
|
}
|
318
317
|
|
318
|
+
// src/utils/relative-path.ts
|
319
|
+
var Path = class {
|
320
|
+
constructor(parts = []) {
|
321
|
+
this.parts = parts;
|
322
|
+
}
|
323
|
+
toString() {
|
324
|
+
return this.parts.map((part) => {
|
325
|
+
if (typeof part === "string") {
|
326
|
+
return part;
|
327
|
+
} else {
|
328
|
+
switch (part) {
|
329
|
+
case 1 /* Slash */:
|
330
|
+
case 3 /* Root */:
|
331
|
+
return "/";
|
332
|
+
case 4 /* Up */:
|
333
|
+
return "..";
|
334
|
+
default:
|
335
|
+
return part;
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}).join("");
|
339
|
+
}
|
340
|
+
add(part) {
|
341
|
+
if (this.parts.includes(3 /* Root */) && part === 3 /* Root */) {
|
342
|
+
throw new Error("Cannot add absolute part to absolute path");
|
343
|
+
}
|
344
|
+
const last = this.parts[this.parts.length - 1];
|
345
|
+
if (last & 1 /* Slash */ && part === 1 /* Slash */) {
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
switch (part) {
|
349
|
+
case ".":
|
350
|
+
this.parts.push(8 /* Noop */);
|
351
|
+
return;
|
352
|
+
case "..":
|
353
|
+
part = 4 /* Up */;
|
354
|
+
}
|
355
|
+
if (last === 8 /* Noop */ && part === 1 /* Slash */) {
|
356
|
+
if (last === 8 /* Noop */) {
|
357
|
+
this.parts.pop();
|
358
|
+
}
|
359
|
+
return;
|
360
|
+
}
|
361
|
+
this.parts.push(part);
|
362
|
+
}
|
363
|
+
};
|
364
|
+
function splitPath(path) {
|
365
|
+
const p = new Path();
|
366
|
+
if (path === "") {
|
367
|
+
return p;
|
368
|
+
}
|
369
|
+
for (let count = 0; path.length; count++) {
|
370
|
+
if (path.match(/^\/+/)) {
|
371
|
+
if (count === 0) {
|
372
|
+
p.add(3 /* Root */);
|
373
|
+
} else {
|
374
|
+
p.add(1 /* Slash */);
|
375
|
+
}
|
376
|
+
path = path.replace(/^\/+/, "");
|
377
|
+
} else {
|
378
|
+
const part = path.replace(/\/.*$/, "");
|
379
|
+
p.add(part);
|
380
|
+
path = path.replace(/^[^/]+/, "");
|
381
|
+
}
|
382
|
+
}
|
383
|
+
return p;
|
384
|
+
}
|
385
|
+
function pathJoin(...paths) {
|
386
|
+
let prev = "";
|
387
|
+
const res = [];
|
388
|
+
for (let i = 0; i < paths.length; i++) {
|
389
|
+
const path = paths[i];
|
390
|
+
if (path === "") {
|
391
|
+
continue;
|
392
|
+
}
|
393
|
+
if (!(prev.endsWith("/") || path.startsWith("/"))) {
|
394
|
+
if (prev !== "") {
|
395
|
+
res.push("/");
|
396
|
+
}
|
397
|
+
res.push(path);
|
398
|
+
} else {
|
399
|
+
res.push(path);
|
400
|
+
}
|
401
|
+
prev = path;
|
402
|
+
}
|
403
|
+
return res.join("");
|
404
|
+
}
|
405
|
+
function relativePath(path, relative) {
|
406
|
+
const relativeParts = splitPath(relative);
|
407
|
+
let result;
|
408
|
+
if (relativeParts.parts[0] === 3 /* Root */) {
|
409
|
+
result = relative;
|
410
|
+
} else {
|
411
|
+
result = pathJoin(path, relative);
|
412
|
+
}
|
413
|
+
const unoptPath = splitPath(result);
|
414
|
+
const out = [];
|
415
|
+
let topUp = false;
|
416
|
+
for (const part of unoptPath.parts) {
|
417
|
+
switch (part) {
|
418
|
+
case 3 /* Root */:
|
419
|
+
out.push(3 /* Root */);
|
420
|
+
break;
|
421
|
+
case 4 /* Up */:
|
422
|
+
if (out.length && !topUp) {
|
423
|
+
const last = out.length - 1;
|
424
|
+
if (typeof out[last] === "string" && out[last - 1] == 3 /* Root */) {
|
425
|
+
out.pop();
|
426
|
+
} else {
|
427
|
+
out.pop();
|
428
|
+
out.pop();
|
429
|
+
}
|
430
|
+
if (out.length === 0) {
|
431
|
+
topUp = !topUp ? true : topUp;
|
432
|
+
out.push(4 /* Up */);
|
433
|
+
}
|
434
|
+
} else {
|
435
|
+
out.push(4 /* Up */);
|
436
|
+
}
|
437
|
+
break;
|
438
|
+
case 1 /* Slash */:
|
439
|
+
if (!(out[out.length - 1] & 1 /* Slash */)) {
|
440
|
+
out.push(1 /* Slash */);
|
441
|
+
}
|
442
|
+
break;
|
443
|
+
default:
|
444
|
+
out.push(part);
|
445
|
+
break;
|
446
|
+
}
|
447
|
+
}
|
448
|
+
return new Path(out).toString();
|
449
|
+
}
|
450
|
+
|
319
451
|
// src/utils/stripper.ts
|
320
452
|
function stripper(strip, obj) {
|
321
453
|
const strips = Array.isArray(strip) ? strip : [strip];
|
@@ -335,7 +467,7 @@ function localStripper(path, restrips, obj) {
|
|
335
467
|
if (Array.isArray(obj)) {
|
336
468
|
return obj.map((i) => localStripper(path, restrips, i));
|
337
469
|
}
|
338
|
-
const ret =
|
470
|
+
const ret = { ...obj };
|
339
471
|
const matcher = (key, nextPath) => {
|
340
472
|
for (const re of restrips) {
|
341
473
|
if (re.test(key) || re.test(nextPath)) {
|
@@ -596,17 +728,29 @@ var BuildURI = class _BuildURI {
|
|
596
728
|
this._url.pathname = p;
|
597
729
|
return this;
|
598
730
|
}
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
pathname = pathname.replace(/^\//, "");
|
731
|
+
// could pass a relative path or a full URL
|
732
|
+
// if relative path, it will be appended to the current path
|
733
|
+
resolve(p) {
|
734
|
+
if (!p) {
|
735
|
+
return this;
|
605
736
|
}
|
606
|
-
if (
|
607
|
-
|
737
|
+
if (typeof p === "string") {
|
738
|
+
if (!p.match(/^[a-zA-Z0-9]+:/)) {
|
739
|
+
if (p.startsWith("/")) {
|
740
|
+
this.pathname(p);
|
741
|
+
return this;
|
742
|
+
}
|
743
|
+
return this.appendRelative(p);
|
744
|
+
}
|
608
745
|
}
|
609
|
-
this.
|
746
|
+
this._url = new MutableURL(p.toString());
|
747
|
+
return this;
|
748
|
+
}
|
749
|
+
appendRelative(p) {
|
750
|
+
const appendUrl = URI.from(p);
|
751
|
+
const pathname = "./" + appendUrl.pathname;
|
752
|
+
const basePath = this._url.pathname;
|
753
|
+
this.pathname(relativePath(basePath, pathname));
|
610
754
|
for (const [key, value] of appendUrl.getParams) {
|
611
755
|
this.setParam(key, value);
|
612
756
|
}
|
@@ -781,11 +925,12 @@ var URI = class _URI {
|
|
781
925
|
searchParams: Object.fromEntries(this.getParams)
|
782
926
|
};
|
783
927
|
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
784
|
-
return stripper(strips,
|
928
|
+
return stripper(strips, {
|
929
|
+
...pathURI,
|
785
930
|
style: "host",
|
786
931
|
hostname: this.hostname,
|
787
932
|
port: this.port
|
788
|
-
})
|
933
|
+
});
|
789
934
|
}
|
790
935
|
return stripper(strips, pathURI);
|
791
936
|
}
|
@@ -1100,9 +1245,9 @@ var LoggerImpl = class _LoggerImpl {
|
|
1100
1245
|
if (!params.withAttributes) {
|
1101
1246
|
this._withAttributes = {};
|
1102
1247
|
} else {
|
1103
|
-
this._withAttributes =
|
1248
|
+
this._withAttributes = { ...params.withAttributes };
|
1104
1249
|
}
|
1105
|
-
this._attributes =
|
1250
|
+
this._attributes = { ...this._withAttributes };
|
1106
1251
|
if (params.levelHandler) {
|
1107
1252
|
this.levelHandler = params.levelHandler;
|
1108
1253
|
} else {
|
@@ -1310,9 +1455,10 @@ var LoggerImpl = class _LoggerImpl {
|
|
1310
1455
|
sys: this._sys,
|
1311
1456
|
levelHandler: this.levelHandler,
|
1312
1457
|
formatter: this._formatter,
|
1313
|
-
withAttributes:
|
1314
|
-
module: this._attributes["module"]
|
1315
|
-
|
1458
|
+
withAttributes: {
|
1459
|
+
module: this._attributes["module"],
|
1460
|
+
...this._withAttributes
|
1461
|
+
}
|
1316
1462
|
})
|
1317
1463
|
);
|
1318
1464
|
}
|
@@ -1336,7 +1482,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
1336
1482
|
if (typeof msg === "string" && !msg.trim().length) {
|
1337
1483
|
delete this._attributes["msg"];
|
1338
1484
|
}
|
1339
|
-
let fnRet = () => this._formatter.format(
|
1485
|
+
let fnRet = () => this._formatter.format({ ...this._attributes });
|
1340
1486
|
if (doWrite) {
|
1341
1487
|
const encoded = fnRet();
|
1342
1488
|
this._logWriter.write(encoded);
|
@@ -1364,7 +1510,7 @@ var WithLoggerBuilder = class {
|
|
1364
1510
|
return this._li;
|
1365
1511
|
}
|
1366
1512
|
Attributes() {
|
1367
|
-
return
|
1513
|
+
return { ...this._li._attributes };
|
1368
1514
|
}
|
1369
1515
|
SetExposeStack(enable) {
|
1370
1516
|
this._li.levelHandler.setExposeStack(enable);
|
@@ -1544,7 +1690,7 @@ var LogCollector = class {
|
|
1544
1690
|
new Uint8Array(
|
1545
1691
|
function* (res) {
|
1546
1692
|
for (const x of res) {
|
1547
|
-
yield*
|
1693
|
+
yield* x;
|
1548
1694
|
}
|
1549
1695
|
}(this._bufferArr)
|
1550
1696
|
)
|
@@ -1663,22 +1809,24 @@ var TraceNode = class _TraceNode {
|
|
1663
1809
|
return this.ctx.parent.getRootPath(rpath.concat(this.ctx.spanId));
|
1664
1810
|
}
|
1665
1811
|
invokes() {
|
1666
|
-
const cleanCtx =
|
1812
|
+
const cleanCtx = { ...this.ctx };
|
1667
1813
|
delete cleanCtx.parent;
|
1668
1814
|
delete cleanCtx.time;
|
1669
1815
|
delete cleanCtx.logger;
|
1670
1816
|
delete cleanCtx.metrics;
|
1671
1817
|
const spanRefs = this.metrics.toJSON.call({ map: this.metrics.spanRefs });
|
1672
1818
|
const metricsRefs = Object.keys(spanRefs).length > 0 ? { metricRefs: spanRefs } : {};
|
1673
|
-
return
|
1819
|
+
return {
|
1674
1820
|
ctx: cleanCtx,
|
1675
|
-
invokations: this.invokations
|
1676
|
-
|
1821
|
+
invokations: this.invokations,
|
1822
|
+
...metricsRefs
|
1823
|
+
};
|
1677
1824
|
}
|
1678
1825
|
ctxWith(spanId, logger) {
|
1679
|
-
const ctx =
|
1826
|
+
const ctx = {
|
1827
|
+
...this.ctx,
|
1680
1828
|
spanId
|
1681
|
-
}
|
1829
|
+
};
|
1682
1830
|
if (logger) {
|
1683
1831
|
ctx.logger = logger;
|
1684
1832
|
}
|
@@ -1688,17 +1836,23 @@ var TraceNode = class _TraceNode {
|
|
1688
1836
|
span(inSpanId, fn) {
|
1689
1837
|
let ctx;
|
1690
1838
|
if (typeof inSpanId === "string") {
|
1691
|
-
ctx =
|
1839
|
+
ctx = {
|
1840
|
+
...this.ctx,
|
1692
1841
|
spanId: inSpanId,
|
1693
1842
|
parent: this
|
1694
|
-
}
|
1843
|
+
};
|
1695
1844
|
} else {
|
1696
|
-
ctx =
|
1845
|
+
ctx = {
|
1846
|
+
...this.ctx,
|
1847
|
+
...inSpanId,
|
1697
1848
|
parent: this
|
1698
|
-
}
|
1849
|
+
};
|
1699
1850
|
}
|
1700
1851
|
if (ctx.logger) {
|
1701
|
-
ctx =
|
1852
|
+
ctx = {
|
1853
|
+
...ctx,
|
1854
|
+
...ctx.logger.Attributes()
|
1855
|
+
};
|
1702
1856
|
}
|
1703
1857
|
const spanId = ctx.spanId;
|
1704
1858
|
let spanTrace = this.childs.get(spanId);
|
@@ -1761,6 +1915,161 @@ function toCryptoRuntime(cryptoOpts = {}) {
|
|
1761
1915
|
var VERSION = Object.keys({
|
1762
1916
|
__packageVersion__: "xxxx"
|
1763
1917
|
})[0];
|
1918
|
+
|
1919
|
+
// src/http_header.ts
|
1920
|
+
var HeadersImpl = class extends Headers {
|
1921
|
+
constructor(init) {
|
1922
|
+
super();
|
1923
|
+
this._headers = init;
|
1924
|
+
}
|
1925
|
+
[Symbol.iterator]() {
|
1926
|
+
return this.entries();
|
1927
|
+
}
|
1928
|
+
entries() {
|
1929
|
+
return this._headers.entries();
|
1930
|
+
}
|
1931
|
+
keys() {
|
1932
|
+
return this._headers.keys();
|
1933
|
+
}
|
1934
|
+
values() {
|
1935
|
+
return this._headers.values();
|
1936
|
+
}
|
1937
|
+
append(key, value) {
|
1938
|
+
const values = this._headers.get(key);
|
1939
|
+
if (typeof value === "undefined") {
|
1940
|
+
value = "";
|
1941
|
+
}
|
1942
|
+
if (Array.isArray(value)) {
|
1943
|
+
this._headers.set(key, [values, ...value].filter((i) => i).join(", "));
|
1944
|
+
} else {
|
1945
|
+
this._headers.set(key, [values, value].filter((i) => i).join(", "));
|
1946
|
+
}
|
1947
|
+
return this;
|
1948
|
+
}
|
1949
|
+
};
|
1950
|
+
var HttpHeader = class _HttpHeader {
|
1951
|
+
constructor() {
|
1952
|
+
this._headers = /* @__PURE__ */ new Map();
|
1953
|
+
}
|
1954
|
+
static from(headers) {
|
1955
|
+
const h = new _HttpHeader();
|
1956
|
+
if (headers) {
|
1957
|
+
if (Array.isArray(headers)) {
|
1958
|
+
for (const [k, v] of headers) {
|
1959
|
+
if (v) {
|
1960
|
+
h.Add(k, v);
|
1961
|
+
}
|
1962
|
+
}
|
1963
|
+
} else if (headers instanceof Headers) {
|
1964
|
+
for (const [k, v] of headers.entries()) {
|
1965
|
+
if (v) {
|
1966
|
+
h.Add(
|
1967
|
+
k,
|
1968
|
+
v.split(",").map((v2) => v2.trim())
|
1969
|
+
);
|
1970
|
+
}
|
1971
|
+
}
|
1972
|
+
} else {
|
1973
|
+
for (const k in headers) {
|
1974
|
+
const v = headers[k];
|
1975
|
+
if (v) {
|
1976
|
+
h.Add(k, v);
|
1977
|
+
}
|
1978
|
+
}
|
1979
|
+
}
|
1980
|
+
}
|
1981
|
+
return h;
|
1982
|
+
}
|
1983
|
+
_asStringString() {
|
1984
|
+
const ret = /* @__PURE__ */ new Map();
|
1985
|
+
for (const [key, values] of this._headers) {
|
1986
|
+
ret.set(key, values.join(", "));
|
1987
|
+
}
|
1988
|
+
return ret;
|
1989
|
+
}
|
1990
|
+
_key(key) {
|
1991
|
+
return key.toLowerCase();
|
1992
|
+
}
|
1993
|
+
Values(key) {
|
1994
|
+
const values = this._headers.get(this._key(key));
|
1995
|
+
return values || [];
|
1996
|
+
}
|
1997
|
+
Get(key) {
|
1998
|
+
const values = this._headers.get(this._key(key));
|
1999
|
+
if (values === void 0 || values.length === 0) {
|
2000
|
+
return void 0;
|
2001
|
+
}
|
2002
|
+
return values[0];
|
2003
|
+
}
|
2004
|
+
Set(key, valueOr) {
|
2005
|
+
const value = Array.isArray(valueOr) ? valueOr : [valueOr];
|
2006
|
+
this._headers.set(this._key(key), value);
|
2007
|
+
return this;
|
2008
|
+
}
|
2009
|
+
Add(key, value) {
|
2010
|
+
if (typeof value === "undefined") {
|
2011
|
+
return this;
|
2012
|
+
}
|
2013
|
+
const vs = Array.isArray(value) ? value : [value];
|
2014
|
+
const values = this._headers.get(this._key(key));
|
2015
|
+
if (values === void 0) {
|
2016
|
+
this._headers.set(this._key(key), vs);
|
2017
|
+
} else {
|
2018
|
+
values.push(...vs);
|
2019
|
+
}
|
2020
|
+
return this;
|
2021
|
+
}
|
2022
|
+
Del(ey) {
|
2023
|
+
this._headers.delete(this._key(ey));
|
2024
|
+
return this;
|
2025
|
+
}
|
2026
|
+
Items() {
|
2027
|
+
return Array.from(this._headers).filter(([_, vs]) => vs.length > 0);
|
2028
|
+
}
|
2029
|
+
SortItems() {
|
2030
|
+
return this.Items().sort(([[a]], [[b]]) => a.localeCompare(b));
|
2031
|
+
}
|
2032
|
+
Clone() {
|
2033
|
+
const clone = new _HttpHeader();
|
2034
|
+
for (const [key, values] of this._headers.entries()) {
|
2035
|
+
clone._headers.set(key, values.slice());
|
2036
|
+
}
|
2037
|
+
return clone;
|
2038
|
+
}
|
2039
|
+
AsRecordStringStringArray() {
|
2040
|
+
const obj = {};
|
2041
|
+
for (const [key, values] of this._headers.entries()) {
|
2042
|
+
obj[key] = [...values];
|
2043
|
+
}
|
2044
|
+
return obj;
|
2045
|
+
}
|
2046
|
+
AsRecordStringString() {
|
2047
|
+
const obj = {};
|
2048
|
+
for (const [key, values] of this._headers.entries()) {
|
2049
|
+
obj[key] = values.join(", ");
|
2050
|
+
}
|
2051
|
+
return obj;
|
2052
|
+
}
|
2053
|
+
AsHeaderInit() {
|
2054
|
+
const obj = {};
|
2055
|
+
for (const [key, values] of this._headers.entries()) {
|
2056
|
+
obj[key] = values[0];
|
2057
|
+
}
|
2058
|
+
return obj;
|
2059
|
+
}
|
2060
|
+
AsHeaders() {
|
2061
|
+
return new HeadersImpl(this._asStringString());
|
2062
|
+
}
|
2063
|
+
Merge(other) {
|
2064
|
+
const ret = this.Clone();
|
2065
|
+
if (other) {
|
2066
|
+
for (const [key, values] of other.Items()) {
|
2067
|
+
ret.Add(key, values);
|
2068
|
+
}
|
2069
|
+
}
|
2070
|
+
return ret;
|
2071
|
+
}
|
2072
|
+
};
|
1764
2073
|
export {
|
1765
2074
|
BaseSysAbstraction,
|
1766
2075
|
BrowserEnvActions,
|
@@ -1768,6 +2077,8 @@ export {
|
|
1768
2077
|
ConstTime,
|
1769
2078
|
EnvImpl,
|
1770
2079
|
Future,
|
2080
|
+
HeadersImpl,
|
2081
|
+
HttpHeader,
|
1771
2082
|
IDMode,
|
1772
2083
|
IdService,
|
1773
2084
|
IsLogger,
|