@liveblocks/emails 2.20.0 → 2.21.0-emails2
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/dist/index.cjs +198 -259
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +190 -120
- package/dist/index.d.ts +190 -120
- package/dist/index.js +199 -260
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,100 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseUserMeta, DU, ResolveUsersArgs, Awaitable, DRI, CommentBodyParagraph, CommentBodyText, CommentBodyLink, CommentBodyMention } from '@liveblocks/core';
|
|
2
2
|
export { ResolveUsersArgs } from '@liveblocks/core';
|
|
3
3
|
import { ReactNode, ComponentType } from 'react';
|
|
4
4
|
import { Properties } from 'csstype';
|
|
5
5
|
import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* CSS properties object.
|
|
9
|
-
* Type alias for DX purposes.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
type CSSProperties = Properties;
|
|
13
|
-
|
|
14
|
-
type CommentBodyContainerComponentProps = {
|
|
15
|
-
/**
|
|
16
|
-
* The blocks of the comment body
|
|
17
|
-
*/
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
};
|
|
20
|
-
type CommentBodyParagraphComponentProps = {
|
|
21
|
-
/**
|
|
22
|
-
* The text content of the paragraph.
|
|
23
|
-
*/
|
|
24
|
-
children: ReactNode;
|
|
25
|
-
};
|
|
26
|
-
type CommentBodyTextComponentProps = {
|
|
27
|
-
/**
|
|
28
|
-
* The text element.
|
|
29
|
-
*/
|
|
30
|
-
element: CommentBodyText;
|
|
31
|
-
};
|
|
32
|
-
type CommentBodyLinkComponentProps = {
|
|
33
|
-
/**
|
|
34
|
-
* The link element.
|
|
35
|
-
*/
|
|
36
|
-
element: CommentBodyLink;
|
|
37
|
-
/**
|
|
38
|
-
* The absolute URL of the link.
|
|
39
|
-
*/
|
|
40
|
-
href: string;
|
|
41
|
-
};
|
|
42
|
-
type CommentBodyMentionComponentProps<U extends BaseUserMeta = DU> = {
|
|
43
|
-
/**
|
|
44
|
-
* The mention element.
|
|
45
|
-
*/
|
|
46
|
-
element: CommentBodyMention;
|
|
47
|
-
/**
|
|
48
|
-
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
49
|
-
*/
|
|
50
|
-
user?: U["info"];
|
|
51
|
-
};
|
|
52
|
-
type ConvertCommentBodyAsReactComponents<U extends BaseUserMeta = DU> = {
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* The component used to act as a container to wrap comment body blocks,
|
|
56
|
-
*/
|
|
57
|
-
Container: ComponentType<CommentBodyContainerComponentProps>;
|
|
58
|
-
/**
|
|
59
|
-
* The component used to display paragraphs.
|
|
60
|
-
*/
|
|
61
|
-
Paragraph: ComponentType<CommentBodyParagraphComponentProps>;
|
|
62
|
-
/**
|
|
63
|
-
* The component used to display text elements.
|
|
64
|
-
*/
|
|
65
|
-
Text: ComponentType<CommentBodyTextComponentProps>;
|
|
66
|
-
/**
|
|
67
|
-
* The component used to display links.
|
|
68
|
-
*/
|
|
69
|
-
Link: ComponentType<CommentBodyLinkComponentProps>;
|
|
70
|
-
/**
|
|
71
|
-
* The component used to display mentions.
|
|
72
|
-
*/
|
|
73
|
-
Mention: ComponentType<CommentBodyMentionComponentProps<U>>;
|
|
74
|
-
};
|
|
75
|
-
type ConvertCommentBodyAsHtmlStyles = {
|
|
76
|
-
/**
|
|
77
|
-
* The default inline CSS styles used to display paragraphs.
|
|
78
|
-
*/
|
|
79
|
-
paragraph: CSSProperties;
|
|
80
|
-
/**
|
|
81
|
-
* The default inline CSS styles used to display text `<strong />` elements.
|
|
82
|
-
*/
|
|
83
|
-
strong: CSSProperties;
|
|
84
|
-
/**
|
|
85
|
-
* The default inline CSS styles used to display text `<code />` elements.
|
|
86
|
-
*/
|
|
87
|
-
code: CSSProperties;
|
|
88
|
-
/**
|
|
89
|
-
* The default inline CSS styles used to display links.
|
|
90
|
-
*/
|
|
91
|
-
mention: CSSProperties;
|
|
92
|
-
/**
|
|
93
|
-
* The default inline CSS styles used to display mentions.
|
|
94
|
-
*/
|
|
95
|
-
link: CSSProperties;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
7
|
type ResolveRoomInfoArgs = {
|
|
99
8
|
/**
|
|
100
9
|
* The ID of the room to resolve
|
|
@@ -102,6 +11,13 @@ type ResolveRoomInfoArgs = {
|
|
|
102
11
|
roomId: string;
|
|
103
12
|
};
|
|
104
13
|
|
|
14
|
+
/**
|
|
15
|
+
* CSS properties object.
|
|
16
|
+
* Type alias for DX purposes.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
type CSSProperties = Properties;
|
|
20
|
+
|
|
105
21
|
/**
|
|
106
22
|
* Liveblocks Text Editor
|
|
107
23
|
*
|
|
@@ -293,52 +209,149 @@ type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<B
|
|
|
293
209
|
*/
|
|
294
210
|
declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsHtml | null>;
|
|
295
211
|
|
|
296
|
-
type
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
createdAt: Date;
|
|
302
|
-
url?: string;
|
|
303
|
-
rawBody: CommentBody;
|
|
212
|
+
type CommentBodyContainerElementArgs<T> = {
|
|
213
|
+
/**
|
|
214
|
+
* The blocks of the comment body
|
|
215
|
+
*/
|
|
216
|
+
children: T[];
|
|
304
217
|
};
|
|
305
|
-
type
|
|
218
|
+
type CommentBodyParagraphElementArgs<T> = {
|
|
306
219
|
/**
|
|
307
|
-
*
|
|
220
|
+
* The paragraph element.
|
|
308
221
|
*/
|
|
309
|
-
|
|
222
|
+
element: CommentBodyParagraph;
|
|
223
|
+
/**
|
|
224
|
+
* The text content of the paragraph.
|
|
225
|
+
*/
|
|
226
|
+
children: T[];
|
|
310
227
|
};
|
|
311
|
-
type
|
|
312
|
-
|
|
313
|
-
|
|
228
|
+
type CommentBodyTextElementArgs = {
|
|
229
|
+
/**
|
|
230
|
+
* The text element.
|
|
231
|
+
*/
|
|
232
|
+
element: CommentBodyText;
|
|
233
|
+
};
|
|
234
|
+
type CommentBodyLinkElementArgs = {
|
|
235
|
+
/**
|
|
236
|
+
* The link element.
|
|
237
|
+
*/
|
|
238
|
+
element: CommentBodyLink;
|
|
239
|
+
/**
|
|
240
|
+
* The absolute URL of the link.
|
|
241
|
+
*/
|
|
242
|
+
href: string;
|
|
314
243
|
};
|
|
315
|
-
type
|
|
244
|
+
type CommentBodyMentionElementArgs<U extends BaseUserMeta = DU> = {
|
|
245
|
+
/**
|
|
246
|
+
* The mention element.
|
|
247
|
+
*/
|
|
248
|
+
element: CommentBodyMention;
|
|
249
|
+
/**
|
|
250
|
+
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
251
|
+
*/
|
|
252
|
+
user?: U["info"];
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Protocol:
|
|
256
|
+
* Comment body elements to be converted to a custom format `T`
|
|
257
|
+
*/
|
|
258
|
+
type ConvertCommentBodyElements<T, U extends BaseUserMeta = DU> = {
|
|
259
|
+
/**
|
|
260
|
+
* The container element used to display comment body blocks.
|
|
261
|
+
*/
|
|
262
|
+
container: (args: CommentBodyContainerElementArgs<T>) => T;
|
|
263
|
+
/**
|
|
264
|
+
* The paragraph element used to display paragraphs.
|
|
265
|
+
*/
|
|
266
|
+
paragraph: (args: CommentBodyParagraphElementArgs<T>, index: number) => T;
|
|
267
|
+
/**
|
|
268
|
+
* The text element used to display text elements.
|
|
269
|
+
*/
|
|
270
|
+
text: (args: CommentBodyTextElementArgs, index: number) => T;
|
|
271
|
+
/**
|
|
272
|
+
* The link element used to display links.
|
|
273
|
+
*/
|
|
274
|
+
link: (args: CommentBodyLinkElementArgs, index: number) => T;
|
|
275
|
+
/**
|
|
276
|
+
* The mention element used to display mentions.
|
|
277
|
+
*/
|
|
278
|
+
mention: (args: CommentBodyMentionElementArgs<U>, index: number) => T;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
type CommentEmailData<BodyType, U extends BaseUserMeta = DU> = {
|
|
282
|
+
id: string;
|
|
283
|
+
threadId: string;
|
|
284
|
+
roomId: string;
|
|
285
|
+
createdAt: Date;
|
|
286
|
+
url?: string;
|
|
316
287
|
author: U;
|
|
317
|
-
|
|
288
|
+
body: BodyType;
|
|
318
289
|
};
|
|
319
|
-
type
|
|
290
|
+
type ThreadNotificationEmailData<BodyType, U extends BaseUserMeta = DU, C extends CommentEmailData<BodyType, U> = CommentEmailData<BodyType, U>> = ({
|
|
320
291
|
type: "unreadReplies";
|
|
321
292
|
comments: C[];
|
|
322
|
-
}
|
|
323
|
-
type ThreadNotificationEmailUnreadMentionsData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = {
|
|
293
|
+
} | {
|
|
324
294
|
type: "unreadMention";
|
|
325
295
|
comment: C;
|
|
326
|
-
}
|
|
327
|
-
type ThreadNotificationEmailData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = (ThreadNotificationEmailUnreadRepliesData<U, C> | ThreadNotificationEmailUnreadMentionsData<U, C>) & {
|
|
296
|
+
}) & {
|
|
328
297
|
roomInfo: DRI;
|
|
329
298
|
};
|
|
330
|
-
type
|
|
299
|
+
type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = CommentEmailData<string, U> & {
|
|
300
|
+
/** @deprecated Use `body` property instead. */
|
|
301
|
+
htmlBody: string;
|
|
302
|
+
};
|
|
303
|
+
type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<ReactNode, U> & {
|
|
304
|
+
/** @deprecated Use `body` property instead. */
|
|
305
|
+
reactBody: ReactNode;
|
|
306
|
+
};
|
|
307
|
+
type PrepareThreadNotificationEmailOptions<BodyType, U extends BaseUserMeta = DU> = {
|
|
308
|
+
/**
|
|
309
|
+
* A function that returns room info from room IDs.
|
|
310
|
+
*/
|
|
311
|
+
resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
|
|
331
312
|
/**
|
|
332
313
|
* A function that returns info from user IDs.
|
|
333
314
|
*/
|
|
334
315
|
resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
|
|
316
|
+
/**
|
|
317
|
+
* Comments body elements customizations.
|
|
318
|
+
*/
|
|
319
|
+
elements: ConvertCommentBodyElements<BodyType, U>;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* The styles used to customize the html elements in the resulting html safe string.
|
|
323
|
+
* Each styles has priority over the base styles inherited.
|
|
324
|
+
*/
|
|
325
|
+
type ConvertCommentBodyAsHtmlStyles = {
|
|
326
|
+
/**
|
|
327
|
+
* The default inline CSS styles used to display paragraphs.
|
|
328
|
+
*/
|
|
329
|
+
paragraph: CSSProperties;
|
|
330
|
+
/**
|
|
331
|
+
* The default inline CSS styles used to display text `<strong />` elements.
|
|
332
|
+
*/
|
|
333
|
+
strong: CSSProperties;
|
|
334
|
+
/**
|
|
335
|
+
* The default inline CSS styles used to display text `<code />` elements.
|
|
336
|
+
*/
|
|
337
|
+
code: CSSProperties;
|
|
338
|
+
/**
|
|
339
|
+
* The default inline CSS styles used to display links.
|
|
340
|
+
*/
|
|
341
|
+
mention: CSSProperties;
|
|
342
|
+
/**
|
|
343
|
+
* The default inline CSS styles used to display mentions.
|
|
344
|
+
*/
|
|
345
|
+
link: CSSProperties;
|
|
346
|
+
};
|
|
347
|
+
type PrepareThreadNotificationEmailAsHtmlOptions<BodyType, U extends BaseUserMeta = DU> = Omit<PrepareThreadNotificationEmailOptions<BodyType, U>, "elements"> & {
|
|
335
348
|
/**
|
|
336
349
|
* The styles used to customize the html elements in the resulting html safe string inside a comment body.
|
|
337
350
|
* Each styles has priority over the base styles inherited.
|
|
338
351
|
*/
|
|
339
352
|
styles?: Partial<ConvertCommentBodyAsHtmlStyles>;
|
|
340
353
|
};
|
|
341
|
-
type ThreadNotificationEmailDataAsHtml = ThreadNotificationEmailData<
|
|
354
|
+
type ThreadNotificationEmailDataAsHtml<U extends BaseUserMeta = DU> = ThreadNotificationEmailData<string, U, CommentEmailAsHtmlData<U>>;
|
|
342
355
|
/**
|
|
343
356
|
* Prepares data from a `ThreadNotificationEvent` and convert comment bodies as an html safe string.
|
|
344
357
|
*
|
|
@@ -365,19 +378,76 @@ type ThreadNotificationEmailDataAsHtml = ThreadNotificationEmailData<BaseUserMet
|
|
|
365
378
|
* )
|
|
366
379
|
*
|
|
367
380
|
*/
|
|
368
|
-
declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
|
|
369
|
-
type
|
|
381
|
+
declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<string, BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
|
|
382
|
+
type CommentBodyContainerComponentProps = {
|
|
370
383
|
/**
|
|
371
|
-
*
|
|
384
|
+
* The blocks of the comment body
|
|
372
385
|
*/
|
|
373
|
-
|
|
386
|
+
children: ReactNode;
|
|
387
|
+
};
|
|
388
|
+
type CommentBodyParagraphComponentProps = {
|
|
389
|
+
/**
|
|
390
|
+
* The text content of the paragraph.
|
|
391
|
+
*/
|
|
392
|
+
children: ReactNode;
|
|
393
|
+
};
|
|
394
|
+
type CommentBodyTextComponentProps = {
|
|
395
|
+
/**
|
|
396
|
+
* The text element.
|
|
397
|
+
*/
|
|
398
|
+
element: CommentBodyText;
|
|
399
|
+
};
|
|
400
|
+
type CommentBodyLinkComponentProps = {
|
|
401
|
+
/**
|
|
402
|
+
* The link element.
|
|
403
|
+
*/
|
|
404
|
+
element: CommentBodyLink;
|
|
405
|
+
/**
|
|
406
|
+
* The absolute URL of the link.
|
|
407
|
+
*/
|
|
408
|
+
href: string;
|
|
409
|
+
};
|
|
410
|
+
type CommentBodyMentionComponentProps<U extends BaseUserMeta = DU> = {
|
|
411
|
+
/**
|
|
412
|
+
* The mention element.
|
|
413
|
+
*/
|
|
414
|
+
element: CommentBodyMention;
|
|
415
|
+
/**
|
|
416
|
+
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
417
|
+
*/
|
|
418
|
+
user?: U["info"];
|
|
419
|
+
};
|
|
420
|
+
type ConvertCommentBodyAsReactComponents<U extends BaseUserMeta = DU> = {
|
|
421
|
+
/**
|
|
422
|
+
*
|
|
423
|
+
* The component used to act as a container to wrap comment body blocks,
|
|
424
|
+
*/
|
|
425
|
+
Container: ComponentType<CommentBodyContainerComponentProps>;
|
|
426
|
+
/**
|
|
427
|
+
* The component used to display paragraphs.
|
|
428
|
+
*/
|
|
429
|
+
Paragraph: ComponentType<CommentBodyParagraphComponentProps>;
|
|
430
|
+
/**
|
|
431
|
+
* The component used to display text elements.
|
|
432
|
+
*/
|
|
433
|
+
Text: ComponentType<CommentBodyTextComponentProps>;
|
|
434
|
+
/**
|
|
435
|
+
* The component used to display links.
|
|
436
|
+
*/
|
|
437
|
+
Link: ComponentType<CommentBodyLinkComponentProps>;
|
|
438
|
+
/**
|
|
439
|
+
* The component used to display mentions.
|
|
440
|
+
*/
|
|
441
|
+
Mention: ComponentType<CommentBodyMentionComponentProps<U>>;
|
|
442
|
+
};
|
|
443
|
+
type PrepareThreadNotificationEmailAsReactOptions<BodyType, U extends BaseUserMeta = DU> = Omit<PrepareThreadNotificationEmailOptions<BodyType, U>, "elements"> & {
|
|
374
444
|
/**
|
|
375
445
|
* The components used to customize the resulting React nodes inside a comment body.
|
|
376
446
|
* Each components has priority over the base components inherited internally defined.
|
|
377
447
|
*/
|
|
378
448
|
components?: Partial<ConvertCommentBodyAsReactComponents<U>>;
|
|
379
449
|
};
|
|
380
|
-
type ThreadNotificationEmailDataAsReact = ThreadNotificationEmailData<
|
|
450
|
+
type ThreadNotificationEmailDataAsReact<U extends BaseUserMeta = DU> = ThreadNotificationEmailData<ReactNode, U, CommentEmailAsReactData<U>>;
|
|
381
451
|
/**
|
|
382
452
|
* Prepares data from a `ThreadNotificationEvent` and convert comment bodies as React nodes.
|
|
383
453
|
*
|