@opendatalabs/vana-sdk
Version:
A TypeScript library for interacting with Vana Network smart contracts.
1 lines • 3.8 kB
Source Map (JSON)
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n * Defines interface for storage provider implementations.\n *\n * @remarks\n * Abstracts storage backends (IPFS, Google Drive, Pinata) behind\n * common interface for encrypted file operations.\n *\n * @category Storage\n * @example\n * ```typescript\n * class MyStorage implements StorageProvider {\n * async upload(file: Blob): Promise<StorageUploadResult> {\n * const url = await uploadToService(file);\n * return { url, size: file.size, contentType: file.type };\n * }\n *\n * async download(url: string): Promise<Blob> {\n * return fetch(url).then(r => r.blob());\n * }\n * }\n * ```\n */\nexport interface StorageProvider {\n /**\n * Upload a file to the storage provider\n *\n * @param file - The file to upload\n * @param filename - Optional custom filename\n * @returns Promise with storage URL and metadata\n */\n upload(file: Blob, filename?: string): Promise<StorageUploadResult>;\n\n /**\n * Download a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with file blob\n */\n download(url: string): Promise<Blob>;\n\n /**\n * List files from the storage provider\n *\n * @param options - Optional filtering and pagination\n * @returns Promise with file list\n */\n list(options?: StorageListOptions): Promise<StorageFile[]>;\n\n /**\n * Delete a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with success status\n */\n delete(url: string): Promise<boolean>;\n\n /**\n * Get provider-specific configuration\n *\n * @returns Provider configuration object\n */\n getConfig(): StorageProviderConfig;\n}\n\nexport interface StorageUploadResult {\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageFile {\n /** File identifier */\n id: string;\n /** File name */\n name: string;\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Upload timestamp */\n createdAt: Date;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageListOptions {\n /** Maximum number of files to return */\n limit?: number;\n /** Pagination cursor/offset */\n offset?: string | number;\n /** Filter by file name pattern */\n namePattern?: string;\n /** Filter by content type */\n contentType?: string;\n}\n\nexport interface StorageProviderConfig {\n /** Provider name */\n name: string;\n /** Provider type */\n type: string;\n /** Whether authentication is required */\n requiresAuth: boolean;\n /** Supported features */\n features: {\n upload: boolean;\n download: boolean;\n list: boolean;\n delete: boolean;\n };\n}\n\nexport class StorageError extends Error {\n public readonly code: string;\n public readonly provider: string;\n // The 'cause' property is now inherited from the base Error class\n\n constructor(\n message: string,\n code: string,\n provider: string,\n options?: { cause?: Error },\n ) {\n // Pass the options object with 'cause' to the super constructor\n super(message, options);\n this.name = \"StorageError\";\n this.code = code;\n this.provider = provider;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuHO,MAAM,qBAAqB,MAAM;AAAA,EACtB;AAAA,EACA;AAAA;AAAA,EAGhB,YACE,SACA,MACA,UACA,SACA;AAEA,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;","names":[]}