simplex-chat 0.3.0 → 6.5.0-beta.10
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 +107 -22
- package/binding.gyp +50 -0
- package/cpp/simplex.cc +426 -0
- package/cpp/simplex.h +46 -0
- package/dist/api.d.ts +423 -0
- package/dist/api.js +857 -0
- package/dist/api.js.map +1 -0
- package/dist/bot.d.ts +29 -0
- package/dist/bot.js +189 -0
- package/dist/bot.js.map +1 -0
- package/dist/core.d.ts +128 -0
- package/dist/core.js +121 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/simplex.d.ts +10 -0
- package/dist/simplex.js +1 -0
- package/dist/util.d.ts +15 -0
- package/dist/util.js +91 -0
- package/dist/util.js.map +1 -0
- package/docs/Namespace.api.md +33 -0
- package/docs/Namespace.bot.md +23 -0
- package/docs/Namespace.core.md +48 -0
- package/docs/Namespace.util.md +25 -0
- package/docs/README.md +12 -0
- package/docs/api.Class.ChatApi.md +1752 -0
- package/docs/api.Class.ChatCommandError.md +205 -0
- package/docs/api.Enumeration.ConnReqType.md +27 -0
- package/docs/api.Interface.BotAddressSettings.md +60 -0
- package/docs/api.TypeAlias.DbConfig.md +64 -0
- package/docs/api.TypeAlias.EventSubscriberFunc.md +27 -0
- package/docs/api.TypeAlias.EventSubscribers.md +11 -0
- package/docs/api.Variable.defaultBotAddressSettings.md +11 -0
- package/docs/bot.Function.run.md +21 -0
- package/docs/bot.Interface.BotConfig.md +75 -0
- package/docs/bot.Interface.BotOptions.md +81 -0
- package/docs/bot.TypeAlias.BotDbOpts.md +17 -0
- package/docs/core.Class.ChatAPIError.md +205 -0
- package/docs/core.Class.ChatInitError.md +205 -0
- package/docs/core.DBMigrationError.Interface.ErrorMigration.md +41 -0
- package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +33 -0
- package/docs/core.DBMigrationError.Interface.ErrorSQL.md +41 -0
- package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +25 -0
- package/docs/core.DBMigrationError.TypeAlias.Tag.md +11 -0
- package/docs/core.Enumeration.MigrationConfirmation.md +43 -0
- package/docs/core.Function.chatCloseStore.md +23 -0
- package/docs/core.Function.chatDecryptFile.md +31 -0
- package/docs/core.Function.chatEncryptFile.md +31 -0
- package/docs/core.Function.chatMigrateInit.md +31 -0
- package/docs/core.Function.chatReadFile.md +27 -0
- package/docs/core.Function.chatRecvMsgWait.md +27 -0
- package/docs/core.Function.chatSendCmd.md +27 -0
- package/docs/core.Function.chatWriteFile.md +31 -0
- package/docs/core.Interface.APIResult.md +31 -0
- package/docs/core.Interface.CryptoArgs.md +27 -0
- package/docs/core.Interface.UpMigration.md +25 -0
- package/docs/core.MTRError.Interface.MTREDifferent.md +33 -0
- package/docs/core.MTRError.Interface.MTRENoDown.md +33 -0
- package/docs/core.MTRError.TypeAlias.Tag.md +11 -0
- package/docs/core.MigrationError.Interface.MEDowngrade.md +33 -0
- package/docs/core.MigrationError.Interface.MEUpgrade.md +33 -0
- package/docs/core.MigrationError.Interface.MigrationError.md +33 -0
- package/docs/core.MigrationError.TypeAlias.Tag.md +11 -0
- package/docs/core.Namespace.DBMigrationError.md +18 -0
- package/docs/core.Namespace.MTRError.md +16 -0
- package/docs/core.Namespace.MigrationError.md +17 -0
- package/docs/core.TypeAlias.DBMigrationError.md +11 -0
- package/docs/core.TypeAlias.MTRError.md +11 -0
- package/docs/core.TypeAlias.MigrationError.md +11 -0
- package/docs/util.Function.botAddressSettings.md +21 -0
- package/docs/util.Function.chatInfoName.md +21 -0
- package/docs/util.Function.chatInfoRef.md +21 -0
- package/docs/util.Function.ciBotCommand.md +21 -0
- package/docs/util.Function.ciContentText.md +21 -0
- package/docs/util.Function.contactAddressStr.md +21 -0
- package/docs/util.Function.fromLocalProfile.md +21 -0
- package/docs/util.Function.reactionText.md +21 -0
- package/docs/util.Function.senderName.md +25 -0
- package/docs/util.Interface.BotCommand.md +25 -0
- package/examples/squaring-bot-pg.js +21 -0
- package/examples/squaring-bot-readme.js +17 -0
- package/examples/squaring-bot.ts +42 -0
- package/package.json +36 -48
- package/src/api.ts +939 -0
- package/src/bot.ts +214 -0
- package/src/core.ts +210 -0
- package/src/download-libs.js +239 -0
- package/src/index.ts +22 -0
- package/src/simplex.d.ts +10 -0
- package/src/simplex.js +1 -0
- package/src/util.ts +92 -0
- package/tsconfig.json +23 -0
- package/dist/client.d.ts +0 -61
- package/dist/client.js +0 -271
- package/dist/client.js.map +0 -1
- package/dist/command.d.ts +0 -408
- package/dist/command.js +0 -184
- package/dist/command.js.map +0 -1
- package/dist/index-web.d.ts +0 -1
- package/dist/index-web.js +0 -6
- package/dist/index-web.js.map +0 -1
- package/dist/index.bundle.js +0 -11
- package/dist/queue.d.ts +0 -24
- package/dist/queue.js +0 -77
- package/dist/queue.js.map +0 -1
- package/dist/response.d.ts +0 -754
- package/dist/response.js +0 -21
- package/dist/response.js.map +0 -1
- package/dist/test.html +0 -7
- package/dist/transport.d.ts +0 -54
- package/dist/transport.js +0 -131
- package/dist/transport.js.map +0 -1
- package/dist/websocket.d.ts +0 -8
- package/dist/websocket.js +0 -4
- package/dist/websocket.js.map +0 -1
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { CEvt, ChatEvent, ChatResponse, T } from "@simplex-chat/types";
|
|
2
|
+
import * as core from "./core";
|
|
3
|
+
export declare class ChatCommandError extends Error {
|
|
4
|
+
message: string;
|
|
5
|
+
response: ChatResponse;
|
|
6
|
+
constructor(message: string, response: ChatResponse);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Connection request types.
|
|
10
|
+
* @enum {string}
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ConnReqType {
|
|
13
|
+
Invitation = "invitation",
|
|
14
|
+
Contact = "contact"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Bot address settings.
|
|
18
|
+
*/
|
|
19
|
+
export interface BotAddressSettings {
|
|
20
|
+
/**
|
|
21
|
+
* Automatically accept contact requests.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
autoAccept?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Optional welcome message to show before connection to the users.
|
|
27
|
+
* @default undefined (no welcome message)
|
|
28
|
+
*/
|
|
29
|
+
welcomeMessage?: T.MsgContent | string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Business contact address.
|
|
32
|
+
* For all requests business chats will be created where other participants can be added.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
businessAddress?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const defaultBotAddressSettings: BotAddressSettings;
|
|
38
|
+
export type EventSubscriberFunc<K extends CEvt.Tag> = (event: ChatEvent & {
|
|
39
|
+
type: K;
|
|
40
|
+
}) => void | Promise<void>;
|
|
41
|
+
export type EventSubscribers = {
|
|
42
|
+
[K in CEvt.Tag]?: EventSubscriberFunc<K>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Database configuration. The native library is built against exactly one
|
|
46
|
+
* backend (see `simplex_backend` / `SIMPLEX_BACKEND` at install time); this
|
|
47
|
+
* type makes the caller state which one they are targeting so field names
|
|
48
|
+
* can't lie about their meaning.
|
|
49
|
+
*/
|
|
50
|
+
export type DbConfig = {
|
|
51
|
+
/** SQLite backend (default). */
|
|
52
|
+
type: "sqlite";
|
|
53
|
+
/** File prefix — two schema files are named `<prefix>_chat.db` and `<prefix>_agent.db`. */
|
|
54
|
+
filePrefix: string;
|
|
55
|
+
/** Optional SQLCipher encryption key. Empty/omitted = unencrypted. */
|
|
56
|
+
encryptionKey?: string;
|
|
57
|
+
} | {
|
|
58
|
+
/** PostgreSQL backend (Linux x86_64 only, libpq5 required). */
|
|
59
|
+
type: "postgres";
|
|
60
|
+
/** Schema prefix used to namespace tables. Defaults to `"simplex_v1"` when omitted. */
|
|
61
|
+
schemaPrefix?: string;
|
|
62
|
+
/** PostgreSQL connection string (e.g. `postgres://user:pass@host/db`). */
|
|
63
|
+
connectionString: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Main API class for interacting with the chat core library.
|
|
67
|
+
*/
|
|
68
|
+
export declare class ChatApi {
|
|
69
|
+
protected ctrl_: bigint | undefined;
|
|
70
|
+
private receiveEvents;
|
|
71
|
+
private eventsLoop;
|
|
72
|
+
private subscribers;
|
|
73
|
+
private receivers;
|
|
74
|
+
private constructor();
|
|
75
|
+
/**
|
|
76
|
+
* Initializes the ChatApi.
|
|
77
|
+
* @param {DbConfig} db - Database configuration (sqlite or postgres).
|
|
78
|
+
* @param {core.MigrationConfirmation} [confirm=core.MigrationConfirmation.YesUp] - Migration confirmation mode.
|
|
79
|
+
*/
|
|
80
|
+
static init(db: DbConfig, confirm?: core.MigrationConfirmation): Promise<ChatApi>;
|
|
81
|
+
/**
|
|
82
|
+
* Start chat controller. Must be called with the existing user profile.
|
|
83
|
+
*/
|
|
84
|
+
startChat(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Stop chat controller.
|
|
87
|
+
* Must be called before closing the database.
|
|
88
|
+
* Usually doesn't need to be called in chat bots.
|
|
89
|
+
*/
|
|
90
|
+
stopChat(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Close chat database.
|
|
93
|
+
* Usually doesn't need to be called in chat bots.
|
|
94
|
+
*/
|
|
95
|
+
close(): Promise<void>;
|
|
96
|
+
private runEventsLoop;
|
|
97
|
+
/**
|
|
98
|
+
* Subscribe multiple event handlers at once.
|
|
99
|
+
* @param subscribers - An object mapping event types (CEvt.Tag) to their subscriber functions.
|
|
100
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
101
|
+
*/
|
|
102
|
+
on<K extends CEvt.Tag>(subscribers: EventSubscribers): void;
|
|
103
|
+
/**
|
|
104
|
+
* Subscribe a handler to a specific event.
|
|
105
|
+
* @param {CEvt.Tag} event - The event type to subscribe to.
|
|
106
|
+
* @param subscriber - The subscriber function for the event.
|
|
107
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
108
|
+
*/
|
|
109
|
+
on<K extends CEvt.Tag>(event: K, subscriber: EventSubscriberFunc<K>): void;
|
|
110
|
+
private on_;
|
|
111
|
+
/**
|
|
112
|
+
* Subscribe a handler to any event.
|
|
113
|
+
* @param receiver - The receiver function for any event.
|
|
114
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
115
|
+
*/
|
|
116
|
+
onAny(receiver: EventSubscriberFunc<CEvt.Tag>): void;
|
|
117
|
+
/**
|
|
118
|
+
* Subscribe a handler to a specific event to be delivered one time.
|
|
119
|
+
* @param {CEvt.Tag} event - The event type to subscribe to.
|
|
120
|
+
* @param subscriber - The subscriber function for the event.
|
|
121
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
122
|
+
*/
|
|
123
|
+
once<K extends CEvt.Tag>(event: K, subscriber: EventSubscriberFunc<K>): void;
|
|
124
|
+
/**
|
|
125
|
+
* Waits for specific event, with an optional predicate.
|
|
126
|
+
* Returns `undefined` on timeout if specified.
|
|
127
|
+
*/
|
|
128
|
+
wait<K extends CEvt.Tag>(event: K): Promise<ChatEvent & {
|
|
129
|
+
type: K;
|
|
130
|
+
}>;
|
|
131
|
+
wait<K extends CEvt.Tag>(event: K, predicate: ((event: ChatEvent & {
|
|
132
|
+
type: K;
|
|
133
|
+
}) => boolean) | undefined): Promise<ChatEvent & {
|
|
134
|
+
type: K;
|
|
135
|
+
}>;
|
|
136
|
+
wait<K extends CEvt.Tag>(event: K, timeout: number): Promise<ChatEvent & {
|
|
137
|
+
type: K;
|
|
138
|
+
} | undefined>;
|
|
139
|
+
wait<K extends CEvt.Tag>(event: K, predicate: ((event: ChatEvent & {
|
|
140
|
+
type: K;
|
|
141
|
+
}) => boolean) | undefined, timeout: number): Promise<ChatEvent & {
|
|
142
|
+
type: K;
|
|
143
|
+
} | undefined>;
|
|
144
|
+
/**
|
|
145
|
+
* Unsubscribe all or a specific handler from a specific event.
|
|
146
|
+
* @param {CEvt.Tag} event - The event type to unsubscribe from.
|
|
147
|
+
* @param subscriber - An optional subscriber function for the event.
|
|
148
|
+
*/
|
|
149
|
+
off<K extends CEvt.Tag>(event: K, subscriber?: EventSubscriberFunc<K> | undefined): void;
|
|
150
|
+
/**
|
|
151
|
+
* Unsubscribe all or a specific handler from any events.
|
|
152
|
+
* @param receiver - An optional subscriber function for the event.
|
|
153
|
+
*/
|
|
154
|
+
offAny(receiver?: EventSubscriberFunc<CEvt.Tag> | undefined): void;
|
|
155
|
+
/**
|
|
156
|
+
* Chat controller is initialized
|
|
157
|
+
*/
|
|
158
|
+
get initialized(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Chat controller is started
|
|
161
|
+
*/
|
|
162
|
+
get started(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Chat controller reference
|
|
165
|
+
*/
|
|
166
|
+
get ctrl(): bigint;
|
|
167
|
+
sendChatCmd(cmd: string): Promise<ChatResponse>;
|
|
168
|
+
recvChatEvent(wait?: number): Promise<ChatEvent | undefined>;
|
|
169
|
+
/**
|
|
170
|
+
* Create bot address.
|
|
171
|
+
* Network usage: interactive.
|
|
172
|
+
*/
|
|
173
|
+
apiCreateUserAddress(userId: number): Promise<T.CreatedConnLink>;
|
|
174
|
+
/**
|
|
175
|
+
* Deletes a user address.
|
|
176
|
+
* Network usage: background.
|
|
177
|
+
*/
|
|
178
|
+
apiDeleteUserAddress(userId: number): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Get bot address and settings.
|
|
181
|
+
* Network usage: no.
|
|
182
|
+
*/
|
|
183
|
+
apiGetUserAddress(userId: number): Promise<T.UserContactLink | undefined>;
|
|
184
|
+
/**
|
|
185
|
+
* Add address to bot profile.
|
|
186
|
+
* Network usage: interactive.
|
|
187
|
+
*/
|
|
188
|
+
apiSetProfileAddress(userId: number, enable: boolean): Promise<T.UserProfileUpdateSummary>;
|
|
189
|
+
/**
|
|
190
|
+
* Set bot address settings.
|
|
191
|
+
* Network usage: interactive.
|
|
192
|
+
*/
|
|
193
|
+
apiSetAddressSettings(userId: number, { autoAccept, welcomeMessage, businessAddress }: BotAddressSettings): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Send messages.
|
|
196
|
+
* Network usage: background.
|
|
197
|
+
*/
|
|
198
|
+
apiSendMessages(chat: [T.ChatType, number] | T.ChatRef | T.ChatInfo, messages: T.ComposedMessage[], liveMessage?: boolean): Promise<T.AChatItem[]>;
|
|
199
|
+
/**
|
|
200
|
+
* Send text message.
|
|
201
|
+
* Network usage: background.
|
|
202
|
+
*/
|
|
203
|
+
apiSendTextMessage(chat: [T.ChatType, number] | T.ChatRef | T.ChatInfo, text: string, inReplyTo?: number): Promise<T.AChatItem[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Send text message in reply to received message.
|
|
206
|
+
* Network usage: background.
|
|
207
|
+
*/
|
|
208
|
+
apiSendTextReply(chatItem: T.AChatItem, text: string): Promise<T.AChatItem[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Update message.
|
|
211
|
+
* Network usage: background.
|
|
212
|
+
*/
|
|
213
|
+
apiUpdateChatItem(chatType: T.ChatType, chatId: number, chatItemId: number, msgContent: T.MsgContent, liveMessage: false): Promise<T.ChatItem>;
|
|
214
|
+
/**
|
|
215
|
+
* Delete message.
|
|
216
|
+
* Network usage: background.
|
|
217
|
+
*/
|
|
218
|
+
apiDeleteChatItems(chatType: T.ChatType, chatId: number, chatItemIds: number[], deleteMode: T.CIDeleteMode): Promise<T.ChatItemDeletion[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Moderate message. Requires Moderator role (and higher than message author's).
|
|
221
|
+
* Network usage: background.
|
|
222
|
+
*/
|
|
223
|
+
apiDeleteMemberChatItem(groupId: number, chatItemIds: number[]): Promise<T.ChatItemDeletion[]>;
|
|
224
|
+
/**
|
|
225
|
+
* Add/remove message reaction.
|
|
226
|
+
* Network usage: background.
|
|
227
|
+
*/
|
|
228
|
+
apiChatItemReaction(chatType: T.ChatType, chatId: number, chatItemId: number, add: boolean, reaction: T.MsgReaction): Promise<T.ChatItemDeletion[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Receive file.
|
|
231
|
+
* Network usage: no.
|
|
232
|
+
*/
|
|
233
|
+
apiReceiveFile(fileId: number): Promise<T.AChatItem>;
|
|
234
|
+
/**
|
|
235
|
+
* Cancel file.
|
|
236
|
+
* Network usage: background.
|
|
237
|
+
*/
|
|
238
|
+
apiCancelFile(fileId: number): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Add contact to group. Requires bot to have Admin role.
|
|
241
|
+
* Network usage: interactive.
|
|
242
|
+
*/
|
|
243
|
+
apiAddMember(groupId: number, contactId: number, memberRole: T.GroupMemberRole): Promise<T.GroupMember>;
|
|
244
|
+
/**
|
|
245
|
+
* Join group.
|
|
246
|
+
* Network usage: interactive.
|
|
247
|
+
*/
|
|
248
|
+
apiJoinGroup(groupId: number): Promise<T.GroupInfo>;
|
|
249
|
+
/**
|
|
250
|
+
* Accept group member. Requires Admin role.
|
|
251
|
+
* Network usage: background.
|
|
252
|
+
*/
|
|
253
|
+
apiAcceptMember(groupId: number, groupMemberId: number, memberRole: T.GroupMemberRole): Promise<T.GroupMember>;
|
|
254
|
+
/**
|
|
255
|
+
* Set members role. Requires Admin role.
|
|
256
|
+
* Network usage: background.
|
|
257
|
+
*/
|
|
258
|
+
apiSetMembersRole(groupId: number, groupMemberIds: number[], memberRole: T.GroupMemberRole): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Block members. Requires Moderator role.
|
|
261
|
+
* Network usage: background.
|
|
262
|
+
*/
|
|
263
|
+
apiBlockMembersForAll(groupId: number, groupMemberIds: number[], blocked: boolean): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Remove members. Requires Admin role.
|
|
266
|
+
* Network usage: background.
|
|
267
|
+
*/
|
|
268
|
+
apiRemoveMembers(groupId: number, memberIds: number[], withMessages?: boolean): Promise<T.GroupMember[]>;
|
|
269
|
+
/**
|
|
270
|
+
* Leave group.
|
|
271
|
+
* Network usage: background.
|
|
272
|
+
*/
|
|
273
|
+
apiLeaveGroup(groupId: number): Promise<T.GroupInfo>;
|
|
274
|
+
/**
|
|
275
|
+
* Get group members.
|
|
276
|
+
* Network usage: no.
|
|
277
|
+
*/
|
|
278
|
+
apiListMembers(groupId: number): Promise<T.GroupMember[]>;
|
|
279
|
+
/**
|
|
280
|
+
* Create group.
|
|
281
|
+
* Network usage: no.
|
|
282
|
+
*/
|
|
283
|
+
apiNewGroup(userId: number, groupProfile: T.GroupProfile): Promise<T.GroupInfo>;
|
|
284
|
+
/**
|
|
285
|
+
* Update group profile.
|
|
286
|
+
* Network usage: background.
|
|
287
|
+
*/
|
|
288
|
+
apiUpdateGroupProfile(groupId: number, groupProfile: T.GroupProfile): Promise<T.GroupInfo>;
|
|
289
|
+
/**
|
|
290
|
+
* Create group link.
|
|
291
|
+
* Network usage: interactive.
|
|
292
|
+
*/
|
|
293
|
+
apiCreateGroupLink(groupId: number, memberRole: T.GroupMemberRole): Promise<string>;
|
|
294
|
+
/**
|
|
295
|
+
* Set member role for group link.
|
|
296
|
+
* Network usage: no.
|
|
297
|
+
*/
|
|
298
|
+
apiSetGroupLinkMemberRole(groupId: number, memberRole: T.GroupMemberRole): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Delete group link.
|
|
301
|
+
* Network usage: background.
|
|
302
|
+
*/
|
|
303
|
+
apiDeleteGroupLink(groupId: number): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Get group link.
|
|
306
|
+
* Network usage: no.
|
|
307
|
+
*/
|
|
308
|
+
apiGetGroupLink(groupId: number): Promise<T.GroupLink>;
|
|
309
|
+
apiGetGroupLinkStr(groupId: number): Promise<string>;
|
|
310
|
+
/**
|
|
311
|
+
* Create 1-time invitation link.
|
|
312
|
+
* Network usage: interactive.
|
|
313
|
+
*/
|
|
314
|
+
apiCreateLink(userId: number): Promise<string>;
|
|
315
|
+
/**
|
|
316
|
+
* Determine SimpleX link type and if the bot is already connected via this link.
|
|
317
|
+
* Network usage: interactive.
|
|
318
|
+
*/
|
|
319
|
+
apiConnectPlan(userId: number, connectionLink: string): Promise<[T.ConnectionPlan, T.CreatedConnLink]>;
|
|
320
|
+
/**
|
|
321
|
+
* Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link
|
|
322
|
+
* Network usage: interactive.
|
|
323
|
+
*/
|
|
324
|
+
apiConnect(userId: number, incognito: boolean, preparedLink?: T.CreatedConnLink): Promise<ConnReqType>;
|
|
325
|
+
/**
|
|
326
|
+
* Connect via SimpleX link as string in the active user profile.
|
|
327
|
+
* Network usage: interactive.
|
|
328
|
+
*/
|
|
329
|
+
apiConnectActiveUser(connLink: string): Promise<ConnReqType>;
|
|
330
|
+
private handleConnectResult;
|
|
331
|
+
/**
|
|
332
|
+
* Accept contact request.
|
|
333
|
+
* Network usage: interactive.
|
|
334
|
+
*/
|
|
335
|
+
apiAcceptContactRequest(contactReqId: number): Promise<T.Contact>;
|
|
336
|
+
/**
|
|
337
|
+
* Reject contact request. The user who sent the request is **not notified**.
|
|
338
|
+
* Network usage: no.
|
|
339
|
+
*/
|
|
340
|
+
apiRejectContactRequest(contactReqId: number): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Get contacts.
|
|
343
|
+
* Network usage: no.
|
|
344
|
+
*/
|
|
345
|
+
apiListContacts(userId: number): Promise<T.Contact[]>;
|
|
346
|
+
/**
|
|
347
|
+
* Get groups.
|
|
348
|
+
* Network usage: no.
|
|
349
|
+
*/
|
|
350
|
+
apiListGroups(userId: number, contactId?: number, search?: string): Promise<T.GroupInfo[]>;
|
|
351
|
+
/**
|
|
352
|
+
* Delete chat.
|
|
353
|
+
* Network usage: background.
|
|
354
|
+
*/
|
|
355
|
+
apiDeleteChat(chatType: T.ChatType, chatId: number, deleteMode?: T.ChatDeleteMode): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Set group custom data.
|
|
358
|
+
* Network usage: no.
|
|
359
|
+
*/
|
|
360
|
+
apiSetGroupCustomData(groupId: number, customData?: object): Promise<void>;
|
|
361
|
+
/**
|
|
362
|
+
* Set contact custom data.
|
|
363
|
+
* Network usage: no.
|
|
364
|
+
*/
|
|
365
|
+
apiSetContactCustomData(contactId: number, customData?: object): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Set auto-accept member contacts.
|
|
368
|
+
* Network usage: no.
|
|
369
|
+
*/
|
|
370
|
+
apiSetAutoAcceptMemberContacts(userId: number, onOff: boolean): Promise<void>;
|
|
371
|
+
/**
|
|
372
|
+
* Get chat items.
|
|
373
|
+
* Network usage: no.
|
|
374
|
+
*/
|
|
375
|
+
apiGetChat(chatType: T.ChatType, chatId: number, count: number): Promise<any>;
|
|
376
|
+
/**
|
|
377
|
+
* Get active user profile
|
|
378
|
+
* Network usage: no.
|
|
379
|
+
*/
|
|
380
|
+
apiGetActiveUser(): Promise<T.User | undefined>;
|
|
381
|
+
/**
|
|
382
|
+
* Create new user profile
|
|
383
|
+
* Network usage: no.
|
|
384
|
+
*/
|
|
385
|
+
apiCreateActiveUser(profile?: T.Profile): Promise<T.User>;
|
|
386
|
+
/**
|
|
387
|
+
* Get all user profiles
|
|
388
|
+
* Network usage: no.
|
|
389
|
+
*/
|
|
390
|
+
apiListUsers(): Promise<T.UserInfo[]>;
|
|
391
|
+
/**
|
|
392
|
+
* Set active user profile
|
|
393
|
+
* Network usage: no.
|
|
394
|
+
*/
|
|
395
|
+
apiSetActiveUser(userId: number, viewPwd?: string): Promise<T.User>;
|
|
396
|
+
/**
|
|
397
|
+
* Delete user profile.
|
|
398
|
+
* Network usage: background.
|
|
399
|
+
*/
|
|
400
|
+
apiDeleteUser(userId: number, delSMPQueues: boolean, viewPwd?: string): Promise<void>;
|
|
401
|
+
/**
|
|
402
|
+
* Update user profile.
|
|
403
|
+
* Network usage: background.
|
|
404
|
+
*/
|
|
405
|
+
apiUpdateProfile(userId: number, profile: T.Profile): Promise<T.UserProfileUpdateSummary | undefined>;
|
|
406
|
+
/**
|
|
407
|
+
* Configure chat preference overrides for the contact.
|
|
408
|
+
* Network usage: background.
|
|
409
|
+
*/
|
|
410
|
+
apiSetContactPrefs(contactId: number, preferences: T.Preferences): Promise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Create a direct message contact with a group member.
|
|
413
|
+
* Returns the created contact.
|
|
414
|
+
* Network usage: interactive.
|
|
415
|
+
*/
|
|
416
|
+
apiCreateMemberContact(groupId: number, groupMemberId: number): Promise<T.Contact>;
|
|
417
|
+
/**
|
|
418
|
+
* Send a direct message invitation to a group member contact.
|
|
419
|
+
* The contact must have been created with {@link apiCreateMemberContact}.
|
|
420
|
+
* Network usage: interactive.
|
|
421
|
+
*/
|
|
422
|
+
apiSendMemberContactInvitation(contactId: number, message?: T.MsgContent | string): Promise<T.Contact>;
|
|
423
|
+
}
|