1
1
import type { CID } from 'multiformats/cid'
2
- import { Perform , Spawn } from " ../task"
2
+ import { Perform , Spawn } from ' ../task'
3
3
4
4
export type { Perform , Spawn }
5
5
6
6
export type Pin = {
7
7
cid : CID
8
8
}
9
9
10
- export type Model = {
11
- pageContent : null | PageContent
12
- pins : string [ ]
13
- sorting : Sorting
14
- mfsSize : number
10
+ type FileType = 'directory' | 'file' | 'unknown'
15
11
16
- pending : PendingJob < any , any > [ ]
17
- finished : FinishedJob < any > [ ]
18
- failed : FailedJob [ ]
19
- }
12
+ type Time = number
20
13
14
+ type FileStat = {
15
+ size : number ,
16
+ type : FileType ,
17
+ cid : CID ,
18
+ name : string ,
19
+ path : string ,
20
+ pinned : boolean
21
+ isParent : boolean | void
22
+ }
21
23
22
- export interface JobInfo {
23
- type : Message [ 'type' ]
24
- id : Symbol
25
- start : number
24
+ type UnknownContent = {
25
+ type : 'unknown' ,
26
+ fetched : Time ,
27
+ path : string ,
28
+ cid : CID ,
29
+ size : 0
26
30
}
27
31
32
+ type FileContent = {
33
+ type : 'file' ,
34
+ fetched : Time ,
35
+ path : string ,
36
+ cid : CID ,
37
+ size : number ,
28
38
29
- export interface PendingJob < M , I > extends JobInfo {
30
- status : 'Pending'
31
- init : I
32
- message ?: M
39
+ name : string ,
40
+ pinned : boolean
33
41
}
34
42
43
+ export type DirectoryContent = {
44
+ type : 'directory' ,
45
+ fetched : Time ,
46
+ path : string ,
47
+ cid : CID ,
35
48
36
- export interface FailedJob extends JobInfo {
37
- status : 'Failed'
38
- error : Error
39
- end : number
49
+ content : FileStat [ ]
50
+ upper : void | FileStat ,
40
51
}
41
52
42
- export interface FinishedJob < T > extends JobInfo {
43
- status : 'Done'
44
- value : T
45
- end : number
46
- }
53
+ export type PageContent =
54
+ | UnknownContent
55
+ | FileContent
56
+ | DirectoryContent
47
57
58
+ export type SortBy = 'name' | 'size'
48
59
49
60
export type Sorting = {
50
61
by : SortBy ,
51
62
asc : boolean
52
63
}
53
64
54
- export type SortBy = 'name' | 'size'
65
+ export type MakeDir = Perform < 'FILES_MAKEDIR' , Error , void , void >
66
+ export type WriteProgress = { paths : string [ ] , progress : number }
67
+ export type Write = Spawn < 'FILES_WRITE' , WriteProgress , Error , void , void >
68
+ export type AddByPath = Perform < 'FILES_ADDBYPATH' , Error , void , void >
69
+ export type BulkCidImport = Perform < 'FILES_BULK_CID_IMPORT' , Error , void , void >
70
+ export type Move = Perform < 'FILES_MOVE' , Error , void , void >
71
+ export type Delete = Perform < 'FILES_DELETE' , Error , void , void >
72
+ export type FileDownload = {
73
+ url : string
74
+ filename : string
75
+ }
76
+ export type DownloadLink = Perform < 'FILES_DOWNLOADLINK' , Error , FileDownload , void >
55
77
56
78
export type Message =
57
79
| { type : 'FILES_CLEAR_ALL' }
@@ -73,71 +95,38 @@ export type Message =
73
95
| Perform < 'FILES_SIZE_GET' , Error , { size : number } , void >
74
96
| Perform < 'FILES_PINS_SIZE_GET' , Error , { pinsSize : number , numberOfPins : number } , void >
75
97
76
- export type MakeDir = Perform < 'FILES_MAKEDIR' , Error , void , void >
77
- export type WriteProgress = { paths : string [ ] , progress : number }
78
- export type Write = Spawn < 'FILES_WRITE' , WriteProgress , Error , void , void >
79
- export type AddByPath = Perform < 'FILES_ADDBYPATH' , Error , void , void >
80
- export type BulkCidImport = Perform < 'FILES_BULK_CID_IMPORT' , Error , void , void >
81
- export type Move = Perform < 'FILES_MOVE' , Error , void , void >
82
- export type Delete = Perform < 'FILES_DELETE' , Error , void , void >
83
- export type DownloadLink = Perform < 'FILES_DOWNLOADLINK' , Error , FileDownload , void >
84
-
85
- export type FileDownload = {
86
- url : string
87
- filename : string
88
- }
89
-
90
- type FileType = 'directory' | 'file' | 'unknown'
91
-
92
- type Time = number
93
-
94
- type FileStat = {
95
- size : number ,
96
- type : FileType ,
97
- cid : CID ,
98
- name : string ,
99
- path : string ,
100
- pinned : boolean
101
- isParent : boolean | void
98
+ export interface JobInfo {
99
+ type : Message [ 'type' ]
100
+ id : Symbol
101
+ start : number
102
102
}
103
103
104
- export type PageContent =
105
- | UnknownContent
106
- | FileContent
107
- | DirectoryContent
108
-
109
- type UnknownContent = {
110
- type : 'unknown' ,
111
- fetched : Time ,
112
- path : string ,
113
- cid : CID ,
114
- size : 0
104
+ export interface PendingJob < M , I > extends JobInfo {
105
+ status : 'Pending'
106
+ init : I
107
+ message ?: M
115
108
}
116
109
117
- type FileContent = {
118
- type : 'file' ,
119
- fetched : Time ,
120
- path : string ,
121
- cid : CID ,
122
- size : number ,
123
-
124
- name : string ,
125
- pinned : boolean
110
+ export interface FailedJob extends JobInfo {
111
+ status : 'Failed'
112
+ error : Error
113
+ end : number
126
114
}
127
115
128
- export type DirectoryContent = {
129
- type : 'directory' ,
130
- fetched : Time ,
131
- path : string ,
132
- cid : CID ,
133
-
134
- content : FileStat [ ]
135
- upper : void | FileStat ,
116
+ export interface FinishedJob < T > extends JobInfo {
117
+ status : 'Done'
118
+ value : T
119
+ end : number
136
120
}
121
+ export type Model = {
122
+ pageContent : null | PageContent
123
+ pins : string [ ]
124
+ sorting : Sorting
125
+ mfsSize : number
137
126
138
- export type Job < K , P , X , T > = {
139
- type : K ,
140
- job : JobState < P , X , T >
127
+ pending : PendingJob < any , any > [ ]
128
+ finished : FinishedJob < any > [ ]
129
+ failed : FailedJob [ ]
141
130
}
142
131
143
132
export type JobState < P , X , T > =
@@ -146,4 +135,7 @@ export type JobState<P, X, T> =
146
135
| { status : 'Failed' , id : Symbol , error : X }
147
136
| { status : 'Done' , id : Symbol , value : T }
148
137
149
-
138
+ export type Job < K , P , X , T > = {
139
+ type : K ,
140
+ job : JobState < P , X , T >
141
+ }
0 commit comments