hazo_files 1.3.0 → 1.3.1

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/dist/index.d.mts CHANGED
@@ -542,7 +542,52 @@ interface MetadataLogger {
542
542
  error?(message: string, data?: Record<string, unknown>): void;
543
543
  }
544
544
  /**
545
- * Minimal CRUD service interface (compatible with hazo_connect CrudService)
545
+ * Minimal CRUD service interface compatible with hazo_connect CrudService.
546
+ *
547
+ * This interface is a structural subset of hazo_connect's CrudService,
548
+ * allowing you to pass a hazo_connect CrudService directly without any adapter.
549
+ *
550
+ * @example Using with hazo_connect
551
+ * ```typescript
552
+ * import { createHazoConnect, createCrudService } from 'hazo_connect/server';
553
+ * import {
554
+ * createFileMetadataService,
555
+ * HAZO_FILES_TABLE_SCHEMA
556
+ * } from 'hazo_files';
557
+ * import type { FileMetadataRecord } from 'hazo_files';
558
+ *
559
+ * // 1. Create database table during app setup
560
+ * await db.run(HAZO_FILES_TABLE_SCHEMA.sqlite.ddl);
561
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
562
+ * await db.run(idx);
563
+ * }
564
+ *
565
+ * // 2. Create hazo_connect CRUD service
566
+ * const adapter = createHazoConnect({
567
+ * type: 'sqlite',
568
+ * database_path: './data.db'
569
+ * });
570
+ * const crud = createCrudService<FileMetadataRecord>(
571
+ * adapter,
572
+ * HAZO_FILES_TABLE_SCHEMA.tableName
573
+ * );
574
+ *
575
+ * // 3. Pass directly to hazo_files - NO ADAPTER NEEDED
576
+ * const metadataService = createFileMetadataService(crud);
577
+ *
578
+ * // 4. Use the service
579
+ * await metadataService.addExtraction(
580
+ * '/documents/report.pdf',
581
+ * 'local',
582
+ * { summary: 'Quarterly report' },
583
+ * { source: 'gpt-4' }
584
+ * );
585
+ * ```
586
+ *
587
+ * @remarks
588
+ * The hazo_connect CrudService has additional methods (findById, query)
589
+ * that are not used by FileMetadataService, making this interface
590
+ * a compatible subset.
546
591
  */
547
592
  interface CrudServiceLike<T> {
548
593
  list(configure?: (qb: unknown) => unknown): Promise<T[]>;
@@ -788,6 +833,112 @@ declare function generateSampleConfig(): string;
788
833
  */
789
834
  declare function saveConfig(config: HazoFilesConfig, configPath?: string): Promise<void>;
790
835
 
836
+ /**
837
+ * Database Schema Exports for hazo_files
838
+ *
839
+ * Provides DDL statements for creating the hazo_files table in different databases.
840
+ * Consuming applications can use these to set up their database schema.
841
+ *
842
+ * @example
843
+ * ```typescript
844
+ * import { HAZO_FILES_TABLE_SCHEMA } from 'hazo_files';
845
+ *
846
+ * // For SQLite
847
+ * await db.run(HAZO_FILES_TABLE_SCHEMA.sqlite.ddl);
848
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
849
+ * await db.run(idx);
850
+ * }
851
+ *
852
+ * // For PostgreSQL
853
+ * await client.query(HAZO_FILES_TABLE_SCHEMA.postgres.ddl);
854
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.postgres.indexes) {
855
+ * await client.query(idx);
856
+ * }
857
+ * ```
858
+ */
859
+ /**
860
+ * Column definitions for the hazo_files table
861
+ */
862
+ interface HazoFilesColumnDefinitions {
863
+ /** Primary key (UUID) */
864
+ id: 'TEXT' | 'UUID';
865
+ /** File or folder name */
866
+ filename: 'TEXT';
867
+ /** MIME type for files, 'folder' for directories */
868
+ file_type: 'TEXT';
869
+ /** Custom metadata as JSON string */
870
+ file_data: 'TEXT';
871
+ /** ISO timestamp when record was created */
872
+ created_at: 'TEXT' | 'TIMESTAMP';
873
+ /** ISO timestamp of last modification */
874
+ changed_at: 'TEXT' | 'TIMESTAMP';
875
+ /** Virtual path in storage */
876
+ file_path: 'TEXT';
877
+ /** Storage provider type ('local' | 'google_drive') */
878
+ storage_type: 'TEXT';
879
+ }
880
+ /**
881
+ * Schema definition for a specific database type
882
+ */
883
+ interface DatabaseSchemaDefinition {
884
+ /** CREATE TABLE statement */
885
+ ddl: string;
886
+ /** CREATE INDEX statements */
887
+ indexes: string[];
888
+ }
889
+ /**
890
+ * Complete schema definition for hazo_files table
891
+ */
892
+ interface HazoFilesTableSchema {
893
+ /** Default table name */
894
+ tableName: string;
895
+ /** SQLite-specific DDL */
896
+ sqlite: DatabaseSchemaDefinition;
897
+ /** PostgreSQL-specific DDL */
898
+ postgres: DatabaseSchemaDefinition;
899
+ /** Column names for reference */
900
+ columns: readonly string[];
901
+ }
902
+ /**
903
+ * Default table name for hazo_files metadata
904
+ */
905
+ declare const HAZO_FILES_DEFAULT_TABLE_NAME = "hazo_files";
906
+ /**
907
+ * DDL schema for the hazo_files table.
908
+ *
909
+ * Use these DDL statements to create the required database table
910
+ * in consuming applications.
911
+ *
912
+ * @example Using with hazo_connect
913
+ * ```typescript
914
+ * import { createHazoConnect, createCrudService } from 'hazo_connect/server';
915
+ * import { createFileMetadataService, HAZO_FILES_TABLE_SCHEMA } from 'hazo_files';
916
+ * import type { FileMetadataRecord } from 'hazo_files';
917
+ *
918
+ * // 1. Create table during app setup
919
+ * await db.run(HAZO_FILES_TABLE_SCHEMA.sqlite.ddl);
920
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
921
+ * await db.run(idx);
922
+ * }
923
+ *
924
+ * // 2. Create hazo_connect CRUD service
925
+ * const adapter = createHazoConnect({ type: 'sqlite', database_path: './data.db' });
926
+ * const crud = createCrudService<FileMetadataRecord>(adapter, HAZO_FILES_TABLE_SCHEMA.tableName);
927
+ *
928
+ * // 3. Pass directly to hazo_files - no adapter needed!
929
+ * const metadataService = createFileMetadataService(crud);
930
+ * ```
931
+ */
932
+ declare const HAZO_FILES_TABLE_SCHEMA: HazoFilesTableSchema;
933
+ /**
934
+ * Get DDL for a custom table name
935
+ *
936
+ * @param tableName - Custom table name to use
937
+ * @param dbType - Database type ('sqlite' | 'postgres')
938
+ * @returns DDL and index statements with the custom table name
939
+ */
940
+ declare function getSchemaForTable(tableName: string, dbType: 'sqlite' | 'postgres'): DatabaseSchemaDefinition;
941
+
791
942
  /**
792
943
  * Common utility functions
793
944
  */
@@ -1461,4 +1612,4 @@ declare function updateExtractionById(fileData: FileDataStructure, id: string, n
1461
1612
  mergeStrategy?: 'shallow' | 'deep';
1462
1613
  }): OperationResult<FileDataStructure>;
1463
1614
 
1464
- export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AuthCallbacks, AuthenticationError, ConfigurationError, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, type ExtractionData, type FileBrowserState, type FileDataStructure, FileExistsError, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileSystemItem, FileTooLargeError, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, type HazoFilesConfig, HazoFilesError, InvalidExtensionError, InvalidPathError, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MoveOptions, type NameGenerationOptions, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TreeNode, type UploadOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, clearExtractions, clonePattern, createAndInitializeModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLiteralSegment, createLocalModule, createModule, createTrackedFileManager, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMimeType, getNameWithoutExtension, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, 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, normalizePath, parseConfig, parseFileData, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, sanitizeFilename, saveConfig, sortItems, stringifyFileData, successResult, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
1615
+ export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AuthCallbacks, AuthenticationError, ConfigurationError, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseSchemaDefinition, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, type ExtractionData, type FileBrowserState, type FileDataStructure, FileExistsError, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileSystemItem, FileTooLargeError, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, HAZO_FILES_DEFAULT_TABLE_NAME, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesTableSchema, InvalidExtensionError, InvalidPathError, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MoveOptions, type NameGenerationOptions, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TreeNode, type UploadOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, clearExtractions, clonePattern, createAndInitializeModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLiteralSegment, createLocalModule, createModule, createTrackedFileManager, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMimeType, getNameWithoutExtension, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSchemaForTable, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, 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, normalizePath, parseConfig, parseFileData, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, sanitizeFilename, saveConfig, sortItems, stringifyFileData, successResult, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
package/dist/index.d.ts CHANGED
@@ -542,7 +542,52 @@ interface MetadataLogger {
542
542
  error?(message: string, data?: Record<string, unknown>): void;
543
543
  }
544
544
  /**
545
- * Minimal CRUD service interface (compatible with hazo_connect CrudService)
545
+ * Minimal CRUD service interface compatible with hazo_connect CrudService.
546
+ *
547
+ * This interface is a structural subset of hazo_connect's CrudService,
548
+ * allowing you to pass a hazo_connect CrudService directly without any adapter.
549
+ *
550
+ * @example Using with hazo_connect
551
+ * ```typescript
552
+ * import { createHazoConnect, createCrudService } from 'hazo_connect/server';
553
+ * import {
554
+ * createFileMetadataService,
555
+ * HAZO_FILES_TABLE_SCHEMA
556
+ * } from 'hazo_files';
557
+ * import type { FileMetadataRecord } from 'hazo_files';
558
+ *
559
+ * // 1. Create database table during app setup
560
+ * await db.run(HAZO_FILES_TABLE_SCHEMA.sqlite.ddl);
561
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
562
+ * await db.run(idx);
563
+ * }
564
+ *
565
+ * // 2. Create hazo_connect CRUD service
566
+ * const adapter = createHazoConnect({
567
+ * type: 'sqlite',
568
+ * database_path: './data.db'
569
+ * });
570
+ * const crud = createCrudService<FileMetadataRecord>(
571
+ * adapter,
572
+ * HAZO_FILES_TABLE_SCHEMA.tableName
573
+ * );
574
+ *
575
+ * // 3. Pass directly to hazo_files - NO ADAPTER NEEDED
576
+ * const metadataService = createFileMetadataService(crud);
577
+ *
578
+ * // 4. Use the service
579
+ * await metadataService.addExtraction(
580
+ * '/documents/report.pdf',
581
+ * 'local',
582
+ * { summary: 'Quarterly report' },
583
+ * { source: 'gpt-4' }
584
+ * );
585
+ * ```
586
+ *
587
+ * @remarks
588
+ * The hazo_connect CrudService has additional methods (findById, query)
589
+ * that are not used by FileMetadataService, making this interface
590
+ * a compatible subset.
546
591
  */
547
592
  interface CrudServiceLike<T> {
548
593
  list(configure?: (qb: unknown) => unknown): Promise<T[]>;
@@ -788,6 +833,112 @@ declare function generateSampleConfig(): string;
788
833
  */
789
834
  declare function saveConfig(config: HazoFilesConfig, configPath?: string): Promise<void>;
790
835
 
836
+ /**
837
+ * Database Schema Exports for hazo_files
838
+ *
839
+ * Provides DDL statements for creating the hazo_files table in different databases.
840
+ * Consuming applications can use these to set up their database schema.
841
+ *
842
+ * @example
843
+ * ```typescript
844
+ * import { HAZO_FILES_TABLE_SCHEMA } from 'hazo_files';
845
+ *
846
+ * // For SQLite
847
+ * await db.run(HAZO_FILES_TABLE_SCHEMA.sqlite.ddl);
848
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
849
+ * await db.run(idx);
850
+ * }
851
+ *
852
+ * // For PostgreSQL
853
+ * await client.query(HAZO_FILES_TABLE_SCHEMA.postgres.ddl);
854
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.postgres.indexes) {
855
+ * await client.query(idx);
856
+ * }
857
+ * ```
858
+ */
859
+ /**
860
+ * Column definitions for the hazo_files table
861
+ */
862
+ interface HazoFilesColumnDefinitions {
863
+ /** Primary key (UUID) */
864
+ id: 'TEXT' | 'UUID';
865
+ /** File or folder name */
866
+ filename: 'TEXT';
867
+ /** MIME type for files, 'folder' for directories */
868
+ file_type: 'TEXT';
869
+ /** Custom metadata as JSON string */
870
+ file_data: 'TEXT';
871
+ /** ISO timestamp when record was created */
872
+ created_at: 'TEXT' | 'TIMESTAMP';
873
+ /** ISO timestamp of last modification */
874
+ changed_at: 'TEXT' | 'TIMESTAMP';
875
+ /** Virtual path in storage */
876
+ file_path: 'TEXT';
877
+ /** Storage provider type ('local' | 'google_drive') */
878
+ storage_type: 'TEXT';
879
+ }
880
+ /**
881
+ * Schema definition for a specific database type
882
+ */
883
+ interface DatabaseSchemaDefinition {
884
+ /** CREATE TABLE statement */
885
+ ddl: string;
886
+ /** CREATE INDEX statements */
887
+ indexes: string[];
888
+ }
889
+ /**
890
+ * Complete schema definition for hazo_files table
891
+ */
892
+ interface HazoFilesTableSchema {
893
+ /** Default table name */
894
+ tableName: string;
895
+ /** SQLite-specific DDL */
896
+ sqlite: DatabaseSchemaDefinition;
897
+ /** PostgreSQL-specific DDL */
898
+ postgres: DatabaseSchemaDefinition;
899
+ /** Column names for reference */
900
+ columns: readonly string[];
901
+ }
902
+ /**
903
+ * Default table name for hazo_files metadata
904
+ */
905
+ declare const HAZO_FILES_DEFAULT_TABLE_NAME = "hazo_files";
906
+ /**
907
+ * DDL schema for the hazo_files table.
908
+ *
909
+ * Use these DDL statements to create the required database table
910
+ * in consuming applications.
911
+ *
912
+ * @example Using with hazo_connect
913
+ * ```typescript
914
+ * import { createHazoConnect, createCrudService } from 'hazo_connect/server';
915
+ * import { createFileMetadataService, HAZO_FILES_TABLE_SCHEMA } from 'hazo_files';
916
+ * import type { FileMetadataRecord } from 'hazo_files';
917
+ *
918
+ * // 1. Create table during app setup
919
+ * await db.run(HAZO_FILES_TABLE_SCHEMA.sqlite.ddl);
920
+ * for (const idx of HAZO_FILES_TABLE_SCHEMA.sqlite.indexes) {
921
+ * await db.run(idx);
922
+ * }
923
+ *
924
+ * // 2. Create hazo_connect CRUD service
925
+ * const adapter = createHazoConnect({ type: 'sqlite', database_path: './data.db' });
926
+ * const crud = createCrudService<FileMetadataRecord>(adapter, HAZO_FILES_TABLE_SCHEMA.tableName);
927
+ *
928
+ * // 3. Pass directly to hazo_files - no adapter needed!
929
+ * const metadataService = createFileMetadataService(crud);
930
+ * ```
931
+ */
932
+ declare const HAZO_FILES_TABLE_SCHEMA: HazoFilesTableSchema;
933
+ /**
934
+ * Get DDL for a custom table name
935
+ *
936
+ * @param tableName - Custom table name to use
937
+ * @param dbType - Database type ('sqlite' | 'postgres')
938
+ * @returns DDL and index statements with the custom table name
939
+ */
940
+ declare function getSchemaForTable(tableName: string, dbType: 'sqlite' | 'postgres'): DatabaseSchemaDefinition;
941
+
791
942
  /**
792
943
  * Common utility functions
793
944
  */
@@ -1461,4 +1612,4 @@ declare function updateExtractionById(fileData: FileDataStructure, id: string, n
1461
1612
  mergeStrategy?: 'shallow' | 'deep';
1462
1613
  }): OperationResult<FileDataStructure>;
1463
1614
 
1464
- export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AuthCallbacks, AuthenticationError, ConfigurationError, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, type ExtractionData, type FileBrowserState, type FileDataStructure, FileExistsError, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileSystemItem, FileTooLargeError, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, type HazoFilesConfig, HazoFilesError, InvalidExtensionError, InvalidPathError, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MoveOptions, type NameGenerationOptions, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TreeNode, type UploadOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, clearExtractions, clonePattern, createAndInitializeModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLiteralSegment, createLocalModule, createModule, createTrackedFileManager, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMimeType, getNameWithoutExtension, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, 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, normalizePath, parseConfig, parseFileData, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, sanitizeFilename, saveConfig, sortItems, stringifyFileData, successResult, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
1615
+ export { ALL_SYSTEM_VARIABLES, type AddExtractionOptions, type AuthCallbacks, AuthenticationError, ConfigurationError, type CrudServiceLike, DEFAULT_DATE_FORMATS, type DatabaseSchemaDefinition, type DatabaseTrackingConfig, DirectoryExistsError, DirectoryNotEmptyError, DirectoryNotFoundError, type DownloadOptions, type ExtractionData, type FileBrowserState, type FileDataStructure, FileExistsError, type FileItem, FileManager, type FileManagerOptions, type FileMetadataInput, type FileMetadataRecord, FileMetadataService, type FileMetadataServiceOptions, type FileMetadataUpdate, FileNotFoundError, type FileSystemItem, FileTooLargeError, type FolderItem, type GeneratedNameResult, type GoogleAuthConfig, GoogleDriveAuth, type GoogleDriveConfig, GoogleDriveModule, HAZO_FILES_DEFAULT_TABLE_NAME, HAZO_FILES_TABLE_SCHEMA, type HazoFilesColumnDefinitions, type HazoFilesConfig, HazoFilesError, type HazoFilesTableSchema, InvalidExtensionError, InvalidPathError, type ListOptions, type LocalStorageConfig, LocalStorageModule, type MetadataLogger, type MoveOptions, type NameGenerationOptions, type NamingRuleConfiguratorProps, type NamingRuleHistoryEntry, type NamingRuleSchema, type NamingVariable, OperationError, type OperationResult, type PatternSegment, PermissionDeniedError, type ProgressCallback, type RemoveExtractionOptions, type RenameOptions, SYSTEM_COUNTER_VARIABLES, SYSTEM_DATE_VARIABLES, SYSTEM_FILE_VARIABLES, type StorageModule, type StorageProvider, type TokenData, TrackedFileManager, type TrackedFileManagerFullOptions, type TrackedFileManagerOptions, type TreeNode, type UploadOptions, type UseNamingRuleActions, type UseNamingRuleReturn, type UseNamingRuleState, type VariableCategory, addExtractionToFileData, clearExtractions, clonePattern, createAndInitializeModule, createEmptyFileDataStructure, createEmptyNamingRuleSchema, createFileItem, createFileManager, createFileMetadataService, createFolderItem, createGoogleDriveAuth, createGoogleDriveModule, createInitializedFileManager, createInitializedTrackedFileManager, createLiteralSegment, createLocalModule, createModule, createTrackedFileManager, createVariableSegment, deepMerge, errorResult, filterItems, formatBytes, formatCounter, formatDateToken, generateExtractionId, generateId, generatePreviewName, generateSampleConfig, generateSegmentId, getBaseName, getBreadcrumbs, getDirName, getExtension, getExtensionFromMime, getExtractionById, getExtractionCount, getExtractions, getFileCategory, getFileMetadataValues, getMergedData, getMimeType, getNameWithoutExtension, getParentPath, getPathSegments, getRegisteredProviders, getRelativePath, getSchemaForTable, getSystemVariablePreviewValues, hasExtension, hasExtractionStructure, 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, normalizePath, parseConfig, parseFileData, parsePatternString, patternToString, recalculateMergedData, registerModule, removeExtractionById, removeExtractionByIndex, sanitizeFilename, saveConfig, sortItems, stringifyFileData, successResult, updateExtractionById, validateExtractionData, validateFileDataStructure, validateNamingRuleSchema, validatePath };
package/dist/index.js CHANGED
@@ -44,6 +44,8 @@ __export(index_exports, {
44
44
  FileTooLargeError: () => FileTooLargeError,
45
45
  GoogleDriveAuth: () => GoogleDriveAuth,
46
46
  GoogleDriveModule: () => GoogleDriveModule,
47
+ HAZO_FILES_DEFAULT_TABLE_NAME: () => HAZO_FILES_DEFAULT_TABLE_NAME,
48
+ HAZO_FILES_TABLE_SCHEMA: () => HAZO_FILES_TABLE_SCHEMA,
47
49
  HazoFilesError: () => HazoFilesError,
48
50
  InvalidExtensionError: () => InvalidExtensionError,
49
51
  InvalidPathError: () => InvalidPathError,
@@ -101,6 +103,7 @@ __export(index_exports, {
101
103
  getPathSegments: () => getPathSegments,
102
104
  getRegisteredProviders: () => getRegisteredProviders,
103
105
  getRelativePath: () => getRelativePath,
106
+ getSchemaForTable: () => getSchemaForTable,
104
107
  getSystemVariablePreviewValues: () => getSystemVariablePreviewValues,
105
108
  hasExtension: () => hasExtension,
106
109
  hasExtractionStructure: () => hasExtractionStructure,
@@ -2856,6 +2859,66 @@ async function createInitializedTrackedFileManager(options) {
2856
2859
  return manager;
2857
2860
  }
2858
2861
 
2862
+ // src/schema/index.ts
2863
+ var HAZO_FILES_DEFAULT_TABLE_NAME = "hazo_files";
2864
+ var HAZO_FILES_TABLE_SCHEMA = {
2865
+ tableName: HAZO_FILES_DEFAULT_TABLE_NAME,
2866
+ sqlite: {
2867
+ ddl: `CREATE TABLE IF NOT EXISTS hazo_files (
2868
+ id TEXT PRIMARY KEY,
2869
+ filename TEXT NOT NULL,
2870
+ file_type TEXT NOT NULL,
2871
+ file_data TEXT DEFAULT '{}',
2872
+ created_at TEXT NOT NULL,
2873
+ changed_at TEXT NOT NULL,
2874
+ file_path TEXT NOT NULL,
2875
+ storage_type TEXT NOT NULL
2876
+ )`,
2877
+ indexes: [
2878
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_path ON hazo_files (file_path)",
2879
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_storage ON hazo_files (storage_type)",
2880
+ "CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_files_path_storage ON hazo_files (file_path, storage_type)"
2881
+ ]
2882
+ },
2883
+ postgres: {
2884
+ ddl: `CREATE TABLE IF NOT EXISTS hazo_files (
2885
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
2886
+ filename TEXT NOT NULL,
2887
+ file_type TEXT NOT NULL,
2888
+ file_data TEXT DEFAULT '{}',
2889
+ created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
2890
+ changed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
2891
+ file_path TEXT NOT NULL,
2892
+ storage_type TEXT NOT NULL
2893
+ )`,
2894
+ indexes: [
2895
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_path ON hazo_files (file_path)",
2896
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_storage ON hazo_files (storage_type)",
2897
+ "CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_files_path_storage ON hazo_files (file_path, storage_type)"
2898
+ ]
2899
+ },
2900
+ columns: [
2901
+ "id",
2902
+ "filename",
2903
+ "file_type",
2904
+ "file_data",
2905
+ "created_at",
2906
+ "changed_at",
2907
+ "file_path",
2908
+ "storage_type"
2909
+ ]
2910
+ };
2911
+ function getSchemaForTable(tableName, dbType) {
2912
+ const schema = HAZO_FILES_TABLE_SCHEMA[dbType];
2913
+ const defaultName = HAZO_FILES_TABLE_SCHEMA.tableName;
2914
+ return {
2915
+ ddl: schema.ddl.replace(new RegExp(defaultName, "g"), tableName),
2916
+ indexes: schema.indexes.map(
2917
+ (idx) => idx.replace(new RegExp(defaultName, "g"), tableName)
2918
+ )
2919
+ };
2920
+ }
2921
+
2859
2922
  // src/common/naming-utils.ts
2860
2923
  var DEFAULT_DATE_FORMATS = [
2861
2924
  "YYYY",
@@ -3192,6 +3255,8 @@ function generatePreviewName(pattern, userVariables, options = {}) {
3192
3255
  FileTooLargeError,
3193
3256
  GoogleDriveAuth,
3194
3257
  GoogleDriveModule,
3258
+ HAZO_FILES_DEFAULT_TABLE_NAME,
3259
+ HAZO_FILES_TABLE_SCHEMA,
3195
3260
  HazoFilesError,
3196
3261
  InvalidExtensionError,
3197
3262
  InvalidPathError,
@@ -3249,6 +3314,7 @@ function generatePreviewName(pattern, userVariables, options = {}) {
3249
3314
  getPathSegments,
3250
3315
  getRegisteredProviders,
3251
3316
  getRelativePath,
3317
+ getSchemaForTable,
3252
3318
  getSystemVariablePreviewValues,
3253
3319
  hasExtension,
3254
3320
  hasExtractionStructure,
package/dist/index.mjs CHANGED
@@ -2710,6 +2710,66 @@ async function createInitializedTrackedFileManager(options) {
2710
2710
  return manager;
2711
2711
  }
2712
2712
 
2713
+ // src/schema/index.ts
2714
+ var HAZO_FILES_DEFAULT_TABLE_NAME = "hazo_files";
2715
+ var HAZO_FILES_TABLE_SCHEMA = {
2716
+ tableName: HAZO_FILES_DEFAULT_TABLE_NAME,
2717
+ sqlite: {
2718
+ ddl: `CREATE TABLE IF NOT EXISTS hazo_files (
2719
+ id TEXT PRIMARY KEY,
2720
+ filename TEXT NOT NULL,
2721
+ file_type TEXT NOT NULL,
2722
+ file_data TEXT DEFAULT '{}',
2723
+ created_at TEXT NOT NULL,
2724
+ changed_at TEXT NOT NULL,
2725
+ file_path TEXT NOT NULL,
2726
+ storage_type TEXT NOT NULL
2727
+ )`,
2728
+ indexes: [
2729
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_path ON hazo_files (file_path)",
2730
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_storage ON hazo_files (storage_type)",
2731
+ "CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_files_path_storage ON hazo_files (file_path, storage_type)"
2732
+ ]
2733
+ },
2734
+ postgres: {
2735
+ ddl: `CREATE TABLE IF NOT EXISTS hazo_files (
2736
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
2737
+ filename TEXT NOT NULL,
2738
+ file_type TEXT NOT NULL,
2739
+ file_data TEXT DEFAULT '{}',
2740
+ created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
2741
+ changed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
2742
+ file_path TEXT NOT NULL,
2743
+ storage_type TEXT NOT NULL
2744
+ )`,
2745
+ indexes: [
2746
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_path ON hazo_files (file_path)",
2747
+ "CREATE INDEX IF NOT EXISTS idx_hazo_files_storage ON hazo_files (storage_type)",
2748
+ "CREATE UNIQUE INDEX IF NOT EXISTS idx_hazo_files_path_storage ON hazo_files (file_path, storage_type)"
2749
+ ]
2750
+ },
2751
+ columns: [
2752
+ "id",
2753
+ "filename",
2754
+ "file_type",
2755
+ "file_data",
2756
+ "created_at",
2757
+ "changed_at",
2758
+ "file_path",
2759
+ "storage_type"
2760
+ ]
2761
+ };
2762
+ function getSchemaForTable(tableName, dbType) {
2763
+ const schema = HAZO_FILES_TABLE_SCHEMA[dbType];
2764
+ const defaultName = HAZO_FILES_TABLE_SCHEMA.tableName;
2765
+ return {
2766
+ ddl: schema.ddl.replace(new RegExp(defaultName, "g"), tableName),
2767
+ indexes: schema.indexes.map(
2768
+ (idx) => idx.replace(new RegExp(defaultName, "g"), tableName)
2769
+ )
2770
+ };
2771
+ }
2772
+
2713
2773
  // src/common/naming-utils.ts
2714
2774
  var DEFAULT_DATE_FORMATS = [
2715
2775
  "YYYY",
@@ -3045,6 +3105,8 @@ export {
3045
3105
  FileTooLargeError,
3046
3106
  GoogleDriveAuth,
3047
3107
  GoogleDriveModule,
3108
+ HAZO_FILES_DEFAULT_TABLE_NAME,
3109
+ HAZO_FILES_TABLE_SCHEMA,
3048
3110
  HazoFilesError,
3049
3111
  InvalidExtensionError,
3050
3112
  InvalidPathError,
@@ -3102,6 +3164,7 @@ export {
3102
3164
  getPathSegments,
3103
3165
  getRegisteredProviders,
3104
3166
  getRelativePath,
3167
+ getSchemaForTable,
3105
3168
  getSystemVariablePreviewValues,
3106
3169
  hasExtension,
3107
3170
  hasExtractionStructure,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_files",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "File management including integration to cloud files",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",