@simplex-chat/types 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/events.d.ts +47 -48
- package/dist/responses.d.ts +50 -51
- package/package.json +4 -3
- package/src/commands.ts +693 -0
- package/src/events.ts +432 -0
- package/src/index.ts +4 -0
- package/src/responses.ts +416 -0
- package/src/types.ts +4587 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplex-chat/types",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "TypeScript types for SimpleX Chat bot libraries",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"src"
|
|
9
10
|
],
|
|
10
11
|
"publishConfig": {
|
|
11
12
|
"access": "public",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"bugs": {
|
|
36
37
|
"url": "https://github.com/simplex-chat/simplex-chat/issues"
|
|
37
38
|
},
|
|
38
|
-
"homepage": "https://github.com/simplex-chat/simplex-chat#readme",
|
|
39
|
+
"homepage": "https://github.com/simplex-chat/simplex-chat/tree/stable/packages/simplex-chat-client/types/typescript#readme",
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"typescript": "^5.9.2"
|
|
41
42
|
}
|
package/src/commands.ts
ADDED
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
// API Commands
|
|
2
|
+
// This file is generated automatically.
|
|
3
|
+
|
|
4
|
+
import * as T from "./types"
|
|
5
|
+
|
|
6
|
+
import {CR} from "./responses"
|
|
7
|
+
|
|
8
|
+
// Address commands
|
|
9
|
+
// Bots can use these commands to automatically check and create address when initialized
|
|
10
|
+
|
|
11
|
+
// Create bot address.
|
|
12
|
+
// Network usage: interactive.
|
|
13
|
+
export interface APICreateMyAddress {
|
|
14
|
+
userId: number // int64
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export namespace APICreateMyAddress {
|
|
18
|
+
export type Response = CR.UserContactLinkCreated | CR.ChatCmdError
|
|
19
|
+
|
|
20
|
+
export function cmdString(self: APICreateMyAddress): string {
|
|
21
|
+
return '/_address ' + self.userId
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Delete bot address.
|
|
26
|
+
// Network usage: background.
|
|
27
|
+
export interface APIDeleteMyAddress {
|
|
28
|
+
userId: number // int64
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export namespace APIDeleteMyAddress {
|
|
32
|
+
export type Response = CR.UserContactLinkDeleted | CR.ChatCmdError
|
|
33
|
+
|
|
34
|
+
export function cmdString(self: APIDeleteMyAddress): string {
|
|
35
|
+
return '/_delete_address ' + self.userId
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Get bot address and settings.
|
|
40
|
+
// Network usage: no.
|
|
41
|
+
export interface APIShowMyAddress {
|
|
42
|
+
userId: number // int64
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export namespace APIShowMyAddress {
|
|
46
|
+
export type Response = CR.UserContactLink | CR.ChatCmdError
|
|
47
|
+
|
|
48
|
+
export function cmdString(self: APIShowMyAddress): string {
|
|
49
|
+
return '/_show_address ' + self.userId
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Add address to bot profile.
|
|
54
|
+
// Network usage: interactive.
|
|
55
|
+
export interface APISetProfileAddress {
|
|
56
|
+
userId: number // int64
|
|
57
|
+
enable: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export namespace APISetProfileAddress {
|
|
61
|
+
export type Response = CR.UserProfileUpdated | CR.ChatCmdError
|
|
62
|
+
|
|
63
|
+
export function cmdString(self: APISetProfileAddress): string {
|
|
64
|
+
return '/_profile_address ' + self.userId + ' ' + (self.enable ? 'on' : 'off')
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Set bot address settings.
|
|
69
|
+
// Network usage: interactive.
|
|
70
|
+
export interface APISetAddressSettings {
|
|
71
|
+
userId: number // int64
|
|
72
|
+
settings: T.AddressSettings
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export namespace APISetAddressSettings {
|
|
76
|
+
export type Response = CR.UserContactLinkUpdated | CR.ChatCmdError
|
|
77
|
+
|
|
78
|
+
export function cmdString(self: APISetAddressSettings): string {
|
|
79
|
+
return '/_address_settings ' + self.userId + ' ' + JSON.stringify(self.settings)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Message commands
|
|
84
|
+
// Commands to send, update, delete, moderate messages and set message reactions
|
|
85
|
+
|
|
86
|
+
// Send messages.
|
|
87
|
+
// Network usage: background.
|
|
88
|
+
export interface APISendMessages {
|
|
89
|
+
sendRef: T.ChatRef
|
|
90
|
+
liveMessage: boolean
|
|
91
|
+
ttl?: number // int
|
|
92
|
+
composedMessages: T.ComposedMessage[] // non-empty
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export namespace APISendMessages {
|
|
96
|
+
export type Response = CR.NewChatItems | CR.ChatCmdError
|
|
97
|
+
|
|
98
|
+
export function cmdString(self: APISendMessages): string {
|
|
99
|
+
return '/_send ' + T.ChatRef.cmdString(self.sendRef) + (self.liveMessage ? ' live=on' : '') + (self.ttl ? ' ttl=' + self.ttl : '') + ' json ' + JSON.stringify(self.composedMessages)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Update message.
|
|
104
|
+
// Network usage: background.
|
|
105
|
+
export interface APIUpdateChatItem {
|
|
106
|
+
chatRef: T.ChatRef
|
|
107
|
+
chatItemId: number // int64
|
|
108
|
+
liveMessage: boolean
|
|
109
|
+
updatedMessage: T.UpdatedMessage
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export namespace APIUpdateChatItem {
|
|
113
|
+
export type Response = CR.ChatItemUpdated | CR.ChatItemNotChanged | CR.ChatCmdError
|
|
114
|
+
|
|
115
|
+
export function cmdString(self: APIUpdateChatItem): string {
|
|
116
|
+
return '/_update item ' + T.ChatRef.cmdString(self.chatRef) + ' ' + self.chatItemId + (self.liveMessage ? ' live=on' : '') + ' json ' + JSON.stringify(self.updatedMessage)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Delete message.
|
|
121
|
+
// Network usage: background.
|
|
122
|
+
export interface APIDeleteChatItem {
|
|
123
|
+
chatRef: T.ChatRef
|
|
124
|
+
chatItemIds: number[] // int64, non-empty
|
|
125
|
+
deleteMode: T.CIDeleteMode
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export namespace APIDeleteChatItem {
|
|
129
|
+
export type Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
|
130
|
+
|
|
131
|
+
export function cmdString(self: APIDeleteChatItem): string {
|
|
132
|
+
return '/_delete item ' + T.ChatRef.cmdString(self.chatRef) + ' ' + self.chatItemIds.join(',') + ' ' + self.deleteMode
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Moderate message. Requires Moderator role (and higher than message author's).
|
|
137
|
+
// Network usage: background.
|
|
138
|
+
export interface APIDeleteMemberChatItem {
|
|
139
|
+
groupId: number // int64
|
|
140
|
+
chatItemIds: number[] // int64, non-empty
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export namespace APIDeleteMemberChatItem {
|
|
144
|
+
export type Response = CR.ChatItemsDeleted | CR.ChatCmdError
|
|
145
|
+
|
|
146
|
+
export function cmdString(self: APIDeleteMemberChatItem): string {
|
|
147
|
+
return '/_delete member item #' + self.groupId + ' ' + self.chatItemIds.join(',')
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Add/remove message reaction.
|
|
152
|
+
// Network usage: background.
|
|
153
|
+
export interface APIChatItemReaction {
|
|
154
|
+
chatRef: T.ChatRef
|
|
155
|
+
chatItemId: number // int64
|
|
156
|
+
add: boolean
|
|
157
|
+
reaction: T.MsgReaction
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export namespace APIChatItemReaction {
|
|
161
|
+
export type Response = CR.ChatItemReaction | CR.ChatCmdError
|
|
162
|
+
|
|
163
|
+
export function cmdString(self: APIChatItemReaction): string {
|
|
164
|
+
return '/_reaction ' + T.ChatRef.cmdString(self.chatRef) + ' ' + self.chatItemId + ' ' + (self.add ? 'on' : 'off') + ' ' + JSON.stringify(self.reaction)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// File commands
|
|
169
|
+
// Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.
|
|
170
|
+
|
|
171
|
+
// Receive file.
|
|
172
|
+
// Network usage: no.
|
|
173
|
+
export interface ReceiveFile {
|
|
174
|
+
fileId: number // int64
|
|
175
|
+
userApprovedRelays: boolean
|
|
176
|
+
storeEncrypted?: boolean
|
|
177
|
+
fileInline?: boolean
|
|
178
|
+
filePath?: string
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export namespace ReceiveFile {
|
|
182
|
+
export type Response = CR.RcvFileAccepted | CR.RcvFileAcceptedSndCancelled | CR.ChatCmdError
|
|
183
|
+
|
|
184
|
+
export function cmdString(self: ReceiveFile): string {
|
|
185
|
+
return '/freceive ' + self.fileId + (self.userApprovedRelays ? ' approved_relays=on' : '') + (typeof self.storeEncrypted == 'boolean' ? ' encrypt=' + (self.storeEncrypted ? 'on' : 'off') : '') + (typeof self.fileInline == 'boolean' ? ' inline=' + (self.fileInline ? 'on' : 'off') : '') + (self.filePath ? ' ' + self.filePath : '')
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Cancel file.
|
|
190
|
+
// Network usage: background.
|
|
191
|
+
export interface CancelFile {
|
|
192
|
+
fileId: number // int64
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export namespace CancelFile {
|
|
196
|
+
export type Response = CR.SndFileCancelled | CR.RcvFileCancelled | CR.ChatCmdError
|
|
197
|
+
|
|
198
|
+
export function cmdString(self: CancelFile): string {
|
|
199
|
+
return '/fcancel ' + self.fileId
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Group commands
|
|
204
|
+
// Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.
|
|
205
|
+
|
|
206
|
+
// Add contact to group. Requires bot to have Admin role.
|
|
207
|
+
// Network usage: interactive.
|
|
208
|
+
export interface APIAddMember {
|
|
209
|
+
groupId: number // int64
|
|
210
|
+
contactId: number // int64
|
|
211
|
+
memberRole: T.GroupMemberRole
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export namespace APIAddMember {
|
|
215
|
+
export type Response = CR.SentGroupInvitation | CR.ChatCmdError
|
|
216
|
+
|
|
217
|
+
export function cmdString(self: APIAddMember): string {
|
|
218
|
+
return '/_add #' + self.groupId + ' ' + self.contactId + ' ' + self.memberRole
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Join group.
|
|
223
|
+
// Network usage: interactive.
|
|
224
|
+
export interface APIJoinGroup {
|
|
225
|
+
groupId: number // int64
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export namespace APIJoinGroup {
|
|
229
|
+
export type Response = CR.UserAcceptedGroupSent | CR.ChatCmdError
|
|
230
|
+
|
|
231
|
+
export function cmdString(self: APIJoinGroup): string {
|
|
232
|
+
return '/_join #' + self.groupId
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Accept group member. Requires Admin role.
|
|
237
|
+
// Network usage: background.
|
|
238
|
+
export interface APIAcceptMember {
|
|
239
|
+
groupId: number // int64
|
|
240
|
+
groupMemberId: number // int64
|
|
241
|
+
memberRole: T.GroupMemberRole
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export namespace APIAcceptMember {
|
|
245
|
+
export type Response = CR.MemberAccepted | CR.ChatCmdError
|
|
246
|
+
|
|
247
|
+
export function cmdString(self: APIAcceptMember): string {
|
|
248
|
+
return '/_accept member #' + self.groupId + ' ' + self.groupMemberId + ' ' + self.memberRole
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Set members role. Requires Admin role.
|
|
253
|
+
// Network usage: background.
|
|
254
|
+
export interface APIMembersRole {
|
|
255
|
+
groupId: number // int64
|
|
256
|
+
groupMemberIds: number[] // int64, non-empty
|
|
257
|
+
memberRole: T.GroupMemberRole
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export namespace APIMembersRole {
|
|
261
|
+
export type Response = CR.MembersRoleUser | CR.ChatCmdError
|
|
262
|
+
|
|
263
|
+
export function cmdString(self: APIMembersRole): string {
|
|
264
|
+
return '/_member role #' + self.groupId + ' ' + self.groupMemberIds.join(',') + ' ' + self.memberRole
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Block members. Requires Moderator role.
|
|
269
|
+
// Network usage: background.
|
|
270
|
+
export interface APIBlockMembersForAll {
|
|
271
|
+
groupId: number // int64
|
|
272
|
+
groupMemberIds: number[] // int64, non-empty
|
|
273
|
+
blocked: boolean
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export namespace APIBlockMembersForAll {
|
|
277
|
+
export type Response = CR.MembersBlockedForAllUser | CR.ChatCmdError
|
|
278
|
+
|
|
279
|
+
export function cmdString(self: APIBlockMembersForAll): string {
|
|
280
|
+
return '/_block #' + self.groupId + ' ' + self.groupMemberIds.join(',') + ' blocked=' + (self.blocked ? 'on' : 'off')
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Remove members. Requires Admin role.
|
|
285
|
+
// Network usage: background.
|
|
286
|
+
export interface APIRemoveMembers {
|
|
287
|
+
groupId: number // int64
|
|
288
|
+
groupMemberIds: number[] // int64, non-empty
|
|
289
|
+
withMessages: boolean
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export namespace APIRemoveMembers {
|
|
293
|
+
export type Response = CR.UserDeletedMembers | CR.ChatCmdError
|
|
294
|
+
|
|
295
|
+
export function cmdString(self: APIRemoveMembers): string {
|
|
296
|
+
return '/_remove #' + self.groupId + ' ' + self.groupMemberIds.join(',') + (self.withMessages ? ' messages=on' : '')
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Leave group.
|
|
301
|
+
// Network usage: background.
|
|
302
|
+
export interface APILeaveGroup {
|
|
303
|
+
groupId: number // int64
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export namespace APILeaveGroup {
|
|
307
|
+
export type Response = CR.LeftMemberUser | CR.ChatCmdError
|
|
308
|
+
|
|
309
|
+
export function cmdString(self: APILeaveGroup): string {
|
|
310
|
+
return '/_leave #' + self.groupId
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Get group members.
|
|
315
|
+
// Network usage: no.
|
|
316
|
+
export interface APIListMembers {
|
|
317
|
+
groupId: number // int64
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export namespace APIListMembers {
|
|
321
|
+
export type Response = CR.GroupMembers | CR.ChatCmdError
|
|
322
|
+
|
|
323
|
+
export function cmdString(self: APIListMembers): string {
|
|
324
|
+
return '/_members #' + self.groupId
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Create group.
|
|
329
|
+
// Network usage: no.
|
|
330
|
+
export interface APINewGroup {
|
|
331
|
+
userId: number // int64
|
|
332
|
+
incognito: boolean
|
|
333
|
+
groupProfile: T.GroupProfile
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export namespace APINewGroup {
|
|
337
|
+
export type Response = CR.GroupCreated | CR.ChatCmdError
|
|
338
|
+
|
|
339
|
+
export function cmdString(self: APINewGroup): string {
|
|
340
|
+
return '/_group ' + self.userId + (self.incognito ? ' incognito=on' : '') + ' ' + JSON.stringify(self.groupProfile)
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Update group profile.
|
|
345
|
+
// Network usage: background.
|
|
346
|
+
export interface APIUpdateGroupProfile {
|
|
347
|
+
groupId: number // int64
|
|
348
|
+
groupProfile: T.GroupProfile
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export namespace APIUpdateGroupProfile {
|
|
352
|
+
export type Response = CR.GroupUpdated | CR.ChatCmdError
|
|
353
|
+
|
|
354
|
+
export function cmdString(self: APIUpdateGroupProfile): string {
|
|
355
|
+
return '/_group_profile #' + self.groupId + ' ' + JSON.stringify(self.groupProfile)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Group link commands
|
|
360
|
+
// These commands can be used by bots that manage multiple public groups
|
|
361
|
+
|
|
362
|
+
// Create group link.
|
|
363
|
+
// Network usage: interactive.
|
|
364
|
+
export interface APICreateGroupLink {
|
|
365
|
+
groupId: number // int64
|
|
366
|
+
memberRole: T.GroupMemberRole
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export namespace APICreateGroupLink {
|
|
370
|
+
export type Response = CR.GroupLinkCreated | CR.ChatCmdError
|
|
371
|
+
|
|
372
|
+
export function cmdString(self: APICreateGroupLink): string {
|
|
373
|
+
return '/_create link #' + self.groupId + ' ' + self.memberRole
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Set member role for group link.
|
|
378
|
+
// Network usage: no.
|
|
379
|
+
export interface APIGroupLinkMemberRole {
|
|
380
|
+
groupId: number // int64
|
|
381
|
+
memberRole: T.GroupMemberRole
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export namespace APIGroupLinkMemberRole {
|
|
385
|
+
export type Response = CR.GroupLink | CR.ChatCmdError
|
|
386
|
+
|
|
387
|
+
export function cmdString(self: APIGroupLinkMemberRole): string {
|
|
388
|
+
return '/_set link role #' + self.groupId + ' ' + self.memberRole
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Delete group link.
|
|
393
|
+
// Network usage: background.
|
|
394
|
+
export interface APIDeleteGroupLink {
|
|
395
|
+
groupId: number // int64
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export namespace APIDeleteGroupLink {
|
|
399
|
+
export type Response = CR.GroupLinkDeleted | CR.ChatCmdError
|
|
400
|
+
|
|
401
|
+
export function cmdString(self: APIDeleteGroupLink): string {
|
|
402
|
+
return '/_delete link #' + self.groupId
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Get group link.
|
|
407
|
+
// Network usage: no.
|
|
408
|
+
export interface APIGetGroupLink {
|
|
409
|
+
groupId: number // int64
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export namespace APIGetGroupLink {
|
|
413
|
+
export type Response = CR.GroupLink | CR.ChatCmdError
|
|
414
|
+
|
|
415
|
+
export function cmdString(self: APIGetGroupLink): string {
|
|
416
|
+
return '/_get link #' + self.groupId
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Connection commands
|
|
421
|
+
// These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.
|
|
422
|
+
|
|
423
|
+
// Create 1-time invitation link.
|
|
424
|
+
// Network usage: interactive.
|
|
425
|
+
export interface APIAddContact {
|
|
426
|
+
userId: number // int64
|
|
427
|
+
incognito: boolean
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export namespace APIAddContact {
|
|
431
|
+
export type Response = CR.Invitation | CR.ChatCmdError
|
|
432
|
+
|
|
433
|
+
export function cmdString(self: APIAddContact): string {
|
|
434
|
+
return '/_connect ' + self.userId + (self.incognito ? ' incognito=on' : '')
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Determine SimpleX link type and if the bot is already connected via this link.
|
|
439
|
+
// Network usage: interactive.
|
|
440
|
+
export interface APIConnectPlan {
|
|
441
|
+
userId: number // int64
|
|
442
|
+
connectionLink?: string
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export namespace APIConnectPlan {
|
|
446
|
+
export type Response = CR.ConnectionPlan | CR.ChatCmdError
|
|
447
|
+
|
|
448
|
+
export function cmdString(self: APIConnectPlan): string {
|
|
449
|
+
return '/_connect plan ' + self.userId + ' ' + self.connectionLink
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link.
|
|
454
|
+
// Network usage: interactive.
|
|
455
|
+
export interface APIConnect {
|
|
456
|
+
userId: number // int64
|
|
457
|
+
incognito: boolean
|
|
458
|
+
preparedLink_?: T.CreatedConnLink
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export namespace APIConnect {
|
|
462
|
+
export type Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError
|
|
463
|
+
|
|
464
|
+
export function cmdString(self: APIConnect): string {
|
|
465
|
+
return '/_connect ' + self.userId + (self.preparedLink_ ? ' ' + T.CreatedConnLink.cmdString(self.preparedLink_) : '')
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Connect via SimpleX link as string in the active user profile.
|
|
470
|
+
// Network usage: interactive.
|
|
471
|
+
export interface Connect {
|
|
472
|
+
incognito: boolean
|
|
473
|
+
connLink_?: string
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export namespace Connect {
|
|
477
|
+
export type Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError
|
|
478
|
+
|
|
479
|
+
export function cmdString(self: Connect): string {
|
|
480
|
+
return '/connect' + (self.connLink_ ? ' ' + self.connLink_ : '')
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Accept contact request.
|
|
485
|
+
// Network usage: interactive.
|
|
486
|
+
export interface APIAcceptContact {
|
|
487
|
+
contactReqId: number // int64
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export namespace APIAcceptContact {
|
|
491
|
+
export type Response = CR.AcceptingContactRequest | CR.ChatCmdError
|
|
492
|
+
|
|
493
|
+
export function cmdString(self: APIAcceptContact): string {
|
|
494
|
+
return '/_accept ' + self.contactReqId
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// Reject contact request. The user who sent the request is **not notified**.
|
|
499
|
+
// Network usage: no.
|
|
500
|
+
export interface APIRejectContact {
|
|
501
|
+
contactReqId: number // int64
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export namespace APIRejectContact {
|
|
505
|
+
export type Response = CR.ContactRequestRejected | CR.ChatCmdError
|
|
506
|
+
|
|
507
|
+
export function cmdString(self: APIRejectContact): string {
|
|
508
|
+
return '/_reject ' + self.contactReqId
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// Chat commands
|
|
513
|
+
// Commands to list and delete conversations.
|
|
514
|
+
|
|
515
|
+
// Get contacts.
|
|
516
|
+
// Network usage: no.
|
|
517
|
+
export interface APIListContacts {
|
|
518
|
+
userId: number // int64
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export namespace APIListContacts {
|
|
522
|
+
export type Response = CR.ContactsList | CR.ChatCmdError
|
|
523
|
+
|
|
524
|
+
export function cmdString(self: APIListContacts): string {
|
|
525
|
+
return '/_contacts ' + self.userId
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// Get groups.
|
|
530
|
+
// Network usage: no.
|
|
531
|
+
export interface APIListGroups {
|
|
532
|
+
userId: number // int64
|
|
533
|
+
contactId_?: number // int64
|
|
534
|
+
search?: string
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export namespace APIListGroups {
|
|
538
|
+
export type Response = CR.GroupsList | CR.ChatCmdError
|
|
539
|
+
|
|
540
|
+
export function cmdString(self: APIListGroups): string {
|
|
541
|
+
return '/_groups ' + self.userId + (self.contactId_ ? ' @' + self.contactId_ : '') + (self.search ? ' ' + self.search : '')
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// Delete chat.
|
|
546
|
+
// Network usage: background.
|
|
547
|
+
export interface APIDeleteChat {
|
|
548
|
+
chatRef: T.ChatRef
|
|
549
|
+
chatDeleteMode: T.ChatDeleteMode
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export namespace APIDeleteChat {
|
|
553
|
+
export type Response = CR.ContactDeleted | CR.ContactConnectionDeleted | CR.GroupDeletedUser | CR.ChatCmdError
|
|
554
|
+
|
|
555
|
+
export function cmdString(self: APIDeleteChat): string {
|
|
556
|
+
return '/_delete ' + T.ChatRef.cmdString(self.chatRef) + ' ' + T.ChatDeleteMode.cmdString(self.chatDeleteMode)
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// User profile commands
|
|
561
|
+
// Most bots don't need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).
|
|
562
|
+
|
|
563
|
+
// Get active user profile.
|
|
564
|
+
// Network usage: no.
|
|
565
|
+
export interface ShowActiveUser {
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export namespace ShowActiveUser {
|
|
569
|
+
export type Response = CR.ActiveUser | CR.ChatCmdError
|
|
570
|
+
|
|
571
|
+
export function cmdString(_self: ShowActiveUser): string {
|
|
572
|
+
return '/user'
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Create new user profile.
|
|
577
|
+
// Network usage: no.
|
|
578
|
+
export interface CreateActiveUser {
|
|
579
|
+
newUser: T.NewUser
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
export namespace CreateActiveUser {
|
|
583
|
+
export type Response = CR.ActiveUser | CR.ChatCmdError
|
|
584
|
+
|
|
585
|
+
export function cmdString(self: CreateActiveUser): string {
|
|
586
|
+
return '/_create user ' + JSON.stringify(self.newUser)
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Get all user profiles.
|
|
591
|
+
// Network usage: no.
|
|
592
|
+
export interface ListUsers {
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export namespace ListUsers {
|
|
596
|
+
export type Response = CR.UsersList | CR.ChatCmdError
|
|
597
|
+
|
|
598
|
+
export function cmdString(_self: ListUsers): string {
|
|
599
|
+
return '/users'
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// Set active user profile.
|
|
604
|
+
// Network usage: no.
|
|
605
|
+
export interface APISetActiveUser {
|
|
606
|
+
userId: number // int64
|
|
607
|
+
viewPwd?: string
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export namespace APISetActiveUser {
|
|
611
|
+
export type Response = CR.ActiveUser | CR.ChatCmdError
|
|
612
|
+
|
|
613
|
+
export function cmdString(self: APISetActiveUser): string {
|
|
614
|
+
return '/_user ' + self.userId + (self.viewPwd ? ' ' + JSON.stringify(self.viewPwd) : '')
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// Delete user profile.
|
|
619
|
+
// Network usage: background.
|
|
620
|
+
export interface APIDeleteUser {
|
|
621
|
+
userId: number // int64
|
|
622
|
+
delSMPQueues: boolean
|
|
623
|
+
viewPwd?: string
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
export namespace APIDeleteUser {
|
|
627
|
+
export type Response = CR.CmdOk | CR.ChatCmdError
|
|
628
|
+
|
|
629
|
+
export function cmdString(self: APIDeleteUser): string {
|
|
630
|
+
return '/_delete user ' + self.userId + ' del_smp=' + (self.delSMPQueues ? 'on' : 'off') + (self.viewPwd ? ' ' + JSON.stringify(self.viewPwd) : '')
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Update user profile.
|
|
635
|
+
// Network usage: background.
|
|
636
|
+
export interface APIUpdateProfile {
|
|
637
|
+
userId: number // int64
|
|
638
|
+
profile: T.Profile
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export namespace APIUpdateProfile {
|
|
642
|
+
export type Response = CR.UserProfileUpdated | CR.UserProfileNoChange | CR.ChatCmdError
|
|
643
|
+
|
|
644
|
+
export function cmdString(self: APIUpdateProfile): string {
|
|
645
|
+
return '/_profile ' + self.userId + ' ' + JSON.stringify(self.profile)
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// Configure chat preference overrides for the contact.
|
|
650
|
+
// Network usage: background.
|
|
651
|
+
export interface APISetContactPrefs {
|
|
652
|
+
contactId: number // int64
|
|
653
|
+
preferences: T.Preferences
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
export namespace APISetContactPrefs {
|
|
657
|
+
export type Response = CR.ContactPrefsUpdated | CR.ChatCmdError
|
|
658
|
+
|
|
659
|
+
export function cmdString(self: APISetContactPrefs): string {
|
|
660
|
+
return '/_set prefs @' + self.contactId + ' ' + JSON.stringify(self.preferences)
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// Chat management
|
|
665
|
+
// These commands should not be used with CLI-based bots
|
|
666
|
+
|
|
667
|
+
// Start chat controller.
|
|
668
|
+
// Network usage: no.
|
|
669
|
+
export interface StartChat {
|
|
670
|
+
mainApp: boolean
|
|
671
|
+
enableSndFiles: boolean
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
export namespace StartChat {
|
|
675
|
+
export type Response = CR.ChatStarted | CR.ChatRunning
|
|
676
|
+
|
|
677
|
+
export function cmdString(_self: StartChat): string {
|
|
678
|
+
return '/_start'
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// Stop chat controller.
|
|
683
|
+
// Network usage: no.
|
|
684
|
+
export interface APIStopChat {
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export namespace APIStopChat {
|
|
688
|
+
export type Response = CR.ChatStopped
|
|
689
|
+
|
|
690
|
+
export function cmdString(_self: APIStopChat): string {
|
|
691
|
+
return '/_stop'
|
|
692
|
+
}
|
|
693
|
+
}
|