@easbot/utils 0.2.23 → 0.2.25

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
@@ -171,6 +171,7 @@ declare namespace Shell {
171
171
  stderr?: 'pipe' | 'ignore';
172
172
  windowsHide?: boolean;
173
173
  shell?: boolean;
174
+ timeout?: number;
174
175
  }
175
176
  function $(strings: TemplateStringsArray, ...values: unknown[]): {
176
177
  quiet: () => any;
@@ -716,6 +717,43 @@ interface RetryOptions {
716
717
  }
717
718
  declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
718
719
 
720
+ type ResponseType = 'json' | 'text' | 'arrayBuffer' | 'blob' | 'buffer';
721
+ interface RequestOptions extends RequestInit {
722
+ timeout?: number;
723
+ retries?: number;
724
+ retryDelay?: number;
725
+ responseType?: ResponseType;
726
+ signal?: AbortSignal;
727
+ }
728
+ interface FetchResponse<T = any> {
729
+ ok: boolean;
730
+ status: number;
731
+ statusText: string;
732
+ headers: Headers;
733
+ data: T;
734
+ url: string;
735
+ }
736
+ interface ProxyOptions {
737
+ connectTimeout?: number;
738
+ keepAliveTimeout?: number;
739
+ httpProxy?: string;
740
+ httpsProxy?: string;
741
+ }
742
+ declare namespace Fetch {
743
+ function hasProxyConfigured(): boolean;
744
+ function getProxyUrl(): string | undefined;
745
+ function enableProxy(options?: ProxyOptions): void;
746
+ function disableProxy(): void;
747
+ function isProxyEnabled(): boolean;
748
+ function get<T = any>(url: string | URL, options?: RequestOptions): Promise<FetchResponse<T>>;
749
+ function post<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
750
+ function put<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
751
+ function del<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
752
+ function patch<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
753
+ function request<T = any>(url: string | URL, options?: RequestOptions): Promise<FetchResponse<T>>;
754
+ function autoProxy(options?: ProxyOptions): boolean;
755
+ }
756
+
719
757
  declare namespace Slug {
720
758
  function create(): string;
721
759
  }
@@ -1244,4 +1282,4 @@ declare function initLog(options: {
1244
1282
  level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
1245
1283
  }): Promise<void>;
1246
1284
 
1247
- export { $, Archive, AsyncQueue, Binary, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, 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 RPCMethod, type RenderLink, type RenderOptions, type RouteDefinition, type SSEHandler, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, 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, getTimezoneOffset, git, iife, initLog, isSafeFenceBreak, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
1285
+ 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, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, 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, getTimezoneOffset, git, iife, initLog, isSafeFenceBreak, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, 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
@@ -171,6 +171,7 @@ declare namespace Shell {
171
171
  stderr?: 'pipe' | 'ignore';
172
172
  windowsHide?: boolean;
173
173
  shell?: boolean;
174
+ timeout?: number;
174
175
  }
175
176
  function $(strings: TemplateStringsArray, ...values: unknown[]): {
176
177
  quiet: () => any;
@@ -716,6 +717,43 @@ interface RetryOptions {
716
717
  }
717
718
  declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
718
719
 
720
+ type ResponseType = 'json' | 'text' | 'arrayBuffer' | 'blob' | 'buffer';
721
+ interface RequestOptions extends RequestInit {
722
+ timeout?: number;
723
+ retries?: number;
724
+ retryDelay?: number;
725
+ responseType?: ResponseType;
726
+ signal?: AbortSignal;
727
+ }
728
+ interface FetchResponse<T = any> {
729
+ ok: boolean;
730
+ status: number;
731
+ statusText: string;
732
+ headers: Headers;
733
+ data: T;
734
+ url: string;
735
+ }
736
+ interface ProxyOptions {
737
+ connectTimeout?: number;
738
+ keepAliveTimeout?: number;
739
+ httpProxy?: string;
740
+ httpsProxy?: string;
741
+ }
742
+ declare namespace Fetch {
743
+ function hasProxyConfigured(): boolean;
744
+ function getProxyUrl(): string | undefined;
745
+ function enableProxy(options?: ProxyOptions): void;
746
+ function disableProxy(): void;
747
+ function isProxyEnabled(): boolean;
748
+ function get<T = any>(url: string | URL, options?: RequestOptions): Promise<FetchResponse<T>>;
749
+ function post<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
750
+ function put<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
751
+ function del<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
752
+ function patch<T = any>(url: string | URL, body?: any, options?: RequestOptions): Promise<FetchResponse<T>>;
753
+ function request<T = any>(url: string | URL, options?: RequestOptions): Promise<FetchResponse<T>>;
754
+ function autoProxy(options?: ProxyOptions): boolean;
755
+ }
756
+
719
757
  declare namespace Slug {
720
758
  function create(): string;
721
759
  }
@@ -1244,4 +1282,4 @@ declare function initLog(options: {
1244
1282
  level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
1245
1283
  }): Promise<void>;
1246
1284
 
1247
- export { $, Archive, AsyncQueue, Binary, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, 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 RPCMethod, type RenderLink, type RenderOptions, type RouteDefinition, type SSEHandler, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, 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, getTimezoneOffset, git, iife, initLog, isSafeFenceBreak, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
1285
+ 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, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, 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, getTimezoneOffset, git, iife, initLog, isSafeFenceBreak, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };