@genwave/svgmaker-sdk
Version:
Official Node.js SDK for SVGMaker API
90 lines • 2.56 kB
TypeScript
import { Readable } from 'stream';
import { SVGMakerConfig } from '../types/config';
/**
* Additional options for requests
*/
export interface RequestOptions extends globalThis.RequestInit {
/**
* Request timeout in milliseconds
*/
timeout?: number;
/**
* Request parameters for query string
*/
params?: Record<string, string | number | boolean | undefined>;
/**
* Form data for multipart/form-data requests
*/
formData?: globalThis.FormData;
/**
* HTTP method
*/
method?: string;
/**
* HTTP headers
*/
headers?: Record<string, string>;
}
/**
* HTTP client for making requests to the SVGMaker API
*/
export declare class HttpClient {
private config;
/**
* Create a new HTTP client
* @param config SDK configuration
*/
constructor(config: SVGMakerConfig);
/**
* Make a request to the SVGMaker API
* @param url Request URL
* @param options Request options
* @returns Promise with the response data
* @throws {APIError} If the API returns an error
* @throws {TimeoutError} If the request times out
* @throws {NetworkError} If there's a network error
*/
request<T>(url: string, options?: RequestOptions): Promise<T>;
/**
* Make a GET request
* @param url Request URL
* @param options Request options
* @returns Promise with the response data
*/
get<T>(url: string, options?: RequestOptions): Promise<T>;
/**
* Make a POST request
* @param url Request URL
* @param data Request body data
* @param options Request options
* @returns Promise with the response data
*/
post<T>(url: string, data: any, options?: RequestOptions): Promise<T>;
/**
* Create a FormData object from file input
* @param fieldName Form field name
* @param file File input (path, buffer, or stream)
* @returns FormData object
*/
createFormData(fieldName: string, file: string | Buffer | Readable): Promise<FormData>;
/**
* Build the full URL with query parameters
* @param url Base URL
* @param params Query parameters
* @returns Full URL
*/
private buildUrl;
/**
* Build request headers
* @param options Request options
* @returns Headers object
*/
private buildHeaders;
/**
* Handle API error responses
* @param response Error response
* @returns Error object
*/
private handleErrorResponse;
}
//# sourceMappingURL=httpClient.d.ts.map