-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipc.d.ts
85 lines (77 loc) · 2.3 KB
/
ipc.d.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
// Shared types for IPC interaction!
import type { WebContents } from 'electron';
import type { components } from './schema';
type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };
type Version = components['schemas']['Version'];
type Asset = components['schemas']['Asset'];
type VersionCreate = components['schemas']['Version'];
type DownloadedEntry = {
asset_id: string;
// null semver means no associated version
semver: string | null;
folderName: string;
folderHash: string;
};
type GriddleIpcSchema = {
'assets:list-downloaded': {
request: null;
response: { versions: DownloadedEntry[] };
};
'assets:download-asset': {
request: { asset_id: string };
response: { ok: boolean };
};
'assets:create-initial-version': {
request: { asset_id: string; asset_name: string };
response: { ok: boolean };
};
'assets:download-version': {
request: { asset_id: string; semver: string };
response: { ok: boolean };
};
'assets:remove-download': {
request: { asset_id: string; assetName: string };
response: { ok: boolean };
};
'assets:commit-changes': {
request: { asset_id: string; message: string; is_major: boolean };
response: { ok: boolean };
};
'assets:files-changed': {
request: { asset_id: string };
response: { ok: boolean; ifChanged: boolean };
};
'assets:open-folder': {
request: { asset_id: string };
response: { ok: boolean };
};
'auth:get-auth-token': {
request: null;
response: { authToken: string | null };
};
'auth:login': {
request: { pennkey: string; password: string };
response: { ok: true } | { ok: false; error: string };
};
'auth:logout': {
request: null;
response: { ok: boolean };
};
'assets:open-houdini': {
request: { asset_id: string };
response: { ok: boolean };
};
'assets:quiet-render-houdini': {
request: { asset_id: string };
response: { ok: boolean };
};
};
export type GriddleIpcKey = keyof GriddleIpcSchema;
type GriddleIpcRequest<K extends GriddleIpcKey> = GriddleIpcSchema[K]['request'];
type GriddleIpcResponse<K extends GriddleIpcKey> = GriddleIpcSchema[K]['response'];
type MessageHandlers = {
[key in GriddleIpcKey]: (
sender: WebContents,
request: GriddleIpcRequest<key>,
) => Promise<GriddleIpcResponse<key>>;
};