@ifzai/connect2dify
Version:
A comprehensive TypeScript client for the Dify API, providing a clean and modular interface for chat, workflow, file management, and application interactions.
39 lines (38 loc) • 1.29 kB
TypeScript
/**
* HTTP utilities and stream handling for Dify API client
*/
/**
* Creates standard headers for API requests
*/
export declare function createHeaders(apiKey: string, extraHeaders?: Record<string, string>, includeContentType?: boolean): Record<string, string>;
/**
* Handles API response errors
*/
export declare function handleResponse<T>(response: Response): Promise<T>;
/**
* Parses Server-Sent Events (SSE) data chunks
*/
export declare function parseSSEChunk(chunkData: string): unknown | null;
/**
* Processes buffer and extracts complete SSE chunks
*/
export declare function processSSEBuffer<T>(buffer: string, chunks: T[], onChunk?: (chunk: T) => void): string;
/**
* Handles streaming response using modern fetch API
*/
export declare function handleStreamResponse<T>(response: Response, onChunk?: (chunk: T) => void): Promise<T[]>;
/**
* Checks if streaming is supported in the current environment
*/
export declare function isStreamingSupported(): boolean;
/**
* Creates a FormData object for file uploads
*/
export declare function createFormData(params: {
file: File | Blob;
user: string;
}): FormData;
/**
* Builds URL with query parameters
*/
export declare function buildURL(baseUrl: string, path: string, params?: Record<string, string>): string;