-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathtypes.ts
More file actions
164 lines (139 loc) Β· 3 KB
/
types.ts
File metadata and controls
164 lines (139 loc) Β· 3 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
161
162
163
164
export type ProxyRequest = {
method: "GET" | "POST" | "DELETE";
path_query: string;
stream: boolean;
body?: string;
headers: object;
};
export type ProxyCommand = {
command: string;
options: string[];
env: Map<string, string>;
timeout: ms;
abortSignal?: AbortSignal;
};
export type ProxyResponse = ProxyJSONResponse | ProxyStreamResponse;
export type ProxyJSONResponse = {
error: boolean;
data?: JSONValue;
status: number;
headers: Map<string, string>;
};
export type ProxyStreamResponse = {
sha256sum: string;
};
type JSONPrimitive = string | number | boolean | null;
type JSONArray = JSONValue[];
export type JSONObject = {
[key: string]: JSONValue;
};
export type JSONValue = JSONPrimitive | JSONArray | JSONObject;
export type ms = number & { readonly __unit: "ms" };
/** Sync types */
// IPC request for syncMetadata operation
export type SyncMetadataRequest = {
authToken: string;
};
export type Index = {
sources: {
[uuid: string]: string;
};
items: {
[uuid: string]: string;
};
journalists: {
[uuid: string]: string;
};
};
export type MetadataRequest = {
sources: string[];
items: string[];
journalists: string[];
};
export type MetadataResponse = {
sources: {
[uuid: string]: SourceMetadata;
};
items: {
[uuid: string]: ItemMetadata;
};
journalists: {
[uuid: string]: JournalistMetadata;
};
};
export type SourceMetadata = {
uuid: string;
journalist_designation: string;
is_starred: boolean;
last_updated: string;
public_key: string;
fingerprint: string;
};
export type ItemMetadata = ReplyMetadata | SubmissionMetadata;
export type ReplyMetadata = {
kind: "reply";
uuid: string;
source: string;
size: number;
journalist_uuid: string;
is_deleted_by_source: boolean;
seen_by: string[];
};
export type SubmissionMetadata = {
kind: "file" | "message";
uuid: string;
source: string;
size: number;
is_read: boolean;
seen_by: string[];
};
export type JournalistMetadata = {
uuid: string;
username: string;
first_name: string;
last_name: string;
};
/** API v1 Types */
export type TokenResponse = {
expiration: string;
token: string;
journalist_uuid: string;
journalist_first_name: string;
journalist_last_name: string;
};
/** UI Types */
export type Source = {
uuid: string;
data: SourceMetadata;
isRead: boolean;
hasAttachment: boolean;
showMessagePreview: boolean;
messagePreview: string;
};
export type SourceWithItems = {
uuid: string;
data: SourceMetadata;
items: Item[];
};
// Database representation
export type SourceRow = {
uuid: string;
data: string; // JSON stringified SourceMetadata
is_seen: boolean;
has_attachment: boolean;
show_message_preview: boolean;
message_preview: string;
};
export type Item = {
uuid: string;
data: ItemMetadata;
plaintext?: string;
filename?: string;
};
// Database representation
export type ItemRow = {
uuid: string;
data: string; // JSON stringified ItemMetadata
plaintext?: string;
filename?: string;
};