@easbot/utils 0.2.49 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -201,6 +201,7 @@ declare function now(): number;
201
201
  declare function nowLocalISO(includeMilliseconds?: boolean): string;
202
202
  declare function parseLocalISO(isoString: string): Date;
203
203
  declare function formatLogTime(date: Date | number): string;
204
+ declare function formatLogTimeMs(date: Date | number): string;
204
205
  declare function getTimezoneOffset(date?: Date): string;
205
206
  interface TimezoneDateParts {
206
207
  year: number;
@@ -1316,12 +1317,50 @@ declare namespace Wildcard {
1316
1317
  }, patterns: Record<string, unknown>): unknown;
1317
1318
  }
1318
1319
 
1319
- declare function initLog(options: {
1320
- print: boolean;
1321
- logDir: string;
1322
- logFile?: string;
1323
- dev?: boolean;
1324
- level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
1325
- }): Promise<void>;
1320
+ declare namespace Log {
1321
+ const Level: z.ZodEnum<{
1322
+ DEBUG: "DEBUG";
1323
+ INFO: "INFO";
1324
+ WARN: "WARN";
1325
+ ERROR: "ERROR";
1326
+ }>;
1327
+ type Level = z.infer<typeof Level>;
1328
+ function getLevel(): Level;
1329
+ function withBaseTimestamp(logger: Logger, baseMs: number, fn: () => void): void;
1330
+ type Logger = {
1331
+ debug(message?: any, extra?: Record<string, any>): void;
1332
+ info(message?: any, extra?: Record<string, any>): void;
1333
+ error(message?: any, extra?: Record<string, any>): void;
1334
+ warn(message?: any, extra?: Record<string, any>): void;
1335
+ tag(key: string, value: string): Logger;
1336
+ clone(): Logger;
1337
+ scope(name: string): Scope;
1338
+ time(message: string, extra?: Record<string, any>): {
1339
+ stop(): void;
1340
+ [Symbol.dispose](): void;
1341
+ };
1342
+ };
1343
+ type Scope = {
1344
+ baseTimestampMs: number;
1345
+ debug(message?: any, extra?: Record<string, any>): void;
1346
+ info(message?: any, extra?: Record<string, any>): void;
1347
+ error(message?: any, extra?: Record<string, any>): void;
1348
+ warn(message?: any, extra?: Record<string, any>): void;
1349
+ end(extra?: Record<string, any>): void;
1350
+ run<T>(fn: (scope: Scope) => Promise<T>): Promise<T>;
1351
+ };
1352
+ const Default: Logger;
1353
+ interface Options {
1354
+ print: boolean;
1355
+ logDir: string;
1356
+ logFile?: string;
1357
+ dev?: boolean;
1358
+ level?: Level;
1359
+ }
1360
+ function file(): string;
1361
+ function init(options: Options): Promise<void>;
1362
+ function close(): Promise<void>;
1363
+ function create(tags?: Record<string, any>): Logger;
1364
+ }
1326
1365
 
1327
- export { $, Archive, AsyncQueue, Binary, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, Fetch, type FetchResponse, Filesystem, Fn, type FormatOptions, type GitResult, Glob, Identifier, Ignore, type InlineCodeState$1 as InlineCodeState, Keybind, Lazy, Locale, Lock, MIME_TYPES, Markdown, type MarkdownConfig, type MarkdownIR, type MarkdownLinkSpan, type MarkdownParseOptions, type MarkdownStyle, type MarkdownStyleSpan, type MarkdownTableMode, type MiddlewareDefinition, NamedError, type NodeSpawnObjectArgs, type NodeSpawnOptions, type NodeSpawnResult, type NodeWhichOptions, PKG, PackageRegistry, type ParseCommandResult, type ParsedFrontmatter, type ParsedVersion, PkgShell, type ProxyOptions, type RPCMethod, type RenderLink, type RenderOptions, type RequestOptions, type RouteDefinition, type SSEHandler, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, type TimezoneDateParts, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, addMinutesInTimezone, buildCodeSpanIndex, chunkMarkdownIR, chunkText, chunkTextByBreakResolver, convertMarkdownTables, createInlineCodeState, createPkgShell, createRESTServer, createRPCServer, createServer, createStreamingServer, createWebSocketServer, defer, detectPlatform, escapeCommandArg, escapeCommandArgSafe, extractFrontmatter, findFenceSpanAt, findLast, fn, formatDuration, formatLocalISO, formatLocalISOCompact, formatLogTime, formatMarkdown, getDirectory, getFileExtension, getFilename, getFilenameTruncated, getProxyConfig, getProxyUrl, getTimezoneOffset, getTimezoneParts, git, iife, initLog, isSafeFenceBreak, isValidTimezone, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, normalizeTimezone, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
1366
+ export { $, Archive, AsyncQueue, Binary, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, Fetch, type FetchResponse, Filesystem, Fn, type FormatOptions, type GitResult, Glob, Identifier, Ignore, type InlineCodeState$1 as InlineCodeState, Keybind, Lazy, Locale, Lock, Log, MIME_TYPES, Markdown, type MarkdownConfig, type MarkdownIR, type MarkdownLinkSpan, type MarkdownParseOptions, type MarkdownStyle, type MarkdownStyleSpan, type MarkdownTableMode, type MiddlewareDefinition, NamedError, type NodeSpawnObjectArgs, type NodeSpawnOptions, type NodeSpawnResult, type NodeWhichOptions, PKG, PackageRegistry, type ParseCommandResult, type ParsedFrontmatter, type ParsedVersion, PkgShell, type ProxyOptions, type RPCMethod, type RenderLink, type RenderOptions, type RequestOptions, type RouteDefinition, type SSEHandler, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, type TimezoneDateParts, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, addMinutesInTimezone, buildCodeSpanIndex, chunkMarkdownIR, chunkText, chunkTextByBreakResolver, convertMarkdownTables, createInlineCodeState, createPkgShell, createRESTServer, createRPCServer, createServer, createStreamingServer, createWebSocketServer, defer, detectPlatform, escapeCommandArg, escapeCommandArgSafe, extractFrontmatter, findFenceSpanAt, findLast, fn, formatDuration, formatLocalISO, formatLocalISOCompact, formatLogTime, formatLogTimeMs, formatMarkdown, getDirectory, getFileExtension, getFilename, getFilenameTruncated, getProxyConfig, getProxyUrl, getTimezoneOffset, getTimezoneParts, git, iife, isSafeFenceBreak, isValidTimezone, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, normalizeTimezone, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
package/dist/index.d.ts CHANGED
@@ -201,6 +201,7 @@ declare function now(): number;
201
201
  declare function nowLocalISO(includeMilliseconds?: boolean): string;
202
202
  declare function parseLocalISO(isoString: string): Date;
203
203
  declare function formatLogTime(date: Date | number): string;
204
+ declare function formatLogTimeMs(date: Date | number): string;
204
205
  declare function getTimezoneOffset(date?: Date): string;
205
206
  interface TimezoneDateParts {
206
207
  year: number;
@@ -1316,12 +1317,50 @@ declare namespace Wildcard {
1316
1317
  }, patterns: Record<string, unknown>): unknown;
1317
1318
  }
1318
1319
 
1319
- declare function initLog(options: {
1320
- print: boolean;
1321
- logDir: string;
1322
- logFile?: string;
1323
- dev?: boolean;
1324
- level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
1325
- }): Promise<void>;
1320
+ declare namespace Log {
1321
+ const Level: z.ZodEnum<{
1322
+ DEBUG: "DEBUG";
1323
+ INFO: "INFO";
1324
+ WARN: "WARN";
1325
+ ERROR: "ERROR";
1326
+ }>;
1327
+ type Level = z.infer<typeof Level>;
1328
+ function getLevel(): Level;
1329
+ function withBaseTimestamp(logger: Logger, baseMs: number, fn: () => void): void;
1330
+ type Logger = {
1331
+ debug(message?: any, extra?: Record<string, any>): void;
1332
+ info(message?: any, extra?: Record<string, any>): void;
1333
+ error(message?: any, extra?: Record<string, any>): void;
1334
+ warn(message?: any, extra?: Record<string, any>): void;
1335
+ tag(key: string, value: string): Logger;
1336
+ clone(): Logger;
1337
+ scope(name: string): Scope;
1338
+ time(message: string, extra?: Record<string, any>): {
1339
+ stop(): void;
1340
+ [Symbol.dispose](): void;
1341
+ };
1342
+ };
1343
+ type Scope = {
1344
+ baseTimestampMs: number;
1345
+ debug(message?: any, extra?: Record<string, any>): void;
1346
+ info(message?: any, extra?: Record<string, any>): void;
1347
+ error(message?: any, extra?: Record<string, any>): void;
1348
+ warn(message?: any, extra?: Record<string, any>): void;
1349
+ end(extra?: Record<string, any>): void;
1350
+ run<T>(fn: (scope: Scope) => Promise<T>): Promise<T>;
1351
+ };
1352
+ const Default: Logger;
1353
+ interface Options {
1354
+ print: boolean;
1355
+ logDir: string;
1356
+ logFile?: string;
1357
+ dev?: boolean;
1358
+ level?: Level;
1359
+ }
1360
+ function file(): string;
1361
+ function init(options: Options): Promise<void>;
1362
+ function close(): Promise<void>;
1363
+ function create(tags?: Record<string, any>): Logger;
1364
+ }
1326
1365
 
1327
- export { $, Archive, AsyncQueue, Binary, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, Fetch, type FetchResponse, Filesystem, Fn, type FormatOptions, type GitResult, Glob, Identifier, Ignore, type InlineCodeState$1 as InlineCodeState, Keybind, Lazy, Locale, Lock, MIME_TYPES, Markdown, type MarkdownConfig, type MarkdownIR, type MarkdownLinkSpan, type MarkdownParseOptions, type MarkdownStyle, type MarkdownStyleSpan, type MarkdownTableMode, type MiddlewareDefinition, NamedError, type NodeSpawnObjectArgs, type NodeSpawnOptions, type NodeSpawnResult, type NodeWhichOptions, PKG, PackageRegistry, type ParseCommandResult, type ParsedFrontmatter, type ParsedVersion, PkgShell, type ProxyOptions, type RPCMethod, type RenderLink, type RenderOptions, type RequestOptions, type RouteDefinition, type SSEHandler, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, type TimezoneDateParts, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, addMinutesInTimezone, buildCodeSpanIndex, chunkMarkdownIR, chunkText, chunkTextByBreakResolver, convertMarkdownTables, createInlineCodeState, createPkgShell, createRESTServer, createRPCServer, createServer, createStreamingServer, createWebSocketServer, defer, detectPlatform, escapeCommandArg, escapeCommandArgSafe, extractFrontmatter, findFenceSpanAt, findLast, fn, formatDuration, formatLocalISO, formatLocalISOCompact, formatLogTime, formatMarkdown, getDirectory, getFileExtension, getFilename, getFilenameTruncated, getProxyConfig, getProxyUrl, getTimezoneOffset, getTimezoneParts, git, iife, initLog, isSafeFenceBreak, isValidTimezone, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, normalizeTimezone, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
1366
+ export { $, Archive, AsyncQueue, Binary, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, Fetch, type FetchResponse, Filesystem, Fn, type FormatOptions, type GitResult, Glob, Identifier, Ignore, type InlineCodeState$1 as InlineCodeState, Keybind, Lazy, Locale, Lock, Log, MIME_TYPES, Markdown, type MarkdownConfig, type MarkdownIR, type MarkdownLinkSpan, type MarkdownParseOptions, type MarkdownStyle, type MarkdownStyleSpan, type MarkdownTableMode, type MiddlewareDefinition, NamedError, type NodeSpawnObjectArgs, type NodeSpawnOptions, type NodeSpawnResult, type NodeWhichOptions, PKG, PackageRegistry, type ParseCommandResult, type ParsedFrontmatter, type ParsedVersion, PkgShell, type ProxyOptions, type RPCMethod, type RenderLink, type RenderOptions, type RequestOptions, type RouteDefinition, type SSEHandler, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, type TimezoneDateParts, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, addMinutesInTimezone, buildCodeSpanIndex, chunkMarkdownIR, chunkText, chunkTextByBreakResolver, convertMarkdownTables, createInlineCodeState, createPkgShell, createRESTServer, createRPCServer, createServer, createStreamingServer, createWebSocketServer, defer, detectPlatform, escapeCommandArg, escapeCommandArgSafe, extractFrontmatter, findFenceSpanAt, findLast, fn, formatDuration, formatLocalISO, formatLocalISOCompact, formatLogTime, formatLogTimeMs, formatMarkdown, getDirectory, getFileExtension, getFilename, getFilenameTruncated, getProxyConfig, getProxyUrl, getTimezoneOffset, getTimezoneParts, git, iife, isSafeFenceBreak, isValidTimezone, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, normalizeTimezone, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };