UNPKG

@stoar/sdk

Version:

JavaScript/TypeScript SDK for STOAR - Decentralized file storage on Arweave

79 lines 2.53 kB
import { type StoarConfig, type UploadOptions, type UploadResult, type BatchUploadOptions, type BatchUploadResult, type FileMetadata, type QueryOptions, type QueryResult, type BatchOptions, type BatchCommitResult, type BatchStatus } from "../types"; export declare class StoarClient { private arweave; private wallet?; private config; private batchQueues; private batchStatuses; private defaultBatchId?; constructor(config?: StoarConfig); /** * Initialize the client with a wallet */ init(walletSource?: string | ArrayBuffer | object): Promise<void>; /** * Upload a single file to Arweave */ uploadFile(data: Buffer | Uint8Array | string, metadata: FileMetadata, options?: UploadOptions): Promise<UploadResult>; /** * Upload multiple files as an AR bundle */ uploadBatch(files: Array<{ data: Buffer | Uint8Array; metadata: FileMetadata; }>, options?: BatchUploadOptions): Promise<BatchUploadResult>; /** * Query transactions using GraphQL */ query(options?: QueryOptions): Promise<QueryResult[]>; /** * Get file data by transaction ID */ getFile(transactionId: string): Promise<Uint8Array>; /** * Get wallet address */ getAddress(): string; /** * Get wallet balance in AR */ getBalance(): Promise<string>; /** * Create a new batch for bundling files */ createBatch(options?: BatchOptions): string; /** * Add a file to a specific batch */ addToBatch(batchId: string, data: Buffer | Uint8Array | string, metadata: FileMetadata, options?: UploadOptions): Promise<string>; /** * Commit a batch and upload as bundle */ commitBatch(batchId: string): Promise<BatchCommitResult>; /** * Get batch status */ getBatchStatus(batchId: string): BatchStatus | null; /** * Enable auto-batching for all uploads */ enableBatching(options?: BatchOptions): void; /** * Disable auto-batching and commit any pending files */ disableBatching(): Promise<BatchCommitResult | void>; /** * Check if wallet has sufficient balance for upload * @throws InsufficientBalanceError if balance is 0 or negative */ private checkBalance; /** * Helper method to extract tags from transaction */ private extractTags; /** * Helper method to build tag query for ArQL */ private buildTagQuery; } //# sourceMappingURL=index.d.ts.map