hazo_files 1.4.0 → 1.4.2
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 +114 -0
- package/dist/index.d.mts +392 -1
- package/dist/index.d.ts +392 -1
- package/dist/index.js +598 -8
- package/dist/index.mjs +586 -8
- package/dist/server/index.d.mts +392 -1
- package/dist/server/index.d.ts +392 -1
- package/dist/server/index.js +598 -8
- package/dist/server/index.mjs +586 -8
- package/package.json +1 -1
package/dist/server/index.d.mts
CHANGED
|
@@ -179,6 +179,12 @@ interface FileMetadataInput {
|
|
|
179
179
|
file_hash?: string;
|
|
180
180
|
/** File size in bytes */
|
|
181
181
|
file_size?: number;
|
|
182
|
+
/** Scope ID for organizational grouping (V2) */
|
|
183
|
+
scope_id?: string;
|
|
184
|
+
/** User who uploaded the file (V2) */
|
|
185
|
+
uploaded_by?: string;
|
|
186
|
+
/** Original filename at upload time (V2) */
|
|
187
|
+
original_filename?: string;
|
|
182
188
|
}
|
|
183
189
|
/**
|
|
184
190
|
* Input for updating an existing metadata record
|
|
@@ -354,6 +360,135 @@ interface ListNamingConventionsOptions {
|
|
|
354
360
|
includeGlobal?: boolean;
|
|
355
361
|
}
|
|
356
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Reference Tracking Types for hazo_files
|
|
365
|
+
* Supports multi-entity file references with lifecycle management
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
/** Status of a file in the system */
|
|
369
|
+
type FileStatus = 'active' | 'orphaned' | 'soft_deleted' | 'missing';
|
|
370
|
+
/** Visibility level for a file reference */
|
|
371
|
+
type FileRefVisibility = 'public' | 'private' | 'internal';
|
|
372
|
+
/**
|
|
373
|
+
* A reference from an entity to a file.
|
|
374
|
+
* Multiple entities can reference the same file.
|
|
375
|
+
*/
|
|
376
|
+
interface FileRef {
|
|
377
|
+
/** Unique ID for this reference */
|
|
378
|
+
ref_id: string;
|
|
379
|
+
/** Type of entity referencing the file (e.g., 'form_field', 'chat_message') */
|
|
380
|
+
entity_type: string;
|
|
381
|
+
/** ID of the entity referencing the file */
|
|
382
|
+
entity_id: string;
|
|
383
|
+
/** ISO timestamp when reference was created */
|
|
384
|
+
created_at: string;
|
|
385
|
+
/** User or system that created this reference */
|
|
386
|
+
created_by?: string;
|
|
387
|
+
/** Visibility of this reference */
|
|
388
|
+
visibility?: FileRefVisibility;
|
|
389
|
+
/** Optional label for the reference */
|
|
390
|
+
label?: string;
|
|
391
|
+
/** Optional metadata for the reference */
|
|
392
|
+
metadata?: Record<string, unknown>;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Extended metadata record with reference tracking fields.
|
|
396
|
+
* Extends FileMetadataRecord with V2 columns.
|
|
397
|
+
*/
|
|
398
|
+
interface FileMetadataRecordV2 extends FileMetadataRecord {
|
|
399
|
+
/** JSON string of FileRef[] - parsed by service methods */
|
|
400
|
+
file_refs: string;
|
|
401
|
+
/** Number of active references (denormalized for queries) */
|
|
402
|
+
ref_count: number;
|
|
403
|
+
/** Current file status */
|
|
404
|
+
status: FileStatus;
|
|
405
|
+
/** Scope ID for organizational grouping (e.g., workspace, tenant) */
|
|
406
|
+
scope_id?: string | null;
|
|
407
|
+
/** User who uploaded the file */
|
|
408
|
+
uploaded_by?: string | null;
|
|
409
|
+
/** Original filename at upload time */
|
|
410
|
+
original_filename?: string | null;
|
|
411
|
+
/** ISO timestamp when storage was last verified */
|
|
412
|
+
storage_verified_at?: string | null;
|
|
413
|
+
/** ISO timestamp when file was soft-deleted */
|
|
414
|
+
deleted_at?: string | null;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Options for adding a reference to a file
|
|
418
|
+
*/
|
|
419
|
+
interface AddRefOptions {
|
|
420
|
+
/** Type of entity referencing the file */
|
|
421
|
+
entity_type: string;
|
|
422
|
+
/** ID of the entity referencing the file */
|
|
423
|
+
entity_id: string;
|
|
424
|
+
/** User creating the reference */
|
|
425
|
+
created_by?: string;
|
|
426
|
+
/** Visibility of the reference */
|
|
427
|
+
visibility?: FileRefVisibility;
|
|
428
|
+
/** Optional label */
|
|
429
|
+
label?: string;
|
|
430
|
+
/** Optional metadata */
|
|
431
|
+
metadata?: Record<string, unknown>;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Criteria for removing references.
|
|
435
|
+
* All specified fields must match (AND semantics).
|
|
436
|
+
*/
|
|
437
|
+
interface RemoveRefsCriteria {
|
|
438
|
+
/** Match by entity type */
|
|
439
|
+
entity_type?: string;
|
|
440
|
+
/** Match by entity ID */
|
|
441
|
+
entity_id?: string;
|
|
442
|
+
/** Match by scope ID on the file record */
|
|
443
|
+
scope_id?: string;
|
|
444
|
+
/** Match by specific file ID */
|
|
445
|
+
file_id?: string;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Rich status view of a file with parsed references
|
|
449
|
+
*/
|
|
450
|
+
interface FileWithStatus {
|
|
451
|
+
/** Full metadata record (V2) */
|
|
452
|
+
record: FileMetadataRecordV2;
|
|
453
|
+
/** Parsed file references */
|
|
454
|
+
refs: FileRef[];
|
|
455
|
+
/** Whether the file has zero references */
|
|
456
|
+
is_orphaned: boolean;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Options for finding orphaned files
|
|
460
|
+
*/
|
|
461
|
+
interface FindOrphanedOptions {
|
|
462
|
+
/** Only find orphans older than this duration (ISO 8601 duration or ms) */
|
|
463
|
+
olderThanMs?: number;
|
|
464
|
+
/** Filter by scope */
|
|
465
|
+
scope_id?: string;
|
|
466
|
+
/** Filter by storage type */
|
|
467
|
+
storage_type?: StorageProvider;
|
|
468
|
+
/** Maximum number of results */
|
|
469
|
+
limit?: number;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Options for cleaning up orphaned files
|
|
473
|
+
*/
|
|
474
|
+
interface CleanupOrphanedOptions extends FindOrphanedOptions {
|
|
475
|
+
/** If true, only soft-delete rather than permanently removing (default: false) */
|
|
476
|
+
softDeleteOnly?: boolean;
|
|
477
|
+
/** If true, also delete physical files (default: true) */
|
|
478
|
+
deletePhysicalFiles?: boolean;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Options for uploading a file with an initial reference
|
|
482
|
+
*/
|
|
483
|
+
interface UploadWithRefOptions {
|
|
484
|
+
/** Reference to add after upload */
|
|
485
|
+
ref?: AddRefOptions;
|
|
486
|
+
/** Scope ID for the file */
|
|
487
|
+
scope_id?: string;
|
|
488
|
+
/** User performing the upload */
|
|
489
|
+
uploaded_by?: string;
|
|
490
|
+
}
|
|
491
|
+
|
|
357
492
|
/**
|
|
358
493
|
* Core types for the hazo_files package
|
|
359
494
|
*/
|
|
@@ -813,6 +948,67 @@ declare class FileMetadataService {
|
|
|
813
948
|
* Clear all extractions for a file
|
|
814
949
|
*/
|
|
815
950
|
clearExtractions(path: string, storageType: StorageProvider): Promise<boolean>;
|
|
951
|
+
/**
|
|
952
|
+
* Find a record by ID
|
|
953
|
+
*/
|
|
954
|
+
findById(id: string): Promise<FileMetadataRecord | null>;
|
|
955
|
+
/**
|
|
956
|
+
* Find multiple records by IDs
|
|
957
|
+
*/
|
|
958
|
+
findByIds(ids: string[]): Promise<FileMetadataRecord[]>;
|
|
959
|
+
/**
|
|
960
|
+
* Add a reference to a file
|
|
961
|
+
* @returns The new ref_id, or null on failure
|
|
962
|
+
*/
|
|
963
|
+
addRef(fileId: string, options: AddRefOptions): Promise<{
|
|
964
|
+
ref_id: string;
|
|
965
|
+
} | null>;
|
|
966
|
+
/**
|
|
967
|
+
* Remove a specific reference from a file
|
|
968
|
+
* @returns Remaining ref count, or null on failure
|
|
969
|
+
*/
|
|
970
|
+
removeRef(fileId: string, refId: string): Promise<{
|
|
971
|
+
remaining_refs: number;
|
|
972
|
+
} | null>;
|
|
973
|
+
/**
|
|
974
|
+
* Remove references matching criteria across all records.
|
|
975
|
+
* Scans all records and removes matching refs (AND semantics).
|
|
976
|
+
*/
|
|
977
|
+
removeRefsByCriteria(criteria: RemoveRefsCriteria): Promise<{
|
|
978
|
+
removed_count: number;
|
|
979
|
+
}>;
|
|
980
|
+
/**
|
|
981
|
+
* Helper: remove matching refs from a single record
|
|
982
|
+
*/
|
|
983
|
+
private removeRefsFromRecord;
|
|
984
|
+
/**
|
|
985
|
+
* Get all references for a file
|
|
986
|
+
*/
|
|
987
|
+
getRefs(fileId: string): Promise<FileRef[] | null>;
|
|
988
|
+
/**
|
|
989
|
+
* Get a file with its status and parsed refs
|
|
990
|
+
*/
|
|
991
|
+
getFileWithStatus(fileId: string): Promise<FileWithStatus | null>;
|
|
992
|
+
/**
|
|
993
|
+
* Get multiple files with status
|
|
994
|
+
*/
|
|
995
|
+
getFilesWithStatus(fileIds: string[]): Promise<FileWithStatus[]>;
|
|
996
|
+
/**
|
|
997
|
+
* Update the status of a file
|
|
998
|
+
*/
|
|
999
|
+
updateStatus(fileId: string, status: FileStatus): Promise<boolean>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Soft-delete a file (set status to soft_deleted, record deleted_at)
|
|
1002
|
+
*/
|
|
1003
|
+
softDelete(fileId: string): Promise<boolean>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Update specific V2 fields on a record
|
|
1006
|
+
*/
|
|
1007
|
+
updateFields(fileId: string, fields: Partial<Pick<FileMetadataRecordV2, 'scope_id' | 'uploaded_by' | 'original_filename' | 'storage_verified_at' | 'status'>>): Promise<boolean>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Find orphaned files (zero references)
|
|
1010
|
+
*/
|
|
1011
|
+
findOrphaned(options?: FindOrphanedOptions): Promise<FileWithStatus[]>;
|
|
816
1012
|
}
|
|
817
1013
|
/**
|
|
818
1014
|
* Create a FileMetadataService instance
|
|
@@ -953,6 +1149,52 @@ declare class TrackedFileManager extends FileManager {
|
|
|
953
1149
|
* @returns Stored size in bytes or null if not found/not tracked
|
|
954
1150
|
*/
|
|
955
1151
|
getStoredSize(path: string): Promise<number | null>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Add a reference to a file
|
|
1154
|
+
*/
|
|
1155
|
+
addRef(fileId: string, options: AddRefOptions): Promise<{
|
|
1156
|
+
ref_id: string;
|
|
1157
|
+
} | null>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Remove a reference from a file
|
|
1160
|
+
*/
|
|
1161
|
+
removeRef(fileId: string, refId: string): Promise<{
|
|
1162
|
+
remaining_refs: number;
|
|
1163
|
+
} | null>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Get a file by its database ID with status information
|
|
1166
|
+
*/
|
|
1167
|
+
getFileById(fileId: string): Promise<FileWithStatus | null>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Get multiple files by their database IDs with status information
|
|
1170
|
+
*/
|
|
1171
|
+
getFilesById(fileIds: string[]): Promise<FileWithStatus[]>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Soft-delete a file (marks as soft_deleted, does not remove physical file)
|
|
1174
|
+
*/
|
|
1175
|
+
softDeleteFile(fileId: string): Promise<boolean>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Find orphaned files (files with zero references)
|
|
1178
|
+
*/
|
|
1179
|
+
findOrphanedFiles(options?: FindOrphanedOptions): Promise<FileWithStatus[]>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Cleanup orphaned files — removes physical files and/or DB records
|
|
1182
|
+
*/
|
|
1183
|
+
cleanupOrphanedFiles(options?: CleanupOrphanedOptions): Promise<{
|
|
1184
|
+
cleaned: number;
|
|
1185
|
+
errors: string[];
|
|
1186
|
+
}>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Verify that a file's physical storage exists and update its status
|
|
1189
|
+
*/
|
|
1190
|
+
verifyFileExistence(fileId: string): Promise<boolean | null>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Upload a file and optionally add an initial reference
|
|
1193
|
+
*/
|
|
1194
|
+
uploadFileWithRef(source: string | Buffer | ReadableStream, remotePath: string, options?: TrackedUploadOptions & UploadWithRefOptions): Promise<OperationResult<FileItem & {
|
|
1195
|
+
file_id?: string;
|
|
1196
|
+
ref_id?: string;
|
|
1197
|
+
}>>;
|
|
956
1198
|
}
|
|
957
1199
|
/**
|
|
958
1200
|
* Create a new TrackedFileManager instance
|
|
@@ -1605,6 +1847,22 @@ interface HazoFilesColumnDefinitions {
|
|
|
1605
1847
|
file_size: 'INTEGER' | 'BIGINT';
|
|
1606
1848
|
/** ISO timestamp when file content last changed */
|
|
1607
1849
|
file_changed_at: 'TEXT' | 'TIMESTAMP';
|
|
1850
|
+
/** JSON string of FileRef[] - reference tracking (V2) */
|
|
1851
|
+
file_refs: 'TEXT';
|
|
1852
|
+
/** Number of active references (V2) */
|
|
1853
|
+
ref_count: 'INTEGER';
|
|
1854
|
+
/** File status: active, orphaned, soft_deleted, missing (V2) */
|
|
1855
|
+
status: 'TEXT';
|
|
1856
|
+
/** Scope ID for organizational grouping (V2) */
|
|
1857
|
+
scope_id: 'TEXT' | 'UUID';
|
|
1858
|
+
/** User who uploaded the file (V2) */
|
|
1859
|
+
uploaded_by: 'TEXT' | 'UUID';
|
|
1860
|
+
/** ISO timestamp when storage was last verified (V2) */
|
|
1861
|
+
storage_verified_at: 'TEXT' | 'TIMESTAMP';
|
|
1862
|
+
/** ISO timestamp when file was soft-deleted (V2) */
|
|
1863
|
+
deleted_at: 'TEXT' | 'TIMESTAMP';
|
|
1864
|
+
/** Original filename at upload time (V2) */
|
|
1865
|
+
original_filename: 'TEXT';
|
|
1608
1866
|
}
|
|
1609
1867
|
/**
|
|
1610
1868
|
* Schema definition for a specific database type
|
|
@@ -1667,6 +1925,57 @@ declare const HAZO_FILES_TABLE_SCHEMA: HazoFilesTableSchema;
|
|
|
1667
1925
|
* @returns DDL and index statements with the custom table name
|
|
1668
1926
|
*/
|
|
1669
1927
|
declare function getSchemaForTable(tableName: string, dbType: 'sqlite' | 'postgres'): DatabaseSchemaDefinition;
|
|
1928
|
+
/**
|
|
1929
|
+
* Migration schema for adding V2 reference tracking columns to existing tables.
|
|
1930
|
+
* Idempotent — safe to run multiple times (uses IF NOT EXISTS for indexes,
|
|
1931
|
+
* and ALTER TABLE ADD COLUMN is ignored if column exists in SQLite).
|
|
1932
|
+
*
|
|
1933
|
+
* For PostgreSQL, columns are added with IF NOT EXISTS (PG 9.6+).
|
|
1934
|
+
*
|
|
1935
|
+
* @example
|
|
1936
|
+
* ```typescript
|
|
1937
|
+
* import { HAZO_FILES_MIGRATION_V2 } from 'hazo_files';
|
|
1938
|
+
*
|
|
1939
|
+
* // SQLite
|
|
1940
|
+
* for (const stmt of HAZO_FILES_MIGRATION_V2.sqlite.alterStatements) {
|
|
1941
|
+
* try { await db.run(stmt); } catch { /* column already exists *\/ }
|
|
1942
|
+
* }
|
|
1943
|
+
* for (const idx of HAZO_FILES_MIGRATION_V2.sqlite.indexes) {
|
|
1944
|
+
* await db.run(idx);
|
|
1945
|
+
* }
|
|
1946
|
+
*
|
|
1947
|
+
* // PostgreSQL
|
|
1948
|
+
* for (const stmt of HAZO_FILES_MIGRATION_V2.postgres.alterStatements) {
|
|
1949
|
+
* await client.query(stmt);
|
|
1950
|
+
* }
|
|
1951
|
+
* for (const idx of HAZO_FILES_MIGRATION_V2.postgres.indexes) {
|
|
1952
|
+
* await client.query(idx);
|
|
1953
|
+
* }
|
|
1954
|
+
* ```
|
|
1955
|
+
*/
|
|
1956
|
+
interface MigrationSchemaDefinition {
|
|
1957
|
+
/** ALTER TABLE statements to add new columns */
|
|
1958
|
+
alterStatements: string[];
|
|
1959
|
+
/** CREATE INDEX statements for new columns */
|
|
1960
|
+
indexes: string[];
|
|
1961
|
+
/** UPDATE statement to backfill defaults for existing records */
|
|
1962
|
+
backfill: string;
|
|
1963
|
+
}
|
|
1964
|
+
interface HazoFilesMigrationV2 {
|
|
1965
|
+
/** Default table name */
|
|
1966
|
+
tableName: string;
|
|
1967
|
+
/** SQLite migration statements */
|
|
1968
|
+
sqlite: MigrationSchemaDefinition;
|
|
1969
|
+
/** PostgreSQL migration statements */
|
|
1970
|
+
postgres: MigrationSchemaDefinition;
|
|
1971
|
+
/** New column names added in V2 */
|
|
1972
|
+
newColumns: readonly string[];
|
|
1973
|
+
}
|
|
1974
|
+
declare const HAZO_FILES_MIGRATION_V2: HazoFilesMigrationV2;
|
|
1975
|
+
/**
|
|
1976
|
+
* Get migration statements for a custom table name
|
|
1977
|
+
*/
|
|
1978
|
+
declare function getMigrationForTable(tableName: string, dbType: 'sqlite' | 'postgres'): MigrationSchemaDefinition;
|
|
1670
1979
|
/**
|
|
1671
1980
|
* Default table name for naming conventions
|
|
1672
1981
|
*/
|
|
@@ -1737,6 +2046,47 @@ declare const HAZO_FILES_NAMING_TABLE_SCHEMA: HazoFilesNamingTableSchema;
|
|
|
1737
2046
|
*/
|
|
1738
2047
|
declare function getNamingSchemaForTable(tableName: string, dbType: 'sqlite' | 'postgres'): DatabaseSchemaDefinition;
|
|
1739
2048
|
|
|
2049
|
+
/**
|
|
2050
|
+
* Migration: Add Reference Tracking (V2)
|
|
2051
|
+
*
|
|
2052
|
+
* Adds reference tracking columns to an existing hazo_files table.
|
|
2053
|
+
* Idempotent — safe to run multiple times.
|
|
2054
|
+
*/
|
|
2055
|
+
/**
|
|
2056
|
+
* Executor interface for running SQL statements.
|
|
2057
|
+
* Compatible with common database adapters (better-sqlite3, pg, hazo_connect).
|
|
2058
|
+
*/
|
|
2059
|
+
interface MigrationExecutor {
|
|
2060
|
+
run(sql: string): Promise<void> | void;
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Run the V2 migration: add reference tracking columns and indexes.
|
|
2064
|
+
*
|
|
2065
|
+
* @param executor - Object with a `run(sql)` method
|
|
2066
|
+
* @param dbType - Database type ('sqlite' | 'postgres')
|
|
2067
|
+
* @param tableName - Custom table name (defaults to 'hazo_files')
|
|
2068
|
+
*
|
|
2069
|
+
* @example
|
|
2070
|
+
* ```typescript
|
|
2071
|
+
* import { migrateToV2 } from 'hazo_files';
|
|
2072
|
+
*
|
|
2073
|
+
* // SQLite with better-sqlite3
|
|
2074
|
+
* await migrateToV2({ run: (sql) => db.exec(sql) }, 'sqlite');
|
|
2075
|
+
*
|
|
2076
|
+
* // PostgreSQL with pg
|
|
2077
|
+
* await migrateToV2({ run: (sql) => client.query(sql) }, 'postgres');
|
|
2078
|
+
* ```
|
|
2079
|
+
*/
|
|
2080
|
+
declare function migrateToV2(executor: MigrationExecutor, dbType: 'sqlite' | 'postgres', tableName?: string): Promise<void>;
|
|
2081
|
+
/**
|
|
2082
|
+
* Backfill V2 defaults for existing records that have NULL V2 columns.
|
|
2083
|
+
*
|
|
2084
|
+
* @param executor - Object with a `run(sql)` method
|
|
2085
|
+
* @param dbType - Database type ('sqlite' | 'postgres')
|
|
2086
|
+
* @param tableName - Custom table name (defaults to 'hazo_files')
|
|
2087
|
+
*/
|
|
2088
|
+
declare function backfillV2Defaults(executor: MigrationExecutor, dbType: 'sqlite' | 'postgres', tableName?: string): Promise<void>;
|
|
2089
|
+
|
|
1740
2090
|
/**
|
|
1741
2091
|
* Common utility functions
|
|
1742
2092
|
*/
|
|
@@ -2538,4 +2888,45 @@ declare function hashesEqual(hash1: string | null | undefined, hash2: string | n
|
|
|
2538
2888
|
*/
|
|
2539
2889
|
declare function hasFileContentChanged(oldHash: string | null | undefined, newBuffer: Buffer): Promise<boolean>;
|
|
2540
2890
|
|
|
2541
|
-
|
|
2891
|
+
/**
|
|
2892
|
+
* Reference Tracking Utilities
|
|
2893
|
+
* Pure functions for managing file references within the file_refs JSON field
|
|
2894
|
+
*/
|
|
2895
|
+
|
|
2896
|
+
/**
|
|
2897
|
+
* Generate a unique reference ID
|
|
2898
|
+
*/
|
|
2899
|
+
declare function generateRefId(): string;
|
|
2900
|
+
/**
|
|
2901
|
+
* Parse a JSON string into FileRef array.
|
|
2902
|
+
* Returns empty array on invalid input.
|
|
2903
|
+
*/
|
|
2904
|
+
declare function parseFileRefs(json: string | null | undefined): FileRef[];
|
|
2905
|
+
/**
|
|
2906
|
+
* Serialize FileRef array to JSON string
|
|
2907
|
+
*/
|
|
2908
|
+
declare function stringifyFileRefs(refs: FileRef[]): string;
|
|
2909
|
+
/**
|
|
2910
|
+
* Create a FileRef from AddRefOptions
|
|
2911
|
+
*/
|
|
2912
|
+
declare function createFileRef(options: AddRefOptions): FileRef;
|
|
2913
|
+
/**
|
|
2914
|
+
* Remove a ref by ref_id (immutable)
|
|
2915
|
+
*/
|
|
2916
|
+
declare function removeRefFromArray(refs: FileRef[], refId: string): FileRef[];
|
|
2917
|
+
/**
|
|
2918
|
+
* Remove refs matching criteria from array (immutable).
|
|
2919
|
+
* All specified criteria fields must match (AND semantics).
|
|
2920
|
+
*/
|
|
2921
|
+
declare function removeRefsByCriteriaFromArray(refs: FileRef[], criteria: Omit<RemoveRefsCriteria, 'file_id' | 'scope_id'>): FileRef[];
|
|
2922
|
+
/**
|
|
2923
|
+
* Safely cast a FileMetadataRecord to FileMetadataRecordV2.
|
|
2924
|
+
* Missing V2 fields are defaulted.
|
|
2925
|
+
*/
|
|
2926
|
+
declare function toV2Record(record: FileMetadataRecord): FileMetadataRecordV2;
|
|
2927
|
+
/**
|
|
2928
|
+
* Build a FileWithStatus view from a record
|
|
2929
|
+
*/
|
|
2930
|
+
declare function buildFileWithStatus(record: FileMetadataRecord): FileWithStatus;
|
|
2931
|
+
|
|
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 };
|