UNPKG

@stoar/sdk

Version:

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

152 lines 3.82 kB
import type Arweave from 'arweave/web'; export interface StoarConfig { arweave?: Arweave; gateway?: string; wallet?: string | ArrayBuffer | object; appName?: string; appVersion?: string; } export interface UploadOptions { tags?: Record<string, string>; contentType?: string; encrypt?: boolean; progress?: (progress: number) => void; batch?: boolean | string; } export interface UploadResult { id: string; url: string; size: number; contentType: string; tags: Record<string, string>; timestamp: number; status?: 'completed' | 'pending'; batchId?: string; } export interface FileMetadata { name: string; size: number; contentType: string; lastModified?: number; } export interface BatchUploadOptions { tags?: Record<string, string>; bundleTags?: Record<string, string>; progress?: (progress: { completed: number; total: number; current?: string; }) => void; concurrent?: number; } export interface BatchUploadResult { bundleId?: string; bundleUrl?: string; files: Array<{ name: string; id: string; url: string; size: number; index: number; }>; totalSize: number; totalCost: number; } export interface S3CompatibleConfig { bucket: string; region?: string; endpoint?: string; accessKeyId?: string; secretAccessKey?: string; } export interface S3PutObjectParams { Key: string; Body: Buffer | Uint8Array | string; ContentType?: string; Metadata?: Record<string, string>; ACL?: string; } export interface S3GetObjectParams { Key: string; } export interface S3ListObjectsParams { Prefix?: string; MaxKeys?: number; Marker?: string; } export interface QueryOptions { limit?: number; after?: string; tags?: Record<string, string>; owner?: string; minBlock?: number; maxBlock?: number; } export interface QueryResult { id: string; owner: string; tags: Record<string, string>; block: { height: number; timestamp: number; }; fee: string; quantity: string; } export interface WalletInterface { address: string; sign(data: Uint8Array): Promise<Uint8Array>; encrypt?(data: Uint8Array, publicKey: string): Promise<Uint8Array>; decrypt?(data: Uint8Array): Promise<Uint8Array>; } export declare class StoarError extends Error { code: string; details?: unknown; constructor(message: string, code: string, details?: unknown); } export declare class UploadError extends StoarError { constructor(message: string, details?: unknown); } export declare class BundleError extends StoarError { constructor(message: string, details?: unknown); } export declare class WalletError extends StoarError { constructor(message: string, details?: unknown); } export declare class InsufficientBalanceError extends StoarError { required: string; available: string; constructor(required: string, available: string, details?: unknown); } export interface BatchOptions { maxFiles?: number; maxBytes?: number; timeout?: number; autoCommit?: boolean; tags?: Record<string, string>; bundleTags?: Record<string, string>; } export interface BatchCommitResult { batchId: string; bundleId: string; bundleUrl: string; fileCount: number; totalSize: number; totalCost: number; files: Array<{ name: string; id: string; url: string; size: number; index: number; }>; } export interface BatchStatus { batchId: string; fileCount: number; totalSize: number; status: 'open' | 'processing' | 'completed' | 'failed'; createdAt: number; error?: string; } //# sourceMappingURL=index.d.ts.map