hazo_files 1.4.6 → 1.4.7
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 +161 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -510,6 +510,167 @@ const fileManager = await createInitializedFileManager({
|
|
|
510
510
|
});
|
|
511
511
|
```
|
|
512
512
|
|
|
513
|
+
## Database Schema
|
|
514
|
+
|
|
515
|
+
Database tables are only required if you use `TrackedFileManager`, `FileMetadataService`, `NamingConventionService`, or `UploadExtractService`. Plain `FileManager` (filesystem only) needs no tables.
|
|
516
|
+
|
|
517
|
+
There are two tables:
|
|
518
|
+
|
|
519
|
+
- **`hazo_files`** — file metadata, hashes, references, content tags
|
|
520
|
+
- **`hazo_files_naming`** — saved naming conventions
|
|
521
|
+
|
|
522
|
+
The DDL below is also exposed programmatically via `HAZO_FILES_TABLE_SCHEMA` and `HAZO_FILES_NAMING_TABLE_SCHEMA` (see [Programmatic Setup](#programmatic-setup) below). Run the raw SQL if you prefer to manage migrations with your existing tooling (psql, sqlite3, Flyway, Knex, etc.).
|
|
523
|
+
|
|
524
|
+
### `hazo_files` Table
|
|
525
|
+
|
|
526
|
+
#### PostgreSQL
|
|
527
|
+
|
|
528
|
+
```sql
|
|
529
|
+
CREATE TABLE IF NOT EXISTS hazo_files (
|
|
530
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
531
|
+
filename TEXT NOT NULL,
|
|
532
|
+
file_type TEXT NOT NULL,
|
|
533
|
+
file_data TEXT DEFAULT '{}',
|
|
534
|
+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
535
|
+
changed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
536
|
+
file_path TEXT NOT NULL,
|
|
537
|
+
storage_type TEXT NOT NULL,
|
|
538
|
+
file_hash TEXT,
|
|
539
|
+
file_size BIGINT,
|
|
540
|
+
file_changed_at TIMESTAMP WITH TIME ZONE,
|
|
541
|
+
file_refs TEXT DEFAULT '[]',
|
|
542
|
+
ref_count INTEGER DEFAULT 0,
|
|
543
|
+
status TEXT DEFAULT 'active',
|
|
544
|
+
scope_id UUID,
|
|
545
|
+
uploaded_by UUID,
|
|
546
|
+
storage_verified_at TIMESTAMP WITH TIME ZONE,
|
|
547
|
+
deleted_at TIMESTAMP WITH TIME ZONE,
|
|
548
|
+
original_filename TEXT,
|
|
549
|
+
content_tag TEXT
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_path ON hazo_files (file_path);
|
|
553
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_storage ON hazo_files (storage_type);
|
|
554
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_files_path_storage ON hazo_files (file_path, storage_type);
|
|
555
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_hash ON hazo_files (file_hash);
|
|
556
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_status ON hazo_files (status);
|
|
557
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_scope ON hazo_files (scope_id);
|
|
558
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_ref_count ON hazo_files (ref_count);
|
|
559
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_deleted ON hazo_files (deleted_at);
|
|
560
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_content_tag ON hazo_files (content_tag);
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
#### SQLite
|
|
564
|
+
|
|
565
|
+
```sql
|
|
566
|
+
CREATE TABLE IF NOT EXISTS hazo_files (
|
|
567
|
+
id TEXT PRIMARY KEY,
|
|
568
|
+
filename TEXT NOT NULL,
|
|
569
|
+
file_type TEXT NOT NULL,
|
|
570
|
+
file_data TEXT DEFAULT '{}',
|
|
571
|
+
created_at TEXT NOT NULL,
|
|
572
|
+
changed_at TEXT NOT NULL,
|
|
573
|
+
file_path TEXT NOT NULL,
|
|
574
|
+
storage_type TEXT NOT NULL,
|
|
575
|
+
file_hash TEXT,
|
|
576
|
+
file_size INTEGER,
|
|
577
|
+
file_changed_at TEXT,
|
|
578
|
+
file_refs TEXT DEFAULT '[]',
|
|
579
|
+
ref_count INTEGER DEFAULT 0,
|
|
580
|
+
status TEXT DEFAULT 'active',
|
|
581
|
+
scope_id TEXT,
|
|
582
|
+
uploaded_by TEXT,
|
|
583
|
+
storage_verified_at TEXT,
|
|
584
|
+
deleted_at TEXT,
|
|
585
|
+
original_filename TEXT,
|
|
586
|
+
content_tag TEXT
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_path ON hazo_files (file_path);
|
|
590
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_storage ON hazo_files (storage_type);
|
|
591
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_files_path_storage ON hazo_files (file_path, storage_type);
|
|
592
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_hash ON hazo_files (file_hash);
|
|
593
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_status ON hazo_files (status);
|
|
594
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_scope ON hazo_files (scope_id);
|
|
595
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_ref_count ON hazo_files (ref_count);
|
|
596
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_deleted ON hazo_files (deleted_at);
|
|
597
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_content_tag ON hazo_files (content_tag);
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
### `hazo_files_naming` Table
|
|
601
|
+
|
|
602
|
+
Required only if you use `NamingConventionService` to persist saved naming rules.
|
|
603
|
+
|
|
604
|
+
#### PostgreSQL
|
|
605
|
+
|
|
606
|
+
```sql
|
|
607
|
+
CREATE TABLE IF NOT EXISTS hazo_files_naming (
|
|
608
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
609
|
+
scope_id UUID,
|
|
610
|
+
naming_title TEXT NOT NULL,
|
|
611
|
+
naming_type TEXT NOT NULL CHECK(naming_type IN ('file', 'folder', 'both')),
|
|
612
|
+
naming_value TEXT NOT NULL,
|
|
613
|
+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
614
|
+
changed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
615
|
+
variables TEXT DEFAULT '[]'
|
|
616
|
+
);
|
|
617
|
+
|
|
618
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_naming_scope ON hazo_files_naming (scope_id);
|
|
619
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_naming_type ON hazo_files_naming (naming_type);
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
#### SQLite
|
|
623
|
+
|
|
624
|
+
```sql
|
|
625
|
+
CREATE TABLE IF NOT EXISTS hazo_files_naming (
|
|
626
|
+
id TEXT PRIMARY KEY,
|
|
627
|
+
scope_id TEXT,
|
|
628
|
+
naming_title TEXT NOT NULL,
|
|
629
|
+
naming_type TEXT NOT NULL CHECK(naming_type IN ('file', 'folder', 'both')),
|
|
630
|
+
naming_value TEXT NOT NULL,
|
|
631
|
+
created_at TEXT NOT NULL,
|
|
632
|
+
changed_at TEXT NOT NULL,
|
|
633
|
+
variables TEXT DEFAULT '[]'
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_naming_scope ON hazo_files_naming (scope_id);
|
|
637
|
+
CREATE INDEX IF NOT EXISTS idx_hazo_files_naming_type ON hazo_files_naming (naming_type);
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
### Programmatic Setup
|
|
641
|
+
|
|
642
|
+
The same DDL is available as exported constants so you can run it from your app's startup or migration script without hand-copying SQL:
|
|
643
|
+
|
|
644
|
+
```typescript
|
|
645
|
+
import {
|
|
646
|
+
HAZO_FILES_TABLE_SCHEMA,
|
|
647
|
+
HAZO_FILES_NAMING_TABLE_SCHEMA,
|
|
648
|
+
} from 'hazo_files';
|
|
649
|
+
|
|
650
|
+
// Pick 'sqlite' or 'postgres'
|
|
651
|
+
const dbType: 'sqlite' | 'postgres' = 'sqlite';
|
|
652
|
+
|
|
653
|
+
// Create hazo_files table
|
|
654
|
+
await db.run(HAZO_FILES_TABLE_SCHEMA[dbType].ddl);
|
|
655
|
+
for (const idx of HAZO_FILES_TABLE_SCHEMA[dbType].indexes) {
|
|
656
|
+
await db.run(idx);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// Create hazo_files_naming table (only if using NamingConventionService)
|
|
660
|
+
await db.run(HAZO_FILES_NAMING_TABLE_SCHEMA[dbType].ddl);
|
|
661
|
+
for (const idx of HAZO_FILES_NAMING_TABLE_SCHEMA[dbType].indexes) {
|
|
662
|
+
await db.run(idx);
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
For PostgreSQL, swap `db.run(...)` for `client.query(...)`.
|
|
667
|
+
|
|
668
|
+
To use a custom table name, see `getSchemaForTable(name, dbType)` and `getNamingSchemaForTable(name, dbType)`.
|
|
669
|
+
|
|
670
|
+
### Upgrading Existing Tables
|
|
671
|
+
|
|
672
|
+
If you already have a pre-V2 or pre-V3 `hazo_files` table, see [Database Migration (Existing Databases)](#database-migration-existing-databases) and [V3 Database Migration](#v3-database-migration) for the `ALTER TABLE` scripts and migration helpers.
|
|
673
|
+
|
|
513
674
|
## UI Components
|
|
514
675
|
|
|
515
676
|
### FileBrowser Component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hazo_files",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"description": "File management including integration to cloud files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -73,16 +73,16 @@
|
|
|
73
73
|
"@dnd-kit/sortable": "^10.0.0",
|
|
74
74
|
"@dnd-kit/utilities": "^3.2.2",
|
|
75
75
|
"@types/ini": "^4.1.1",
|
|
76
|
-
"@types/node": "^20.10
|
|
77
|
-
"@types/react": "^18.
|
|
78
|
-
"@types/react-dom": "^18.
|
|
76
|
+
"@types/node": "^20.14.10",
|
|
77
|
+
"@types/react": "^18.3.3",
|
|
78
|
+
"@types/react-dom": "^18.3.0",
|
|
79
79
|
"dropbox": "^10.34.0",
|
|
80
80
|
"googleapis": "^140.0.1",
|
|
81
81
|
"hazo_llm_api": "^1.2.7",
|
|
82
82
|
"react": "^18.2.0",
|
|
83
83
|
"react-dom": "^18.2.0",
|
|
84
84
|
"tsup": "^8.0.1",
|
|
85
|
-
"typescript": "^5.
|
|
85
|
+
"typescript": "^5.7.2",
|
|
86
86
|
"vitest": "^4.0.15",
|
|
87
87
|
"xxhash-wasm": "^1.1.0"
|
|
88
88
|
},
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
"@dnd-kit/utilities": "^3.0.0",
|
|
93
93
|
"dropbox": "^10.0.0",
|
|
94
94
|
"googleapis": "^140.0.0",
|
|
95
|
-
"hazo_connect": "
|
|
96
|
-
"hazo_debug": "
|
|
97
|
-
"hazo_llm_api": "
|
|
98
|
-
"hazo_logs": "
|
|
95
|
+
"hazo_connect": "^2.4.0",
|
|
96
|
+
"hazo_debug": "^2.0.0",
|
|
97
|
+
"hazo_llm_api": "^1.2.0",
|
|
98
|
+
"hazo_logs": "^1.0.13",
|
|
99
99
|
"react": "^18.0.0",
|
|
100
100
|
"react-dom": "^18.0.0",
|
|
101
101
|
"server-only": ">=0.0.1",
|