hazo_files 1.4.7 → 1.5.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.
@@ -1,260 +0,0 @@
1
- # hazo_files Setup Checklist
2
-
3
- Complete guide to setting up hazo_files in your project.
4
-
5
- ## 1. Installation
6
-
7
- ```bash
8
- # Install hazo_files
9
- npm install hazo_files
10
-
11
- # Optional peer dependencies
12
- npm install hazo_connect # For database tracking
13
- npm install hazo_llm_api # For LLM extraction
14
- npm install server-only # For server entry point safety
15
- npm install xxhash-wasm # For fast file hashing (included by default)
16
- ```
17
-
18
- ## 2. Database Setup
19
-
20
- ### a. Create Tables
21
-
22
- Using hazo_connect:
23
-
24
- ```typescript
25
- import { createHazoConnect, SqliteAdapter } from 'hazo_connect/server';
26
- import { HAZO_FILES_TABLE_SCHEMA, HAZO_FILES_NAMING_TABLE_SCHEMA } from 'hazo_files';
27
-
28
- // Create adapter
29
- const adapter = createHazoConnect({
30
- type: 'sqlite',
31
- sqlite: { database_path: './data/hazo_files.sqlite' }
32
- });
33
-
34
- // Initialize file metadata table
35
- const fileStatements = HAZO_FILES_TABLE_SCHEMA.sqlite.ddl
36
- .split(';')
37
- .filter(s => s.trim());
38
- for (const stmt of fileStatements) {
39
- await (adapter as SqliteAdapter).rawQuery(stmt + ';', { method: 'POST' });
40
- }
41
- for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
42
- await (adapter as SqliteAdapter).rawQuery(idx, { method: 'POST' });
43
- }
44
-
45
- // Initialize naming conventions table
46
- const namingStatements = HAZO_FILES_NAMING_TABLE_SCHEMA.sqlite.ddl
47
- .split(';')
48
- .filter(s => s.trim());
49
- for (const stmt of namingStatements) {
50
- await (adapter as SqliteAdapter).rawQuery(stmt + ';', { method: 'POST' });
51
- }
52
- for (const idx of HAZO_FILES_NAMING_TABLE_SCHEMA.sqlite.indexes) {
53
- await (adapter as SqliteAdapter).rawQuery(idx, { method: 'POST' });
54
- }
55
- ```
56
-
57
- ### b. Column Reference
58
-
59
- **hazo_files table:**
60
- - `id` - Primary key (UUID)
61
- - `filename` - File/folder name
62
- - `file_type` - MIME type or 'folder'
63
- - `file_data` - JSON metadata and extractions
64
- - `created_at` - Creation timestamp
65
- - `changed_at` - Last modification timestamp
66
- - `file_path` - Virtual path
67
- - `storage_type` - 'local' or 'google_drive'
68
- - `file_hash` - xxHash for change detection
69
- - `file_size` - Size in bytes
70
- - `file_changed_at` - Content change timestamp
71
-
72
- **hazo_files_naming table:**
73
- - `id` - Primary key (UUID)
74
- - `scope_id` - Links to hazo_scopes (optional)
75
- - `naming_title` - Display name
76
- - `naming_type` - 'file', 'folder', or 'both'
77
- - `naming_value` - JSON NamingRuleSchema
78
- - `created_at` - Creation timestamp
79
- - `changed_at` - Last modification timestamp
80
- - `variables` - JSON array of NamingVariable
81
-
82
- ## 3. Server Setup
83
-
84
- ### Option A: Using Factory
85
-
86
- ```typescript
87
- // server/hazo-files.ts
88
- import { createHazoFilesServer } from 'hazo_files/server';
89
- import { createCrudService } from 'hazo_connect/server';
90
-
91
- export async function getHazoFiles() {
92
- const fileCrud = createCrudService(adapter, 'hazo_files');
93
- const namingCrud = createCrudService(adapter, 'hazo_files_naming');
94
-
95
- return createHazoFilesServer({
96
- crudService: fileCrud,
97
- namingCrudService: namingCrud,
98
- config: {
99
- provider: 'local',
100
- local: { basePath: './storage/files' }
101
- },
102
- enableTracking: true
103
- });
104
- }
105
- ```
106
-
107
- ### Option B: Manual Setup
108
-
109
- ```typescript
110
- import {
111
- TrackedFileManager,
112
- FileMetadataService,
113
- NamingConventionService,
114
- UploadExtractService
115
- } from 'hazo_files';
116
-
117
- // Create file manager
118
- const fileManager = new TrackedFileManager({
119
- config: { provider: 'local', local: { basePath: './files' } },
120
- crudService: fileCrud,
121
- tracking: { enabled: true }
122
- });
123
- await fileManager.initialize();
124
-
125
- // Create services
126
- const namingService = new NamingConventionService(namingCrud);
127
- const uploadService = new UploadExtractService(fileManager, namingService);
128
- ```
129
-
130
- ## 4. UI Setup (React)
131
-
132
- ### a. Install UI Dependencies
133
-
134
- ```bash
135
- npm install @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities
136
- ```
137
-
138
- ### b. Configure Tailwind (v4)
139
-
140
- In your `globals.css`:
141
-
142
- ```css
143
- @import "tailwindcss";
144
-
145
- /* Include hazo_files for Tailwind to scan classes */
146
- @source "../node_modules/hazo_files/dist";
147
- ```
148
-
149
- ### c. Use Components
150
-
151
- ```tsx
152
- import { FileBrowser, NamingConventionManager } from 'hazo_files/ui';
153
-
154
- // File Browser
155
- <FileBrowser api={fileBrowserAPI} />
156
-
157
- // Naming Convention Manager
158
- <NamingConventionManager api={namingAPI} />
159
- ```
160
-
161
- ## 5. API Routes (Next.js)
162
-
163
- ### File Operations
164
-
165
- ```typescript
166
- // app/api/files/route.ts
167
- import { getFileManager } from '@/server/hazo-files';
168
-
169
- export async function GET(request: NextRequest) {
170
- const { searchParams } = new URL(request.url);
171
- const action = searchParams.get('action');
172
- const path = searchParams.get('path') || '/';
173
-
174
- const { fileManager } = await getHazoFiles();
175
-
176
- switch (action) {
177
- case 'list':
178
- return NextResponse.json(await fileManager.listDirectory(path));
179
- case 'tree':
180
- return NextResponse.json(await fileManager.getFolderTree(path));
181
- }
182
- }
183
- ```
184
-
185
- ### Naming Conventions
186
-
187
- ```typescript
188
- // app/api/naming-conventions/route.ts
189
- import { NamingConventionService } from 'hazo_files';
190
- import { getNamingCrudService } from '@/config/database';
191
-
192
- export async function GET() {
193
- const service = new NamingConventionService(getNamingCrudService());
194
- const conventions = await service.listParsed();
195
- return NextResponse.json({ success: true, data: conventions });
196
- }
197
- ```
198
-
199
- ## 6. Environment Variables
200
-
201
- ```env
202
- # Storage
203
- HAZO_FILES_BASE_PATH=./storage/files
204
-
205
- # Database
206
- HAZO_CONNECT_SQLITE_PATH=./data/hazo_files.sqlite
207
- HAZO_FILES_DB_ENABLED=true
208
-
209
- # Google Drive (optional)
210
- HAZO_GOOGLE_DRIVE_CLIENT_ID=your-client-id
211
- HAZO_GOOGLE_DRIVE_CLIENT_SECRET=your-client-secret
212
- HAZO_GOOGLE_DRIVE_REDIRECT_URI=http://localhost:3000/api/auth/google/callback
213
- ```
214
-
215
- ## 7. Verification
216
-
217
- Run the test-app to verify your setup:
218
-
219
- ```bash
220
- cd hazo_files
221
- npm run dev:test-app
222
- ```
223
-
224
- Then open http://localhost:3000 and test:
225
- - [ ] Local Files - file browser works
226
- - [ ] Naming Config - create/edit naming rules
227
- - [ ] Naming Conventions - CRUD for conventions
228
- - [ ] Upload & Extract - upload with conventions
229
- - [ ] File Metadata - view tracked files
230
-
231
- ## Common Issues
232
-
233
- ### 1. Module not found: 'fs'
234
-
235
- You're importing server code in a client component. Use the `/server` entry point:
236
-
237
- ```typescript
238
- // Wrong
239
- import { TrackedFileManager } from 'hazo_files';
240
-
241
- // Right (server only)
242
- import { TrackedFileManager } from 'hazo_files/server';
243
- ```
244
-
245
- ### 2. Tailwind classes not applied
246
-
247
- Add `@source` directive for hazo_files in your CSS:
248
-
249
- ```css
250
- @source "../node_modules/hazo_files/dist";
251
- ```
252
-
253
- ### 3. Database not initialized
254
-
255
- Ensure you call `initializeDatabase()` before using services:
256
-
257
- ```typescript
258
- await initializeDatabase();
259
- const crud = getCrudService();
260
- ```