@talkjs/core 0.0.4 → 0.0.5
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/package.json +4 -2
- package/dist/talkSession.cjs +0 -2
- package/dist/talkSession.d.ts +0 -2254
- package/dist/talkSession.js +0 -3189
package/dist/talkSession.d.ts
DELETED
|
@@ -1,2254 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A node in a {@link TextBlock} that renders its children as a clickable {@link https://talkjs.com/docs/Features/Customizations/Action_Buttons_Links/ | action button} which triggers a custom action.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* By default, users do not have permission to send messages containing action buttons as they can be used maliciously to trick others into invoking custom actions.
|
|
6
|
-
* For example, a user could send an "accept offer" action button, but disguise it as "view offer".
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare interface ActionButtonNode {
|
|
11
|
-
type: "actionButton";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The name of the custom action to invoke when the button is clicked.
|
|
15
|
-
*/
|
|
16
|
-
action: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The parameters to pass to the custom action when the button is clicked.
|
|
20
|
-
*/
|
|
21
|
-
params: Record<string, string>;
|
|
22
|
-
|
|
23
|
-
children: TextNode[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A node in a {@link TextBlock} that renders its children as a clickable {@link https://talkjs.com/docs/Features/Customizations/Action_Buttons_Links/ | action link} which triggers a custom action.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* By default, users do not have permission to send messages containing `ActionLinkNode` as it can be used maliciously to trick others into invoking custom actions.
|
|
31
|
-
* For example, a user could send an "accept offer" action link, but disguise it as a link to a website.
|
|
32
|
-
*
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
export declare interface ActionLinkNode {
|
|
36
|
-
type: "actionLink";
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The name of the custom action to invoke when the link is clicked.
|
|
40
|
-
*/
|
|
41
|
-
action: string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The parameters to pass to the custom action when the link is clicked.
|
|
45
|
-
*/
|
|
46
|
-
params: Record<string, string>;
|
|
47
|
-
|
|
48
|
-
children: TextNode[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* A FileBlock variant for an audio attachment, with additional audio-specific metadata.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* You can identify this variant by checking for `subtype: "audio"`.
|
|
56
|
-
*
|
|
57
|
-
* The same file could be uploaded as either an audio block, or as a {@link VoiceBlock}.
|
|
58
|
-
* The same data will be available either way, but they will be rendered differently in the UI.
|
|
59
|
-
*
|
|
60
|
-
* Includes metadata about the duration of the audio file in seconds, where available.
|
|
61
|
-
*
|
|
62
|
-
* Audio files that you upload with the TalkJS UI will include the duration as long as the sender's browser can preview the file.
|
|
63
|
-
* Audio files that you upload with the REST API or {@link Session.uploadAudio} will include the duration if you specified it when uploading.
|
|
64
|
-
* Audio files attached in a reply to an email notification will not include the duration.
|
|
65
|
-
*
|
|
66
|
-
* @public
|
|
67
|
-
*/
|
|
68
|
-
export declare interface AudioBlock {
|
|
69
|
-
type: "file";
|
|
70
|
-
|
|
71
|
-
subtype: "audio";
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* An encoded identifier for this file. Use in {@link SendFileBlock} to send this file in another message.
|
|
75
|
-
*/
|
|
76
|
-
fileToken: FileToken;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The URL where you can fetch the file
|
|
80
|
-
*/
|
|
81
|
-
url: string;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The size of the file in bytes
|
|
85
|
-
*/
|
|
86
|
-
size: number;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The name of the audio file, including file extension
|
|
90
|
-
*/
|
|
91
|
-
filename: string;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* The duration of the audio in seconds, if known
|
|
95
|
-
*/
|
|
96
|
-
duration?: number;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
declare interface AudioFileMetadata {
|
|
100
|
-
/**
|
|
101
|
-
* The name of the file including extension.
|
|
102
|
-
*/
|
|
103
|
-
filename: string;
|
|
104
|
-
/**
|
|
105
|
-
* The duration of the audio file in seconds, if known.
|
|
106
|
-
*/
|
|
107
|
-
duration?: number;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* A node in a {@link TextBlock} that renders `text` as a link (HTML `<a>`).
|
|
112
|
-
*
|
|
113
|
-
* @remarks
|
|
114
|
-
* Used when user-typed text is turned into a link automatically.
|
|
115
|
-
*
|
|
116
|
-
* Unlike {@link LinkNode}, users do have permission to send AutoLinkNodes by default, because the `text` and `url` properties must match.
|
|
117
|
-
* Specifically:
|
|
118
|
-
*
|
|
119
|
-
* - If `text` is an email, `url` must contain a `mailto:` link to the same email address
|
|
120
|
-
*
|
|
121
|
-
* - If `text` is a phone number, `url` must contain a `tel:` link to the same phone number
|
|
122
|
-
*
|
|
123
|
-
* - If `text` is a website, the domain name including subdomains must be the same in both `text` and `url`.
|
|
124
|
-
* If `text` includes a protocol (such as `https`), path (/page), query string (?page=true), or url fragment (#title), they must be the same in `url`.
|
|
125
|
-
* If `text` does not specify a protocol, `url` must use either `https` or `http`.
|
|
126
|
-
*
|
|
127
|
-
* This means that the following AutoLink is valid:
|
|
128
|
-
*
|
|
129
|
-
* ```
|
|
130
|
-
* {
|
|
131
|
-
* type: "autoLink",
|
|
132
|
-
* text: "talkjs.com"
|
|
133
|
-
* url: "https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#AutoLinkNode"
|
|
134
|
-
* }
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* That link will appear as `talkjs.com` and link you to the specific section of the documentation that explains how AutoLinkNodes work.
|
|
138
|
-
*
|
|
139
|
-
* These rules ensure that the user knows what link they are clicking, and prevents AutoLinkNode being used for phishing.
|
|
140
|
-
* If you try to send a message containing an AutoLink that breaks these rules, the request will be rejected.
|
|
141
|
-
*
|
|
142
|
-
* @public
|
|
143
|
-
*/
|
|
144
|
-
export declare interface AutoLinkNode {
|
|
145
|
-
type: "autoLink";
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* The URL to open when a user clicks this node.
|
|
149
|
-
*/
|
|
150
|
-
url: string;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* The text to display in the link.
|
|
154
|
-
*/
|
|
155
|
-
text: string;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* A node in a {@link TextBlock} that adds indentation for a bullet-point list around its children (HTML `<ul>`).
|
|
160
|
-
*
|
|
161
|
-
* @remarks
|
|
162
|
-
* Used when users send a bullet-point list by starting lines of their message with `-` or `*`.
|
|
163
|
-
*
|
|
164
|
-
* @public
|
|
165
|
-
*/
|
|
166
|
-
export declare interface BulletListNode {
|
|
167
|
-
type: "bulletList";
|
|
168
|
-
children: TextNode[];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* A node in a {@link TextBlock} that renders its children with a bullet-point (HTML `<li>`).
|
|
173
|
-
*
|
|
174
|
-
* @remarks
|
|
175
|
-
* Used when users start a line of their message with `-` or `*`.
|
|
176
|
-
*
|
|
177
|
-
* @public
|
|
178
|
-
*/
|
|
179
|
-
export declare interface BulletPointNode {
|
|
180
|
-
type: "bulletPoint";
|
|
181
|
-
children: TextNode[];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* A node in a {@link TextBlock} that renders `text` in an inline code span (HTML `<code>`).
|
|
186
|
-
*
|
|
187
|
-
* @remarks
|
|
188
|
-
* Used when a user types ```text```.
|
|
189
|
-
*
|
|
190
|
-
* @public
|
|
191
|
-
*/
|
|
192
|
-
export declare interface CodeSpanNode {
|
|
193
|
-
type: "codeSpan";
|
|
194
|
-
text: string;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* The content of a message is structured as a list of content blocks.
|
|
199
|
-
*
|
|
200
|
-
* @remarks
|
|
201
|
-
* Currently, each message can only have one content block, but this will change in the future.
|
|
202
|
-
* This will not be considered a breaking change, so your code should assume there can be multiple content blocks.
|
|
203
|
-
*
|
|
204
|
-
* These blocks are rendered in order, top-to-bottom.
|
|
205
|
-
*
|
|
206
|
-
* Currently the available Content Block types are:
|
|
207
|
-
*
|
|
208
|
-
* - `type: "text"` ({@link TextBlock})
|
|
209
|
-
*
|
|
210
|
-
* - `type: "file"` ({@link FileBlock})
|
|
211
|
-
*
|
|
212
|
-
* - `type: "location"` ({@link LocationBlock})
|
|
213
|
-
*
|
|
214
|
-
* @public
|
|
215
|
-
*/
|
|
216
|
-
export declare type ContentBlock = TextBlock | FileBlock | LocationBlock;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* The state of a conversation subscription when it is actively listening for changes
|
|
220
|
-
*
|
|
221
|
-
* @public
|
|
222
|
-
*/
|
|
223
|
-
export declare interface ConversationActiveState {
|
|
224
|
-
type: "active";
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* The most recently received snapshot for the conversation, or `null` if you are not a participant in the conversation (including when the conversation does not exist).
|
|
228
|
-
*/
|
|
229
|
-
latestSnapshot: ConversationSnapshot | null;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* References the conversation with a given conversation ID, from the perspective of the current user.
|
|
234
|
-
*
|
|
235
|
-
* @remarks
|
|
236
|
-
* Used in all Realtime API operations affecting that conversation, such as fetching or updating conversation attributes.
|
|
237
|
-
* Created via {@link Session.conversation}.
|
|
238
|
-
*
|
|
239
|
-
* @public
|
|
240
|
-
*/
|
|
241
|
-
export declare interface ConversationRef {
|
|
242
|
-
/**
|
|
243
|
-
* The ID of the referenced conversation.
|
|
244
|
-
*
|
|
245
|
-
* @remarks
|
|
246
|
-
* Immutable: if you want to reference a different conversation, get a new ConversationRef instead.
|
|
247
|
-
*/
|
|
248
|
-
readonly id: string;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Get a reference to a participant in this conversation
|
|
252
|
-
*
|
|
253
|
-
* @param user - the user's ID or a reference to the user
|
|
254
|
-
*/
|
|
255
|
-
participant(user: string | UserRef): ParticipantRef;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Get a reference to a message in this conversation
|
|
259
|
-
*
|
|
260
|
-
* @param user - the message ID
|
|
261
|
-
*/
|
|
262
|
-
message(id: string): MessageRef;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Fetches a snapshot of the conversation.
|
|
266
|
-
*
|
|
267
|
-
* @remarks
|
|
268
|
-
* This contains all of the information related to the conversation and the current user's participation in the conversation.
|
|
269
|
-
*
|
|
270
|
-
* @returns A snapshot of the current user's view of the conversation, or null if the current user is not a participant (including if the conversation doesn't exist).
|
|
271
|
-
*/
|
|
272
|
-
get(): Promise<ConversationSnapshot | null>;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Sets properties of this conversation and your participation in it.
|
|
276
|
-
*
|
|
277
|
-
* @remarks
|
|
278
|
-
* The conversation is created if a conversation with this ID doesn't already exist.
|
|
279
|
-
* You are added as a participant if you are not already a participant in the conversation.
|
|
280
|
-
*
|
|
281
|
-
* @returns A promise that resolves when the operation completes.
|
|
282
|
-
* When client-side conversation syncing is disabled, you may only set your `notify` property, when you are already a participant.
|
|
283
|
-
* Everything else requires client-side conversation syncing to be enabled, and will cause the promise to reject.
|
|
284
|
-
*/
|
|
285
|
-
set(params: SetConversationParams): Promise<void>;
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Creates this conversation if it does not already exist.
|
|
289
|
-
* Adds you as a participant in this conversation, if you are not already a participant.
|
|
290
|
-
*
|
|
291
|
-
* @remarks
|
|
292
|
-
* If the conversation already exists or you are already a participant, this operation is still considered successful and the promise will still resolve.
|
|
293
|
-
*
|
|
294
|
-
* @returns A promise that resolves when the operation completes. The promise rejects if you are not already a participant and client-side conversation syncing is disabled.
|
|
295
|
-
*/
|
|
296
|
-
createIfNotExists(params?: CreateConversationParams): Promise<void>;
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Marks the conversation as read.
|
|
300
|
-
*
|
|
301
|
-
* @returns A promise that resolves when the operation completes. The promise rejects if you are not a participant in the conversation.
|
|
302
|
-
*/
|
|
303
|
-
markAsRead(): Promise<void>;
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Marks the conversation as unread.
|
|
307
|
-
*
|
|
308
|
-
* @returns A promise that resolves when the operation completes. The promise rejects if you are not a participant in the conversation.
|
|
309
|
-
*/
|
|
310
|
-
markAsUnread(): Promise<void>;
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Sends a message in the conversation
|
|
314
|
-
*
|
|
315
|
-
* @returns A promise that resolves with a reference to the newly created message. The promise will reject if you do not have permission to send the message.
|
|
316
|
-
*/
|
|
317
|
-
send(
|
|
318
|
-
params: string | SendTextMessageParams | SendMessageParams,
|
|
319
|
-
): Promise<MessageRef>;
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Subscribes to the messages in the conversation.
|
|
323
|
-
*
|
|
324
|
-
* @remarks
|
|
325
|
-
* Initially, you will be subscribed to the 30 most recent messages and any new messages.
|
|
326
|
-
* Call `loadMore` to load additional older messages.
|
|
327
|
-
*
|
|
328
|
-
* Whenever `Subscription.state.type` is "active" and a message is sent, edited, deleted, or you load more messages, `onSnapshot` will fire and `Subscription.state.latestSnapshot` will be updated.
|
|
329
|
-
* `loadedAll` is true when the snapshot contains all the messages in the conversation.
|
|
330
|
-
*
|
|
331
|
-
* The snapshot is null if you are not a participant in the conversation (including when the conversation doesn't exist)
|
|
332
|
-
*/
|
|
333
|
-
subscribeMessages(
|
|
334
|
-
onSnapshot?: (
|
|
335
|
-
snapshot: MessageSnapshot[] | null,
|
|
336
|
-
loadedAll: boolean,
|
|
337
|
-
) => void,
|
|
338
|
-
): MessageSubscription;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Subscribes to the conversation.
|
|
342
|
-
*
|
|
343
|
-
* @remarks
|
|
344
|
-
* Whenever `Subscription.state.type` is "active" and something about the conversation changes, `onSnapshot` will fire and `Subscription.state.latestSnapshot` will be updated.
|
|
345
|
-
* This includes changes to nested data. As an extreme example, `onSnapshot` would be called if `snapshot.lastMessage.referencedMessage.sender.name` changes.
|
|
346
|
-
*
|
|
347
|
-
* The snapshot is null if you are not a participant in the conversation (including when the conversation doesn't exist)
|
|
348
|
-
*/
|
|
349
|
-
subscribe(
|
|
350
|
-
onSnapshot?: (snapshot: ConversationSnapshot | null) => void,
|
|
351
|
-
): ConversationSubscription;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* A snapshot of a conversation's attributes at a given moment in time.
|
|
356
|
-
*
|
|
357
|
-
* @remarks
|
|
358
|
-
* Also includes information about the current user's view of that conversation, such as whether or not notifications are enabled.
|
|
359
|
-
*
|
|
360
|
-
* Snapshots are immutable and we try to reuse them when possible. You should only re-render your UI when `oldSnapshot !== newSnapshot`.
|
|
361
|
-
*
|
|
362
|
-
* @public
|
|
363
|
-
*/
|
|
364
|
-
export declare interface ConversationSnapshot {
|
|
365
|
-
/**
|
|
366
|
-
* The ID of the conversation
|
|
367
|
-
*/
|
|
368
|
-
id: string;
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Contains the conversation subject if it was set using {@link ConversationBuilder.subject}.
|
|
372
|
-
*/
|
|
373
|
-
subject: string | null;
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Contains the URL of a photo was set using {@link ConversationBuilder.subject}.
|
|
377
|
-
*/
|
|
378
|
-
photoUrl: string | null;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* One or more welcome messages that will display to the user as a SystemMessage
|
|
382
|
-
*/
|
|
383
|
-
welcomeMessages: string[];
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Custom metadata you have set on the conversation
|
|
387
|
-
*/
|
|
388
|
-
custom: Record<string, string>;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* The date that the conversation was created, as a unix timestamp in milliseconds.
|
|
392
|
-
*/
|
|
393
|
-
createdAt: number;
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* The date that the current user joined the conversation, as a unix timestamp in milliseconds.
|
|
397
|
-
*/
|
|
398
|
-
joinedAt: number;
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* The last message sent in this conversation, or null if no messages have been sent.
|
|
402
|
-
*/
|
|
403
|
-
lastMessage: MessageSnapshot | null;
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* The number of messages in this conversation that the current user hasn't read.
|
|
407
|
-
*/
|
|
408
|
-
unreadMessageCount: number;
|
|
409
|
-
|
|
410
|
-
// TODO-STEVEN everyoneReadUntil
|
|
411
|
-
// TODO-STEVEN readUntil
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Whether the conversation should be considered unread.
|
|
415
|
-
*
|
|
416
|
-
* @remarks
|
|
417
|
-
* This can be true even when `unreadMessageCount` is zero, if the user has manually marked the conversation as unread.
|
|
418
|
-
*/
|
|
419
|
-
isUnread: boolean;
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* The current user's permission level in this conversation.
|
|
423
|
-
*/
|
|
424
|
-
access: "Read" | "ReadWrite";
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* The current user's notification settings for this conversation.
|
|
428
|
-
*
|
|
429
|
-
* @remarks
|
|
430
|
-
* `false` means no notifications, `true` means notifications for all messages, and `"MentionsOnly"` means that the user will only be notified when they are mentioned with an `@`.
|
|
431
|
-
*/
|
|
432
|
-
notify: boolean | "MentionsOnly";
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* A subscription to a specific conversation.
|
|
437
|
-
*
|
|
438
|
-
* @remarks
|
|
439
|
-
* Get a ConversationSubscription by calling {@link ConversationRef.subscribe}
|
|
440
|
-
*
|
|
441
|
-
* @public
|
|
442
|
-
*/
|
|
443
|
-
export declare interface ConversationSubscription {
|
|
444
|
-
/**
|
|
445
|
-
* The current state of the subscription
|
|
446
|
-
*
|
|
447
|
-
* @remarks
|
|
448
|
-
* An object with the following fields:
|
|
449
|
-
*
|
|
450
|
-
* `type` is one of "pending", "active", "unsubscribed", or "error".
|
|
451
|
-
*
|
|
452
|
-
* When `type` is "active", includes `latestSnapshot: ConversationSnapshot | null`, the current state of the conversation.
|
|
453
|
-
* `latestSnapshot` is `null` when you are not a participant or the conversation does not exist.
|
|
454
|
-
*
|
|
455
|
-
* When `type` is "error", includes the `error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
|
|
456
|
-
*/
|
|
457
|
-
state:
|
|
458
|
-
| PendingState
|
|
459
|
-
| ConversationActiveState
|
|
460
|
-
| UnsubscribedState
|
|
461
|
-
| ErrorState;
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Resolves when the subscription starts receiving updates from the server.
|
|
465
|
-
*/
|
|
466
|
-
connected: Promise<ConversationActiveState>;
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Resolves when the subscription permanently stops receiving updates from the server.
|
|
470
|
-
*
|
|
471
|
-
* @remarks
|
|
472
|
-
* This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
|
|
473
|
-
*/
|
|
474
|
-
terminated: Promise<UnsubscribedState | ErrorState>;
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Unsubscribe from this resource and stop receiving updates.
|
|
478
|
-
*
|
|
479
|
-
* @remarks
|
|
480
|
-
* If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
|
|
481
|
-
*/
|
|
482
|
-
unsubscribe(): void;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Parameters you can pass to {@link ConversationRef.createIfNotExists}.
|
|
487
|
-
*
|
|
488
|
-
* Properties that are `undefined` will be set to the default.
|
|
489
|
-
*
|
|
490
|
-
* @public
|
|
491
|
-
*/
|
|
492
|
-
export declare interface CreateConversationParams {
|
|
493
|
-
/**
|
|
494
|
-
* The conversation subject to display in the chat header.
|
|
495
|
-
* Default = no subject, list participant names instead.
|
|
496
|
-
*/
|
|
497
|
-
subject?: string;
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* The URL for the conversation photo to display in the chat header.
|
|
501
|
-
* Default = no photo, show a placeholder image.
|
|
502
|
-
*/
|
|
503
|
-
photoUrl?: string;
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* System messages which are sent at the beginning of a conversation.
|
|
507
|
-
* Default = no messages.
|
|
508
|
-
*/
|
|
509
|
-
welcomeMessages?: string[];
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Custom metadata you have set on the conversation.
|
|
513
|
-
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
514
|
-
* Default = no custom metadata
|
|
515
|
-
*/
|
|
516
|
-
custom?: Record<string, string>;
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Your access to the conversation.
|
|
520
|
-
* Default = "ReadWrite" access.
|
|
521
|
-
*/
|
|
522
|
-
access?: "Read" | "ReadWrite";
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Your notification settings.
|
|
526
|
-
* Default = `true`
|
|
527
|
-
*/
|
|
528
|
-
notify?: boolean | "MentionsOnly";
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Parameters you can pass to {@link ParticipantRef.createIfNotExists}.
|
|
533
|
-
*
|
|
534
|
-
* @remarks
|
|
535
|
-
* Properties that are `undefined` will be set to the default.
|
|
536
|
-
*
|
|
537
|
-
* @public
|
|
538
|
-
*/
|
|
539
|
-
export declare interface CreateParticipantParams {
|
|
540
|
-
/**
|
|
541
|
-
* The level of access the participant should have in the conversation.
|
|
542
|
-
* Default = "ReadWrite" access.
|
|
543
|
-
*/
|
|
544
|
-
access?: "ReadWrite" | "Read";
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* When the participant should be notified about new messages in this conversation.
|
|
548
|
-
* Default = `true`
|
|
549
|
-
*
|
|
550
|
-
* @remarks
|
|
551
|
-
* `false` means no notifications, `true` means notifications for all messages, and `"MentionsOnly"` means that the user will only be notified when they are mentioned with an `@`.
|
|
552
|
-
*/
|
|
553
|
-
notify?: boolean | "MentionsOnly";
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* Parameters you can pass to {@link UserRef.createIfNotExists}.
|
|
558
|
-
*
|
|
559
|
-
* @remarks
|
|
560
|
-
* Properties that are `undefined` will be set to the default.
|
|
561
|
-
*
|
|
562
|
-
* @public
|
|
563
|
-
*/
|
|
564
|
-
export declare interface CreateUserParams {
|
|
565
|
-
/**
|
|
566
|
-
* The user's name which is displayed on the TalkJS UI
|
|
567
|
-
*/
|
|
568
|
-
name: string;
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Custom metadata you have set on the user.
|
|
572
|
-
* Default = no custom metadata
|
|
573
|
-
*/
|
|
574
|
-
custom?: Record<string, string>;
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* An {@link https://www.w3.org/International/articles/language-tags/ | IETF language tag}.
|
|
578
|
-
* See the {@link https://talkjs.com/docs/Features/Language_Support/Localization.html | localization documentation}
|
|
579
|
-
* Default = the locale selected on the dashboard
|
|
580
|
-
*/
|
|
581
|
-
locale?: string;
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
* An optional URL to a photo that is displayed as the user's avatar.
|
|
585
|
-
* Default = no photo
|
|
586
|
-
*/
|
|
587
|
-
photoUrl?: string;
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* TalkJS supports multiple sets of settings, called "roles". These allow you to change the behavior of TalkJS for different users.
|
|
591
|
-
* You have full control over which user gets which configuration.
|
|
592
|
-
* Default = the `default` role
|
|
593
|
-
*/
|
|
594
|
-
role?: string;
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* The default message a person sees when starting a chat with this user.
|
|
598
|
-
* Default = no welcome message
|
|
599
|
-
*/
|
|
600
|
-
welcomeMessage?: string;
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* An array of email addresses associated with the user.
|
|
604
|
-
* Default = no email addresses
|
|
605
|
-
*/
|
|
606
|
-
email?: string[];
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* An array of phone numbers associated with the user.
|
|
610
|
-
* Default = no phone numbers
|
|
611
|
-
*/
|
|
612
|
-
phone?: string[];
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* An object of push registration tokens to use when notifying this user.
|
|
616
|
-
*
|
|
617
|
-
* Keys in the object have the format `'provider:token_id'`,
|
|
618
|
-
* where `provider` is either `"fcm"` for Android (Firebase Cloud Messaging),
|
|
619
|
-
* or `"apns"` for iOS (Apple Push Notification Service).
|
|
620
|
-
*
|
|
621
|
-
* Default = no push registration tokens
|
|
622
|
-
*/
|
|
623
|
-
pushTokens?: Record<string, true>;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* A node in a {@link TextBlock} that is used for {@link https://talkjs.com/docs/Features/Message_Features/Emoji_Reactions/#custom-emojis | custom emoji}.
|
|
628
|
-
*
|
|
629
|
-
* @public
|
|
630
|
-
*/
|
|
631
|
-
export declare interface CustomEmojiNode {
|
|
632
|
-
type: "customEmoji";
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* The name of the custom emoji to show.
|
|
636
|
-
*/
|
|
637
|
-
text: string;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Parameters you can pass to {@link MessageRef.edit}.
|
|
642
|
-
*
|
|
643
|
-
* @remarks
|
|
644
|
-
* Properties that are `undefined` will not be changed.
|
|
645
|
-
* To clear / reset a property to the default, pass `null`.
|
|
646
|
-
*
|
|
647
|
-
* This is the more advanced method for editing a message. It gives you full control over the message content.
|
|
648
|
-
* You can decide exactly how a text message should be formatted, edit an attachment, or even turn a text message into a location.
|
|
649
|
-
*
|
|
650
|
-
* @public
|
|
651
|
-
*/
|
|
652
|
-
export declare interface EditMessageParams {
|
|
653
|
-
/**
|
|
654
|
-
* Custom metadata you have set on the message.
|
|
655
|
-
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
656
|
-
* Default = no custom metadata
|
|
657
|
-
*/
|
|
658
|
-
custom?: Record<string, string | null> | null;
|
|
659
|
-
|
|
660
|
-
/**
|
|
661
|
-
* The new content for the message.
|
|
662
|
-
*
|
|
663
|
-
* @remarks
|
|
664
|
-
* Any value provided here will overwrite the existing message content.
|
|
665
|
-
*
|
|
666
|
-
* By default users do not have permission to send {@link LinkNode}, {@link ActionLinkNode}, or {@link ActionButtonNode}, as they can be used to trick the recipient.
|
|
667
|
-
*/
|
|
668
|
-
content?: [SendContentBlock];
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Parameters you can pass to {@link MessageRef.edit}.
|
|
673
|
-
*
|
|
674
|
-
* @remarks
|
|
675
|
-
* Properties that are `undefined` will not be changed.
|
|
676
|
-
* To clear / reset a property to the default, pass `null`.
|
|
677
|
-
*
|
|
678
|
-
* This is a simpler version of {@link EditMessageParams} that only supports setting the message content to text.
|
|
679
|
-
*
|
|
680
|
-
* @public
|
|
681
|
-
*/
|
|
682
|
-
export declare interface EditTextMessageParams {
|
|
683
|
-
/**
|
|
684
|
-
* Custom metadata you have set on the message.
|
|
685
|
-
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
686
|
-
* Default = no custom metadata
|
|
687
|
-
*/
|
|
688
|
-
custom?: Record<string, string | null> | null;
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* The new text to set in the message body.
|
|
692
|
-
*
|
|
693
|
-
* @remarks
|
|
694
|
-
* This is parsed the same way as the text entered in the message field. For example, `*hi*` will appear as `hi` in bold.
|
|
695
|
-
*
|
|
696
|
-
* See the {@link https://talkjs.com/docs/Features/Message_Features/Formatting/ | message formatting documentation} for more details.
|
|
697
|
-
*/
|
|
698
|
-
text?: string;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* The state of a subscription after it encounters an unrecoverable error
|
|
703
|
-
*
|
|
704
|
-
* @public
|
|
705
|
-
*/
|
|
706
|
-
export declare interface ErrorState {
|
|
707
|
-
type: "error";
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* The error that caused the subscription to be terminated
|
|
711
|
-
*/
|
|
712
|
-
error: Error;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* A file attachment received in a message's content.
|
|
717
|
-
*
|
|
718
|
-
* @remarks
|
|
719
|
-
* All `FileBlock` variants contain `url`, `size`, and `fileToken`.
|
|
720
|
-
* Some file blocks have additional metadata, in which case they will have the `subtype` property set.
|
|
721
|
-
*
|
|
722
|
-
* Currently the available FileBlock subtypes are:
|
|
723
|
-
*
|
|
724
|
-
* - No `subtype` set ({@link GenericFileBlock})
|
|
725
|
-
*
|
|
726
|
-
* - `subtype: "video"` ({@link VideoBlock})
|
|
727
|
-
*
|
|
728
|
-
* - `subtype: "image"` ({@link ImageBlock})
|
|
729
|
-
*
|
|
730
|
-
* - `subtype: "audio"` ({@link AudioBlock})
|
|
731
|
-
*
|
|
732
|
-
* - `subtype: "voice"` ({@link VoiceBlock})
|
|
733
|
-
*
|
|
734
|
-
* @public
|
|
735
|
-
*/
|
|
736
|
-
export declare type FileBlock =
|
|
737
|
-
| VideoBlock
|
|
738
|
-
| ImageBlock
|
|
739
|
-
| AudioBlock
|
|
740
|
-
| VoiceBlock
|
|
741
|
-
| GenericFileBlock;
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* A token representing a file uploaded to TalkJS.
|
|
745
|
-
*
|
|
746
|
-
* @remarks
|
|
747
|
-
* You cannot create a FileToken yourself. Get a file token by uploading your file to TalkJS with {@link Session.uploadFile}, or one of the subtype-specific variants like {@link Session.uploadImage}.
|
|
748
|
-
*
|
|
749
|
-
* For example:
|
|
750
|
-
*
|
|
751
|
-
* ```
|
|
752
|
-
* // From `<input type="file">`
|
|
753
|
-
* const file: File = fileInputElement.files[0];
|
|
754
|
-
* const myFileToken = await session.uploadFile(file, { filename: file.name });
|
|
755
|
-
* ```
|
|
756
|
-
*
|
|
757
|
-
* Alternatively, take a file token from an existing {@link FileBlock} to re-send an attachment you received, without having to download and re-upload the file.
|
|
758
|
-
*
|
|
759
|
-
* You can also upload files using the {@link https://talkjs.com/docs/Reference/REST_API/Messages/#1-upload-a-file| REST API}.
|
|
760
|
-
*
|
|
761
|
-
* Passed in {@link SendFileBlock} when you send a message containing a file attachment:
|
|
762
|
-
*
|
|
763
|
-
* ```
|
|
764
|
-
* const block: SendFileBlock = {
|
|
765
|
-
* type: 'file',
|
|
766
|
-
* fileToken: myFileToken,
|
|
767
|
-
* };
|
|
768
|
-
*
|
|
769
|
-
* const convRef = session.conversation('example_conversation_id');
|
|
770
|
-
* convRef.send({ content: [block] });
|
|
771
|
-
* ```
|
|
772
|
-
*
|
|
773
|
-
* We may change the FileToken format in the future.
|
|
774
|
-
* Do not store old file tokens for future use, as these may stop working.
|
|
775
|
-
*
|
|
776
|
-
* This system ensures that all files must be uploaded to TalkJS before being sent to users, limiting the risk of malware.
|
|
777
|
-
*
|
|
778
|
-
* @public
|
|
779
|
-
*/
|
|
780
|
-
export declare type FileToken = string & {
|
|
781
|
-
__tag: Record<"TalkJS Encoded File Token", true>;
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* The most basic FileBlock variant, used whenever there is no additional metadata for a file.
|
|
786
|
-
*
|
|
787
|
-
* @remarks
|
|
788
|
-
* Do not try to check for `subtype === undefined` directly, as this will break when we add new FileBlock variants in the future.
|
|
789
|
-
*
|
|
790
|
-
* Instead, treat GenericFileBlock as the default. For example:
|
|
791
|
-
*
|
|
792
|
-
* ```
|
|
793
|
-
* if (block.subtype === "video") {
|
|
794
|
-
* handleVideoBlock(block);
|
|
795
|
-
* } else if (block.subtype === "image") {
|
|
796
|
-
* handleImageBlock(block);
|
|
797
|
-
* } else if (block.subtype === "audio") {
|
|
798
|
-
* handleAudioBlock(block);
|
|
799
|
-
* } else if (block.subtype === "voice") {
|
|
800
|
-
* handleVoiceBlock(block);
|
|
801
|
-
* } else {
|
|
802
|
-
* handleGenericFileBlock(block);
|
|
803
|
-
* }
|
|
804
|
-
* ```
|
|
805
|
-
*
|
|
806
|
-
* @public
|
|
807
|
-
*/
|
|
808
|
-
export declare interface GenericFileBlock {
|
|
809
|
-
type: "file";
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* Never set for generic file blocks.
|
|
813
|
-
*/
|
|
814
|
-
subtype?: undefined;
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* An encoded identifier for this file. Use in {@link SendFileBlock} to send this file in another message.
|
|
818
|
-
*/
|
|
819
|
-
fileToken: FileToken;
|
|
820
|
-
|
|
821
|
-
/**
|
|
822
|
-
* The URL where you can fetch the file
|
|
823
|
-
*/
|
|
824
|
-
url: string;
|
|
825
|
-
|
|
826
|
-
/**
|
|
827
|
-
* The size of the file in bytes
|
|
828
|
-
*/
|
|
829
|
-
size: number;
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* The name of the file, including file extension
|
|
833
|
-
*/
|
|
834
|
-
filename: string;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
declare interface GenericFileMetadata {
|
|
838
|
-
/**
|
|
839
|
-
* The name of the file including extension.
|
|
840
|
-
*/
|
|
841
|
-
filename: string;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* Returns a TalkSession option for the specified App ID and User ID.
|
|
846
|
-
*
|
|
847
|
-
* @remarks
|
|
848
|
-
* Backed by a registry, so calling this function twice with the same app and user returns the same session object both times.
|
|
849
|
-
* A new session will be created if the old one encountered an error or got garbage collected.
|
|
850
|
-
*
|
|
851
|
-
* The `token` and `tokenFetcher` properties are ignored if there is already a session for that user in the registry.
|
|
852
|
-
*/
|
|
853
|
-
export declare function getTalkSession(options: TalkSessionOptions): TalkSession;
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* A FileBlock variant for an image attachment, with additional image-specific metadata.
|
|
857
|
-
*
|
|
858
|
-
* @remarks
|
|
859
|
-
* You can identify this variant by checking for `subtype: "image"`.
|
|
860
|
-
*
|
|
861
|
-
* Includes metadata about the height and width of the image in pixels, where available.
|
|
862
|
-
*
|
|
863
|
-
* Images that you upload with the TalkJS UI will include the image dimensions as long as the sender's browser can preview the file.
|
|
864
|
-
* Images that you upload with the REST API or {@link Session.uploadImage} will include the dimensions if you specified them when uploading.
|
|
865
|
-
* Image attached in a reply to an email notification will not include the dimensions.
|
|
866
|
-
*
|
|
867
|
-
* @public
|
|
868
|
-
*/
|
|
869
|
-
export declare interface ImageBlock {
|
|
870
|
-
type: "file";
|
|
871
|
-
|
|
872
|
-
subtype: "image";
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* An encoded identifier for this file. Use in {@link SendFileBlock} to send this image in another message.
|
|
876
|
-
*/
|
|
877
|
-
fileToken: FileToken;
|
|
878
|
-
|
|
879
|
-
/**
|
|
880
|
-
* The URL where you can fetch the file.
|
|
881
|
-
*/
|
|
882
|
-
url: string;
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* The size of the file in bytes.
|
|
886
|
-
*/
|
|
887
|
-
size: number;
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* The name of the image file, including file extension.
|
|
891
|
-
*/
|
|
892
|
-
filename: string;
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* The width of the image in pixels, if known.
|
|
896
|
-
*/
|
|
897
|
-
width?: number;
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* The height of the image in pixels, if known.
|
|
901
|
-
*/
|
|
902
|
-
height?: number;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
declare interface ImageFileMetadata {
|
|
906
|
-
/**
|
|
907
|
-
* The name of the file including extension.
|
|
908
|
-
*/
|
|
909
|
-
filename: string;
|
|
910
|
-
/**
|
|
911
|
-
* The width of the image in pixels, if known.
|
|
912
|
-
*/
|
|
913
|
-
width?: number;
|
|
914
|
-
/**
|
|
915
|
-
* The height of the image in pixels, if known.
|
|
916
|
-
*/
|
|
917
|
-
height?: number;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
/**
|
|
921
|
-
* A node in a {@link TextBlock} that renders its children as a clickable link (HTML `<a>`).
|
|
922
|
-
*
|
|
923
|
-
* @remarks
|
|
924
|
-
* By default, users do not have permission to send messages containing `LinkNode` as it can be used to maliciously hide the true destination of a link.
|
|
925
|
-
*
|
|
926
|
-
* @public
|
|
927
|
-
*/
|
|
928
|
-
export declare interface LinkNode {
|
|
929
|
-
type: "link";
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* The URL to open when the node is clicked.
|
|
933
|
-
*/
|
|
934
|
-
url: string;
|
|
935
|
-
|
|
936
|
-
children: TextNode[];
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* A block showing a location in the world, typically because a user shared their location in the chat.
|
|
941
|
-
*
|
|
942
|
-
* @remarks
|
|
943
|
-
* In the TalkJS UI, location blocks are rendered as a link to Google Maps, with the map pin showing at the specified coordinate.
|
|
944
|
-
* A thumbnail shows the surrounding area on the map.
|
|
945
|
-
*
|
|
946
|
-
* @public
|
|
947
|
-
*/
|
|
948
|
-
export declare interface LocationBlock {
|
|
949
|
-
type: "location";
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* The north-south coordinate of the location.
|
|
953
|
-
*
|
|
954
|
-
* @remarks
|
|
955
|
-
* Usually listed first in a pair of coordinates.
|
|
956
|
-
*
|
|
957
|
-
* Must be a number between -90 and 90
|
|
958
|
-
*/
|
|
959
|
-
latitude: number;
|
|
960
|
-
|
|
961
|
-
/**
|
|
962
|
-
* The east-west coordinate of the location.
|
|
963
|
-
*
|
|
964
|
-
* @remarks
|
|
965
|
-
* Usually listed second in a pair of coordinates.
|
|
966
|
-
*
|
|
967
|
-
* Must be a number between -180 and 180
|
|
968
|
-
*/
|
|
969
|
-
longitude: number;
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* A node in a {@link TextBlock} that renders its children with a specific style.
|
|
974
|
-
*
|
|
975
|
-
* @public
|
|
976
|
-
*/
|
|
977
|
-
export declare interface MarkupNode {
|
|
978
|
-
/**
|
|
979
|
-
* The kind of formatting to apply when rendering the children
|
|
980
|
-
*
|
|
981
|
-
* - `type: "bold"` is used when users type `*text*` and is rendered with HTML `<strong>`
|
|
982
|
-
*
|
|
983
|
-
* - `type: "italic"` is used when users type `_text_` and is rendered with HTML `<em>`
|
|
984
|
-
*
|
|
985
|
-
* - `type: "strikethrough"` is used when users type `~text~` and is rendered with HTML `<s>`
|
|
986
|
-
*/
|
|
987
|
-
type: "bold" | "italic" | "strikethrough";
|
|
988
|
-
|
|
989
|
-
children: TextNode[];
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* A node in a {@link TextBlock} that is used when a user is {@link https://talkjs.com/docs/Features/Message_Features/Mentions/ | mentioned}.
|
|
994
|
-
*
|
|
995
|
-
* @remarks
|
|
996
|
-
* Used when a user types `@name` and selects the user they want to mention.
|
|
997
|
-
*
|
|
998
|
-
* @public
|
|
999
|
-
*/
|
|
1000
|
-
export declare interface MentionNode {
|
|
1001
|
-
type: "mention";
|
|
1002
|
-
|
|
1003
|
-
/**
|
|
1004
|
-
* The ID of the user who is mentioned.
|
|
1005
|
-
*/
|
|
1006
|
-
id: string;
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* The name of the user who is mentioned.
|
|
1010
|
-
*/
|
|
1011
|
-
text: string;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* The state of a messages subscription when it is actively listening for changes
|
|
1016
|
-
*
|
|
1017
|
-
* @public
|
|
1018
|
-
*/
|
|
1019
|
-
export declare interface MessageActiveState {
|
|
1020
|
-
type: "active";
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
* The most recently received snapshot for the user, or `null` if the user does not exist yet.
|
|
1024
|
-
*/
|
|
1025
|
-
latestSnapshot: MessageSnapshot[] | null;
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
* True if `latestSnapshot` contains all messages in the conversation.
|
|
1029
|
-
* Use `MessageSubscription.loadMore` to load more.
|
|
1030
|
-
*/
|
|
1031
|
-
loadedAll: boolean;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
/**
|
|
1035
|
-
* References the message with a given message ID.
|
|
1036
|
-
*
|
|
1037
|
-
* @remarks
|
|
1038
|
-
* Used in all Realtime API operations affecting that message, such as fetching or editing the message attributes, or deleting the message.
|
|
1039
|
-
* Created via {@link ConversationRef.message}.
|
|
1040
|
-
*
|
|
1041
|
-
* @public
|
|
1042
|
-
*/
|
|
1043
|
-
export declare interface MessageRef {
|
|
1044
|
-
/**
|
|
1045
|
-
* The ID of the referenced message.
|
|
1046
|
-
*
|
|
1047
|
-
* @remarks
|
|
1048
|
-
* Immutable: if you want to reference a different message, get a new MessageRef instead.
|
|
1049
|
-
*/
|
|
1050
|
-
readonly id: string;
|
|
1051
|
-
|
|
1052
|
-
/**
|
|
1053
|
-
* The ID of the conversation that the referenced message belongs to.
|
|
1054
|
-
*
|
|
1055
|
-
* @remarks
|
|
1056
|
-
* Immutable: if you want to reference a message from a different conversation, get a new MessageRef from that conversation.
|
|
1057
|
-
*/
|
|
1058
|
-
readonly conversationId: string;
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* Fetches a snapshot of the message.
|
|
1062
|
-
*
|
|
1063
|
-
* @remarks
|
|
1064
|
-
* Supports {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#cached-fetch | Cached Fetch}
|
|
1065
|
-
*
|
|
1066
|
-
* @returns A snapshot of the message's attributes, or null if the message doesn't exist, the conversation doesn't exist, or you're not a participant in the conversation.
|
|
1067
|
-
*/
|
|
1068
|
-
get(): Promise<MessageSnapshot | null>;
|
|
1069
|
-
|
|
1070
|
-
/**
|
|
1071
|
-
* Edits this message.
|
|
1072
|
-
*
|
|
1073
|
-
* @returns A promise that resolves when the operation completes. The promise will reject if the request is invalid, the message doesn't exist, or you do not have permission to edit that message.
|
|
1074
|
-
*/
|
|
1075
|
-
edit(
|
|
1076
|
-
params: string | EditTextMessageParams | EditMessageParams,
|
|
1077
|
-
): Promise<void>;
|
|
1078
|
-
|
|
1079
|
-
/**
|
|
1080
|
-
* Deletes this message, or does nothing if they are already not a participant.
|
|
1081
|
-
*
|
|
1082
|
-
* @remarks
|
|
1083
|
-
* Deleting a nonexistent message is treated as success, and the promise will resolve.
|
|
1084
|
-
*
|
|
1085
|
-
* @returns A promise that resolves when the operation completes. This promise will reject if you are not a participant in the conversation or if your role does not give you permission to delete this message.
|
|
1086
|
-
*/
|
|
1087
|
-
delete(): Promise<void>;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* A snapshot of a message's attributes at a given moment in time.
|
|
1092
|
-
*
|
|
1093
|
-
* @remarks
|
|
1094
|
-
* Automatically expanded to include a snapshot of the user that sent the message, and a snapshot of the referenced message, if this message is a reply.
|
|
1095
|
-
*
|
|
1096
|
-
* Snapshots are immutable and we try to reuse them when possible. You should only re-render your UI when `oldSnapshot !== newSnapshot`.
|
|
1097
|
-
*
|
|
1098
|
-
* @public
|
|
1099
|
-
*/
|
|
1100
|
-
export declare interface MessageSnapshot {
|
|
1101
|
-
/**
|
|
1102
|
-
* The unique ID that is used to identify the message in TalkJS
|
|
1103
|
-
*/
|
|
1104
|
-
id: string;
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* Whether this message was "from a user" or a general system message without a specific sender.
|
|
1108
|
-
*
|
|
1109
|
-
* The `sender` property is always present for "UserMessage" messages and never present for "SystemMessage" messages.
|
|
1110
|
-
*/
|
|
1111
|
-
type: "UserMessage" | "SystemMessage";
|
|
1112
|
-
|
|
1113
|
-
/**
|
|
1114
|
-
* A snapshot of the user who sent the message, or null if it is a system message.
|
|
1115
|
-
* The user's attributes may have been updated since they sent the message, in which case this snapshot contains the updated data.
|
|
1116
|
-
* It is not a historical snapshot.
|
|
1117
|
-
*/
|
|
1118
|
-
sender: UserSnapshot | null;
|
|
1119
|
-
|
|
1120
|
-
/**
|
|
1121
|
-
* Custom metadata you have set on the message
|
|
1122
|
-
*/
|
|
1123
|
-
custom: Record<string, string>;
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* Time at which the message was sent, as a unix timestamp in milliseconds
|
|
1127
|
-
*/
|
|
1128
|
-
createdAt: number;
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
* Time at which the message was last edited, as a unix timestamp in milliseconds.
|
|
1132
|
-
* `null` if the message has never been edited.
|
|
1133
|
-
*/
|
|
1134
|
-
editedAt: number | null;
|
|
1135
|
-
|
|
1136
|
-
/**
|
|
1137
|
-
* A snapshot of the message that this message is a reply to, or null if this message is not a reply.
|
|
1138
|
-
*
|
|
1139
|
-
* @remarks
|
|
1140
|
-
* Only UserMessages can reference other messages.
|
|
1141
|
-
* The referenced message snapshot does not have a `referencedMessage` field.
|
|
1142
|
-
* Instead, it has `referencedMessageId`.
|
|
1143
|
-
* This prevents TalkJS fetching an unlimited number of messages in a long chain of replies.
|
|
1144
|
-
*/
|
|
1145
|
-
referencedMessage: ReferencedMessageSnapshot | null;
|
|
1146
|
-
|
|
1147
|
-
// TODO-STEVEN `rest` also applies when messages are sent with DL, but that's not exposed yet
|
|
1148
|
-
// TODO-STEVEN Add components here
|
|
1149
|
-
// TODO-STEVEN we want to make this make more sense
|
|
1150
|
-
/**
|
|
1151
|
-
* Where this message originated from:
|
|
1152
|
-
*
|
|
1153
|
-
* - "web" = Message sent via the UI or via {@link ConversationBuilder.sendMessage}
|
|
1154
|
-
*
|
|
1155
|
-
* - "rest" = Message sent via the REST API's "send message" endpoint or {@link ConversationRef.send}
|
|
1156
|
-
*
|
|
1157
|
-
* - "import" = Message sent via the REST API's "import messages" endpoint
|
|
1158
|
-
*
|
|
1159
|
-
* - "email" = Message sent by replying to an email notification
|
|
1160
|
-
*/
|
|
1161
|
-
origin: "web" | "rest" | "import" | "email";
|
|
1162
|
-
|
|
1163
|
-
/**
|
|
1164
|
-
* The contents of the message, as a plain text string without any formatting or attachments.
|
|
1165
|
-
* Useful for showing in a conversation list or in notifications.
|
|
1166
|
-
*/
|
|
1167
|
-
plaintext: string;
|
|
1168
|
-
|
|
1169
|
-
/**
|
|
1170
|
-
* The main body of the message, as a list of blocks that are rendered top-to-bottom.
|
|
1171
|
-
*/
|
|
1172
|
-
content: ContentBlock[];
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
/**
|
|
1176
|
-
* A subscription to the messages in a specific conversation.
|
|
1177
|
-
*
|
|
1178
|
-
* @remarks
|
|
1179
|
-
* Get a MessageSubscription by calling {@link ConversationRef.subscribeMessages}
|
|
1180
|
-
*
|
|
1181
|
-
* The subscription is 'windowed'. It includes all messages since a certain point in time.
|
|
1182
|
-
* By default, you subscribe to the 30 most recent messages, and any new messages are sent after you subscribe.
|
|
1183
|
-
*
|
|
1184
|
-
* You can expand this window by calling `loadMore`, which extends the window further into the past.
|
|
1185
|
-
*
|
|
1186
|
-
* @public
|
|
1187
|
-
*/
|
|
1188
|
-
export declare interface MessageSubscription {
|
|
1189
|
-
/**
|
|
1190
|
-
* The current state of the subscription
|
|
1191
|
-
*
|
|
1192
|
-
* @remarks
|
|
1193
|
-
* An object with the following fields:
|
|
1194
|
-
*
|
|
1195
|
-
* `type` is one of "pending", "active", "unsubscribed", or "error".
|
|
1196
|
-
*
|
|
1197
|
-
* When `type` is "active", includes `latestSnapshot` and `loadedAll`.
|
|
1198
|
-
*
|
|
1199
|
-
* - `latestSnapshot: MessageSnapshot[] | null` the current state of the messages in the window, or null if you're not a participant in the conversation
|
|
1200
|
-
*
|
|
1201
|
-
* - `loadedAll: boolean` true when `latestSnapshot` contains all the messages in the conversation
|
|
1202
|
-
*
|
|
1203
|
-
* When `type` is "error", includes the `error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
|
|
1204
|
-
*/
|
|
1205
|
-
state: PendingState | MessageActiveState | UnsubscribedState | ErrorState;
|
|
1206
|
-
|
|
1207
|
-
/**
|
|
1208
|
-
* Resolves when the subscription starts receiving updates from the server.
|
|
1209
|
-
*
|
|
1210
|
-
* @remarks
|
|
1211
|
-
* Wait for this promise if you want to perform some action as soon as the subscription is active.
|
|
1212
|
-
*
|
|
1213
|
-
* The promise rejects if the subscription is terminated before it connects.
|
|
1214
|
-
*/
|
|
1215
|
-
connected: Promise<MessageActiveState>;
|
|
1216
|
-
|
|
1217
|
-
/**
|
|
1218
|
-
* Resolves when the subscription permanently stops receiving updates from the server.
|
|
1219
|
-
*
|
|
1220
|
-
* @remarks
|
|
1221
|
-
* This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
|
|
1222
|
-
*/
|
|
1223
|
-
terminated: Promise<UnsubscribedState | ErrorState>;
|
|
1224
|
-
|
|
1225
|
-
/**
|
|
1226
|
-
* Expand the window to include older messages
|
|
1227
|
-
*
|
|
1228
|
-
* @remarks
|
|
1229
|
-
* Calling `loadMore` multiple times in parallel will still only load one page of messages.
|
|
1230
|
-
*
|
|
1231
|
-
* @param count - The number of additional messages to load. Must be between 1 and 100
|
|
1232
|
-
* @returns A promise that resolves once the additional messages have loaded
|
|
1233
|
-
*/
|
|
1234
|
-
loadMore: (count?: number) => Promise<void>;
|
|
1235
|
-
|
|
1236
|
-
/**
|
|
1237
|
-
* Unsubscribe from this resource and stop receiving updates.
|
|
1238
|
-
*
|
|
1239
|
-
* @remarks
|
|
1240
|
-
* If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
|
|
1241
|
-
*/
|
|
1242
|
-
unsubscribe(): void;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
* References a given user's participation in a conversation.
|
|
1247
|
-
*
|
|
1248
|
-
* @remarks
|
|
1249
|
-
* Used in all Realtime API operations affecting that participant, such as joining/leaving a conversation, or setting their access.
|
|
1250
|
-
* Created via {@link ConversationRef.participant}.
|
|
1251
|
-
*
|
|
1252
|
-
* @public
|
|
1253
|
-
*/
|
|
1254
|
-
export declare interface ParticipantRef {
|
|
1255
|
-
/**
|
|
1256
|
-
* The ID of the user who is participating.
|
|
1257
|
-
*
|
|
1258
|
-
* @remarks
|
|
1259
|
-
* Immutable: if you want to reference a different participant, get a new ParticipantRef instead.
|
|
1260
|
-
*/
|
|
1261
|
-
readonly userId: string;
|
|
1262
|
-
|
|
1263
|
-
/**
|
|
1264
|
-
* The ID of the conversation the user is participating in.
|
|
1265
|
-
*
|
|
1266
|
-
* @remarks
|
|
1267
|
-
* Immutable: if you want to reference the user in a different conversation, get a new ParticipantRef instead.
|
|
1268
|
-
*/
|
|
1269
|
-
readonly conversationId: string;
|
|
1270
|
-
|
|
1271
|
-
/**
|
|
1272
|
-
* Fetches a snapshot of the participant.
|
|
1273
|
-
*
|
|
1274
|
-
* @remarks
|
|
1275
|
-
* This contains all of the participant's public information.
|
|
1276
|
-
*
|
|
1277
|
-
* @returns A snapshot of the participant's attributes, or null if the user is not a participant. The promise will reject if you are not a participant and try to read information about someone else.
|
|
1278
|
-
*/
|
|
1279
|
-
get(): Promise<ParticipantSnapshot | null>;
|
|
1280
|
-
|
|
1281
|
-
/**
|
|
1282
|
-
* Sets properties of this participant. If the user is not already a participant in the conversation, they will be added.
|
|
1283
|
-
*
|
|
1284
|
-
* @remarks
|
|
1285
|
-
* Supports {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#automatic-batching | Automatic Batching}
|
|
1286
|
-
*
|
|
1287
|
-
* @returns A promise that resolves when the operation completes.
|
|
1288
|
-
* When client-side conversation syncing is disabled, you may only set your `notify` property, when you are already a participant.
|
|
1289
|
-
* Everything else requires client-side conversation syncing to be enabled, and will cause the promise to reject.
|
|
1290
|
-
*/
|
|
1291
|
-
set(params: SetParticipantParams): Promise<void>;
|
|
1292
|
-
|
|
1293
|
-
/**
|
|
1294
|
-
* Edits properties of a pre-existing participant. If the user is not already a participant in the conversation, the promise will reject.
|
|
1295
|
-
*
|
|
1296
|
-
* @remarks
|
|
1297
|
-
* Supports {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#automatic-batching | Automatic Batching}
|
|
1298
|
-
*
|
|
1299
|
-
* @returns A promise that resolves when the operation completes.
|
|
1300
|
-
* When client-side conversation syncing is disabled, you may only set your `notify` property, when you are already a participant.
|
|
1301
|
-
* Everything else requires client-side conversation syncing to be enabled, and will cause the promise to reject.
|
|
1302
|
-
*/
|
|
1303
|
-
edit(params: SetParticipantParams): Promise<void>;
|
|
1304
|
-
|
|
1305
|
-
/**
|
|
1306
|
-
* Adds the user as a participant, or does nothing if they are already a participant.
|
|
1307
|
-
*
|
|
1308
|
-
* @remarks
|
|
1309
|
-
* If the participant already exists, this operation is still considered successful and the promise will still resolve.
|
|
1310
|
-
*
|
|
1311
|
-
* Supports {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#automatic-batching | Automatic Batching}
|
|
1312
|
-
*
|
|
1313
|
-
* @returns A promise that resolves when the operation completes. The promise will reject if client-side conversation syncing is disabled and the user is not already a participant.
|
|
1314
|
-
*/
|
|
1315
|
-
createIfNotExists(params?: CreateParticipantParams): Promise<void>;
|
|
1316
|
-
|
|
1317
|
-
/**
|
|
1318
|
-
* Removes the user as a participant, or does nothing if they are already not a participant.
|
|
1319
|
-
*
|
|
1320
|
-
* @remarks
|
|
1321
|
-
* Deleting a nonexistent participant is treated as success, and the promise will resolve.
|
|
1322
|
-
*
|
|
1323
|
-
* @returns A promise that resolves when the operation completes. This promise will reject if client-side conversation syncing is disabled.
|
|
1324
|
-
*/
|
|
1325
|
-
delete(): Promise<void>;
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* A snapshot of a participant's attributes at a given moment in time.
|
|
1330
|
-
*
|
|
1331
|
-
* @remarks
|
|
1332
|
-
* Automatically expanded to include a snapshot of the user who is a participant.
|
|
1333
|
-
*
|
|
1334
|
-
* Snapshots are immutable and we try to reuse them when possible. You should only re-render your UI when `oldSnapshot !== newSnapshot`.
|
|
1335
|
-
*
|
|
1336
|
-
* @public
|
|
1337
|
-
*/
|
|
1338
|
-
export declare interface ParticipantSnapshot {
|
|
1339
|
-
/**
|
|
1340
|
-
* The user who this participant snapshot is referring to
|
|
1341
|
-
*/
|
|
1342
|
-
user: UserSnapshot;
|
|
1343
|
-
|
|
1344
|
-
/**
|
|
1345
|
-
* The level of access this participant has in the conversation.
|
|
1346
|
-
*/
|
|
1347
|
-
access: "ReadWrite" | "Read";
|
|
1348
|
-
|
|
1349
|
-
/**
|
|
1350
|
-
* When the participant will be notified about new messages in this conversation.
|
|
1351
|
-
*
|
|
1352
|
-
* @remarks
|
|
1353
|
-
* `false` means no notifications, `true` means notifications for all messages, and `"MentionsOnly"` means that the user will only be notified when they are mentioned with an `@`.
|
|
1354
|
-
*/
|
|
1355
|
-
notify: boolean | "MentionsOnly";
|
|
1356
|
-
|
|
1357
|
-
/**
|
|
1358
|
-
* The date that this user joined the conversation, as a unix timestamp in milliseconds.
|
|
1359
|
-
*/
|
|
1360
|
-
joinedAt: number;
|
|
1361
|
-
|
|
1362
|
-
// TODO-STEVEN readUntil
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
/**
|
|
1366
|
-
* The state of a subscription before it has connected to the server
|
|
1367
|
-
*
|
|
1368
|
-
* @public
|
|
1369
|
-
*/
|
|
1370
|
-
export declare interface PendingState {
|
|
1371
|
-
type: "pending";
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
/**
|
|
1375
|
-
* A snapshot of a message's attributes at a given moment in time, used in {@link MessageSnapshot.referencedMessage}.
|
|
1376
|
-
*
|
|
1377
|
-
* @remarks
|
|
1378
|
-
* Automatically expanded to include a snapshot of the user that sent the message.
|
|
1379
|
-
* Since this is a snapshot of a referenced message, its referenced message is not automatically expanded, to prevent fetching an unlimited number of messages in a long chain of replies.
|
|
1380
|
-
* Instead, contains the `referencedMessageId` field.
|
|
1381
|
-
*
|
|
1382
|
-
* Snapshots are immutable and we try to reuse them when possible. You should only re-render your UI when `oldSnapshot !== newSnapshot`.
|
|
1383
|
-
*
|
|
1384
|
-
* @public
|
|
1385
|
-
*/
|
|
1386
|
-
export declare interface ReferencedMessageSnapshot {
|
|
1387
|
-
/**
|
|
1388
|
-
* The unique ID that is used to identify the message in TalkJS
|
|
1389
|
-
*/
|
|
1390
|
-
id: string;
|
|
1391
|
-
|
|
1392
|
-
/**
|
|
1393
|
-
* Referenced messages are always "UserMessage" because you cannot reply to a system message.
|
|
1394
|
-
*/
|
|
1395
|
-
type: "UserMessage";
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* A snapshot of the user who sent the message.
|
|
1399
|
-
* The user's attributes may have been updated since they sent the message, in which case this snapshot contains the updated data.
|
|
1400
|
-
* It is not a historical snapshot.
|
|
1401
|
-
*
|
|
1402
|
-
* @remarks
|
|
1403
|
-
* Guaranteed to be set, unlike in MessageSnapshot, because you cannot reference a SystemMessage
|
|
1404
|
-
*/
|
|
1405
|
-
sender: UserSnapshot;
|
|
1406
|
-
|
|
1407
|
-
/**
|
|
1408
|
-
* Custom metadata you have set on the message
|
|
1409
|
-
*/
|
|
1410
|
-
custom: Record<string, string>;
|
|
1411
|
-
|
|
1412
|
-
/**
|
|
1413
|
-
* Time at which the message was sent, as a unix timestamp in milliseconds
|
|
1414
|
-
*/
|
|
1415
|
-
createdAt: number;
|
|
1416
|
-
|
|
1417
|
-
/**
|
|
1418
|
-
* Time at which the message was last edited, as a unix timestamp in milliseconds.
|
|
1419
|
-
* `null` if the message has never been edited.
|
|
1420
|
-
*/
|
|
1421
|
-
editedAt: number | null;
|
|
1422
|
-
|
|
1423
|
-
/**
|
|
1424
|
-
* The ID of the message that this message is a reply to, or null if this message is not a reply.
|
|
1425
|
-
*
|
|
1426
|
-
* @remarks
|
|
1427
|
-
* Since this is a snapshot of a referenced message, we do not automatically expand its referenced message.
|
|
1428
|
-
* The ID of its referenced message is provided here instead.
|
|
1429
|
-
*/
|
|
1430
|
-
referencedMessageId: string | null;
|
|
1431
|
-
|
|
1432
|
-
// TODO-STEVEN `rest` also applies when messages are sent with DL, but that's not exposed yet
|
|
1433
|
-
// TODO-STEVEN Add components here
|
|
1434
|
-
// TODO-STEVEN we want to make this make more sense
|
|
1435
|
-
/**
|
|
1436
|
-
* Where this message originated from:
|
|
1437
|
-
*
|
|
1438
|
-
* - "web" = Message sent via the UI or via `ConversationBuilder.sendMessage`
|
|
1439
|
-
*
|
|
1440
|
-
* - "rest" = Message sent via the REST API's "send message" endpoint
|
|
1441
|
-
*
|
|
1442
|
-
* - "import" = Message sent via the REST API's "import messages" endpoint
|
|
1443
|
-
*
|
|
1444
|
-
* - "email" = Message sent by replying to an email notification
|
|
1445
|
-
*/
|
|
1446
|
-
origin: "web" | "rest" | "import" | "email";
|
|
1447
|
-
|
|
1448
|
-
/**
|
|
1449
|
-
* The contents of the message, as a plain text string without any formatting or attachments.
|
|
1450
|
-
* Useful for showing in a conversation list or in notifications.
|
|
1451
|
-
*/
|
|
1452
|
-
plaintext: string;
|
|
1453
|
-
|
|
1454
|
-
/**
|
|
1455
|
-
* The main body of the message, as a list of blocks that are rendered top-to-bottom.
|
|
1456
|
-
*/
|
|
1457
|
-
content: ContentBlock[];
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
export declare function registerPolyfills({ WebSocket }: {
|
|
1461
|
-
WebSocket: object;
|
|
1462
|
-
}): void;
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
* The version of {@link ContentBlock} that is used when sending or editing messages.
|
|
1466
|
-
*
|
|
1467
|
-
* @remarks
|
|
1468
|
-
* This is the same as {@link ContentBlock} except it uses {@link SendFileBlock} instead of {@link FileBlock}
|
|
1469
|
-
*
|
|
1470
|
-
* `SendContentBlock` is a subset of `ContentBlock`.
|
|
1471
|
-
* This means that you can re-send the `content` from an existing message without any issues:
|
|
1472
|
-
*
|
|
1473
|
-
* ```
|
|
1474
|
-
* const existingMessage: MessageSnapshot = ...;
|
|
1475
|
-
*
|
|
1476
|
-
* const convRef = session.conversation('example_conversation_id');
|
|
1477
|
-
* convRef.send({ content: existingMessage.content });
|
|
1478
|
-
* ```
|
|
1479
|
-
*
|
|
1480
|
-
* @public
|
|
1481
|
-
*/
|
|
1482
|
-
export declare type SendContentBlock = TextBlock | SendFileBlock | LocationBlock;
|
|
1483
|
-
|
|
1484
|
-
/**
|
|
1485
|
-
* The version of {@link FileBlock} that is used when sending or editing messages.
|
|
1486
|
-
*
|
|
1487
|
-
* @remarks
|
|
1488
|
-
* When a user receives the message you send with `SendFileBlock`, this block will have turned into one of the {@link FileBlock} variants.
|
|
1489
|
-
*
|
|
1490
|
-
* For information on how to obtain a file token, see {@link FileToken}.
|
|
1491
|
-
*
|
|
1492
|
-
* The `SendFileBlock` interface is a subset of the `FileBlock` interface.
|
|
1493
|
-
* If you have an existing `FileBlock` received in a message, you can re-use that block to re-send the same attachment:
|
|
1494
|
-
*
|
|
1495
|
-
* ```
|
|
1496
|
-
* const existingFileBlock = ...;
|
|
1497
|
-
* const imageToShare = existingFileBlock.content[0] as ImageBlock
|
|
1498
|
-
*
|
|
1499
|
-
* const convRef = session.conversation('example_conversation_id');
|
|
1500
|
-
* convRef.send({ content: [imageToShare] });
|
|
1501
|
-
* ```
|
|
1502
|
-
*
|
|
1503
|
-
* @public
|
|
1504
|
-
*/
|
|
1505
|
-
export declare interface SendFileBlock {
|
|
1506
|
-
type: "file";
|
|
1507
|
-
/**
|
|
1508
|
-
* The encoded identifier for the file, obtained by uploading a file with {@link Session.sendFile}, or taken from another message.
|
|
1509
|
-
*/
|
|
1510
|
-
fileToken: FileToken;
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
/**
|
|
1514
|
-
* Parameters you can pass to {@link ConversationRef.send}.
|
|
1515
|
-
*
|
|
1516
|
-
* @remarks
|
|
1517
|
-
* Properties that are `undefined` will be set to the default.
|
|
1518
|
-
*
|
|
1519
|
-
* This is the more advanced method for editing a message, giving full control over the message content.
|
|
1520
|
-
* You can decide exactly how a text message should be formatted, edit an attachment, or even turn a text message into a location.
|
|
1521
|
-
*
|
|
1522
|
-
* @public
|
|
1523
|
-
*/
|
|
1524
|
-
export declare interface SendMessageParams {
|
|
1525
|
-
/**
|
|
1526
|
-
* Custom metadata you have set on the user.
|
|
1527
|
-
* Default = no custom metadata
|
|
1528
|
-
*/
|
|
1529
|
-
custom?: Record<string, string>;
|
|
1530
|
-
|
|
1531
|
-
/**
|
|
1532
|
-
* The message that you are replying to.
|
|
1533
|
-
* Default = not a reply
|
|
1534
|
-
*/
|
|
1535
|
-
referencedMessage?: string | MessageRef;
|
|
1536
|
-
|
|
1537
|
-
/**
|
|
1538
|
-
* The most important part of the message, either some text, a file attachment, or a location.
|
|
1539
|
-
*
|
|
1540
|
-
* @remarks
|
|
1541
|
-
* By default users do not have permission to send {@link LinkNode}, {@link ActionLinkNode}, or {@link ActionButtonNode}, as they can be used to trick the recipient.
|
|
1542
|
-
*/
|
|
1543
|
-
content: [SendContentBlock];
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
/**
|
|
1547
|
-
* Parameters you can pass to {@link ConversationRef.send}.
|
|
1548
|
-
*
|
|
1549
|
-
* @remarks
|
|
1550
|
-
* Properties that are `undefined` will be set to the default.
|
|
1551
|
-
*
|
|
1552
|
-
* This is a simpler version of {@link SendMessageParams} that only supports text messages.
|
|
1553
|
-
*
|
|
1554
|
-
* @public
|
|
1555
|
-
*/
|
|
1556
|
-
export declare interface SendTextMessageParams {
|
|
1557
|
-
/**
|
|
1558
|
-
* Custom metadata you have set on the user.
|
|
1559
|
-
* Default = no custom metadata
|
|
1560
|
-
*/
|
|
1561
|
-
custom?: Record<string, string>;
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* The message that you are replying to.
|
|
1565
|
-
* Default = not a reply
|
|
1566
|
-
*/
|
|
1567
|
-
referencedMessage?: string | MessageRef;
|
|
1568
|
-
|
|
1569
|
-
/**
|
|
1570
|
-
* The text to send in the message.
|
|
1571
|
-
*
|
|
1572
|
-
* @remarks
|
|
1573
|
-
* This is parsed the same way as the text entered in the message field. For example, `*hi*` will appear as `hi` in bold.
|
|
1574
|
-
*
|
|
1575
|
-
* See the {@link https://talkjs.com/docs/Features/Message_Features/Formatting/ | message formatting documentation} for more details.
|
|
1576
|
-
*/
|
|
1577
|
-
text: string;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
/**
|
|
1581
|
-
* Parameters you can pass to {@link ConversationRef.set}.
|
|
1582
|
-
*
|
|
1583
|
-
* Properties that are `undefined` will not be changed.
|
|
1584
|
-
* To clear / reset a property to the default, pass `null`.
|
|
1585
|
-
*
|
|
1586
|
-
* @public
|
|
1587
|
-
*/
|
|
1588
|
-
export declare interface SetConversationParams {
|
|
1589
|
-
/**
|
|
1590
|
-
* The conversation subject to display in the chat header.
|
|
1591
|
-
* Default = no subject, list participant names instead.
|
|
1592
|
-
*/
|
|
1593
|
-
subject?: string | null;
|
|
1594
|
-
|
|
1595
|
-
/**
|
|
1596
|
-
* The URL for the conversation photo to display in the chat header.
|
|
1597
|
-
* Default = no photo, show a placeholder image.
|
|
1598
|
-
*/
|
|
1599
|
-
photoUrl?: string | null;
|
|
1600
|
-
|
|
1601
|
-
/**
|
|
1602
|
-
* System messages which are sent at the beginning of a conversation.
|
|
1603
|
-
* Default = no messages.
|
|
1604
|
-
*/
|
|
1605
|
-
welcomeMessages?: string[] | null;
|
|
1606
|
-
|
|
1607
|
-
/**
|
|
1608
|
-
* Custom metadata you have set on the conversation.
|
|
1609
|
-
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
1610
|
-
* Default = no custom metadata
|
|
1611
|
-
*/
|
|
1612
|
-
custom?: Record<string, string | null> | null;
|
|
1613
|
-
|
|
1614
|
-
/**
|
|
1615
|
-
* Your access to the conversation.
|
|
1616
|
-
* Default = "ReadWrite" access.
|
|
1617
|
-
*/
|
|
1618
|
-
access?: "Read" | "ReadWrite" | null;
|
|
1619
|
-
|
|
1620
|
-
/**
|
|
1621
|
-
* Your notification settings.
|
|
1622
|
-
* Default = `true`
|
|
1623
|
-
*/
|
|
1624
|
-
notify?: boolean | "MentionsOnly" | null;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
/**
|
|
1628
|
-
* Parameters you can pass to {@link ParticipantRef.set} or {@link ParticipantRef.edit}.
|
|
1629
|
-
*
|
|
1630
|
-
* @remarks
|
|
1631
|
-
* Properties that are `undefined` will not be changed.
|
|
1632
|
-
* To clear / reset a property to the default, pass `null`.
|
|
1633
|
-
*
|
|
1634
|
-
* @public
|
|
1635
|
-
*/
|
|
1636
|
-
export declare interface SetParticipantParams {
|
|
1637
|
-
/**
|
|
1638
|
-
* The level of access the participant should have in the conversation.
|
|
1639
|
-
* Default = "ReadWrite" access.
|
|
1640
|
-
*/
|
|
1641
|
-
access?: "ReadWrite" | "Read" | null;
|
|
1642
|
-
|
|
1643
|
-
/**
|
|
1644
|
-
* When the participant should be notified about new messages in this conversation.
|
|
1645
|
-
* Default = `ReadWrite` access.
|
|
1646
|
-
*
|
|
1647
|
-
* @remarks
|
|
1648
|
-
* `false` means no notifications, `true` means notifications for all messages, and `"MentionsOnly"` means that the user will only be notified when they are mentioned with an `@`.
|
|
1649
|
-
*/
|
|
1650
|
-
notify?: boolean | "MentionsOnly" | null;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
/**
|
|
1654
|
-
* Parameters you can pass to {@link UserRef.set}.
|
|
1655
|
-
*
|
|
1656
|
-
* @remarks
|
|
1657
|
-
* Properties that are `undefined` will not be changed.
|
|
1658
|
-
* To clear / reset a property to the default, pass `null`.
|
|
1659
|
-
*
|
|
1660
|
-
* @public
|
|
1661
|
-
*/
|
|
1662
|
-
export declare interface SetUserParams {
|
|
1663
|
-
/**
|
|
1664
|
-
* The user's name which will be displayed on the TalkJS UI
|
|
1665
|
-
*/
|
|
1666
|
-
name?: string;
|
|
1667
|
-
|
|
1668
|
-
/**
|
|
1669
|
-
* Custom metadata you have set on the user.
|
|
1670
|
-
* This value acts as a patch. Remove specific properties by setting them to `null`.
|
|
1671
|
-
* Default = no custom metadata
|
|
1672
|
-
*/
|
|
1673
|
-
custom?: Record<string, string | null> | null;
|
|
1674
|
-
|
|
1675
|
-
/**
|
|
1676
|
-
* An {@link https://www.w3.org/International/articles/language-tags/ | IETF language tag}.
|
|
1677
|
-
* See the {@link https://talkjs.com/docs/Features/Language_Support/Localization.html | localization documentation}
|
|
1678
|
-
* Default = the locale selected on the dashboard
|
|
1679
|
-
*/
|
|
1680
|
-
locale?: string;
|
|
1681
|
-
|
|
1682
|
-
/**
|
|
1683
|
-
* An optional URL to a photo which will be displayed as the user's avatar.
|
|
1684
|
-
* Default = no photo
|
|
1685
|
-
*/
|
|
1686
|
-
photoUrl?: string | null;
|
|
1687
|
-
|
|
1688
|
-
/**
|
|
1689
|
-
* TalkJS supports multiple sets of settings, called "roles". These allow you to change the behavior of TalkJS for different users.
|
|
1690
|
-
* You have full control over which user gets which configuration.
|
|
1691
|
-
* Default = the `default` role
|
|
1692
|
-
*/
|
|
1693
|
-
role?: string | null;
|
|
1694
|
-
|
|
1695
|
-
/**
|
|
1696
|
-
* The default message a person sees when starting a chat with this user.
|
|
1697
|
-
* Default = no welcome message
|
|
1698
|
-
*/
|
|
1699
|
-
welcomeMessage?: string | null;
|
|
1700
|
-
|
|
1701
|
-
/**
|
|
1702
|
-
* An array of email addresses associated with the user.
|
|
1703
|
-
* Default = no email addresses
|
|
1704
|
-
*/
|
|
1705
|
-
email?: string[] | null;
|
|
1706
|
-
|
|
1707
|
-
/**
|
|
1708
|
-
* An array of phone numbers associated with the user.
|
|
1709
|
-
* Default = no phone numbers
|
|
1710
|
-
*/
|
|
1711
|
-
phone?: string[] | null;
|
|
1712
|
-
|
|
1713
|
-
/**
|
|
1714
|
-
* An object of push registration tokens to use when notifying this user.
|
|
1715
|
-
*
|
|
1716
|
-
* Keys in the object have the format `'provider:token_id'`,
|
|
1717
|
-
* where `provider` is either `"fcm"` for Android (Firebase Cloud Messaging),
|
|
1718
|
-
* or `"apns"` for iOS (Apple Push Notification Service).
|
|
1719
|
-
*
|
|
1720
|
-
* The value for each key can either be `true` to register the device for push notifications, or `null` to unregister that device.
|
|
1721
|
-
*
|
|
1722
|
-
* Setting pushTokens to null unregisters all the previously registered devices.
|
|
1723
|
-
*
|
|
1724
|
-
* Default = no push tokens
|
|
1725
|
-
*/
|
|
1726
|
-
pushTokens?: Record<string, true | null> | null;
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
export declare type Subscription = {
|
|
1730
|
-
unsubscribe: () => void;
|
|
1731
|
-
};
|
|
1732
|
-
|
|
1733
|
-
export declare interface TalkSession {
|
|
1734
|
-
/**
|
|
1735
|
-
* A reference to the user this session is connected as
|
|
1736
|
-
*
|
|
1737
|
-
* @remarks
|
|
1738
|
-
* This is immutable. If you want to connect as a different user,
|
|
1739
|
-
* call `getTalkSession` again to get a new session.
|
|
1740
|
-
*/
|
|
1741
|
-
readonly currentUser: UserRef;
|
|
1742
|
-
/**
|
|
1743
|
-
* Subscribe to unrecoverable errors on the session.
|
|
1744
|
-
*
|
|
1745
|
-
* @remarks
|
|
1746
|
-
* For example, the handler will be called if your authentication token
|
|
1747
|
-
* expires and can't be refreshed, or if you try to connect with an invalid app ID.
|
|
1748
|
-
*
|
|
1749
|
-
* The handler will only be called at most once.
|
|
1750
|
-
*
|
|
1751
|
-
* Returns a subscription with a `.unsubscribe` method.
|
|
1752
|
-
* Call this unsubscribe method when you no longer need to be notified about errors on the session.
|
|
1753
|
-
*/
|
|
1754
|
-
onError(handler: (error: Error) => void): Subscription;
|
|
1755
|
-
/**
|
|
1756
|
-
* Get a reference to a user
|
|
1757
|
-
*
|
|
1758
|
-
* @param id - The ID of the user that you want to reference
|
|
1759
|
-
* @returns A {@linkcode UserRef} for the user with that ID
|
|
1760
|
-
* @public
|
|
1761
|
-
*/
|
|
1762
|
-
user(id: string): UserRef;
|
|
1763
|
-
/**
|
|
1764
|
-
* Get a reference to a conversation
|
|
1765
|
-
*
|
|
1766
|
-
* @param id - The ID of the conversation that you want to reference
|
|
1767
|
-
* @returns A {@linkcode ConversationRef} for the conversation with that ID
|
|
1768
|
-
* @public
|
|
1769
|
-
*/
|
|
1770
|
-
conversation(id: string): ConversationRef;
|
|
1771
|
-
/**
|
|
1772
|
-
* Upload a generic file without any additional metadata.
|
|
1773
|
-
*
|
|
1774
|
-
* @remarks
|
|
1775
|
-
* This function does not send any message, it only uploads the file and returns a file token.
|
|
1776
|
-
* To send the file in a message, pass the file token in a {@linkcode SendFileBlock} when calling {@linkcode ConversationRef.send}.
|
|
1777
|
-
*
|
|
1778
|
-
* {@link https://talkjs.com/docs/Reference/Concepts/Message_Content/#sending-message-content | See the documentation} for more information about sending files in messages.
|
|
1779
|
-
*
|
|
1780
|
-
* If the file is a video, image, audio file, or voice recording, use one of the other functions like {@linkcode uploadImage} instead.
|
|
1781
|
-
*
|
|
1782
|
-
* @param data The binary file data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
|
|
1783
|
-
* @param metadata Information about the file
|
|
1784
|
-
* @returns A file token that can be used to send the file in a message.
|
|
1785
|
-
*/
|
|
1786
|
-
uploadFile(data: Blob, metadata: GenericFileMetadata): Promise<FileToken>;
|
|
1787
|
-
/**
|
|
1788
|
-
* Upload an image with image-specific metadata.
|
|
1789
|
-
*
|
|
1790
|
-
* @remarks
|
|
1791
|
-
* This is a variant of {@linkcode TalkSession.uploadFile} used for images.
|
|
1792
|
-
*
|
|
1793
|
-
* @param data The binary image data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
|
|
1794
|
-
* @param metadata Information about the image.
|
|
1795
|
-
* @returns A file token that can be used to send the image in a message.
|
|
1796
|
-
*/
|
|
1797
|
-
uploadImage(data: Blob, metadata: ImageFileMetadata): Promise<FileToken>;
|
|
1798
|
-
/**
|
|
1799
|
-
* Upload a video with video-specific metadata.
|
|
1800
|
-
*
|
|
1801
|
-
* @remarks
|
|
1802
|
-
* This is a variant of {@linkcode TalkSession.uploadFile} used for videos.
|
|
1803
|
-
*
|
|
1804
|
-
* @param data The binary video data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
|
|
1805
|
-
* @param metadata Information about the video.
|
|
1806
|
-
* @returns A file token that can be used to send the video in a message.
|
|
1807
|
-
*/
|
|
1808
|
-
uploadVideo(data: Blob, metadata: VideoFileMetadata): Promise<FileToken>;
|
|
1809
|
-
/**
|
|
1810
|
-
* Upload an audio file with audio-specific metadata.
|
|
1811
|
-
*
|
|
1812
|
-
* @remarks
|
|
1813
|
-
* This is a variant of {@linkcode TalkSession.uploadFile} used for audio files.
|
|
1814
|
-
*
|
|
1815
|
-
* @param data The binary audio data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
|
|
1816
|
-
* @param metadata Information about the audio file.
|
|
1817
|
-
* @returns A file token that can be used to send the audio file in a message.
|
|
1818
|
-
*/
|
|
1819
|
-
uploadAudio(data: Blob, metadata: AudioFileMetadata): Promise<FileToken>;
|
|
1820
|
-
/**
|
|
1821
|
-
* Upload a voice recording with voice-specific metadata.
|
|
1822
|
-
*
|
|
1823
|
-
* @remarks
|
|
1824
|
-
* This is a variant of {@linkcode TalkSession.uploadFile} used for voice recordings.
|
|
1825
|
-
*
|
|
1826
|
-
* @param data The binary audio data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.
|
|
1827
|
-
* @param metadata Information about the voice recording.
|
|
1828
|
-
* @returns A file token that can be used to send the audio file in a message.
|
|
1829
|
-
*/
|
|
1830
|
-
uploadVoice(data: Blob, metadata: VoiceRecordingFileMetadata): Promise<FileToken>;
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
export declare interface TalkSessionOptions {
|
|
1834
|
-
appId: string;
|
|
1835
|
-
userId: string;
|
|
1836
|
-
token?: string;
|
|
1837
|
-
tokenFetcher?: () => string | Promise<string>;
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1840
|
-
/**
|
|
1841
|
-
* A block of formatted text in a message's content.
|
|
1842
|
-
*
|
|
1843
|
-
* @remarks
|
|
1844
|
-
* Each TextBlock is a tree of {@link TextNode} children describing the structure of some formatted text.
|
|
1845
|
-
* Each child is either a plain text string, or a `node` representing some text with additional formatting.
|
|
1846
|
-
*
|
|
1847
|
-
* For example, if the user typed:
|
|
1848
|
-
*
|
|
1849
|
-
* > *This first bit* is bold, and *_the second bit_* is bold and italics
|
|
1850
|
-
*
|
|
1851
|
-
* Then this would become a Text Block with the structure:
|
|
1852
|
-
*
|
|
1853
|
-
* ```
|
|
1854
|
-
* {
|
|
1855
|
-
* type: "text",
|
|
1856
|
-
* children: [
|
|
1857
|
-
* {
|
|
1858
|
-
* type: "text",
|
|
1859
|
-
* children: [
|
|
1860
|
-
* { type: "bold", children: ["This first bit"] },
|
|
1861
|
-
* " is bold, and ",
|
|
1862
|
-
* {
|
|
1863
|
-
* children: [
|
|
1864
|
-
* { type: "italic", children: ["the second bit"] }
|
|
1865
|
-
* ],
|
|
1866
|
-
* type: "bold",
|
|
1867
|
-
* },
|
|
1868
|
-
* " is bold and italics",
|
|
1869
|
-
* ],
|
|
1870
|
-
* },
|
|
1871
|
-
* ],
|
|
1872
|
-
* }
|
|
1873
|
-
* ```
|
|
1874
|
-
*
|
|
1875
|
-
* Rather than relying the automatic message parsing, you can also specify the `TextBlock` directly using {@link ConversationRef.send} with {@link SendMessageParams}.
|
|
1876
|
-
*
|
|
1877
|
-
* @public
|
|
1878
|
-
*/
|
|
1879
|
-
export declare interface TextBlock {
|
|
1880
|
-
type: "text";
|
|
1881
|
-
children: TextNode[];
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
/**
|
|
1885
|
-
* Any node that can exist inside a {@link TextBlock}.
|
|
1886
|
-
*
|
|
1887
|
-
* @remarks
|
|
1888
|
-
* The simplest `TextNode` is a plain text string.
|
|
1889
|
-
* Using "hello" as an example message, the `TextBlock` would be:
|
|
1890
|
-
*
|
|
1891
|
-
* ```typescript
|
|
1892
|
-
* {
|
|
1893
|
-
* type: 'text';
|
|
1894
|
-
* children: ['hello'];
|
|
1895
|
-
* }
|
|
1896
|
-
* ```
|
|
1897
|
-
*
|
|
1898
|
-
* Other than plain text, there are many different kinds of node which render some text in a specific way or with certain formatting.
|
|
1899
|
-
*
|
|
1900
|
-
* ```
|
|
1901
|
-
* type TextNode =
|
|
1902
|
-
* | string
|
|
1903
|
-
* | MarkupNode
|
|
1904
|
-
* | BulletListNode
|
|
1905
|
-
* | BulletPointNode
|
|
1906
|
-
* | CodeSpanNode
|
|
1907
|
-
* | LinkNode
|
|
1908
|
-
* | AutoLinkNode
|
|
1909
|
-
* | ActionLinkNode
|
|
1910
|
-
* | ActionButtonNode
|
|
1911
|
-
* | CustomEmojiNode
|
|
1912
|
-
* | MentionNode;
|
|
1913
|
-
* ```
|
|
1914
|
-
*
|
|
1915
|
-
* If the text node is not a plain string, it will have a `type` field indicating what kind of node it is, and either a property `text: string` or a property `children: TextNode[]`.
|
|
1916
|
-
* This will be true for all nodes added in the future as well.
|
|
1917
|
-
*
|
|
1918
|
-
* @public
|
|
1919
|
-
*/
|
|
1920
|
-
export declare type TextNode =
|
|
1921
|
-
| string
|
|
1922
|
-
| MarkupNode
|
|
1923
|
-
| BulletListNode
|
|
1924
|
-
| BulletPointNode
|
|
1925
|
-
| CodeSpanNode
|
|
1926
|
-
| LinkNode
|
|
1927
|
-
| AutoLinkNode
|
|
1928
|
-
| ActionLinkNode
|
|
1929
|
-
| ActionButtonNode
|
|
1930
|
-
| CustomEmojiNode
|
|
1931
|
-
| MentionNode;
|
|
1932
|
-
|
|
1933
|
-
/**
|
|
1934
|
-
* The state of a subscription after you have manually unsubscribed
|
|
1935
|
-
*
|
|
1936
|
-
* @public
|
|
1937
|
-
*/
|
|
1938
|
-
export declare interface UnsubscribedState {
|
|
1939
|
-
type: "unsubscribed";
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
/**
|
|
1943
|
-
* The state of a user subscription when it is actively listening for changes
|
|
1944
|
-
*
|
|
1945
|
-
* @public
|
|
1946
|
-
*/
|
|
1947
|
-
export declare interface UserActiveState {
|
|
1948
|
-
type: "active";
|
|
1949
|
-
|
|
1950
|
-
/**
|
|
1951
|
-
* The most recently received snapshot for the user, or `null` if the user does not exist yet.
|
|
1952
|
-
*/
|
|
1953
|
-
latestSnapshot: UserSnapshot | null;
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
/**
|
|
1957
|
-
* References the user with a given user ID.
|
|
1958
|
-
*
|
|
1959
|
-
* @remarks
|
|
1960
|
-
* Used in all Realtime API operations affecting that user, such as creating the user, fetching or updating user data, or adding a user to a conversation.
|
|
1961
|
-
* Created via {@link Session.user}.
|
|
1962
|
-
*
|
|
1963
|
-
* @public
|
|
1964
|
-
*/
|
|
1965
|
-
export declare interface UserRef {
|
|
1966
|
-
/**
|
|
1967
|
-
* The ID of the referenced user.
|
|
1968
|
-
*
|
|
1969
|
-
* @remarks
|
|
1970
|
-
* Immutable: if you want to reference a different user, get a new UserRef instead.
|
|
1971
|
-
*/
|
|
1972
|
-
readonly id: string;
|
|
1973
|
-
|
|
1974
|
-
/**
|
|
1975
|
-
* Fetches a snapshot of the user.
|
|
1976
|
-
*
|
|
1977
|
-
* @remarks
|
|
1978
|
-
* This contains all of a user's public information.
|
|
1979
|
-
* Fetching a user snapshot doesn't require any permissions. You can read the public information of any user.
|
|
1980
|
-
* Private information, such as email addresses and phone numbers, aren't included in the response.
|
|
1981
|
-
*
|
|
1982
|
-
* Supports {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#automatic-batching | Automatic Batching} and {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#cached-fetch | Cached Fetch}
|
|
1983
|
-
*
|
|
1984
|
-
* @returns A snapshot of the user's public attributes, or null if the user doesn't exist.
|
|
1985
|
-
*/
|
|
1986
|
-
get(): Promise<UserSnapshot | null>;
|
|
1987
|
-
|
|
1988
|
-
/**
|
|
1989
|
-
* Sets properties of this user. The user is created if a user with this ID doesn't already exist.
|
|
1990
|
-
*
|
|
1991
|
-
* @remarks
|
|
1992
|
-
* `name` is required when creating a user. The promise will reject if you don't provide a `name` and the user does not exist yet.
|
|
1993
|
-
*
|
|
1994
|
-
* @returns A promise that resolves when the operation completes. The promise will reject if the request is invalid or if client-side user syncing is disabled.
|
|
1995
|
-
*/
|
|
1996
|
-
set(params: SetUserParams): Promise<void>;
|
|
1997
|
-
|
|
1998
|
-
/**
|
|
1999
|
-
* Creates a user with this ID, or does nothing if a user with this ID already exists.
|
|
2000
|
-
*
|
|
2001
|
-
* @remarks
|
|
2002
|
-
* If the user already exists, this operation is still considered successful and the promise will still resolve.
|
|
2003
|
-
*
|
|
2004
|
-
* @returns A promise that resolves when the operation completes. The promise will reject if client-side user syncing is disabled and the user does not already exist.
|
|
2005
|
-
*/
|
|
2006
|
-
createIfNotExists(params: CreateUserParams): Promise<void>;
|
|
2007
|
-
|
|
2008
|
-
/**
|
|
2009
|
-
* Subscribe to this user's state.
|
|
2010
|
-
*
|
|
2011
|
-
* @remarks
|
|
2012
|
-
* Whenever `Subscription.state.type` is "active" and the user is created or their attributes change, `onSnapshot` will fire and `Subscription.state.latestSnapshot` will be updated.
|
|
2013
|
-
*
|
|
2014
|
-
* Supports {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#subscription-sharing | Subscription Sharing} and {@link https://talkjs.com/docs/Reference/JavaScript_Chat_SDK/Realtime_API/#debounced-unsubscribe | Debounced Unsubscribe}
|
|
2015
|
-
*
|
|
2016
|
-
* @returns A subscription to the user
|
|
2017
|
-
*/
|
|
2018
|
-
subscribe(
|
|
2019
|
-
onSnapshot?: (event: UserSnapshot | null) => void,
|
|
2020
|
-
): UserSubscription;
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
/**
|
|
2024
|
-
* A snapshot of a user's attributes at a given moment in time.
|
|
2025
|
-
*
|
|
2026
|
-
* @remarks
|
|
2027
|
-
* Users also have private information, such as email addresses and phone numbers, but these are only exposed on the {@link https://talkjs.com/docs/Reference/REST_API/Getting_Started/Introduction/ | REST API}.
|
|
2028
|
-
*
|
|
2029
|
-
* Snapshots are immutable and we try to reuse them when possible. You should only re-render your UI when `oldSnapshot !== newSnapshot`.
|
|
2030
|
-
*
|
|
2031
|
-
* @public
|
|
2032
|
-
*/
|
|
2033
|
-
export declare interface UserSnapshot {
|
|
2034
|
-
/**
|
|
2035
|
-
* The unique ID that is used to identify the user in TalkJS
|
|
2036
|
-
*/
|
|
2037
|
-
id: string;
|
|
2038
|
-
|
|
2039
|
-
/**
|
|
2040
|
-
* The user's name, which is displayed on the TalkJS UI
|
|
2041
|
-
*/
|
|
2042
|
-
name: string;
|
|
2043
|
-
|
|
2044
|
-
/**
|
|
2045
|
-
* Custom metadata you have set on the user
|
|
2046
|
-
*/
|
|
2047
|
-
custom: Record<string, string>;
|
|
2048
|
-
|
|
2049
|
-
/**
|
|
2050
|
-
* An {@link https://www.w3.org/International/articles/language-tags/ | IETF language tag}.
|
|
2051
|
-
* For more information, see: {@link https://talkjs.com/docs/Features/Language_Support/Localization.html | Localization}.
|
|
2052
|
-
*
|
|
2053
|
-
* When `locale` is null, the app's default locale will be used
|
|
2054
|
-
*/
|
|
2055
|
-
locale: string | null;
|
|
2056
|
-
|
|
2057
|
-
/**
|
|
2058
|
-
* An optional URL to a photo that is displayed as the user's avatar
|
|
2059
|
-
*/
|
|
2060
|
-
photoUrl: string | null;
|
|
2061
|
-
|
|
2062
|
-
/**
|
|
2063
|
-
* TalkJS supports multiple sets of settings for users, called "roles". Roles allow you to change the behavior of TalkJS for different users.
|
|
2064
|
-
* You have full control over which user gets which configuration.
|
|
2065
|
-
*/
|
|
2066
|
-
role: string;
|
|
2067
|
-
|
|
2068
|
-
/**
|
|
2069
|
-
* The default message a person sees when starting a chat with this user
|
|
2070
|
-
*/
|
|
2071
|
-
welcomeMessage: string | null;
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
/**
|
|
2075
|
-
* A subscription to a specific user
|
|
2076
|
-
*
|
|
2077
|
-
* @remarks
|
|
2078
|
-
* Get a UserSubscription by calling {@link UserRef.subscribe}
|
|
2079
|
-
*
|
|
2080
|
-
* @public
|
|
2081
|
-
*/
|
|
2082
|
-
export declare interface UserSubscription {
|
|
2083
|
-
/**
|
|
2084
|
-
* The current state of the subscription
|
|
2085
|
-
*
|
|
2086
|
-
* @remarks
|
|
2087
|
-
* An object with the following fields:
|
|
2088
|
-
*
|
|
2089
|
-
* `type` is one of "pending", "active", "unsubscribed", or "error".
|
|
2090
|
-
*
|
|
2091
|
-
* When `type` is "active", includes `latestSnapshot: UserSnapshot | null`. It is the current state of the user, or null if they don't exist.
|
|
2092
|
-
*
|
|
2093
|
-
* When `type` is "error", includes the `error: Error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
|
|
2094
|
-
*/
|
|
2095
|
-
state: PendingState | UserActiveState | UnsubscribedState | ErrorState;
|
|
2096
|
-
|
|
2097
|
-
/**
|
|
2098
|
-
* Resolves when the subscription starts receiving updates from the server.
|
|
2099
|
-
*/
|
|
2100
|
-
connected: Promise<UserActiveState>;
|
|
2101
|
-
|
|
2102
|
-
/**
|
|
2103
|
-
* Resolves when the subscription permanently stops receiving updates from the server.
|
|
2104
|
-
*
|
|
2105
|
-
* @remarks
|
|
2106
|
-
* This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
|
|
2107
|
-
*/
|
|
2108
|
-
terminated: Promise<UnsubscribedState | ErrorState>;
|
|
2109
|
-
|
|
2110
|
-
/**
|
|
2111
|
-
* Unsubscribe from this resource and stop receiving updates.
|
|
2112
|
-
*
|
|
2113
|
-
* @remarks
|
|
2114
|
-
* If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
|
|
2115
|
-
*/
|
|
2116
|
-
unsubscribe(): void;
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
/**
|
|
2120
|
-
* A FileBlock variant for a video attachment, with additional video-specific metadata.
|
|
2121
|
-
*
|
|
2122
|
-
* @remarks
|
|
2123
|
-
* You can identify this variant by checking for `subtype: "video"`.
|
|
2124
|
-
*
|
|
2125
|
-
* Includes metadata about the height and width of the video in pixels, and the duration of the video in seconds, where available.
|
|
2126
|
-
*
|
|
2127
|
-
* Videos that you upload with the TalkJS UI will include the dimensions and duration as long as the sender's browser can preview the file.
|
|
2128
|
-
* Videos that you upload with the REST API or {@link Session.uploadVideo} will include this metadata if you specified it when uploading.
|
|
2129
|
-
* Videos attached in a reply to an email notification will not include any metadata.
|
|
2130
|
-
*
|
|
2131
|
-
* @public
|
|
2132
|
-
*/
|
|
2133
|
-
export declare interface VideoBlock {
|
|
2134
|
-
type: "file";
|
|
2135
|
-
|
|
2136
|
-
subtype: "video";
|
|
2137
|
-
|
|
2138
|
-
/**
|
|
2139
|
-
* An encoded identifier for this file. Use in {@link SendFileBlock} to send this video in another message.
|
|
2140
|
-
*/
|
|
2141
|
-
fileToken: FileToken;
|
|
2142
|
-
|
|
2143
|
-
/**
|
|
2144
|
-
* The URL where you can fetch the file.
|
|
2145
|
-
*/
|
|
2146
|
-
url: string;
|
|
2147
|
-
|
|
2148
|
-
/**
|
|
2149
|
-
* The size of the file in bytes.
|
|
2150
|
-
*/
|
|
2151
|
-
size: number;
|
|
2152
|
-
|
|
2153
|
-
/**
|
|
2154
|
-
* The name of the video file, including file extension.
|
|
2155
|
-
*/
|
|
2156
|
-
filename: string;
|
|
2157
|
-
|
|
2158
|
-
/**
|
|
2159
|
-
* The width of the video in pixels, if known.
|
|
2160
|
-
*/
|
|
2161
|
-
width?: number;
|
|
2162
|
-
|
|
2163
|
-
/**
|
|
2164
|
-
* The height of the video in pixels, if known.
|
|
2165
|
-
*/
|
|
2166
|
-
height?: number;
|
|
2167
|
-
|
|
2168
|
-
/**
|
|
2169
|
-
* The duration of the video in seconds, if known.
|
|
2170
|
-
*/
|
|
2171
|
-
duration?: number;
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
declare interface VideoFileMetadata {
|
|
2175
|
-
/**
|
|
2176
|
-
* The name of the file including extension.
|
|
2177
|
-
*/
|
|
2178
|
-
filename: string;
|
|
2179
|
-
/**
|
|
2180
|
-
* The width of the video in pixels, if known.
|
|
2181
|
-
*/
|
|
2182
|
-
width?: number;
|
|
2183
|
-
/**
|
|
2184
|
-
* The height of the video in pixels, if known.
|
|
2185
|
-
*/
|
|
2186
|
-
height?: number;
|
|
2187
|
-
/**
|
|
2188
|
-
* The duration of the video in seconds, if known.
|
|
2189
|
-
*/
|
|
2190
|
-
duration?: number;
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
/**
|
|
2194
|
-
* A FileBlock variant for a voice recording attachment, with additional voice-recording-specific metadata.
|
|
2195
|
-
*
|
|
2196
|
-
* @remarks
|
|
2197
|
-
* You can identify this variant by checking for `subtype: "voice"`.
|
|
2198
|
-
*
|
|
2199
|
-
* The same file could be uploaded as either a voice block, or as an {@link AudioBlock}.
|
|
2200
|
-
* The same data will be available either way, but they will be rendered differently in the UI.
|
|
2201
|
-
*
|
|
2202
|
-
* Includes metadata about the duration of the recording in seconds, where available.
|
|
2203
|
-
*
|
|
2204
|
-
* Voice recordings done in the TalkJS UI will always include the duration.
|
|
2205
|
-
* Voice recording that you upload with the REST API or {@link Session.uploadVoice} will include this metadata if you specified it when uploading.
|
|
2206
|
-
*
|
|
2207
|
-
* Voice recordings will never be taken from a reply to an email notification.
|
|
2208
|
-
* Any attached audio file will become an {@link AudioBlock} instead of a voice block.
|
|
2209
|
-
*
|
|
2210
|
-
* @public
|
|
2211
|
-
*/
|
|
2212
|
-
export declare interface VoiceBlock {
|
|
2213
|
-
type: "file";
|
|
2214
|
-
|
|
2215
|
-
subtype: "voice";
|
|
2216
|
-
|
|
2217
|
-
/**
|
|
2218
|
-
* An encoded identifier for this file. Use in {@link SendFileBlock} to send this voice recording in another message.
|
|
2219
|
-
*/
|
|
2220
|
-
fileToken: FileToken;
|
|
2221
|
-
|
|
2222
|
-
/**
|
|
2223
|
-
* The URL where you can fetch the file
|
|
2224
|
-
*/
|
|
2225
|
-
url: string;
|
|
2226
|
-
|
|
2227
|
-
/**
|
|
2228
|
-
* The size of the file in bytes
|
|
2229
|
-
*/
|
|
2230
|
-
size: number;
|
|
2231
|
-
|
|
2232
|
-
/**
|
|
2233
|
-
* The name of the file, including file extension
|
|
2234
|
-
*/
|
|
2235
|
-
filename: string;
|
|
2236
|
-
|
|
2237
|
-
/**
|
|
2238
|
-
* The duration of the voice recording in seconds, if known
|
|
2239
|
-
*/
|
|
2240
|
-
duration?: number;
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
declare interface VoiceRecordingFileMetadata {
|
|
2244
|
-
/**
|
|
2245
|
-
* The name of the file including extension.
|
|
2246
|
-
*/
|
|
2247
|
-
filename: string;
|
|
2248
|
-
/**
|
|
2249
|
-
* The duration of the recording in seconds, if known.
|
|
2250
|
-
*/
|
|
2251
|
-
duration?: number;
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
export { }
|