@roeehrl/tinode-sdk 0.25.1-sqlite.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/LICENSE +201 -0
- package/README.md +47 -0
- package/package.json +76 -0
- package/src/access-mode.js +567 -0
- package/src/cbuffer.js +244 -0
- package/src/cbuffer.test.js +107 -0
- package/src/comm-error.js +14 -0
- package/src/config.js +71 -0
- package/src/connection.js +537 -0
- package/src/db.js +1021 -0
- package/src/drafty.js +2758 -0
- package/src/drafty.test.js +1600 -0
- package/src/fnd-topic.js +123 -0
- package/src/index.js +29 -0
- package/src/index.native.js +35 -0
- package/src/large-file.js +325 -0
- package/src/me-topic.js +480 -0
- package/src/meta-builder.js +283 -0
- package/src/storage-sqlite.js +1081 -0
- package/src/tinode.js +2382 -0
- package/src/topic.js +2160 -0
- package/src/utils.js +309 -0
- package/src/utils.test.js +456 -0
- package/types/index.d.ts +1227 -0
- package/umd/tinode.dev.js +6856 -0
- package/umd/tinode.dev.js.map +1 -0
- package/umd/tinode.prod.js +2 -0
- package/umd/tinode.prod.js.map +1 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,1227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for tinode-sdk
|
|
3
|
+
*
|
|
4
|
+
* Based on official Tinode JS API documentation:
|
|
5
|
+
* https://tinode.github.io/js-api/tinode.js.html
|
|
6
|
+
* https://tinode.github.io/js-api/topic.js.html
|
|
7
|
+
*
|
|
8
|
+
* The tinode-sdk npm package does not include TypeScript declarations.
|
|
9
|
+
* These types cover the core functionality used by our chat integration.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/tinode/tinode-js
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare module 'tinode-sdk' {
|
|
15
|
+
// ==========================================================================
|
|
16
|
+
// Configuration Types
|
|
17
|
+
// ==========================================================================
|
|
18
|
+
|
|
19
|
+
export interface TinodeConfig {
|
|
20
|
+
/** Application identifier shown in 'User-Agent' (optional) */
|
|
21
|
+
appName?: string;
|
|
22
|
+
/** Server hostname and optional port number */
|
|
23
|
+
host: string;
|
|
24
|
+
/** API key for the server */
|
|
25
|
+
apiKey: string;
|
|
26
|
+
/** Transport type: 'ws' (WebSocket) or 'lp' (long polling) */
|
|
27
|
+
transport?: 'ws' | 'lp';
|
|
28
|
+
/** Use secure connection (wss:// or https://) */
|
|
29
|
+
secure?: boolean;
|
|
30
|
+
/** Platform identifier */
|
|
31
|
+
platform?: 'ios' | 'web' | 'android';
|
|
32
|
+
/** Enable IndexedDB caching for messages */
|
|
33
|
+
persist?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ==========================================================================
|
|
37
|
+
// Access Mode
|
|
38
|
+
// ==========================================================================
|
|
39
|
+
|
|
40
|
+
export class AccessMode {
|
|
41
|
+
given: number;
|
|
42
|
+
want: number;
|
|
43
|
+
mode: number;
|
|
44
|
+
|
|
45
|
+
constructor(acs?: { given?: string | number; want?: string | number; mode?: string | number });
|
|
46
|
+
|
|
47
|
+
static decode(str: string | number | null): number | null;
|
|
48
|
+
static encode(val: number | null): string | null;
|
|
49
|
+
static update(val: number, upd: string): number;
|
|
50
|
+
static diff(a1: string | number, a2: string | number): number;
|
|
51
|
+
|
|
52
|
+
toString(): string;
|
|
53
|
+
jsonHelper(): { mode: string | null; given: string | null; want: string | null };
|
|
54
|
+
|
|
55
|
+
setMode(m: string | number): this;
|
|
56
|
+
updateMode(u: string): this;
|
|
57
|
+
getMode(): string | null;
|
|
58
|
+
|
|
59
|
+
setGiven(g: string | number): this;
|
|
60
|
+
updateGiven(u: string): this;
|
|
61
|
+
getGiven(): string | null;
|
|
62
|
+
|
|
63
|
+
setWant(w: string | number): this;
|
|
64
|
+
updateWant(u: string): this;
|
|
65
|
+
getWant(): string | null;
|
|
66
|
+
|
|
67
|
+
getMissing(): string | null;
|
|
68
|
+
getExcessive(): string | null;
|
|
69
|
+
updateAll(val: { given?: string; want?: string }): this;
|
|
70
|
+
|
|
71
|
+
isOwner(side?: 'given' | 'want' | 'mode'): boolean;
|
|
72
|
+
isPresencer(side?: 'given' | 'want' | 'mode'): boolean;
|
|
73
|
+
isMuted(side?: 'given' | 'want' | 'mode'): boolean;
|
|
74
|
+
isJoiner(side?: 'given' | 'want' | 'mode'): boolean;
|
|
75
|
+
isReader(side?: 'given' | 'want' | 'mode'): boolean;
|
|
76
|
+
isWriter(side?: 'given' | 'want' | 'mode'): boolean;
|
|
77
|
+
isApprover(side?: 'given' | 'want' | 'mode'): boolean;
|
|
78
|
+
isSharer(side?: 'given' | 'want' | 'mode'): boolean;
|
|
79
|
+
isDeleter(side?: 'given' | 'want' | 'mode'): boolean;
|
|
80
|
+
isAdmin(side?: 'given' | 'want' | 'mode'): boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ==========================================================================
|
|
84
|
+
// Message & Content Types
|
|
85
|
+
// ==========================================================================
|
|
86
|
+
|
|
87
|
+
export interface ServerMessage {
|
|
88
|
+
topic?: string;
|
|
89
|
+
from?: string;
|
|
90
|
+
ts?: string;
|
|
91
|
+
seq?: number;
|
|
92
|
+
head?: Record<string, unknown>;
|
|
93
|
+
content?: unknown;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ControlMessage {
|
|
97
|
+
id?: string;
|
|
98
|
+
topic?: string;
|
|
99
|
+
code: number;
|
|
100
|
+
text: string;
|
|
101
|
+
ts?: string;
|
|
102
|
+
params?: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface PresenceMessage {
|
|
106
|
+
topic: string;
|
|
107
|
+
src?: string;
|
|
108
|
+
what: string;
|
|
109
|
+
seq?: number;
|
|
110
|
+
clear?: number;
|
|
111
|
+
ua?: string;
|
|
112
|
+
act?: string;
|
|
113
|
+
tgt?: string;
|
|
114
|
+
acs?: { given?: string; want?: string; mode?: string };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface MetaMessage {
|
|
118
|
+
topic: string;
|
|
119
|
+
ts?: string;
|
|
120
|
+
desc?: TopicDescription;
|
|
121
|
+
sub?: TopicSubscription[];
|
|
122
|
+
tags?: string[];
|
|
123
|
+
cred?: Credential[];
|
|
124
|
+
del?: { clear: number; delseq: Array<{ low: number; hi?: number }> };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface AuthToken {
|
|
128
|
+
token: string;
|
|
129
|
+
expires: Date;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface Credential {
|
|
133
|
+
meth: string;
|
|
134
|
+
val: string;
|
|
135
|
+
resp?: string;
|
|
136
|
+
done?: boolean;
|
|
137
|
+
params?: Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ==========================================================================
|
|
141
|
+
// Topic Types
|
|
142
|
+
// ==========================================================================
|
|
143
|
+
|
|
144
|
+
export interface TopicDescription {
|
|
145
|
+
created?: string;
|
|
146
|
+
updated?: string;
|
|
147
|
+
touched?: string;
|
|
148
|
+
defacs?: DefAcs;
|
|
149
|
+
acs?: { given?: string; want?: string; mode?: string };
|
|
150
|
+
seq?: number;
|
|
151
|
+
read?: number;
|
|
152
|
+
recv?: number;
|
|
153
|
+
clear?: number;
|
|
154
|
+
public?: Record<string, unknown>;
|
|
155
|
+
trusted?: Record<string, unknown>;
|
|
156
|
+
private?: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface DefAcs {
|
|
160
|
+
auth?: string;
|
|
161
|
+
anon?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface TopicSubscription {
|
|
165
|
+
user?: string;
|
|
166
|
+
topic?: string;
|
|
167
|
+
updated?: string;
|
|
168
|
+
touched?: string;
|
|
169
|
+
acs?: { given?: string; want?: string; mode?: string };
|
|
170
|
+
read?: number;
|
|
171
|
+
recv?: number;
|
|
172
|
+
clear?: number;
|
|
173
|
+
public?: Record<string, unknown>;
|
|
174
|
+
trusted?: Record<string, unknown>;
|
|
175
|
+
private?: Record<string, unknown>;
|
|
176
|
+
online?: boolean;
|
|
177
|
+
seen?: { when?: string; ua?: string };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface GetQuery {
|
|
181
|
+
what?: string;
|
|
182
|
+
desc?: GetOptsType;
|
|
183
|
+
sub?: GetOptsType & { user?: string; topic?: string; limit?: number };
|
|
184
|
+
data?: GetDataType;
|
|
185
|
+
del?: GetDataType;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface GetOptsType {
|
|
189
|
+
ims?: string | Date;
|
|
190
|
+
limit?: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface GetDataType {
|
|
194
|
+
since?: number;
|
|
195
|
+
before?: number;
|
|
196
|
+
limit?: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface SetParams {
|
|
200
|
+
desc?: SetDesc;
|
|
201
|
+
sub?: SetSub;
|
|
202
|
+
tags?: string[];
|
|
203
|
+
cred?: Credential;
|
|
204
|
+
attachments?: string[];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface SetDesc {
|
|
208
|
+
defacs?: DefAcs;
|
|
209
|
+
public?: Record<string, unknown>;
|
|
210
|
+
trusted?: Record<string, unknown>;
|
|
211
|
+
private?: Record<string, unknown>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface SetSub {
|
|
215
|
+
user?: string;
|
|
216
|
+
mode?: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface DelRange {
|
|
220
|
+
low: number;
|
|
221
|
+
hi?: number;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ==========================================================================
|
|
225
|
+
// Drafty (Rich Text Format)
|
|
226
|
+
// ==========================================================================
|
|
227
|
+
|
|
228
|
+
export interface DraftyDocument {
|
|
229
|
+
txt?: string;
|
|
230
|
+
fmt?: Array<{ at?: number; len?: number; tp?: string; key?: number }>;
|
|
231
|
+
ent?: Array<{ tp: string; data: Record<string, unknown> }>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Drafty descriptor types for media/attachments
|
|
235
|
+
export interface ImageDesc {
|
|
236
|
+
mime: string;
|
|
237
|
+
bits?: string;
|
|
238
|
+
refurl?: string;
|
|
239
|
+
preview?: string;
|
|
240
|
+
width: number;
|
|
241
|
+
height: number;
|
|
242
|
+
filename?: string;
|
|
243
|
+
size?: number;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface VideoDesc {
|
|
247
|
+
mime: string;
|
|
248
|
+
bits?: string;
|
|
249
|
+
refurl?: string;
|
|
250
|
+
preref?: string;
|
|
251
|
+
preview?: string;
|
|
252
|
+
width: number;
|
|
253
|
+
height: number;
|
|
254
|
+
duration?: number;
|
|
255
|
+
filename?: string;
|
|
256
|
+
size?: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface AudioDesc {
|
|
260
|
+
mime: string;
|
|
261
|
+
bits?: string;
|
|
262
|
+
refurl?: string;
|
|
263
|
+
preview?: string;
|
|
264
|
+
duration: number;
|
|
265
|
+
filename?: string;
|
|
266
|
+
size?: number;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface AttachmentDesc {
|
|
270
|
+
mime?: string;
|
|
271
|
+
data?: string;
|
|
272
|
+
filename?: string;
|
|
273
|
+
refurl?: string;
|
|
274
|
+
size?: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export namespace Drafty {
|
|
278
|
+
// Core methods
|
|
279
|
+
/** Initialize a new Drafty document from plain text */
|
|
280
|
+
function init(plainText: string): DraftyDocument | null;
|
|
281
|
+
/** Parse markdown-like content into Drafty */
|
|
282
|
+
function parse(content: string): DraftyDocument | null;
|
|
283
|
+
/** Format Drafty document using custom formatter */
|
|
284
|
+
function format(doc: DraftyDocument, formatter: unknown, context?: unknown): unknown;
|
|
285
|
+
/** Check if object is a valid Drafty document */
|
|
286
|
+
function isValid(doc: unknown): boolean;
|
|
287
|
+
|
|
288
|
+
// Plain text conversion
|
|
289
|
+
/** Convert Drafty to plain text (stripping formatting) */
|
|
290
|
+
function toPlainText(doc: DraftyDocument | string | null): string;
|
|
291
|
+
/** Convert Drafty to markdown */
|
|
292
|
+
function toMarkdown(doc: DraftyDocument): string;
|
|
293
|
+
/** Convert Drafty to HTML (UNSAFE - not sanitized) */
|
|
294
|
+
function UNSAFE_toHTML(doc: DraftyDocument): string;
|
|
295
|
+
/** Create a preview of the document */
|
|
296
|
+
function preview(doc: DraftyDocument | string, limit: number, forwarding?: boolean): DraftyDocument;
|
|
297
|
+
/** Shorten document to specified limit */
|
|
298
|
+
function shorten(content: DraftyDocument | string, limit: number, light?: boolean): DraftyDocument;
|
|
299
|
+
|
|
300
|
+
// Entity methods
|
|
301
|
+
/** Check if document has entities */
|
|
302
|
+
function hasEntities(doc: DraftyDocument): boolean;
|
|
303
|
+
/** Iterate over entities. Callback receives (data, index, type). Return truthy to stop. */
|
|
304
|
+
function entities(doc: DraftyDocument, callback: (data: Record<string, unknown>, index: number, type: string) => boolean | void, context?: unknown): void;
|
|
305
|
+
/** Get MIME type from entity data (defaults to 'text/plain') */
|
|
306
|
+
function getEntityMimeType(entData: Record<string, unknown>): string;
|
|
307
|
+
/** Get size from entity data (defaults to 0) */
|
|
308
|
+
function getEntitySize(entData: Record<string, unknown>): number;
|
|
309
|
+
/** Get HTML attribute value for a style */
|
|
310
|
+
function attrValue(style: string, data: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
311
|
+
/** Remove dangerous entities from document */
|
|
312
|
+
function sanitizeEntities(doc: DraftyDocument): DraftyDocument;
|
|
313
|
+
/** Get HTML tag name for a style code */
|
|
314
|
+
function tagName(style: string): string | undefined;
|
|
315
|
+
/** Iterate over styles in document. Callback receives (tp, at, len, key, index). Return truthy to stop. */
|
|
316
|
+
function styles(content: DraftyDocument, callback: (tp: string, at: number, len: number, key: number | undefined, index: number) => boolean | void, context?: unknown): void;
|
|
317
|
+
/** Get content type for Drafty documents */
|
|
318
|
+
function getContentType(): string;
|
|
319
|
+
|
|
320
|
+
// Attachment methods
|
|
321
|
+
/** Check if document has file attachments */
|
|
322
|
+
function hasAttachments(doc: DraftyDocument): boolean;
|
|
323
|
+
/** Iterate over attachments. Callback receives (data, count, 'EX'). Return truthy to stop. */
|
|
324
|
+
function attachments(doc: DraftyDocument, callback: (data: Record<string, unknown>, count: number, type: string) => boolean | void, context?: unknown): void;
|
|
325
|
+
/** Attach a file to document using descriptor */
|
|
326
|
+
function attachFile(content: DraftyDocument, attachmentDesc: AttachmentDesc): DraftyDocument;
|
|
327
|
+
/** Attach JSON data to document */
|
|
328
|
+
function attachJSON(doc: DraftyDocument, data: Record<string, unknown>): DraftyDocument;
|
|
329
|
+
/** Get download URL from entity data */
|
|
330
|
+
function getDownloadUrl(entData: { ref?: string; url?: string }): string | null;
|
|
331
|
+
/** Get preview URL from entity data */
|
|
332
|
+
function getPreviewUrl(entData: { ref?: string }): string | null;
|
|
333
|
+
|
|
334
|
+
// Content creation
|
|
335
|
+
/** Create a mention element */
|
|
336
|
+
function mention(name: string, uid: string): DraftyDocument;
|
|
337
|
+
/** Create a quote element */
|
|
338
|
+
function quote(header: string, uid: string, body: DraftyDocument): DraftyDocument;
|
|
339
|
+
/** Create reply content from original message */
|
|
340
|
+
function replyContent(original: DraftyDocument | string, limit: number): DraftyDocument;
|
|
341
|
+
/** Create forwarded content from original */
|
|
342
|
+
function forwardedContent(original: DraftyDocument | string): DraftyDocument;
|
|
343
|
+
|
|
344
|
+
// Append/Insert methods
|
|
345
|
+
/** Append content to document */
|
|
346
|
+
function append(doc: DraftyDocument, content: DraftyDocument | string): DraftyDocument;
|
|
347
|
+
/** Append a line break */
|
|
348
|
+
function appendLineBreak(doc: DraftyDocument): DraftyDocument;
|
|
349
|
+
/** Append an image using descriptor */
|
|
350
|
+
function appendImage(content: DraftyDocument, imageDesc: ImageDesc): DraftyDocument;
|
|
351
|
+
/** Append audio using descriptor */
|
|
352
|
+
function appendAudio(content: DraftyDocument, audioDesc: AudioDesc): DraftyDocument;
|
|
353
|
+
/** Append a button */
|
|
354
|
+
function appendButton(content: DraftyDocument | string, title: string, name: string, actionType: string, actionValue: string, refUrl?: string): DraftyDocument;
|
|
355
|
+
/** Append a link */
|
|
356
|
+
function appendLink(doc: DraftyDocument, linkData: { txt: string; url: string }): DraftyDocument;
|
|
357
|
+
|
|
358
|
+
/** Insert an image at position using descriptor */
|
|
359
|
+
function insertImage(content: DraftyDocument, at: number, imageDesc: ImageDesc): DraftyDocument;
|
|
360
|
+
/** Insert audio at position using descriptor */
|
|
361
|
+
function insertAudio(content: DraftyDocument, at: number, audioDesc: AudioDesc): DraftyDocument;
|
|
362
|
+
/** Insert a button at position (no title param) */
|
|
363
|
+
function insertButton(content: DraftyDocument | string, at: number, len: number, name: string, actionType: string, actionValue: string, refUrl?: string): DraftyDocument | null;
|
|
364
|
+
/** Insert video at position using descriptor */
|
|
365
|
+
function insertVideo(content: DraftyDocument, at: number, videoDesc: VideoDesc): DraftyDocument;
|
|
366
|
+
|
|
367
|
+
// Wrapping
|
|
368
|
+
/** Wrap content as a form at position */
|
|
369
|
+
function wrapAsForm(content: DraftyDocument | string, at: number, len: number): DraftyDocument;
|
|
370
|
+
/** Wrap content into a style at position (defaults: at=0, len=content length) */
|
|
371
|
+
function wrapInto(content: DraftyDocument | string, style: string, at?: number, len?: number): DraftyDocument;
|
|
372
|
+
|
|
373
|
+
// Video call
|
|
374
|
+
/** Create a video call document */
|
|
375
|
+
function videoCall(audioOnly?: boolean): DraftyDocument;
|
|
376
|
+
/** Update an existing video call document */
|
|
377
|
+
function updateVideoCall(content: DraftyDocument, params: { duration?: number; state?: string }): DraftyDocument;
|
|
378
|
+
|
|
379
|
+
// State checks
|
|
380
|
+
/** Check if document is plain text (no formatting) */
|
|
381
|
+
function isPlainText(doc: DraftyDocument): boolean;
|
|
382
|
+
/** Check if entity data indicates pending upload */
|
|
383
|
+
function isProcessing(entData: Record<string, unknown>): boolean;
|
|
384
|
+
/** Check if MIME type is a form response type */
|
|
385
|
+
function isFormResponseType(mimeType: string): boolean;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// ==========================================================================
|
|
389
|
+
// Topic Class
|
|
390
|
+
// ==========================================================================
|
|
391
|
+
|
|
392
|
+
export class Topic<
|
|
393
|
+
PublicType = Record<string, unknown>,
|
|
394
|
+
PrivateType = Record<string, unknown>,
|
|
395
|
+
TrustedType = Record<string, unknown>,
|
|
396
|
+
> {
|
|
397
|
+
// Static methods for topic name classification
|
|
398
|
+
static topicType(name: string): 'me' | 'fnd' | 'grp' | 'p2p' | 'sys' | undefined;
|
|
399
|
+
static isMeTopicName(name: string): boolean;
|
|
400
|
+
static isSelfTopicName(name: string): boolean;
|
|
401
|
+
static isGroupTopicName(name: string): boolean;
|
|
402
|
+
static isP2PTopicName(name: string): boolean;
|
|
403
|
+
static isCommTopicName(name: string): boolean;
|
|
404
|
+
static isNewGroupTopicName(name: string): boolean;
|
|
405
|
+
static isChannelTopicName(name: string): boolean;
|
|
406
|
+
|
|
407
|
+
// Fields
|
|
408
|
+
name: string;
|
|
409
|
+
acs: AccessMode;
|
|
410
|
+
private: PrivateType | null;
|
|
411
|
+
public: PublicType | null;
|
|
412
|
+
trusted: TrustedType | null;
|
|
413
|
+
seq: number;
|
|
414
|
+
read: number;
|
|
415
|
+
recv: number;
|
|
416
|
+
unread: number;
|
|
417
|
+
clear: number;
|
|
418
|
+
touched: Date;
|
|
419
|
+
updated: Date;
|
|
420
|
+
created: Date;
|
|
421
|
+
defacs: DefAcs | null;
|
|
422
|
+
|
|
423
|
+
// Callbacks
|
|
424
|
+
onData: ((msg: ServerMessage) => void) | null;
|
|
425
|
+
onMeta: ((msg: MetaMessage) => void) | null;
|
|
426
|
+
onPres: ((msg: PresenceMessage) => void) | null;
|
|
427
|
+
onInfo: ((msg: PresenceMessage) => void) | null;
|
|
428
|
+
onMetaSub: ((sub: TopicSubscription) => void) | null;
|
|
429
|
+
onMetaDesc: ((topic: Topic) => void) | null;
|
|
430
|
+
onSubsUpdated: ((subs: string[], count?: number) => void) | null;
|
|
431
|
+
onTagsUpdated: ((tags: string[]) => void) | null;
|
|
432
|
+
onCredsUpdated: ((creds: Credential[]) => void) | null;
|
|
433
|
+
onAuxUpdated: ((aux: Record<string, unknown>) => void) | null;
|
|
434
|
+
onDeleteTopic: (() => void) | null;
|
|
435
|
+
onAllMessagesReceived: ((count: number) => void) | null;
|
|
436
|
+
|
|
437
|
+
constructor(name: string, callbacks?: Partial<TopicCallbacks>);
|
|
438
|
+
|
|
439
|
+
// Subscription
|
|
440
|
+
subscribe(getParams?: GetQuery, setParams?: SetParams): Promise<ControlMessage>;
|
|
441
|
+
leave(unsub?: boolean): Promise<ControlMessage>;
|
|
442
|
+
leaveDelayed(unsub: boolean, delay: number): void;
|
|
443
|
+
isSubscribed(): boolean;
|
|
444
|
+
|
|
445
|
+
// Messaging
|
|
446
|
+
publish(data: string | DraftyDocument, noEcho?: boolean): Promise<ControlMessage>;
|
|
447
|
+
/** Publish a message created by createMessage(). Attachments are extracted internally. */
|
|
448
|
+
publishMessage(pub: unknown): Promise<ControlMessage>;
|
|
449
|
+
publishDraft(pub: unknown, prom?: Promise<unknown>): Promise<ControlMessage>;
|
|
450
|
+
createMessage(data: string | DraftyDocument, noEcho?: boolean): unknown;
|
|
451
|
+
|
|
452
|
+
// Message retrieval
|
|
453
|
+
getMessagesPage(limit: number, gaps?: Array<{ low: number; hi?: number }>, min?: number, max?: number, newer?: boolean): Promise<ControlMessage>;
|
|
454
|
+
getPinnedMessages(): Promise<ControlMessage>;
|
|
455
|
+
/** Iterate over messages. Callback receives (msg, prevMsg, nextMsg, index) */
|
|
456
|
+
messages(callback?: (msg: ServerMessage, prevMsg: ServerMessage | undefined, nextMsg: ServerMessage | undefined, idx: number) => void, sinceId?: number, beforeId?: number, context?: unknown): void;
|
|
457
|
+
findMessage(seq: number): ServerMessage | undefined;
|
|
458
|
+
latestMessage(): ServerMessage | undefined;
|
|
459
|
+
latestMsgVersion(seq: number): ServerMessage | null;
|
|
460
|
+
/** Iterate over message versions. Callback receives (msg, prevMsg, nextMsg, index) */
|
|
461
|
+
messageVersions(origSeq: number, callback?: (msg: ServerMessage, prevMsg: ServerMessage | undefined, nextMsg: ServerMessage | undefined, idx: number) => void, context?: unknown): void;
|
|
462
|
+
/** Iterate over queued messages (wraps messages with LOCAL_SEQID). Callback receives (msg, prevMsg, nextMsg, index) */
|
|
463
|
+
queuedMessages(callback: (msg: ServerMessage, prevMsg: ServerMessage | undefined, nextMsg: ServerMessage | undefined, idx: number) => void, context?: unknown): void;
|
|
464
|
+
maxMsgSeq(): number;
|
|
465
|
+
minMsgSeq(): number;
|
|
466
|
+
maxClearId(): number;
|
|
467
|
+
messageCount(): number;
|
|
468
|
+
|
|
469
|
+
// Metadata
|
|
470
|
+
getMeta(params: GetQuery): Promise<ControlMessage>;
|
|
471
|
+
setMeta(params: SetParams): Promise<ControlMessage>;
|
|
472
|
+
startMetaQuery(): MetaGetBuilder;
|
|
473
|
+
pinMessage(seq: number, pin: boolean): Promise<ControlMessage>;
|
|
474
|
+
|
|
475
|
+
// Notifications
|
|
476
|
+
note(what: 'recv' | 'read', seq: number): void;
|
|
477
|
+
noteRecv(seq: number): void;
|
|
478
|
+
noteRead(seq?: number): void;
|
|
479
|
+
noteKeyPress(): void;
|
|
480
|
+
noteRecording(audioOnly?: boolean): void;
|
|
481
|
+
videoCall(evt: string, seq: number, payload?: string): Promise<ControlMessage>;
|
|
482
|
+
|
|
483
|
+
// Message management
|
|
484
|
+
delMessages(ranges: DelRange[], hard?: boolean): Promise<ControlMessage>;
|
|
485
|
+
delMessagesAll(hardDel?: boolean): Promise<ControlMessage>;
|
|
486
|
+
delMessagesList(list: number[], hardDel?: boolean): Promise<ControlMessage>;
|
|
487
|
+
delMessagesEdits(seq: number, hardDel?: boolean): Promise<ControlMessage>;
|
|
488
|
+
flushMessage(seqId: number): unknown | undefined;
|
|
489
|
+
flushMessageRange(fromId: number, untilId: number): unknown[];
|
|
490
|
+
swapMessageId(pub: unknown, newSeqId: number): void;
|
|
491
|
+
cancelSend(seqId: number): boolean;
|
|
492
|
+
|
|
493
|
+
// Message status
|
|
494
|
+
msgStatus(msg: unknown, upd?: boolean): number;
|
|
495
|
+
msgReadCount(seq: number): number;
|
|
496
|
+
msgRecvCount(seq: number): number;
|
|
497
|
+
msgReceiptCount(what: 'read' | 'recv', seq: number): number;
|
|
498
|
+
msgHasMoreMessages(min: number, max: number, newer: boolean): Array<{ low: number; hi?: number }>;
|
|
499
|
+
isNewMessage(seqId: number): boolean;
|
|
500
|
+
|
|
501
|
+
// Topic info
|
|
502
|
+
getType(): 'me' | 'fnd' | 'grp' | 'p2p' | 'sys' | undefined;
|
|
503
|
+
getAccessMode(): AccessMode;
|
|
504
|
+
setAccessMode(acs: AccessMode | { given?: string; want?: string; mode?: string }): AccessMode;
|
|
505
|
+
getDefaultAccess(): DefAcs | null;
|
|
506
|
+
isArchived(): boolean;
|
|
507
|
+
isMeType(): boolean;
|
|
508
|
+
isSelfType(): boolean;
|
|
509
|
+
isGroupType(): boolean;
|
|
510
|
+
isP2PType(): boolean;
|
|
511
|
+
isChannelType(): boolean;
|
|
512
|
+
isCommType(): boolean;
|
|
513
|
+
|
|
514
|
+
// Auxiliary data
|
|
515
|
+
aux(key: string): unknown;
|
|
516
|
+
|
|
517
|
+
// Subscribers
|
|
518
|
+
/** Iterate over subscribers. Callback receives (sub, userId, users) */
|
|
519
|
+
subscribers(callback?: (sub: TopicSubscription, userId: string, users: Record<string, TopicSubscription>) => void, context?: unknown): void;
|
|
520
|
+
subscriber(uid: string): TopicSubscription | undefined;
|
|
521
|
+
userDesc(uid: string): TopicSubscription | undefined;
|
|
522
|
+
p2pPeerDesc(): TopicSubscription | undefined;
|
|
523
|
+
|
|
524
|
+
// Subscription management
|
|
525
|
+
updateMode(uid: string | null, update: string): Promise<ControlMessage>;
|
|
526
|
+
invite(userId: string, mode?: string): Promise<ControlMessage>;
|
|
527
|
+
delSubscription(user: string): Promise<ControlMessage>;
|
|
528
|
+
archive(arch: boolean): Promise<ControlMessage>;
|
|
529
|
+
|
|
530
|
+
// Tags
|
|
531
|
+
tags(): string[];
|
|
532
|
+
alias(): string | undefined;
|
|
533
|
+
|
|
534
|
+
// Topic deletion
|
|
535
|
+
delTopic(hard?: boolean): Promise<ControlMessage>;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export interface TopicCallbacks {
|
|
539
|
+
onData: (msg: ServerMessage) => void;
|
|
540
|
+
onMeta: (msg: MetaMessage) => void;
|
|
541
|
+
onPres: (msg: PresenceMessage) => void;
|
|
542
|
+
onInfo: (msg: unknown) => void;
|
|
543
|
+
onMetaSub: (sub: TopicSubscription) => void;
|
|
544
|
+
onMetaDesc: (topic: Topic) => void;
|
|
545
|
+
onSubsUpdated: (subs: string[], count?: number) => void;
|
|
546
|
+
onTagsUpdated: (tags: string[]) => void;
|
|
547
|
+
onCredsUpdated: (creds: Credential[]) => void;
|
|
548
|
+
onAuxUpdated: (aux: Record<string, unknown>) => void;
|
|
549
|
+
onDeleteTopic: () => void;
|
|
550
|
+
onAllMessagesReceived: (count: number) => void;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// ==========================================================================
|
|
554
|
+
// TopicMe (User's personal topic)
|
|
555
|
+
// ==========================================================================
|
|
556
|
+
|
|
557
|
+
export class TopicMe extends Topic {
|
|
558
|
+
/** Callback when a contact is updated */
|
|
559
|
+
onContactUpdate: ((what: string, contact: TopicSubscription) => void) | null;
|
|
560
|
+
|
|
561
|
+
/** Publishing to 'me' is not supported - always returns rejected Promise */
|
|
562
|
+
publish(): Promise<never>;
|
|
563
|
+
|
|
564
|
+
/** Iterate over cached contacts (topics), callback receives (topic, cacheKey) */
|
|
565
|
+
contacts(callback?: (contact: Topic, key: string) => void, filter?: (contact: Topic) => boolean, context?: unknown): void;
|
|
566
|
+
getContact(name: string): TopicSubscription | undefined;
|
|
567
|
+
getAccessMode(name?: string): AccessMode | null;
|
|
568
|
+
/** Check if a contact is archived. @param name - UID or topic name (required for TopicMe, checks contact not self) */
|
|
569
|
+
isArchived(name?: string): boolean;
|
|
570
|
+
getCredentials(): Credential[];
|
|
571
|
+
delCredential(method: string, value: string): Promise<ControlMessage>;
|
|
572
|
+
/** Pin or unpin a topic. If pin is undefined, toggles current state */
|
|
573
|
+
pinTopic(topic: string, pin?: boolean): Promise<ControlMessage>;
|
|
574
|
+
/** Get the rank of a pinned topic (0 if unpinned, 1..N if pinned) */
|
|
575
|
+
pinnedTopicRank(topic: string): number;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// ==========================================================================
|
|
579
|
+
// TopicFnd (Discovery topic)
|
|
580
|
+
// ==========================================================================
|
|
581
|
+
|
|
582
|
+
export class TopicFnd extends Topic {
|
|
583
|
+
/** Publishing to 'fnd' is not supported - always returns rejected Promise */
|
|
584
|
+
publish(): Promise<never>;
|
|
585
|
+
|
|
586
|
+
/** Iterate through cached contacts, callback receives (contact, key, contacts) */
|
|
587
|
+
contacts(callback?: (contact: TopicSubscription, key: string, contacts: Record<string, TopicSubscription>) => void, context?: unknown): void;
|
|
588
|
+
/** Check if a tag is unique. @param caller - Identifier string for the caller */
|
|
589
|
+
checkTagUniqueness(tag: string, caller: string): Promise<boolean>;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// ==========================================================================
|
|
593
|
+
// MetaGetBuilder
|
|
594
|
+
// ==========================================================================
|
|
595
|
+
|
|
596
|
+
export class MetaGetBuilder {
|
|
597
|
+
constructor(parent?: Topic);
|
|
598
|
+
|
|
599
|
+
withData(since?: number, before?: number, limit?: number): this;
|
|
600
|
+
withLaterData(limit?: number): this;
|
|
601
|
+
withEarlierData(limit?: number): this;
|
|
602
|
+
withDataRanges(ranges: DelRange[], limit?: number): this;
|
|
603
|
+
withDataList(list: number[]): this;
|
|
604
|
+
withDel(since?: number, limit?: number): this;
|
|
605
|
+
withLaterDel(limit?: number): this;
|
|
606
|
+
withDesc(ims?: Date): this;
|
|
607
|
+
withLaterDesc(): this;
|
|
608
|
+
withSub(ims?: Date, limit?: number, identifier?: string): this;
|
|
609
|
+
withLaterSub(limit?: number): this;
|
|
610
|
+
withOneSub(ims?: Date, user?: string): this;
|
|
611
|
+
withLaterOneSub(userOrTopic?: string): this;
|
|
612
|
+
withTags(): this;
|
|
613
|
+
withCred(): this;
|
|
614
|
+
withAux(): this;
|
|
615
|
+
extract(what: string): GetQuery[keyof GetQuery];
|
|
616
|
+
build(): GetQuery;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// ==========================================================================
|
|
620
|
+
// LargeFileHelper
|
|
621
|
+
// ==========================================================================
|
|
622
|
+
|
|
623
|
+
export class LargeFileHelper {
|
|
624
|
+
static setNetworkProvider(xhrProvider: unknown): void;
|
|
625
|
+
|
|
626
|
+
constructor(tinode: Tinode, version?: string);
|
|
627
|
+
|
|
628
|
+
uploadWithBaseUrl(
|
|
629
|
+
baseUrl: string,
|
|
630
|
+
data: File | Blob,
|
|
631
|
+
avatarFor?: string,
|
|
632
|
+
/** Progress callback receives float 0..1 */
|
|
633
|
+
onProgress?: (progress: number) => void,
|
|
634
|
+
onSuccess?: (ctrl: ControlMessage) => void,
|
|
635
|
+
/** Failure callback receives control object or null */
|
|
636
|
+
onFailure?: (ctrl: ControlMessage | null) => void,
|
|
637
|
+
): Promise<unknown>;
|
|
638
|
+
|
|
639
|
+
upload(
|
|
640
|
+
data: File | Blob,
|
|
641
|
+
avatarFor?: string,
|
|
642
|
+
/** Progress callback receives float 0..1 */
|
|
643
|
+
onProgress?: (progress: number) => void,
|
|
644
|
+
onSuccess?: (ctrl: ControlMessage) => void,
|
|
645
|
+
/** Failure callback receives control object or null */
|
|
646
|
+
onFailure?: (ctrl: ControlMessage | null) => void,
|
|
647
|
+
): Promise<unknown>;
|
|
648
|
+
|
|
649
|
+
download(
|
|
650
|
+
relativeUrl: string,
|
|
651
|
+
filename?: string,
|
|
652
|
+
mimetype?: string,
|
|
653
|
+
/** Progress callback receives bytes loaded (not ratio, due to gzip) */
|
|
654
|
+
onProgress?: (loaded: number) => void,
|
|
655
|
+
/** Error callback receives error message string or Error object */
|
|
656
|
+
onError?: (error: Error | string) => void,
|
|
657
|
+
): Promise<void>;
|
|
658
|
+
|
|
659
|
+
cancel(): void;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// ==========================================================================
|
|
663
|
+
// Main Tinode Class
|
|
664
|
+
// ==========================================================================
|
|
665
|
+
|
|
666
|
+
// Note: tinode-sdk exports Tinode as both default and named export.
|
|
667
|
+
// The UMD bundle uses named exports, so we export it both ways for compatibility.
|
|
668
|
+
export class Tinode {
|
|
669
|
+
// Static constants
|
|
670
|
+
static readonly MESSAGE_STATUS_NONE: number;
|
|
671
|
+
static readonly MESSAGE_STATUS_QUEUED: number;
|
|
672
|
+
static readonly MESSAGE_STATUS_SENDING: number;
|
|
673
|
+
static readonly MESSAGE_STATUS_FAILED: number;
|
|
674
|
+
static readonly MESSAGE_STATUS_FATAL: number;
|
|
675
|
+
static readonly MESSAGE_STATUS_SENT: number;
|
|
676
|
+
static readonly MESSAGE_STATUS_RECEIVED: number;
|
|
677
|
+
static readonly MESSAGE_STATUS_READ: number;
|
|
678
|
+
static readonly MESSAGE_STATUS_TO_ME: number;
|
|
679
|
+
static readonly DEL_CHAR: string;
|
|
680
|
+
/** Key for getServerParam() - returns max message size limit */
|
|
681
|
+
static readonly MAX_MESSAGE_SIZE: string;
|
|
682
|
+
/** Key for getServerParam() - returns max subscriber count limit */
|
|
683
|
+
static readonly MAX_SUBSCRIBER_COUNT: string;
|
|
684
|
+
/** Key for getServerParam() - returns max tag count limit */
|
|
685
|
+
static readonly MAX_TAG_COUNT: string;
|
|
686
|
+
/** Key for getServerParam() - returns max file upload size limit */
|
|
687
|
+
static readonly MAX_FILE_UPLOAD_SIZE: string;
|
|
688
|
+
/** Key for getServerParam() - returns required credential validators */
|
|
689
|
+
static readonly REQ_CRED_VALIDATORS: string;
|
|
690
|
+
/** Key for getServerParam() - returns min tag length */
|
|
691
|
+
static readonly MIN_TAG_LENGTH: string;
|
|
692
|
+
/** Key for getServerParam() - returns max tag length */
|
|
693
|
+
static readonly MAX_TAG_LENGTH: string;
|
|
694
|
+
/** Key for getServerParam() - returns message delete age limit */
|
|
695
|
+
static readonly MSG_DELETE_AGE: string;
|
|
696
|
+
static readonly TAG_ALIAS: string;
|
|
697
|
+
static readonly TAG_EMAIL: string;
|
|
698
|
+
static readonly TAG_PHONE: string;
|
|
699
|
+
static readonly URI_TOPIC_ID_PREFIX: string;
|
|
700
|
+
|
|
701
|
+
// Static methods
|
|
702
|
+
static setNetworkProviders(wsProvider: unknown, xhrProvider?: unknown): void;
|
|
703
|
+
static setDatabaseProvider(idbProvider: unknown): void;
|
|
704
|
+
/**
|
|
705
|
+
* Set a custom storage provider (e.g., SQLiteStorage for React Native).
|
|
706
|
+
* Must be called BEFORE creating Tinode instance with persist: true.
|
|
707
|
+
* @param storage - Storage implementation (DB, SQLiteStorage, or custom)
|
|
708
|
+
*/
|
|
709
|
+
static setStorageProvider(storage: Storage): void;
|
|
710
|
+
static getVersion(): string;
|
|
711
|
+
static getLibrary(): string;
|
|
712
|
+
static credential(meth: string | Credential, val?: string, params?: Record<string, unknown>, resp?: string): Credential[] | null;
|
|
713
|
+
static topicType(name: string): 'me' | 'fnd' | 'grp' | 'p2p' | 'sys' | undefined;
|
|
714
|
+
static isMeTopicName(name: string): boolean;
|
|
715
|
+
static isSelfTopicName(name: string): boolean;
|
|
716
|
+
static isGroupTopicName(name: string): boolean;
|
|
717
|
+
static isP2PTopicName(name: string): boolean;
|
|
718
|
+
static isCommTopicName(name: string): boolean;
|
|
719
|
+
static isNewGroupTopicName(name: string): boolean;
|
|
720
|
+
static isChannelTopicName(name: string): boolean;
|
|
721
|
+
static isNullValue(str: string): boolean;
|
|
722
|
+
static isServerAssignedSeq(seq: number): boolean;
|
|
723
|
+
static isValidTagValue(tag: string): boolean;
|
|
724
|
+
static tagSplit(tag: string): { prefix: string; value: string } | null;
|
|
725
|
+
static setUniqueTag(tags: string[], uniqueTag: string): string[];
|
|
726
|
+
static clearTagPrefix(tags: string[], prefix: string): string[];
|
|
727
|
+
static tagByPrefix(tags: string[], prefix: string): string | undefined;
|
|
728
|
+
|
|
729
|
+
// Callbacks
|
|
730
|
+
onWebsocketOpen: (() => void) | null;
|
|
731
|
+
onConnect: ((code: number, text: string, params: Record<string, unknown>) => void) | null;
|
|
732
|
+
onDisconnect: ((err: Error | null) => void) | null;
|
|
733
|
+
onLogin: ((code: number, text: string) => void) | null;
|
|
734
|
+
onCtrlMessage: ((ctrl: ControlMessage) => void) | null;
|
|
735
|
+
onDataMessage: ((data: ServerMessage) => void) | null;
|
|
736
|
+
onPresMessage: ((pres: PresenceMessage) => void) | null;
|
|
737
|
+
onMetaMessage: ((meta: MetaMessage) => void) | null;
|
|
738
|
+
onInfoMessage: ((info: unknown) => void) | null;
|
|
739
|
+
onMessage: ((packet: unknown) => void) | null;
|
|
740
|
+
onRawMessage: ((text: string) => void) | null;
|
|
741
|
+
onNetworkProbe: (() => void) | null;
|
|
742
|
+
onAutoreconnectIteration: ((timeout: number, promise: Promise<unknown> | null) => void) | null;
|
|
743
|
+
|
|
744
|
+
constructor(config: TinodeConfig, onComplete?: (err?: Error) => void);
|
|
745
|
+
|
|
746
|
+
// Connection
|
|
747
|
+
connect(host?: string): Promise<ControlMessage>;
|
|
748
|
+
disconnect(): void;
|
|
749
|
+
reconnect(force?: boolean): void;
|
|
750
|
+
isConnected(): boolean;
|
|
751
|
+
networkProbe(): void;
|
|
752
|
+
|
|
753
|
+
// Authentication
|
|
754
|
+
login(scheme: string, secret: string | Uint8Array, cred?: Credential[]): Promise<ControlMessage>;
|
|
755
|
+
loginBasic(username: string, password: string, cred?: Credential[]): Promise<ControlMessage>;
|
|
756
|
+
loginToken(token: string, cred?: Credential[]): Promise<ControlMessage>;
|
|
757
|
+
account(uid: string | null, scheme: string, secret: string | Uint8Array, login?: boolean, params?: AccountParams): Promise<ControlMessage>;
|
|
758
|
+
createAccount(scheme: string, secret: string | Uint8Array, login: boolean, params?: AccountParams): Promise<ControlMessage>;
|
|
759
|
+
createAccountBasic(username: string, password: string, params?: AccountParams): Promise<ControlMessage>;
|
|
760
|
+
updateAccountBasic(uid: string, username: string, password: string, params?: AccountParams): Promise<ControlMessage>;
|
|
761
|
+
requestResetAuthSecret(scheme: string, method: string, value: string): Promise<ControlMessage>;
|
|
762
|
+
|
|
763
|
+
isAuthenticated(): boolean;
|
|
764
|
+
getAuthToken(): AuthToken | null;
|
|
765
|
+
setAuthToken(token: AuthToken): void;
|
|
766
|
+
getCurrentUserID(): string | undefined;
|
|
767
|
+
getCurrentLogin(): string | undefined;
|
|
768
|
+
isMe(uid: string): boolean;
|
|
769
|
+
getNextUniqueId(): string | undefined;
|
|
770
|
+
|
|
771
|
+
// Topic management
|
|
772
|
+
getTopic(topicName: string): Topic | undefined;
|
|
773
|
+
getMeTopic(): TopicMe;
|
|
774
|
+
getFndTopic(): TopicFnd;
|
|
775
|
+
newGroupTopicName(isChan?: boolean): string;
|
|
776
|
+
cacheGetTopic(topicName: string): Topic | undefined;
|
|
777
|
+
cacheRemTopic(topicName: string): void;
|
|
778
|
+
/** Iterate over cached topics. Return true from callback to stop enumeration. */
|
|
779
|
+
mapTopics(func: (topic: Topic, key: string) => boolean | void, context?: unknown): void;
|
|
780
|
+
isTopicCached(topicName: string): boolean;
|
|
781
|
+
isTopicOnline(name: string): boolean;
|
|
782
|
+
getTopicAccessMode(name: string): AccessMode | null;
|
|
783
|
+
|
|
784
|
+
// Subscription
|
|
785
|
+
subscribe(topicName: string, getParams?: GetQuery, setParams?: SetParams): Promise<ControlMessage>;
|
|
786
|
+
leave(topic: string, unsub?: boolean): Promise<ControlMessage>;
|
|
787
|
+
|
|
788
|
+
// Messaging
|
|
789
|
+
publish(topicName: string, content: string | DraftyDocument, noEcho?: boolean): Promise<ControlMessage>;
|
|
790
|
+
publishMessage(pub: unknown, attachments?: unknown[]): Promise<ControlMessage>;
|
|
791
|
+
createMessage(topic: string, content: string | DraftyDocument, noEcho?: boolean): unknown;
|
|
792
|
+
getMeta(topic: string, params: GetQuery): Promise<ControlMessage>;
|
|
793
|
+
setMeta(topic: string, params: SetParams): Promise<ControlMessage>;
|
|
794
|
+
delMessages(topic: string, ranges: DelRange[], hard?: boolean): Promise<ControlMessage>;
|
|
795
|
+
note(topicName: string, what: 'recv' | 'read', seq: number): void;
|
|
796
|
+
noteKeyPress(topicName: string, type?: string): void;
|
|
797
|
+
videoCall(topicName: string, seq: number, evt: string, payload?: unknown): Promise<ControlMessage>;
|
|
798
|
+
|
|
799
|
+
// Topic deletion
|
|
800
|
+
delTopic(topicName: string, hard?: boolean): Promise<ControlMessage>;
|
|
801
|
+
delSubscription(topicName: string, user: string): Promise<ControlMessage>;
|
|
802
|
+
delCredential(method: string, value: string): Promise<ControlMessage>;
|
|
803
|
+
delCurrentUser(hard?: boolean): Promise<ControlMessage>;
|
|
804
|
+
|
|
805
|
+
// Server info
|
|
806
|
+
hello(): Promise<ControlMessage>;
|
|
807
|
+
getServerInfo(): ServerInfo | null;
|
|
808
|
+
getServerParam(name: string, defaultValue?: unknown): unknown;
|
|
809
|
+
authorizeURL(url: string): string;
|
|
810
|
+
report(action: string, target: string): Promise<ControlMessage>;
|
|
811
|
+
|
|
812
|
+
// Push notifications
|
|
813
|
+
oobNotification(data: unknown): void;
|
|
814
|
+
/** Set or clear device token. Pass falsy value (null/undefined/false) to clear. */
|
|
815
|
+
setDeviceToken(dt: string | null | undefined | false): boolean;
|
|
816
|
+
|
|
817
|
+
// Utilities
|
|
818
|
+
enableLogging(enabled: boolean, trimLongStrings?: boolean): void;
|
|
819
|
+
setHumanLanguage(hl: string): void;
|
|
820
|
+
getLargeFileHelper(): LargeFileHelper;
|
|
821
|
+
initStorage(): Promise<void>;
|
|
822
|
+
clearStorage(): Promise<void>;
|
|
823
|
+
logger(str: string, ...args: unknown[]): void;
|
|
824
|
+
|
|
825
|
+
/** @deprecated Control whether to send acknowledgments */
|
|
826
|
+
wantAkn(status: boolean): void;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
export interface AccountParams {
|
|
830
|
+
fn?: string;
|
|
831
|
+
photo?: string | { type: string; data: string };
|
|
832
|
+
private?: Record<string, unknown>;
|
|
833
|
+
tags?: string[];
|
|
834
|
+
cred?: Credential[];
|
|
835
|
+
token?: string;
|
|
836
|
+
attachments?: string[];
|
|
837
|
+
/** Temporary authentication scheme for password reset */
|
|
838
|
+
scheme?: string;
|
|
839
|
+
/** Temporary authentication secret for password reset */
|
|
840
|
+
secret?: string;
|
|
841
|
+
desc?: {
|
|
842
|
+
defacs?: DefAcs;
|
|
843
|
+
public?: Record<string, unknown>;
|
|
844
|
+
private?: Record<string, unknown>;
|
|
845
|
+
trusted?: Record<string, unknown>;
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export interface ServerInfo {
|
|
850
|
+
ver: string;
|
|
851
|
+
build: string;
|
|
852
|
+
sid?: string;
|
|
853
|
+
maxFileUploadSize?: number;
|
|
854
|
+
maxMessageSize?: number;
|
|
855
|
+
maxSubscriberCount?: number;
|
|
856
|
+
maxTagCount?: number;
|
|
857
|
+
maxTagLength?: number;
|
|
858
|
+
minTagLength?: number;
|
|
859
|
+
/** Required credential methods */
|
|
860
|
+
reqCred?: {
|
|
861
|
+
auth?: string[];
|
|
862
|
+
anonauthSet?: string[];
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// ==========================================================================
|
|
867
|
+
// Database/Storage Types
|
|
868
|
+
// ==========================================================================
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Query parameters for reading messages or deletion logs.
|
|
872
|
+
*/
|
|
873
|
+
export interface GetDataType {
|
|
874
|
+
/** Return messages with seq >= since */
|
|
875
|
+
since?: number;
|
|
876
|
+
/** Return messages with seq < before */
|
|
877
|
+
before?: number;
|
|
878
|
+
/** Maximum number of messages to return */
|
|
879
|
+
limit?: number;
|
|
880
|
+
/** Specific ranges to fetch (alternative to since/before) */
|
|
881
|
+
ranges?: IdRange[];
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Message ID range used in deletion logs and queries.
|
|
886
|
+
*/
|
|
887
|
+
export interface IdRange {
|
|
888
|
+
/** Lower boundary (inclusive) */
|
|
889
|
+
low: number;
|
|
890
|
+
/** Upper boundary (exclusive). If omitted, represents single message at low */
|
|
891
|
+
hi?: number;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* Cached user data structure.
|
|
896
|
+
*/
|
|
897
|
+
export interface CachedUser {
|
|
898
|
+
uid: string;
|
|
899
|
+
public: Record<string, unknown>;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Deletion log entry structure.
|
|
904
|
+
*/
|
|
905
|
+
export interface DelLogEntry {
|
|
906
|
+
topic: string;
|
|
907
|
+
/** Deletion transaction ID (clear value) */
|
|
908
|
+
clear: number;
|
|
909
|
+
/** Lower boundary of deleted range */
|
|
910
|
+
low: number;
|
|
911
|
+
/** Upper boundary of deleted range */
|
|
912
|
+
hi: number;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Serialized message for storage.
|
|
917
|
+
*/
|
|
918
|
+
export interface StoredMessage {
|
|
919
|
+
topic: string;
|
|
920
|
+
seq: number;
|
|
921
|
+
ts?: string;
|
|
922
|
+
from?: string;
|
|
923
|
+
head?: Record<string, unknown>;
|
|
924
|
+
content?: unknown;
|
|
925
|
+
_status?: number;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Serialized topic for storage.
|
|
930
|
+
*/
|
|
931
|
+
export interface StoredTopic {
|
|
932
|
+
name: string;
|
|
933
|
+
created?: string;
|
|
934
|
+
updated?: string;
|
|
935
|
+
deleted?: string;
|
|
936
|
+
touched?: string;
|
|
937
|
+
read?: number;
|
|
938
|
+
recv?: number;
|
|
939
|
+
seq?: number;
|
|
940
|
+
clear?: number;
|
|
941
|
+
defacs?: DefAcs;
|
|
942
|
+
creds?: Credential[];
|
|
943
|
+
public?: Record<string, unknown>;
|
|
944
|
+
trusted?: Record<string, unknown>;
|
|
945
|
+
private?: Record<string, unknown>;
|
|
946
|
+
_aux?: Record<string, unknown>;
|
|
947
|
+
_deleted?: boolean;
|
|
948
|
+
tags?: string[];
|
|
949
|
+
acs?: { given?: string; want?: string; mode?: string };
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Serialized subscription for storage.
|
|
954
|
+
*/
|
|
955
|
+
export interface StoredSubscription {
|
|
956
|
+
topic: string;
|
|
957
|
+
uid: string;
|
|
958
|
+
updated?: string;
|
|
959
|
+
mode?: string;
|
|
960
|
+
read?: number;
|
|
961
|
+
recv?: number;
|
|
962
|
+
clear?: number;
|
|
963
|
+
lastSeen?: { when?: string; ua?: string };
|
|
964
|
+
userAgent?: string;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Storage interface - exactly matches the DB class API.
|
|
969
|
+
* Implementations: DB (IndexedDB, default), SQLiteStorage (React Native)
|
|
970
|
+
*/
|
|
971
|
+
export interface Storage {
|
|
972
|
+
// Database lifecycle
|
|
973
|
+
/**
|
|
974
|
+
* Initialize persistent cache: open or create/upgrade if needed.
|
|
975
|
+
* @returns Promise resolved/rejected when the DB is initialized.
|
|
976
|
+
*/
|
|
977
|
+
initDatabase(): Promise<IDBDatabase | unknown>;
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Delete persistent cache.
|
|
981
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
982
|
+
*/
|
|
983
|
+
deleteDatabase(): Promise<boolean>;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Check if persistent cache is ready for use.
|
|
987
|
+
* @returns true if cache is ready, false otherwise.
|
|
988
|
+
*/
|
|
989
|
+
isReady(): boolean;
|
|
990
|
+
|
|
991
|
+
// Topics
|
|
992
|
+
/**
|
|
993
|
+
* Save to cache or update topic in persistent cache.
|
|
994
|
+
* @param topic - topic to be added or updated.
|
|
995
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
996
|
+
*/
|
|
997
|
+
updTopic(topic: Topic | StoredTopic): Promise<void>;
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Mark or unmark topic as deleted.
|
|
1001
|
+
* @param name - name of the topic to mark or unmark.
|
|
1002
|
+
* @param deleted - status
|
|
1003
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1004
|
+
*/
|
|
1005
|
+
markTopicAsDeleted(name: string, deleted: boolean): Promise<void>;
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Remove topic from persistent cache.
|
|
1009
|
+
* @param name - name of the topic to remove from database.
|
|
1010
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1011
|
+
*/
|
|
1012
|
+
remTopic(name: string): Promise<void>;
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Execute a callback for each stored topic.
|
|
1016
|
+
* @param callback - function to call for each topic.
|
|
1017
|
+
* @param context - the value of 'this' inside the callback.
|
|
1018
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1019
|
+
*/
|
|
1020
|
+
mapTopics(callback?: (topic: StoredTopic) => void, context?: unknown): Promise<StoredTopic[]>;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Copy data from serialized object to topic.
|
|
1024
|
+
* @param topic - target to deserialize to.
|
|
1025
|
+
* @param src - serialized data to copy from.
|
|
1026
|
+
*/
|
|
1027
|
+
deserializeTopic(topic: Topic, src: StoredTopic): void;
|
|
1028
|
+
|
|
1029
|
+
// Users
|
|
1030
|
+
/**
|
|
1031
|
+
* Add or update user object in the persistent cache.
|
|
1032
|
+
* @param uid - ID of the user to save or update.
|
|
1033
|
+
* @param pub - user's public information.
|
|
1034
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1035
|
+
*/
|
|
1036
|
+
updUser(uid: string, pub: Record<string, unknown>): Promise<void>;
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Remove user from persistent cache.
|
|
1040
|
+
* @param uid - ID of the user to remove from the cache.
|
|
1041
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1042
|
+
*/
|
|
1043
|
+
remUser(uid: string): Promise<void>;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Execute a callback for each stored user.
|
|
1047
|
+
* @param callback - function to call for each user.
|
|
1048
|
+
* @param context - the value of 'this' inside the callback.
|
|
1049
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1050
|
+
*/
|
|
1051
|
+
mapUsers(callback?: (user: CachedUser) => void, context?: unknown): Promise<CachedUser[]>;
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Read a single user from persistent cache.
|
|
1055
|
+
* @param uid - ID of the user to fetch from cache.
|
|
1056
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1057
|
+
*/
|
|
1058
|
+
getUser(uid: string): Promise<CachedUser | undefined>;
|
|
1059
|
+
|
|
1060
|
+
// Subscriptions
|
|
1061
|
+
/**
|
|
1062
|
+
* Add or update subscription in persistent cache.
|
|
1063
|
+
* @param topicName - name of the topic which owns the subscription.
|
|
1064
|
+
* @param uid - ID of the subscribed user.
|
|
1065
|
+
* @param sub - subscription to save.
|
|
1066
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1067
|
+
*/
|
|
1068
|
+
updSubscription(topicName: string, uid: string, sub: TopicSubscription | StoredSubscription): Promise<void>;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Execute a callback for each cached subscription in a given topic.
|
|
1072
|
+
* @param topicName - name of the topic which owns the subscriptions.
|
|
1073
|
+
* @param callback - function to call for each subscription.
|
|
1074
|
+
* @param context - the value of 'this' inside the callback.
|
|
1075
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1076
|
+
*/
|
|
1077
|
+
mapSubscriptions(topicName: string, callback?: (sub: StoredSubscription) => void, context?: unknown): Promise<StoredSubscription[]>;
|
|
1078
|
+
|
|
1079
|
+
// Messages
|
|
1080
|
+
/**
|
|
1081
|
+
* Save message to persistent cache.
|
|
1082
|
+
* @param msg - message to save.
|
|
1083
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1084
|
+
*/
|
|
1085
|
+
addMessage(msg: ServerMessage | StoredMessage): Promise<void>;
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* Update delivery status of a message stored in persistent cache.
|
|
1089
|
+
* @param topicName - name of the topic which owns the message.
|
|
1090
|
+
* @param seq - ID of the message to update.
|
|
1091
|
+
* @param status - new delivery status of the message.
|
|
1092
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1093
|
+
*/
|
|
1094
|
+
updMessageStatus(topicName: string, seq: number, status: number): Promise<void>;
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Remove one or more messages from persistent cache.
|
|
1098
|
+
* @param topicName - name of the topic which owns the message.
|
|
1099
|
+
* @param from - id of the message to remove or lower boundary when removing range (inclusive).
|
|
1100
|
+
* @param to - upper boundary (exclusive) when removing a range of messages.
|
|
1101
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1102
|
+
*/
|
|
1103
|
+
remMessages(topicName: string, from?: number, to?: number): Promise<void>;
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Retrieve messages from persistent store.
|
|
1107
|
+
* @param topicName - name of the topic to retrieve messages from.
|
|
1108
|
+
* @param query - parameters of the message range to retrieve.
|
|
1109
|
+
* @param callback - function to call for each retrieved message.
|
|
1110
|
+
* @param context - the value of 'this' inside the callback.
|
|
1111
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1112
|
+
*/
|
|
1113
|
+
readMessages(topicName: string, query: GetDataType, callback?: (msg: StoredMessage | StoredMessage[]) => void, context?: unknown): Promise<StoredMessage[]>;
|
|
1114
|
+
|
|
1115
|
+
// Deletion Log
|
|
1116
|
+
/**
|
|
1117
|
+
* Add records of deleted messages.
|
|
1118
|
+
* @param topicName - name of the topic which owns the message.
|
|
1119
|
+
* @param delId - id of the deletion transaction.
|
|
1120
|
+
* @param ranges - array of deleted message ranges.
|
|
1121
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1122
|
+
*/
|
|
1123
|
+
addDelLog(topicName: string, delId: number, ranges: IdRange[]): Promise<void>;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Retrieve deleted message records from persistent store.
|
|
1127
|
+
* @param topicName - name of the topic to retrieve records for.
|
|
1128
|
+
* @param query - parameters of the range to retrieve.
|
|
1129
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1130
|
+
*/
|
|
1131
|
+
readDelLog(topicName: string, query: GetDataType): Promise<IdRange[]>;
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Retrieve the latest 'clear' ID for the given topic.
|
|
1135
|
+
* @param topicName - name of the topic.
|
|
1136
|
+
* @returns Promise resolved/rejected on operation completion.
|
|
1137
|
+
*/
|
|
1138
|
+
maxDelId(topicName: string): Promise<DelLogEntry | undefined>;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* DB class - IndexedDB storage implementation (default).
|
|
1143
|
+
* This is the default storage backend used by Tinode on web platforms.
|
|
1144
|
+
*/
|
|
1145
|
+
export class DB implements Storage {
|
|
1146
|
+
/** Indicator that the cache is disabled */
|
|
1147
|
+
disabled: boolean;
|
|
1148
|
+
/** Instance of IndexDB */
|
|
1149
|
+
db: IDBDatabase | null;
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* Create a new DB instance.
|
|
1153
|
+
* @param onError - callback for database errors.
|
|
1154
|
+
* @param logger - logging function.
|
|
1155
|
+
*/
|
|
1156
|
+
constructor(onError?: (err: Error) => void, logger?: (component: string, event: string, ...args: unknown[]) => void);
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* To use DB in a non-browser context, supply indexedDB provider.
|
|
1160
|
+
* @param idbProvider - indexedDB provider, e.g. for node: require('fake-indexeddb')
|
|
1161
|
+
*/
|
|
1162
|
+
static setDatabaseProvider(idbProvider: IDBFactory): void;
|
|
1163
|
+
|
|
1164
|
+
// Storage interface implementation
|
|
1165
|
+
initDatabase(): Promise<IDBDatabase>;
|
|
1166
|
+
deleteDatabase(): Promise<boolean>;
|
|
1167
|
+
isReady(): boolean;
|
|
1168
|
+
updTopic(topic: Topic | StoredTopic): Promise<void>;
|
|
1169
|
+
markTopicAsDeleted(name: string, deleted: boolean): Promise<void>;
|
|
1170
|
+
remTopic(name: string): Promise<void>;
|
|
1171
|
+
mapTopics(callback?: (topic: StoredTopic) => void, context?: unknown): Promise<StoredTopic[]>;
|
|
1172
|
+
deserializeTopic(topic: Topic, src: StoredTopic): void;
|
|
1173
|
+
updUser(uid: string, pub: Record<string, unknown>): Promise<void>;
|
|
1174
|
+
remUser(uid: string): Promise<void>;
|
|
1175
|
+
mapUsers(callback?: (user: CachedUser) => void, context?: unknown): Promise<CachedUser[]>;
|
|
1176
|
+
getUser(uid: string): Promise<CachedUser | undefined>;
|
|
1177
|
+
updSubscription(topicName: string, uid: string, sub: TopicSubscription | StoredSubscription): Promise<void>;
|
|
1178
|
+
mapSubscriptions(topicName: string, callback?: (sub: StoredSubscription) => void, context?: unknown): Promise<StoredSubscription[]>;
|
|
1179
|
+
addMessage(msg: ServerMessage | StoredMessage): Promise<void>;
|
|
1180
|
+
updMessageStatus(topicName: string, seq: number, status: number): Promise<void>;
|
|
1181
|
+
remMessages(topicName: string, from?: number, to?: number): Promise<void>;
|
|
1182
|
+
readMessages(topicName: string, query: GetDataType, callback?: (msg: StoredMessage | StoredMessage[]) => void, context?: unknown): Promise<StoredMessage[]>;
|
|
1183
|
+
addDelLog(topicName: string, delId: number, ranges: IdRange[]): Promise<void>;
|
|
1184
|
+
readDelLog(topicName: string, query: GetDataType): Promise<IdRange[]>;
|
|
1185
|
+
maxDelId(topicName: string): Promise<DelLogEntry | undefined>;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* SQLite storage implementation for React Native.
|
|
1190
|
+
* Drop-in replacement for DB class using expo-sqlite for true persistence.
|
|
1191
|
+
*/
|
|
1192
|
+
export class SQLiteStorage implements Storage {
|
|
1193
|
+
/**
|
|
1194
|
+
* Create a new SQLiteStorage instance.
|
|
1195
|
+
* @param dbName - database file name (default: 'tinode.db').
|
|
1196
|
+
* @param onError - callback for database errors.
|
|
1197
|
+
* @param logger - logging function.
|
|
1198
|
+
*/
|
|
1199
|
+
constructor(dbName?: string, onError?: (err: Error) => void, logger?: (component: string, event: string, ...args: unknown[]) => void);
|
|
1200
|
+
|
|
1201
|
+
// Storage interface implementation
|
|
1202
|
+
initDatabase(): Promise<unknown>;
|
|
1203
|
+
deleteDatabase(): Promise<boolean>;
|
|
1204
|
+
isReady(): boolean;
|
|
1205
|
+
updTopic(topic: Topic | StoredTopic): Promise<void>;
|
|
1206
|
+
markTopicAsDeleted(name: string, deleted: boolean): Promise<void>;
|
|
1207
|
+
remTopic(name: string): Promise<void>;
|
|
1208
|
+
mapTopics(callback?: (topic: StoredTopic) => void, context?: unknown): Promise<StoredTopic[]>;
|
|
1209
|
+
deserializeTopic(topic: Topic, src: StoredTopic): void;
|
|
1210
|
+
updUser(uid: string, pub: Record<string, unknown>): Promise<void>;
|
|
1211
|
+
remUser(uid: string): Promise<void>;
|
|
1212
|
+
mapUsers(callback?: (user: CachedUser) => void, context?: unknown): Promise<CachedUser[]>;
|
|
1213
|
+
getUser(uid: string): Promise<CachedUser | undefined>;
|
|
1214
|
+
updSubscription(topicName: string, uid: string, sub: TopicSubscription | StoredSubscription): Promise<void>;
|
|
1215
|
+
mapSubscriptions(topicName: string, callback?: (sub: StoredSubscription) => void, context?: unknown): Promise<StoredSubscription[]>;
|
|
1216
|
+
addMessage(msg: ServerMessage | StoredMessage): Promise<void>;
|
|
1217
|
+
updMessageStatus(topicName: string, seq: number, status: number): Promise<void>;
|
|
1218
|
+
remMessages(topicName: string, from?: number, to?: number): Promise<void>;
|
|
1219
|
+
readMessages(topicName: string, query: GetDataType, callback?: (msg: StoredMessage | StoredMessage[]) => void, context?: unknown): Promise<StoredMessage[]>;
|
|
1220
|
+
addDelLog(topicName: string, delId: number, ranges: IdRange[]): Promise<void>;
|
|
1221
|
+
readDelLog(topicName: string, query: GetDataType): Promise<IdRange[]>;
|
|
1222
|
+
maxDelId(topicName: string): Promise<DelLogEntry | undefined>;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// Also export as default for backwards compatibility
|
|
1226
|
+
export default Tinode;
|
|
1227
|
+
}
|