/** * dnetwork.ts - Network Utility Functions for HTTP Requests * * Provides a set of async functions for GET/POST requests using axios, * with integrated logging, assertion, and error handling. * - All requests log activity via dlog * - All responses are checked for HTTP success * - JSON responses are parsed and returned as objects * - SimpleStore helpers for common API patterns * - Detailed error handling for network issues */ import { AxiosRequestConfig } from "axios"; import { DError } from "./dassert"; import { TObject } from "./dtypes"; export declare class NetworkError extends DError { data?: T; statusCode?: number; constructor(message: string, code?: string, data?: T, statusCode?: number); } export declare namespace dnetwork { /** * Perform a GET request and return the response data. */ function get(url: string, config?: AxiosRequestConfig): Promise; /** * Perform a GET request and return the response as a JSON object. */ function getJson(url: string, config?: AxiosRequestConfig): Promise; /** * Perform a POST request and return the response data. */ function post(url: string, data: any, config?: AxiosRequestConfig): Promise; /** * Perform a POST request and return the response as a JSON object. */ function postJson(url: string, data: TObject, config?: AxiosRequestConfig): Promise; /** * GET request to a SimpleStore endpoint, expects {status: "success", ...} */ function getSimpleStore(url: string, config?: AxiosRequestConfig): Promise; /** * POST request to a SimpleStore endpoint, expects {status: "success", ...} */ function postSimpleStore(url: string, data: TObject, config?: AxiosRequestConfig): Promise; /** * Perform a GET request with a browser-like user-agent header. */ function getAsFakeBrowser(url: string, config?: AxiosRequestConfig): Promise; }