Create a new SNApiClient
HttpClient instance for making REST requests
Download the file associated with a task
Downloads the file data as a ReadableStream for efficient streaming of large files without loading them entirely into memory. Maps to: GET /api/downloads/cascade/{task_id}/file
The task ID to download
Promise resolving to a ReadableStream of the file data
Get information about a specific task
Retrieves detailed information about a Cascade task, including its status and progress. Maps to: GET /api/actions/cascade/tasks/{task_id}
The task ID to query
Promise resolving to task information
Get the status of a specific task
Retrieves just the status information for a Cascade task, which is lighter weight than getting the full task details. Maps to: GET /api/actions/cascade/tasks/{task_id}/status
The task ID to query
Promise resolving to task status
Request a download for a specific Cascade action
Initiates a download task for a previously stored Cascade action. Maps to: POST /api/actions/cascade/{action_id}/downloads
The action ID to download
Request body (currently unused in spec)
Promise resolving to the response with download task ID
Start a new Cascade storage action
Initiates a new Cascade storage action by uploading a file with required authentication. Maps to: POST /api/v1/actions/cascade
Request body containing the action ID, signature, and file to upload
Promise resolving to the response with task ID
Watch download task status via Server-Sent Events (SSE)
Creates an EventSource connection to monitor task status updates in real-time. The SSE stream will emit events until the task completes or fails. Maps to: GET /api/v1/downloads/cascade/{task_id}/status
The task ID to watch
EventSource instance for receiving status updates
const eventSource = client.watchDownloadTask('task-456');
eventSource.addEventListener('sdk:completed', (event) => {
console.log('Task completed:', event.data);
eventSource.close();
});
eventSource.addEventListener('error', (event) => {
console.error('Task error:', event);
eventSource.close();
});
Typed REST client for interacting with sn-api endpoints.
This client provides a thin, type-safe wrapper around the HttpClient for Cascade storage operations. It maps directly to the sn-api REST endpoints defined in the OpenAPI specification.
Example