UNPKG

nhfs

Version:

NHFS — A sleek HTTP file server for the web built with Next.js and HeroUI. (Alpha)

139 lines (117 loc) 2.71 kB
export type RenameFileErrorTypes = | 'MISSING_PATH' | 'SOURCE_NOT_FOUND' | 'DEST_ALREADY_EXISTS' | 'NO_WRITE_PERMISSION' | 'UNKNOWN'; export type RenameFileResult = FileOperationsType<string, RenameFileErrorTypes>; import { SVGProps } from 'react'; export type IconSvgProps = SVGProps<SVGSVGElement> & { size?: number; }; export type FileTypes = | 'dir' | 'file' | 'symlink' | 'video' | 'audio' | 'text' | 'image' | 'other'; export type FileTypesWithPreview = Extract< FileTypes, 'video' | 'audio' | 'image' | 'text' >; export type FileTimeEntry = { access: Date; create: Date; modified: Date; }; export type FileEntry = { name: string; type: FileTypes; path: string; parentPath: string; permissions: FilePermissions; size: number; time?: FileTimeEntry; }; export type DirEntry = { name: string; path: string; parentPath: string; children: FileEntry[]; time: FileTimeEntry; type: 'dir'; }; export type FileOperationError = { ok: false; code: FileErrorTypes; msg: string; }; export type FileEntrySuccess = DirEntry | FileEntry; export type FileEntryError = { code: FileErrorTypes; msg?: unknown; }; export type GetDataResult = Result<DirEntry | FileEntry, FileEntryError>; export type FilePermissions = | ['read'?, 'write'?, 'execute'?] | 'EACCES' | 'ENOENT'; export type downloadFileSuccess = { error: false; content: any; contentType: string; contentLength: number; }; export type downloadFileError = { error: true; code: FileErrorTypes; msg: string; }; export type downloadFileResult = downloadFileSuccess | downloadFileError; export type BreadcrumbsItemsProps = { name: string; path: string; type?: 'file' | 'dir'; }[]; export type FileErrorTypes = | 'EACCES' | 'EPERM' | 'ENOENT' | 'EEXIST' | 'EPATHINJECTION' | 'EIO' | 'EINVAL' | 'EXDEV' | 'ENOTDIR' | 'EISDIR' | 'EBUSY' | 'EFBIG' | 'UNKNOWN'; export type CopyFileErrorTypes = | 'MISSING_PATH' | 'SOURCE_NOT_FOUND' | 'DEST_DIR_NOT_FOUND' | 'NO_READ_PERMISSION' | 'NO_WRITE_PERMISSION' | 'COPY_FAILED' | 'DEST_ALREADY_EXISTS' | 'UNKNOWN'; export type FileOperationsType<T, E> = Result<T, E>; export type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }; export type CopyFileResult = FileOperationsType<string, CopyFileErrorTypes>; export type DeleteFileResult = FileOperationsType<string, FileErrorTypes>; export type UploadFileEntry = { file: File; error?: FileErrorTypes | string; errorMessage?: string; progress: number; size: number; name: string; type: FileTypes; status: 'pending' | 'uploading' | 'completed' | 'error'; id: string; path: string; };