@unciatech/file-manager 0.0.19 → 0.0.21
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/chunk-4DQRTTKI.mjs +18 -0
- package/dist/chunk-S4HRPNKF.js +18 -0
- package/dist/cli.js +20 -20
- package/dist/cli.mjs +14 -14
- package/dist/file-manager-4KJI2OA3.d.mts +194 -0
- package/dist/file-manager-4KJI2OA3.d.ts +194 -0
- package/dist/index.d.mts +3 -229
- package/dist/index.d.ts +3 -229
- package/dist/index.js +21 -38
- package/dist/index.mjs +21 -38
- package/dist/mock.d.mts +38 -0
- package/dist/mock.d.ts +38 -0
- package/dist/mock.js +2 -0
- package/dist/mock.mjs +2 -0
- package/package.json +9 -4
package/dist/mock.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { I as IFileManagerProvider, F as FolderId, a as Folder, P as PaginationInfo, b as FileType, c as FileMetaData, d as FileUploadInput, E as EntityId } from './file-manager-4KJI2OA3.mjs';
|
|
2
|
+
|
|
3
|
+
declare class MockProvider implements IFileManagerProvider {
|
|
4
|
+
getFolder(folderId: FolderId): Promise<Folder | null>;
|
|
5
|
+
getFolders(folderId: FolderId, page?: number, limit?: number, query?: string): Promise<{
|
|
6
|
+
folders: Folder[];
|
|
7
|
+
pagination: PaginationInfo;
|
|
8
|
+
}>;
|
|
9
|
+
getTags(): Promise<string[]>;
|
|
10
|
+
getFiles(folderId: FolderId, fileTypes?: FileType[], page?: number, limit?: number, query?: string): Promise<{
|
|
11
|
+
files: FileMetaData[];
|
|
12
|
+
pagination: PaginationInfo;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Get files and folders separately (folders always come first)
|
|
16
|
+
* Folders are not paginated (all folders in current directory are returned)
|
|
17
|
+
* Files are paginated after folders
|
|
18
|
+
*/
|
|
19
|
+
getItems(folderId: FolderId, fileTypes?: FileType[], page?: number, limit?: number, query?: string): Promise<{
|
|
20
|
+
folders: Folder[];
|
|
21
|
+
files: FileMetaData[];
|
|
22
|
+
pagination: PaginationInfo;
|
|
23
|
+
}>;
|
|
24
|
+
createFolder(name: string, parentId?: FolderId): Promise<Folder>;
|
|
25
|
+
private getMetaDataType;
|
|
26
|
+
private getFileType;
|
|
27
|
+
uploadFiles(files: FileUploadInput[], folderId?: FolderId): Promise<FileMetaData[]>;
|
|
28
|
+
renameFolder(folderId: EntityId, newName: string): Promise<Folder>;
|
|
29
|
+
updateFileMetaData(fileId: EntityId, updates: Partial<FileMetaData>): Promise<FileMetaData>;
|
|
30
|
+
deleteFiles(fileIds: EntityId[]): Promise<void>;
|
|
31
|
+
deleteFolders(folderIds: EntityId[]): Promise<void>;
|
|
32
|
+
findFiles(searchQuery: string): Promise<FileMetaData[]>;
|
|
33
|
+
findFolders(searchQuery: string): Promise<Folder[]>;
|
|
34
|
+
moveFiles(fileIds: EntityId[], newFolderId: FolderId): Promise<FileMetaData[]>;
|
|
35
|
+
moveFolders(folderIds: FolderId[], newParentId: FolderId): Promise<Folder[]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { MockProvider };
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { I as IFileManagerProvider, F as FolderId, a as Folder, P as PaginationInfo, b as FileType, c as FileMetaData, d as FileUploadInput, E as EntityId } from './file-manager-4KJI2OA3.js';
|
|
2
|
+
|
|
3
|
+
declare class MockProvider implements IFileManagerProvider {
|
|
4
|
+
getFolder(folderId: FolderId): Promise<Folder | null>;
|
|
5
|
+
getFolders(folderId: FolderId, page?: number, limit?: number, query?: string): Promise<{
|
|
6
|
+
folders: Folder[];
|
|
7
|
+
pagination: PaginationInfo;
|
|
8
|
+
}>;
|
|
9
|
+
getTags(): Promise<string[]>;
|
|
10
|
+
getFiles(folderId: FolderId, fileTypes?: FileType[], page?: number, limit?: number, query?: string): Promise<{
|
|
11
|
+
files: FileMetaData[];
|
|
12
|
+
pagination: PaginationInfo;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Get files and folders separately (folders always come first)
|
|
16
|
+
* Folders are not paginated (all folders in current directory are returned)
|
|
17
|
+
* Files are paginated after folders
|
|
18
|
+
*/
|
|
19
|
+
getItems(folderId: FolderId, fileTypes?: FileType[], page?: number, limit?: number, query?: string): Promise<{
|
|
20
|
+
folders: Folder[];
|
|
21
|
+
files: FileMetaData[];
|
|
22
|
+
pagination: PaginationInfo;
|
|
23
|
+
}>;
|
|
24
|
+
createFolder(name: string, parentId?: FolderId): Promise<Folder>;
|
|
25
|
+
private getMetaDataType;
|
|
26
|
+
private getFileType;
|
|
27
|
+
uploadFiles(files: FileUploadInput[], folderId?: FolderId): Promise<FileMetaData[]>;
|
|
28
|
+
renameFolder(folderId: EntityId, newName: string): Promise<Folder>;
|
|
29
|
+
updateFileMetaData(fileId: EntityId, updates: Partial<FileMetaData>): Promise<FileMetaData>;
|
|
30
|
+
deleteFiles(fileIds: EntityId[]): Promise<void>;
|
|
31
|
+
deleteFolders(folderIds: EntityId[]): Promise<void>;
|
|
32
|
+
findFiles(searchQuery: string): Promise<FileMetaData[]>;
|
|
33
|
+
findFolders(searchQuery: string): Promise<Folder[]>;
|
|
34
|
+
moveFiles(fileIds: EntityId[], newFolderId: FolderId): Promise<FileMetaData[]>;
|
|
35
|
+
moveFolders(folderIds: FolderId[], newParentId: FolderId): Promise<Folder[]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { MockProvider };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkS4HRPNKF_js=require('./chunk-S4HRPNKF.js');var p=[{id:1,name:"Documents",pathId:1,path:"/1",parentId:null,fileCount:20,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:2,name:"Images",pathId:2,path:"/2",parentId:null,fileCount:10,folderCount:3,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:3,name:"Videos",pathId:3,path:"/3",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:4,name:"Music Some Long Name Streched also so long to fit in the card Music Some Long Name Streched also so long to fit in the card",pathId:4,path:"/4",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:5,name:"Archives",pathId:5,path:"/5",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:6,name:"Album 01",pathId:6,path:"/2/6",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:7,name:"Album 02",pathId:7,path:"/2/7",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:8,name:"Squirrels",pathId:8,path:"/2/8",parentId:2,fileCount:1,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")}],b=[{id:1,name:"Important",color:"#ef4444"},{id:2,name:"Work",color:"#3b82f6"},{id:3,name:"Personal",color:"#10b981"},{id:4,name:"Project",color:"#8b5cf6"},{id:5,name:"Archive",color:"#6b7280"}],m=[{id:101,name:"welcome.pdf",url:"/placeholder.svg?height=400&width=300",size:245e3,createdAt:new Date("2024-05-15T10:00:00Z"),updatedAt:new Date("2024-05-15T10:00:00Z"),folderId:null,tags:["important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:2,author:"Admin"}},{id:102,name:"desktop_wallpaper.jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926",size:42e5,createdAt:new Date("2024-05-14T15:30:00Z"),updatedAt:new Date("2024-05-14T15:30:00Z"),folderId:null,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:5e3,height:3333,formats:{thumbnail:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=156",hash:"thumbnail_desktop_wallpaper_abc123",mime:"image/jpeg",name:"thumbnail_desktop_wallpaper.jpg",path:null,size:5.57,width:156,height:104},small:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=500",hash:"small_desktop_wallpaper_abc123",mime:"image/jpeg",name:"small_desktop_wallpaper.jpg",path:null,size:47.27,width:500,height:333},medium:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=750",hash:"medium_desktop_wallpaper_abc123",mime:"image/jpeg",name:"medium_desktop_wallpaper.jpg",path:null,size:97.89,width:750,height:500},large:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=1000",hash:"large_desktop_wallpaper_abc123",mime:"image/jpeg",name:"large_desktop_wallpaper.jpg",path:null,size:159.48,width:1e3,height:667}},metaData:{}},{id:103,name:"quick_notes.txt",url:"/placeholder.svg?height=400&width=300",size:3500,createdAt:new Date("2024-05-13T09:45:00Z"),updatedAt:new Date("2024-05-13T09:45:00Z"),folderId:null,tags:[],mime:"text/plain",ext:".txt",metaData:{}},{id:104,name:"intro_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:12e6,createdAt:new Date("2024-05-12T14:00:00Z"),updatedAt:new Date("2024-05-12T14:00:00Z"),folderId:null,tags:[],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:90,videoSource:"local"}},{id:105,name:"profile_photo.png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde",size:85e4,createdAt:new Date("2024-05-11T11:20:00Z"),updatedAt:new Date("2024-05-11T11:20:00Z"),folderId:null,tags:["personal"],mime:"image/png",ext:".png",width:2e3,height:2e3,formats:{thumbnail:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=156",hash:"thumbnail_profile_photo_def456",mime:"image/png",name:"thumbnail_profile_photo.png",path:null,size:8.2,width:156,height:156},small:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=500",hash:"small_profile_photo_def456",mime:"image/png",name:"small_profile_photo.png",path:null,size:52.3,width:500,height:500},medium:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=750",hash:"medium_profile_photo_def456",mime:"image/png",name:"medium_profile_photo.png",path:null,size:110.5,width:750,height:750},large:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=1000",hash:"large_profile_photo_def456",mime:"image/png",name:"large_profile_photo.png",path:null,size:185.7,width:1e3,height:1e3}},metaData:{}},{id:106,name:"todo_list.md",url:"/placeholder.svg?height=400&width=300",size:6200,createdAt:new Date("2024-05-10T08:30:00Z"),updatedAt:new Date("2024-05-10T08:30:00Z"),folderId:null,tags:["important"],mime:"text/markdown",ext:".md",metaData:{}},{id:107,name:"app_settings.json",url:"/placeholder.svg?height=400&width=300",size:4800,createdAt:new Date("2024-05-09T16:15:00Z"),updatedAt:new Date("2024-05-09T16:15:00Z"),folderId:null,tags:[],mime:"application/json",ext:".json",metaData:{}},{id:108,name:"mountain_landscape.webp",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:12e5,createdAt:new Date("2024-05-08T13:00:00Z"),updatedAt:new Date("2024-05-08T13:00:00Z"),folderId:null,tags:["personal"],mime:"image/webp",ext:".webp",width:4e3,height:2667,metaData:{}},{id:1,name:"Key-Monastery-img.avif",url:"https://unciatrails.com/wp-content/uploads/2024/07/Key-Monastery-img.avif",size:2621440,createdAt:new Date("2023-10-26T10:30:00Z"),updatedAt:new Date("2023-10-26T10:30:00Z"),folderId:8,tags:["personal","important"],mime:"image/avif",ext:".avif",caption:"A cute squirrel in the park",alternativeText:"Gray squirrel sitting on wooden fence",width:3024,height:4032,metaData:{}},{id:2,name:"project_proposal thoda sa.pdf",url:"/placeholder.svg?height=400&width=300",size:1048576,createdAt:new Date("2024-05-10T14:20:00Z"),updatedAt:new Date("2024-05-10T14:20:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:15,author:"John Doe"}},{id:3,name:"quarterly_report.xlsx",url:"/placeholder.svg?height=400&width=300",size:524288,createdAt:new Date("2024-05-08T09:15:00Z"),updatedAt:new Date("2024-05-08T09:15:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:10}},{id:4,name:"presentation.pptx",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:20}},{id:8,name:"documnet.doc",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/msword",ext:".doc",metaData:{pageCount:20}},{id:5,name:"demo_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:10485760,createdAt:new Date("2024-05-03T11:30:00Z"),updatedAt:new Date("2024-05-03T11:30:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:120,videoSource:"remote"}},{id:6,name:"podcast_episode.mp3",url:"/placeholder.svg?height=400&width=300",size:5242880,createdAt:new Date("2024-05-02T10:00:00Z"),updatedAt:new Date("2024-05-02T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:3600}},{id:7,name:"notes.txt",url:"/placeholder.svg?height=400&width=300",size:1024,createdAt:new Date("2024-05-01T09:00:00Z"),updatedAt:new Date("2024-05-01T09:00:00Z"),folderId:1,tags:["work"],mime:"text/plain",ext:".txt",metaData:{}},{id:9,name:"data.json",url:"/placeholder.svg?height=400&width=300",size:2048,createdAt:new Date("2024-04-30T15:00:00Z"),updatedAt:new Date("2024-04-30T15:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:10,name:"archive.zip",url:"/placeholder.svg?height=400&width=300",size:104857600,createdAt:new Date("2024-04-29T12:00:00Z"),updatedAt:new Date("2024-04-29T12:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Project backup"}},{id:11,name:"setup.exe",url:"/placeholder.svg?height=400&width=300",size:52428800,createdAt:new Date("2024-04-28T11:00:00Z"),updatedAt:new Date("2024-04-28T11:00:00Z"),folderId:5,tags:["software"],mime:"application/x-msdownload",ext:".exe",metaData:{description:"Installer"}},{id:12,name:"old_stuff.rar",url:"/placeholder.svg?height=400&width=300",size:20971520,createdAt:new Date("2024-04-27T10:00:00Z"),updatedAt:new Date("2024-04-27T10:00:00Z"),folderId:5,tags:["archive"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Old files"}},{id:13,name:"meeting_notes_q1.pdf",url:"/placeholder.svg?height=400&width=300",size:856e3,createdAt:new Date("2024-03-15T09:00:00Z"),updatedAt:new Date("2024-03-15T09:00:00Z"),folderId:1,tags:["work"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:8,author:"Sarah Johnson"}},{id:14,name:"budget_2024.xlsx",url:"/placeholder.svg?height=400&width=300",size:425e3,createdAt:new Date("2024-03-10T14:30:00Z"),updatedAt:new Date("2024-03-10T14:30:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:5}},{id:15,name:"team_photo.jpg",url:"https://images.unsplash.com/photo-1522071820081-009f0129c71c",size:32e5,createdAt:new Date("2024-02-28T11:00:00Z"),updatedAt:new Date("2024-02-28T11:00:00Z"),folderId:2,tags:["work"],mime:"image/jpeg",ext:".jpg",width:4e3,height:3e3,metaData:{}},{id:16,name:"logo_design.png",url:"https://images.unsplash.com/photo-1611162617474-5b21e879e113",size:15e5,createdAt:new Date("2024-02-20T10:00:00Z"),updatedAt:new Date("2024-02-20T10:00:00Z"),folderId:2,tags:["project"],mime:"image/png",ext:".png",width:2e3,height:2e3,metaData:{}},{id:17,name:"product_demo.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:15e6,createdAt:new Date("2024-02-15T16:00:00Z"),updatedAt:new Date("2024-02-15T16:00:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:180,videoSource:"local"}},{id:18,name:"training_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:25e6,createdAt:new Date("2024-02-10T09:30:00Z"),updatedAt:new Date("2024-02-10T09:30:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:300,videoSource:"local"}},{id:19,name:"background_music.mp3",url:"/placeholder.svg?height=400&width=300",size:45e5,createdAt:new Date("2024-02-05T14:00:00Z"),updatedAt:new Date("2024-02-05T14:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:240}},{id:20,name:"contract_template.docx",url:"/placeholder.svg?height=400&width=300",size:65e4,createdAt:new Date("2024-01-30T11:00:00Z"),updatedAt:new Date("2024-01-30T11:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:12}},{id:21,name:"invoice_jan.pdf",url:"/placeholder.svg?height=400&width=300",size:32e4,createdAt:new Date("2024-01-25T10:00:00Z"),updatedAt:new Date("2024-01-25T10:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:3}},{id:22,name:"vacation_photo1.jpg",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:28e5,createdAt:new Date("2024-01-20T15:00:00Z"),updatedAt:new Date("2024-01-20T15:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:3500,height:2500,metaData:{}},{id:23,name:"vacation_photo2.jpg",url:"https://images.unsplash.com/photo-1469474968028-56623f02e42e",size:31e5,createdAt:new Date("2024-01-20T15:05:00Z"),updatedAt:new Date("2024-01-20T15:05:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2800,metaData:{}},{id:24,name:"project_backup.zip",url:"/placeholder.svg?height=400&width=300",size:85e6,createdAt:new Date("2024-01-15T12:00:00Z"),updatedAt:new Date("2024-01-15T12:00:00Z"),folderId:5,tags:["archive","project"],mime:"application/zip",ext:".zip",metaData:{description:"Full project backup"}},{id:25,name:"presentation_final.pptx",url:"/placeholder.svg?height=400&width=300",size:35e5,createdAt:new Date("2024-01-10T16:00:00Z"),updatedAt:new Date("2024-01-10T16:00:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:35}},{id:26,name:"screenshot_001.png",url:"https://images.unsplash.com/photo-1517694712202-14dd9538aa97",size:12e5,createdAt:new Date("2024-01-05T09:00:00Z"),updatedAt:new Date("2024-01-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/png",ext:".png",width:1920,height:1080,metaData:{}},{id:27,name:"config.json",url:"/placeholder.svg?height=400&width=300",size:5e3,createdAt:new Date("2023-12-28T14:00:00Z"),updatedAt:new Date("2023-12-28T14:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:28,name:"readme.md",url:"/placeholder.svg?height=400&width=300",size:8500,createdAt:new Date("2023-12-20T10:00:00Z"),updatedAt:new Date("2023-12-20T10:00:00Z"),folderId:1,tags:["project"],mime:"text/markdown",ext:".md",metaData:{}},{id:29,name:"database_backup.sql",url:"/placeholder.svg?height=400&width=300",size:12e6,createdAt:new Date("2023-12-15T11:00:00Z"),updatedAt:new Date("2023-12-15T11:00:00Z"),folderId:5,tags:["archive","important"],mime:"application/sql",ext:".sql",metaData:{description:"Database backup"}},{id:30,name:"tutorial_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:18e6,createdAt:new Date("2023-12-10T13:00:00Z"),updatedAt:new Date("2023-12-10T13:00:00Z"),folderId:3,tags:["personal"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:420,videoSource:"local"}},{id:31,name:"company_logo.svg",url:"/placeholder.svg?height=400&width=300",size:45e3,createdAt:new Date("2023-12-05T09:00:00Z"),updatedAt:new Date("2023-12-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/svg+xml",ext:".svg",metaData:{}},{id:32,name:"report_q4.pdf",url:"/placeholder.svg?height=400&width=300",size:18e5,createdAt:new Date("2023-12-01T15:00:00Z"),updatedAt:new Date("2023-12-01T15:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:25,author:"Finance Team"}},{id:33,name:"nature_photo.webp",url:"https://images.unsplash.com/photo-1441974231531-c6227db76b6e",size:95e4,createdAt:new Date("2023-11-25T12:00:00Z"),updatedAt:new Date("2023-11-25T12:00:00Z"),folderId:2,tags:["personal"],mime:"image/webp",ext:".webp",width:3e3,height:2e3,metaData:{}},{id:34,name:"podcast_intro.mp3",url:"/placeholder.svg?height=400&width=300",size:25e5,createdAt:new Date("2023-11-20T10:00:00Z"),updatedAt:new Date("2023-11-20T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:180}},{id:35,name:"data_export.csv",url:"/placeholder.svg?height=400&width=300",size:85e4,createdAt:new Date("2023-11-15T14:00:00Z"),updatedAt:new Date("2023-11-15T14:00:00Z"),folderId:1,tags:["work"],mime:"text/csv",ext:".csv",metaData:{}},{id:36,name:"wireframes.pdf",url:"/placeholder.svg?height=400&width=300",size:42e5,createdAt:new Date("2023-11-10T11:00:00Z"),updatedAt:new Date("2023-11-10T11:00:00Z"),folderId:1,tags:["project"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:45}},{id:37,name:"cityscape.jpg",url:"https://images.unsplash.com/photo-1449824913935-59a10b8d2000",size:38e5,createdAt:new Date("2023-11-05T16:00:00Z"),updatedAt:new Date("2023-11-05T16:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4500,height:3e3,metaData:{}},{id:38,name:"interview_recording.mp3",url:"/placeholder.svg?height=400&width=300",size:85e5,createdAt:new Date("2023-11-01T09:00:00Z"),updatedAt:new Date("2023-11-01T09:00:00Z"),folderId:4,tags:["work"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:1800}},{id:39,name:"client_files.rar",url:"/placeholder.svg?height=400&width=300",size:45e6,createdAt:new Date("2023-10-25T13:00:00Z"),updatedAt:new Date("2023-10-25T13:00:00Z"),folderId:5,tags:["archive","work"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Client deliverables"}},{id:40,name:"marketing_plan.docx",url:"/placeholder.svg?height=400&width=300",size:12e5,createdAt:new Date("2023-10-20T10:00:00Z"),updatedAt:new Date("2023-10-20T10:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:18}},{id:41,name:"analytics_data.xlsx",url:"/placeholder.svg?height=400&width=300",size:21e5,createdAt:new Date("2023-10-15T15:00:00Z"),updatedAt:new Date("2023-10-15T15:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:8}},{id:42,name:"sunset_beach.jpg",url:"https://images.unsplash.com/photo-1507525428034-b723cf961d3e",size:32e5,createdAt:new Date("2023-10-10T17:00:00Z"),updatedAt:new Date("2023-10-10T17:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2700,metaData:{}},{id:43,name:"webinar_recording.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:35e6,createdAt:new Date("2023-10-05T14:00:00Z"),updatedAt:new Date("2023-10-05T14:00:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:600,videoSource:"local"}},{id:44,name:"sound_effects.wav",url:"/placeholder.svg?height=400&width=300",size:15e6,createdAt:new Date("2023-10-01T11:00:00Z"),updatedAt:new Date("2023-10-01T11:00:00Z"),folderId:4,tags:["project"],mime:"audio/wav",ext:".wav",metaData:{duration:120}},{id:45,name:"legacy_system.zip",url:"/placeholder.svg?height=400&width=300",size:125e6,createdAt:new Date("2023-09-25T09:00:00Z"),updatedAt:new Date("2023-09-25T09:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Old system files"}}];var A=v=>new Promise(t=>setTimeout(t,v)),P=class{getFolder(t){if(t===null)return Promise.resolve(null);let a=p.find(i=>i.id===t);if(!a)return Promise.resolve(null);let e=chunkS4HRPNKF_js.a({},a),d=e;for(;d.parentId!==null;){let i=p.find(o=>o.id===d.parentId);if(i)d.parent=chunkS4HRPNKF_js.a({},i),d=d.parent;else break}return Promise.resolve(e)}async getFolders(t,a=1,e=20,d=""){await A(300);let i=t!==null?p.filter(l=>l.parentId===t):p.filter(l=>l.parentId===null),o=i;if(d&&d.trim()){let l=d.toLowerCase().trim();o=i.filter(w=>w.name.toLowerCase().includes(l));}let r=o.sort((l,w)=>new Date(l.createdAt).getTime()-new Date(w.createdAt).getTime()),s=r.length,h=Math.ceil(s/e),u=(a-1)*e;return {folders:r.slice(u,u+e),pagination:{currentPage:a,totalPages:h,totalFiles:s,filesPerPage:e}}}getTags(){return Promise.resolve(b.map(t=>t.name))}async getFiles(t,a,e,d,i){await A(500);let o=[...m];if(t!==null&&(o=o.filter(c=>c.folderId===t)),a&&a.length>0&&(o=o.filter(c=>{let f=chunkS4HRPNKF_js.H(c.mime,c.ext);return a.includes(f)})),i){let c=i==null?void 0:i.toLowerCase();o=o.filter(f=>f.name.toLowerCase().includes(c));}let r=o.sort((c,f)=>new Date(c.createdAt).getTime()-new Date(f.createdAt).getTime()),s=e!=null?e:1,h=d!=null?d:10,u=r.length,T=Math.ceil(u/h),l=(s-1)*h,w=r.slice(l,l+h);return Promise.resolve({files:w,pagination:{currentPage:s,totalPages:T,totalFiles:u,filesPerPage:h}})}async getItems(t,a,e=1,d=24,i=""){await A(300);let o=t!==null?p.filter(n=>n.parentId===t):p.filter(n=>n.parentId===null),r=t!==null?m.filter(n=>n.folderId===t):m.filter(n=>n.folderId===null);if(a&&a.length>0&&(r=r.filter(n=>{let g=chunkS4HRPNKF_js.H(n.mime,n.ext);return a.includes(g)})),i&&i.trim()){let n=i.toLowerCase().trim();o=o.filter(g=>g.name.toLowerCase().includes(n)),r=r.filter(g=>{var F,_;return g.name.toLowerCase().includes(n)||((_=(F=g.ext)==null?void 0:F.toLowerCase().includes(n))!=null?_:false)});}let s=o.sort((n,g)=>new Date(n.createdAt).getTime()-new Date(g.createdAt).getTime()),h=r.sort((n,g)=>new Date(n.createdAt).getTime()-new Date(g.createdAt).getTime()),u=s.length+h.length,T=Math.ceil(u/d)||1,l=(e-1)*d,w=l+d,c=s.slice(Math.max(0,l),Math.min(s.length,w)),f=c.length,C=d-f;Math.min(s.length,l);let Z=Math.max(0,l-s.length),k=h.slice(Z,Z+C);return {folders:c,files:k,pagination:{currentPage:e,totalPages:T,totalFiles:u,filesPerPage:d}}}async createFolder(t,a){await A(300);let e={id:Date.now(),name:t,parentId:a!=null?a:null,pathId:typeof a=="number"?a:0,path:"",fileCount:0,folderCount:0,createdAt:new Date,updatedAt:new Date};return p.push(e),e}getMetaDataType(t,a){return t.type.startsWith("image/")?{}:t.type.startsWith("video/")?{duration:0,videoSource:a!=null?a:chunkS4HRPNKF_js.g.LOCAL}:t.type.startsWith("audio/")?{duration:0}:{description:""}}getFileType(t){var e;let a="."+((e=t.name.split(".").pop())==null?void 0:e.toLowerCase());return chunkS4HRPNKF_js.H(t.type,a)}async uploadFiles(t,a){var d;await A(500);let e=[];for(let{file:i,videoSource:o}of t){let r=this.getFileType(i),s="."+((d=i.name.split(".").pop())==null?void 0:d.toLowerCase()),h={id:Date.now()+Math.random(),name:i.name,folderId:a!=null?a:null,size:i.size,url:URL.createObjectURL(i),mime:i.type||"application/octet-stream",ext:s,metaData:this.getMetaDataType(i,o),createdAt:new Date,updatedAt:new Date,tags:[],width:r===chunkS4HRPNKF_js.e.IMAGE?800:void 0,height:r===chunkS4HRPNKF_js.e.IMAGE?600:void 0};m.push(h),e.push(h);}return e}renameFolder(t,a){let e=p.find(d=>d.id===t);return e?(e.name=a,e.updatedAt=new Date,Promise.resolve(e)):Promise.reject(new Error("Folder not found"))}updateFileMetaData(t,a){let e=m.find(r=>r.id===t);if(!e)return Promise.reject(new Error("File not found"));let o=a,{metaData:d}=o,i=chunkS4HRPNKF_js.c(o,["metaData"]);return Object.assign(e,i),d&&(e.metaData=chunkS4HRPNKF_js.a(chunkS4HRPNKF_js.a({},e.metaData),d)),e.updatedAt=new Date,Promise.resolve(e)}deleteFiles(t){for(let a of t){let e=m.findIndex(d=>d.id===a);e!==-1&&m.splice(e,1);}return Promise.resolve()}deleteFolders(t){for(let a of t){let e=p.findIndex(d=>d.id===a);if(e!==-1){p.splice(e,1);for(let d=m.length-1;d>=0;d--)m[d].folderId===a&&m.splice(d,1);}}return Promise.resolve()}findFiles(t){let a=t==null?void 0:t.toLowerCase(),e=m.filter(d=>{var i;return d.name.toLowerCase().includes(a)||((i=d.tags)==null?void 0:i.some(o=>o.toLowerCase().includes(a)))});return Promise.resolve(e)}findFolders(t){let a=t==null?void 0:t.toLowerCase(),e=p.filter(d=>d.name.toLowerCase().includes(a));return Promise.resolve(e)}moveFiles(t,a){let e=[];for(let d of t){let i=m.find(o=>o.id===d);i&&(i.folderId=a,i.updatedAt=new Date,e.push(i));}return Promise.resolve(e)}moveFolders(t,a){let e=[];for(let d of t){let i=p.find(o=>o.id===d);i&&(i.parentId=a,i.updatedAt=new Date,e.push(i));}return Promise.resolve(e)}};
|
|
2
|
+
exports.MockProvider=P;
|
package/dist/mock.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,H,g,e,c}from'./chunk-4DQRTTKI.mjs';var p=[{id:1,name:"Documents",pathId:1,path:"/1",parentId:null,fileCount:20,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:2,name:"Images",pathId:2,path:"/2",parentId:null,fileCount:10,folderCount:3,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:3,name:"Videos",pathId:3,path:"/3",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:4,name:"Music Some Long Name Streched also so long to fit in the card Music Some Long Name Streched also so long to fit in the card",pathId:4,path:"/4",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:5,name:"Archives",pathId:5,path:"/5",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:6,name:"Album 01",pathId:6,path:"/2/6",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:7,name:"Album 02",pathId:7,path:"/2/7",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:8,name:"Squirrels",pathId:8,path:"/2/8",parentId:2,fileCount:1,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")}],b=[{id:1,name:"Important",color:"#ef4444"},{id:2,name:"Work",color:"#3b82f6"},{id:3,name:"Personal",color:"#10b981"},{id:4,name:"Project",color:"#8b5cf6"},{id:5,name:"Archive",color:"#6b7280"}],m=[{id:101,name:"welcome.pdf",url:"/placeholder.svg?height=400&width=300",size:245e3,createdAt:new Date("2024-05-15T10:00:00Z"),updatedAt:new Date("2024-05-15T10:00:00Z"),folderId:null,tags:["important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:2,author:"Admin"}},{id:102,name:"desktop_wallpaper.jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926",size:42e5,createdAt:new Date("2024-05-14T15:30:00Z"),updatedAt:new Date("2024-05-14T15:30:00Z"),folderId:null,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:5e3,height:3333,formats:{thumbnail:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=156",hash:"thumbnail_desktop_wallpaper_abc123",mime:"image/jpeg",name:"thumbnail_desktop_wallpaper.jpg",path:null,size:5.57,width:156,height:104},small:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=500",hash:"small_desktop_wallpaper_abc123",mime:"image/jpeg",name:"small_desktop_wallpaper.jpg",path:null,size:47.27,width:500,height:333},medium:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=750",hash:"medium_desktop_wallpaper_abc123",mime:"image/jpeg",name:"medium_desktop_wallpaper.jpg",path:null,size:97.89,width:750,height:500},large:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=1000",hash:"large_desktop_wallpaper_abc123",mime:"image/jpeg",name:"large_desktop_wallpaper.jpg",path:null,size:159.48,width:1e3,height:667}},metaData:{}},{id:103,name:"quick_notes.txt",url:"/placeholder.svg?height=400&width=300",size:3500,createdAt:new Date("2024-05-13T09:45:00Z"),updatedAt:new Date("2024-05-13T09:45:00Z"),folderId:null,tags:[],mime:"text/plain",ext:".txt",metaData:{}},{id:104,name:"intro_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:12e6,createdAt:new Date("2024-05-12T14:00:00Z"),updatedAt:new Date("2024-05-12T14:00:00Z"),folderId:null,tags:[],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:90,videoSource:"local"}},{id:105,name:"profile_photo.png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde",size:85e4,createdAt:new Date("2024-05-11T11:20:00Z"),updatedAt:new Date("2024-05-11T11:20:00Z"),folderId:null,tags:["personal"],mime:"image/png",ext:".png",width:2e3,height:2e3,formats:{thumbnail:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=156",hash:"thumbnail_profile_photo_def456",mime:"image/png",name:"thumbnail_profile_photo.png",path:null,size:8.2,width:156,height:156},small:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=500",hash:"small_profile_photo_def456",mime:"image/png",name:"small_profile_photo.png",path:null,size:52.3,width:500,height:500},medium:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=750",hash:"medium_profile_photo_def456",mime:"image/png",name:"medium_profile_photo.png",path:null,size:110.5,width:750,height:750},large:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=1000",hash:"large_profile_photo_def456",mime:"image/png",name:"large_profile_photo.png",path:null,size:185.7,width:1e3,height:1e3}},metaData:{}},{id:106,name:"todo_list.md",url:"/placeholder.svg?height=400&width=300",size:6200,createdAt:new Date("2024-05-10T08:30:00Z"),updatedAt:new Date("2024-05-10T08:30:00Z"),folderId:null,tags:["important"],mime:"text/markdown",ext:".md",metaData:{}},{id:107,name:"app_settings.json",url:"/placeholder.svg?height=400&width=300",size:4800,createdAt:new Date("2024-05-09T16:15:00Z"),updatedAt:new Date("2024-05-09T16:15:00Z"),folderId:null,tags:[],mime:"application/json",ext:".json",metaData:{}},{id:108,name:"mountain_landscape.webp",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:12e5,createdAt:new Date("2024-05-08T13:00:00Z"),updatedAt:new Date("2024-05-08T13:00:00Z"),folderId:null,tags:["personal"],mime:"image/webp",ext:".webp",width:4e3,height:2667,metaData:{}},{id:1,name:"Key-Monastery-img.avif",url:"https://unciatrails.com/wp-content/uploads/2024/07/Key-Monastery-img.avif",size:2621440,createdAt:new Date("2023-10-26T10:30:00Z"),updatedAt:new Date("2023-10-26T10:30:00Z"),folderId:8,tags:["personal","important"],mime:"image/avif",ext:".avif",caption:"A cute squirrel in the park",alternativeText:"Gray squirrel sitting on wooden fence",width:3024,height:4032,metaData:{}},{id:2,name:"project_proposal thoda sa.pdf",url:"/placeholder.svg?height=400&width=300",size:1048576,createdAt:new Date("2024-05-10T14:20:00Z"),updatedAt:new Date("2024-05-10T14:20:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:15,author:"John Doe"}},{id:3,name:"quarterly_report.xlsx",url:"/placeholder.svg?height=400&width=300",size:524288,createdAt:new Date("2024-05-08T09:15:00Z"),updatedAt:new Date("2024-05-08T09:15:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:10}},{id:4,name:"presentation.pptx",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:20}},{id:8,name:"documnet.doc",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/msword",ext:".doc",metaData:{pageCount:20}},{id:5,name:"demo_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:10485760,createdAt:new Date("2024-05-03T11:30:00Z"),updatedAt:new Date("2024-05-03T11:30:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:120,videoSource:"remote"}},{id:6,name:"podcast_episode.mp3",url:"/placeholder.svg?height=400&width=300",size:5242880,createdAt:new Date("2024-05-02T10:00:00Z"),updatedAt:new Date("2024-05-02T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:3600}},{id:7,name:"notes.txt",url:"/placeholder.svg?height=400&width=300",size:1024,createdAt:new Date("2024-05-01T09:00:00Z"),updatedAt:new Date("2024-05-01T09:00:00Z"),folderId:1,tags:["work"],mime:"text/plain",ext:".txt",metaData:{}},{id:9,name:"data.json",url:"/placeholder.svg?height=400&width=300",size:2048,createdAt:new Date("2024-04-30T15:00:00Z"),updatedAt:new Date("2024-04-30T15:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:10,name:"archive.zip",url:"/placeholder.svg?height=400&width=300",size:104857600,createdAt:new Date("2024-04-29T12:00:00Z"),updatedAt:new Date("2024-04-29T12:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Project backup"}},{id:11,name:"setup.exe",url:"/placeholder.svg?height=400&width=300",size:52428800,createdAt:new Date("2024-04-28T11:00:00Z"),updatedAt:new Date("2024-04-28T11:00:00Z"),folderId:5,tags:["software"],mime:"application/x-msdownload",ext:".exe",metaData:{description:"Installer"}},{id:12,name:"old_stuff.rar",url:"/placeholder.svg?height=400&width=300",size:20971520,createdAt:new Date("2024-04-27T10:00:00Z"),updatedAt:new Date("2024-04-27T10:00:00Z"),folderId:5,tags:["archive"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Old files"}},{id:13,name:"meeting_notes_q1.pdf",url:"/placeholder.svg?height=400&width=300",size:856e3,createdAt:new Date("2024-03-15T09:00:00Z"),updatedAt:new Date("2024-03-15T09:00:00Z"),folderId:1,tags:["work"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:8,author:"Sarah Johnson"}},{id:14,name:"budget_2024.xlsx",url:"/placeholder.svg?height=400&width=300",size:425e3,createdAt:new Date("2024-03-10T14:30:00Z"),updatedAt:new Date("2024-03-10T14:30:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:5}},{id:15,name:"team_photo.jpg",url:"https://images.unsplash.com/photo-1522071820081-009f0129c71c",size:32e5,createdAt:new Date("2024-02-28T11:00:00Z"),updatedAt:new Date("2024-02-28T11:00:00Z"),folderId:2,tags:["work"],mime:"image/jpeg",ext:".jpg",width:4e3,height:3e3,metaData:{}},{id:16,name:"logo_design.png",url:"https://images.unsplash.com/photo-1611162617474-5b21e879e113",size:15e5,createdAt:new Date("2024-02-20T10:00:00Z"),updatedAt:new Date("2024-02-20T10:00:00Z"),folderId:2,tags:["project"],mime:"image/png",ext:".png",width:2e3,height:2e3,metaData:{}},{id:17,name:"product_demo.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:15e6,createdAt:new Date("2024-02-15T16:00:00Z"),updatedAt:new Date("2024-02-15T16:00:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:180,videoSource:"local"}},{id:18,name:"training_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:25e6,createdAt:new Date("2024-02-10T09:30:00Z"),updatedAt:new Date("2024-02-10T09:30:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:300,videoSource:"local"}},{id:19,name:"background_music.mp3",url:"/placeholder.svg?height=400&width=300",size:45e5,createdAt:new Date("2024-02-05T14:00:00Z"),updatedAt:new Date("2024-02-05T14:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:240}},{id:20,name:"contract_template.docx",url:"/placeholder.svg?height=400&width=300",size:65e4,createdAt:new Date("2024-01-30T11:00:00Z"),updatedAt:new Date("2024-01-30T11:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:12}},{id:21,name:"invoice_jan.pdf",url:"/placeholder.svg?height=400&width=300",size:32e4,createdAt:new Date("2024-01-25T10:00:00Z"),updatedAt:new Date("2024-01-25T10:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:3}},{id:22,name:"vacation_photo1.jpg",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:28e5,createdAt:new Date("2024-01-20T15:00:00Z"),updatedAt:new Date("2024-01-20T15:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:3500,height:2500,metaData:{}},{id:23,name:"vacation_photo2.jpg",url:"https://images.unsplash.com/photo-1469474968028-56623f02e42e",size:31e5,createdAt:new Date("2024-01-20T15:05:00Z"),updatedAt:new Date("2024-01-20T15:05:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2800,metaData:{}},{id:24,name:"project_backup.zip",url:"/placeholder.svg?height=400&width=300",size:85e6,createdAt:new Date("2024-01-15T12:00:00Z"),updatedAt:new Date("2024-01-15T12:00:00Z"),folderId:5,tags:["archive","project"],mime:"application/zip",ext:".zip",metaData:{description:"Full project backup"}},{id:25,name:"presentation_final.pptx",url:"/placeholder.svg?height=400&width=300",size:35e5,createdAt:new Date("2024-01-10T16:00:00Z"),updatedAt:new Date("2024-01-10T16:00:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:35}},{id:26,name:"screenshot_001.png",url:"https://images.unsplash.com/photo-1517694712202-14dd9538aa97",size:12e5,createdAt:new Date("2024-01-05T09:00:00Z"),updatedAt:new Date("2024-01-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/png",ext:".png",width:1920,height:1080,metaData:{}},{id:27,name:"config.json",url:"/placeholder.svg?height=400&width=300",size:5e3,createdAt:new Date("2023-12-28T14:00:00Z"),updatedAt:new Date("2023-12-28T14:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:28,name:"readme.md",url:"/placeholder.svg?height=400&width=300",size:8500,createdAt:new Date("2023-12-20T10:00:00Z"),updatedAt:new Date("2023-12-20T10:00:00Z"),folderId:1,tags:["project"],mime:"text/markdown",ext:".md",metaData:{}},{id:29,name:"database_backup.sql",url:"/placeholder.svg?height=400&width=300",size:12e6,createdAt:new Date("2023-12-15T11:00:00Z"),updatedAt:new Date("2023-12-15T11:00:00Z"),folderId:5,tags:["archive","important"],mime:"application/sql",ext:".sql",metaData:{description:"Database backup"}},{id:30,name:"tutorial_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:18e6,createdAt:new Date("2023-12-10T13:00:00Z"),updatedAt:new Date("2023-12-10T13:00:00Z"),folderId:3,tags:["personal"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:420,videoSource:"local"}},{id:31,name:"company_logo.svg",url:"/placeholder.svg?height=400&width=300",size:45e3,createdAt:new Date("2023-12-05T09:00:00Z"),updatedAt:new Date("2023-12-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/svg+xml",ext:".svg",metaData:{}},{id:32,name:"report_q4.pdf",url:"/placeholder.svg?height=400&width=300",size:18e5,createdAt:new Date("2023-12-01T15:00:00Z"),updatedAt:new Date("2023-12-01T15:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:25,author:"Finance Team"}},{id:33,name:"nature_photo.webp",url:"https://images.unsplash.com/photo-1441974231531-c6227db76b6e",size:95e4,createdAt:new Date("2023-11-25T12:00:00Z"),updatedAt:new Date("2023-11-25T12:00:00Z"),folderId:2,tags:["personal"],mime:"image/webp",ext:".webp",width:3e3,height:2e3,metaData:{}},{id:34,name:"podcast_intro.mp3",url:"/placeholder.svg?height=400&width=300",size:25e5,createdAt:new Date("2023-11-20T10:00:00Z"),updatedAt:new Date("2023-11-20T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:180}},{id:35,name:"data_export.csv",url:"/placeholder.svg?height=400&width=300",size:85e4,createdAt:new Date("2023-11-15T14:00:00Z"),updatedAt:new Date("2023-11-15T14:00:00Z"),folderId:1,tags:["work"],mime:"text/csv",ext:".csv",metaData:{}},{id:36,name:"wireframes.pdf",url:"/placeholder.svg?height=400&width=300",size:42e5,createdAt:new Date("2023-11-10T11:00:00Z"),updatedAt:new Date("2023-11-10T11:00:00Z"),folderId:1,tags:["project"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:45}},{id:37,name:"cityscape.jpg",url:"https://images.unsplash.com/photo-1449824913935-59a10b8d2000",size:38e5,createdAt:new Date("2023-11-05T16:00:00Z"),updatedAt:new Date("2023-11-05T16:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4500,height:3e3,metaData:{}},{id:38,name:"interview_recording.mp3",url:"/placeholder.svg?height=400&width=300",size:85e5,createdAt:new Date("2023-11-01T09:00:00Z"),updatedAt:new Date("2023-11-01T09:00:00Z"),folderId:4,tags:["work"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:1800}},{id:39,name:"client_files.rar",url:"/placeholder.svg?height=400&width=300",size:45e6,createdAt:new Date("2023-10-25T13:00:00Z"),updatedAt:new Date("2023-10-25T13:00:00Z"),folderId:5,tags:["archive","work"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Client deliverables"}},{id:40,name:"marketing_plan.docx",url:"/placeholder.svg?height=400&width=300",size:12e5,createdAt:new Date("2023-10-20T10:00:00Z"),updatedAt:new Date("2023-10-20T10:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:18}},{id:41,name:"analytics_data.xlsx",url:"/placeholder.svg?height=400&width=300",size:21e5,createdAt:new Date("2023-10-15T15:00:00Z"),updatedAt:new Date("2023-10-15T15:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:8}},{id:42,name:"sunset_beach.jpg",url:"https://images.unsplash.com/photo-1507525428034-b723cf961d3e",size:32e5,createdAt:new Date("2023-10-10T17:00:00Z"),updatedAt:new Date("2023-10-10T17:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2700,metaData:{}},{id:43,name:"webinar_recording.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:35e6,createdAt:new Date("2023-10-05T14:00:00Z"),updatedAt:new Date("2023-10-05T14:00:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:600,videoSource:"local"}},{id:44,name:"sound_effects.wav",url:"/placeholder.svg?height=400&width=300",size:15e6,createdAt:new Date("2023-10-01T11:00:00Z"),updatedAt:new Date("2023-10-01T11:00:00Z"),folderId:4,tags:["project"],mime:"audio/wav",ext:".wav",metaData:{duration:120}},{id:45,name:"legacy_system.zip",url:"/placeholder.svg?height=400&width=300",size:125e6,createdAt:new Date("2023-09-25T09:00:00Z"),updatedAt:new Date("2023-09-25T09:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Old system files"}}];var A=v=>new Promise(t=>setTimeout(t,v)),P=class{getFolder(t){if(t===null)return Promise.resolve(null);let a$1=p.find(i=>i.id===t);if(!a$1)return Promise.resolve(null);let e=a({},a$1),d=e;for(;d.parentId!==null;){let i=p.find(o=>o.id===d.parentId);if(i)d.parent=a({},i),d=d.parent;else break}return Promise.resolve(e)}async getFolders(t,a=1,e=20,d=""){await A(300);let i=t!==null?p.filter(l=>l.parentId===t):p.filter(l=>l.parentId===null),o=i;if(d&&d.trim()){let l=d.toLowerCase().trim();o=i.filter(w=>w.name.toLowerCase().includes(l));}let r=o.sort((l,w)=>new Date(l.createdAt).getTime()-new Date(w.createdAt).getTime()),s=r.length,h=Math.ceil(s/e),u=(a-1)*e;return {folders:r.slice(u,u+e),pagination:{currentPage:a,totalPages:h,totalFiles:s,filesPerPage:e}}}getTags(){return Promise.resolve(b.map(t=>t.name))}async getFiles(t,a,e,d,i){await A(500);let o=[...m];if(t!==null&&(o=o.filter(c=>c.folderId===t)),a&&a.length>0&&(o=o.filter(c=>{let f=H(c.mime,c.ext);return a.includes(f)})),i){let c=i==null?void 0:i.toLowerCase();o=o.filter(f=>f.name.toLowerCase().includes(c));}let r=o.sort((c,f)=>new Date(c.createdAt).getTime()-new Date(f.createdAt).getTime()),s=e!=null?e:1,h=d!=null?d:10,u=r.length,T=Math.ceil(u/h),l=(s-1)*h,w=r.slice(l,l+h);return Promise.resolve({files:w,pagination:{currentPage:s,totalPages:T,totalFiles:u,filesPerPage:h}})}async getItems(t,a,e=1,d=24,i=""){await A(300);let o=t!==null?p.filter(n=>n.parentId===t):p.filter(n=>n.parentId===null),r=t!==null?m.filter(n=>n.folderId===t):m.filter(n=>n.folderId===null);if(a&&a.length>0&&(r=r.filter(n=>{let g=H(n.mime,n.ext);return a.includes(g)})),i&&i.trim()){let n=i.toLowerCase().trim();o=o.filter(g=>g.name.toLowerCase().includes(n)),r=r.filter(g=>{var F,_;return g.name.toLowerCase().includes(n)||((_=(F=g.ext)==null?void 0:F.toLowerCase().includes(n))!=null?_:false)});}let s=o.sort((n,g)=>new Date(n.createdAt).getTime()-new Date(g.createdAt).getTime()),h=r.sort((n,g)=>new Date(n.createdAt).getTime()-new Date(g.createdAt).getTime()),u=s.length+h.length,T=Math.ceil(u/d)||1,l=(e-1)*d,w=l+d,c=s.slice(Math.max(0,l),Math.min(s.length,w)),f=c.length,C=d-f;Math.min(s.length,l);let Z=Math.max(0,l-s.length),k=h.slice(Z,Z+C);return {folders:c,files:k,pagination:{currentPage:e,totalPages:T,totalFiles:u,filesPerPage:d}}}async createFolder(t,a){await A(300);let e={id:Date.now(),name:t,parentId:a!=null?a:null,pathId:typeof a=="number"?a:0,path:"",fileCount:0,folderCount:0,createdAt:new Date,updatedAt:new Date};return p.push(e),e}getMetaDataType(t,a){return t.type.startsWith("image/")?{}:t.type.startsWith("video/")?{duration:0,videoSource:a!=null?a:g.LOCAL}:t.type.startsWith("audio/")?{duration:0}:{description:""}}getFileType(t){var e;let a="."+((e=t.name.split(".").pop())==null?void 0:e.toLowerCase());return H(t.type,a)}async uploadFiles(t,a){var d;await A(500);let e$1=[];for(let{file:i,videoSource:o}of t){let r=this.getFileType(i),s="."+((d=i.name.split(".").pop())==null?void 0:d.toLowerCase()),h={id:Date.now()+Math.random(),name:i.name,folderId:a!=null?a:null,size:i.size,url:URL.createObjectURL(i),mime:i.type||"application/octet-stream",ext:s,metaData:this.getMetaDataType(i,o),createdAt:new Date,updatedAt:new Date,tags:[],width:r===e.IMAGE?800:void 0,height:r===e.IMAGE?600:void 0};m.push(h),e$1.push(h);}return e$1}renameFolder(t,a){let e=p.find(d=>d.id===t);return e?(e.name=a,e.updatedAt=new Date,Promise.resolve(e)):Promise.reject(new Error("Folder not found"))}updateFileMetaData(t,a$1){let e=m.find(r=>r.id===t);if(!e)return Promise.reject(new Error("File not found"));let o=a$1,{metaData:d}=o,i=c(o,["metaData"]);return Object.assign(e,i),d&&(e.metaData=a(a({},e.metaData),d)),e.updatedAt=new Date,Promise.resolve(e)}deleteFiles(t){for(let a of t){let e=m.findIndex(d=>d.id===a);e!==-1&&m.splice(e,1);}return Promise.resolve()}deleteFolders(t){for(let a of t){let e=p.findIndex(d=>d.id===a);if(e!==-1){p.splice(e,1);for(let d=m.length-1;d>=0;d--)m[d].folderId===a&&m.splice(d,1);}}return Promise.resolve()}findFiles(t){let a=t==null?void 0:t.toLowerCase(),e=m.filter(d=>{var i;return d.name.toLowerCase().includes(a)||((i=d.tags)==null?void 0:i.some(o=>o.toLowerCase().includes(a)))});return Promise.resolve(e)}findFolders(t){let a=t==null?void 0:t.toLowerCase(),e=p.filter(d=>d.name.toLowerCase().includes(a));return Promise.resolve(e)}moveFiles(t,a){let e=[];for(let d of t){let i=m.find(o=>o.id===d);i&&(i.folderId=a,i.updatedAt=new Date,e.push(i));}return Promise.resolve(e)}moveFolders(t,a){let e=[];for(let d of t){let i=p.find(o=>o.id===d);i&&(i.parentId=a,i.updatedAt=new Date,e.push(i));}return Promise.resolve(e)}};
|
|
2
|
+
export{P as MockProvider};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unciatech/file-manager",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
"require": "./dist/index.js",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
},
|
|
17
|
+
"./mock": {
|
|
18
|
+
"types": "./dist/mock.d.ts",
|
|
19
|
+
"import": "./dist/mock.mjs",
|
|
20
|
+
"require": "./dist/mock.js",
|
|
21
|
+
"default": "./dist/mock.js"
|
|
22
|
+
},
|
|
17
23
|
"./styles": "./dist/styles.css"
|
|
18
24
|
},
|
|
19
25
|
"files": [
|
|
@@ -45,10 +51,10 @@
|
|
|
45
51
|
"mime": "^4.1.0",
|
|
46
52
|
"radix-ui": "^1.4.3",
|
|
47
53
|
"sonner": "^2.0.7",
|
|
48
|
-
"tailwind-merge": "^3.5.0"
|
|
54
|
+
"tailwind-merge": "^3.5.0",
|
|
55
|
+
"tw-animate-css": "^1.4.0"
|
|
49
56
|
},
|
|
50
57
|
"peerDependencies": {
|
|
51
|
-
"lucide-react": ">=0.400.0",
|
|
52
58
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
53
59
|
"react": "^18.2.0 || ^19.0.0",
|
|
54
60
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
@@ -62,7 +68,6 @@
|
|
|
62
68
|
"eslint-config-next": "16.1.0",
|
|
63
69
|
"tailwindcss": "^4.2.1",
|
|
64
70
|
"tsup": "^8.5.1",
|
|
65
|
-
"tw-animate-css": "^1.4.0",
|
|
66
71
|
"typescript": "^5.9.3"
|
|
67
72
|
}
|
|
68
73
|
}
|