@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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/logger-impl.ts","../../src/bin2text.ts","../../src/logger.ts","../../src/result.ts","../../src/utils/stripper.ts","../../src/uri.ts","../../src/runtime.ts","../../src/log-writer-impl.ts","../../src/log-level-impl.ts","../../src/test/log-write-stream.ts","../../src/test/mock-logger.ts","../../src/option.ts","../../src/tracer.ts","../../src/crypto.ts","../../src/version.ts"],"sourcesContent":["// import { v4 } from \"uuid\";\nimport YAML from \"yaml\";\nimport {\n AsError,\n FnSerialized,\n LogSerializable,\n Level,\n Logger,\n logValue,\n Serialized,\n WithLogger,\n // sanitizeSerialize,\n Sized,\n Lengthed,\n LogValue,\n asyncLogValue,\n LevelHandler,\n LogFormatter,\n LogValueArg,\n} from \"./logger.js\";\nimport { WebSysAbstraction } from \"./web/web-sys-abstraction.js\";\nimport { SysAbstraction } from \"./sys-abstraction.js\";\nimport { Result } from \"./result.js\";\nimport { CoerceURI, URI } from \"./uri.js\";\nimport { runtimeFn } from \"./runtime.js\";\nimport { ConsoleWriterStream } from \"./utils/console-write-stream.js\";\nimport { LogWriterStream } from \"./log-writer-impl.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"./txt-en-decoder.js\";\nimport { LevelHandlerSingleton } from \"./log-level-impl.js\";\n\nfunction getLen(value: unknown): LogValue {\n if (Array.isArray(value)) {\n return logValue(() => value.length);\n } else if (typeof value === \"string\") {\n return logValue(() => value.length);\n } else if (typeof value === \"object\" && value !== null) {\n if (typeof (value as Sized).size === \"number\") {\n return logValue(() => (value as Sized).size);\n } else if (typeof (value as Lengthed).length === \"number\") {\n return logValue(() => (value as Lengthed).length);\n }\n return logValue(() => Object.keys(value).length);\n }\n return logValue(() => -1);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction hash(value: unknown): string {\n // const hasher = createHash(\"sha256\");\n // hasher.update(JSON.stringify(value, removeSelfRef()));\n // return hasher.digest(\"hex\");\n return \"not implemented\";\n}\n\nfunction toLogValue(lop: LogValue | Promise<LogValue>): LogValue | undefined {\n if (lop && typeof (lop as Promise<LogValue>).then === \"function\") {\n throw new Error(\"async logValue Not implemented\");\n }\n return lop as LogValue;\n}\n\nexport class JSONFormatter implements LogFormatter {\n private readonly _txtEnDe: TxtEnDecoder;\n private readonly _space?: number;\n constructor(txtEnde: TxtEnDecoder, space?: number) {\n this._txtEnDe = txtEnde;\n this._space = space;\n }\n format(attr: LogSerializable): Uint8Array {\n let ret: string;\n try {\n ret = JSON.stringify(attr, null, this._space);\n } catch (e) {\n ret = JSON.stringify({ internal: { message: (e as Error).message, stack: (e as Error).stack } });\n }\n return this._txtEnDe.encode(ret + \"\\n\");\n }\n}\n\nexport class YAMLFormatter implements LogFormatter {\n private readonly _txtEnDe: TxtEnDecoder;\n private readonly _space?: number;\n constructor(txtEnde: TxtEnDecoder, space?: number) {\n this._txtEnDe = txtEnde;\n this._space = space;\n }\n format(attr: LogSerializable): Uint8Array {\n return this._txtEnDe.encode(\"---\\n\" + YAML.stringify(attr, null, this._space) + \"\\n\");\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriterStream;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: LogSerializable;\n readonly levelHandler?: LevelHandler;\n readonly txtEnDe?: TxtEnDecoder;\n readonly formatter?: LogFormatter;\n}\n\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: LogSerializable = {};\n readonly _withAttributes: LogSerializable;\n readonly _logWriter: LogWriterStream;\n readonly _levelHandler: LevelHandler;\n readonly _txtEnDe: TxtEnDecoder;\n _formatter: LogFormatter;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (!params.txtEnDe) {\n this._txtEnDe = Utf8EnDecoderSingleton();\n } else {\n this._txtEnDe = params.txtEnDe;\n }\n if (!params.formatter) {\n this._formatter = new JSONFormatter(this._txtEnDe);\n } else {\n this._formatter = params.formatter;\n }\n\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n const rt = runtimeFn();\n let stream: WritableStream<Uint8Array>;\n if (rt.isBrowser) {\n stream = new ConsoleWriterStream();\n } else {\n if (rt.isNodeIsh || rt.isReactNative || rt.isDeno) {\n stream = this._sys.Stdout();\n } else {\n throw new Error(\"No output defined for runtime\");\n }\n }\n this._logWriter = new LogWriterStream(stream);\n } else {\n this._logWriter = new LogWriterStream(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = LevelHandlerSingleton();\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n TxtEnDe(): TxtEnDecoder {\n return this._txtEnDe;\n }\n\n Attributes(): Record<string, unknown> {\n return JSON.parse(JSON.stringify(this._attributes, null));\n // return Array.from(Object.entries(this._attributes)).reduce(\n // (acc, [key, value]) => {\n // if (value instanceof LogValue) {\n // acc[key] = value.value();\n // }\n // return acc;\n // },\n // {} as Record<string, unknown>,\n // );\n }\n\n SetExposeStack(enable?: boolean): Logger {\n this._levelHandler.setExposeStack(enable);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = logValue(key);\n this._withAttributes[\"module\"] = logValue(key);\n return this;\n }\n // if the string is \"*\" it will enable for all modules\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n return this;\n }\n\n SetFormatter(formatter: LogFormatter): Logger {\n this._formatter = formatter;\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = logValue(() => this._sys.Time().Now().toISOString());\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN);\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG);\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR);\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO);\n return this;\n }\n Err(err: unknown | Result<unknown> | Error): Logger {\n if (Result.Is(err)) {\n if (err.isOk()) {\n this.Result(\"noerror\", err);\n } else {\n this.Result(\"error\", err);\n }\n } else if (err instanceof Error) {\n this._attributes[\"error\"] = logValue(err.message);\n if (this._levelHandler.isStackExposed) {\n this._attributes[\"stack\"] = logValue(err.stack?.split(\"\\n\").map((s) => s.trim()));\n }\n } else {\n this._attributes[\"error\"] = logValue(\"\" + err);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l);\n return this;\n }\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): Logger {\n if (typeof action === \"function\") {\n this._attributes[key] = logValue(action as FnSerialized);\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString());\n } else {\n this._attributes[key] = logValue(\"INVALID REF\");\n }\n return this;\n }\n Bool(key: string, value: unknown): Logger {\n this._attributes[key] = logValue(!!value);\n return this;\n }\n\n Http(res: Response | Result<Response>, req?: Request, key?: string): Logger {\n if (Result.Is(res)) {\n if (res.isErr()) {\n this.Err(res.Err());\n return this;\n }\n res = res.Ok();\n }\n let reqRes: Response | { res: Response; req: Request } = res;\n if (req) {\n reqRes = { res, req };\n }\n this.Any(key || \"Http\", reqRes as unknown as LogSerializable);\n return this;\n }\n Pair(x: Record<string, unknown>): Logger {\n for (const key of Object.keys(x)) {\n const value = x[key];\n if (value instanceof LogValue) {\n this._attributes[key] = value;\n continue;\n }\n if (Result.Is(value)) {\n this.Result(key, value);\n continue;\n }\n this.Any(key, value as LogSerializable);\n }\n return this;\n }\n\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized);\n } else {\n this.Err(res.Err());\n }\n return this;\n }\n\n Len(value: unknown, key = \"len\"): Logger {\n this._attributes[key] = getLen(value);\n return this;\n }\n\n Hash(value: unknown, key = \"hash\"): Logger {\n this._attributes[key] = asyncLogValue(async () => `${getLen(value).value()}:${await hash(value)}`);\n return this;\n }\n\n Url(url: CoerceURI, key = \"url\"): Logger {\n this.Ref(key, () => URI.from(url).toString());\n return this;\n }\n\n Str(key: string, value?: string): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n\n Any(key: string, value?: string | number | boolean | LogSerializable): Logger {\n this._attributes[key] = logValue(value as LogValueArg);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`);\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string, value: number): Logger {\n this._attributes[key] = logValue(value);\n return this;\n }\n Int(key: string, value: number): Logger {\n return this.Uint64(key, value);\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n formatter: this._formatter,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => () => Uint8Array): () => Uint8Array {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n\n Msg(...args: string[]): AsError {\n const fnError = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(\n toLogValue(this._attributes[\"level\"])?.value(),\n toLogValue(this._attributes[\"module\"])?.value(),\n );\n this._attributes[\"msg\"] = logValue(args.join(\" \"));\n const msg = this._attributes[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete this._attributes[\"msg\"];\n }\n let fnRet = (): Uint8Array => this._formatter.format({ ...this._attributes });\n if (doWrite) {\n const encoded = fnRet();\n this._logWriter.write(encoded);\n fnRet = (): Uint8Array => encoded;\n }\n return fnRet;\n });\n const asError = (): Error => new Error(this._txtEnDe.decode(fnError()));\n return {\n ResultError: () => Result.Err(asError()),\n AsError: asError,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n\n TxtEnDe(): TxtEnDecoder {\n return this._li.TxtEnDe();\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n Attributes(): Record<string, unknown> {\n return { ...this._li._attributes };\n }\n\n SetExposeStack(enable?: boolean): WithLogger {\n this._li._levelHandler.setExposeStack(enable);\n return this;\n }\n\n SetFormatter(fmt: LogFormatter): WithLogger {\n this._li.SetFormatter(fmt);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Http(res: Response | Result<Response>, req?: Request, key?: string): WithLogger {\n this._li.Http(res, req, key);\n return this;\n }\n Pair(x: Record<string, unknown>): WithLogger {\n this._li.Pair(x);\n return this;\n }\n\n Str(key: string, value?: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Len(value: unknown, key?: string): WithLogger {\n this._li.Len(value, key);\n return this;\n }\n\n Hash(value: unknown, key?: string): WithLogger {\n this._li.Hash(value, key);\n return this;\n }\n\n Ref(key: string, action: Serialized | FnSerialized): WithLogger {\n this._li.Ref(key, action);\n return this;\n }\n Bool(key: string, value: unknown): WithLogger {\n this._li.Bool(key, value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): WithLogger {\n this._li.Result(key, res);\n return this;\n }\n Url(url: CoerceURI, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string, value: number): WithLogger {\n this._li.Int(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li.Timestamp();\n return this;\n }\n Any(key: string, value: LogSerializable): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string, value: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size = 0): void {\n const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);\n let cutted = \" \";\n if (size == 0) {\n size = arr.length;\n }\n size = Math.min(size, arr.length);\n const cols = 16;\n for (let line = 0; line < size; line += cols) {\n if (line + cols <= size || arr.length == size) {\n // normal line\n } else {\n line = arr.length - (arr.length % cols);\n size = arr.length;\n cutted = \">>\";\n }\n const l: string[] = [line.toString(16).padStart(4, \"0\"), cutted];\n for (let col = 0; col < cols; col++) {\n if (line + col < size) {\n l.push(arr[line + col].toString(16).padStart(2, \"0\"));\n } else {\n l.push(\" \");\n }\n // l.push((col > 0 && col % 4 === 3) ? \" \" : \" \");\n l.push(\" \");\n }\n for (let col = 0; col < cols; col++) {\n if (line + col < size) {\n const ch = arr[line + col];\n l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : \".\");\n }\n }\n lineFn(l.join(\"\"));\n }\n}\n\nexport function bin2string(hex: ArrayBufferView, size = 0): string {\n const collector: string[] = [];\n bin2text(\n hex,\n (line) => {\n collector.push(line);\n },\n size,\n );\n return collector.join(\"\\n\");\n}\n","import { bin2string } from \"./bin2text.js\";\nimport { Result } from \"./result.js\";\nimport { TxtEnDecoder } from \"./txt-en-decoder.js\";\nimport { CoerceURI } from \"./uri.js\";\n\nexport enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport type Serialized = string | number | boolean;\nexport type FnSerialized = () => Serialized | Serialized[];\n\nexport class LogValue {\n constructor(readonly fn: FnSerialized) {}\n value(): Serialized | Serialized[] {\n try {\n // console.log(\"LogValue.value\", this.fn.toString());\n return this.fn();\n } catch (e) {\n return `LogValue:${(e as Error).message}`;\n }\n }\n toJSON(): Serialized | Serialized[] {\n return this.value();\n }\n}\n\nexport type LogSerializable = Record<string, LogValue | Promise<LogValue>>;\n\n// export function sanitizeSerialize(lineEnd?: string): (key: unknown, val: unknown) => unknown {\n// const cache = new Set();\n// return function (this: unknown, key: unknown, value: unknown) {\n// if (typeof value === \"object\" && value !== null) {\n// // Duplicate reference found, discard key\n// if (cache.has(value)) return \"...\";\n// cache.add(value);\n// }\n// return lineEnd ? value + lineEnd : value;\n// };\n// }\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue> {\n // return Promise.resolve(logValue(val));\n throw new Error(\"Not implemented\");\n}\n\nexport type LogValueArg = LogValue | Serialized | Serialized[] | FnSerialized | undefined | null;\n\nexport function logValue(val: LogValueArg, state: Set<unknown> = new Set<unknown>([Math.random()])): LogValue {\n switch (typeof val) {\n case \"function\":\n return new LogValue(val);\n case \"string\": {\n try {\n const ret = JSON.parse(val);\n if (typeof ret === \"object\" && ret !== null) {\n return logValue(ret, state);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n if (val.match(/[\\n\\r]/)) {\n const lines = val.trimEnd().split(/[\\n\\r]/);\n return new LogValue(() => lines);\n }\n }\n return new LogValue(() => val.toString());\n }\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\": {\n if (val === null) {\n return new LogValue(() => \"null\");\n }\n if (ArrayBuffer.isView(val)) {\n return logValue(bin2string(val, 512));\n }\n if (Array.isArray(val)) {\n return new LogValue(() => (val as Serialized[]).map((v) => logValue(v).value() as Serialized));\n }\n // if (val instanceof Response) {\n // // my = my.clone() as unknown as LogValue | Serialized[] | null\n // // const rval = my as unknown as Partial<Response>;\n // // delete rval.clone\n // // delete rval.blob\n // }\n if (val instanceof Headers) {\n return new LogValue(() => Object.fromEntries(val.entries()) as unknown as Serialized);\n }\n if (val instanceof ReadableStream) {\n return new LogValue(() => \">Stream<\");\n }\n if (val instanceof Promise) {\n return new LogValue(() => \">Promise<\");\n }\n\n // Duplicate reference found, discard key\n if (state.has(val)) {\n return new LogValue(() => \"...\");\n }\n state.add(val);\n if (typeof val.toJSON === \"function\") {\n return new LogValue(() => val.toJSON());\n }\n\n const res: Record<string, LogValue> = {};\n const typedVal = val as unknown as Record<string, LogValueArg>;\n for (const key in typedVal) {\n const element = typedVal[key];\n if (element instanceof LogValue) {\n res[key] = element;\n } else {\n if (typeof element !== \"function\") {\n res[key] = logValue(element, state);\n }\n // res[key] = logValue(element, state);\n }\n }\n // ugly as hell cast but how declare a self-referencing type?\n return new LogValue(() => res as unknown as Serialized);\n }\n default:\n if (!val) {\n return new LogValue(() => \"--Falsy--\");\n }\n throw new Error(`Invalid type:${typeof val}`);\n }\n}\n\nexport interface Sized {\n size: number;\n}\nexport interface Lengthed {\n length: number;\n}\nexport type SizeOrLength = Sized | Lengthed;\n\nexport interface LogFormatter {\n format(attr: LogSerializable): Uint8Array;\n}\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setExposeStack(enable?: boolean): void;\n isStackExposed: boolean;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport interface LoggerInterface<R> {\n TxtEnDe(): TxtEnDecoder;\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n Attributes(): Record<string, unknown>;\n\n SetDebug(...modules: (string | string[])[]): R;\n SetExposeStack(enable?: boolean): R;\n SetFormatter(fmt: LogFormatter): R;\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): R;\n Result<T>(key: string, res: Result<T>): R;\n // default key url\n Url(url: CoerceURI, key?: string): R;\n // len\n Len(value: unknown, key?: string): R;\n\n Hash(value: unknown, key?: string): R;\n\n Str(key: string, value?: string): R;\n\n Http(res: Response | Result<Response>, req?: Request, key?: string): R;\n Pair(x: Record<string, unknown>): R;\n\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown | Result<unknown> | Error): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Any(key: string, value: unknown): R;\n Dur(key: string, nsec: number): R;\n Uint64(key: string, value: number): R;\n Int(key: string, value: number): R;\n Bool(key: string, value: unknown): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n ResultError<T>(): Result<T>;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T = void>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T, E extends Error = Error>(t: E | string): Result<T, E> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as E);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n if (!t) {\n return false;\n }\n if (t instanceof Result) {\n return true;\n }\n const rt = t as Result<T>;\n if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === \"function\")) {\n return true;\n }\n return false;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n// type WithoutPromise<T> = T extends Promise<infer U> ? U : T;\ntype WithResult<T> = T extends Promise<infer U> ? Promise<Result<U>> : Result<T>;\n\nexport function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): WithResult<ReturnType<FN>> {\n try {\n const res = fn();\n if (res instanceof Promise) {\n return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e)) as WithResult<ReturnType<FN>>;\n }\n return Result.Ok(res) as WithResult<ReturnType<FN>>;\n } catch (e) {\n return Result.Err(e as Error) as WithResult<ReturnType<FN>>;\n }\n}\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export type StripCommand = string | RegExp;\n\nexport function stripper<T extends unknown | ArrayLike<unknown>>(\n strip: StripCommand | StripCommand[],\n obj: T,\n): T extends ArrayLike<unknown> ? Record<string, unknown>[] : Record<string, unknown> {\n const strips = Array.isArray(strip) ? strip : [strip];\n const restrips = strips.map((s) => {\n if (typeof s === \"string\") {\n const escaped = s.replace(/[-\\\\[\\]\\\\/\\\\{\\\\}\\\\(\\\\)\\\\*\\\\+\\\\?\\\\.\\\\\\\\^\\\\$\\\\|]/g, \"\\\\$&\");\n return new RegExp(`^${escaped}$`);\n }\n return s;\n });\n return localStripper(undefined, restrips, obj) as T extends ArrayLike<unknown>\n ? Record<string, unknown>[]\n : Record<string, unknown>;\n}\n\nfunction localStripper<T>(path: string | undefined, restrips: RegExp[], obj: T): unknown {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map((i) => localStripper(path, restrips, i));\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const ret = { ...obj } as Record<string, any>;\n const matcher = (key: string, nextPath: string): boolean => {\n for (const re of restrips) {\n if (re.test(key) || re.test(nextPath)) {\n return true;\n }\n }\n return false;\n };\n for (const key in ret) {\n if (Object.prototype.hasOwnProperty.call(ret, key)) {\n let nextPath: string;\n if (path) {\n nextPath = [path, key].join(\".\");\n } else {\n nextPath = key;\n }\n if (matcher(key, nextPath)) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete ret[key];\n continue;\n }\n if (typeof ret[key] === \"object\") {\n if (Array.isArray(ret[key])) {\n ret[key] = ret[key].reduce((acc, v, i) => {\n const toDelete = matcher(key, `${nextPath}[${i}]`);\n if (!toDelete) {\n acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));\n }\n return acc;\n }, []);\n } else {\n ret[key] = localStripper(nextPath, restrips, ret[key]);\n }\n }\n }\n }\n return ret;\n}\n","import { exception2Result, Result } from \"./result.js\";\nimport { StripCommand, stripper } from \"./utils/stripper.js\";\n\ntype NullOrUndef = null | undefined;\n\nexport interface URIObject {\n readonly style: \"host\" | \"path\";\n readonly protocol: string;\n readonly pathname: string;\n readonly searchParams: Record<string, string>;\n}\n\nexport interface PathURIObject extends URIObject {\n readonly style: \"path\";\n}\n\nexport interface HostURIObject extends URIObject {\n readonly style: \"host\";\n readonly hostname: string;\n readonly port: string;\n}\n\nfunction falsy2undef<T>(value: T | NullOrUndef): T | undefined {\n return value === undefined || value === null ? undefined : value;\n}\n\nfunction ensureURLWithDefaultProto(url: string | URL, defaultProtocol: string): MutableURL {\n if (!url) {\n return new MutableURL(`${defaultProtocol}//`);\n }\n if (typeof url === \"string\") {\n try {\n return new MutableURL(url);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n return new MutableURL(`${defaultProtocol}//${url}`);\n }\n } else {\n return new MutableURL(url.toString());\n }\n}\n\nexport function isURL(value: unknown): value is URL {\n return (\n value instanceof URL ||\n (!!value &&\n typeof (value as URL).searchParams === \"object\" &&\n typeof (value as URL).searchParams.sort === \"function\" &&\n typeof (value as URL).hash === \"string\")\n );\n}\n\n// due to that the System URL class is has a strange behavior\n// on different platforms, we need to implement our own URL class\nexport class MutableURL extends URL {\n private readonly _sysURL: URL;\n // private readonly _urlStr: string;\n\n private _protocol: string;\n private _pathname: string;\n private _hasHostpart: boolean;\n\n override readonly hash: string;\n\n constructor(urlStr: string) {\n super(\"defect://does.not.exist\");\n const partedURL = urlStr.split(\":\");\n this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);\n let hostPartUrl = [\"http\", ...partedURL.slice(1)].join(\":\");\n if (!this._hasHostpart) {\n const pathname = hostPartUrl.replace(/http:\\/\\/[/]*/, \"\").replace(/[#?].*$/, \"\");\n hostPartUrl = hostPartUrl.replace(/http:\\/\\//, `http://localhost/${pathname}`);\n }\n try {\n this._sysURL = new URL(hostPartUrl);\n } catch (ie) {\n const e = ie as Error;\n e.message = `${e.message} for URL: ${urlStr}`;\n throw e;\n }\n this._protocol = `${partedURL[0]}:`; // this._sysURL.protocol.replace(new RegExp(\"^cement-\"), \"\");\n if (this._hasHostpart) {\n this._pathname = this._sysURL.pathname;\n } else {\n this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), \"\").replace(/[#?].*$/, \"\");\n }\n this.hash = this._sysURL.hash;\n }\n\n clone(): MutableURL {\n return new MutableURL(this.toString());\n }\n\n override get host(): string {\n if (!this._hasHostpart) {\n throw new Error(\n `you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`,\n );\n }\n return this._sysURL.host;\n }\n\n override get port(): string {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n return this._sysURL.port;\n }\n\n override set port(p: string) {\n if (!this._hasHostpart) {\n throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n this._sysURL.port = p;\n }\n\n override get hostname(): string {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n return this._sysURL.hostname;\n }\n\n override set hostname(h: string) {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n this._sysURL.hostname = h;\n }\n\n override set pathname(p: string) {\n this._pathname = p;\n }\n\n override get pathname(): string {\n return this._pathname;\n }\n\n override get protocol(): string {\n return this._protocol;\n }\n\n override set protocol(p: string) {\n if (!p.endsWith(\":\")) {\n p = `${p}:`;\n }\n this._protocol = p;\n }\n\n override get searchParams(): URLSearchParams {\n return this._sysURL.searchParams;\n }\n\n override toString(): string {\n let search = \"\";\n if (this._sysURL.searchParams.size) {\n for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {\n search += `${!search.length ? \"?\" : \"&\"}${key}=${encodeURIComponent(value)}`;\n }\n }\n let hostpart = \"\";\n if (this._hasHostpart) {\n hostpart = this._sysURL.hostname;\n if (this._sysURL.port) {\n hostpart += `:${this._sysURL.port}`;\n }\n if (!this._pathname.startsWith(\"/\")) {\n hostpart += \"/\";\n }\n }\n return `${this._protocol}//${hostpart}${this._pathname}${search}`;\n }\n}\n\nfunction from<T>(fac: (url: MutableURL) => T, strURLUri: CoerceURI | undefined, defaultProtocol: string): T {\n switch (typeof falsy2undef(strURLUri)) {\n case \"undefined\":\n return fac(new MutableURL(`${defaultProtocol}///`));\n case \"string\":\n return fac(ensureURLWithDefaultProto(strURLUri as string, defaultProtocol));\n case \"object\":\n if (BuildURI.is(strURLUri)) {\n return fac(new MutableURL(strURLUri._url.toString()));\n } else if (URI.is(strURLUri)) {\n return fac(new MutableURL(strURLUri._url.toString()));\n } else if (isURL(strURLUri)) {\n return fac(new MutableURL(strURLUri.toString()));\n }\n throw new Error(`unknown object type: ${strURLUri}`);\n default:\n throw new Error(`Invalid argument: ${typeof strURLUri}`);\n }\n}\n\nfunction getParamResult(\n key: string,\n val: string | undefined,\n msgFn: (key: string) => string = (key) => {\n return `missing parameter: ${key}`;\n },\n): Result<string> {\n if (val === undefined) {\n return Result.Err(msgFn(key));\n }\n return Result.Ok(val);\n}\n\ntype keysParam = (string | ((...keys: string[]) => string))[];\n\nfunction getParamsResult(\n keys: keysParam,\n getParam: { getParam: (key: string) => string | undefined },\n): Result<Record<string, string>> {\n const keyStrs = keys.flat().filter((k) => typeof k === \"string\");\n const msgFn =\n keys.find((k) => typeof k === \"function\") ||\n ((...keys: string[]): string => {\n const msg = keys.join(\",\");\n return `missing parameters: ${msg}`;\n });\n const errors: string[] = [];\n const result: Record<string, string> = {};\n for (const key of keyStrs) {\n const val = getParam.getParam(key);\n if (val === undefined) {\n errors.push(key);\n } else {\n result[key] = val;\n }\n }\n if (errors.length) {\n return Result.Err(msgFn(...errors));\n }\n return Result.Ok(result);\n}\n\nexport class BuildURI {\n _url: MutableURL; // pathname needs this\n private constructor(url: MutableURL) {\n this._url = url;\n }\n\n static is(value: unknown): value is BuildURI {\n return (\n value instanceof BuildURI ||\n (!!value && typeof (value as BuildURI).delParam === \"function\" && typeof (value as BuildURI).setParam === \"function\")\n );\n }\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): BuildURI {\n return from((url) => new BuildURI(url), strURLUri, defaultProtocol);\n }\n\n port(p: string): BuildURI {\n this._url.port = p;\n return this;\n }\n\n hostname(h: string): BuildURI {\n this._url.hostname = h;\n return this;\n }\n\n // password(p: string) {\n // this._url.password = p;\n // return this;\n // }\n\n // port(p: string) {\n // this._url.port = p;\n // return this;\n // }\n\n // username(u: string) {\n // this._url.username = u;\n // return this;\n // }\n\n // search(s: string) {\n // this._url.search = s;\n // return this;\n // }\n\n protocol(p: string): BuildURI {\n this._url.protocol = p;\n // if (!p.endsWith(\":\")) {\n // p = `${p}:`;\n // }\n // const mySrc = this._url.toString();\n // const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}`), `${p}`);\n // this._url = new URL(myDst);\n return this;\n }\n\n pathname(p: string): BuildURI {\n // const myp = this.URI().pathname;\n // const mySrc = this._url.toString();\n // const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}//${myp}`), `${this._url.protocol}//${p}`);\n // this._url = new URL(myDst);\n this._url.pathname = p;\n return this;\n }\n\n // hash(h: string) {\n // this._url.hash = h;\n // return this;\n // }\n\n // host(h: string) {\n // this._url.host = h;\n // return this;\n // }\n\n appendRelative(p: CoerceURI): BuildURI {\n const appendUrl = URI.from(p);\n let pathname = appendUrl.pathname;\n let basePath = this._url.pathname;\n /*\n * cases\n * pathname \"\" basePAth \"\" -> \"\"\n * pathname \"/\" basePath \"\" -> \"/\"\n * pathname \"\" basePath \"/\" -> \"/\"\n * pathname \"/\" basePath \"/\" -> \"/\"\n * pathname \"ab\" basePath \"\" -> \"/ab\"\n * pathname \"ab\" basePath \"/\" -> \"/ab\"\n * pathname \"ab\" basePath \"/ab/\" -> \"/ab/ab\"\n * pathname \"/ab/\" basePath \"/ab/\" -> \"/ab/ab/\"\n */\n if (pathname.startsWith(\"/\")) {\n pathname = pathname.replace(/^\\//, \"\");\n }\n if (basePath.length > 0) {\n basePath = basePath.replace(/\\/$/, \"\");\n }\n this.pathname(basePath + \"/\" + pathname);\n for (const [key, value] of appendUrl.getParams) {\n this.setParam(key, value);\n }\n return this;\n }\n\n delParam(key: string): BuildURI {\n this._url.searchParams.delete(key);\n return this;\n }\n\n defParam(key: string, str: string): BuildURI {\n if (!this._url.searchParams.has(key)) {\n this._url.searchParams.set(key, str);\n }\n return this;\n }\n\n setParam(key: string, str: string): BuildURI {\n this._url.searchParams.set(key, str);\n return this;\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n\n getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined {\n let val = this._url.searchParams.get(key);\n if (!falsy2undef(val) && def) {\n val = def;\n }\n return falsy2undef(val) as T extends string ? string : string | undefined;\n }\n\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string> {\n return getParamResult(key, this.getParam(key), msgFn);\n }\n\n getParamsResult(...keys: keysParam): Result<Record<string, string>> {\n return getParamsResult(keys, this);\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n toJSON(): string {\n return this.toString();\n }\n\n asURL(): URL {\n return this.URI().asURL();\n }\n\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject> {\n return this.URI().asObj(...strips);\n }\n\n URI(): URI {\n return URI.from(this._url);\n }\n}\n\nexport type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;\n\nexport const hasHostPartProtocols: Set<string> = new Set<string>([\"http\", \"https\", \"ws\", \"wss\"]);\n\n// non mutable URL Implementation\nexport class URI {\n static protocolHasHostpart(protocol: string): () => void {\n protocol = protocol.replace(/:$/, \"\");\n hasHostPartProtocols.add(protocol);\n return () => {\n hasHostPartProtocols.delete(protocol);\n };\n }\n\n // if no protocol is provided, default to file:\n static merge(into: CoerceURI, from: CoerceURI, defaultProtocol = \"file:\"): URI {\n const intoUrl = BuildURI.from(into, defaultProtocol);\n const fromUrl = URI.from(from, defaultProtocol);\n\n intoUrl.protocol(fromUrl.protocol);\n const fPath = fromUrl.pathname;\n if (!(fPath.length === 0 || fPath === \"/\" || fPath === \"./\")) {\n intoUrl.pathname(fromUrl.pathname);\n }\n for (const [key, value] of fromUrl.getParams) {\n intoUrl.setParam(key, value);\n }\n return intoUrl.URI();\n }\n\n static is(value: unknown): value is URI {\n return (\n value instanceof URI ||\n (!!value &&\n typeof (value as URI).asURL === \"function\" &&\n typeof (value as URI).getParam === \"function\" &&\n typeof (value as URI).hasParam === \"function\")\n );\n }\n\n // if no protocol is provided, default to file:\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): URI {\n return from((url) => new URI(url), strURLUri, defaultProtocol);\n }\n\n static fromResult(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): Result<URI> {\n return exception2Result(() => from((url) => new URI(url), strURLUri, defaultProtocol)) as Result<URI>;\n }\n\n readonly _url: MutableURL;\n private constructor(url: MutableURL) {\n this._url = url.clone();\n }\n\n build(): BuildURI {\n return BuildURI.from(this._url);\n }\n\n get hostname(): string {\n return this._url.hostname;\n }\n\n // get password(): string {\n // return this._url.password;\n // }\n\n get port(): string {\n return this._url.port;\n }\n\n get host(): string {\n return this._url.host;\n }\n\n // get username(): string {\n // return this._url.username;\n // }\n\n // get search(): string {\n // return this._url.search;\n // }\n\n get protocol(): string {\n return this._url.protocol;\n }\n\n get pathname(): string {\n return this._url.pathname;\n // return this._url\n // .toString()\n // .replace(/^.*:\\/\\//, \"\")\n // .replace(/\\?.*$/, \"\");\n }\n\n // get hash(): string {\n // return this._url.hash;\n // }\n\n // get host(): string {\n // return this._url.host;\n // }\n\n get getParams(): Iterable<[string, string]> {\n return this._url.searchParams.entries();\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n\n getParam<T extends string | undefined>(key: string, def?: T): T extends string ? string : string | undefined {\n let val = this._url.searchParams.get(key);\n if (!falsy2undef(val) && def) {\n val = def;\n }\n return falsy2undef(val) as T extends string ? string : string | undefined;\n }\n\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string> {\n return getParamResult(key, this.getParam(key), msgFn);\n }\n\n getParamsResult(...keys: keysParam): Result<Record<string, string>> {\n return getParamsResult(keys, this);\n }\n\n clone(): URI {\n return new URI(this._url);\n }\n\n asURL(): URL {\n // const url = new URL(this._url.toString());\n // url.searchParams.sort();\n return this._url.clone() as unknown as URL;\n }\n\n toString(): string {\n // this._url.searchParams.sort();\n return this._url.toString();\n }\n toJSON(): string {\n return this.toString();\n }\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject> {\n const pathURI: PathURIObject = {\n style: \"path\",\n protocol: this.protocol,\n pathname: this.pathname,\n searchParams: Object.fromEntries(this.getParams),\n };\n if (hasHostPartProtocols.has(this.protocol.replace(/:$/, \"\"))) {\n return stripper(strips, {\n ...pathURI,\n style: \"host\",\n hostname: this.hostname,\n port: this.port,\n }) as Partial<HostURIObject>;\n }\n return stripper(strips, pathURI) as Partial<PathURIObject>;\n }\n}\n","export interface Runtime {\n isNodeIsh: boolean;\n isBrowser: boolean;\n isDeno: boolean;\n isReactNative: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isSet(value: string, ref: any = globalThis): boolean {\n const [head, ...tail] = value.split(\".\");\n if ([\"object\", \"function\"].includes(typeof ref) && ref && [\"object\", \"function\"].includes(typeof ref[head]) && ref[head]) {\n if (tail.length <= 1) {\n return true;\n }\n return isSet(tail.join(\".\"), ref[head]);\n }\n return false;\n}\n\nexport function runtimeFn(): Runtime {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const gt: any = globalThis;\n const isReactNative =\n isSet(\"navigator.product\") && typeof gt[\"navigator\"] === \"object\" && gt[\"navigator\"][\"product\"] === \"ReactNative\";\n let isNodeIsh = false;\n if (!isSet(\"Deno\")) {\n isNodeIsh = isSet(\"process.versions.node\") && !isReactNative;\n }\n const isDeno = isSet(\"Deno\");\n return {\n isNodeIsh,\n isBrowser: !(isNodeIsh || isDeno) && !isReactNative,\n isDeno,\n isReactNative,\n };\n}\n","export class LogWriterStream {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array): void {\n const my = async (): Promise<void> => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns: (() => void)[] = [];\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n","import { LevelHandler, Level } from \"./logger.js\";\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels: Set<Level> = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules: Map<string, Set<Level>> = new Map<string, Set<Level>>();\n isStackExposed = false;\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n setExposeStack(enable?: boolean): void {\n this.isStackExposed = !!enable;\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n if (typeof m !== \"string\") {\n continue;\n }\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (typeof module === \"string\") {\n const levels = this._modules.get(module);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n const wlevel = this._modules.get(\"*\");\n if (wlevel && typeof level === \"string\") {\n if (wlevel.has(level)) {\n return true;\n }\n }\n if (typeof level !== \"string\") {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\nexport function LevelHandlerSingleton(): LevelHandler {\n return levelSingleton;\n}\n","import { FanoutWriteStream } from \"../utils/fanout-write-stream.js\";\nimport { Future } from \"../future.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\n\nexport class LogWriteStream implements WritableStreamDefaultWriter<Uint8Array> {\n private readonly _bufferArr: Uint8Array[];\n\n constructor(bufferArr: Uint8Array[]) {\n this._bufferArr = bufferArr;\n }\n\n readonly _resolveClosed: Future<undefined> = new Future<undefined>();\n readonly closed: Promise<undefined> = this._resolveClosed.asPromise();\n readonly desiredSize: number | null = null;\n readonly ready: Promise<undefined> = Promise.resolve(undefined);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n await this.closed;\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n async write(chunk?: Uint8Array): Promise<void> {\n if (chunk) {\n this._bufferArr.push(chunk);\n }\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n private _writer?: FanoutWriteStream;\n private readonly _pass?: WritableStreamDefaultWriter<Uint8Array>;\n private readonly _bufferArr: Uint8Array[] = [];\n private readonly _txtEnDe: TxtEnDecoder;\n\n constructor(pass?: WritableStreamDefaultWriter<Uint8Array>, txtEnDe?: TxtEnDecoder) {\n this._pass = pass;\n this._txtEnDe = txtEnDe || Utf8EnDecoderSingleton();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n const dests: WritableStreamDefaultWriter[] = [new LogWriteStream(this._bufferArr)];\n if (this._pass) {\n dests.push(this._pass);\n }\n this._writer = new FanoutWriteStream(dests);\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(notJsonLine = false): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = this._txtEnDe.decode(\n new Uint8Array(\n (function* (res: Uint8Array[]): Generator<number, void, undefined> {\n for (const x of res) {\n yield* x;\n }\n })(this._bufferArr),\n ),\n );\n if (!notJsonLine) {\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n return jsonNlStr.split(\"\\n\").filter((a) => a.length);\n }\n}\n","import { LevelHandlerImpl } from \"../log-level-impl.js\";\nimport { Logger } from \"../logger.js\";\nimport { LoggerImpl } from \"../logger-impl.js\";\nimport { SysAbstraction } from \"../sys-abstraction.js\";\nimport { LogCollector } from \"./log-write-stream.js\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n readonly pass?: WritableStreamDefaultWriter<Uint8Array>;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector(params?.pass);\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n if (!params?.disableDebug) {\n logger.SetDebug(...modNames);\n }\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","import type { MarkWritable } from \"ts-essentials\";\nimport { Time } from \"./time.js\";\nimport { Logger } from \"./logger.js\";\n\nexport type TraceCtx = {\n readonly spanId: string;\n readonly time: Time;\n readonly parent: TraceNode;\n readonly metrics: Map<string, Metric<unknown>>;\n readonly logger?: Logger;\n} & Record<string, unknown>;\n\nexport type CleanCtx = {\n readonly spanId: string;\n} & Record<string, unknown>;\n\nexport type TraceCtxParam = {\n readonly spanId: string;\n} & Partial<{\n readonly time: Time;\n readonly parent: TraceNode;\n readonly logger: Logger;\n}> &\n Record<string, unknown>;\n\nexport class Metric<T> {\n value?: T;\n readonly path: string;\n\n constructor(path: string) {\n this.path = path;\n }\n\n set(value: T): void {\n this.value = value;\n }\n\n add<R extends number | ArrayLike<T>>(value: R): void {\n if (typeof value === \"number\") {\n if (this.value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.value = 0 as any;\n }\n (this.value as number) = ((this.value as number) + value) as number;\n } else if (Array.isArray(value)) {\n if (!Array.isArray(this.value)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.value = [] as any;\n }\n (this.value as T[]).push(...value);\n } else {\n throw new Error(\"add only support number or array\");\n }\n }\n}\n\nexport type MetricMap = Map<string, Metric<unknown>>;\n\nexport class Metrics {\n readonly tracenode: TraceNode;\n private readonly map: MetricMap;\n\n readonly spanRefs: MetricMap = new Map<string, Metric<unknown>>();\n constructor(tracenode: TraceNode) {\n this.tracenode = tracenode;\n this.map = tracenode.ctx.metrics;\n }\n\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {};\n for (const [key, value] of this.map) {\n obj[key] = value.value;\n }\n return obj;\n }\n\n get<T>(ipath: string): Metric<T> {\n const path = ipath.replace(/[/]+/g, \"/\").trim();\n if (path.startsWith(\"/\")) {\n if (path.slice(1).length === 0) {\n throw new Error(`Metrics path must contain value /:${path}`);\n }\n let metric = this.map.get(path);\n if (!metric) {\n metric = new Metric<T>(path);\n this.map.set(path, metric);\n }\n this.spanRefs.set(path, metric);\n return metric as Metric<T>;\n } else if (path.includes(\"/\")) {\n throw new Error(`Metrics path must start with /:${path}`);\n }\n const rootPath = this.tracenode.getRootPath();\n return this.get(`${rootPath}/${path}`);\n }\n}\n\nexport interface Invokaction {\n readonly result: \"success\" | \"error\";\n readonly start: number;\n readonly end: number;\n readonly metrics?: Metrics;\n}\n\nexport type TraceNodeMap = Map<string, TraceNode>;\n\nexport class TraceNode {\n readonly childs: TraceNodeMap = new Map<string, TraceNode>();\n\n readonly invokations: Invokaction[] = [];\n\n readonly spanId: string;\n readonly ctx: TraceCtx;\n readonly metrics: Metrics;\n\n static root(time: Time, logger?: Logger): TraceNode {\n return new TraceNode({\n spanId: \"root\",\n time,\n logger,\n metrics: new Map(),\n parent: undefined as unknown as TraceNode,\n });\n }\n\n constructor(ctx: TraceCtx) {\n this.spanId = ctx.spanId;\n this.ctx = ctx;\n this.metrics = new Metrics(this);\n }\n\n getRootPath(rpath: string[] = []): string {\n if (!this.ctx.parent) {\n return \"/\" + rpath.reverse().join(\"/\");\n }\n return this.ctx.parent.getRootPath(rpath.concat(this.ctx.spanId));\n }\n\n invokes(): { ctx: CleanCtx; invokations: Invokaction[] } {\n const cleanCtx = { ...this.ctx } as CleanCtx;\n delete cleanCtx.parent;\n delete cleanCtx.time;\n delete cleanCtx.logger;\n delete cleanCtx.metrics;\n const spanRefs = this.metrics.toJSON.call({ map: this.metrics.spanRefs });\n const metricsRefs = Object.keys(spanRefs).length > 0 ? { metricRefs: spanRefs } : {};\n return {\n ctx: cleanCtx as CleanCtx,\n invokations: this.invokations,\n ...metricsRefs,\n };\n }\n\n ctxWith(spanId: string, logger?: Logger): TraceCtxParam {\n const ctx = {\n ...this.ctx,\n spanId,\n };\n if (logger) {\n ctx.logger = logger;\n }\n return ctx;\n }\n\n // <V extends () => Promise<T> | T, T>(id: string, fn: V): ReturnType<V>\n span<V extends (trace: TraceNode) => Promise<T> | T, T>(inSpanId: string | TraceCtxParam, fn: V): ReturnType<V> {\n let ctx: TraceCtx;\n if (typeof inSpanId === \"string\") {\n ctx = {\n ...this.ctx,\n spanId: inSpanId,\n parent: this,\n };\n } else {\n ctx = {\n ...this.ctx,\n ...inSpanId,\n parent: this,\n };\n }\n if (ctx.logger) {\n ctx = {\n ...ctx,\n ...ctx.logger.Attributes(),\n };\n }\n const spanId = ctx.spanId;\n let spanTrace = this.childs.get(spanId);\n if (!spanTrace) {\n spanTrace = new TraceNode(ctx);\n this.childs.set(spanId.toString(), spanTrace);\n }\n const invokation: MarkWritable<MarkWritable<Invokaction, \"end\">, \"result\"> = {\n start: this.ctx.time.Now().getTime(),\n end: 0,\n result: \"success\",\n };\n spanTrace.invokations.push(invokation);\n try {\n const possiblePromise = fn(spanTrace);\n if (possiblePromise instanceof Promise) {\n return possiblePromise\n .then((v) => {\n return v;\n })\n .catch((e) => {\n invokation.result = \"error\";\n throw e;\n })\n .finally(() => {\n invokation.end = this.ctx.time.Now().getTime();\n }) as ReturnType<V>;\n }\n invokation.end = this.ctx.time.Now().getTime();\n return possiblePromise as ReturnType<V>;\n } catch (e) {\n invokation.result = \"error\";\n invokation.end = this.ctx.time.Now().getTime();\n throw e;\n }\n }\n}\n","export interface CTJsonWebKey {\n alg?: string;\n crv?: string;\n d?: string;\n dp?: string;\n dq?: string;\n e?: string;\n ext?: boolean;\n k?: string;\n key_ops?: string[];\n kty?: string;\n n?: string;\n oth?: RsaOtherPrimesInfo[];\n p?: string;\n q?: string;\n qi?: string;\n use?: string;\n x?: string;\n y?: string;\n}\n\nexport type CTKeyFormat = \"jwk\" | \"pkcs8\" | \"raw\" | \"spki\";\nexport type CTKeyUsage = \"decrypt\" | \"deriveBits\" | \"deriveKey\" | \"encrypt\" | \"sign\" | \"unwrapKey\" | \"verify\" | \"wrapKey\";\n\nexport interface CTAlgorithm {\n name: string;\n}\nexport type CTAlgorithmIdentifier = CTAlgorithm | string;\n\nexport interface CTRsaHashedImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n}\n\nexport type CTNamedCurve = string;\nexport interface CTEcKeyImportParams extends CTAlgorithm {\n namedCurve: CTNamedCurve;\n}\n\nexport interface CTHmacImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n length?: number;\n}\n\nexport interface CTAesKeyAlgorithm extends CTAlgorithm {\n length: number;\n}\n\nexport type CTKeyType = \"private\" | \"public\" | \"secret\";\n\nexport interface CTCryptoKey {\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */\n readonly algorithm: CTAlgorithm;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */\n readonly extractable: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */\n readonly type: CTKeyType;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */\n readonly usages: CTKeyUsage[];\n}\n\ninterface CTArrayBufferTypes {\n ArrayBuffer: ArrayBuffer;\n}\ntype CTArrayBufferLike = CTArrayBufferTypes[keyof CTArrayBufferTypes];\n\nexport interface CTArrayBufferView {\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n buffer: CTArrayBufferLike;\n\n /**\n * The length in bytes of the array.\n */\n byteLength: number;\n\n /**\n * The offset in bytes of the array.\n */\n byteOffset: number;\n}\n\nexport type CTBufferSource = CTArrayBufferView | ArrayBuffer;\n\nexport interface CryptoRuntime {\n importKey(\n format: CTKeyFormat,\n keyData: CTJsonWebKey | CTBufferSource,\n algorithm: CTAlgorithmIdentifier | CTRsaHashedImportParams | CTEcKeyImportParams | CTHmacImportParams | CTAesKeyAlgorithm,\n extractable: boolean,\n keyUsages: CTKeyUsage[],\n ): Promise<CTCryptoKey>;\n exportKey(format: CTKeyFormat, key: CTCryptoKey): Promise<CTJsonWebKey | ArrayBuffer>;\n\n //(format: \"raw\", key: ArrayBuffer, algo: string, extractable: boolean, usages: string[]) => Promise<CryptoKey>;\n decrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n encrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n digestSHA256(data: Uint8Array): Promise<ArrayBuffer>;\n randomBytes(size: number): Uint8Array;\n}\n\nfunction randomBytes(size: number): Uint8Array {\n const bytes = new Uint8Array(size);\n if (size > 0) {\n crypto.getRandomValues(bytes);\n }\n return bytes;\n}\n\nfunction digestSHA256(data: Uint8Array): Promise<ArrayBuffer> {\n return Promise.resolve(crypto.subtle.digest(\"SHA-256\", data));\n}\n\nexport function toCryptoRuntime(cryptoOpts: Partial<CryptoRuntime> = {}): CryptoRuntime {\n const runtime = {\n importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),\n exportKey: cryptoOpts.exportKey || crypto.subtle.exportKey.bind(crypto.subtle),\n encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),\n decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),\n randomBytes: cryptoOpts.randomBytes || randomBytes,\n digestSHA256: cryptoOpts.digestSHA256 || digestSHA256,\n };\n // console.log(\"cryptoOpts\", cryptoOpts, opts)\n return runtime;\n}\n","export const VERSION = Object.keys({\n __packageVersion__: \"xxxx\",\n})[0] as string;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;;;ACDV,SAAS,SAAS,KAAsB,QAAgC,OAAO,GAAS;AAC7F,QAAM,MAAM,IAAI,WAAW,IAAI,QAAQ,IAAI,YAAY,IAAI,UAAU;AACrE,MAAI,SAAS;AACb,MAAI,QAAQ,GAAG;AACb,WAAO,IAAI;AAAA,EACb;AACA,SAAO,KAAK,IAAI,MAAM,IAAI,MAAM;AAChC,QAAM,OAAO;AACb,WAAS,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,MAAM,KAAK,IAAI,KAAK,IAAI,EAAE,QAAQ;AAC7C,YAAM;AAAA,IACR;AAAA,EACF;AACF;;;ACxHA,SAAS,YAAY,MAA0B;AAC7C,QAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,MAAI,OAAO,GAAG;AACZ,WAAO,gBAAgB,KAAK;AAAA,EAC9B;AACA,SAAO;AACT;AAEA,SAAS,aAAa,MAAwC;AAC5D,SAAO,QAAQ,QAAQ,OAAO,OAAO,OAAO,WAAW,IAAI,CAAC;AAC9D;AAEO,SAAS,gBAAgB,aAAqC,CAAC,GAAkB;AACtF,QAAM,UAAU;AAAA,IACd,WAAW,WAAW,aAAa,OAAO,OAAO,UAAU,KAAK,OAAO,MAAM;AAAA,IAC7E,WAAW,WAAW,aAAa,OAAO,OAAO,UAAU,KAAK,OAAO,MAAM;AAAA,IAC7E,SAAS,WAAW,WAAW,OAAO,OAAO,QAAQ,KAAK,OAAO,MAAM;AAAA,IACvE,SAAS,WAAW,WAAW,OAAO,OAAO,QAAQ,KAAK,OAAO,MAAM;AAAA,IACvE,aAAa,WAAW,eAAe;AAAA,IACvC,cAAc,WAAW,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AC5HO,IAAM,UAAU,OAAO,KAAK;AAAA,EACjC,oBAAoB;AACtB,CAAC,EAAE,CAAC;","names":["Level","key","keys","from"]}
1
+ {"version":3,"sources":["../../src/logger-impl.ts","../../src/bin2text.ts","../../src/logger.ts","../../src/result.ts","../../src/utils/stripper.ts","../../src/uri.ts","../../src/runtime.ts","../../src/log-writer-impl.ts","../../src/log-level-impl.ts","../../src/test/log-write-stream.ts","../../src/test/mock-logger.ts","../../src/option.ts","../../src/tracer.ts","../../src/crypto.ts","../../src/version.ts"],"sourcesContent":["// import { v4 } from \"uuid\";\nimport YAML from \"yaml\";\nimport {\n AsError,\n FnSerialized,\n LogSerializable,\n Level,\n Logger,\n logValue,\n Serialized,\n WithLogger,\n // sanitizeSerialize,\n Sized,\n Lengthed,\n LogValue,\n asyncLogValue,\n LevelHandler,\n LogFormatter,\n LogValueArg,\n HttpType,\n} from \"./logger.js\";\nimport { WebSysAbstraction } from \"./web/web-sys-abstraction.js\";\nimport { SysAbstraction } from \"./sys-abstraction.js\";\nimport { Result } from \"./result.js\";\nimport { CoerceURI, URI } from \"./uri.js\";\nimport { runtimeFn } from \"./runtime.js\";\nimport { ConsoleWriterStream } from \"./utils/console-write-stream.js\";\nimport { LogWriterStream } from \"./log-writer-impl.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"./txt-en-decoder.js\";\nimport { LevelHandlerSingleton } from \"./log-level-impl.js\";\n\nfunction getLen(value: unknown): LogValue {\n if (Array.isArray(value)) {\n return logValue(() => value.length);\n } else if (typeof value === \"string\") {\n return logValue(() => value.length);\n } else if (typeof value === \"object\" && value !== null) {\n if (typeof (value as Sized).size === \"number\") {\n return logValue(() => (value as Sized).size);\n } else if (typeof (value as Lengthed).length === \"number\") {\n return logValue(() => (value as Lengthed).length);\n }\n return logValue(() => Object.keys(value).length);\n }\n return logValue(() => -1);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction hash(value: unknown): string {\n // const hasher = createHash(\"sha256\");\n // hasher.update(JSON.stringify(value, removeSelfRef()));\n // return hasher.digest(\"hex\");\n return \"not implemented\";\n}\n\nfunction toLogValue(lop: LogValue | Promise<LogValue>): LogValue | undefined {\n if (lop && typeof (lop as Promise<LogValue>).then === \"function\") {\n throw new Error(\"async logValue Not implemented\");\n }\n return lop as LogValue;\n}\n\nexport class JSONFormatter implements LogFormatter {\n private readonly _txtEnDe: TxtEnDecoder;\n private readonly _space?: number;\n constructor(txtEnde: TxtEnDecoder, space?: number) {\n this._txtEnDe = txtEnde;\n this._space = space;\n }\n format(attr: LogSerializable): Uint8Array {\n let ret: string;\n try {\n ret = JSON.stringify(attr, null, this._space);\n } catch (e) {\n ret = JSON.stringify({ internal: { message: (e as Error).message, stack: (e as Error).stack } });\n }\n return this._txtEnDe.encode(ret + \"\\n\");\n }\n}\n\nexport class YAMLFormatter implements LogFormatter {\n private readonly _txtEnDe: TxtEnDecoder;\n private readonly _space?: number;\n constructor(txtEnde: TxtEnDecoder, space?: number) {\n this._txtEnDe = txtEnde;\n this._space = space;\n }\n format(attr: LogSerializable): Uint8Array {\n return this._txtEnDe.encode(\"---\\n\" + YAML.stringify(attr, null, this._space) + \"\\n\");\n }\n}\n\nexport interface LoggerImplParams {\n readonly out?: WritableStream<Uint8Array>;\n readonly logWriter?: LogWriterStream;\n readonly sys?: SysAbstraction;\n readonly withAttributes?: LogSerializable;\n readonly levelHandler?: LevelHandler;\n readonly txtEnDe?: TxtEnDecoder;\n readonly formatter?: LogFormatter;\n}\n\nexport class LoggerImpl implements Logger {\n readonly _sys: SysAbstraction;\n readonly _attributes: LogSerializable = {};\n readonly _withAttributes: LogSerializable;\n readonly _logWriter: LogWriterStream;\n readonly _levelHandler: LevelHandler;\n readonly _txtEnDe: TxtEnDecoder;\n _formatter: LogFormatter;\n // readonly _id: string = \"logger-\" + Math.random().toString(36)\n\n constructor(params?: LoggerImplParams) {\n if (!params) {\n params = {};\n }\n if (!params.sys) {\n this._sys = WebSysAbstraction();\n } else {\n this._sys = params.sys;\n }\n if (!params.txtEnDe) {\n this._txtEnDe = Utf8EnDecoderSingleton();\n } else {\n this._txtEnDe = params.txtEnDe;\n }\n if (!params.formatter) {\n this._formatter = new JSONFormatter(this._txtEnDe);\n } else {\n this._formatter = params.formatter;\n }\n\n if (params.logWriter) {\n this._logWriter = params.logWriter;\n } else {\n if (!params.out) {\n const rt = runtimeFn();\n let stream: WritableStream<Uint8Array>;\n if (rt.isBrowser) {\n stream = new ConsoleWriterStream();\n } else {\n if (rt.isNodeIsh || rt.isReactNative || rt.isDeno) {\n stream = this._sys.Stdout();\n } else {\n throw new Error(\"No output defined for runtime\");\n }\n }\n this._logWriter = new LogWriterStream(stream);\n } else {\n this._logWriter = new LogWriterStream(params.out);\n }\n }\n if (!params.withAttributes) {\n this._withAttributes = {};\n } else {\n this._withAttributes = { ...params.withAttributes };\n }\n this._attributes = { ...this._withAttributes };\n if (params.levelHandler) {\n this._levelHandler = params.levelHandler;\n } else {\n this._levelHandler = LevelHandlerSingleton();\n }\n // console.log(\"LoggerImpl\", this._id, this._attributes, this._withAttributes)\n }\n\n TxtEnDe(): TxtEnDecoder {\n return this._txtEnDe;\n }\n\n Attributes(): Record<string, unknown> {\n return JSON.parse(JSON.stringify(this._attributes, null));\n // return Array.from(Object.entries(this._attributes)).reduce(\n // (acc, [key, value]) => {\n // if (value instanceof LogValue) {\n // acc[key] = value.value();\n // }\n // return acc;\n // },\n // {} as Record<string, unknown>,\n // );\n }\n\n SetExposeStack(enable?: boolean): Logger {\n this._levelHandler.setExposeStack(enable);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): Logger {\n this._levelHandler.disableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): Logger {\n this._attributes[\"module\"] = logValue(key);\n this._withAttributes[\"module\"] = logValue(key);\n return this;\n }\n // if the string is \"*\" it will enable for all modules\n SetDebug(...modules: (string | string[])[]): Logger {\n this._levelHandler.setDebug(...modules);\n return this;\n }\n\n SetFormatter(formatter: LogFormatter): Logger {\n this._formatter = formatter;\n return this;\n }\n\n Timestamp(): Logger {\n this._attributes[\"ts\"] = logValue(() => this._sys.Time().Now().toISOString());\n return this;\n }\n Warn(): Logger {\n this._attributes[\"level\"] = logValue(Level.WARN);\n return this;\n }\n Log(): Logger {\n return this;\n }\n Debug(): Logger {\n this._attributes[\"level\"] = logValue(Level.DEBUG);\n return this;\n }\n Error(): Logger {\n this._attributes[\"level\"] = logValue(Level.ERROR);\n return this;\n }\n Info(): Logger {\n this._attributes[\"level\"] = logValue(Level.INFO);\n return this;\n }\n Err(err: unknown | Result<unknown> | Error): Logger {\n if (Result.Is(err)) {\n if (err.isOk()) {\n this.Result(\"noerror\", err);\n } else {\n this.Result(\"error\", err);\n }\n } else if (err instanceof Error) {\n this._attributes[\"error\"] = logValue(err.message);\n if (this._levelHandler.isStackExposed) {\n this._attributes[\"stack\"] = logValue(err.stack?.split(\"\\n\").map((s) => s.trim()));\n }\n } else {\n this._attributes[\"error\"] = logValue(\"\" + err);\n }\n return this;\n }\n WithLevel(l: Level): Logger {\n this._attributes[\"level\"] = logValue(l);\n return this;\n }\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): Logger {\n if (typeof action === \"function\") {\n this._attributes[key] = logValue(action as FnSerialized);\n } else if (typeof action.toString === \"function\") {\n this._attributes[key] = logValue(() => action.toString());\n } else {\n this._attributes[key] = logValue(\"INVALID REF\");\n }\n return this;\n }\n Bool(key: string | Record<string, unknown>, value: unknown): Logger {\n this.coerceKey(key, !!value);\n // this._attributes[key] = logValue(!!value);\n return this;\n }\n\n Http(...mix: (HttpType | string)[]): Logger {\n const key: string | undefined = mix.find((x) => typeof x === \"string\");\n mix = mix.filter((x) => typeof x !== \"string\");\n const resErrors = mix.filter((x) => Result.Is(x) && x.isErr()) as Result<unknown, Error>[];\n if (resErrors.length) {\n this.Err(resErrors.map((x) => x.Err().message).join(\"\\n\"));\n return this;\n }\n const req = mix\n .map((reqOrResult) => (Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult))\n .find((req) => typeof (req as Response).status !== \"number\") as Request | undefined;\n const res = mix\n .map((resOrResult) => (Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult))\n .find((res) => typeof (res as Response).status === \"number\") as Response | undefined;\n let reqAndOrres: { res: Response; req: Request } | Response | Request | undefined;\n if (res && req) {\n reqAndOrres = { res, req };\n } else if (!res && !req) {\n reqAndOrres = undefined;\n } else if (res) {\n reqAndOrres = res;\n } else if (req) {\n reqAndOrres = req;\n }\n if (reqAndOrres) {\n this.Any(key || \"Http\", reqAndOrres as unknown as LogSerializable);\n }\n return this;\n }\n Pair(x: Record<string, unknown>): Logger {\n for (const key of Object.keys(x)) {\n const value = x[key];\n if (value instanceof LogValue) {\n this._attributes[key] = value;\n continue;\n }\n if (Result.Is(value)) {\n this.Result(key, value);\n continue;\n }\n this.Any(key, value as LogSerializable);\n }\n return this;\n }\n\n Result<T>(key: string, res: Result<T, Error>): Logger {\n if (res.isOk()) {\n this._attributes[key] = logValue(res.Ok() as Serialized);\n } else {\n this.Err(res.Err());\n }\n return this;\n }\n\n Len(value: unknown, key = \"len\"): Logger {\n this._attributes[key] = getLen(value);\n return this;\n }\n\n Hash(value: unknown, key = \"hash\"): Logger {\n this._attributes[key] = asyncLogValue(async () => `${getLen(value).value()}:${await hash(value)}`);\n return this;\n }\n\n Url(url: CoerceURI, key = \"url\"): Logger {\n this.Ref(key, () => URI.from(url).toString());\n return this;\n }\n\n private coerceKey(key: string | Record<string, unknown>, value?: unknown): void {\n if (typeof key === \"string\") {\n this._attributes[key] = logValue(value as LogValueArg);\n } else {\n this.Pair(key);\n }\n }\n\n Str(key: string | Record<string, string>, value?: string): Logger {\n this.coerceKey(key, value);\n return this;\n }\n\n Any(key: string | Record<string, unknown>, value?: unknown): Logger {\n this.coerceKey(key, value);\n //this._attributes[coerceKey(key)] = logValue(value as LogValueArg);\n return this;\n }\n Dur(key: string, nsec: number): Logger {\n this._attributes[key] = logValue(`${nsec}ms`);\n // new Intl.DurationFormat(\"en\", { style: \"narrow\" }).format(nsec);\n return this;\n }\n Uint64(key: string | Record<string, number>, value?: number): Logger {\n this.coerceKey(key, value);\n //this._attributes[coerceKey(key)] = logValue(value);\n return this;\n }\n Int(key: string | Record<string, number>, value?: number): Logger {\n return this.Uint64(key, value);\n }\n\n async Flush(): Promise<void> {\n return new Promise((resolve) => {\n this._logWriter._flush(undefined, resolve);\n });\n }\n\n With(): WithLogger {\n // console.log(\"WithLoggerBuilder.With\", this._id, this._attributes, this._withAttributes);\n return new WithLoggerBuilder(\n new LoggerImpl({\n logWriter: this._logWriter,\n sys: this._sys,\n levelHandler: this._levelHandler,\n formatter: this._formatter,\n withAttributes: {\n module: this._attributes[\"module\"],\n ...this._withAttributes,\n },\n }),\n );\n }\n\n _resetAttributes(fn: () => () => Uint8Array): () => Uint8Array {\n const ret = fn();\n Object.keys(this._attributes).forEach((key) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._attributes[key];\n });\n Object.assign(this._attributes, this._withAttributes);\n return ret;\n }\n\n Msg(...args: string[]): AsError {\n const fnError = this._resetAttributes(() => {\n const doWrite = this._levelHandler.isEnabled(\n toLogValue(this._attributes[\"level\"])?.value(),\n toLogValue(this._attributes[\"module\"])?.value(),\n );\n this._attributes[\"msg\"] = logValue(args.join(\" \"));\n const msg = this._attributes[\"msg\"].value();\n if (typeof msg === \"string\" && !msg.trim().length) {\n delete this._attributes[\"msg\"];\n }\n let fnRet = (): Uint8Array => this._formatter.format({ ...this._attributes });\n if (doWrite) {\n const encoded = fnRet();\n this._logWriter.write(encoded);\n fnRet = (): Uint8Array => encoded;\n }\n return fnRet;\n });\n const asError = (): Error => new Error(this._txtEnDe.decode(fnError()));\n return {\n ResultError: () => Result.Err(asError()),\n AsError: asError,\n };\n }\n}\n\nclass WithLoggerBuilder implements WithLogger {\n readonly _li: LoggerImpl;\n constructor(li: LoggerImpl) {\n this._li = li;\n }\n\n TxtEnDe(): TxtEnDecoder {\n return this._li.TxtEnDe();\n }\n\n Logger(): Logger {\n Object.assign(this._li._withAttributes, this._li._attributes);\n return this._li;\n }\n\n Attributes(): Record<string, unknown> {\n return { ...this._li._attributes };\n }\n\n SetExposeStack(enable?: boolean): WithLogger {\n this._li._levelHandler.setExposeStack(enable);\n return this;\n }\n\n SetFormatter(fmt: LogFormatter): WithLogger {\n this._li.SetFormatter(fmt);\n return this;\n }\n\n EnableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n DisableLevel(level: Level, ...modules: string[]): WithLogger {\n this._li._levelHandler.enableLevel(level, ...modules);\n return this;\n }\n\n Module(key: string): WithLogger {\n this._li.Module(key);\n return this;\n }\n SetDebug(...modules: (string | string[])[]): WithLogger {\n this._li.SetDebug(...modules);\n return this;\n }\n\n Http(...mix: (HttpType | string)[]): WithLogger {\n this._li.Http(...mix);\n return this;\n }\n Pair(x: Record<string, unknown>): WithLogger {\n this._li.Pair(x);\n return this;\n }\n\n Str(key: string | Record<string, string>, value?: string): WithLogger {\n this._li.Str(key, value);\n return this;\n }\n\n Len(value: unknown, key?: string): WithLogger {\n this._li.Len(value, key);\n return this;\n }\n\n Hash(value: unknown, key?: string): WithLogger {\n this._li.Hash(value, key);\n return this;\n }\n\n Ref(key: string, action: Serialized | FnSerialized): WithLogger {\n this._li.Ref(key, action);\n return this;\n }\n Bool(key: string | Record<string, unknown>, value?: unknown): WithLogger {\n this._li.Bool(key, value);\n return this;\n }\n Result<T>(key: string, res: Result<T, Error>): WithLogger {\n this._li.Result(key, res);\n return this;\n }\n Url(url: CoerceURI, key?: string): WithLogger {\n this._li.Url(url, key);\n return this;\n }\n Int(key: string | Record<string, number>, value?: number): WithLogger {\n this._li.Int(key, value);\n return this;\n }\n\n Log(): WithLogger {\n this._li.Log();\n return this;\n }\n\n WithLevel(level: Level): WithLogger {\n this._li.WithLevel(level);\n return this;\n }\n\n Error(): WithLogger {\n this._li.Error();\n return this;\n }\n Warn(): WithLogger {\n this._li.Error();\n return this;\n }\n Debug(): WithLogger {\n this._li.Debug();\n return this;\n }\n Err(err: unknown): WithLogger {\n this._li.Err(err);\n return this;\n }\n Info(): WithLogger {\n this._li.Info();\n return this;\n }\n Timestamp(): WithLogger {\n this._li.Timestamp();\n return this;\n }\n Any(key: string | Record<string, unknown>, value?: unknown | LogSerializable): WithLogger {\n this._li.Any(key, value);\n return this;\n }\n Dur(key: string, nsec: number): WithLogger {\n this._li.Dur(key, nsec);\n return this;\n }\n Uint64(key: string | Record<string, number>, value?: number): WithLogger {\n this._li.Uint64(key, value);\n return this;\n }\n}\n","export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size = 0): void {\n const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);\n let cutted = \" \";\n if (size == 0) {\n size = arr.length;\n }\n size = Math.min(size, arr.length);\n const cols = 16;\n for (let line = 0; line < size; line += cols) {\n if (line + cols <= size || arr.length == size) {\n // normal line\n } else {\n line = arr.length - (arr.length % cols);\n size = arr.length;\n cutted = \">>\";\n }\n const l: string[] = [line.toString(16).padStart(4, \"0\"), cutted];\n for (let col = 0; col < cols; col++) {\n if (line + col < size) {\n l.push(arr[line + col].toString(16).padStart(2, \"0\"));\n } else {\n l.push(\" \");\n }\n // l.push((col > 0 && col % 4 === 3) ? \" \" : \" \");\n l.push(\" \");\n }\n for (let col = 0; col < cols; col++) {\n if (line + col < size) {\n const ch = arr[line + col];\n l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : \".\");\n }\n }\n lineFn(l.join(\"\"));\n }\n}\n\nexport function bin2string(hex: ArrayBufferView, size = 0): string {\n const collector: string[] = [];\n bin2text(\n hex,\n (line) => {\n collector.push(line);\n },\n size,\n );\n return collector.join(\"\\n\");\n}\n","import { bin2string } from \"./bin2text.js\";\nimport { Result } from \"./result.js\";\nimport { TxtEnDecoder } from \"./txt-en-decoder.js\";\nimport { CoerceURI } from \"./uri.js\";\n\nexport enum Level {\n WARN = \"warn\",\n DEBUG = \"debug\",\n INFO = \"info\",\n ERROR = \"error\",\n}\n\nexport type Serialized = string | number | boolean;\nexport type FnSerialized = () => Serialized | Serialized[];\n\nexport class LogValue {\n constructor(readonly fn: FnSerialized) {}\n value(): Serialized | Serialized[] {\n try {\n // console.log(\"LogValue.value\", this.fn.toString());\n return this.fn();\n } catch (e) {\n return `LogValue:${(e as Error).message}`;\n }\n }\n toJSON(): Serialized | Serialized[] {\n return this.value();\n }\n}\n\nexport type LogSerializable = Record<string, LogValue | Promise<LogValue>>;\n\n// export function sanitizeSerialize(lineEnd?: string): (key: unknown, val: unknown) => unknown {\n// const cache = new Set();\n// return function (this: unknown, key: unknown, value: unknown) {\n// if (typeof value === \"object\" && value !== null) {\n// // Duplicate reference found, discard key\n// if (cache.has(value)) return \"...\";\n// cache.add(value);\n// }\n// return lineEnd ? value + lineEnd : value;\n// };\n// }\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function asyncLogValue(val: () => Promise<Serialized>): Promise<LogValue> {\n // return Promise.resolve(logValue(val));\n throw new Error(\"Not implemented\");\n}\n\nexport type LogValueArg = LogValue | Serialized | Serialized[] | FnSerialized | undefined | null;\n\nexport function logValue(val: LogValueArg, state: Set<unknown> = new Set<unknown>([Math.random()])): LogValue {\n switch (typeof val) {\n case \"function\":\n return new LogValue(val);\n case \"string\": {\n try {\n const ret = JSON.parse(val);\n if (typeof ret === \"object\" && ret !== null) {\n return logValue(ret, state);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n if (val.match(/[\\n\\r]/)) {\n const lines = val.trimEnd().split(/[\\n\\r]/);\n return new LogValue(() => lines);\n }\n }\n return new LogValue(() => val.toString());\n }\n case \"number\":\n return new LogValue(() => val);\n case \"boolean\":\n return new LogValue(() => val);\n case \"object\": {\n if (val === null) {\n return new LogValue(() => \"null\");\n }\n if (ArrayBuffer.isView(val)) {\n return logValue(bin2string(val, 512));\n }\n if (Array.isArray(val)) {\n return new LogValue(() => (val as Serialized[]).map((v) => logValue(v).value() as Serialized));\n }\n // if (val instanceof Response) {\n // // my = my.clone() as unknown as LogValue | Serialized[] | null\n // // const rval = my as unknown as Partial<Response>;\n // // delete rval.clone\n // // delete rval.blob\n // }\n if (val instanceof Headers) {\n return new LogValue(() => Object.fromEntries(val.entries()) as unknown as Serialized);\n }\n if (val instanceof ReadableStream) {\n return new LogValue(() => \">Stream<\");\n }\n if (val instanceof Promise) {\n return new LogValue(() => \">Promise<\");\n }\n\n // Duplicate reference found, discard key\n if (state.has(val)) {\n return new LogValue(() => \"...\");\n }\n state.add(val);\n if (typeof val.toJSON === \"function\") {\n return new LogValue(() => val.toJSON());\n }\n\n const res: Record<string, LogValue> = {};\n const typedVal = val as unknown as Record<string, LogValueArg>;\n for (const key in typedVal) {\n const element = typedVal[key];\n if (element instanceof LogValue) {\n res[key] = element;\n } else {\n if (typeof element !== \"function\") {\n res[key] = logValue(element, state);\n }\n // res[key] = logValue(element, state);\n }\n }\n // ugly as hell cast but how declare a self-referencing type?\n return new LogValue(() => res as unknown as Serialized);\n }\n default:\n if (!val) {\n return new LogValue(() => \"--Falsy--\");\n }\n throw new Error(`Invalid type:${typeof val}`);\n }\n}\n\nexport interface Sized {\n size: number;\n}\nexport interface Lengthed {\n length: number;\n}\nexport type SizeOrLength = Sized | Lengthed;\n\nexport interface LogFormatter {\n format(attr: LogSerializable): Uint8Array;\n}\n\nexport interface LevelHandler {\n enableLevel(level: Level, ...modules: string[]): void;\n disableLevel(level: Level, ...modules: string[]): void;\n setExposeStack(enable?: boolean): void;\n isStackExposed: boolean;\n setDebug(...modules: (string | string[])[]): void;\n isEnabled(ilevel: unknown, module: unknown): boolean;\n}\n\nexport type HttpType = Response | Result<Response> | Request | Result<Request>;\n\nexport interface LoggerInterface<R> {\n TxtEnDe(): TxtEnDecoder;\n Module(key: string): R;\n // if modules is empty, set for all Levels\n EnableLevel(level: Level, ...modules: string[]): R;\n DisableLevel(level: Level, ...modules: string[]): R;\n\n Attributes(): Record<string, unknown>;\n\n SetDebug(...modules: (string | string[])[]): R;\n SetExposeStack(enable?: boolean): R;\n SetFormatter(fmt: LogFormatter): R;\n\n Ref(key: string, action: { toString: () => string } | FnSerialized): R;\n Result<T>(key: string, res: Result<T>): R;\n // default key url\n Url(url: CoerceURI, key?: string): R;\n // len\n Len(value: unknown, key?: string): R;\n\n Hash(value: unknown, key?: string): R;\n\n Str<T extends string | Record<string, string>>(key: T, value?: T extends string ? string : undefined): R;\n Uint64<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;\n Int<T extends string | Record<string, number>>(key: T, value?: T extends string ? number : undefined): R;\n Bool<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;\n Any<T extends string | Record<string, unknown>>(key: T, value?: T extends string ? unknown : undefined): R;\n\n // first string is the key\n // first response is Response\n // first request is Request\n Http(...mix: (HttpType | string)[]): R;\n Pair(x: Record<string, unknown>): R;\n\n Error(): R;\n Warn(): R;\n Debug(): R;\n Log(): R;\n WithLevel(level: Level): R;\n\n Err(err: unknown | Result<unknown> | Error): R; // could be Error, or something which coerces to string\n Info(): R;\n Timestamp(): R;\n Dur(key: string, nsec: number): R;\n}\n\nexport function IsLogger(obj: unknown): obj is Logger {\n return (\n typeof obj === \"object\" &&\n [\n \"Module\",\n \"EnableLevel\",\n \"DisableLevel\",\n \"SetDebug\",\n \"Str\",\n \"Error\",\n \"Warn\",\n \"Debug\",\n \"Log\",\n \"WithLevel\",\n \"Err\",\n \"Info\",\n \"Timestamp\",\n \"Any\",\n \"Dur\",\n \"Uint64\",\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .map((fn) => typeof (obj as any)[fn] === \"function\")\n .reduce((a, b) => a && b, true)\n );\n}\n\nexport interface WithLogger extends LoggerInterface<WithLogger> {\n Logger(): Logger;\n}\n\nexport interface AsError {\n AsError(): Error;\n ResultError<T>(): Result<T>;\n}\n\nexport interface Logger extends LoggerInterface<Logger> {\n With(): WithLogger;\n\n Msg(...args: string[]): AsError;\n Flush(): Promise<void>;\n}\n","export abstract class Result<T, E = Error> {\n static Ok<T = void>(t: T): Result<T, Error> {\n return new ResultOK(t);\n }\n static Err<T, E extends Error = Error>(t: E | string): Result<T, E> {\n if (typeof t === \"string\") {\n return new ResultError(new Error(t) as E);\n }\n return new ResultError(t);\n }\n static Is<T>(t: unknown): t is Result<T> {\n if (!t) {\n return false;\n }\n if (t instanceof Result) {\n return true;\n }\n const rt = t as Result<T>;\n if ([typeof rt.is_ok, typeof rt.is_err, typeof rt.unwrap, typeof rt.unwrap_err].every((x) => x === \"function\")) {\n return true;\n }\n return false;\n }\n\n isOk(): boolean {\n return this.is_ok();\n }\n isErr(): boolean {\n return this.is_err();\n }\n\n Ok(): T {\n return this.unwrap();\n }\n Err(): E {\n return this.unwrap_err();\n }\n\n abstract is_ok(): boolean;\n abstract is_err(): boolean;\n abstract unwrap(): T;\n abstract unwrap_err(): E;\n}\n\nexport class ResultOK<T> extends Result<T, Error> {\n private _t: T;\n constructor(t: T) {\n super();\n this._t = t;\n }\n is_ok(): boolean {\n return true;\n }\n is_err(): boolean {\n return false;\n }\n unwrap_err(): Error {\n throw new Error(\"Result is Ok\");\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class ResultError<T extends Error> extends Result<never, T> {\n private _error: T;\n constructor(t: T) {\n super();\n this._error = t;\n }\n is_ok(): boolean {\n return false;\n }\n is_err(): boolean {\n return true;\n }\n unwrap(): never {\n throw new Error(`Result is Err: ${this._error}`);\n }\n unwrap_err(): T {\n return this._error;\n }\n}\n\nexport type WithoutResult<T> = T extends Result<infer U> ? U : T;\n\n// type WithoutPromise<T> = T extends Promise<infer U> ? U : T;\ntype WithResult<T> = T extends Promise<infer U> ? Promise<Result<U>> : Result<T>;\n\nexport function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): WithResult<ReturnType<FN>> {\n try {\n const res = fn();\n if (res instanceof Promise) {\n return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e)) as WithResult<ReturnType<FN>>;\n }\n return Result.Ok(res) as WithResult<ReturnType<FN>>;\n } catch (e) {\n return Result.Err(e as Error) as WithResult<ReturnType<FN>>;\n }\n}\n\n/*\n\ntype FinalizedResult<T> = {\n result: T;\n scopeResult?: Result<void>;\n finally: () => Promise<void>;\n}\n\ntype exection2ResultParam<T> = {\n init: () => Promise<T>;\n inScope?: (t: T) => Promise<void>;\n cleanup: (t: T) => Promise<void>;\n\n}\n\nasync function expection2Result<T>({fn, inScope, cleanup}: exection2ResultParam<T>): Promise<Result<FinalizedResult<T>>> {\n try {\n const res = await fn();\n if (inScope) {\n try {\n await inScope?.(res)\n } catch (err) {\n return Result.Err(err as Error)\n }\n await cleanup(res)\n return Result.Ok({\n result: res,\n finally: async () => { }\n })\n }\n return Result.Ok({\n result: res ,\n finally: async () => {\n return cleanup(res)\n }\n })\n } catch (err) {\n return Result.Err(err as Error)\n }\n}\n*/\n\n// await expection2Result({\n// init: openDB,\n// inScope: (res) => {\n// res.query()\n// },\n// cleanup: async (y) => {\n// await y.close()\n// }\n// })\n// async function openDB() {\n// try {\n// const opendb = await openDB()\n// return Result.Ok({\n// openDB,\n// finally: async () => {\n// await opendb.close()\n// }})\n// } catch (err) {\n// return Result.Err(err)\n// }\n// }\n// }\n","export type StripCommand = string | RegExp;\n\nexport function stripper<T extends unknown | ArrayLike<unknown>>(\n strip: StripCommand | StripCommand[],\n obj: T,\n): T extends ArrayLike<unknown> ? Record<string, unknown>[] : Record<string, unknown> {\n const strips = Array.isArray(strip) ? strip : [strip];\n const restrips = strips.map((s) => {\n if (typeof s === \"string\") {\n const escaped = s.replace(/[-\\\\[\\]\\\\/\\\\{\\\\}\\\\(\\\\)\\\\*\\\\+\\\\?\\\\.\\\\\\\\^\\\\$\\\\|]/g, \"\\\\$&\");\n return new RegExp(`^${escaped}$`);\n }\n return s;\n });\n return localStripper(undefined, restrips, obj) as T extends ArrayLike<unknown>\n ? Record<string, unknown>[]\n : Record<string, unknown>;\n}\n\nfunction localStripper<T>(path: string | undefined, restrips: RegExp[], obj: T): unknown {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map((i) => localStripper(path, restrips, i));\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const ret = { ...obj } as Record<string, any>;\n const matcher = (key: string, nextPath: string): boolean => {\n for (const re of restrips) {\n if (re.test(key) || re.test(nextPath)) {\n return true;\n }\n }\n return false;\n };\n for (const key in ret) {\n if (Object.prototype.hasOwnProperty.call(ret, key)) {\n let nextPath: string;\n if (path) {\n nextPath = [path, key].join(\".\");\n } else {\n nextPath = key;\n }\n if (matcher(key, nextPath)) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete ret[key];\n continue;\n }\n if (typeof ret[key] === \"object\") {\n if (Array.isArray(ret[key])) {\n ret[key] = ret[key].reduce((acc, v, i) => {\n const toDelete = matcher(key, `${nextPath}[${i}]`);\n if (!toDelete) {\n acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));\n }\n return acc;\n }, []);\n } else {\n ret[key] = localStripper(nextPath, restrips, ret[key]);\n }\n }\n }\n }\n return ret;\n}\n","import { exception2Result, Result } from \"./result.js\";\nimport { StripCommand, stripper } from \"./utils/stripper.js\";\n\ntype NullOrUndef = null | undefined;\n\ntype OneKey<K extends string, V = string> = Record<K, V>;\n\nexport interface URIInterface<R extends URIInterface<R>> {\n // readonly hostname: string;\n // readonly port: string;\n // readonly host: string;\n // readonly protocol: string;\n // readonly pathname: string;\n readonly getParams: Iterable<[string, string]>;\n\n hasParam(key: string): boolean;\n getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined;\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string>;\n getParamsResult(...keys: keysParam): Result<Record<string, string>>;\n clone(): R;\n asURL(): URL;\n toString(): string;\n toJSON(): string;\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject>;\n}\n\nfunction coerceKey(key: string | OneKey<string>, def?: string): { key: string; def?: string } {\n if (typeof key === \"object\") {\n const keys = Object.keys(key);\n if (keys.length !== 1) {\n throw new Error(`Invalid key: ${JSON.stringify(key)}`);\n }\n return { key: keys[0], def: key[keys[0]] };\n }\n return { key, def: def };\n}\n\nexport interface URIObject {\n readonly style: \"host\" | \"path\";\n readonly protocol: string;\n readonly pathname: string;\n readonly searchParams: Record<string, string>;\n}\n\nexport interface PathURIObject extends URIObject {\n readonly style: \"path\";\n}\n\nexport interface HostURIObject extends URIObject {\n readonly style: \"host\";\n readonly hostname: string;\n readonly port: string;\n}\n\nfunction falsy2undef<T>(value: T | NullOrUndef): T | undefined {\n return value === undefined || value === null ? undefined : value;\n}\n\nfunction ensureURLWithDefaultProto(url: string | URL, defaultProtocol: string): MutableURL {\n if (!url) {\n return new MutableURL(`${defaultProtocol}//`);\n }\n if (typeof url === \"string\") {\n try {\n return new MutableURL(url);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n return new MutableURL(`${defaultProtocol}//${url}`);\n }\n } else {\n return new MutableURL(url.toString());\n }\n}\n\nexport function isURL(value: unknown): value is URL {\n return (\n value instanceof URL ||\n (!!value &&\n typeof (value as URL).searchParams === \"object\" &&\n typeof (value as URL).searchParams.sort === \"function\" &&\n typeof (value as URL).hash === \"string\")\n );\n}\n\n// due to that the System URL class is has a strange behavior\n// on different platforms, we need to implement our own URL class\nexport class MutableURL extends URL {\n private readonly _sysURL: URL;\n // private readonly _urlStr: string;\n\n private _protocol: string;\n private _pathname: string;\n private _hasHostpart: boolean;\n\n override readonly hash: string;\n\n constructor(urlStr: string) {\n super(\"defect://does.not.exist\");\n const partedURL = urlStr.split(\":\");\n this._hasHostpart = hasHostPartProtocols.has(partedURL[0]);\n let hostPartUrl = [\"http\", ...partedURL.slice(1)].join(\":\");\n if (!this._hasHostpart) {\n const pathname = hostPartUrl.replace(/http:\\/\\/[/]*/, \"\").replace(/[#?].*$/, \"\");\n hostPartUrl = hostPartUrl.replace(/http:\\/\\//, `http://localhost/${pathname}`);\n }\n try {\n this._sysURL = new URL(hostPartUrl);\n } catch (ie) {\n const e = ie as Error;\n e.message = `${e.message} for URL: ${urlStr}`;\n throw e;\n }\n this._protocol = `${partedURL[0]}:`; // this._sysURL.protocol.replace(new RegExp(\"^cement-\"), \"\");\n if (this._hasHostpart) {\n this._pathname = this._sysURL.pathname;\n } else {\n this._pathname = urlStr.replace(new RegExp(`^${this._protocol}//`), \"\").replace(/[#?].*$/, \"\");\n }\n this.hash = this._sysURL.hash;\n }\n\n clone(): MutableURL {\n return new MutableURL(this.toString());\n }\n\n override get host(): string {\n if (!this._hasHostpart) {\n throw new Error(\n `you can use hostname only if protocol is ${this.toString()} ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`,\n );\n }\n return this._sysURL.host;\n }\n\n override get port(): string {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n return this._sysURL.port;\n }\n\n override set port(p: string) {\n if (!this._hasHostpart) {\n throw new Error(`you can use port only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n this._sysURL.port = p;\n }\n\n override get hostname(): string {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n return this._sysURL.hostname;\n }\n\n override set hostname(h: string) {\n if (!this._hasHostpart) {\n throw new Error(`you can use hostname only if protocol is ${JSON.stringify(Array.from(hasHostPartProtocols.keys()))}`);\n }\n this._sysURL.hostname = h;\n }\n\n override set pathname(p: string) {\n this._pathname = p;\n }\n\n override get pathname(): string {\n return this._pathname;\n }\n\n override get protocol(): string {\n return this._protocol;\n }\n\n override set protocol(p: string) {\n if (!p.endsWith(\":\")) {\n p = `${p}:`;\n }\n this._protocol = p;\n }\n\n override get searchParams(): URLSearchParams {\n return this._sysURL.searchParams;\n }\n\n override toString(): string {\n let search = \"\";\n if (this._sysURL.searchParams.size) {\n for (const [key, value] of Array.from(this._sysURL.searchParams.entries()).sort((a, b) => a[0].localeCompare(b[0]))) {\n search += `${!search.length ? \"?\" : \"&\"}${key}=${encodeURIComponent(value)}`;\n }\n }\n let hostpart = \"\";\n if (this._hasHostpart) {\n hostpart = this._sysURL.hostname;\n if (this._sysURL.port) {\n hostpart += `:${this._sysURL.port}`;\n }\n if (!this._pathname.startsWith(\"/\")) {\n hostpart += \"/\";\n }\n }\n return `${this._protocol}//${hostpart}${this._pathname}${search}`;\n }\n}\n\nfunction from<T>(fac: (url: MutableURL) => T, strURLUri: CoerceURI | undefined, defaultProtocol: string): T {\n switch (typeof falsy2undef(strURLUri)) {\n case \"undefined\":\n return fac(new MutableURL(`${defaultProtocol}///`));\n case \"string\":\n return fac(ensureURLWithDefaultProto(strURLUri as string, defaultProtocol));\n case \"object\":\n if (BuildURI.is(strURLUri)) {\n return fac(new MutableURL(strURLUri._url.toString()));\n } else if (URI.is(strURLUri)) {\n return fac(new MutableURL(strURLUri._url.toString()));\n } else if (isURL(strURLUri)) {\n return fac(new MutableURL(strURLUri.toString()));\n }\n throw new Error(`unknown object type: ${strURLUri}`);\n default:\n throw new Error(`Invalid argument: ${typeof strURLUri}`);\n }\n}\n\nfunction getParamResult(\n key: string,\n val: string | undefined,\n msgFn: (key: string) => string = (key) => {\n return `missing parameter: ${key}`;\n },\n): Result<string> {\n if (val === undefined) {\n return Result.Err(msgFn(key));\n }\n return Result.Ok(val);\n}\n\ntype msgFn = (...keys: string[]) => string;\n// if right head of Record is string the key used and the value is the default value\ntype keysParam = (string | msgFn | Record<string, unknown>)[];\n\nfunction getParamsResult(\n keys: keysParam,\n getParam: { getParam: (key: string) => string | undefined },\n): Result<Record<string, string>> {\n const keyDef = keys.flat().reduce(\n (acc, i) => {\n if (typeof i === \"string\") {\n acc.push({ key: i });\n } else if (typeof i === \"object\") {\n acc.push(...Object.keys(i).map((k) => ({ key: k, def: typeof i[k] === \"string\" ? i[k] : undefined })));\n }\n return acc;\n },\n [] as { key: string; def?: string }[],\n );\n //.filter((k) => typeof k === \"string\");\n const msgFn =\n keys.find((k) => typeof k === \"function\") ||\n ((...keys: string[]): string => {\n const msg = keys.join(\",\");\n return `missing parameters: ${msg}`;\n });\n const errors: string[] = [];\n const result: Record<string, string> = {};\n for (const kd of keyDef) {\n const val = getParam.getParam(kd.key);\n if (val === undefined) {\n if (typeof kd.def === \"string\") {\n result[kd.key] = kd.def;\n } else {\n errors.push(kd.key);\n }\n } else {\n result[kd.key] = val;\n }\n }\n if (errors.length) {\n return Result.Err(msgFn(...errors));\n }\n return Result.Ok(result);\n}\n\nexport class BuildURI implements URIInterface<BuildURI> {\n _url: MutableURL; // pathname needs this\n private constructor(url: MutableURL) {\n this._url = url;\n }\n\n static is(value: unknown): value is BuildURI {\n return (\n value instanceof BuildURI ||\n (!!value && typeof (value as BuildURI).delParam === \"function\" && typeof (value as BuildURI).setParam === \"function\")\n );\n }\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): BuildURI {\n return from((url) => new BuildURI(url), strURLUri, defaultProtocol);\n }\n\n port(p: string): BuildURI {\n this._url.port = p;\n return this;\n }\n\n hostname(h: string): BuildURI {\n this._url.hostname = h;\n return this;\n }\n\n // password(p: string) {\n // this._url.password = p;\n // return this;\n // }\n\n // port(p: string) {\n // this._url.port = p;\n // return this;\n // }\n\n // username(u: string) {\n // this._url.username = u;\n // return this;\n // }\n\n // search(s: string) {\n // this._url.search = s;\n // return this;\n // }\n\n protocol(p: string): BuildURI {\n this._url.protocol = p;\n // if (!p.endsWith(\":\")) {\n // p = `${p}:`;\n // }\n // const mySrc = this._url.toString();\n // const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}`), `${p}`);\n // this._url = new URL(myDst);\n return this;\n }\n\n pathname(p: string): BuildURI {\n // const myp = this.URI().pathname;\n // const mySrc = this._url.toString();\n // const myDst = mySrc.replace(new RegExp(`^${this._url.protocol}//${myp}`), `${this._url.protocol}//${p}`);\n // this._url = new URL(myDst);\n this._url.pathname = p;\n return this;\n }\n\n // hash(h: string) {\n // this._url.hash = h;\n // return this;\n // }\n\n // host(h: string) {\n // this._url.host = h;\n // return this;\n // }\n\n appendRelative(p: CoerceURI): BuildURI {\n const appendUrl = URI.from(p);\n let pathname = appendUrl.pathname;\n let basePath = this._url.pathname;\n /*\n * cases\n * pathname \"\" basePAth \"\" -> \"\"\n * pathname \"/\" basePath \"\" -> \"/\"\n * pathname \"\" basePath \"/\" -> \"/\"\n * pathname \"/\" basePath \"/\" -> \"/\"\n * pathname \"ab\" basePath \"\" -> \"/ab\"\n * pathname \"ab\" basePath \"/\" -> \"/ab\"\n * pathname \"ab\" basePath \"/ab/\" -> \"/ab/ab\"\n * pathname \"/ab/\" basePath \"/ab/\" -> \"/ab/ab/\"\n */\n if (pathname.startsWith(\"/\")) {\n pathname = pathname.replace(/^\\//, \"\");\n }\n if (basePath.length > 0) {\n basePath = basePath.replace(/\\/$/, \"\");\n }\n this.pathname(basePath + \"/\" + pathname);\n for (const [key, value] of appendUrl.getParams) {\n this.setParam(key, value);\n }\n return this;\n }\n\n delParam(key: string): BuildURI {\n this._url.searchParams.delete(key);\n return this;\n }\n\n defParam(key: string, str: string): BuildURI {\n if (!this._url.searchParams.has(key)) {\n this._url.searchParams.set(key, str);\n }\n return this;\n }\n\n setParam(key: string, str: string): BuildURI {\n this._url.searchParams.set(key, str);\n return this;\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n\n get getParams(): Iterable<[string, string]> {\n return this._url.searchParams.entries();\n }\n\n getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined {\n const { key: k, def: d } = coerceKey(key, def);\n let val = this._url.searchParams.get(k);\n if (!falsy2undef(val) && d) {\n val = d;\n }\n return falsy2undef(val) as T extends string ? string : string | undefined;\n }\n\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string> {\n return getParamResult(key, this.getParam(key), msgFn);\n }\n\n getParamsResult(...keys: keysParam): Result<Record<string, string>> {\n return getParamsResult(keys, this);\n }\n\n toString(): string {\n this._url.searchParams.sort();\n return this._url.toString();\n }\n toJSON(): string {\n return this.toString();\n }\n\n asURL(): URL {\n return this.URI().asURL();\n }\n\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject> {\n return this.URI().asObj(...strips);\n }\n\n clone(): BuildURI {\n return BuildURI.from(this.toString());\n }\n\n URI(): URI {\n return URI.from(this._url);\n }\n}\n\nexport type CoerceURI = string | URI | MutableURL | URL | BuildURI | NullOrUndef;\n\nexport const hasHostPartProtocols: Set<string> = new Set<string>([\"http\", \"https\", \"ws\", \"wss\"]);\n\n// non mutable URL Implementation\nexport class URI implements URIInterface<URI> {\n static protocolHasHostpart(protocol: string): () => void {\n protocol = protocol.replace(/:$/, \"\");\n hasHostPartProtocols.add(protocol);\n return () => {\n hasHostPartProtocols.delete(protocol);\n };\n }\n\n // if no protocol is provided, default to file:\n static merge(into: CoerceURI, from: CoerceURI, defaultProtocol = \"file:\"): URI {\n const intoUrl = BuildURI.from(into, defaultProtocol);\n const fromUrl = URI.from(from, defaultProtocol);\n\n intoUrl.protocol(fromUrl.protocol);\n const fPath = fromUrl.pathname;\n if (!(fPath.length === 0 || fPath === \"/\" || fPath === \"./\")) {\n intoUrl.pathname(fromUrl.pathname);\n }\n for (const [key, value] of fromUrl.getParams) {\n intoUrl.setParam(key, value);\n }\n return intoUrl.URI();\n }\n\n static is(value: unknown): value is URI {\n return (\n value instanceof URI ||\n (!!value &&\n typeof (value as URI).asURL === \"function\" &&\n typeof (value as URI).getParam === \"function\" &&\n typeof (value as URI).hasParam === \"function\")\n );\n }\n\n // if no protocol is provided, default to file:\n static from(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): URI {\n return from((url) => new URI(url), strURLUri, defaultProtocol);\n }\n\n static fromResult(strURLUri?: CoerceURI, defaultProtocol = \"file:\"): Result<URI> {\n return exception2Result(() => from((url) => new URI(url), strURLUri, defaultProtocol)) as Result<URI>;\n }\n\n readonly _url: MutableURL;\n private constructor(url: MutableURL) {\n this._url = url.clone();\n }\n\n build(): BuildURI {\n return BuildURI.from(this._url);\n }\n\n get hostname(): string {\n return this._url.hostname;\n }\n\n // get password(): string {\n // return this._url.password;\n // }\n\n get port(): string {\n return this._url.port;\n }\n\n get host(): string {\n return this._url.host;\n }\n\n // get username(): string {\n // return this._url.username;\n // }\n\n // get search(): string {\n // return this._url.search;\n // }\n\n get protocol(): string {\n return this._url.protocol;\n }\n\n get pathname(): string {\n return this._url.pathname;\n // return this._url\n // .toString()\n // .replace(/^.*:\\/\\//, \"\")\n // .replace(/\\?.*$/, \"\");\n }\n\n // get hash(): string {\n // return this._url.hash;\n // }\n\n // get host(): string {\n // return this._url.host;\n // }\n\n get getParams(): Iterable<[string, string]> {\n return this._url.searchParams.entries();\n }\n\n hasParam(key: string): boolean {\n return this._url.searchParams.has(key);\n }\n\n getParam<T extends string | undefined>(key: string | OneKey<string>, def?: T): T extends string ? string : string | undefined {\n const { key: k, def: d } = coerceKey(key, def);\n let val = this._url.searchParams.get(k);\n if (!falsy2undef(val) && d) {\n val = d;\n }\n return falsy2undef(val) as T extends string ? string : string | undefined;\n }\n\n getParamResult(key: string, msgFn?: (key: string) => string): Result<string> {\n return getParamResult(key, this.getParam(key), msgFn);\n }\n\n getParamsResult(...keys: keysParam): Result<Record<string, string>> {\n return getParamsResult(keys, this);\n }\n\n clone(): URI {\n return new URI(this._url);\n }\n\n asURL(): URL {\n // const url = new URL(this._url.toString());\n // url.searchParams.sort();\n return this._url.clone() as unknown as URL;\n }\n\n toString(): string {\n // this._url.searchParams.sort();\n return this._url.toString();\n }\n toJSON(): string {\n return this.toString();\n }\n asObj(...strips: StripCommand[]): Partial<HostURIObject | PathURIObject> {\n const pathURI: PathURIObject = {\n style: \"path\",\n protocol: this.protocol,\n pathname: this.pathname,\n searchParams: Object.fromEntries(this.getParams),\n };\n if (hasHostPartProtocols.has(this.protocol.replace(/:$/, \"\"))) {\n return stripper(strips, {\n ...pathURI,\n style: \"host\",\n hostname: this.hostname,\n port: this.port,\n }) as Partial<HostURIObject>;\n }\n return stripper(strips, pathURI) as Partial<PathURIObject>;\n }\n}\n","export interface Runtime {\n isNodeIsh: boolean;\n isBrowser: boolean;\n isDeno: boolean;\n isReactNative: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isSet(value: string, ref: any = globalThis): boolean {\n const [head, ...tail] = value.split(\".\");\n if ([\"object\", \"function\"].includes(typeof ref) && ref && [\"object\", \"function\"].includes(typeof ref[head]) && ref[head]) {\n if (tail.length <= 1) {\n return true;\n }\n return isSet(tail.join(\".\"), ref[head]);\n }\n return false;\n}\n\nexport function runtimeFn(): Runtime {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const gt: any = globalThis;\n const isReactNative =\n isSet(\"navigator.product\") && typeof gt[\"navigator\"] === \"object\" && gt[\"navigator\"][\"product\"] === \"ReactNative\";\n let isNodeIsh = false;\n if (!isSet(\"Deno\")) {\n isNodeIsh = isSet(\"process.versions.node\") && !isReactNative;\n }\n const isDeno = isSet(\"Deno\");\n return {\n isNodeIsh,\n isBrowser: !(isNodeIsh || isDeno) && !isReactNative,\n isDeno,\n isReactNative,\n };\n}\n","export class LogWriterStream {\n readonly _out: WritableStream<Uint8Array>;\n readonly _toFlush: (() => Promise<void>)[] = [];\n\n constructor(out: WritableStream<Uint8Array>) {\n this._out = out;\n }\n\n write(encoded: Uint8Array): void {\n const my = async (): Promise<void> => {\n // const val = Math.random();\n // console.log(\">>>My:\", val)\n try {\n const writer = this._out.getWriter();\n await writer.ready;\n await writer.write(encoded);\n await writer.releaseLock();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\"Chunk error:\", err);\n }\n // console.log(\"<<<My:\", val)\n };\n this._toFlush.push(my);\n this._flush();\n }\n\n _flushIsRunning = false;\n _flushDoneFns: (() => void)[] = [];\n _flush(toFlush: (() => Promise<void>)[] | undefined = undefined, done?: () => void): void {\n if (done) {\n this._flushDoneFns.push(done);\n }\n\n if (this._toFlush.length == 0) {\n // console.log(\"Flush is stopped\", this._toFlush.length)\n this._flushIsRunning = false;\n this._flushDoneFns.forEach((fn) => fn());\n this._flushDoneFns = [];\n return;\n }\n\n if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {\n this._flushIsRunning = true;\n // console.log(\"Flush is started\", this._toFlush.length)\n } else if (!toFlush) {\n // console.log(\"flush queue check but is running\", this._toFlush.length)\n return;\n }\n\n // console.log(\">>>Msg:\", this._toFlush.length)\n const my = this._toFlush.shift();\n my?.().finally(() => {\n // console.log(\"<<<Msg:\", this._toFlush.length)\n this._flush(this._toFlush);\n });\n }\n}\n","import { LevelHandler, Level } from \"./logger.js\";\n\nexport class LevelHandlerImpl implements LevelHandler {\n readonly _globalLevels: Set<Level> = new Set<Level>([Level.INFO, Level.ERROR, Level.WARN]);\n readonly _modules: Map<string, Set<Level>> = new Map<string, Set<Level>>();\n isStackExposed = false;\n enableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.add(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, level]));\n },\n ...modules,\n );\n }\n disableLevel(level: Level, ...modules: string[]): void {\n if (modules.length == 0) {\n this._globalLevels.delete(level);\n return;\n }\n this.forModules(\n level,\n (p) => {\n this._modules.delete(p);\n },\n ...modules,\n );\n }\n\n setExposeStack(enable?: boolean): void {\n this.isStackExposed = !!enable;\n }\n\n forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void {\n for (const m of modules.flat()) {\n if (typeof m !== \"string\") {\n continue;\n }\n const parts = m\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length);\n for (const p of parts) {\n fnAction(p);\n }\n }\n }\n setDebug(...modules: (string | string[])[]): void {\n this.forModules(\n Level.DEBUG,\n (p) => {\n this._modules.set(p, new Set([...this._globalLevels, Level.DEBUG]));\n },\n ...modules,\n );\n }\n isEnabled(ilevel: unknown, module: unknown): boolean {\n const level = ilevel as Level; // what if it's not a level?\n if (typeof module === \"string\") {\n const levels = this._modules.get(module);\n if (levels && levels.has(level)) {\n return true;\n }\n }\n const wlevel = this._modules.get(\"*\");\n if (wlevel && typeof level === \"string\") {\n if (wlevel.has(level)) {\n return true;\n }\n }\n if (typeof level !== \"string\") {\n // this is a plain log\n return true;\n }\n return this._globalLevels.has(level);\n }\n}\n\nconst levelSingleton = new LevelHandlerImpl();\n\nexport function LevelHandlerSingleton(): LevelHandler {\n return levelSingleton;\n}\n","import { FanoutWriteStream } from \"../utils/fanout-write-stream.js\";\nimport { Future } from \"../future.js\";\nimport { TxtEnDecoder, Utf8EnDecoderSingleton } from \"../txt-en-decoder.js\";\n\nexport class LogWriteStream implements WritableStreamDefaultWriter<Uint8Array> {\n private readonly _bufferArr: Uint8Array[];\n\n constructor(bufferArr: Uint8Array[]) {\n this._bufferArr = bufferArr;\n }\n\n readonly _resolveClosed: Future<undefined> = new Future<undefined>();\n readonly closed: Promise<undefined> = this._resolveClosed.asPromise();\n readonly desiredSize: number | null = null;\n readonly ready: Promise<undefined> = Promise.resolve(undefined);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n await this.closed;\n return Promise.resolve(undefined);\n }\n releaseLock(): void {\n // do nothing\n }\n async write(chunk?: Uint8Array): Promise<void> {\n if (chunk) {\n this._bufferArr.push(chunk);\n }\n return Promise.resolve(undefined);\n }\n}\n\nexport class LogCollector implements WritableStream<Uint8Array> {\n readonly locked: boolean = false;\n private _writer?: FanoutWriteStream;\n private readonly _pass?: WritableStreamDefaultWriter<Uint8Array>;\n private readonly _bufferArr: Uint8Array[] = [];\n private readonly _txtEnDe: TxtEnDecoder;\n\n constructor(pass?: WritableStreamDefaultWriter<Uint8Array>, txtEnDe?: TxtEnDecoder) {\n this._pass = pass;\n this._txtEnDe = txtEnDe || Utf8EnDecoderSingleton();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abort(reason?: Uint8Array): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n async close(): Promise<void> {\n if (this._writer) {\n const ret = await this._writer.close();\n this._writer = undefined;\n return ret;\n }\n return Promise.resolve(undefined);\n }\n\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (!this._writer) {\n const dests: WritableStreamDefaultWriter[] = [new LogWriteStream(this._bufferArr)];\n if (this._pass) {\n dests.push(this._pass);\n }\n this._writer = new FanoutWriteStream(dests);\n }\n return this._writer;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Logs(notJsonLine = false): any[] {\n if (!this._writer) {\n return [];\n }\n const jsonNlStr = this._txtEnDe.decode(\n new Uint8Array(\n (function* (res: Uint8Array[]): Generator<number, void, undefined> {\n for (const x of res) {\n yield* x;\n }\n })(this._bufferArr),\n ),\n );\n if (!notJsonLine) {\n const splitStr = jsonNlStr.split(\"\\n\");\n const filterStr = splitStr.filter((a) => a.length);\n const mapStr = filterStr.map((a) => JSON.parse(a));\n return mapStr;\n }\n return jsonNlStr.split(\"\\n\").filter((a) => a.length);\n }\n}\n","import { LevelHandlerImpl } from \"../log-level-impl.js\";\nimport { Logger } from \"../logger.js\";\nimport { LoggerImpl } from \"../logger-impl.js\";\nimport { SysAbstraction } from \"../sys-abstraction.js\";\nimport { LogCollector } from \"./log-write-stream.js\";\n\nexport interface MockLoggerReturn {\n readonly logger: Logger;\n readonly logCollector: LogCollector;\n}\n\nexport function MockLogger(params?: {\n readonly sys?: SysAbstraction;\n readonly pass?: WritableStreamDefaultWriter<Uint8Array>;\n moduleName?: string | string[];\n readonly disableDebug?: boolean;\n}): MockLoggerReturn {\n const lc = new LogCollector(params?.pass);\n let modNames = [\"MockLogger\"];\n if (typeof params?.moduleName === \"string\") {\n modNames = [params?.moduleName];\n } else if (Array.isArray(params?.moduleName)) {\n modNames = [...params.moduleName, ...modNames];\n }\n const logger = new LoggerImpl({\n out: lc,\n sys: params?.sys,\n levelHandler: new LevelHandlerImpl(),\n })\n .With()\n .Module(modNames[0])\n .Logger();\n if (!params?.disableDebug) {\n logger.SetDebug(...modNames);\n }\n return {\n logCollector: lc,\n logger,\n };\n}\n","export abstract class Option<T> {\n static Some<T>(t: T): Option<T> {\n return new Some(t);\n }\n\n static None<T>(): Option<T> {\n return new None();\n }\n\n static Is<T>(t: unknown): t is Option<T> {\n return t instanceof Option;\n }\n\n IsNone(): boolean {\n return this.is_none();\n }\n\n IsSome(): boolean {\n return this.is_some();\n }\n Unwrap(): T {\n return this.unwrap();\n }\n\n abstract is_none(): boolean;\n abstract is_some(): boolean;\n abstract unwrap(): T;\n}\n\nexport class Some<T> extends Option<T> {\n private _t: T;\n constructor(_t: T) {\n super();\n this._t = _t;\n }\n\n is_none(): boolean {\n return false;\n }\n is_some(): boolean {\n return true;\n }\n unwrap(): T {\n return this._t;\n }\n}\n\nexport class None<T> extends Option<T> {\n is_none(): boolean {\n return true;\n }\n is_some(): boolean {\n return false;\n }\n unwrap(): T {\n throw new Error(\"None.unwrap\");\n }\n}\n\nexport type WithoutOption<T> = T extends Option<infer U> ? U : T;\n","import type { MarkWritable } from \"ts-essentials\";\nimport { Time } from \"./time.js\";\nimport { Logger } from \"./logger.js\";\n\nexport type TraceCtx = {\n readonly spanId: string;\n readonly time: Time;\n readonly parent: TraceNode;\n readonly metrics: Map<string, Metric<unknown>>;\n readonly logger?: Logger;\n} & Record<string, unknown>;\n\nexport type CleanCtx = {\n readonly spanId: string;\n} & Record<string, unknown>;\n\nexport type TraceCtxParam = {\n readonly spanId: string;\n} & Partial<{\n readonly time: Time;\n readonly parent: TraceNode;\n readonly logger: Logger;\n}> &\n Record<string, unknown>;\n\nexport class Metric<T> {\n value?: T;\n readonly path: string;\n\n constructor(path: string) {\n this.path = path;\n }\n\n set(value: T): void {\n this.value = value;\n }\n\n add<R extends number | ArrayLike<T>>(value: R): void {\n if (typeof value === \"number\") {\n if (this.value === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.value = 0 as any;\n }\n (this.value as number) = ((this.value as number) + value) as number;\n } else if (Array.isArray(value)) {\n if (!Array.isArray(this.value)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.value = [] as any;\n }\n (this.value as T[]).push(...value);\n } else {\n throw new Error(\"add only support number or array\");\n }\n }\n}\n\nexport type MetricMap = Map<string, Metric<unknown>>;\n\nexport class Metrics {\n readonly tracenode: TraceNode;\n private readonly map: MetricMap;\n\n readonly spanRefs: MetricMap = new Map<string, Metric<unknown>>();\n constructor(tracenode: TraceNode) {\n this.tracenode = tracenode;\n this.map = tracenode.ctx.metrics;\n }\n\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {};\n for (const [key, value] of this.map) {\n obj[key] = value.value;\n }\n return obj;\n }\n\n get<T>(ipath: string): Metric<T> {\n const path = ipath.replace(/[/]+/g, \"/\").trim();\n if (path.startsWith(\"/\")) {\n if (path.slice(1).length === 0) {\n throw new Error(`Metrics path must contain value /:${path}`);\n }\n let metric = this.map.get(path);\n if (!metric) {\n metric = new Metric<T>(path);\n this.map.set(path, metric);\n }\n this.spanRefs.set(path, metric);\n return metric as Metric<T>;\n } else if (path.includes(\"/\")) {\n throw new Error(`Metrics path must start with /:${path}`);\n }\n const rootPath = this.tracenode.getRootPath();\n return this.get(`${rootPath}/${path}`);\n }\n}\n\nexport interface Invokaction {\n readonly result: \"success\" | \"error\";\n readonly start: number;\n readonly end: number;\n readonly metrics?: Metrics;\n}\n\nexport type TraceNodeMap = Map<string, TraceNode>;\n\nexport class TraceNode {\n readonly childs: TraceNodeMap = new Map<string, TraceNode>();\n\n readonly invokations: Invokaction[] = [];\n\n readonly spanId: string;\n readonly ctx: TraceCtx;\n readonly metrics: Metrics;\n\n static root(time: Time, logger?: Logger): TraceNode {\n return new TraceNode({\n spanId: \"root\",\n time,\n logger,\n metrics: new Map(),\n parent: undefined as unknown as TraceNode,\n });\n }\n\n constructor(ctx: TraceCtx) {\n this.spanId = ctx.spanId;\n this.ctx = ctx;\n this.metrics = new Metrics(this);\n }\n\n getRootPath(rpath: string[] = []): string {\n if (!this.ctx.parent) {\n return \"/\" + rpath.reverse().join(\"/\");\n }\n return this.ctx.parent.getRootPath(rpath.concat(this.ctx.spanId));\n }\n\n invokes(): { ctx: CleanCtx; invokations: Invokaction[] } {\n const cleanCtx = { ...this.ctx } as CleanCtx;\n delete cleanCtx.parent;\n delete cleanCtx.time;\n delete cleanCtx.logger;\n delete cleanCtx.metrics;\n const spanRefs = this.metrics.toJSON.call({ map: this.metrics.spanRefs });\n const metricsRefs = Object.keys(spanRefs).length > 0 ? { metricRefs: spanRefs } : {};\n return {\n ctx: cleanCtx as CleanCtx,\n invokations: this.invokations,\n ...metricsRefs,\n };\n }\n\n ctxWith(spanId: string, logger?: Logger): TraceCtxParam {\n const ctx = {\n ...this.ctx,\n spanId,\n };\n if (logger) {\n ctx.logger = logger;\n }\n return ctx;\n }\n\n // <V extends () => Promise<T> | T, T>(id: string, fn: V): ReturnType<V>\n span<V extends (trace: TraceNode) => Promise<T> | T, T>(inSpanId: string | TraceCtxParam, fn: V): ReturnType<V> {\n let ctx: TraceCtx;\n if (typeof inSpanId === \"string\") {\n ctx = {\n ...this.ctx,\n spanId: inSpanId,\n parent: this,\n };\n } else {\n ctx = {\n ...this.ctx,\n ...inSpanId,\n parent: this,\n };\n }\n if (ctx.logger) {\n ctx = {\n ...ctx,\n ...ctx.logger.Attributes(),\n };\n }\n const spanId = ctx.spanId;\n let spanTrace = this.childs.get(spanId);\n if (!spanTrace) {\n spanTrace = new TraceNode(ctx);\n this.childs.set(spanId.toString(), spanTrace);\n }\n const invokation: MarkWritable<MarkWritable<Invokaction, \"end\">, \"result\"> = {\n start: this.ctx.time.Now().getTime(),\n end: 0,\n result: \"success\",\n };\n spanTrace.invokations.push(invokation);\n try {\n const possiblePromise = fn(spanTrace);\n if (possiblePromise instanceof Promise) {\n return possiblePromise\n .then((v) => {\n return v;\n })\n .catch((e) => {\n invokation.result = \"error\";\n throw e;\n })\n .finally(() => {\n invokation.end = this.ctx.time.Now().getTime();\n }) as ReturnType<V>;\n }\n invokation.end = this.ctx.time.Now().getTime();\n return possiblePromise as ReturnType<V>;\n } catch (e) {\n invokation.result = \"error\";\n invokation.end = this.ctx.time.Now().getTime();\n throw e;\n }\n }\n}\n","export interface CTJsonWebKey {\n alg?: string;\n crv?: string;\n d?: string;\n dp?: string;\n dq?: string;\n e?: string;\n ext?: boolean;\n k?: string;\n key_ops?: string[];\n kty?: string;\n n?: string;\n oth?: RsaOtherPrimesInfo[];\n p?: string;\n q?: string;\n qi?: string;\n use?: string;\n x?: string;\n y?: string;\n}\n\nexport type CTKeyFormat = \"jwk\" | \"pkcs8\" | \"raw\" | \"spki\";\nexport type CTKeyUsage = \"decrypt\" | \"deriveBits\" | \"deriveKey\" | \"encrypt\" | \"sign\" | \"unwrapKey\" | \"verify\" | \"wrapKey\";\n\nexport interface CTAlgorithm {\n name: string;\n}\nexport type CTAlgorithmIdentifier = CTAlgorithm | string;\n\nexport interface CTRsaHashedImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n}\n\nexport type CTNamedCurve = string;\nexport interface CTEcKeyImportParams extends CTAlgorithm {\n namedCurve: CTNamedCurve;\n}\n\nexport interface CTHmacImportParams extends CTAlgorithm {\n hash: CTAlgorithmIdentifier;\n length?: number;\n}\n\nexport interface CTAesKeyAlgorithm extends CTAlgorithm {\n length: number;\n}\n\nexport type CTKeyType = \"private\" | \"public\" | \"secret\";\n\nexport interface CTCryptoKey {\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */\n readonly algorithm: CTAlgorithm;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */\n readonly extractable: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */\n readonly type: CTKeyType;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */\n readonly usages: CTKeyUsage[];\n}\n\ninterface CTArrayBufferTypes {\n ArrayBuffer: ArrayBuffer;\n}\ntype CTArrayBufferLike = CTArrayBufferTypes[keyof CTArrayBufferTypes];\n\nexport interface CTArrayBufferView {\n /**\n * The ArrayBuffer instance referenced by the array.\n */\n buffer: CTArrayBufferLike;\n\n /**\n * The length in bytes of the array.\n */\n byteLength: number;\n\n /**\n * The offset in bytes of the array.\n */\n byteOffset: number;\n}\n\nexport type CTBufferSource = CTArrayBufferView | ArrayBuffer;\n\nexport interface CryptoRuntime {\n importKey(\n format: CTKeyFormat,\n keyData: CTJsonWebKey | CTBufferSource,\n algorithm: CTAlgorithmIdentifier | CTRsaHashedImportParams | CTEcKeyImportParams | CTHmacImportParams | CTAesKeyAlgorithm,\n extractable: boolean,\n keyUsages: CTKeyUsage[],\n ): Promise<CTCryptoKey>;\n exportKey(format: CTKeyFormat, key: CTCryptoKey): Promise<CTJsonWebKey | ArrayBuffer>;\n\n //(format: \"raw\", key: ArrayBuffer, algo: string, extractable: boolean, usages: string[]) => Promise<CryptoKey>;\n decrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n encrypt(algo: { name: string; iv: Uint8Array; tagLength: number }, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;\n digestSHA256(data: Uint8Array): Promise<ArrayBuffer>;\n randomBytes(size: number): Uint8Array;\n}\n\nfunction randomBytes(size: number): Uint8Array {\n const bytes = new Uint8Array(size);\n if (size > 0) {\n crypto.getRandomValues(bytes);\n }\n return bytes;\n}\n\nfunction digestSHA256(data: Uint8Array): Promise<ArrayBuffer> {\n return Promise.resolve(crypto.subtle.digest(\"SHA-256\", data));\n}\n\nexport function toCryptoRuntime(cryptoOpts: Partial<CryptoRuntime> = {}): CryptoRuntime {\n const runtime = {\n importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),\n exportKey: cryptoOpts.exportKey || crypto.subtle.exportKey.bind(crypto.subtle),\n encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),\n decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),\n randomBytes: cryptoOpts.randomBytes || randomBytes,\n digestSHA256: cryptoOpts.digestSHA256 || digestSHA256,\n };\n // console.log(\"cryptoOpts\", cryptoOpts, opts)\n return runtime;\n}\n","export const VERSION = Object.keys({\n __packageVersion__: \"xxxx\",\n})[0] as string;\n"],"mappings":";;;;;;;;;;;;;;;;;;;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kB;AACtF,QAAM,UAAU;AAAA,IACd,WAAW,WAAW,aAAa,OAAO,OAAO,UAAU,KAAK,OAAO,MAAM;AAAA,IAC7E,WAAW,WAAW,aAAa,OAAO,OAAO,UAAU,KAAK,OAAO,MAAM;AAAA,IAC7E,SAAS,WAAW,WAAW,OAAO,OAAO,QAAQ,KAAK,OAAO,MAAM;AAAA,IACvE,SAAS,WAAW,WAAW,OAAO,OAAO,QAAQ,KAAK,OAAO,MAAM;AAAA,IACvE,aAAa,WAAW,eAAe;AAAA,IACvC,cAAc,WAAW,gBAAgB;AAAA,EAC3C;AAEA,SAAO;AACT;;;AC5HO,IAAM,UAAU,OAAO,KAAK;AAAA,EACjC,oBAAoB;AACtB,CAAC,EAAE,CAAC;","names":["Level","key","keys","from","req","res"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adviser/cement",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "description": "better try/catch/finally handling",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "@vitest/browser": "^2.1.1",
50
50
  "esbuild-plugin-replace": "^1.4.0",
51
51
  "esbuild-plugin-resolve": "^2.0.0",
52
- "eslint": "^9.11.1",
52
+ "eslint": "9.14.0",
53
53
  "prettier": "^3.3.3",
54
54
  "tsup": "^8.3.0",
55
55
  "tsx": "^4.19.1",
package/src/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adviser/cement",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./web": "./web/index.ts",