hazo_files 3.0.0 → 3.1.0
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/CHANGE_LOG.md +24 -0
- package/README.md +45 -2
- package/dist/index.d.mts +125 -1
- package/dist/index.d.ts +125 -1
- package/dist/index.js +418 -0
- package/dist/index.mjs +422 -0
- package/dist/server/index.d.mts +84 -1
- package/dist/server/index.d.ts +84 -1
- package/dist/server/index.js +264 -0
- package/dist/server/index.mjs +265 -1
- package/dist/testing/index.d.mts +37 -0
- package/dist/testing/index.d.ts +37 -0
- package/dist/testing/index.js +33 -0
- package/dist/testing/index.mjs +33 -0
- package/package.json +10 -10
package/CHANGE_LOG.md
CHANGED
|
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 3.1.0 — 2026-06-11
|
|
9
|
+
|
|
10
|
+
**Additive** — no breaking changes from 3.0.x.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **`FileStorageProvider` parity methods** — `list`, `move`, and `rename` added to the interface and implemented across all three providers:
|
|
15
|
+
- `AppFileServerProvider.list(prefix)` — recursive filesystem walk; returns `FileEntry[]`.
|
|
16
|
+
- `AppFileServerProvider.move(from, to)` — atomic `renameSync` with automatic EXDEV (cross-device) fallback to copy+delete.
|
|
17
|
+
- `AppFileServerProvider.rename(from, to)` — delegates to `move`.
|
|
18
|
+
- `InMemoryProvider.list(prefix)` — returns entries for all keys under the prefix, including synthetic directory entries.
|
|
19
|
+
- `InMemoryProvider.move(from, to)` / `rename` — in-place store key reassignment.
|
|
20
|
+
- `GoogleDriveProvider.list(prefix)` — single-level Drive API query; returns immediate children.
|
|
21
|
+
- `GoogleDriveProvider.move(from, to)` — Drive `files.update` with parent-change and rename; invalidates path cache entry.
|
|
22
|
+
- `GoogleDriveProvider.rename(from, to)` — Drive `files.update` rename only.
|
|
23
|
+
- **`FileEntry` type** — returned by `list()`; carries `path`, `name`, `size`, and `isDirectory`. Exported from both `hazo_files` and `hazo_files/server`.
|
|
24
|
+
|
|
25
|
+
### Test-app improvements
|
|
26
|
+
|
|
27
|
+
- Fixed 4 failing autotest scenarios: envelope assertion (`{success,data}` shape), correct `naming_title` field, required `action` param for naming generation, required `scope_id` for quota.
|
|
28
|
+
- Added 9 new autotest scenarios covering file CRUD, rename/move, metadata listing, naming-convention full CRUD, advanced name generation, quota lifecycle + threshold events, SSRF rejection, LLM status, and upload-extract wiring.
|
|
29
|
+
- Fixed missing **Run All** button: added `hazo_ui/dist` to `tailwind.config.ts` content globs so the harness runner's Tailwind classes are compiled.
|
|
30
|
+
- Bumped `lucide-react` from `^0.294.0` → `^0.553.0` to resolve `OctagonAlert` import error from `hazo_ui`.
|
|
31
|
+
|
|
8
32
|
## 3.0.0 — 2026-05-29
|
|
9
33
|
|
|
10
34
|
### Breaking changes (Wave 2 standardisation)
|
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
|
-
- **`FileStorageProvider` Interface**: Lightweight `put/get/delete/exists/getSignedUrl/probe` abstraction for simpler use cases
|
|
10
|
+
- **`FileStorageProvider` Interface**: Lightweight `put/get/delete/exists/getSignedUrl/probe/list/move/rename` abstraction for simpler use cases
|
|
11
11
|
- **`AppFileServerProvider`**: Local filesystem + HMAC-signed download URLs — no cloud account required
|
|
12
12
|
- **`GoogleDriveProvider`**: Service-account Google Drive for Shared Drives with lazy path-cache
|
|
13
13
|
- **`InMemoryProvider`**: Zero-dependency in-memory store for unit tests (via `hazo_files/testing`)
|
|
@@ -64,6 +64,7 @@ npm install dropbox # Dropbox support
|
|
|
64
64
|
For database tracking and LLM extraction features (optional):
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
+
npm install hazo_core # Error classes, logger, config (peer of all hazo_* packages)
|
|
67
68
|
npm install hazo_connect # Database tracking
|
|
68
69
|
npm install hazo_llm_api # LLM document extraction
|
|
69
70
|
npm install server-only # Server-side safety (recommended)
|
|
@@ -1999,15 +2000,31 @@ v2 introduces a slimmer storage abstraction — `FileStorageProvider` — that s
|
|
|
1999
2000
|
### Interface
|
|
2000
2001
|
|
|
2001
2002
|
```typescript
|
|
2002
|
-
import type { FileStorageProvider } from 'hazo_files/server';
|
|
2003
|
+
import type { FileStorageProvider, FileEntry } from 'hazo_files/server';
|
|
2003
2004
|
|
|
2004
2005
|
interface FileStorageProvider {
|
|
2006
|
+
// Core CRUD
|
|
2005
2007
|
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
2006
2008
|
get(path: string): Promise<Buffer | Readable>;
|
|
2007
2009
|
delete(path: string): Promise<void>;
|
|
2008
2010
|
exists(path: string): Promise<boolean>;
|
|
2009
2011
|
getSignedUrl(path: string, opts?: SignedUrlOpts): Promise<string>;
|
|
2010
2012
|
probe(): Promise<ProbeResult>;
|
|
2013
|
+
|
|
2014
|
+
// v3.1 — parity methods
|
|
2015
|
+
/** List all files and sub-directories under a prefix (recursive). */
|
|
2016
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
2017
|
+
/** Move bytes from `from` to `to`, removing the source on success. */
|
|
2018
|
+
move(from: string, to: string): Promise<void>;
|
|
2019
|
+
/** Rename — equivalent to move when the parent directory stays the same. */
|
|
2020
|
+
rename(from: string, to: string): Promise<void>;
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
interface FileEntry {
|
|
2024
|
+
path: string; // logical path (same namespace as put/get)
|
|
2025
|
+
name: string; // bare filename or directory name
|
|
2026
|
+
size: number; // bytes; 0 for directories
|
|
2027
|
+
isDirectory: boolean;
|
|
2011
2028
|
}
|
|
2012
2029
|
```
|
|
2013
2030
|
|
|
@@ -2122,6 +2139,32 @@ const url = await store.getSignedUrl('docs/readme.txt');
|
|
|
2122
2139
|
// 'data:application/octet-stream;base64,aGVsbG8='
|
|
2123
2140
|
```
|
|
2124
2141
|
|
|
2142
|
+
### list / move / rename (v3.1)
|
|
2143
|
+
|
|
2144
|
+
All three providers now implement `list`, `move`, and `rename`:
|
|
2145
|
+
|
|
2146
|
+
```typescript
|
|
2147
|
+
import { AppFileServerProvider } from 'hazo_files/server';
|
|
2148
|
+
import type { FileEntry } from 'hazo_files/server';
|
|
2149
|
+
|
|
2150
|
+
const provider = new AppFileServerProvider({ root: './storage', hmac_secret: '...' });
|
|
2151
|
+
|
|
2152
|
+
// List all files and sub-directories under a prefix (recursive)
|
|
2153
|
+
const entries: FileEntry[] = await provider.list('uploads/2026');
|
|
2154
|
+
// [
|
|
2155
|
+
// { path: 'uploads/2026/ACME', name: 'ACME', size: 0, isDirectory: true },
|
|
2156
|
+
// { path: 'uploads/2026/ACME/invoice.pdf', name: 'invoice.pdf', size: 12345, isDirectory: false },
|
|
2157
|
+
// ]
|
|
2158
|
+
|
|
2159
|
+
// Move a file (source is removed on success; intermediate directories are created)
|
|
2160
|
+
await provider.move('uploads/incoming/report.pdf', 'uploads/2026/ACME/report.pdf');
|
|
2161
|
+
|
|
2162
|
+
// Rename (full new logical path)
|
|
2163
|
+
await provider.rename('uploads/2026/ACME/report.pdf', 'uploads/2026/ACME/report_final.pdf');
|
|
2164
|
+
```
|
|
2165
|
+
|
|
2166
|
+
`AppFileServerProvider.move` handles cross-device (EXDEV) renames transparently by falling back to copy-then-delete. `GoogleDriveProvider.move` updates the Drive file's parent folder and name in a single API call, then invalidates the path-cache entry. `InMemoryProvider` implementations are synchronous key-reassignments — useful for tests that need to exercise rename/move paths.
|
|
2167
|
+
|
|
2125
2168
|
### Provider Errors
|
|
2126
2169
|
|
|
2127
2170
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -3318,6 +3318,22 @@ interface ProbeResult {
|
|
|
3318
3318
|
/** Free-form detail for logging. */
|
|
3319
3319
|
message?: string;
|
|
3320
3320
|
}
|
|
3321
|
+
/**
|
|
3322
|
+
* A single entry returned by `FileStorageProvider.list()`.
|
|
3323
|
+
*
|
|
3324
|
+
* `path` is the same logical namespace used by `put`/`get` — callers can pass
|
|
3325
|
+
* it directly back to those methods without any transformation.
|
|
3326
|
+
*/
|
|
3327
|
+
interface FileEntry {
|
|
3328
|
+
/** Logical path within the provider (same namespace as put/get). */
|
|
3329
|
+
path: StoragePath;
|
|
3330
|
+
/** Bare filename or directory name (the last segment of `path`). */
|
|
3331
|
+
name: string;
|
|
3332
|
+
/** Size in bytes. 0 for directories. */
|
|
3333
|
+
size: number;
|
|
3334
|
+
/** True when this entry represents a directory. */
|
|
3335
|
+
isDirectory: boolean;
|
|
3336
|
+
}
|
|
3321
3337
|
/**
|
|
3322
3338
|
* Storage provider abstraction. Every method MUST be idempotent at the
|
|
3323
3339
|
* data-content level — re-invoking put with identical body is allowed.
|
|
@@ -3332,6 +3348,36 @@ interface FileStorageProvider {
|
|
|
3332
3348
|
getSignedUrl(path: StoragePath, opts?: SignedUrlOpts): Promise<string>;
|
|
3333
3349
|
/** Used by validation cron + onboarding step 2. */
|
|
3334
3350
|
probe(): Promise<ProbeResult>;
|
|
3351
|
+
/**
|
|
3352
|
+
* List all entries (files and sub-directories) under a logical path prefix.
|
|
3353
|
+
* Results are recursive — all descendants are included.
|
|
3354
|
+
* Returns an empty array when the prefix does not exist.
|
|
3355
|
+
*/
|
|
3356
|
+
list(prefix: StoragePath): Promise<FileEntry[]>;
|
|
3357
|
+
/**
|
|
3358
|
+
* Move bytes from `from` to `to`, creating any intermediate directories.
|
|
3359
|
+
* The source is removed on success.
|
|
3360
|
+
* Throws with a message containing "Not found" when `from` does not exist.
|
|
3361
|
+
*/
|
|
3362
|
+
move(from: StoragePath, to: StoragePath): Promise<void>;
|
|
3363
|
+
/**
|
|
3364
|
+
* Rename a file or directory. `to` is the full new logical path.
|
|
3365
|
+
* Implementations may delegate to `move`.
|
|
3366
|
+
* Throws with a message containing "Not found" when `from` does not exist.
|
|
3367
|
+
*/
|
|
3368
|
+
rename(from: StoragePath, to: StoragePath): Promise<void>;
|
|
3369
|
+
}
|
|
3370
|
+
declare class StorageCollisionExhausted extends Error {
|
|
3371
|
+
attempts: number;
|
|
3372
|
+
lastPath: StoragePath;
|
|
3373
|
+
constructor(attempts: number, lastPath: StoragePath);
|
|
3374
|
+
}
|
|
3375
|
+
declare class StorageNotConfigured extends Error {
|
|
3376
|
+
constructor();
|
|
3377
|
+
}
|
|
3378
|
+
declare class StorageUnavailable extends Error {
|
|
3379
|
+
reason: ProbeResult["error"];
|
|
3380
|
+
constructor(reason: ProbeResult["error"], message: string);
|
|
3335
3381
|
}
|
|
3336
3382
|
|
|
3337
3383
|
interface WriteWithCollisionOpts {
|
|
@@ -3370,4 +3416,82 @@ declare function addRef<T extends FileWithRefs>(file: T, ref: FileRef): T;
|
|
|
3370
3416
|
declare function removeRef<T extends FileWithRefs>(file: T, ref_id: string, removed_at: string): T;
|
|
3371
3417
|
declare function countRefs(file: Pick<FileWithRefs, "file_refs">): number;
|
|
3372
3418
|
|
|
3373
|
-
|
|
3419
|
+
interface AppFileServerOpts {
|
|
3420
|
+
/** Filesystem root. All paths are resolved relative to this. */
|
|
3421
|
+
root: string;
|
|
3422
|
+
/** HMAC secret used to sign download URLs. */
|
|
3423
|
+
hmac_secret: string;
|
|
3424
|
+
/** Default signed-URL TTL in seconds. */
|
|
3425
|
+
default_ttl_seconds?: number;
|
|
3426
|
+
}
|
|
3427
|
+
declare class AppFileServerProvider implements FileStorageProvider {
|
|
3428
|
+
readonly provider_tag: "app_file_server";
|
|
3429
|
+
private readonly root;
|
|
3430
|
+
private readonly secret;
|
|
3431
|
+
private readonly default_ttl;
|
|
3432
|
+
constructor(opts: AppFileServerOpts);
|
|
3433
|
+
private resolve;
|
|
3434
|
+
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
3435
|
+
get(path: string): Promise<Buffer>;
|
|
3436
|
+
delete(path: string): Promise<void>;
|
|
3437
|
+
exists(path: string): Promise<boolean>;
|
|
3438
|
+
getSignedUrl(path: string, opts?: SignedUrlOpts): Promise<string>;
|
|
3439
|
+
/** Verify a token produced by `getSignedUrl`. Used by the `/api/files/serve` route. */
|
|
3440
|
+
verifySignedUrl(token: string, path: string): boolean;
|
|
3441
|
+
probe(): Promise<ProbeResult>;
|
|
3442
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
3443
|
+
private walkDir;
|
|
3444
|
+
move(from: string, to: string): Promise<void>;
|
|
3445
|
+
rename(from: string, to: string): Promise<void>;
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
declare class InMemoryProvider implements FileStorageProvider {
|
|
3449
|
+
readonly provider_tag: "in_memory";
|
|
3450
|
+
private readonly store;
|
|
3451
|
+
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
3452
|
+
get(path: string): Promise<Buffer>;
|
|
3453
|
+
delete(path: string): Promise<void>;
|
|
3454
|
+
exists(path: string): Promise<boolean>;
|
|
3455
|
+
getSignedUrl(path: string, _opts?: SignedUrlOpts): Promise<string>;
|
|
3456
|
+
probe(): Promise<ProbeResult>;
|
|
3457
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
3458
|
+
move(from: string, to: string): Promise<void>;
|
|
3459
|
+
rename(from: string, to: string): Promise<void>;
|
|
3460
|
+
/** Test-only escape hatch — exposes the internal store for assertions. */
|
|
3461
|
+
snapshot(): Map<string, Buffer>;
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
interface DrivePathCache {
|
|
3465
|
+
lookup(key: string): Promise<string | null>;
|
|
3466
|
+
write(key: string, folder_id: string): Promise<void>;
|
|
3467
|
+
invalidate(key: string): Promise<void>;
|
|
3468
|
+
}
|
|
3469
|
+
interface GoogleDriveOpts {
|
|
3470
|
+
/** Raw JSON keyfile contents (decoded from GOOGLE_SERVICE_ACCOUNT_JSON env var). */
|
|
3471
|
+
service_account_json: string;
|
|
3472
|
+
/** Target Shared Drive ID. */
|
|
3473
|
+
shared_drive_id: string;
|
|
3474
|
+
/** Lazy folder-ID cache, scoped per Hazodocs org. */
|
|
3475
|
+
path_cache: DrivePathCache;
|
|
3476
|
+
}
|
|
3477
|
+
declare class GoogleDriveProvider implements FileStorageProvider {
|
|
3478
|
+
readonly provider_tag: "gdrive";
|
|
3479
|
+
private readonly drive;
|
|
3480
|
+
private readonly driveId;
|
|
3481
|
+
private readonly cache;
|
|
3482
|
+
constructor(opts: GoogleDriveOpts);
|
|
3483
|
+
probe(): Promise<ProbeResult>;
|
|
3484
|
+
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
3485
|
+
get(path: string): Promise<Buffer>;
|
|
3486
|
+
delete(path: string): Promise<void>;
|
|
3487
|
+
exists(path: string): Promise<boolean>;
|
|
3488
|
+
getSignedUrl(path: string, _opts?: SignedUrlOpts): Promise<string>;
|
|
3489
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
3490
|
+
move(from: string, to: string): Promise<void>;
|
|
3491
|
+
rename(from: string, to: string): Promise<void>;
|
|
3492
|
+
private resolvePath;
|
|
3493
|
+
private findChild;
|
|
3494
|
+
private lookupFileId;
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AppFileServerOpts, AppFileServerProvider, 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 DrivePathCache, DropboxAuth, type DropboxAuthCallbacks, type DropboxAuthConfig, type DropboxConfig, DropboxModule, type DropboxTokenData, type ExtractionData, type ExtractionOptions, type ExtractionResult, type FileBrowserState, type FileDataStructure, type FileEntry, FileExistsError, type FileInfo, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, type FileMetadataRecordV2, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileRef$1 as FileRef, type FileRefVisibility, type FileStatus, type FileStorageProvider, type FileSystemItem, FileTooLargeError, type FileWithRefs, type FileWithStatus, type FindOrphanedOptions, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, type GoogleDriveOpts, GoogleDriveProvider, 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, type HazoFilesMigrationV2, type HazoFilesMigrationV3, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesTableSchema, type HazoLLMInstance, InMemoryProvider, 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, NamingTemplate, type NamingVariable, OperationError, type OperationResult, type ParsedNamingConvention, type PatternSegment, PermissionDeniedError, type ProbeResult, type ProgressCallback, type PutOpts, type PutResult, type RemoveExtractionOptions, type RemoveRefsCriteria, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type SignedUrlOpts, StorageCollisionExhausted, type StorageModule, StorageNotConfigured, type StoragePath, type StorageProvider, StorageUnavailable, 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, type WriteWithCollisionOpts, addExtractionToFileData, addRef, backfillV2Defaults, buildFileWithStatus, clearExtractions, clonePattern, computeFileHash, computeFileHashFromStream, computeFileHashSync, computeFileInfo, countRefs, 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, removeRef, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath, writeWithCollisionRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -3318,6 +3318,22 @@ interface ProbeResult {
|
|
|
3318
3318
|
/** Free-form detail for logging. */
|
|
3319
3319
|
message?: string;
|
|
3320
3320
|
}
|
|
3321
|
+
/**
|
|
3322
|
+
* A single entry returned by `FileStorageProvider.list()`.
|
|
3323
|
+
*
|
|
3324
|
+
* `path` is the same logical namespace used by `put`/`get` — callers can pass
|
|
3325
|
+
* it directly back to those methods without any transformation.
|
|
3326
|
+
*/
|
|
3327
|
+
interface FileEntry {
|
|
3328
|
+
/** Logical path within the provider (same namespace as put/get). */
|
|
3329
|
+
path: StoragePath;
|
|
3330
|
+
/** Bare filename or directory name (the last segment of `path`). */
|
|
3331
|
+
name: string;
|
|
3332
|
+
/** Size in bytes. 0 for directories. */
|
|
3333
|
+
size: number;
|
|
3334
|
+
/** True when this entry represents a directory. */
|
|
3335
|
+
isDirectory: boolean;
|
|
3336
|
+
}
|
|
3321
3337
|
/**
|
|
3322
3338
|
* Storage provider abstraction. Every method MUST be idempotent at the
|
|
3323
3339
|
* data-content level — re-invoking put with identical body is allowed.
|
|
@@ -3332,6 +3348,36 @@ interface FileStorageProvider {
|
|
|
3332
3348
|
getSignedUrl(path: StoragePath, opts?: SignedUrlOpts): Promise<string>;
|
|
3333
3349
|
/** Used by validation cron + onboarding step 2. */
|
|
3334
3350
|
probe(): Promise<ProbeResult>;
|
|
3351
|
+
/**
|
|
3352
|
+
* List all entries (files and sub-directories) under a logical path prefix.
|
|
3353
|
+
* Results are recursive — all descendants are included.
|
|
3354
|
+
* Returns an empty array when the prefix does not exist.
|
|
3355
|
+
*/
|
|
3356
|
+
list(prefix: StoragePath): Promise<FileEntry[]>;
|
|
3357
|
+
/**
|
|
3358
|
+
* Move bytes from `from` to `to`, creating any intermediate directories.
|
|
3359
|
+
* The source is removed on success.
|
|
3360
|
+
* Throws with a message containing "Not found" when `from` does not exist.
|
|
3361
|
+
*/
|
|
3362
|
+
move(from: StoragePath, to: StoragePath): Promise<void>;
|
|
3363
|
+
/**
|
|
3364
|
+
* Rename a file or directory. `to` is the full new logical path.
|
|
3365
|
+
* Implementations may delegate to `move`.
|
|
3366
|
+
* Throws with a message containing "Not found" when `from` does not exist.
|
|
3367
|
+
*/
|
|
3368
|
+
rename(from: StoragePath, to: StoragePath): Promise<void>;
|
|
3369
|
+
}
|
|
3370
|
+
declare class StorageCollisionExhausted extends Error {
|
|
3371
|
+
attempts: number;
|
|
3372
|
+
lastPath: StoragePath;
|
|
3373
|
+
constructor(attempts: number, lastPath: StoragePath);
|
|
3374
|
+
}
|
|
3375
|
+
declare class StorageNotConfigured extends Error {
|
|
3376
|
+
constructor();
|
|
3377
|
+
}
|
|
3378
|
+
declare class StorageUnavailable extends Error {
|
|
3379
|
+
reason: ProbeResult["error"];
|
|
3380
|
+
constructor(reason: ProbeResult["error"], message: string);
|
|
3335
3381
|
}
|
|
3336
3382
|
|
|
3337
3383
|
interface WriteWithCollisionOpts {
|
|
@@ -3370,4 +3416,82 @@ declare function addRef<T extends FileWithRefs>(file: T, ref: FileRef): T;
|
|
|
3370
3416
|
declare function removeRef<T extends FileWithRefs>(file: T, ref_id: string, removed_at: string): T;
|
|
3371
3417
|
declare function countRefs(file: Pick<FileWithRefs, "file_refs">): number;
|
|
3372
3418
|
|
|
3373
|
-
|
|
3419
|
+
interface AppFileServerOpts {
|
|
3420
|
+
/** Filesystem root. All paths are resolved relative to this. */
|
|
3421
|
+
root: string;
|
|
3422
|
+
/** HMAC secret used to sign download URLs. */
|
|
3423
|
+
hmac_secret: string;
|
|
3424
|
+
/** Default signed-URL TTL in seconds. */
|
|
3425
|
+
default_ttl_seconds?: number;
|
|
3426
|
+
}
|
|
3427
|
+
declare class AppFileServerProvider implements FileStorageProvider {
|
|
3428
|
+
readonly provider_tag: "app_file_server";
|
|
3429
|
+
private readonly root;
|
|
3430
|
+
private readonly secret;
|
|
3431
|
+
private readonly default_ttl;
|
|
3432
|
+
constructor(opts: AppFileServerOpts);
|
|
3433
|
+
private resolve;
|
|
3434
|
+
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
3435
|
+
get(path: string): Promise<Buffer>;
|
|
3436
|
+
delete(path: string): Promise<void>;
|
|
3437
|
+
exists(path: string): Promise<boolean>;
|
|
3438
|
+
getSignedUrl(path: string, opts?: SignedUrlOpts): Promise<string>;
|
|
3439
|
+
/** Verify a token produced by `getSignedUrl`. Used by the `/api/files/serve` route. */
|
|
3440
|
+
verifySignedUrl(token: string, path: string): boolean;
|
|
3441
|
+
probe(): Promise<ProbeResult>;
|
|
3442
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
3443
|
+
private walkDir;
|
|
3444
|
+
move(from: string, to: string): Promise<void>;
|
|
3445
|
+
rename(from: string, to: string): Promise<void>;
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
declare class InMemoryProvider implements FileStorageProvider {
|
|
3449
|
+
readonly provider_tag: "in_memory";
|
|
3450
|
+
private readonly store;
|
|
3451
|
+
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
3452
|
+
get(path: string): Promise<Buffer>;
|
|
3453
|
+
delete(path: string): Promise<void>;
|
|
3454
|
+
exists(path: string): Promise<boolean>;
|
|
3455
|
+
getSignedUrl(path: string, _opts?: SignedUrlOpts): Promise<string>;
|
|
3456
|
+
probe(): Promise<ProbeResult>;
|
|
3457
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
3458
|
+
move(from: string, to: string): Promise<void>;
|
|
3459
|
+
rename(from: string, to: string): Promise<void>;
|
|
3460
|
+
/** Test-only escape hatch — exposes the internal store for assertions. */
|
|
3461
|
+
snapshot(): Map<string, Buffer>;
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
interface DrivePathCache {
|
|
3465
|
+
lookup(key: string): Promise<string | null>;
|
|
3466
|
+
write(key: string, folder_id: string): Promise<void>;
|
|
3467
|
+
invalidate(key: string): Promise<void>;
|
|
3468
|
+
}
|
|
3469
|
+
interface GoogleDriveOpts {
|
|
3470
|
+
/** Raw JSON keyfile contents (decoded from GOOGLE_SERVICE_ACCOUNT_JSON env var). */
|
|
3471
|
+
service_account_json: string;
|
|
3472
|
+
/** Target Shared Drive ID. */
|
|
3473
|
+
shared_drive_id: string;
|
|
3474
|
+
/** Lazy folder-ID cache, scoped per Hazodocs org. */
|
|
3475
|
+
path_cache: DrivePathCache;
|
|
3476
|
+
}
|
|
3477
|
+
declare class GoogleDriveProvider implements FileStorageProvider {
|
|
3478
|
+
readonly provider_tag: "gdrive";
|
|
3479
|
+
private readonly drive;
|
|
3480
|
+
private readonly driveId;
|
|
3481
|
+
private readonly cache;
|
|
3482
|
+
constructor(opts: GoogleDriveOpts);
|
|
3483
|
+
probe(): Promise<ProbeResult>;
|
|
3484
|
+
put(path: string, body: Buffer | Readable, opts?: PutOpts): Promise<PutResult>;
|
|
3485
|
+
get(path: string): Promise<Buffer>;
|
|
3486
|
+
delete(path: string): Promise<void>;
|
|
3487
|
+
exists(path: string): Promise<boolean>;
|
|
3488
|
+
getSignedUrl(path: string, _opts?: SignedUrlOpts): Promise<string>;
|
|
3489
|
+
list(prefix: string): Promise<FileEntry[]>;
|
|
3490
|
+
move(from: string, to: string): Promise<void>;
|
|
3491
|
+
rename(from: string, to: string): Promise<void>;
|
|
3492
|
+
private resolvePath;
|
|
3493
|
+
private findChild;
|
|
3494
|
+
private lookupFileId;
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AddRefOptions, type AppFileServerOpts, AppFileServerProvider, 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 DrivePathCache, DropboxAuth, type DropboxAuthCallbacks, type DropboxAuthConfig, type DropboxConfig, DropboxModule, type DropboxTokenData, type ExtractionData, type ExtractionOptions, type ExtractionResult, type FileBrowserState, type FileDataStructure, type FileEntry, FileExistsError, type FileInfo, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, type FileMetadataRecordV2, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileRef$1 as FileRef, type FileRefVisibility, type FileStatus, type FileStorageProvider, type FileSystemItem, FileTooLargeError, type FileWithRefs, type FileWithStatus, type FindOrphanedOptions, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, type GoogleDriveOpts, GoogleDriveProvider, 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, type HazoFilesMigrationV2, type HazoFilesMigrationV3, type HazoFilesNamingColumnDefinitions, type HazoFilesNamingTableSchema, type HazoFilesTableSchema, type HazoLLMInstance, InMemoryProvider, 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, NamingTemplate, type NamingVariable, OperationError, type OperationResult, type ParsedNamingConvention, type PatternSegment, PermissionDeniedError, type ProbeResult, type ProgressCallback, type PutOpts, type PutResult, type RemoveExtractionOptions, type RemoveRefsCriteria, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type SignedUrlOpts, StorageCollisionExhausted, type StorageModule, StorageNotConfigured, type StoragePath, type StorageProvider, StorageUnavailable, 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, type WriteWithCollisionOpts, addExtractionToFileData, addRef, backfillV2Defaults, buildFileWithStatus, clearExtractions, clonePattern, computeFileHash, computeFileHashFromStream, computeFileHashSync, computeFileInfo, countRefs, 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, removeRef, removeRefFromArray, removeRefsByCriteriaFromArray, sanitizeFilename, saveConfig, sortItems, stringifyFileData, stringifyFileRefs, successResult, toV2Record, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath, writeWithCollisionRetry };
|