UNPKG

@stoar/sdk

Version:

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

117 lines 2.88 kB
import type { ArweaveManifest } from './manifest-manager'; /** * Transaction record stored locally */ export interface TransactionRecord { txId: string; timestamp: number; type: 'file' | 'manifest' | 'metadata' | 'versions' | 'index'; bucketName?: string; key?: string; size: number; contentType?: string; tags?: Record<string, string>; data?: any; } /** * Bucket state tracked locally */ export interface BucketState { bucketName: string; currentManifestId: string; manifestVersion: number; previousManifests: string[]; files: Record<string, { txId: string; version: number; size: number; uploadedAt: number; }>; metadata: { owner: string; createdAt: number; visibility: 'public' | 'private'; }; } /** * Local storage configuration */ export interface LocalStorageConfig { baseDir?: string; } /** * Manages local storage for development and testing * Tracks all transactions and allows state reconstruction */ export declare class LocalStorageManager { private baseDir; private transactionsDir; private bucketsDir; private manifestsDir; constructor(config?: LocalStorageConfig); /** * Ensure all required directories exist */ private ensureDirectories; /** * Record a transaction */ recordTransaction(record: TransactionRecord): void; /** * Get a transaction record */ getTransaction(txId: string): TransactionRecord | null; /** * Record a manifest */ recordManifest(manifestId: string, manifest: ArweaveManifest, bucketName: string): void; /** * Get a manifest */ getManifest(manifestId: string): { manifest: ArweaveManifest; bucketName: string; } | null; /** * Update bucket state based on transaction */ private updateBucketState; /** * Get bucket state */ getBucketState(bucketName: string): BucketState | null; /** * List all buckets */ listBuckets(): string[]; /** * Get manifest history for a bucket */ getManifestHistory(bucketName: string): { version: number; manifestId: string; timestamp: number; }[]; /** * Get file icon based on extension/type */ private getFileIcon; /** * Export bucket state as HTML for visualization */ exportBucketAsHtml(bucketName: string): string; /** * Update bucket with manifest changes */ updateBucketFromManifest(bucketName: string, manifestId: string, updates: Array<{ operation: 'add' | 'remove'; key: string; txId?: string; size?: number; }>, owner?: string): void; /** * Clear all local storage */ clear(): void; } //# sourceMappingURL=local-storage.d.ts.map