hazo_files 2.1.1 → 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 +44 -0
- package/README.md +45 -2
- package/config/hazo_files_config.ini.sample +11 -0
- package/dist/background-upload/index.js +4 -2
- package/dist/background-upload/index.mjs +4 -2
- package/dist/background-upload/react/index.js +6 -2
- package/dist/background-upload/react/index.mjs +6 -2
- package/dist/index.d.mts +141 -18
- package/dist/index.d.ts +141 -18
- package/dist/index.js +15434 -489
- package/dist/index.mjs +15452 -489
- package/dist/server/index.d.mts +103 -21
- package/dist/server/index.d.ts +103 -21
- package/dist/server/index.js +15326 -522
- package/dist/server/index.mjs +15346 -527
- 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 +21 -12
package/CHANGE_LOG.md
CHANGED
|
@@ -5,6 +5,50 @@ 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
|
+
|
|
32
|
+
## 3.0.0 — 2026-05-29
|
|
33
|
+
|
|
34
|
+
### Breaking changes (Wave 2 standardisation)
|
|
35
|
+
|
|
36
|
+
- **Required peer dep:** `hazo_core ^1.0.0`. Provides `HazoError` hierarchy, structured logger, and `withContext()` correlation propagation.
|
|
37
|
+
- **Cross-hazo peer-dep major bumps:** `hazo_connect ^3.0.0` (was `^2.7.3`), `hazo_llm_api ^2.0.0` (was `^1.3.0`). Consumers using these alongside `hazo_files` must upgrade them together.
|
|
38
|
+
- **Error API surface:** the 12 `HazoFilesError` subclasses (`FileNotFoundError`, `FileTooLargeError`, etc.) now extend `HazoError` from `hazo_core` and carry `HAZO_FILES_*` codes. Catch sites that used `instanceof HazoFilesError` continue to work; catch sites that matched `error.message` text should switch to `.code`.
|
|
39
|
+
|
|
40
|
+
### Internal changes
|
|
41
|
+
|
|
42
|
+
- Default logger resolves to `createLogger('hazo_files')` from `hazo_core` (delegates to `hazo_logs`).
|
|
43
|
+
- Google Drive adapter outbound API calls and `LLMExtractionService` provider calls use `fetchWithRequestId()` so `x-request-id` propagates.
|
|
44
|
+
- `TrackedFileManager` operations run inside `withContext({ correlationId })` per call so DB writes and storage writes share the same correlation ID.
|
|
45
|
+
|
|
46
|
+
### Migration
|
|
47
|
+
|
|
48
|
+
1. `npm install hazo_core@^1.0.0`.
|
|
49
|
+
2. Upgrade `hazo_connect` to `^3.0.0` and `hazo_llm_api` to `^2.0.0` if you depend on them.
|
|
50
|
+
3. No public API method signatures changed — `FileManager` and `TrackedFileManager` methods keep their existing call shape.
|
|
51
|
+
|
|
8
52
|
## 2.1.1 — 2026-05-24
|
|
9
53
|
|
|
10
54
|
**Docs + housekeeping** — no API changes.
|
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
|
|
@@ -42,3 +42,14 @@ root_path =
|
|
|
42
42
|
; Comma-separated list of supported date format tokens for naming rules
|
|
43
43
|
; Available: YYYY, YY, MM, M, DD, D, MMM, MMMM, YYYY-MM-DD, YYYY-MMM-DD, DD-MM-YYYY, MM-DD-YYYY
|
|
44
44
|
date_formats = YYYY,YY,MM,M,DD,D,MMM,MMMM,YYYY-MM-DD,YYYY-MMM-DD,DD-MM-YYYY,MM-DD-YYYY
|
|
45
|
+
|
|
46
|
+
[log.overrides]
|
|
47
|
+
; Override log levels per namespace. Format: namespace = TRACE|DEBUG|INFO|WARN|ERROR
|
|
48
|
+
; Example:
|
|
49
|
+
; hazo_files.metadata = DEBUG
|
|
50
|
+
; hazo_files.naming = WARN
|
|
51
|
+
|
|
52
|
+
[env]
|
|
53
|
+
; Set HAZO_ENV to control which overlay config file is loaded
|
|
54
|
+
; e.g. HAZO_ENV=production loads hazo_files_config.production.ini as an overlay
|
|
55
|
+
; hazo_env = production
|
|
@@ -57,6 +57,7 @@ var TypedEventEmitter = class {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/background_upload/core/job.ts
|
|
60
|
+
var import_hazo_core = require("hazo_core");
|
|
60
61
|
var Job = class {
|
|
61
62
|
constructor(init) {
|
|
62
63
|
this.status = "queued";
|
|
@@ -64,7 +65,7 @@ var Job = class {
|
|
|
64
65
|
this.error = null;
|
|
65
66
|
this.confirmation_payload = null;
|
|
66
67
|
this.confirmation_resolve = null;
|
|
67
|
-
this.job_id =
|
|
68
|
+
this.job_id = (0, import_hazo_core.generateRequestId)().slice(4);
|
|
68
69
|
this.batch_id = init.batch_id;
|
|
69
70
|
this.created_at = Date.now();
|
|
70
71
|
this.updated_at = this.created_at;
|
|
@@ -183,6 +184,7 @@ var PipelineExecutor = class {
|
|
|
183
184
|
};
|
|
184
185
|
|
|
185
186
|
// src/background_upload/core/upload-manager.ts
|
|
187
|
+
var import_hazo_core2 = require("hazo_core");
|
|
186
188
|
var UploadManager = class {
|
|
187
189
|
constructor(config) {
|
|
188
190
|
this.jobs = /* @__PURE__ */ new Map();
|
|
@@ -204,7 +206,7 @@ var UploadManager = class {
|
|
|
204
206
|
}
|
|
205
207
|
submit_batch(options) {
|
|
206
208
|
if (this.destroyed) throw new Error("UploadManager is destroyed");
|
|
207
|
-
const batch_id =
|
|
209
|
+
const batch_id = (0, import_hazo_core2.generateRequestId)().slice(4);
|
|
208
210
|
const job_ids = [];
|
|
209
211
|
const pipeline_steps = options.pipeline_steps ?? this.config.default_pipeline_steps;
|
|
210
212
|
for (const file of options.files) {
|
|
@@ -28,6 +28,7 @@ var TypedEventEmitter = class {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// src/background_upload/core/job.ts
|
|
31
|
+
import { generateRequestId } from "hazo_core";
|
|
31
32
|
var Job = class {
|
|
32
33
|
constructor(init) {
|
|
33
34
|
this.status = "queued";
|
|
@@ -35,7 +36,7 @@ var Job = class {
|
|
|
35
36
|
this.error = null;
|
|
36
37
|
this.confirmation_payload = null;
|
|
37
38
|
this.confirmation_resolve = null;
|
|
38
|
-
this.job_id =
|
|
39
|
+
this.job_id = generateRequestId().slice(4);
|
|
39
40
|
this.batch_id = init.batch_id;
|
|
40
41
|
this.created_at = Date.now();
|
|
41
42
|
this.updated_at = this.created_at;
|
|
@@ -154,6 +155,7 @@ var PipelineExecutor = class {
|
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
// src/background_upload/core/upload-manager.ts
|
|
158
|
+
import { generateRequestId as generateRequestId2 } from "hazo_core";
|
|
157
159
|
var UploadManager = class {
|
|
158
160
|
constructor(config) {
|
|
159
161
|
this.jobs = /* @__PURE__ */ new Map();
|
|
@@ -175,7 +177,7 @@ var UploadManager = class {
|
|
|
175
177
|
}
|
|
176
178
|
submit_batch(options) {
|
|
177
179
|
if (this.destroyed) throw new Error("UploadManager is destroyed");
|
|
178
|
-
const batch_id =
|
|
180
|
+
const batch_id = generateRequestId2().slice(4);
|
|
179
181
|
const job_ids = [];
|
|
180
182
|
const pipeline_steps = options.pipeline_steps ?? this.config.default_pipeline_steps;
|
|
181
183
|
for (const file of options.files) {
|
|
@@ -41,7 +41,11 @@ module.exports = __toCommonJS(index_exports);
|
|
|
41
41
|
// src/background_upload/react/provider.tsx
|
|
42
42
|
var import_react3 = require("react");
|
|
43
43
|
|
|
44
|
+
// src/background_upload/core/upload-manager.ts
|
|
45
|
+
var import_hazo_core2 = require("hazo_core");
|
|
46
|
+
|
|
44
47
|
// src/background_upload/core/job.ts
|
|
48
|
+
var import_hazo_core = require("hazo_core");
|
|
45
49
|
var Job = class {
|
|
46
50
|
constructor(init) {
|
|
47
51
|
this.status = "queued";
|
|
@@ -49,7 +53,7 @@ var Job = class {
|
|
|
49
53
|
this.error = null;
|
|
50
54
|
this.confirmation_payload = null;
|
|
51
55
|
this.confirmation_resolve = null;
|
|
52
|
-
this.job_id =
|
|
56
|
+
this.job_id = (0, import_hazo_core.generateRequestId)().slice(4);
|
|
53
57
|
this.batch_id = init.batch_id;
|
|
54
58
|
this.created_at = Date.now();
|
|
55
59
|
this.updated_at = this.created_at;
|
|
@@ -218,7 +222,7 @@ var UploadManager = class {
|
|
|
218
222
|
}
|
|
219
223
|
submit_batch(options) {
|
|
220
224
|
if (this.destroyed) throw new Error("UploadManager is destroyed");
|
|
221
|
-
const batch_id =
|
|
225
|
+
const batch_id = (0, import_hazo_core2.generateRequestId)().slice(4);
|
|
222
226
|
const job_ids = [];
|
|
223
227
|
const pipeline_steps = options.pipeline_steps ?? this.config.default_pipeline_steps;
|
|
224
228
|
for (const file of options.files) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// src/background_upload/react/provider.tsx
|
|
2
2
|
import { useRef, useEffect as useEffect2 } from "react";
|
|
3
3
|
|
|
4
|
+
// src/background_upload/core/upload-manager.ts
|
|
5
|
+
import { generateRequestId as generateRequestId2 } from "hazo_core";
|
|
6
|
+
|
|
4
7
|
// src/background_upload/core/job.ts
|
|
8
|
+
import { generateRequestId } from "hazo_core";
|
|
5
9
|
var Job = class {
|
|
6
10
|
constructor(init) {
|
|
7
11
|
this.status = "queued";
|
|
@@ -9,7 +13,7 @@ var Job = class {
|
|
|
9
13
|
this.error = null;
|
|
10
14
|
this.confirmation_payload = null;
|
|
11
15
|
this.confirmation_resolve = null;
|
|
12
|
-
this.job_id =
|
|
16
|
+
this.job_id = generateRequestId().slice(4);
|
|
13
17
|
this.batch_id = init.batch_id;
|
|
14
18
|
this.created_at = Date.now();
|
|
15
19
|
this.updated_at = this.created_at;
|
|
@@ -178,7 +182,7 @@ var UploadManager = class {
|
|
|
178
182
|
}
|
|
179
183
|
submit_batch(options) {
|
|
180
184
|
if (this.destroyed) throw new Error("UploadManager is destroyed");
|
|
181
|
-
const batch_id =
|
|
185
|
+
const batch_id = generateRequestId2().slice(4);
|
|
182
186
|
const job_ids = [];
|
|
183
187
|
const pipeline_steps = options.pipeline_steps ?? this.config.default_pipeline_steps;
|
|
184
188
|
for (const file of options.files) {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { HazoAuthError, HazoConfigError, HazoConflictError, HazoNotFoundError, HazoValidationError, HazoExternalError } from 'hazo_core';
|
|
2
|
+
export { HazoError as HazoFilesError } from 'hazo_core';
|
|
1
3
|
import { Readable } from 'node:stream';
|
|
2
4
|
import { OAuth2Client } from 'google-auth-library';
|
|
3
5
|
|
|
@@ -2871,46 +2873,43 @@ declare function registerModule(provider: StorageProvider, factory: ModuleFactor
|
|
|
2871
2873
|
|
|
2872
2874
|
/**
|
|
2873
2875
|
* Custom error classes for hazo_files
|
|
2876
|
+
* All errors extend the appropriate hazo_core subclass.
|
|
2874
2877
|
*/
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
details?: Record<string, unknown> | undefined;
|
|
2878
|
-
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
2879
|
-
}
|
|
2880
|
-
declare class FileNotFoundError extends HazoFilesError {
|
|
2878
|
+
|
|
2879
|
+
declare class FileNotFoundError extends HazoNotFoundError {
|
|
2881
2880
|
constructor(path: string);
|
|
2882
2881
|
}
|
|
2883
|
-
declare class DirectoryNotFoundError extends
|
|
2882
|
+
declare class DirectoryNotFoundError extends HazoNotFoundError {
|
|
2884
2883
|
constructor(path: string);
|
|
2885
2884
|
}
|
|
2886
|
-
declare class FileExistsError extends
|
|
2885
|
+
declare class FileExistsError extends HazoConflictError {
|
|
2887
2886
|
constructor(path: string);
|
|
2888
2887
|
}
|
|
2889
|
-
declare class DirectoryExistsError extends
|
|
2888
|
+
declare class DirectoryExistsError extends HazoConflictError {
|
|
2890
2889
|
constructor(path: string);
|
|
2891
2890
|
}
|
|
2892
|
-
declare class DirectoryNotEmptyError extends
|
|
2891
|
+
declare class DirectoryNotEmptyError extends HazoConflictError {
|
|
2893
2892
|
constructor(path: string);
|
|
2894
2893
|
}
|
|
2895
|
-
declare class PermissionDeniedError extends
|
|
2894
|
+
declare class PermissionDeniedError extends HazoAuthError {
|
|
2896
2895
|
constructor(path: string, operation: string);
|
|
2897
2896
|
}
|
|
2898
|
-
declare class InvalidPathError extends
|
|
2897
|
+
declare class InvalidPathError extends HazoValidationError {
|
|
2899
2898
|
constructor(path: string, reason: string);
|
|
2900
2899
|
}
|
|
2901
|
-
declare class FileTooLargeError extends
|
|
2900
|
+
declare class FileTooLargeError extends HazoValidationError {
|
|
2902
2901
|
constructor(path: string, size: number, maxSize: number);
|
|
2903
2902
|
}
|
|
2904
|
-
declare class InvalidExtensionError extends
|
|
2903
|
+
declare class InvalidExtensionError extends HazoValidationError {
|
|
2905
2904
|
constructor(path: string, extension: string, allowedExtensions: string[]);
|
|
2906
2905
|
}
|
|
2907
|
-
declare class AuthenticationError extends
|
|
2906
|
+
declare class AuthenticationError extends HazoAuthError {
|
|
2908
2907
|
constructor(provider: string, message: string);
|
|
2909
2908
|
}
|
|
2910
|
-
declare class ConfigurationError extends
|
|
2909
|
+
declare class ConfigurationError extends HazoConfigError {
|
|
2911
2910
|
constructor(message: string);
|
|
2912
2911
|
}
|
|
2913
|
-
declare class OperationError extends
|
|
2912
|
+
declare class OperationError extends HazoExternalError {
|
|
2914
2913
|
constructor(operation: string, message: string, details?: Record<string, unknown>);
|
|
2915
2914
|
}
|
|
2916
2915
|
|
|
@@ -3319,6 +3318,22 @@ interface ProbeResult {
|
|
|
3319
3318
|
/** Free-form detail for logging. */
|
|
3320
3319
|
message?: string;
|
|
3321
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
|
+
}
|
|
3322
3337
|
/**
|
|
3323
3338
|
* Storage provider abstraction. Every method MUST be idempotent at the
|
|
3324
3339
|
* data-content level — re-invoking put with identical body is allowed.
|
|
@@ -3333,6 +3348,36 @@ interface FileStorageProvider {
|
|
|
3333
3348
|
getSignedUrl(path: StoragePath, opts?: SignedUrlOpts): Promise<string>;
|
|
3334
3349
|
/** Used by validation cron + onboarding step 2. */
|
|
3335
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);
|
|
3336
3381
|
}
|
|
3337
3382
|
|
|
3338
3383
|
interface WriteWithCollisionOpts {
|
|
@@ -3371,4 +3416,82 @@ declare function addRef<T extends FileWithRefs>(file: T, ref: FileRef): T;
|
|
|
3371
3416
|
declare function removeRef<T extends FileWithRefs>(file: T, ref_id: string, removed_at: string): T;
|
|
3372
3417
|
declare function countRefs(file: Pick<FileWithRefs, "file_refs">): number;
|
|
3373
3418
|
|
|
3374
|
-
|
|
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 };
|