-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.ts
More file actions
160 lines (141 loc) Β· 3.56 KB
/
schema.ts
File metadata and controls
160 lines (141 loc) Β· 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Models
import type { Dispatch, SetStateAction } from 'react'
import type { Counter } from './server/makeCounter'
export type Migration = {
id: number
applied: string // as ISO 8601 string
name: string // Unique
}
export type File = {
id: number
nanoid: string
path: string // Unique
taken_at: string | null // as ISO 8601 string
added_at: string // as ISO 8601 string
updated_at: string // as ISO 8601 string
bytes: number
sha512: string
extension: string
type: 'photo' | 'video' | 'other'
width: number | null
height: number | null
seconds: number | null
metadata?: Record<string, unknown>
version?: number // Added dynamically via editing methods
tags?: Tag[] // Added dynamically for a selected file on the client
}
export type Tag = {
id: number
nanoid: string
name: string // Unique
shortcut?: string // Unique
created_at: string // as ISO 8601 string
updated_at: string // as ISO 8601 string
}
export type FileTag = {
id: number
nanoid: string
created_at: string // As a date
updated_at: string // as ISO 8601 string
file_id: number // As foreign key to File
tag_id: number // As foreign key to Tag
}
// Actions
export type Data = {
files: Map<number, File>
fileMapKeys: number[]
fileKeyToIndex: Map<number, number>
tags: Map<number, Tag>
b2Endpoint: string
folders: {
thumbnails: string
exports: string
tags: string
}
selected: SelectedManifest
lastSelected: [number, number] | null
}
export type SetData = Dispatch<SetStateAction<Data>>
export type MakeTag = Tag[]
export type UpdateTagPayload = {
newName: string
newShortcut: string
oldName: string
}
export type UpdateTag = Tag[]
// Reports
export type MakeThumbnailsReport = {
remaining: number
total: number
type: 'thumbnails'
}
export type MakeExportsReport = {
remaining: number
total: number
type: 'exports'
}
export type MakeFilesReport = {
toAddSize: number
addedSize: number
toRemoveSize: number
type: 'files'
}
export type DeleteFilesReport = {
toAddSize: number
addedSize: number
toRemoveSize: number
type: 'delete-files'
}
export type SyncReport = {
sync: string
type: 'sync'
}
export type Report = (
| MakeFilesReport
| DeleteFilesReport
| MakeThumbnailsReport
| MakeExportsReport
| SyncReport
) & { counter: Counter }
export type SelectedManifest = Map<number, { path: string; sha512: string }>
export type Electron = {
// Actions
getData: (
directory: string,
direction: string,
field: string,
showDuplicates: boolean,
tag: string,
search: string,
type: string
) => Promise<Data>
getSelectedTags: (fileId: number) => Promise<(FileTag & Tag)[]>
makeTag: (name: string) => Promise<Tag[]>
updateTag: (payload: UpdateTagPayload) => Promise<Tag[]>
deleteTag: (tag: Tag, directory: string) => Promise<Tag[]>
deleteFileTag: (file_tag_id: number) => Promise<boolean>
openFile: (path: string) => Promise<void>
openFileInFinder: (path: string) => Promise<void>
getFile: (path: string) => Promise<File>
deleteFiles: (directory: string, manifest: SelectedManifest) => Promise<void>
rotatePhoto: (
directory: string,
path: string,
sha512: string
) => Promise<{
sha512: string
updated_at: string
width: number
height: number
metadata: Record<string, unknown>
}>
tagItems: (
directory: string,
file_ids: number[],
tag_id: number
) => Promise<FileTag>
sync: (directory: string) => Promise<void>
publish: (directory: string) => Promise<void>
// Reporter
onReport: (callback: (payload: Report) => void) => void
}