@arke-institute/sdk 2.3.8 → 2.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/operations/upload/engine.ts","../../src/operations/upload/cid.ts","../../src/operations/upload/scanners.ts","../../src/operations/folders.ts","../../src/operations/batch.ts","../../src/operations/crypto.ts"],"sourcesContent":["/**\n * Upload Engine\n *\n * Core upload implementation optimized for fast tree visibility:\n * 1. Create folders by depth (with unidirectional 'in' → parent)\n * 2. Create file entities (metadata only, high parallelism)\n * 3. Backlink parents with 'contains' relationships\n * → Tree is now browsable! Users can explore structure immediately.\n * 4. Upload file content via POST /files/{id}/content (byte-based pool, ~200MB in flight)\n * - Direct upload to API endpoint\n * - API streams to R2, computes CID, updates entity atomically\n *\n * Byte-based pool (for uploads):\n * - Maintains ~200MB of data in flight at all times\n * - When a file completes, next file starts immediately (no gaps)\n * - Small files: Many upload in parallel\n * - Large files: Fewer upload in parallel (bandwidth-limited)\n * - Single file > 200MB: Uploads alone when pool is empty\n *\n * This minimizes time-to-browse by:\n * - Creating all entities before uploading content\n * - Using unidirectional 'in' relationship on entity creation\n * - Adding all 'contains' relationships in a single PUT per parent\n */\n\nimport type { ArkeClient } from '../../client/ArkeClient.js';\nimport type { components } from '../../generated/types.js';\nimport type {\n UploadTree,\n UploadOptions,\n UploadResult,\n UploadProgress,\n CreatedFolder,\n CreatedFile,\n CreatedEntity,\n UploadFolder,\n} from './types.js';\n\ntype CreateCollectionRequest = components['schemas']['CreateCollectionRequest'];\ntype CreateFolderRequest = components['schemas']['CreateFolderRequest'];\ntype CreateFileRequest = components['schemas']['CreateFileRequest'];\ntype UpdateFolderRequest = components['schemas']['UpdateFolderRequest'];\ntype UpdateCollectionRequest = components['schemas']['UpdateCollectionRequest'];\n\n// Phase constants\nconst PHASE_COUNT = 3; // creating, backlinking, uploading (excluding complete/error)\nconst PHASE_INDEX: Record<string, number> = {\n creating: 0,\n backlinking: 1,\n uploading: 2,\n complete: 3,\n error: -1,\n};\n\n// =============================================================================\n// Concurrency Utilities\n// =============================================================================\n\n/**\n * Simple concurrency limiter for parallel operations.\n */\nasync function parallelLimit<T, R>(\n items: T[],\n concurrency: number,\n fn: (item: T, index: number) => Promise<R>\n): Promise<R[]> {\n const results: R[] = [];\n let index = 0;\n\n async function worker(): Promise<void> {\n while (index < items.length) {\n const currentIndex = index++;\n const item = items[currentIndex]!;\n results[currentIndex] = await fn(item, currentIndex);\n }\n }\n\n const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker());\n await Promise.all(workers);\n\n return results;\n}\n\n// =============================================================================\n// Byte-Based Pool\n// =============================================================================\n\n/** Target bytes in flight (~200MB) */\nconst TARGET_BYTES_IN_FLIGHT = 200 * 1024 * 1024;\n\n/**\n * Pool that maintains a target number of bytes in flight.\n *\n * When a file completes, its bytes are released and the next\n * waiting file can start immediately. This keeps the pipeline full.\n *\n * - Small files: Many run in parallel (up to ~200MB worth)\n * - Large files: Fewer run in parallel\n * - Single file > 200MB: Runs alone (allowed when pool is empty)\n */\nclass BytePool {\n private bytesInFlight = 0;\n private waitQueue: Array<() => void> = [];\n\n constructor(private targetBytes: number = TARGET_BYTES_IN_FLIGHT) {}\n\n async run<T>(size: number, fn: () => Promise<T>): Promise<T> {\n // Wait until we have room\n // Exception: if pool is empty, always allow (handles files > targetBytes)\n while (this.bytesInFlight > 0 && this.bytesInFlight + size > this.targetBytes) {\n await new Promise<void>((resolve) => this.waitQueue.push(resolve));\n }\n\n this.bytesInFlight += size;\n try {\n return await fn();\n } finally {\n this.bytesInFlight -= size;\n // Wake up next waiting task\n const next = this.waitQueue.shift();\n if (next) next();\n }\n }\n}\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\n/**\n * Parse folder path to get parent path.\n * e.g., \"docs/images/photos\" -> \"docs/images\"\n */\nfunction getParentPath(relativePath: string): string | null {\n const lastSlash = relativePath.lastIndexOf('/');\n if (lastSlash === -1) return null;\n return relativePath.slice(0, lastSlash);\n}\n\n/**\n * Group folders by depth level.\n */\nfunction groupFoldersByDepth(folders: UploadFolder[]): Map<number, UploadFolder[]> {\n const byDepth = new Map<number, UploadFolder[]>();\n\n for (const folder of folders) {\n const depth = folder.relativePath.split('/').length - 1;\n if (!byDepth.has(depth)) byDepth.set(depth, []);\n byDepth.get(depth)!.push(folder);\n }\n\n return byDepth;\n}\n\n// =============================================================================\n// Main Upload Function\n// =============================================================================\n\n/**\n * Main upload function.\n * Orchestrates the entire upload process with optimized relationship strategy.\n */\nexport async function uploadTree(\n client: ArkeClient,\n tree: UploadTree,\n options: UploadOptions\n): Promise<UploadResult> {\n const { target, onProgress, concurrency = 10, continueOnError = false, note } = options;\n\n const errors: Array<{ path: string; error: string }> = [];\n const createdFolders: CreatedFolder[] = [];\n const createdFiles: CreatedFile[] = [];\n\n // Maps for tracking\n const foldersByPath = new Map<string, { id: string; cid: string }>();\n\n // Calculate totals\n const totalEntities = tree.files.length + tree.folders.length;\n const totalBytes = tree.files.reduce((sum, f) => sum + f.size, 0);\n let completedEntities = 0;\n let bytesUploaded = 0;\n\n // Helper to report progress\n const reportProgress = (progress: Partial<UploadProgress>) => {\n if (onProgress) {\n const phase = progress.phase || 'creating';\n const phaseIndex = PHASE_INDEX[phase] ?? -1;\n\n // Calculate phase percent based on current phase\n let phasePercent = 0;\n if (phase === 'creating') {\n // Creating phase: progress is based on entities created\n const done = progress.completedEntities ?? completedEntities;\n phasePercent = totalEntities > 0 ? Math.round((done / totalEntities) * 100) : 100;\n } else if (phase === 'backlinking') {\n // Backlinking phase: progress is based on parents updated\n const done = progress.completedParents ?? 0;\n const total = progress.totalParents ?? 0;\n phasePercent = total > 0 ? Math.round((done / total) * 100) : 100;\n } else if (phase === 'uploading') {\n // Uploading phase: progress is based on bytes uploaded\n const done = progress.bytesUploaded ?? bytesUploaded;\n phasePercent = totalBytes > 0 ? Math.round((done / totalBytes) * 100) : 100;\n } else if (phase === 'complete') {\n phasePercent = 100;\n }\n\n onProgress({\n phase,\n phaseIndex,\n phaseCount: PHASE_COUNT,\n phasePercent,\n totalEntities,\n completedEntities,\n totalParents: 0,\n completedParents: 0,\n totalBytes,\n bytesUploaded,\n ...progress,\n } as UploadProgress);\n }\n };\n\n try {\n // ─────────────────────────────────────────────────────────────────────────\n // SETUP: Resolve or create collection\n // ─────────────────────────────────────────────────────────────────────────\n let collectionId: string;\n let collectionCid: string;\n let collectionCreated = false;\n\n if (target.createCollection) {\n const collectionBody: CreateCollectionRequest = {\n label: target.createCollection.label,\n description: target.createCollection.description,\n roles: target.createCollection.roles,\n note,\n };\n\n const { data, error } = await client.api.POST('/collections', {\n body: collectionBody,\n });\n\n if (error || !data) {\n throw new Error(`Failed to create collection: ${JSON.stringify(error)}`);\n }\n\n collectionId = data.id;\n collectionCid = data.cid;\n collectionCreated = true;\n } else if (target.collectionId) {\n collectionId = target.collectionId;\n\n const { data, error } = await client.api.GET('/collections/{id}', {\n params: { path: { id: collectionId } },\n });\n\n if (error || !data) {\n throw new Error(`Failed to fetch collection: ${JSON.stringify(error)}`);\n }\n\n collectionCid = data.cid;\n } else {\n throw new Error('Must provide either collectionId or createCollection in target');\n }\n\n // Determine the parent for root-level items\n const rootParentId = target.parentId ?? collectionId;\n\n // ─────────────────────────────────────────────────────────────────────────\n // PHASE 1: Create entities (folders by depth, then files)\n // ─────────────────────────────────────────────────────────────────────────\n reportProgress({ phase: 'creating', completedEntities: 0 });\n\n // Group folders by depth\n const foldersByDepth = groupFoldersByDepth(tree.folders);\n const sortedDepths = [...foldersByDepth.keys()].sort((a, b) => a - b);\n\n // Create folders depth by depth (parents before children)\n for (const depth of sortedDepths) {\n const foldersAtDepth = foldersByDepth.get(depth)!;\n\n await Promise.all(\n foldersAtDepth.map(async (folder) => {\n try {\n const parentPath = getParentPath(folder.relativePath);\n const parentId = parentPath ? foldersByPath.get(parentPath)!.id : rootParentId;\n const parentType = parentPath ? 'folder' : parentId === collectionId ? 'collection' : 'folder';\n\n const folderBody: CreateFolderRequest = {\n label: folder.name,\n collection: collectionId,\n note,\n relationships: [{ predicate: 'in', peer: parentId, peer_type: parentType }],\n };\n\n const { data, error } = await client.api.POST('/folders', {\n body: folderBody,\n });\n\n if (error || !data) {\n throw new Error(JSON.stringify(error));\n }\n\n // Track folder\n foldersByPath.set(folder.relativePath, { id: data.id, cid: data.cid });\n createdFolders.push({\n name: folder.name,\n relativePath: folder.relativePath,\n id: data.id,\n entityCid: data.cid,\n });\n\n completedEntities++;\n reportProgress({\n phase: 'creating',\n completedEntities,\n currentItem: folder.relativePath,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: folder.relativePath, error: `Folder creation failed: ${errorMsg}` });\n completedEntities++;\n } else {\n throw new Error(`Failed to create folder ${folder.relativePath}: ${errorMsg}`);\n }\n }\n })\n );\n }\n\n // Create file entities (metadata only, no content upload yet)\n // Use simple concurrency limit for API calls\n const FILE_CREATION_CONCURRENCY = 50;\n\n await parallelLimit(tree.files, FILE_CREATION_CONCURRENCY, async (file) => {\n try {\n const parentPath = getParentPath(file.relativePath);\n const parentId = parentPath ? foldersByPath.get(parentPath)!.id : rootParentId;\n const parentType = parentPath ? 'folder' : parentId === collectionId ? 'collection' : 'folder';\n\n // Create file entity with 'in' relationship\n // Server computes CID when content is uploaded\n const fileBody: CreateFileRequest = {\n key: crypto.randomUUID(), // Generate unique storage key\n filename: file.name,\n content_type: file.mimeType,\n size: file.size,\n collection: collectionId,\n relationships: [{ predicate: 'in', peer: parentId, peer_type: parentType }],\n };\n\n const { data, error } = await client.api.POST('/files', {\n body: fileBody,\n });\n\n if (error || !data) {\n throw new Error(`Entity creation failed: ${JSON.stringify(error)}`);\n }\n\n // Track file for later upload\n createdFiles.push({\n ...file,\n id: data.id,\n entityCid: data.cid,\n });\n\n completedEntities++;\n reportProgress({\n phase: 'creating',\n completedEntities,\n currentItem: file.relativePath,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: file.relativePath, error: errorMsg });\n completedEntities++;\n } else {\n throw new Error(`Failed to create file ${file.relativePath}: ${errorMsg}`);\n }\n }\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // PHASE 2: Backlink - Update each parent with 'contains' relationships\n // ─────────────────────────────────────────────────────────────────────────\n\n // Build parent -> children map\n const childrenByParent = new Map<string, Array<{ id: string; type: 'file' | 'folder' }>>();\n\n // Add folders as children of their parents\n for (const folder of createdFolders) {\n const parentPath = getParentPath(folder.relativePath);\n const parentId = parentPath ? foldersByPath.get(parentPath)!.id : rootParentId;\n\n if (!childrenByParent.has(parentId)) childrenByParent.set(parentId, []);\n childrenByParent.get(parentId)!.push({ id: folder.id, type: 'folder' });\n }\n\n // Add files as children of their parents\n for (const file of createdFiles) {\n const parentPath = getParentPath(file.relativePath);\n const parentId = parentPath ? foldersByPath.get(parentPath)!.id : rootParentId;\n\n if (!childrenByParent.has(parentId)) childrenByParent.set(parentId, []);\n childrenByParent.get(parentId)!.push({ id: file.id, type: 'file' });\n }\n\n const totalParents = childrenByParent.size;\n let completedParents = 0;\n\n reportProgress({ phase: 'backlinking', totalParents, completedParents: 0 });\n\n // Update all parents in parallel - each parent gets one PUT with all its children\n const parentEntries = [...childrenByParent.entries()];\n\n await parallelLimit(parentEntries, concurrency, async ([parentId, children]) => {\n try {\n const isCollection = parentId === collectionId;\n\n // Build relationships_add array with all children\n const relationshipsAdd = children.map((child) => ({\n predicate: 'contains' as const,\n peer: child.id,\n peer_type: child.type,\n }));\n\n if (isCollection) {\n // Get current collection CID for CAS\n const { data: collData, error: getError } = await client.api.GET('/collections/{id}', {\n params: { path: { id: parentId } },\n });\n if (getError || !collData) {\n throw new Error(`Failed to fetch collection: ${JSON.stringify(getError)}`);\n }\n\n // Update collection with relationships_add\n const updateBody: UpdateCollectionRequest = {\n expect_tip: collData.cid,\n relationships_add: relationshipsAdd,\n note: note ? `${note} (backlink)` : 'Upload backlink',\n };\n\n const { error } = await client.api.PUT('/collections/{id}', {\n params: { path: { id: parentId } },\n body: updateBody,\n });\n\n if (error) {\n throw new Error(JSON.stringify(error));\n }\n } else {\n // Get current folder CID for CAS\n const { data: folderData, error: getError } = await client.api.GET('/folders/{id}', {\n params: { path: { id: parentId } },\n });\n if (getError || !folderData) {\n throw new Error(`Failed to fetch folder: ${JSON.stringify(getError)}`);\n }\n\n // Update folder with relationships_add\n const updateBody: UpdateFolderRequest = {\n expect_tip: folderData.cid,\n relationships_add: relationshipsAdd,\n note: note ? `${note} (backlink)` : 'Upload backlink',\n };\n\n const { error } = await client.api.PUT('/folders/{id}', {\n params: { path: { id: parentId } },\n body: updateBody,\n });\n\n if (error) {\n throw new Error(JSON.stringify(error));\n }\n }\n\n completedParents++;\n reportProgress({\n phase: 'backlinking',\n totalParents,\n completedParents,\n currentItem: `parent:${parentId}`,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: `parent:${parentId}`, error: `Backlink failed: ${errorMsg}` });\n completedParents++;\n } else {\n throw new Error(`Failed to backlink parent ${parentId}: ${errorMsg}`);\n }\n }\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // PHASE 3: Upload file content directly to API\n // Tree is now browsable! Users can explore while content uploads.\n // ─────────────────────────────────────────────────────────────────────────\n reportProgress({ phase: 'uploading', bytesUploaded: 0 });\n\n // Use byte-based pool to maintain ~200MB in flight\n const pool = new BytePool();\n\n await Promise.all(\n createdFiles.map(async (file) => {\n await pool.run(file.size, async () => {\n try {\n // Get file data\n const fileData = await file.getData();\n\n let body: Blob;\n if (fileData instanceof Blob) {\n body = fileData;\n } else if (fileData instanceof Uint8Array) {\n const arrayBuffer = new ArrayBuffer(fileData.byteLength);\n new Uint8Array(arrayBuffer).set(fileData);\n body = new Blob([arrayBuffer], { type: file.mimeType });\n } else {\n body = new Blob([fileData], { type: file.mimeType });\n }\n\n // Upload content directly to API endpoint\n // The API streams to R2, computes CID, and updates the entity atomically\n const { error: uploadError } = await client.api.POST('/files/{id}/content', {\n params: { path: { id: file.id } },\n body: body as unknown as Record<string, never>,\n bodySerializer: (b: unknown) => b as BodyInit,\n headers: { 'Content-Type': file.mimeType },\n } as Parameters<typeof client.api.POST>[1]);\n\n if (uploadError) {\n throw new Error(`Upload failed: ${JSON.stringify(uploadError)}`);\n }\n\n bytesUploaded += file.size;\n reportProgress({\n phase: 'uploading',\n bytesUploaded,\n currentItem: file.relativePath,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: file.relativePath, error: `Upload failed: ${errorMsg}` });\n } else {\n throw new Error(`Failed to upload ${file.relativePath}: ${errorMsg}`);\n }\n }\n });\n })\n );\n\n // ─────────────────────────────────────────────────────────────────────────\n // Complete!\n // ─────────────────────────────────────────────────────────────────────────\n reportProgress({ phase: 'complete', totalParents, completedParents, bytesUploaded });\n\n const resultFolders: CreatedEntity[] = createdFolders.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'folder' as const,\n relativePath: f.relativePath,\n }));\n\n const resultFiles: CreatedEntity[] = createdFiles.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'file' as const,\n relativePath: f.relativePath,\n }));\n\n return {\n success: errors.length === 0,\n collection: {\n id: collectionId,\n cid: collectionCid,\n created: collectionCreated,\n },\n folders: resultFolders,\n files: resultFiles,\n errors,\n };\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n\n reportProgress({\n phase: 'error',\n error: errorMsg,\n });\n\n return {\n success: false,\n collection: {\n id: target.collectionId ?? '',\n cid: '',\n created: false,\n },\n folders: createdFolders.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'folder' as const,\n relativePath: f.relativePath,\n })),\n files: createdFiles.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'file' as const,\n relativePath: f.relativePath,\n })),\n errors: [...errors, { path: '', error: errorMsg }],\n };\n }\n}\n","/**\n * CID Computation Utility\n *\n * Computes IPFS CIDv1 (base32) for file content.\n * Uses raw codec (0x55) and SHA-256 hash.\n *\n * Note: This module is not used internally by the upload engine (the server\n * computes CIDs from uploaded content). It is exported for convenience in case\n * you want to verify entity CIDs, detect duplicates before upload, or perform\n * other content-addressed operations.\n */\n\nimport { CID } from 'multiformats/cid';\nimport { sha256 } from 'multiformats/hashes/sha2';\nimport * as raw from 'multiformats/codecs/raw';\n\n/**\n * Compute CIDv1 for binary content.\n * Returns base32 encoded string (bafk... prefix for raw codec).\n *\n * @param data - Binary content as ArrayBuffer, Uint8Array, or Blob\n * @returns CIDv1 string in base32 encoding\n *\n * @example\n * ```typescript\n * const cid = await computeCid(new TextEncoder().encode('hello world'));\n * // Returns: \"bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e\"\n * ```\n */\nexport async function computeCid(data: ArrayBuffer | Uint8Array | Blob): Promise<string> {\n // Convert to Uint8Array\n let bytes: Uint8Array;\n\n if (data instanceof Blob) {\n const buffer = await data.arrayBuffer();\n bytes = new Uint8Array(buffer);\n } else if (data instanceof ArrayBuffer) {\n bytes = new Uint8Array(data);\n } else {\n bytes = data;\n }\n\n // Compute SHA-256 hash\n const hash = await sha256.digest(bytes);\n\n // Create CIDv1 with raw codec\n const cid = CID.create(1, raw.code, hash);\n\n // Return base32 encoded string\n return cid.toString();\n}\n\n/**\n * Verify a CID matches the content.\n *\n * @param data - Binary content\n * @param expectedCid - CID to verify against\n * @returns true if CID matches\n */\nexport async function verifyCid(\n data: ArrayBuffer | Uint8Array | Blob,\n expectedCid: string\n): Promise<boolean> {\n const computed = await computeCid(data);\n return computed === expectedCid;\n}\n","/**\n * Platform-specific Scanners\n *\n * Helpers to build UploadTree from different input sources.\n * These are optional utilities - users can also build UploadTree manually.\n */\n\n/// <reference lib=\"dom\" />\n\nimport type { UploadTree, UploadFile, UploadFolder } from './types.js';\n\n/**\n * Detect MIME type from filename.\n * Falls back to 'application/octet-stream' if unknown.\n */\nexport function getMimeType(filename: string): string {\n const ext = filename.toLowerCase().split('.').pop() || '';\n\n const mimeTypes: Record<string, string> = {\n // Images\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n png: 'image/png',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n ico: 'image/x-icon',\n bmp: 'image/bmp',\n tiff: 'image/tiff',\n tif: 'image/tiff',\n\n // Documents\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n odt: 'application/vnd.oasis.opendocument.text',\n ods: 'application/vnd.oasis.opendocument.spreadsheet',\n odp: 'application/vnd.oasis.opendocument.presentation',\n\n // Text\n txt: 'text/plain',\n md: 'text/markdown',\n csv: 'text/csv',\n html: 'text/html',\n htm: 'text/html',\n css: 'text/css',\n xml: 'text/xml',\n rtf: 'application/rtf',\n\n // Code\n js: 'text/javascript',\n mjs: 'text/javascript',\n ts: 'text/typescript',\n jsx: 'text/javascript',\n tsx: 'text/typescript',\n json: 'application/json',\n yaml: 'text/yaml',\n yml: 'text/yaml',\n\n // Archives\n zip: 'application/zip',\n tar: 'application/x-tar',\n gz: 'application/gzip',\n rar: 'application/vnd.rar',\n '7z': 'application/x-7z-compressed',\n\n // Audio\n mp3: 'audio/mpeg',\n wav: 'audio/wav',\n ogg: 'audio/ogg',\n m4a: 'audio/mp4',\n flac: 'audio/flac',\n\n // Video\n mp4: 'video/mp4',\n webm: 'video/webm',\n avi: 'video/x-msvideo',\n mov: 'video/quicktime',\n mkv: 'video/x-matroska',\n\n // Fonts\n woff: 'font/woff',\n woff2: 'font/woff2',\n ttf: 'font/ttf',\n otf: 'font/otf',\n\n // Other\n wasm: 'application/wasm',\n };\n\n return mimeTypes[ext] || 'application/octet-stream';\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Browser Scanners\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Scan browser FileSystemEntry objects (from drag-drop or showDirectoryPicker).\n *\n * **Browser only** - uses FileSystemEntry API.\n *\n * @param entries - FileSystemEntry array from DataTransferItem.webkitGetAsEntry()\n * @returns UploadTree ready for upload\n *\n * @example\n * ```typescript\n * // In a drop handler\n * dropzone.ondrop = async (e) => {\n * const entries = Array.from(e.dataTransfer.items)\n * .map(item => item.webkitGetAsEntry())\n * .filter(Boolean);\n *\n * const tree = await scanFileSystemEntries(entries);\n * const result = await uploadTree(client, tree, { target: { collectionId: '...' } });\n * };\n * ```\n */\nexport async function scanFileSystemEntries(\n entries: FileSystemEntry[],\n options: {\n /** Patterns to ignore */\n ignore?: string[];\n } = {}\n): Promise<UploadTree> {\n const { ignore = ['node_modules', '.git', '.DS_Store'] } = options;\n\n const files: UploadFile[] = [];\n const folders: UploadFolder[] = [];\n\n async function processEntry(entry: FileSystemEntry, parentPath: string): Promise<void> {\n const name = entry.name;\n\n // Skip ignored patterns\n if (ignore.some((pattern) => name === pattern)) {\n return;\n }\n\n const relativePath = parentPath ? `${parentPath}/${name}` : name;\n\n if (entry.isFile) {\n const fileEntry = entry as FileSystemFileEntry;\n\n // Get File object from FileSystemFileEntry\n const file = await new Promise<File>((resolve, reject) => {\n fileEntry.file(resolve, reject);\n });\n\n files.push({\n name,\n relativePath,\n size: file.size,\n mimeType: file.type || getMimeType(name),\n getData: async () => file.arrayBuffer(),\n });\n } else if (entry.isDirectory) {\n const dirEntry = entry as FileSystemDirectoryEntry;\n\n folders.push({\n name,\n relativePath,\n });\n\n // Read directory contents\n const reader = dirEntry.createReader();\n const childEntries = await new Promise<FileSystemEntry[]>((resolve, reject) => {\n const allEntries: FileSystemEntry[] = [];\n\n function readEntries() {\n reader.readEntries((entries) => {\n if (entries.length === 0) {\n resolve(allEntries);\n } else {\n allEntries.push(...entries);\n readEntries(); // Continue reading (readEntries returns max 100 at a time)\n }\n }, reject);\n }\n\n readEntries();\n });\n\n // Process children\n for (const childEntry of childEntries) {\n await processEntry(childEntry, relativePath);\n }\n }\n }\n\n // Process all root entries\n for (const entry of entries) {\n if (entry) {\n await processEntry(entry, '');\n }\n }\n\n // Sort folders by depth\n folders.sort((a, b) => a.relativePath.split('/').length - b.relativePath.split('/').length);\n\n return { files, folders };\n}\n\n/**\n * Build UploadTree from a FileList (from <input type=\"file\"> with webkitdirectory).\n *\n * **Browser only** - uses File API.\n *\n * @param fileList - FileList from input element\n * @returns UploadTree ready for upload\n *\n * @example\n * ```typescript\n * <input type=\"file\" webkitdirectory multiple onChange={async (e) => {\n * const tree = await scanFileList(e.target.files);\n * const result = await uploadTree(client, tree, { target: { collectionId: '...' } });\n * }} />\n * ```\n */\nexport async function scanFileList(\n fileList: FileList,\n options: {\n /** Patterns to ignore */\n ignore?: string[];\n } = {}\n): Promise<UploadTree> {\n const { ignore = ['node_modules', '.git', '.DS_Store'] } = options;\n\n const files: UploadFile[] = [];\n const folderPaths = new Set<string>();\n\n for (let i = 0; i < fileList.length; i++) {\n const file = fileList[i];\n if (!file) continue;\n\n // webkitRelativePath gives us the path including the root folder\n const relativePath = file.webkitRelativePath || file.name;\n const name = file.name;\n\n // Skip ignored patterns (check each path segment)\n const pathSegments = relativePath.split('/');\n if (pathSegments.some((segment: string) => ignore.includes(segment))) {\n continue;\n }\n\n // Extract folder paths\n const pathParts = relativePath.split('/');\n for (let j = 1; j < pathParts.length; j++) {\n const folderPath = pathParts.slice(0, j).join('/');\n folderPaths.add(folderPath);\n }\n\n // Capture file reference for closure\n const fileRef = file;\n files.push({\n name,\n relativePath,\n size: fileRef.size,\n mimeType: fileRef.type || getMimeType(name),\n getData: async () => fileRef.arrayBuffer(),\n });\n }\n\n // Convert folder paths to UploadFolder objects\n const folders: UploadFolder[] = Array.from(folderPaths)\n .map((path) => ({\n name: path.split('/').pop()!,\n relativePath: path,\n }))\n .sort((a, b) => a.relativePath.split('/').length - b.relativePath.split('/').length);\n\n return { files, folders };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Utility: Build tree from flat file list\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Build an UploadTree from a flat array of files with paths.\n *\n * Useful for programmatically constructing uploads without filesystem access.\n *\n * @param items - Array of file items with path, data, and optional metadata\n * @returns UploadTree ready for upload\n *\n * @example\n * ```typescript\n * const tree = buildUploadTree([\n * { path: 'docs/readme.md', data: new Blob(['# Hello']) },\n * { path: 'docs/images/logo.png', data: logoBlob },\n * ]);\n * ```\n */\nexport function buildUploadTree(\n items: Array<{\n /** Relative path (e.g., \"docs/readme.md\") */\n path: string;\n /** File data */\n data: Blob | ArrayBuffer | Uint8Array;\n /** MIME type (auto-detected if not provided) */\n mimeType?: string;\n }>\n): UploadTree {\n const files: UploadFile[] = [];\n const folderPaths = new Set<string>();\n\n for (const item of items) {\n const pathParts = item.path.split('/');\n const name = pathParts.pop()!;\n\n // Extract folder paths\n for (let i = 1; i <= pathParts.length; i++) {\n folderPaths.add(pathParts.slice(0, i).join('/'));\n }\n\n // Determine size\n let size: number;\n if (item.data instanceof Blob) {\n size = item.data.size;\n } else if (item.data instanceof ArrayBuffer) {\n size = item.data.byteLength;\n } else {\n size = item.data.length;\n }\n\n files.push({\n name,\n relativePath: item.path,\n size,\n mimeType: item.mimeType || getMimeType(name),\n getData: async () => item.data,\n });\n }\n\n const folders: UploadFolder[] = Array.from(folderPaths)\n .map((path) => ({\n name: path.split('/').pop()!,\n relativePath: path,\n }))\n .sort((a, b) => a.relativePath.split('/').length - b.relativePath.split('/').length);\n\n return { files, folders };\n}\n","/**\n * Folder Operations (Legacy)\n *\n * @deprecated Use the new upload module instead:\n * ```typescript\n * import { uploadTree, buildUploadTree } from '@arke-institute/sdk/operations';\n *\n * const tree = buildUploadTree([\n * { path: 'docs/readme.md', data: readmeBuffer },\n * { path: 'images/logo.png', data: logoBlob },\n * ]);\n * const result = await uploadTree(client, tree, {\n * target: { collectionId: '...' },\n * });\n * ```\n */\n\nimport type { ArkeClient } from '../client/ArkeClient.js';\n\n/**\n * @deprecated Use UploadProgress from upload module\n */\nexport interface UploadProgress {\n phase: 'scanning' | 'creating-folders' | 'uploading-files' | 'linking' | 'complete';\n totalFiles: number;\n completedFiles: number;\n totalFolders: number;\n completedFolders: number;\n currentFile?: string;\n}\n\n/**\n * @deprecated Use UploadOptions from upload module\n */\nexport interface UploadDirectoryOptions {\n /** Collection to upload into */\n collectionId: string;\n /** Parent folder ID (optional - creates at root if not provided) */\n parentFolderId?: string;\n /** Progress callback */\n onProgress?: (progress: UploadProgress) => void;\n /** Max concurrent uploads */\n concurrency?: number;\n}\n\n/**\n * @deprecated Use UploadResult from upload module\n */\nexport interface UploadDirectoryResult {\n /** Root folder entity */\n rootFolder: unknown;\n /** All created folder entities */\n folders: unknown[];\n /** All created file entities */\n files: unknown[];\n}\n\n/**\n * Folder operations helper\n *\n * @deprecated Use uploadTree and buildUploadTree functions instead:\n * ```typescript\n * import { uploadTree, buildUploadTree } from '@arke-institute/sdk/operations';\n *\n * const tree = buildUploadTree([\n * { path: 'docs/readme.md', data: readmeBuffer },\n * ]);\n * const result = await uploadTree(client, tree, {\n * target: { collectionId: '...' },\n * });\n * ```\n */\nexport class FolderOperations {\n constructor(private client: ArkeClient) {\n void client; // Suppress unused warning\n }\n\n /**\n * Upload a local directory to Arke\n *\n * @deprecated This method has been removed. Use uploadTree and buildUploadTree instead.\n */\n async uploadDirectory(\n _localPath: string,\n _options: UploadDirectoryOptions\n ): Promise<UploadDirectoryResult> {\n throw new Error(\n 'FolderOperations.uploadDirectory has been removed. ' +\n 'Use uploadTree() with buildUploadTree() instead. ' +\n 'See: https://github.com/arke-institute/arke-sdk#upload-module'\n );\n }\n}\n","/**\n * Batch Operations\n *\n * High-level operations for bulk entity and relationship management.\n *\n * TODO: Implement batch operations\n * - createEntities: Create multiple entities in parallel\n * - updateEntities: Update multiple entities in parallel\n * - createRelationships: Create multiple relationships in parallel\n */\n\nimport type { ArkeClient } from '../client/ArkeClient.js';\n\nexport interface BatchCreateOptions {\n /** Max concurrent operations */\n concurrency?: number;\n /** Continue on individual failures */\n continueOnError?: boolean;\n /** Progress callback */\n onProgress?: (completed: number, total: number) => void;\n}\n\nexport interface BatchResult<T> {\n /** Successfully completed operations */\n succeeded: T[];\n /** Failed operations with errors */\n failed: Array<{ input: unknown; error: Error }>;\n}\n\n/**\n * Batch operations helper\n *\n * @example\n * ```typescript\n * const batch = new BatchOperations(arkeClient);\n * const result = await batch.createEntities([\n * { type: 'document', properties: { title: 'Doc 1' } },\n * { type: 'document', properties: { title: 'Doc 2' } },\n * ], { concurrency: 5 });\n * ```\n */\nexport class BatchOperations {\n constructor(private client: ArkeClient) {}\n\n /**\n * Create multiple entities in parallel\n *\n * TODO: Implement this method\n */\n async createEntities(\n _entities: Array<{\n collectionId: string;\n type: string;\n properties?: Record<string, unknown>;\n }>,\n _options?: BatchCreateOptions\n ): Promise<BatchResult<unknown>> {\n throw new Error('BatchOperations.createEntities is not yet implemented');\n }\n\n /**\n * Create multiple relationships in parallel\n *\n * TODO: Implement this method\n */\n async createRelationships(\n _relationships: Array<{\n sourceId: string;\n targetId: string;\n predicate: string;\n bidirectional?: boolean;\n properties?: Record<string, unknown>;\n }>,\n _options?: BatchCreateOptions\n ): Promise<BatchResult<unknown>> {\n throw new Error('BatchOperations.createRelationships is not yet implemented');\n }\n}\n","/**\n * Crypto Operations\n *\n * Cryptographic utilities for agents and content addressing.\n *\n * TODO: Implement crypto operations\n * - generateKeyPair: Generate Ed25519 key pair for agent authentication\n * - signPayload: Sign a payload with agent private key\n * - computeCID: Compute IPFS CID for content\n */\n\n/**\n * Ed25519 key pair for agent authentication\n */\nexport interface KeyPair {\n /** Public key in base64 */\n publicKey: string;\n /** Private key in base64 (keep secret!) */\n privateKey: string;\n}\n\n/**\n * Signed payload with signature\n */\nexport interface SignedPayload {\n /** Original payload */\n payload: string;\n /** Ed25519 signature in base64 */\n signature: string;\n /** Timestamp of signature */\n timestamp: number;\n}\n\n/**\n * Crypto operations helper\n *\n * @example\n * ```typescript\n * // Generate key pair for a new agent\n * const { publicKey, privateKey } = await CryptoOperations.generateKeyPair();\n *\n * // Sign a payload\n * const signed = await CryptoOperations.signPayload(privateKey, payload);\n * ```\n */\nexport class CryptoOperations {\n /**\n * Generate an Ed25519 key pair for agent authentication\n *\n * TODO: Implement using Node.js crypto or Web Crypto API\n */\n static async generateKeyPair(): Promise<KeyPair> {\n throw new Error('CryptoOperations.generateKeyPair is not yet implemented');\n }\n\n /**\n * Sign a payload with an Ed25519 private key\n *\n * TODO: Implement signature generation\n */\n static async signPayload(_privateKey: string, _payload: string): Promise<SignedPayload> {\n throw new Error('CryptoOperations.signPayload is not yet implemented');\n }\n\n /**\n * Verify an Ed25519 signature\n *\n * TODO: Implement signature verification\n */\n static async verifySignature(\n _publicKey: string,\n _payload: string,\n _signature: string\n ): Promise<boolean> {\n throw new Error('CryptoOperations.verifySignature is not yet implemented');\n }\n\n /**\n * Compute IPFS CID for content\n *\n * TODO: Implement using multiformats library\n */\n static async computeCID(_content: Uint8Array): Promise<string> {\n throw new Error('CryptoOperations.computeCID is not yet implemented');\n }\n}\n"],"mappings":";AA6CA,IAAM,cAAc;AACpB,IAAM,cAAsC;AAAA,EAC1C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AACT;AASA,eAAe,cACb,OACA,aACA,IACc;AACd,QAAM,UAAe,CAAC;AACtB,MAAI,QAAQ;AAEZ,iBAAe,SAAwB;AACrC,WAAO,QAAQ,MAAM,QAAQ;AAC3B,YAAM,eAAe;AACrB,YAAM,OAAO,MAAM,YAAY;AAC/B,cAAQ,YAAY,IAAI,MAAM,GAAG,MAAM,YAAY;AAAA,IACrD;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,aAAa,MAAM,MAAM,EAAE,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GAAG,MAAM,EAAE,aAAa,MAAM,GAAG,EAAE,SAAS,EAAE,aAAa,MAAM,GAAG,EAAE,MAAM;AAErF,SAAO,EAAE,OAAO,QAAQ;AAC1B;;;AClRO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAAoB,QAAoB;AAApB;AAClB,SAAK;AAAA,EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,gBACJ,YACA,UACgC;AAChC,UAAM,IAAI;AAAA,MACR;AAAA,IAGF;AAAA,EACF;AACF;;;ACnDO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,QAAoB;AAApB;AAAA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOzC,MAAM,eACJ,WAKA,UAC+B;AAC/B,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,oBACJ,gBAOA,UAC+B;AAC/B,UAAM,IAAI,MAAM,4DAA4D;AAAA,EAC9E;AACF;;;AChCO,IAAM,mBAAN,MAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5B,aAAa,kBAAoC;AAC/C,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,YAAY,aAAqB,UAA0C;AACtF,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,gBACX,YACA,UACA,YACkB;AAClB,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,WAAW,UAAuC;AAC7D,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACF;","names":["entries"]}
1
+ {"version":3,"sources":["../../src/operations/upload/engine.ts","../../src/operations/upload/cid.ts","../../src/operations/upload/scanners.ts","../../src/operations/folders.ts","../../src/operations/batch.ts","../../src/operations/crypto.ts"],"sourcesContent":["/**\n * Upload Engine\n *\n * Core upload implementation optimized for fast tree visibility:\n * 1. Create folders by depth (with unidirectional 'in' → parent)\n * 2. Create file entities (metadata only, high parallelism)\n * 3. Backlink parents with 'contains' relationships\n * → Tree is now browsable! Users can explore structure immediately.\n * 4. Upload file content via POST /files/{id}/content (byte-based pool, ~200MB in flight)\n * - Direct upload to API endpoint\n * - API streams to R2, computes CID, updates entity atomically\n *\n * Byte-based pool (for uploads):\n * - Maintains ~200MB of data in flight at all times\n * - When a file completes, next file starts immediately (no gaps)\n * - Small files: Many upload in parallel\n * - Large files: Fewer upload in parallel (bandwidth-limited)\n * - Single file > 200MB: Uploads alone when pool is empty\n *\n * This minimizes time-to-browse by:\n * - Creating all entities before uploading content\n * - Using unidirectional 'in' relationship on entity creation\n * - Adding all 'contains' relationships in a single PUT per parent\n */\n\nimport type { ArkeClient } from '../../client/ArkeClient.js';\nimport type { components } from '../../generated/types.js';\nimport type {\n UploadTree,\n UploadOptions,\n UploadResult,\n UploadProgress,\n CreatedFolder,\n CreatedFile,\n CreatedEntity,\n UploadFolder,\n} from './types.js';\n\ntype CreateCollectionRequest = components['schemas']['CreateCollectionRequest'];\ntype CreateFolderRequest = components['schemas']['CreateFolderRequest'];\ntype CreateFileRequest = components['schemas']['CreateFileRequest'];\ntype UpdateFolderRequest = components['schemas']['UpdateFolderRequest'];\ntype UpdateCollectionRequest = components['schemas']['UpdateCollectionRequest'];\n\n// Phase constants\nconst PHASE_COUNT = 3; // creating, backlinking, uploading (excluding complete/error)\nconst PHASE_INDEX: Record<string, number> = {\n creating: 0,\n backlinking: 1,\n uploading: 2,\n complete: 3,\n error: -1,\n};\n\n// =============================================================================\n// Concurrency Utilities\n// =============================================================================\n\n/**\n * Simple concurrency limiter for parallel operations.\n */\nasync function parallelLimit<T, R>(\n items: T[],\n concurrency: number,\n fn: (item: T, index: number) => Promise<R>\n): Promise<R[]> {\n const results: R[] = [];\n let index = 0;\n\n async function worker(): Promise<void> {\n while (index < items.length) {\n const currentIndex = index++;\n const item = items[currentIndex]!;\n results[currentIndex] = await fn(item, currentIndex);\n }\n }\n\n const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker());\n await Promise.all(workers);\n\n return results;\n}\n\n// =============================================================================\n// Byte-Based Pool\n// =============================================================================\n\n/** Target bytes in flight (~200MB) */\nconst TARGET_BYTES_IN_FLIGHT = 200 * 1024 * 1024;\n\n/**\n * Pool that maintains a target number of bytes in flight.\n *\n * When a file completes, its bytes are released and the next\n * waiting file can start immediately. This keeps the pipeline full.\n *\n * - Small files: Many run in parallel (up to ~200MB worth)\n * - Large files: Fewer run in parallel\n * - Single file > 200MB: Runs alone (allowed when pool is empty)\n */\nclass BytePool {\n private bytesInFlight = 0;\n private waitQueue: Array<() => void> = [];\n\n constructor(private targetBytes: number = TARGET_BYTES_IN_FLIGHT) {}\n\n async run<T>(size: number, fn: () => Promise<T>): Promise<T> {\n // Wait until we have room\n // Exception: if pool is empty, always allow (handles files > targetBytes)\n while (this.bytesInFlight > 0 && this.bytesInFlight + size > this.targetBytes) {\n await new Promise<void>((resolve) => this.waitQueue.push(resolve));\n }\n\n this.bytesInFlight += size;\n try {\n return await fn();\n } finally {\n this.bytesInFlight -= size;\n // Wake up next waiting task\n const next = this.waitQueue.shift();\n if (next) next();\n }\n }\n}\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\n/**\n * Parse folder path to get parent path.\n * e.g., \"docs/images/photos\" -> \"docs/images\"\n */\nfunction getParentPath(relativePath: string): string | null {\n const lastSlash = relativePath.lastIndexOf('/');\n if (lastSlash === -1) return null;\n return relativePath.slice(0, lastSlash);\n}\n\n/**\n * Group folders by depth level.\n */\nfunction groupFoldersByDepth(folders: UploadFolder[]): Map<number, UploadFolder[]> {\n const byDepth = new Map<number, UploadFolder[]>();\n\n for (const folder of folders) {\n const depth = folder.relativePath.split('/').length - 1;\n if (!byDepth.has(depth)) byDepth.set(depth, []);\n byDepth.get(depth)!.push(folder);\n }\n\n return byDepth;\n}\n\n// =============================================================================\n// Main Upload Function\n// =============================================================================\n\n/**\n * Main upload function.\n * Orchestrates the entire upload process with optimized relationship strategy.\n */\nexport async function uploadTree(\n client: ArkeClient,\n tree: UploadTree,\n options: UploadOptions\n): Promise<UploadResult> {\n const { target, onProgress, concurrency = 10, continueOnError = false, note } = options;\n\n const errors: Array<{ path: string; error: string }> = [];\n const createdFolders: CreatedFolder[] = [];\n const createdFiles: CreatedFile[] = [];\n\n // Maps for tracking (include label for peer_label in relationships)\n const foldersByPath = new Map<string, { id: string; cid: string; label: string }>();\n\n // Calculate totals\n const totalEntities = tree.files.length + tree.folders.length;\n const totalBytes = tree.files.reduce((sum, f) => sum + f.size, 0);\n let completedEntities = 0;\n let bytesUploaded = 0;\n\n // Helper to report progress\n const reportProgress = (progress: Partial<UploadProgress>) => {\n if (onProgress) {\n const phase = progress.phase || 'creating';\n const phaseIndex = PHASE_INDEX[phase] ?? -1;\n\n // Calculate phase percent based on current phase\n let phasePercent = 0;\n if (phase === 'creating') {\n // Creating phase: progress is based on entities created\n const done = progress.completedEntities ?? completedEntities;\n phasePercent = totalEntities > 0 ? Math.round((done / totalEntities) * 100) : 100;\n } else if (phase === 'backlinking') {\n // Backlinking phase: progress is based on parents updated\n const done = progress.completedParents ?? 0;\n const total = progress.totalParents ?? 0;\n phasePercent = total > 0 ? Math.round((done / total) * 100) : 100;\n } else if (phase === 'uploading') {\n // Uploading phase: progress is based on bytes uploaded\n const done = progress.bytesUploaded ?? bytesUploaded;\n phasePercent = totalBytes > 0 ? Math.round((done / totalBytes) * 100) : 100;\n } else if (phase === 'complete') {\n phasePercent = 100;\n }\n\n onProgress({\n phase,\n phaseIndex,\n phaseCount: PHASE_COUNT,\n phasePercent,\n totalEntities,\n completedEntities,\n totalParents: 0,\n completedParents: 0,\n totalBytes,\n bytesUploaded,\n ...progress,\n } as UploadProgress);\n }\n };\n\n try {\n // ─────────────────────────────────────────────────────────────────────────\n // SETUP: Resolve or create collection\n // ─────────────────────────────────────────────────────────────────────────\n let collectionId: string;\n let collectionCid: string;\n let collectionLabel: string;\n let collectionCreated = false;\n\n if (target.createCollection) {\n const collectionBody: CreateCollectionRequest = {\n label: target.createCollection.label,\n description: target.createCollection.description,\n roles: target.createCollection.roles,\n note,\n };\n\n const { data, error } = await client.api.POST('/collections', {\n body: collectionBody,\n });\n\n if (error || !data) {\n throw new Error(`Failed to create collection: ${JSON.stringify(error)}`);\n }\n\n collectionId = data.id;\n collectionCid = data.cid;\n collectionLabel = target.createCollection.label;\n collectionCreated = true;\n } else if (target.collectionId) {\n collectionId = target.collectionId;\n\n const { data, error } = await client.api.GET('/collections/{id}', {\n params: { path: { id: collectionId } },\n });\n\n if (error || !data) {\n throw new Error(`Failed to fetch collection: ${JSON.stringify(error)}`);\n }\n\n collectionCid = data.cid;\n collectionLabel = (data.properties?.label as string) ?? collectionId;\n } else {\n throw new Error('Must provide either collectionId or createCollection in target');\n }\n\n // Determine the parent for root-level items\n const rootParentId = target.parentId ?? collectionId;\n let rootParentLabel = collectionLabel;\n let rootParentType: 'collection' | 'folder' = 'collection';\n\n // If a specific parent folder is provided, fetch its label\n if (target.parentId && target.parentId !== collectionId) {\n const { data: parentData, error: parentError } = await client.api.GET('/folders/{id}', {\n params: { path: { id: target.parentId } },\n });\n if (parentError || !parentData) {\n throw new Error(`Failed to fetch parent folder: ${JSON.stringify(parentError)}`);\n }\n rootParentLabel = (parentData.properties?.label as string) ?? target.parentId;\n rootParentType = 'folder';\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // PHASE 1: Create entities (folders by depth, then files)\n // ─────────────────────────────────────────────────────────────────────────\n reportProgress({ phase: 'creating', completedEntities: 0 });\n\n // Group folders by depth\n const foldersByDepth = groupFoldersByDepth(tree.folders);\n const sortedDepths = [...foldersByDepth.keys()].sort((a, b) => a - b);\n\n // Create folders depth by depth (parents before children)\n for (const depth of sortedDepths) {\n const foldersAtDepth = foldersByDepth.get(depth)!;\n\n await Promise.all(\n foldersAtDepth.map(async (folder) => {\n try {\n const parentPath = getParentPath(folder.relativePath);\n const parentInfo = parentPath ? foldersByPath.get(parentPath)! : null;\n const parentId = parentInfo ? parentInfo.id : rootParentId;\n const parentType = parentInfo ? 'folder' : rootParentType;\n const parentLabel = parentInfo ? parentInfo.label : rootParentLabel;\n\n const folderBody: CreateFolderRequest = {\n label: folder.name,\n collection: collectionId,\n note,\n relationships: [{ predicate: 'in', peer: parentId, peer_type: parentType, peer_label: parentLabel }],\n };\n\n const { data, error } = await client.api.POST('/folders', {\n body: folderBody,\n });\n\n if (error || !data) {\n throw new Error(JSON.stringify(error));\n }\n\n // Track folder (include label for peer_label in child relationships)\n foldersByPath.set(folder.relativePath, { id: data.id, cid: data.cid, label: folder.name });\n createdFolders.push({\n name: folder.name,\n relativePath: folder.relativePath,\n id: data.id,\n entityCid: data.cid,\n });\n\n completedEntities++;\n reportProgress({\n phase: 'creating',\n completedEntities,\n currentItem: folder.relativePath,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: folder.relativePath, error: `Folder creation failed: ${errorMsg}` });\n completedEntities++;\n } else {\n throw new Error(`Failed to create folder ${folder.relativePath}: ${errorMsg}`);\n }\n }\n })\n );\n }\n\n // Create file entities (metadata only, no content upload yet)\n // Use simple concurrency limit for API calls\n const FILE_CREATION_CONCURRENCY = 50;\n\n await parallelLimit(tree.files, FILE_CREATION_CONCURRENCY, async (file) => {\n try {\n const parentPath = getParentPath(file.relativePath);\n const parentInfo = parentPath ? foldersByPath.get(parentPath)! : null;\n const parentId = parentInfo ? parentInfo.id : rootParentId;\n const parentType = parentInfo ? 'folder' : rootParentType;\n const parentLabel = parentInfo ? parentInfo.label : rootParentLabel;\n\n // Create file entity with 'in' relationship (include peer_label for display)\n // Server computes CID when content is uploaded\n const fileBody: CreateFileRequest = {\n key: crypto.randomUUID(), // Generate unique storage key\n filename: file.name,\n label: file.name, // Display label for the file\n content_type: file.mimeType,\n size: file.size,\n collection: collectionId,\n relationships: [{ predicate: 'in', peer: parentId, peer_type: parentType, peer_label: parentLabel }],\n };\n\n const { data, error } = await client.api.POST('/files', {\n body: fileBody,\n });\n\n if (error || !data) {\n throw new Error(`Entity creation failed: ${JSON.stringify(error)}`);\n }\n\n // Track file for later upload\n createdFiles.push({\n ...file,\n id: data.id,\n entityCid: data.cid,\n });\n\n completedEntities++;\n reportProgress({\n phase: 'creating',\n completedEntities,\n currentItem: file.relativePath,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: file.relativePath, error: errorMsg });\n completedEntities++;\n } else {\n throw new Error(`Failed to create file ${file.relativePath}: ${errorMsg}`);\n }\n }\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // PHASE 2: Backlink - Update each parent with 'contains' relationships\n // ─────────────────────────────────────────────────────────────────────────\n\n // Build parent -> children map (include label for peer_label)\n const childrenByParent = new Map<string, Array<{ id: string; type: 'file' | 'folder'; label: string }>>();\n\n // Add folders as children of their parents\n for (const folder of createdFolders) {\n const parentPath = getParentPath(folder.relativePath);\n const parentId = parentPath ? foldersByPath.get(parentPath)!.id : rootParentId;\n\n if (!childrenByParent.has(parentId)) childrenByParent.set(parentId, []);\n childrenByParent.get(parentId)!.push({ id: folder.id, type: 'folder', label: folder.name });\n }\n\n // Add files as children of their parents\n for (const file of createdFiles) {\n const parentPath = getParentPath(file.relativePath);\n const parentId = parentPath ? foldersByPath.get(parentPath)!.id : rootParentId;\n\n if (!childrenByParent.has(parentId)) childrenByParent.set(parentId, []);\n childrenByParent.get(parentId)!.push({ id: file.id, type: 'file', label: file.name });\n }\n\n const totalParents = childrenByParent.size;\n let completedParents = 0;\n\n reportProgress({ phase: 'backlinking', totalParents, completedParents: 0 });\n\n // Update all parents in parallel - each parent gets one PUT with all its children\n const parentEntries = [...childrenByParent.entries()];\n\n await parallelLimit(parentEntries, concurrency, async ([parentId, children]) => {\n try {\n const isCollection = parentId === collectionId;\n\n // Build relationships_add array with all children (include peer_label for display)\n const relationshipsAdd = children.map((child) => ({\n predicate: 'contains' as const,\n peer: child.id,\n peer_type: child.type,\n peer_label: child.label,\n }));\n\n if (isCollection) {\n // Get current collection CID for CAS\n const { data: collData, error: getError } = await client.api.GET('/collections/{id}', {\n params: { path: { id: parentId } },\n });\n if (getError || !collData) {\n throw new Error(`Failed to fetch collection: ${JSON.stringify(getError)}`);\n }\n\n // Update collection with relationships_add\n const updateBody: UpdateCollectionRequest = {\n expect_tip: collData.cid,\n relationships_add: relationshipsAdd,\n note: note ? `${note} (backlink)` : 'Upload backlink',\n };\n\n const { error } = await client.api.PUT('/collections/{id}', {\n params: { path: { id: parentId } },\n body: updateBody,\n });\n\n if (error) {\n throw new Error(JSON.stringify(error));\n }\n } else {\n // Get current folder CID for CAS\n const { data: folderData, error: getError } = await client.api.GET('/folders/{id}', {\n params: { path: { id: parentId } },\n });\n if (getError || !folderData) {\n throw new Error(`Failed to fetch folder: ${JSON.stringify(getError)}`);\n }\n\n // Update folder with relationships_add\n const updateBody: UpdateFolderRequest = {\n expect_tip: folderData.cid,\n relationships_add: relationshipsAdd,\n note: note ? `${note} (backlink)` : 'Upload backlink',\n };\n\n const { error } = await client.api.PUT('/folders/{id}', {\n params: { path: { id: parentId } },\n body: updateBody,\n });\n\n if (error) {\n throw new Error(JSON.stringify(error));\n }\n }\n\n completedParents++;\n reportProgress({\n phase: 'backlinking',\n totalParents,\n completedParents,\n currentItem: `parent:${parentId}`,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: `parent:${parentId}`, error: `Backlink failed: ${errorMsg}` });\n completedParents++;\n } else {\n throw new Error(`Failed to backlink parent ${parentId}: ${errorMsg}`);\n }\n }\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // PHASE 3: Upload file content directly to API\n // Tree is now browsable! Users can explore while content uploads.\n // ─────────────────────────────────────────────────────────────────────────\n reportProgress({ phase: 'uploading', bytesUploaded: 0 });\n\n // Use byte-based pool to maintain ~200MB in flight\n const pool = new BytePool();\n\n await Promise.all(\n createdFiles.map(async (file) => {\n await pool.run(file.size, async () => {\n try {\n // Get file data\n const fileData = await file.getData();\n\n let body: Blob;\n if (fileData instanceof Blob) {\n body = fileData;\n } else if (fileData instanceof Uint8Array) {\n const arrayBuffer = new ArrayBuffer(fileData.byteLength);\n new Uint8Array(arrayBuffer).set(fileData);\n body = new Blob([arrayBuffer], { type: file.mimeType });\n } else {\n body = new Blob([fileData], { type: file.mimeType });\n }\n\n // Upload content directly to API endpoint\n // The API streams to R2, computes CID, and updates the entity atomically\n const { error: uploadError } = await client.api.POST('/files/{id}/content', {\n params: { path: { id: file.id } },\n body: body as unknown as Record<string, never>,\n bodySerializer: (b: unknown) => b as BodyInit,\n headers: { 'Content-Type': file.mimeType },\n } as Parameters<typeof client.api.POST>[1]);\n\n if (uploadError) {\n throw new Error(`Upload failed: ${JSON.stringify(uploadError)}`);\n }\n\n bytesUploaded += file.size;\n reportProgress({\n phase: 'uploading',\n bytesUploaded,\n currentItem: file.relativePath,\n });\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n if (continueOnError) {\n errors.push({ path: file.relativePath, error: `Upload failed: ${errorMsg}` });\n } else {\n throw new Error(`Failed to upload ${file.relativePath}: ${errorMsg}`);\n }\n }\n });\n })\n );\n\n // ─────────────────────────────────────────────────────────────────────────\n // Complete!\n // ─────────────────────────────────────────────────────────────────────────\n reportProgress({ phase: 'complete', totalParents, completedParents, bytesUploaded });\n\n const resultFolders: CreatedEntity[] = createdFolders.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'folder' as const,\n relativePath: f.relativePath,\n }));\n\n const resultFiles: CreatedEntity[] = createdFiles.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'file' as const,\n relativePath: f.relativePath,\n }));\n\n return {\n success: errors.length === 0,\n collection: {\n id: collectionId,\n cid: collectionCid,\n created: collectionCreated,\n },\n folders: resultFolders,\n files: resultFiles,\n errors,\n };\n } catch (err) {\n const errorMsg = err instanceof Error ? err.message : String(err);\n\n reportProgress({\n phase: 'error',\n error: errorMsg,\n });\n\n return {\n success: false,\n collection: {\n id: target.collectionId ?? '',\n cid: '',\n created: false,\n },\n folders: createdFolders.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'folder' as const,\n relativePath: f.relativePath,\n })),\n files: createdFiles.map((f) => ({\n id: f.id,\n cid: f.entityCid,\n type: 'file' as const,\n relativePath: f.relativePath,\n })),\n errors: [...errors, { path: '', error: errorMsg }],\n };\n }\n}\n","/**\n * CID Computation Utility\n *\n * Computes IPFS CIDv1 (base32) for file content.\n * Uses raw codec (0x55) and SHA-256 hash.\n *\n * Note: This module is not used internally by the upload engine (the server\n * computes CIDs from uploaded content). It is exported for convenience in case\n * you want to verify entity CIDs, detect duplicates before upload, or perform\n * other content-addressed operations.\n */\n\nimport { CID } from 'multiformats/cid';\nimport { sha256 } from 'multiformats/hashes/sha2';\nimport * as raw from 'multiformats/codecs/raw';\n\n/**\n * Compute CIDv1 for binary content.\n * Returns base32 encoded string (bafk... prefix for raw codec).\n *\n * @param data - Binary content as ArrayBuffer, Uint8Array, or Blob\n * @returns CIDv1 string in base32 encoding\n *\n * @example\n * ```typescript\n * const cid = await computeCid(new TextEncoder().encode('hello world'));\n * // Returns: \"bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e\"\n * ```\n */\nexport async function computeCid(data: ArrayBuffer | Uint8Array | Blob): Promise<string> {\n // Convert to Uint8Array\n let bytes: Uint8Array;\n\n if (data instanceof Blob) {\n const buffer = await data.arrayBuffer();\n bytes = new Uint8Array(buffer);\n } else if (data instanceof ArrayBuffer) {\n bytes = new Uint8Array(data);\n } else {\n bytes = data;\n }\n\n // Compute SHA-256 hash\n const hash = await sha256.digest(bytes);\n\n // Create CIDv1 with raw codec\n const cid = CID.create(1, raw.code, hash);\n\n // Return base32 encoded string\n return cid.toString();\n}\n\n/**\n * Verify a CID matches the content.\n *\n * @param data - Binary content\n * @param expectedCid - CID to verify against\n * @returns true if CID matches\n */\nexport async function verifyCid(\n data: ArrayBuffer | Uint8Array | Blob,\n expectedCid: string\n): Promise<boolean> {\n const computed = await computeCid(data);\n return computed === expectedCid;\n}\n","/**\n * Platform-specific Scanners\n *\n * Helpers to build UploadTree from different input sources.\n * These are optional utilities - users can also build UploadTree manually.\n */\n\n/// <reference lib=\"dom\" />\n\nimport type { UploadTree, UploadFile, UploadFolder } from './types.js';\n\n/**\n * Detect MIME type from filename.\n * Falls back to 'application/octet-stream' if unknown.\n */\nexport function getMimeType(filename: string): string {\n const ext = filename.toLowerCase().split('.').pop() || '';\n\n const mimeTypes: Record<string, string> = {\n // Images\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n png: 'image/png',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n ico: 'image/x-icon',\n bmp: 'image/bmp',\n tiff: 'image/tiff',\n tif: 'image/tiff',\n\n // Documents\n pdf: 'application/pdf',\n doc: 'application/msword',\n docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n xls: 'application/vnd.ms-excel',\n xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ppt: 'application/vnd.ms-powerpoint',\n pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n odt: 'application/vnd.oasis.opendocument.text',\n ods: 'application/vnd.oasis.opendocument.spreadsheet',\n odp: 'application/vnd.oasis.opendocument.presentation',\n\n // Text\n txt: 'text/plain',\n md: 'text/markdown',\n csv: 'text/csv',\n html: 'text/html',\n htm: 'text/html',\n css: 'text/css',\n xml: 'text/xml',\n rtf: 'application/rtf',\n\n // Code\n js: 'text/javascript',\n mjs: 'text/javascript',\n ts: 'text/typescript',\n jsx: 'text/javascript',\n tsx: 'text/typescript',\n json: 'application/json',\n yaml: 'text/yaml',\n yml: 'text/yaml',\n\n // Archives\n zip: 'application/zip',\n tar: 'application/x-tar',\n gz: 'application/gzip',\n rar: 'application/vnd.rar',\n '7z': 'application/x-7z-compressed',\n\n // Audio\n mp3: 'audio/mpeg',\n wav: 'audio/wav',\n ogg: 'audio/ogg',\n m4a: 'audio/mp4',\n flac: 'audio/flac',\n\n // Video\n mp4: 'video/mp4',\n webm: 'video/webm',\n avi: 'video/x-msvideo',\n mov: 'video/quicktime',\n mkv: 'video/x-matroska',\n\n // Fonts\n woff: 'font/woff',\n woff2: 'font/woff2',\n ttf: 'font/ttf',\n otf: 'font/otf',\n\n // Other\n wasm: 'application/wasm',\n };\n\n return mimeTypes[ext] || 'application/octet-stream';\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Browser Scanners\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Scan browser FileSystemEntry objects (from drag-drop or showDirectoryPicker).\n *\n * **Browser only** - uses FileSystemEntry API.\n *\n * @param entries - FileSystemEntry array from DataTransferItem.webkitGetAsEntry()\n * @returns UploadTree ready for upload\n *\n * @example\n * ```typescript\n * // In a drop handler\n * dropzone.ondrop = async (e) => {\n * const entries = Array.from(e.dataTransfer.items)\n * .map(item => item.webkitGetAsEntry())\n * .filter(Boolean);\n *\n * const tree = await scanFileSystemEntries(entries);\n * const result = await uploadTree(client, tree, { target: { collectionId: '...' } });\n * };\n * ```\n */\nexport async function scanFileSystemEntries(\n entries: FileSystemEntry[],\n options: {\n /** Patterns to ignore */\n ignore?: string[];\n } = {}\n): Promise<UploadTree> {\n const { ignore = ['node_modules', '.git', '.DS_Store'] } = options;\n\n const files: UploadFile[] = [];\n const folders: UploadFolder[] = [];\n\n async function processEntry(entry: FileSystemEntry, parentPath: string): Promise<void> {\n const name = entry.name;\n\n // Skip ignored patterns\n if (ignore.some((pattern) => name === pattern)) {\n return;\n }\n\n const relativePath = parentPath ? `${parentPath}/${name}` : name;\n\n if (entry.isFile) {\n const fileEntry = entry as FileSystemFileEntry;\n\n // Get File object from FileSystemFileEntry\n const file = await new Promise<File>((resolve, reject) => {\n fileEntry.file(resolve, reject);\n });\n\n files.push({\n name,\n relativePath,\n size: file.size,\n mimeType: file.type || getMimeType(name),\n getData: async () => file.arrayBuffer(),\n });\n } else if (entry.isDirectory) {\n const dirEntry = entry as FileSystemDirectoryEntry;\n\n folders.push({\n name,\n relativePath,\n });\n\n // Read directory contents\n const reader = dirEntry.createReader();\n const childEntries = await new Promise<FileSystemEntry[]>((resolve, reject) => {\n const allEntries: FileSystemEntry[] = [];\n\n function readEntries() {\n reader.readEntries((entries) => {\n if (entries.length === 0) {\n resolve(allEntries);\n } else {\n allEntries.push(...entries);\n readEntries(); // Continue reading (readEntries returns max 100 at a time)\n }\n }, reject);\n }\n\n readEntries();\n });\n\n // Process children\n for (const childEntry of childEntries) {\n await processEntry(childEntry, relativePath);\n }\n }\n }\n\n // Process all root entries\n for (const entry of entries) {\n if (entry) {\n await processEntry(entry, '');\n }\n }\n\n // Sort folders by depth\n folders.sort((a, b) => a.relativePath.split('/').length - b.relativePath.split('/').length);\n\n return { files, folders };\n}\n\n/**\n * Build UploadTree from a FileList (from <input type=\"file\"> with webkitdirectory).\n *\n * **Browser only** - uses File API.\n *\n * @param fileList - FileList from input element\n * @returns UploadTree ready for upload\n *\n * @example\n * ```typescript\n * <input type=\"file\" webkitdirectory multiple onChange={async (e) => {\n * const tree = await scanFileList(e.target.files);\n * const result = await uploadTree(client, tree, { target: { collectionId: '...' } });\n * }} />\n * ```\n */\nexport async function scanFileList(\n fileList: FileList,\n options: {\n /** Patterns to ignore */\n ignore?: string[];\n } = {}\n): Promise<UploadTree> {\n const { ignore = ['node_modules', '.git', '.DS_Store'] } = options;\n\n const files: UploadFile[] = [];\n const folderPaths = new Set<string>();\n\n for (let i = 0; i < fileList.length; i++) {\n const file = fileList[i];\n if (!file) continue;\n\n // webkitRelativePath gives us the path including the root folder\n const relativePath = file.webkitRelativePath || file.name;\n const name = file.name;\n\n // Skip ignored patterns (check each path segment)\n const pathSegments = relativePath.split('/');\n if (pathSegments.some((segment: string) => ignore.includes(segment))) {\n continue;\n }\n\n // Extract folder paths\n const pathParts = relativePath.split('/');\n for (let j = 1; j < pathParts.length; j++) {\n const folderPath = pathParts.slice(0, j).join('/');\n folderPaths.add(folderPath);\n }\n\n // Capture file reference for closure\n const fileRef = file;\n files.push({\n name,\n relativePath,\n size: fileRef.size,\n mimeType: fileRef.type || getMimeType(name),\n getData: async () => fileRef.arrayBuffer(),\n });\n }\n\n // Convert folder paths to UploadFolder objects\n const folders: UploadFolder[] = Array.from(folderPaths)\n .map((path) => ({\n name: path.split('/').pop()!,\n relativePath: path,\n }))\n .sort((a, b) => a.relativePath.split('/').length - b.relativePath.split('/').length);\n\n return { files, folders };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Utility: Build tree from flat file list\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Build an UploadTree from a flat array of files with paths.\n *\n * Useful for programmatically constructing uploads without filesystem access.\n *\n * @param items - Array of file items with path, data, and optional metadata\n * @returns UploadTree ready for upload\n *\n * @example\n * ```typescript\n * const tree = buildUploadTree([\n * { path: 'docs/readme.md', data: new Blob(['# Hello']) },\n * { path: 'docs/images/logo.png', data: logoBlob },\n * ]);\n * ```\n */\nexport function buildUploadTree(\n items: Array<{\n /** Relative path (e.g., \"docs/readme.md\") */\n path: string;\n /** File data */\n data: Blob | ArrayBuffer | Uint8Array;\n /** MIME type (auto-detected if not provided) */\n mimeType?: string;\n }>\n): UploadTree {\n const files: UploadFile[] = [];\n const folderPaths = new Set<string>();\n\n for (const item of items) {\n const pathParts = item.path.split('/');\n const name = pathParts.pop()!;\n\n // Extract folder paths\n for (let i = 1; i <= pathParts.length; i++) {\n folderPaths.add(pathParts.slice(0, i).join('/'));\n }\n\n // Determine size\n let size: number;\n if (item.data instanceof Blob) {\n size = item.data.size;\n } else if (item.data instanceof ArrayBuffer) {\n size = item.data.byteLength;\n } else {\n size = item.data.length;\n }\n\n files.push({\n name,\n relativePath: item.path,\n size,\n mimeType: item.mimeType || getMimeType(name),\n getData: async () => item.data,\n });\n }\n\n const folders: UploadFolder[] = Array.from(folderPaths)\n .map((path) => ({\n name: path.split('/').pop()!,\n relativePath: path,\n }))\n .sort((a, b) => a.relativePath.split('/').length - b.relativePath.split('/').length);\n\n return { files, folders };\n}\n","/**\n * Folder Operations (Legacy)\n *\n * @deprecated Use the new upload module instead:\n * ```typescript\n * import { uploadTree, buildUploadTree } from '@arke-institute/sdk/operations';\n *\n * const tree = buildUploadTree([\n * { path: 'docs/readme.md', data: readmeBuffer },\n * { path: 'images/logo.png', data: logoBlob },\n * ]);\n * const result = await uploadTree(client, tree, {\n * target: { collectionId: '...' },\n * });\n * ```\n */\n\nimport type { ArkeClient } from '../client/ArkeClient.js';\n\n/**\n * @deprecated Use UploadProgress from upload module\n */\nexport interface UploadProgress {\n phase: 'scanning' | 'creating-folders' | 'uploading-files' | 'linking' | 'complete';\n totalFiles: number;\n completedFiles: number;\n totalFolders: number;\n completedFolders: number;\n currentFile?: string;\n}\n\n/**\n * @deprecated Use UploadOptions from upload module\n */\nexport interface UploadDirectoryOptions {\n /** Collection to upload into */\n collectionId: string;\n /** Parent folder ID (optional - creates at root if not provided) */\n parentFolderId?: string;\n /** Progress callback */\n onProgress?: (progress: UploadProgress) => void;\n /** Max concurrent uploads */\n concurrency?: number;\n}\n\n/**\n * @deprecated Use UploadResult from upload module\n */\nexport interface UploadDirectoryResult {\n /** Root folder entity */\n rootFolder: unknown;\n /** All created folder entities */\n folders: unknown[];\n /** All created file entities */\n files: unknown[];\n}\n\n/**\n * Folder operations helper\n *\n * @deprecated Use uploadTree and buildUploadTree functions instead:\n * ```typescript\n * import { uploadTree, buildUploadTree } from '@arke-institute/sdk/operations';\n *\n * const tree = buildUploadTree([\n * { path: 'docs/readme.md', data: readmeBuffer },\n * ]);\n * const result = await uploadTree(client, tree, {\n * target: { collectionId: '...' },\n * });\n * ```\n */\nexport class FolderOperations {\n constructor(private client: ArkeClient) {\n void client; // Suppress unused warning\n }\n\n /**\n * Upload a local directory to Arke\n *\n * @deprecated This method has been removed. Use uploadTree and buildUploadTree instead.\n */\n async uploadDirectory(\n _localPath: string,\n _options: UploadDirectoryOptions\n ): Promise<UploadDirectoryResult> {\n throw new Error(\n 'FolderOperations.uploadDirectory has been removed. ' +\n 'Use uploadTree() with buildUploadTree() instead. ' +\n 'See: https://github.com/arke-institute/arke-sdk#upload-module'\n );\n }\n}\n","/**\n * Batch Operations\n *\n * High-level operations for bulk entity and relationship management.\n *\n * TODO: Implement batch operations\n * - createEntities: Create multiple entities in parallel\n * - updateEntities: Update multiple entities in parallel\n * - createRelationships: Create multiple relationships in parallel\n */\n\nimport type { ArkeClient } from '../client/ArkeClient.js';\n\nexport interface BatchCreateOptions {\n /** Max concurrent operations */\n concurrency?: number;\n /** Continue on individual failures */\n continueOnError?: boolean;\n /** Progress callback */\n onProgress?: (completed: number, total: number) => void;\n}\n\nexport interface BatchResult<T> {\n /** Successfully completed operations */\n succeeded: T[];\n /** Failed operations with errors */\n failed: Array<{ input: unknown; error: Error }>;\n}\n\n/**\n * Batch operations helper\n *\n * @example\n * ```typescript\n * const batch = new BatchOperations(arkeClient);\n * const result = await batch.createEntities([\n * { type: 'document', properties: { title: 'Doc 1' } },\n * { type: 'document', properties: { title: 'Doc 2' } },\n * ], { concurrency: 5 });\n * ```\n */\nexport class BatchOperations {\n constructor(private client: ArkeClient) {}\n\n /**\n * Create multiple entities in parallel\n *\n * TODO: Implement this method\n */\n async createEntities(\n _entities: Array<{\n collectionId: string;\n type: string;\n properties?: Record<string, unknown>;\n }>,\n _options?: BatchCreateOptions\n ): Promise<BatchResult<unknown>> {\n throw new Error('BatchOperations.createEntities is not yet implemented');\n }\n\n /**\n * Create multiple relationships in parallel\n *\n * TODO: Implement this method\n */\n async createRelationships(\n _relationships: Array<{\n sourceId: string;\n targetId: string;\n predicate: string;\n bidirectional?: boolean;\n properties?: Record<string, unknown>;\n }>,\n _options?: BatchCreateOptions\n ): Promise<BatchResult<unknown>> {\n throw new Error('BatchOperations.createRelationships is not yet implemented');\n }\n}\n","/**\n * Crypto Operations\n *\n * Cryptographic utilities for agents and content addressing.\n *\n * TODO: Implement crypto operations\n * - generateKeyPair: Generate Ed25519 key pair for agent authentication\n * - signPayload: Sign a payload with agent private key\n * - computeCID: Compute IPFS CID for content\n */\n\n/**\n * Ed25519 key pair for agent authentication\n */\nexport interface KeyPair {\n /** Public key in base64 */\n publicKey: string;\n /** Private key in base64 (keep secret!) */\n privateKey: string;\n}\n\n/**\n * Signed payload with signature\n */\nexport interface SignedPayload {\n /** Original payload */\n payload: string;\n /** Ed25519 signature in base64 */\n signature: string;\n /** Timestamp of signature */\n timestamp: number;\n}\n\n/**\n * Crypto operations helper\n *\n * @example\n * ```typescript\n * // Generate key pair for a new agent\n * const { publicKey, privateKey } = await CryptoOperations.generateKeyPair();\n *\n * // Sign a payload\n * const signed = await CryptoOperations.signPayload(privateKey, payload);\n * ```\n */\nexport class CryptoOperations {\n /**\n * Generate an Ed25519 key pair for agent authentication\n *\n * TODO: Implement using Node.js crypto or Web Crypto API\n */\n static async generateKeyPair(): Promise<KeyPair> {\n throw new Error('CryptoOperations.generateKeyPair is not yet implemented');\n }\n\n /**\n * Sign a payload with an Ed25519 private key\n *\n * TODO: Implement signature generation\n */\n static async signPayload(_privateKey: string, _payload: string): Promise<SignedPayload> {\n throw new Error('CryptoOperations.signPayload is not yet implemented');\n }\n\n /**\n * Verify an Ed25519 signature\n *\n * TODO: Implement signature verification\n */\n static async verifySignature(\n _publicKey: string,\n _payload: string,\n _signature: string\n ): Promise<boolean> {\n throw new Error('CryptoOperations.verifySignature is not yet implemented');\n }\n\n /**\n * Compute IPFS CID for content\n *\n * TODO: Implement using multiformats library\n */\n static async computeCID(_content: Uint8Array): Promise<string> {\n throw new Error('CryptoOperations.computeCID is not yet implemented');\n }\n}\n"],"mappings":";AA6CA,IAAM,cAAc;AACpB,IAAM,cAAsC;AAAA,EAC1C,UAAU;AAAA,EAC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