hazo_files 1.4.3 → 1.4.4

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.
package/README.md CHANGED
@@ -7,7 +7,7 @@ A powerful, modular file management package for Node.js and React applications w
7
7
 
8
8
  ## Features
9
9
 
10
- - **Multiple Storage Providers**: Local filesystem and Google Drive support out of the box
10
+ - **Multiple Storage Providers**: Local filesystem, Google Drive, and Dropbox support out of the box
11
11
  - **Modular Architecture**: Easily add custom storage providers
12
12
  - **Unified API**: Single consistent interface across all storage providers
13
13
  - **React UI Components**: Drop-in FileBrowser component with folder tree, file list, and preview
@@ -21,7 +21,8 @@ A powerful, modular file management package for Node.js and React applications w
21
21
  - **Content Tagging**: Optional LLM-based content classification at upload time or on-demand via `content_tag` field
22
22
  - **Schema Migrations**: Built-in V2/V3 migration utilities for adding reference tracking and content tagging to existing databases
23
23
  - **TypeScript**: Full type safety and IntelliSense support
24
- - **OAuth Integration**: Built-in Google Drive OAuth authentication
24
+ - **OAuth Integration**: Built-in Google Drive and Dropbox OAuth authentication
25
+ - **Prompt Cache Invalidation**: Passthrough for hazo_llm_api prompt cache management via server instance
25
26
  - **Progress Tracking**: Upload/download progress callbacks
26
27
  - **File Validation**: Extension filtering and file size limits
27
28
  - **Error Handling**: Comprehensive error types and handling
@@ -1173,7 +1174,10 @@ const folderResult = await uploadExtract.createFolderFromConvention(
1173
1174
  ```typescript
1174
1175
  import { LLMExtractionService } from 'hazo_files';
1175
1176
 
1176
- const extractionService = new LLMExtractionService(llmFactory, 'gemini');
1177
+ const extractionService = new LLMExtractionService({
1178
+ create: llmFactory,
1179
+ invalidateCache: (area, key) => invalidate_prompt_cache(area, key), // optional
1180
+ }, 'gemini');
1177
1181
 
1178
1182
  // Extract from document
1179
1183
  const result = await extractionService.extractFromDocument(
@@ -1409,7 +1413,10 @@ const hazoFiles = await createHazoFilesServer({
1409
1413
  local: { basePath: './storage' },
1410
1414
  },
1411
1415
  enableTracking: true,
1412
- llmFactory: (provider) => createLLM({ provider }),
1416
+ llmFactory: {
1417
+ create: (provider) => createLLM({ provider }),
1418
+ invalidateCache: (area, key) => invalidate_prompt_cache(area, key), // optional
1419
+ },
1413
1420
  // Optional: enable automatic content tagging for all uploads
1414
1421
  defaultContentTagConfig: {
1415
1422
  content_tag_set_by_llm: true,
@@ -1420,7 +1427,10 @@ const hazoFiles = await createHazoFilesServer({
1420
1427
  });
1421
1428
 
1422
1429
  // Access all services
1423
- const { fileManager, metadataService, namingService, extractionService, uploadExtractService } = hazoFiles;
1430
+ const { fileManager, metadataService, namingService, extractionService, uploadExtractService, invalidatePromptCache } = hazoFiles;
1431
+
1432
+ // Invalidate prompt cache without importing hazo_llm_api directly
1433
+ invalidatePromptCache?.('classification', 'classify_document');
1424
1434
  ```
1425
1435
 
1426
1436
  ## API Reference
package/dist/index.d.mts CHANGED
@@ -514,7 +514,7 @@ interface UploadWithRefOptions {
514
514
  * Core types for the hazo_files package
515
515
  */
516
516
  /** Supported storage provider types */
517
- type StorageProvider = 'local' | 'google_drive';
517
+ type StorageProvider = 'local' | 'google_drive' | 'dropbox';
518
518
  /** File item representing a file in storage */
519
519
  interface FileItem {
520
520
  id: string;
@@ -542,11 +542,21 @@ interface FolderItem {
542
542
  }
543
543
  /** Union type for file system items */
544
544
  type FileSystemItem = FileItem | FolderItem;
545
+ /** Dropbox specific configuration */
546
+ interface DropboxConfig {
547
+ clientId: string;
548
+ clientSecret: string;
549
+ redirectUri: string;
550
+ refreshToken?: string;
551
+ accessToken?: string;
552
+ rootPath?: string;
553
+ }
545
554
  /** Configuration for the file manager */
546
555
  interface HazoFilesConfig {
547
556
  provider: StorageProvider;
548
557
  local?: LocalStorageConfig;
549
558
  google_drive?: GoogleDriveConfig;
559
+ dropbox?: DropboxConfig;
550
560
  }
551
561
  /** Local storage specific configuration */
552
562
  interface LocalStorageConfig {
@@ -1429,6 +1439,13 @@ interface HazoLLMInstance {
1429
1439
  * Factory function type for creating LLM instances
1430
1440
  */
1431
1441
  type LLMFactory = (provider: LLMProvider, options?: Record<string, unknown>) => HazoLLMInstance | Promise<HazoLLMInstance>;
1442
+ /**
1443
+ * Extended LLM factory configuration with optional cache management
1444
+ */
1445
+ interface LLMFactoryConfig {
1446
+ create: LLMFactory;
1447
+ invalidateCache?: (area?: string, key?: string) => void;
1448
+ }
1432
1449
  /**
1433
1450
  * LLM Extraction Service
1434
1451
  *
@@ -1470,7 +1487,13 @@ type LLMFactory = (provider: LLMProvider, options?: Record<string, unknown>) =>
1470
1487
  declare class LLMExtractionService {
1471
1488
  private llmFactory;
1472
1489
  private defaultProvider;
1473
- constructor(llmFactory: LLMFactory, defaultProvider?: LLMProvider);
1490
+ private cacheInvalidator?;
1491
+ constructor(factoryConfig: LLMFactoryConfig, defaultProvider?: LLMProvider);
1492
+ /**
1493
+ * Invalidate the LLM prompt cache
1494
+ * Passthrough to hazo_llm_api's invalidate_prompt_cache when configured
1495
+ */
1496
+ invalidatePromptCache(area?: string, key?: string): void;
1474
1497
  /**
1475
1498
  * Extract data from a document
1476
1499
  *
@@ -1502,10 +1525,10 @@ declare class LLMExtractionService {
1502
1525
  /**
1503
1526
  * Create an LLMExtractionService instance
1504
1527
  *
1505
- * @param llmFactory - Factory function for creating LLM instances
1528
+ * @param factoryConfig - LLM factory configuration with create function and optional cache invalidation
1506
1529
  * @param defaultProvider - Default LLM provider (default: 'gemini')
1507
1530
  */
1508
- declare function createLLMExtractionService(llmFactory: LLMFactory, defaultProvider?: LLMProvider): LLMExtractionService;
1531
+ declare function createLLMExtractionService(factoryConfig: LLMFactoryConfig, defaultProvider?: LLMProvider): LLMExtractionService;
1509
1532
 
1510
1533
  /**
1511
1534
  * Upload + Extract Service
@@ -2449,6 +2472,150 @@ declare class GoogleDriveModule extends BaseStorageModule {
2449
2472
  */
2450
2473
  declare function createGoogleDriveModule(): GoogleDriveModule;
2451
2474
 
2475
+ /**
2476
+ * Dropbox OAuth Authentication Handler
2477
+ * Manages OAuth flow, token storage, and token refresh
2478
+ */
2479
+ interface DropboxAuthConfig {
2480
+ clientId: string;
2481
+ clientSecret: string;
2482
+ redirectUri: string;
2483
+ }
2484
+ interface DropboxTokenData {
2485
+ accessToken: string;
2486
+ refreshToken: string;
2487
+ expiryDate?: number;
2488
+ }
2489
+ interface DropboxAuthCallbacks {
2490
+ onTokensUpdated?: (tokens: DropboxTokenData) => Promise<void>;
2491
+ getStoredTokens?: () => Promise<DropboxTokenData | null>;
2492
+ }
2493
+ /**
2494
+ * Dropbox Authentication Manager
2495
+ */
2496
+ declare class DropboxAuth {
2497
+ private config;
2498
+ private callbacks;
2499
+ private tokens;
2500
+ constructor(config: DropboxAuthConfig, callbacks?: DropboxAuthCallbacks);
2501
+ /**
2502
+ * Generate the authorization URL for OAuth consent
2503
+ */
2504
+ getAuthUrl(state?: string): string;
2505
+ /**
2506
+ * Exchange authorization code for tokens
2507
+ */
2508
+ exchangeCodeForTokens(code: string): Promise<DropboxTokenData>;
2509
+ /**
2510
+ * Set tokens directly (e.g., from stored tokens)
2511
+ */
2512
+ setTokens(tokens: DropboxTokenData): Promise<void>;
2513
+ /**
2514
+ * Load tokens from storage using callback
2515
+ */
2516
+ loadStoredTokens(): Promise<boolean>;
2517
+ /**
2518
+ * Check if authenticated
2519
+ */
2520
+ isAuthenticated(): boolean;
2521
+ /**
2522
+ * Get current tokens
2523
+ */
2524
+ getTokens(): DropboxTokenData | null;
2525
+ /**
2526
+ * Get current access token
2527
+ */
2528
+ getAccessToken(): string | null;
2529
+ /**
2530
+ * Refresh the access token
2531
+ */
2532
+ refreshAccessToken(): Promise<DropboxTokenData>;
2533
+ /**
2534
+ * Revoke access (disconnect)
2535
+ */
2536
+ revokeAccess(): Promise<void>;
2537
+ /**
2538
+ * Check if token is expired or will expire soon
2539
+ */
2540
+ isTokenExpired(bufferSeconds?: number): boolean;
2541
+ /**
2542
+ * Ensure valid access token (refresh if needed)
2543
+ */
2544
+ ensureValidToken(): Promise<void>;
2545
+ }
2546
+ /**
2547
+ * Create a new DropboxAuth instance
2548
+ */
2549
+ declare function createDropboxAuth(config: DropboxAuthConfig, callbacks?: DropboxAuthCallbacks): DropboxAuth;
2550
+
2551
+ /**
2552
+ * Dropbox Storage Module
2553
+ * Implements file operations using Dropbox API via the official SDK
2554
+ */
2555
+
2556
+ declare class DropboxModule extends BaseStorageModule {
2557
+ readonly provider: StorageProvider;
2558
+ private auth;
2559
+ private dbx;
2560
+ private rootPath;
2561
+ private authCallbacks;
2562
+ /**
2563
+ * Set authentication callbacks for token persistence
2564
+ */
2565
+ setAuthCallbacks(callbacks: DropboxAuthCallbacks): void;
2566
+ initialize(config: HazoFilesConfig): Promise<void>;
2567
+ /**
2568
+ * Create/recreate the Dropbox SDK client with the current access token
2569
+ */
2570
+ private createDropboxClient;
2571
+ /**
2572
+ * Get the auth instance for OAuth flow
2573
+ */
2574
+ getAuth(): DropboxAuth;
2575
+ /**
2576
+ * Check if user is authenticated
2577
+ */
2578
+ isAuthenticated(): boolean;
2579
+ /**
2580
+ * Authenticate with provided tokens
2581
+ */
2582
+ authenticate(tokens: DropboxTokenData): Promise<void>;
2583
+ /**
2584
+ * Ensure authenticated before operations
2585
+ */
2586
+ private ensureAuthenticated;
2587
+ /**
2588
+ * Convert virtual path to Dropbox path
2589
+ * Virtual: /folder/file.txt -> Dropbox: /folder/file.txt (or /rootPath/folder/file.txt)
2590
+ * Dropbox root is empty string "", not "/"
2591
+ */
2592
+ private toDropboxPath;
2593
+ /**
2594
+ * Convert Dropbox metadata to FileSystemItem
2595
+ */
2596
+ private metadataToItem;
2597
+ /**
2598
+ * Convert a Dropbox path_display to virtual path
2599
+ */
2600
+ private toVirtualPath;
2601
+ createDirectory(virtualPath: string): Promise<OperationResult<FolderItem>>;
2602
+ removeDirectory(virtualPath: string, recursive?: boolean): Promise<OperationResult>;
2603
+ uploadFile(source: string | Buffer | ReadableStream, remotePath: string, options?: UploadOptions): Promise<OperationResult<FileItem>>;
2604
+ downloadFile(remotePath: string, localPath?: string, options?: DownloadOptions): Promise<OperationResult<Buffer | string>>;
2605
+ moveItem(sourcePath: string, destinationPath: string, _options?: MoveOptions): Promise<OperationResult<FileSystemItem>>;
2606
+ deleteFile(virtualPath: string): Promise<OperationResult>;
2607
+ renameFile(virtualPath: string, newName: string, _options?: RenameOptions): Promise<OperationResult<FileItem>>;
2608
+ renameFolder(virtualPath: string, newName: string, _options?: RenameOptions): Promise<OperationResult<FolderItem>>;
2609
+ listDirectory(virtualPath: string, options?: ListOptions): Promise<OperationResult<FileSystemItem[]>>;
2610
+ getItem(virtualPath: string): Promise<OperationResult<FileSystemItem>>;
2611
+ exists(virtualPath: string): Promise<boolean>;
2612
+ getFolderTree(path?: string, depth?: number): Promise<OperationResult<TreeNode[]>>;
2613
+ }
2614
+ /**
2615
+ * Factory function to create a DropboxModule instance
2616
+ */
2617
+ declare function createDropboxModule(): DropboxModule;
2618
+
2452
2619
  /**
2453
2620
  * Module Registry
2454
2621
  * Central registry for all storage modules
@@ -2895,4 +3062,4 @@ declare function toV2Record(record: FileMetadataRecord): FileMetadataRecordV2;
2895
3062
  */
2896
3063
  declare function buildFileWithStatus(record: FileMetadataRecord): FileWithStatus;
2897
3064
 
2898
- export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AuthCallbacks, AuthenticationError, type CleanupOrphanedOptions, ConfigurationError, type ContentTagConfig, type CreateFolderOptions, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseSchemaDefinition, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, type ExtractionData, type ExtractionOptions, type ExtractionResult, type FileBrowserState, type FileDataStructure, FileExistsError, type FileInfo, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, type FileMetadataRecordV2, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileRef, type FileRefVisibility, type FileStatus, type FileSystemItem, FileTooLargeError, type FileWithStatus, type FindOrphanedOptions, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, HAZO_FILES_DEFAULT_TABLE_NAME, HAZO_FILES_MIGRATION_V2, HAZO_FILES_MIGRATION_V3, HAZO_FILES_NAMING_DEFAULT_TABLE_NAME, HAZO_FILES_NAMING_TABLE_SCHEMA, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesMigrationV2, type HazoFilesMigrationV3, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesTableSchema, type HazoLLMInstance, InvalidExtensionError, InvalidPathError, LLMExtractionService, type LLMFactory, type LLMProvider, type ListNamingConventionsOptions, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MigrationExecutor, type MigrationSchemaDefinition, type MoveOptions, type NameGenerationOptions, type NamingConventionInput, type NamingConventionRecord, NamingConventionService, type NamingConventionServiceOptions, type NamingConventionType, type NamingConventionUpdate, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type ParsedNamingConvention, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RemoveRefsCriteria, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TrackedUploadOptions, type TreeNode, type UploadExtractOptions, type UploadExtractResult, UploadExtractService, type UploadOptions, type UploadWithRefOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, backfillV2Defaults, buildFileWithStatus, clearExtractions, clonePattern, computeFileHash, computeFileHashFromStream, computeFileHashSync, computeFileInfo, createAndInitializeModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFileRef, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLLMExtractionService, createLiteralSegment, createLocalModule, createModule, createNamingConventionService, createTrackedFileManager, createUploadExtractService, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateRefId, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMigrationForTable, getMigrationV3ForTable, getMimeType, getNameWithoutExtension, getNamingSchemaForTable, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSchemaForTable, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, hasFileContentChanged, hashesEqual, hazo_files_generate_file_name, hazo_files_generate_folder_name, isAudio, isChildPath, isCounterVariable, isDateVariable, isDocument, isFile, isFileMetadataVariable, isFolder, isImage, isPreviewable, isProviderRegistered, isText, isVideo, joinPath, loadConfig, loadConfigAsync, migrateToV2, migrateToV3, normalizePath, parseConfig, parseFileData, parseFileRefs, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
3065
+ export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AuthCallbacks, AuthenticationError, type CleanupOrphanedOptions, ConfigurationError, type ContentTagConfig, type CreateFolderOptions, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseSchemaDefinition, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, DropboxAuth, type DropboxAuthCallbacks, type DropboxAuthConfig, type DropboxConfig, DropboxModule, type DropboxTokenData, type ExtractionData, type ExtractionOptions, type ExtractionResult, type FileBrowserState, type FileDataStructure, FileExistsError, type FileInfo, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, type FileMetadataRecordV2, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileRef, type FileRefVisibility, type FileStatus, type FileSystemItem, FileTooLargeError, type FileWithStatus, type FindOrphanedOptions, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, HAZO_FILES_DEFAULT_TABLE_NAME, HAZO_FILES_MIGRATION_V2, HAZO_FILES_MIGRATION_V3, HAZO_FILES_NAMING_DEFAULT_TABLE_NAME, HAZO_FILES_NAMING_TABLE_SCHEMA, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesMigrationV2, type HazoFilesMigrationV3, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesTableSchema, type HazoLLMInstance, InvalidExtensionError, InvalidPathError, LLMExtractionService, type LLMFactory, type LLMFactoryConfig, type LLMProvider, type ListNamingConventionsOptions, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MigrationExecutor, type MigrationSchemaDefinition, type MoveOptions, type NameGenerationOptions, type NamingConventionInput, type NamingConventionRecord, NamingConventionService, type NamingConventionServiceOptions, type NamingConventionType, type NamingConventionUpdate, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type ParsedNamingConvention, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RemoveRefsCriteria, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TrackedUploadOptions, type TreeNode, type UploadExtractOptions, type UploadExtractResult, UploadExtractService, type UploadOptions, type UploadWithRefOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, backfillV2Defaults, buildFileWithStatus, clearExtractions, clonePattern, computeFileHash, computeFileHashFromStream, computeFileHashSync, computeFileInfo, createAndInitializeModule, createDropboxAuth, createDropboxModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFileRef, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLLMExtractionService, createLiteralSegment, createLocalModule, createModule, createNamingConventionService, createTrackedFileManager, createUploadExtractService, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateRefId, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMigrationForTable, getMigrationV3ForTable, getMimeType, getNameWithoutExtension, getNamingSchemaForTable, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSchemaForTable, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, hasFileContentChanged, hashesEqual, hazo_files_generate_file_name, hazo_files_generate_folder_name, isAudio, isChildPath, isCounterVariable, isDateVariable, isDocument, isFile, isFileMetadataVariable, isFolder, isImage, isPreviewable, isProviderRegistered, isText, isVideo, joinPath, loadConfig, loadConfigAsync, migrateToV2, migrateToV3, normalizePath, parseConfig, parseFileData, parseFileRefs, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
package/dist/index.d.ts CHANGED
@@ -514,7 +514,7 @@ interface UploadWithRefOptions {
514
514
  * Core types for the hazo_files package
515
515
  */
516
516
  /** Supported storage provider types */
517
- type StorageProvider = 'local' | 'google_drive';
517
+ type StorageProvider = 'local' | 'google_drive' | 'dropbox';
518
518
  /** File item representing a file in storage */
519
519
  interface FileItem {
520
520
  id: string;
@@ -542,11 +542,21 @@ interface FolderItem {
542
542
  }
543
543
  /** Union type for file system items */
544
544
  type FileSystemItem = FileItem | FolderItem;
545
+ /** Dropbox specific configuration */
546
+ interface DropboxConfig {
547
+ clientId: string;
548
+ clientSecret: string;
549
+ redirectUri: string;
550
+ refreshToken?: string;
551
+ accessToken?: string;
552
+ rootPath?: string;
553
+ }
545
554
  /** Configuration for the file manager */
546
555
  interface HazoFilesConfig {
547
556
  provider: StorageProvider;
548
557
  local?: LocalStorageConfig;
549
558
  google_drive?: GoogleDriveConfig;
559
+ dropbox?: DropboxConfig;
550
560
  }
551
561
  /** Local storage specific configuration */
552
562
  interface LocalStorageConfig {
@@ -1429,6 +1439,13 @@ interface HazoLLMInstance {
1429
1439
  * Factory function type for creating LLM instances
1430
1440
  */
1431
1441
  type LLMFactory = (provider: LLMProvider, options?: Record<string, unknown>) => HazoLLMInstance | Promise<HazoLLMInstance>;
1442
+ /**
1443
+ * Extended LLM factory configuration with optional cache management
1444
+ */
1445
+ interface LLMFactoryConfig {
1446
+ create: LLMFactory;
1447
+ invalidateCache?: (area?: string, key?: string) => void;
1448
+ }
1432
1449
  /**
1433
1450
  * LLM Extraction Service
1434
1451
  *
@@ -1470,7 +1487,13 @@ type LLMFactory = (provider: LLMProvider, options?: Record<string, unknown>) =>
1470
1487
  declare class LLMExtractionService {
1471
1488
  private llmFactory;
1472
1489
  private defaultProvider;
1473
- constructor(llmFactory: LLMFactory, defaultProvider?: LLMProvider);
1490
+ private cacheInvalidator?;
1491
+ constructor(factoryConfig: LLMFactoryConfig, defaultProvider?: LLMProvider);
1492
+ /**
1493
+ * Invalidate the LLM prompt cache
1494
+ * Passthrough to hazo_llm_api's invalidate_prompt_cache when configured
1495
+ */
1496
+ invalidatePromptCache(area?: string, key?: string): void;
1474
1497
  /**
1475
1498
  * Extract data from a document
1476
1499
  *
@@ -1502,10 +1525,10 @@ declare class LLMExtractionService {
1502
1525
  /**
1503
1526
  * Create an LLMExtractionService instance
1504
1527
  *
1505
- * @param llmFactory - Factory function for creating LLM instances
1528
+ * @param factoryConfig - LLM factory configuration with create function and optional cache invalidation
1506
1529
  * @param defaultProvider - Default LLM provider (default: 'gemini')
1507
1530
  */
1508
- declare function createLLMExtractionService(llmFactory: LLMFactory, defaultProvider?: LLMProvider): LLMExtractionService;
1531
+ declare function createLLMExtractionService(factoryConfig: LLMFactoryConfig, defaultProvider?: LLMProvider): LLMExtractionService;
1509
1532
 
1510
1533
  /**
1511
1534
  * Upload + Extract Service
@@ -2449,6 +2472,150 @@ declare class GoogleDriveModule extends BaseStorageModule {
2449
2472
  */
2450
2473
  declare function createGoogleDriveModule(): GoogleDriveModule;
2451
2474
 
2475
+ /**
2476
+ * Dropbox OAuth Authentication Handler
2477
+ * Manages OAuth flow, token storage, and token refresh
2478
+ */
2479
+ interface DropboxAuthConfig {
2480
+ clientId: string;
2481
+ clientSecret: string;
2482
+ redirectUri: string;
2483
+ }
2484
+ interface DropboxTokenData {
2485
+ accessToken: string;
2486
+ refreshToken: string;
2487
+ expiryDate?: number;
2488
+ }
2489
+ interface DropboxAuthCallbacks {
2490
+ onTokensUpdated?: (tokens: DropboxTokenData) => Promise<void>;
2491
+ getStoredTokens?: () => Promise<DropboxTokenData | null>;
2492
+ }
2493
+ /**
2494
+ * Dropbox Authentication Manager
2495
+ */
2496
+ declare class DropboxAuth {
2497
+ private config;
2498
+ private callbacks;
2499
+ private tokens;
2500
+ constructor(config: DropboxAuthConfig, callbacks?: DropboxAuthCallbacks);
2501
+ /**
2502
+ * Generate the authorization URL for OAuth consent
2503
+ */
2504
+ getAuthUrl(state?: string): string;
2505
+ /**
2506
+ * Exchange authorization code for tokens
2507
+ */
2508
+ exchangeCodeForTokens(code: string): Promise<DropboxTokenData>;
2509
+ /**
2510
+ * Set tokens directly (e.g., from stored tokens)
2511
+ */
2512
+ setTokens(tokens: DropboxTokenData): Promise<void>;
2513
+ /**
2514
+ * Load tokens from storage using callback
2515
+ */
2516
+ loadStoredTokens(): Promise<boolean>;
2517
+ /**
2518
+ * Check if authenticated
2519
+ */
2520
+ isAuthenticated(): boolean;
2521
+ /**
2522
+ * Get current tokens
2523
+ */
2524
+ getTokens(): DropboxTokenData | null;
2525
+ /**
2526
+ * Get current access token
2527
+ */
2528
+ getAccessToken(): string | null;
2529
+ /**
2530
+ * Refresh the access token
2531
+ */
2532
+ refreshAccessToken(): Promise<DropboxTokenData>;
2533
+ /**
2534
+ * Revoke access (disconnect)
2535
+ */
2536
+ revokeAccess(): Promise<void>;
2537
+ /**
2538
+ * Check if token is expired or will expire soon
2539
+ */
2540
+ isTokenExpired(bufferSeconds?: number): boolean;
2541
+ /**
2542
+ * Ensure valid access token (refresh if needed)
2543
+ */
2544
+ ensureValidToken(): Promise<void>;
2545
+ }
2546
+ /**
2547
+ * Create a new DropboxAuth instance
2548
+ */
2549
+ declare function createDropboxAuth(config: DropboxAuthConfig, callbacks?: DropboxAuthCallbacks): DropboxAuth;
2550
+
2551
+ /**
2552
+ * Dropbox Storage Module
2553
+ * Implements file operations using Dropbox API via the official SDK
2554
+ */
2555
+
2556
+ declare class DropboxModule extends BaseStorageModule {
2557
+ readonly provider: StorageProvider;
2558
+ private auth;
2559
+ private dbx;
2560
+ private rootPath;
2561
+ private authCallbacks;
2562
+ /**
2563
+ * Set authentication callbacks for token persistence
2564
+ */
2565
+ setAuthCallbacks(callbacks: DropboxAuthCallbacks): void;
2566
+ initialize(config: HazoFilesConfig): Promise<void>;
2567
+ /**
2568
+ * Create/recreate the Dropbox SDK client with the current access token
2569
+ */
2570
+ private createDropboxClient;
2571
+ /**
2572
+ * Get the auth instance for OAuth flow
2573
+ */
2574
+ getAuth(): DropboxAuth;
2575
+ /**
2576
+ * Check if user is authenticated
2577
+ */
2578
+ isAuthenticated(): boolean;
2579
+ /**
2580
+ * Authenticate with provided tokens
2581
+ */
2582
+ authenticate(tokens: DropboxTokenData): Promise<void>;
2583
+ /**
2584
+ * Ensure authenticated before operations
2585
+ */
2586
+ private ensureAuthenticated;
2587
+ /**
2588
+ * Convert virtual path to Dropbox path
2589
+ * Virtual: /folder/file.txt -> Dropbox: /folder/file.txt (or /rootPath/folder/file.txt)
2590
+ * Dropbox root is empty string "", not "/"
2591
+ */
2592
+ private toDropboxPath;
2593
+ /**
2594
+ * Convert Dropbox metadata to FileSystemItem
2595
+ */
2596
+ private metadataToItem;
2597
+ /**
2598
+ * Convert a Dropbox path_display to virtual path
2599
+ */
2600
+ private toVirtualPath;
2601
+ createDirectory(virtualPath: string): Promise<OperationResult<FolderItem>>;
2602
+ removeDirectory(virtualPath: string, recursive?: boolean): Promise<OperationResult>;
2603
+ uploadFile(source: string | Buffer | ReadableStream, remotePath: string, options?: UploadOptions): Promise<OperationResult<FileItem>>;
2604
+ downloadFile(remotePath: string, localPath?: string, options?: DownloadOptions): Promise<OperationResult<Buffer | string>>;
2605
+ moveItem(sourcePath: string, destinationPath: string, _options?: MoveOptions): Promise<OperationResult<FileSystemItem>>;
2606
+ deleteFile(virtualPath: string): Promise<OperationResult>;
2607
+ renameFile(virtualPath: string, newName: string, _options?: RenameOptions): Promise<OperationResult<FileItem>>;
2608
+ renameFolder(virtualPath: string, newName: string, _options?: RenameOptions): Promise<OperationResult<FolderItem>>;
2609
+ listDirectory(virtualPath: string, options?: ListOptions): Promise<OperationResult<FileSystemItem[]>>;
2610
+ getItem(virtualPath: string): Promise<OperationResult<FileSystemItem>>;
2611
+ exists(virtualPath: string): Promise<boolean>;
2612
+ getFolderTree(path?: string, depth?: number): Promise<OperationResult<TreeNode[]>>;
2613
+ }
2614
+ /**
2615
+ * Factory function to create a DropboxModule instance
2616
+ */
2617
+ declare function createDropboxModule(): DropboxModule;
2618
+
2452
2619
  /**
2453
2620
  * Module Registry
2454
2621
  * Central registry for all storage modules
@@ -2895,4 +3062,4 @@ declare function toV2Record(record: FileMetadataRecord): FileMetadataRecordV2;
2895
3062
  */
2896
3063
  declare function buildFileWithStatus(record: FileMetadataRecord): FileWithStatus;
2897
3064
 
2898
- export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AuthCallbacks, AuthenticationError, type CleanupOrphanedOptions, ConfigurationError, type ContentTagConfig, type CreateFolderOptions, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseSchemaDefinition, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, type ExtractionData, type ExtractionOptions, type ExtractionResult, type FileBrowserState, type FileDataStructure, FileExistsError, type FileInfo, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, type FileMetadataRecordV2, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileRef, type FileRefVisibility, type FileStatus, type FileSystemItem, FileTooLargeError, type FileWithStatus, type FindOrphanedOptions, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, HAZO_FILES_DEFAULT_TABLE_NAME, HAZO_FILES_MIGRATION_V2, HAZO_FILES_MIGRATION_V3, HAZO_FILES_NAMING_DEFAULT_TABLE_NAME, HAZO_FILES_NAMING_TABLE_SCHEMA, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesMigrationV2, type HazoFilesMigrationV3, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesTableSchema, type HazoLLMInstance, InvalidExtensionError, InvalidPathError, LLMExtractionService, type LLMFactory, type LLMProvider, type ListNamingConventionsOptions, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MigrationExecutor, type MigrationSchemaDefinition, type MoveOptions, type NameGenerationOptions, type NamingConventionInput, type NamingConventionRecord, NamingConventionService, type NamingConventionServiceOptions, type NamingConventionType, type NamingConventionUpdate, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type ParsedNamingConvention, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RemoveRefsCriteria, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TrackedUploadOptions, type TreeNode, type UploadExtractOptions, type UploadExtractResult, UploadExtractService, type UploadOptions, type UploadWithRefOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, backfillV2Defaults, buildFileWithStatus, clearExtractions, clonePattern, computeFileHash, computeFileHashFromStream, computeFileHashSync, computeFileInfo, createAndInitializeModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFileRef, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLLMExtractionService, createLiteralSegment, createLocalModule, createModule, createNamingConventionService, createTrackedFileManager, createUploadExtractService, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateRefId, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMigrationForTable, getMigrationV3ForTable, getMimeType, getNameWithoutExtension, getNamingSchemaForTable, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSchemaForTable, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, hasFileContentChanged, hashesEqual, hazo_files_generate_file_name, hazo_files_generate_folder_name, isAudio, isChildPath, isCounterVariable, isDateVariable, isDocument, isFile, isFileMetadataVariable, isFolder, isImage, isPreviewable, isProviderRegistered, isText, isVideo, joinPath, loadConfig, loadConfigAsync, migrateToV2, migrateToV3, normalizePath, parseConfig, parseFileData, parseFileRefs, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
3065
+ export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AuthCallbacks, AuthenticationError, type CleanupOrphanedOptions, ConfigurationError, type ContentTagConfig, type CreateFolderOptions, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseSchemaDefinition, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, DropboxAuth, type DropboxAuthCallbacks, type DropboxAuthConfig, type DropboxConfig, DropboxModule, type DropboxTokenData, type ExtractionData, type ExtractionOptions, type ExtractionResult, type FileBrowserState, type FileDataStructure, FileExistsError, type FileInfo, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, type FileMetadataRecordV2, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileRef, type FileRefVisibility, type FileStatus, type FileSystemItem, FileTooLargeError, type FileWithStatus, type FindOrphanedOptions, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, HAZO_FILES_DEFAULT_TABLE_NAME, HAZO_FILES_MIGRATION_V2, HAZO_FILES_MIGRATION_V3, HAZO_FILES_NAMING_DEFAULT_TABLE_NAME, HAZO_FILES_NAMING_TABLE_SCHEMA, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesMigrationV2, type HazoFilesMigrationV3, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesTableSchema, type HazoLLMInstance, InvalidExtensionError, InvalidPathError, LLMExtractionService, type LLMFactory, type LLMFactoryConfig, type LLMProvider, type ListNamingConventionsOptions, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MigrationExecutor, type MigrationSchemaDefinition, type MoveOptions, type NameGenerationOptions, type NamingConventionInput, type NamingConventionRecord, NamingConventionService, type NamingConventionServiceOptions, type NamingConventionType, type NamingConventionUpdate, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type ParsedNamingConvention, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RemoveRefsCriteria, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TrackedUploadOptions, type TreeNode, type UploadExtractOptions, type UploadExtractResult, UploadExtractService, type UploadOptions, type UploadWithRefOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, backfillV2Defaults, buildFileWithStatus, clearExtractions, clonePattern, computeFileHash, computeFileHashFromStream, computeFileHashSync, computeFileInfo, createAndInitializeModule, createDropboxAuth, createDropboxModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFileRef, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLLMExtractionService, createLiteralSegment, createLocalModule, createModule, createNamingConventionService, createTrackedFileManager, createUploadExtractService, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateRefId, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMigrationForTable, getMigrationV3ForTable, getMimeType, getNameWithoutExtension, getNamingSchemaForTable, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSchemaForTable, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, hasFileContentChanged, hashesEqual, hazo_files_generate_file_name, hazo_files_generate_folder_name, isAudio, isChildPath, isCounterVariable, isDateVariable, isDocument, isFile, isFileMetadataVariable, isFolder, isImage, isPreviewable, isProviderRegistered, isText, isVideo, joinPath, loadConfig, loadConfigAsync, migrateToV2, migrateToV3, normalizePath, parseConfig, parseFileData, parseFileRefs, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };