hazo_files 1.4.2 → 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 +103 -9
- package/dist/index.d.mts +288 -8
- package/dist/index.d.ts +288 -8
- package/dist/index.js +842 -16
- package/dist/index.mjs +835 -16
- package/dist/server/index.d.mts +298 -11
- package/dist/server/index.d.ts +298 -11
- package/dist/server/index.js +849 -19
- package/dist/server/index.mjs +842 -19
- package/package.json +5 -6
package/dist/server/index.d.mts
CHANGED
|
@@ -185,6 +185,8 @@ interface FileMetadataInput {
|
|
|
185
185
|
uploaded_by?: string;
|
|
186
186
|
/** Original filename at upload time (V2) */
|
|
187
187
|
original_filename?: string;
|
|
188
|
+
/** Content tag classifying the document type (V3) */
|
|
189
|
+
content_tag?: string;
|
|
188
190
|
}
|
|
189
191
|
/**
|
|
190
192
|
* Input for updating an existing metadata record
|
|
@@ -258,6 +260,23 @@ interface RemoveExtractionOptions {
|
|
|
258
260
|
/** Merge strategy to use when recalculating (default: 'shallow') */
|
|
259
261
|
mergeStrategy?: 'shallow' | 'deep';
|
|
260
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Configuration for LLM-based content tagging.
|
|
265
|
+
* When enabled, calls the LLM with a specific prompt and writes
|
|
266
|
+
* the extracted field value to the content_tag column.
|
|
267
|
+
*/
|
|
268
|
+
interface ContentTagConfig {
|
|
269
|
+
/** Whether to enable LLM-based content tagging */
|
|
270
|
+
content_tag_set_by_llm: boolean;
|
|
271
|
+
/** Prompt area for hazo_llm_api lookup */
|
|
272
|
+
content_tag_prompt_area: string;
|
|
273
|
+
/** Prompt key within the area */
|
|
274
|
+
content_tag_prompt_key: string;
|
|
275
|
+
/** Optional variables to substitute in the prompt template */
|
|
276
|
+
content_tag_prompt_variables?: Record<string, string>;
|
|
277
|
+
/** Field name to extract from the LLM response as the content tag */
|
|
278
|
+
content_tag_prompt_return_fieldname: string;
|
|
279
|
+
}
|
|
261
280
|
|
|
262
281
|
/**
|
|
263
282
|
* Naming convention types for hazo_files
|
|
@@ -412,6 +431,8 @@ interface FileMetadataRecordV2 extends FileMetadataRecord {
|
|
|
412
431
|
storage_verified_at?: string | null;
|
|
413
432
|
/** ISO timestamp when file was soft-deleted */
|
|
414
433
|
deleted_at?: string | null;
|
|
434
|
+
/** Content tag classifying the document type (V3) */
|
|
435
|
+
content_tag?: string | null;
|
|
415
436
|
}
|
|
416
437
|
/**
|
|
417
438
|
* Options for adding a reference to a file
|
|
@@ -493,7 +514,7 @@ interface UploadWithRefOptions {
|
|
|
493
514
|
* Core types for the hazo_files package
|
|
494
515
|
*/
|
|
495
516
|
/** Supported storage provider types */
|
|
496
|
-
type StorageProvider = 'local' | 'google_drive';
|
|
517
|
+
type StorageProvider = 'local' | 'google_drive' | 'dropbox';
|
|
497
518
|
/** File item representing a file in storage */
|
|
498
519
|
interface FileItem {
|
|
499
520
|
id: string;
|
|
@@ -521,11 +542,21 @@ interface FolderItem {
|
|
|
521
542
|
}
|
|
522
543
|
/** Union type for file system items */
|
|
523
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
|
+
}
|
|
524
554
|
/** Configuration for the file manager */
|
|
525
555
|
interface HazoFilesConfig {
|
|
526
556
|
provider: StorageProvider;
|
|
527
557
|
local?: LocalStorageConfig;
|
|
528
558
|
google_drive?: GoogleDriveConfig;
|
|
559
|
+
dropbox?: DropboxConfig;
|
|
529
560
|
}
|
|
530
561
|
/** Local storage specific configuration */
|
|
531
562
|
interface LocalStorageConfig {
|
|
@@ -1004,7 +1035,7 @@ declare class FileMetadataService {
|
|
|
1004
1035
|
/**
|
|
1005
1036
|
* Update specific V2 fields on a record
|
|
1006
1037
|
*/
|
|
1007
|
-
updateFields(fileId: string, fields: Partial<Pick<FileMetadataRecordV2, 'scope_id' | 'uploaded_by' | 'original_filename' | 'storage_verified_at' | 'status'>>): Promise<boolean>;
|
|
1038
|
+
updateFields(fileId: string, fields: Partial<Pick<FileMetadataRecordV2, 'scope_id' | 'uploaded_by' | 'original_filename' | 'storage_verified_at' | 'status' | 'content_tag'>>): Promise<boolean>;
|
|
1008
1039
|
/**
|
|
1009
1040
|
* Find orphaned files (zero references)
|
|
1010
1041
|
*/
|
|
@@ -1408,6 +1439,13 @@ interface HazoLLMInstance {
|
|
|
1408
1439
|
* Factory function type for creating LLM instances
|
|
1409
1440
|
*/
|
|
1410
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
|
+
}
|
|
1411
1449
|
/**
|
|
1412
1450
|
* LLM Extraction Service
|
|
1413
1451
|
*
|
|
@@ -1449,7 +1487,13 @@ type LLMFactory = (provider: LLMProvider, options?: Record<string, unknown>) =>
|
|
|
1449
1487
|
declare class LLMExtractionService {
|
|
1450
1488
|
private llmFactory;
|
|
1451
1489
|
private defaultProvider;
|
|
1452
|
-
|
|
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;
|
|
1453
1497
|
/**
|
|
1454
1498
|
* Extract data from a document
|
|
1455
1499
|
*
|
|
@@ -1481,10 +1525,10 @@ declare class LLMExtractionService {
|
|
|
1481
1525
|
/**
|
|
1482
1526
|
* Create an LLMExtractionService instance
|
|
1483
1527
|
*
|
|
1484
|
-
* @param
|
|
1528
|
+
* @param factoryConfig - LLM factory configuration with create function and optional cache invalidation
|
|
1485
1529
|
* @param defaultProvider - Default LLM provider (default: 'gemini')
|
|
1486
1530
|
*/
|
|
1487
|
-
declare function createLLMExtractionService(
|
|
1531
|
+
declare function createLLMExtractionService(factoryConfig: LLMFactoryConfig, defaultProvider?: LLMProvider): LLMExtractionService;
|
|
1488
1532
|
|
|
1489
1533
|
/**
|
|
1490
1534
|
* Upload + Extract Service
|
|
@@ -1532,6 +1576,11 @@ interface UploadExtractOptions extends TrackedUploadOptions {
|
|
|
1532
1576
|
* Whether to create the folder path if it doesn't exist
|
|
1533
1577
|
*/
|
|
1534
1578
|
createFolders?: boolean;
|
|
1579
|
+
/**
|
|
1580
|
+
* Content tag configuration for this upload.
|
|
1581
|
+
* Overrides the default config set on the service.
|
|
1582
|
+
*/
|
|
1583
|
+
contentTagConfig?: ContentTagConfig;
|
|
1535
1584
|
}
|
|
1536
1585
|
/**
|
|
1537
1586
|
* Result of upload with extraction
|
|
@@ -1551,6 +1600,8 @@ interface UploadExtractResult {
|
|
|
1551
1600
|
generatedFolderPath?: string;
|
|
1552
1601
|
/** Original file name before renaming */
|
|
1553
1602
|
originalFileName?: string;
|
|
1603
|
+
/** Content tag assigned by LLM (if content tagging was performed) */
|
|
1604
|
+
contentTag?: string;
|
|
1554
1605
|
}
|
|
1555
1606
|
/**
|
|
1556
1607
|
* Options for creating folders from naming convention
|
|
@@ -1608,7 +1659,8 @@ declare class UploadExtractService {
|
|
|
1608
1659
|
private fileManager;
|
|
1609
1660
|
private namingService?;
|
|
1610
1661
|
private extractionService?;
|
|
1611
|
-
|
|
1662
|
+
private defaultContentTagConfig?;
|
|
1663
|
+
constructor(fileManager: TrackedFileManager, namingService?: NamingConventionService, extractionService?: LLMExtractionService, defaultContentTagConfig?: ContentTagConfig);
|
|
1612
1664
|
/**
|
|
1613
1665
|
* Upload a file with optional extraction and naming convention
|
|
1614
1666
|
*/
|
|
@@ -1633,6 +1685,21 @@ declare class UploadExtractService {
|
|
|
1633
1685
|
fullPath?: string;
|
|
1634
1686
|
folderPath?: string;
|
|
1635
1687
|
}>;
|
|
1688
|
+
/**
|
|
1689
|
+
* Perform content tagging via LLM extraction.
|
|
1690
|
+
* Calls the LLM with the configured prompt, extracts the specified field,
|
|
1691
|
+
* and writes it to the content_tag column.
|
|
1692
|
+
*/
|
|
1693
|
+
private performContentTagging;
|
|
1694
|
+
/**
|
|
1695
|
+
* Manually tag a file's content via LLM.
|
|
1696
|
+
* Works with existing DB records, resolving the file path internally.
|
|
1697
|
+
*
|
|
1698
|
+
* @param fileId - Database record ID of the file
|
|
1699
|
+
* @param config - Content tag config (falls back to default if not provided)
|
|
1700
|
+
* @returns OperationResult with the tag value
|
|
1701
|
+
*/
|
|
1702
|
+
tagFileContent(fileId: string, config?: ContentTagConfig): Promise<OperationResult<string>>;
|
|
1636
1703
|
/**
|
|
1637
1704
|
* Get the file manager
|
|
1638
1705
|
*/
|
|
@@ -1649,7 +1716,7 @@ declare class UploadExtractService {
|
|
|
1649
1716
|
/**
|
|
1650
1717
|
* Create an UploadExtractService instance
|
|
1651
1718
|
*/
|
|
1652
|
-
declare function createUploadExtractService(fileManager: TrackedFileManager, namingService?: NamingConventionService, extractionService?: LLMExtractionService): UploadExtractService;
|
|
1719
|
+
declare function createUploadExtractService(fileManager: TrackedFileManager, namingService?: NamingConventionService, extractionService?: LLMExtractionService, defaultContentTagConfig?: ContentTagConfig): UploadExtractService;
|
|
1653
1720
|
|
|
1654
1721
|
/**
|
|
1655
1722
|
* Server Factory
|
|
@@ -1699,10 +1766,10 @@ interface HazoFilesServerOptions {
|
|
|
1699
1766
|
*/
|
|
1700
1767
|
enableExtraction?: boolean;
|
|
1701
1768
|
/**
|
|
1702
|
-
*
|
|
1769
|
+
* LLM factory configuration for creating LLM instances
|
|
1703
1770
|
* Required if enableExtraction is true
|
|
1704
1771
|
*/
|
|
1705
|
-
llmFactory?:
|
|
1772
|
+
llmFactory?: LLMFactoryConfig;
|
|
1706
1773
|
/**
|
|
1707
1774
|
* Default LLM provider for extraction
|
|
1708
1775
|
*/
|
|
@@ -1723,6 +1790,11 @@ interface HazoFilesServerOptions {
|
|
|
1723
1790
|
* Track download/access operations
|
|
1724
1791
|
*/
|
|
1725
1792
|
trackDownloads?: boolean;
|
|
1793
|
+
/**
|
|
1794
|
+
* Default content tag configuration for LLM-based content classification.
|
|
1795
|
+
* When set, uploads can automatically classify document content.
|
|
1796
|
+
*/
|
|
1797
|
+
defaultContentTagConfig?: ContentTagConfig;
|
|
1726
1798
|
}
|
|
1727
1799
|
/**
|
|
1728
1800
|
* Result of createHazoFilesServer
|
|
@@ -1738,6 +1810,8 @@ interface HazoFilesServerInstance {
|
|
|
1738
1810
|
extractionService: LLMExtractionService | null;
|
|
1739
1811
|
/** Combined upload + extract service */
|
|
1740
1812
|
uploadExtractService: UploadExtractService;
|
|
1813
|
+
/** Invalidate hazo_llm_api prompt cache (if LLMFactoryConfig with invalidateCache was provided) */
|
|
1814
|
+
invalidatePromptCache?: (area?: string, key?: string) => void;
|
|
1741
1815
|
}
|
|
1742
1816
|
/**
|
|
1743
1817
|
* Create a fully-configured hazo_files server instance
|
|
@@ -1776,7 +1850,7 @@ interface HazoFilesServerInstance {
|
|
|
1776
1850
|
* config: { provider: 'local', local: { basePath: './files' } },
|
|
1777
1851
|
* enableTracking: true,
|
|
1778
1852
|
* enableExtraction: true,
|
|
1779
|
-
* llmFactory: (provider) => createLLM({ provider })
|
|
1853
|
+
* llmFactory: { create: (provider) => createLLM({ provider }) }
|
|
1780
1854
|
* });
|
|
1781
1855
|
*
|
|
1782
1856
|
* // Upload with extraction and naming convention
|
|
@@ -1863,6 +1937,8 @@ interface HazoFilesColumnDefinitions {
|
|
|
1863
1937
|
deleted_at: 'TEXT' | 'TIMESTAMP';
|
|
1864
1938
|
/** Original filename at upload time (V2) */
|
|
1865
1939
|
original_filename: 'TEXT';
|
|
1940
|
+
/** Content tag classifying the document type (V3) */
|
|
1941
|
+
content_tag: 'TEXT';
|
|
1866
1942
|
}
|
|
1867
1943
|
/**
|
|
1868
1944
|
* Schema definition for a specific database type
|
|
@@ -2045,6 +2121,46 @@ declare const HAZO_FILES_NAMING_TABLE_SCHEMA: HazoFilesNamingTableSchema;
|
|
|
2045
2121
|
* Get DDL for a custom naming table name
|
|
2046
2122
|
*/
|
|
2047
2123
|
declare function getNamingSchemaForTable(tableName: string, dbType: 'sqlite' | 'postgres'): DatabaseSchemaDefinition;
|
|
2124
|
+
/**
|
|
2125
|
+
* Migration schema for adding V3 content tagging column to existing tables.
|
|
2126
|
+
* Idempotent — safe to run multiple times.
|
|
2127
|
+
*
|
|
2128
|
+
* @example
|
|
2129
|
+
* ```typescript
|
|
2130
|
+
* import { HAZO_FILES_MIGRATION_V3 } from 'hazo_files';
|
|
2131
|
+
*
|
|
2132
|
+
* // SQLite
|
|
2133
|
+
* for (const stmt of HAZO_FILES_MIGRATION_V3.sqlite.alterStatements) {
|
|
2134
|
+
* try { await db.run(stmt); } catch { /* column already exists *\/ }
|
|
2135
|
+
* }
|
|
2136
|
+
* for (const idx of HAZO_FILES_MIGRATION_V3.sqlite.indexes) {
|
|
2137
|
+
* await db.run(idx);
|
|
2138
|
+
* }
|
|
2139
|
+
*
|
|
2140
|
+
* // PostgreSQL
|
|
2141
|
+
* for (const stmt of HAZO_FILES_MIGRATION_V3.postgres.alterStatements) {
|
|
2142
|
+
* await client.query(stmt);
|
|
2143
|
+
* }
|
|
2144
|
+
* for (const idx of HAZO_FILES_MIGRATION_V3.postgres.indexes) {
|
|
2145
|
+
* await client.query(idx);
|
|
2146
|
+
* }
|
|
2147
|
+
* ```
|
|
2148
|
+
*/
|
|
2149
|
+
interface HazoFilesMigrationV3 {
|
|
2150
|
+
/** Default table name */
|
|
2151
|
+
tableName: string;
|
|
2152
|
+
/** SQLite migration statements */
|
|
2153
|
+
sqlite: MigrationSchemaDefinition;
|
|
2154
|
+
/** PostgreSQL migration statements */
|
|
2155
|
+
postgres: MigrationSchemaDefinition;
|
|
2156
|
+
/** New column names added in V3 */
|
|
2157
|
+
newColumns: readonly string[];
|
|
2158
|
+
}
|
|
2159
|
+
declare const HAZO_FILES_MIGRATION_V3: HazoFilesMigrationV3;
|
|
2160
|
+
/**
|
|
2161
|
+
* Get V3 migration statements for a custom table name
|
|
2162
|
+
*/
|
|
2163
|
+
declare function getMigrationV3ForTable(tableName: string, dbType: 'sqlite' | 'postgres'): MigrationSchemaDefinition;
|
|
2048
2164
|
|
|
2049
2165
|
/**
|
|
2050
2166
|
* Migration: Add Reference Tracking (V2)
|
|
@@ -2087,6 +2203,33 @@ declare function migrateToV2(executor: MigrationExecutor, dbType: 'sqlite' | 'po
|
|
|
2087
2203
|
*/
|
|
2088
2204
|
declare function backfillV2Defaults(executor: MigrationExecutor, dbType: 'sqlite' | 'postgres', tableName?: string): Promise<void>;
|
|
2089
2205
|
|
|
2206
|
+
/**
|
|
2207
|
+
* Migration: Add Content Tag (V3)
|
|
2208
|
+
*
|
|
2209
|
+
* Adds content_tag column to an existing hazo_files table.
|
|
2210
|
+
* Idempotent — safe to run multiple times.
|
|
2211
|
+
*/
|
|
2212
|
+
|
|
2213
|
+
/**
|
|
2214
|
+
* Run the V3 migration: add content_tag column and index.
|
|
2215
|
+
*
|
|
2216
|
+
* @param executor - Object with a `run(sql)` method
|
|
2217
|
+
* @param dbType - Database type ('sqlite' | 'postgres')
|
|
2218
|
+
* @param tableName - Custom table name (defaults to 'hazo_files')
|
|
2219
|
+
*
|
|
2220
|
+
* @example
|
|
2221
|
+
* ```typescript
|
|
2222
|
+
* import { migrateToV3 } from 'hazo_files';
|
|
2223
|
+
*
|
|
2224
|
+
* // SQLite with better-sqlite3
|
|
2225
|
+
* await migrateToV3({ run: (sql) => db.exec(sql) }, 'sqlite');
|
|
2226
|
+
*
|
|
2227
|
+
* // PostgreSQL with pg
|
|
2228
|
+
* await migrateToV3({ run: (sql) => client.query(sql) }, 'postgres');
|
|
2229
|
+
* ```
|
|
2230
|
+
*/
|
|
2231
|
+
declare function migrateToV3(executor: MigrationExecutor, dbType: 'sqlite' | 'postgres', tableName?: string): Promise<void>;
|
|
2232
|
+
|
|
2090
2233
|
/**
|
|
2091
2234
|
* Common utility functions
|
|
2092
2235
|
*/
|
|
@@ -2456,6 +2599,150 @@ declare class GoogleDriveModule extends BaseStorageModule {
|
|
|
2456
2599
|
*/
|
|
2457
2600
|
declare function createGoogleDriveModule(): GoogleDriveModule;
|
|
2458
2601
|
|
|
2602
|
+
/**
|
|
2603
|
+
* Dropbox OAuth Authentication Handler
|
|
2604
|
+
* Manages OAuth flow, token storage, and token refresh
|
|
2605
|
+
*/
|
|
2606
|
+
interface DropboxAuthConfig {
|
|
2607
|
+
clientId: string;
|
|
2608
|
+
clientSecret: string;
|
|
2609
|
+
redirectUri: string;
|
|
2610
|
+
}
|
|
2611
|
+
interface DropboxTokenData {
|
|
2612
|
+
accessToken: string;
|
|
2613
|
+
refreshToken: string;
|
|
2614
|
+
expiryDate?: number;
|
|
2615
|
+
}
|
|
2616
|
+
interface DropboxAuthCallbacks {
|
|
2617
|
+
onTokensUpdated?: (tokens: DropboxTokenData) => Promise<void>;
|
|
2618
|
+
getStoredTokens?: () => Promise<DropboxTokenData | null>;
|
|
2619
|
+
}
|
|
2620
|
+
/**
|
|
2621
|
+
* Dropbox Authentication Manager
|
|
2622
|
+
*/
|
|
2623
|
+
declare class DropboxAuth {
|
|
2624
|
+
private config;
|
|
2625
|
+
private callbacks;
|
|
2626
|
+
private tokens;
|
|
2627
|
+
constructor(config: DropboxAuthConfig, callbacks?: DropboxAuthCallbacks);
|
|
2628
|
+
/**
|
|
2629
|
+
* Generate the authorization URL for OAuth consent
|
|
2630
|
+
*/
|
|
2631
|
+
getAuthUrl(state?: string): string;
|
|
2632
|
+
/**
|
|
2633
|
+
* Exchange authorization code for tokens
|
|
2634
|
+
*/
|
|
2635
|
+
exchangeCodeForTokens(code: string): Promise<DropboxTokenData>;
|
|
2636
|
+
/**
|
|
2637
|
+
* Set tokens directly (e.g., from stored tokens)
|
|
2638
|
+
*/
|
|
2639
|
+
setTokens(tokens: DropboxTokenData): Promise<void>;
|
|
2640
|
+
/**
|
|
2641
|
+
* Load tokens from storage using callback
|
|
2642
|
+
*/
|
|
2643
|
+
loadStoredTokens(): Promise<boolean>;
|
|
2644
|
+
/**
|
|
2645
|
+
* Check if authenticated
|
|
2646
|
+
*/
|
|
2647
|
+
isAuthenticated(): boolean;
|
|
2648
|
+
/**
|
|
2649
|
+
* Get current tokens
|
|
2650
|
+
*/
|
|
2651
|
+
getTokens(): DropboxTokenData | null;
|
|
2652
|
+
/**
|
|
2653
|
+
* Get current access token
|
|
2654
|
+
*/
|
|
2655
|
+
getAccessToken(): string | null;
|
|
2656
|
+
/**
|
|
2657
|
+
* Refresh the access token
|
|
2658
|
+
*/
|
|
2659
|
+
refreshAccessToken(): Promise<DropboxTokenData>;
|
|
2660
|
+
/**
|
|
2661
|
+
* Revoke access (disconnect)
|
|
2662
|
+
*/
|
|
2663
|
+
revokeAccess(): Promise<void>;
|
|
2664
|
+
/**
|
|
2665
|
+
* Check if token is expired or will expire soon
|
|
2666
|
+
*/
|
|
2667
|
+
isTokenExpired(bufferSeconds?: number): boolean;
|
|
2668
|
+
/**
|
|
2669
|
+
* Ensure valid access token (refresh if needed)
|
|
2670
|
+
*/
|
|
2671
|
+
ensureValidToken(): Promise<void>;
|
|
2672
|
+
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Create a new DropboxAuth instance
|
|
2675
|
+
*/
|
|
2676
|
+
declare function createDropboxAuth(config: DropboxAuthConfig, callbacks?: DropboxAuthCallbacks): DropboxAuth;
|
|
2677
|
+
|
|
2678
|
+
/**
|
|
2679
|
+
* Dropbox Storage Module
|
|
2680
|
+
* Implements file operations using Dropbox API via the official SDK
|
|
2681
|
+
*/
|
|
2682
|
+
|
|
2683
|
+
declare class DropboxModule extends BaseStorageModule {
|
|
2684
|
+
readonly provider: StorageProvider;
|
|
2685
|
+
private auth;
|
|
2686
|
+
private dbx;
|
|
2687
|
+
private rootPath;
|
|
2688
|
+
private authCallbacks;
|
|
2689
|
+
/**
|
|
2690
|
+
* Set authentication callbacks for token persistence
|
|
2691
|
+
*/
|
|
2692
|
+
setAuthCallbacks(callbacks: DropboxAuthCallbacks): void;
|
|
2693
|
+
initialize(config: HazoFilesConfig): Promise<void>;
|
|
2694
|
+
/**
|
|
2695
|
+
* Create/recreate the Dropbox SDK client with the current access token
|
|
2696
|
+
*/
|
|
2697
|
+
private createDropboxClient;
|
|
2698
|
+
/**
|
|
2699
|
+
* Get the auth instance for OAuth flow
|
|
2700
|
+
*/
|
|
2701
|
+
getAuth(): DropboxAuth;
|
|
2702
|
+
/**
|
|
2703
|
+
* Check if user is authenticated
|
|
2704
|
+
*/
|
|
2705
|
+
isAuthenticated(): boolean;
|
|
2706
|
+
/**
|
|
2707
|
+
* Authenticate with provided tokens
|
|
2708
|
+
*/
|
|
2709
|
+
authenticate(tokens: DropboxTokenData): Promise<void>;
|
|
2710
|
+
/**
|
|
2711
|
+
* Ensure authenticated before operations
|
|
2712
|
+
*/
|
|
2713
|
+
private ensureAuthenticated;
|
|
2714
|
+
/**
|
|
2715
|
+
* Convert virtual path to Dropbox path
|
|
2716
|
+
* Virtual: /folder/file.txt -> Dropbox: /folder/file.txt (or /rootPath/folder/file.txt)
|
|
2717
|
+
* Dropbox root is empty string "", not "/"
|
|
2718
|
+
*/
|
|
2719
|
+
private toDropboxPath;
|
|
2720
|
+
/**
|
|
2721
|
+
* Convert Dropbox metadata to FileSystemItem
|
|
2722
|
+
*/
|
|
2723
|
+
private metadataToItem;
|
|
2724
|
+
/**
|
|
2725
|
+
* Convert a Dropbox path_display to virtual path
|
|
2726
|
+
*/
|
|
2727
|
+
private toVirtualPath;
|
|
2728
|
+
createDirectory(virtualPath: string): Promise<OperationResult<FolderItem>>;
|
|
2729
|
+
removeDirectory(virtualPath: string, recursive?: boolean): Promise<OperationResult>;
|
|
2730
|
+
uploadFile(source: string | Buffer | ReadableStream, remotePath: string, options?: UploadOptions): Promise<OperationResult<FileItem>>;
|
|
2731
|
+
downloadFile(remotePath: string, localPath?: string, options?: DownloadOptions): Promise<OperationResult<Buffer | string>>;
|
|
2732
|
+
moveItem(sourcePath: string, destinationPath: string, _options?: MoveOptions): Promise<OperationResult<FileSystemItem>>;
|
|
2733
|
+
deleteFile(virtualPath: string): Promise<OperationResult>;
|
|
2734
|
+
renameFile(virtualPath: string, newName: string, _options?: RenameOptions): Promise<OperationResult<FileItem>>;
|
|
2735
|
+
renameFolder(virtualPath: string, newName: string, _options?: RenameOptions): Promise<OperationResult<FolderItem>>;
|
|
2736
|
+
listDirectory(virtualPath: string, options?: ListOptions): Promise<OperationResult<FileSystemItem[]>>;
|
|
2737
|
+
getItem(virtualPath: string): Promise<OperationResult<FileSystemItem>>;
|
|
2738
|
+
exists(virtualPath: string): Promise<boolean>;
|
|
2739
|
+
getFolderTree(path?: string, depth?: number): Promise<OperationResult<TreeNode[]>>;
|
|
2740
|
+
}
|
|
2741
|
+
/**
|
|
2742
|
+
* Factory function to create a DropboxModule instance
|
|
2743
|
+
*/
|
|
2744
|
+
declare function createDropboxModule(): DropboxModule;
|
|
2745
|
+
|
|
2459
2746
|
/**
|
|
2460
2747
|
* Module Registry
|
|
2461
2748
|
* Central registry for all storage modules
|
|
@@ -2929,4 +3216,4 @@ declare function toV2Record(record: FileMetadataRecord): FileMetadataRecordV2;
|
|
|
2929
3216
|
*/
|
|
2930
3217
|
declare function buildFileWithStatus(record: FileMetadataRecord): FileWithStatus;
|
|
2931
3218
|
|
|
2932
|
-
export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AuthCallbacks, AuthenticationError, type CleanupOrphanedOptions, ConfigurationError, 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_NAMING_DEFAULT_TABLE_NAME, HAZO_FILES_NAMING_TABLE_SCHEMA, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesMigrationV2, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesServerInstance, type HazoFilesServerOptions, type HazoFilesTableSchema, type HazoLLMInstance, type HazoLogger, 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, createBasicFileManager, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFileRef, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createHazoFilesServer, 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, 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, normalizePath, parseConfig, parseFileData, parseFileRefs, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
|
|
3219
|
+
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 HazoFilesServerInstance, type HazoFilesServerOptions, type HazoFilesTableSchema, type HazoLLMInstance, type HazoLogger, 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, createBasicFileManager, createDropboxAuth, createDropboxModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFileRef, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createHazoFilesServer, 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 };
|