-
Notifications
You must be signed in to change notification settings - Fork 175
/
types.ts
183 lines (160 loc) · 4.17 KB
/
types.ts
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import type { IpcMainEvent } from 'electron'
import type { Error } from '../types'
import type { RobotSystemAction } from './is-ready/types'
export interface Remote {
ipcRenderer: {
invoke: (channel: string, ...args: unknown[]) => Promise<any>
send: (channel: string, ...args: unknown[]) => void
on: (channel: string, listener: IpcListener) => void
off: (channel: string, listener: IpcListener) => void
}
}
export type IpcListener = (
event: IpcMainEvent,
hostname: string,
topic: NotifyTopic,
message: NotifyResponseData | NotifyNetworkError,
...args: unknown[]
) => void
export interface NotifyRefetchData {
refetch: boolean
}
export interface NotifyUnsubscribeData {
unsubscribe: boolean
}
export type NotifyBrokerResponses = NotifyRefetchData | NotifyUnsubscribeData
export type NotifyNetworkError = 'ECONNFAILED' | 'ECONNREFUSED'
export type NotifyResponseData = NotifyBrokerResponses | NotifyNetworkError
interface File {
sha512: string
url: string
[key: string]: unknown
}
export interface UpdateInfo {
version: string
files: File[]
releaseDate?: string
releaseNotes?: string
}
export interface ShellUpdateState {
checking: boolean
downloading: boolean
available: boolean
downloaded: boolean
downloadPercentage: number
error: Error | null | undefined
info: UpdateInfo | null | undefined
}
export type ShellUpdateAction =
| { type: 'shell:CHECK_UPDATE'; meta: { shell: true } }
| {
type: 'shell:CHECK_UPDATE_RESULT'
payload: { available?: boolean; info?: UpdateInfo | null; error?: Error }
}
| { type: 'shell:DOWNLOAD_UPDATE'; meta: { shell: true } }
| { type: 'shell:DOWNLOAD_UPDATE_RESULT'; payload: { error?: Error } }
| { type: 'shell:APPLY_UPDATE'; meta: { shell: true } }
| { type: 'shell:DOWNLOAD_PERCENTAGE'; payload: { percent: number } }
export interface ShellState {
update: ShellUpdateState
isReady: boolean
}
export interface UiInitializedAction {
type: 'shell:UI_INITIALIZED'
meta: { shell: true }
}
export type UsbRequestsAction =
| { type: 'shell:USB_HTTP_REQUESTS_START'; meta: { shell: true } }
| { type: 'shell:USB_HTTP_REQUESTS_STOP'; meta: { shell: true } }
export interface AppRestartAction {
type: 'shell:APP_RESTART'
payload: {
message: string
}
meta: { shell: true }
}
export interface ReloadUiAction {
type: 'shell:RELOAD_UI'
payload: {
message: string
}
meta: { shell: true }
}
export interface SendLogAction {
type: 'shell:SEND_LOG'
payload: {
message: string
}
meta: { shell: true }
}
export interface UpdateBrightnessAction {
type: 'shell:UPDATE_BRIGHTNESS'
payload: {
message: string
}
meta: { shell: true }
}
export interface RobotMassStorageDeviceAdded {
type: 'shell:ROBOT_MASS_STORAGE_DEVICE_ADDED'
payload: {
rootPath: string
}
meta: { shell: true }
}
export interface RobotMassStorageDeviceEnumerated {
type: 'shell:ROBOT_MASS_STORAGE_DEVICE_ENUMERATED'
payload: {
rootPath: string
filePaths: string[]
}
meta: { shell: true }
}
export interface RobotMassStorageDeviceRemoved {
type: 'shell:ROBOT_MASS_STORAGE_DEVICE_REMOVED'
payload: {
rootPath: string
}
meta: { shell: true }
}
export type NotifyTopic =
| 'ALL_TOPICS'
| 'robot-server/maintenance_runs/current_run'
| 'robot-server/runs/current_command'
| 'robot-server/runs'
| `robot-server/runs/${string}`
| 'robot-server/deck_configuration'
| `robot-server/runs/pre_serialized_commands/${string}`
export interface NotifySubscribeAction {
type: 'shell:NOTIFY_SUBSCRIBE'
payload: {
hostname: string
topic: NotifyTopic
}
meta: { shell: true }
}
export type ShellAction =
| UiInitializedAction
| ShellUpdateAction
| RobotSystemAction
| UsbRequestsAction
| AppRestartAction
| ReloadUiAction
| SendLogAction
| UpdateBrightnessAction
| RobotMassStorageDeviceAdded
| RobotMassStorageDeviceEnumerated
| RobotMassStorageDeviceRemoved
| NotifySubscribeAction
export type IPCSafeFormDataEntry =
| {
type: 'string'
name: string
value: string
}
| {
type: 'file'
name: string
value: ArrayBuffer
filename: string
}
export type IPCSafeFormData = IPCSafeFormDataEntry[]