@liveblocks/emails 0.0.1 → 2.9.3-emails1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/dist/index.d.mts +215 -0
- package/dist/index.d.ts +215 -0
- package/dist/index.js +638 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +638 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +42 -2
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://liveblocks.io#gh-light-mode-only">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-light.svg" alt="Liveblocks" />
|
|
4
|
+
</a>
|
|
5
|
+
<a href="https://liveblocks.io#gh-dark-mode-only">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-dark.svg" alt="Liveblocks" />
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
# `@liveblocks/emails`
|
|
11
|
+
|
|
12
|
+
<p>
|
|
13
|
+
<a href="https://npmjs.org/package/@liveblocks/emails">
|
|
14
|
+
<img src="https://img.shields.io/npm/v/@liveblocks/emails?style=flat&label=npm&color=c33" alt="NPM" />
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://bundlephobia.com/package/@liveblocks/emails">
|
|
17
|
+
<img src="https://img.shields.io/bundlephobia/minzip/@liveblocks/emails?style=flat&label=size&color=09f" alt="Size" />
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/liveblocks/liveblocks/blob/main/LICENSE">
|
|
20
|
+
<img src="https://img.shields.io/github/license/liveblocks/liveblocks?style=flat&label=license&color=f80" alt="License" />
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
`@liveblocks/emails` provides a set of functions and utilities to make sending
|
|
25
|
+
emails based on [Liveblocks](https://liveblocks.io) notifications events easy.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npm install @liveblocks/node @liveblocks/emails
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
## Releases
|
|
42
|
+
|
|
43
|
+
See the [latest changes](https://github.com/liveblocks/liveblocks/releases) or
|
|
44
|
+
learn more about
|
|
45
|
+
[upcoming releases](https://github.com/liveblocks/liveblocks/milestones).
|
|
46
|
+
|
|
47
|
+
## Community
|
|
48
|
+
|
|
49
|
+
- [Discord](https://liveblocks.io/discord) - To get involved with the Liveblocks
|
|
50
|
+
community, ask questions and share tips.
|
|
51
|
+
- [X](https://x.com/liveblocks) - To receive updates, announcements, blog posts,
|
|
52
|
+
and general Liveblocks tips.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
Licensed under the Apache License 2.0, Copyright © 2021-present
|
|
57
|
+
[Liveblocks](https://liveblocks.io).
|
|
58
|
+
|
|
59
|
+
See [LICENSE](../../LICENSE) for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise, CommentBody, DRI } from '@liveblocks/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Properties } from 'csstype';
|
|
4
|
+
import { Liveblocks, ThreadNotificationEvent } from '@liveblocks/node';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CSS properties object.
|
|
8
|
+
* Type alias for DX purposes.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
declare type CSSProperties = Properties;
|
|
12
|
+
|
|
13
|
+
declare type CommentBodyContainerComponentProps = {
|
|
14
|
+
/**
|
|
15
|
+
* The blocks of the comment body
|
|
16
|
+
*/
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
};
|
|
19
|
+
declare type CommentBodyParagraphComponentProps = {
|
|
20
|
+
/**
|
|
21
|
+
* The text content of the paragraph.
|
|
22
|
+
*/
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
declare type CommentBodyTextComponentProps = {
|
|
26
|
+
/**
|
|
27
|
+
* The text element.
|
|
28
|
+
*/
|
|
29
|
+
element: CommentBodyText;
|
|
30
|
+
};
|
|
31
|
+
declare type CommentBodyLinkComponentProps = {
|
|
32
|
+
/**
|
|
33
|
+
* The link element.
|
|
34
|
+
*/
|
|
35
|
+
element: CommentBodyLink;
|
|
36
|
+
/**
|
|
37
|
+
* The absolute URL of the link.
|
|
38
|
+
*/
|
|
39
|
+
href: string;
|
|
40
|
+
};
|
|
41
|
+
declare type CommentBodyMentionComponentProps<U extends BaseUserMeta = DU> = {
|
|
42
|
+
/**
|
|
43
|
+
* The mention element.
|
|
44
|
+
*/
|
|
45
|
+
element: CommentBodyMention;
|
|
46
|
+
/**
|
|
47
|
+
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
48
|
+
*/
|
|
49
|
+
user?: U["info"];
|
|
50
|
+
};
|
|
51
|
+
declare type ConvertCommentBodyAsReactComponents<U extends BaseUserMeta = DU> = {
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* The component used to act as a container to wrap comment body blocks,
|
|
55
|
+
*/
|
|
56
|
+
Container: React.ComponentType<CommentBodyContainerComponentProps>;
|
|
57
|
+
/**
|
|
58
|
+
* The component used to display paragraphs.
|
|
59
|
+
*/
|
|
60
|
+
Paragraph: React.ComponentType<CommentBodyParagraphComponentProps>;
|
|
61
|
+
/**
|
|
62
|
+
* The component used to display text elements.
|
|
63
|
+
*/
|
|
64
|
+
Text: React.ComponentType<CommentBodyTextComponentProps>;
|
|
65
|
+
/**
|
|
66
|
+
* The component used to display links.
|
|
67
|
+
*/
|
|
68
|
+
Link: React.ComponentType<CommentBodyLinkComponentProps>;
|
|
69
|
+
/**
|
|
70
|
+
* The component used to display mentions.
|
|
71
|
+
*/
|
|
72
|
+
Mention: React.ComponentType<CommentBodyMentionComponentProps<U>>;
|
|
73
|
+
};
|
|
74
|
+
declare type ConvertCommentBodyAsHtmlStyles = {
|
|
75
|
+
/**
|
|
76
|
+
* The default inline CSS styles used to display paragraphs.
|
|
77
|
+
*/
|
|
78
|
+
paragraph: CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* The default inline CSS styles used to display text `<strong />` elements.
|
|
81
|
+
*/
|
|
82
|
+
strong: CSSProperties;
|
|
83
|
+
/**
|
|
84
|
+
* The default inline CSS styles used to display text `<code />` elements.
|
|
85
|
+
*/
|
|
86
|
+
code: CSSProperties;
|
|
87
|
+
/**
|
|
88
|
+
* The default inline CSS styles used to display links.
|
|
89
|
+
*/
|
|
90
|
+
mention: CSSProperties;
|
|
91
|
+
/**
|
|
92
|
+
* The default inline CSS styles used to display mentions.
|
|
93
|
+
*/
|
|
94
|
+
link: CSSProperties;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare type CommentEmailBaseData = {
|
|
98
|
+
id: string;
|
|
99
|
+
threadId: string;
|
|
100
|
+
roomId: string;
|
|
101
|
+
userId: string;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
url?: string;
|
|
104
|
+
rawBody: CommentBody;
|
|
105
|
+
};
|
|
106
|
+
declare type ResolveRoomInfoArgs = {
|
|
107
|
+
/**
|
|
108
|
+
* The ID of the room to resolve
|
|
109
|
+
*/
|
|
110
|
+
roomId: string;
|
|
111
|
+
};
|
|
112
|
+
declare type PrepareThreadNotificationEmailBaseDataOptions = {
|
|
113
|
+
/**
|
|
114
|
+
* A function that returns room info from room IDs.
|
|
115
|
+
*/
|
|
116
|
+
resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
|
|
117
|
+
};
|
|
118
|
+
declare type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<CommentEmailBaseData, "userId" | "rawBody"> & {
|
|
119
|
+
author: U;
|
|
120
|
+
htmlBody: string;
|
|
121
|
+
};
|
|
122
|
+
declare type CommentEmailAsReactData<U extends BaseUserMeta = DU> = Omit<CommentEmailBaseData, "userId" | "rawBody"> & {
|
|
123
|
+
author: U;
|
|
124
|
+
reactBody: React.ReactNode;
|
|
125
|
+
};
|
|
126
|
+
declare type ThreadNotificationEmailUnreadRepliesData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = {
|
|
127
|
+
type: "unreadReplies";
|
|
128
|
+
comments: C[];
|
|
129
|
+
};
|
|
130
|
+
declare type ThreadNotificationEmailUnreadMentionsData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = {
|
|
131
|
+
type: "unreadMention";
|
|
132
|
+
comment: C;
|
|
133
|
+
};
|
|
134
|
+
declare type ThreadNotificationEmailData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = (ThreadNotificationEmailUnreadRepliesData<U, C> | ThreadNotificationEmailUnreadMentionsData<U, C>) & {
|
|
135
|
+
roomInfo: DRI;
|
|
136
|
+
};
|
|
137
|
+
declare type PrepareThreadNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailBaseDataOptions & {
|
|
138
|
+
/**
|
|
139
|
+
* A function that returns info from user IDs.
|
|
140
|
+
*/
|
|
141
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
142
|
+
/**
|
|
143
|
+
* The styles used to customize the html elements in the resulting html safe string inside a comment body.
|
|
144
|
+
* Each styles has priority over the base styles inherited.
|
|
145
|
+
*/
|
|
146
|
+
styles?: Partial<ConvertCommentBodyAsHtmlStyles>;
|
|
147
|
+
};
|
|
148
|
+
declare type ThreadNotificationEmailDataAsHtml = ThreadNotificationEmailData<BaseUserMeta, CommentEmailAsHtmlData>;
|
|
149
|
+
/**
|
|
150
|
+
* Prepares data from a `ThreadNotificationEvent` and convert comment bodies as an html safe string.
|
|
151
|
+
*
|
|
152
|
+
* @param client The `Liveblocks` node client
|
|
153
|
+
* @param event The `ThreadNotificationEvent` received in the webhook handler
|
|
154
|
+
* @param options The optional options to provide to resolve users, resolve room info
|
|
155
|
+
* and customize comment bodies html elements styles with inline CSS.
|
|
156
|
+
*
|
|
157
|
+
* It returns a `ThreadNotificationEmailDataAsHtml` or `null` if there are no unread comments (mention or replies).
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
161
|
+
* import { prepareThreadNotificationEmailAsHtml } from "@liveblocks/emails"
|
|
162
|
+
*
|
|
163
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
164
|
+
* const emailData = prepareThreadNotificationEmailAsHtml(
|
|
165
|
+
* liveblocks,
|
|
166
|
+
* event,
|
|
167
|
+
* {
|
|
168
|
+
* resolveUsers,
|
|
169
|
+
* resolveRoomInfo,
|
|
170
|
+
* styles,
|
|
171
|
+
* }
|
|
172
|
+
* )
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
|
|
176
|
+
declare type PrepareThreadNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailBaseDataOptions & {
|
|
177
|
+
/**
|
|
178
|
+
* A function that returns info from user IDs.
|
|
179
|
+
*/
|
|
180
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
181
|
+
/**
|
|
182
|
+
* The components used to customize the resulting React nodes inside a comment body.
|
|
183
|
+
* Each components has priority over the base components inherited internally defined.
|
|
184
|
+
*/
|
|
185
|
+
components?: Partial<ConvertCommentBodyAsReactComponents<U>>;
|
|
186
|
+
};
|
|
187
|
+
declare type ThreadNotificationEmailDataAsReact = ThreadNotificationEmailData<BaseUserMeta, CommentEmailAsReactData>;
|
|
188
|
+
/**
|
|
189
|
+
* Prepares data from a `ThreadNotificationEvent` and convert comment bodies as React nodes.
|
|
190
|
+
*
|
|
191
|
+
* @param client The `Liveblocks` node client
|
|
192
|
+
* @param event The `ThreadNotificationEvent` received in the webhook handler
|
|
193
|
+
* @param options The optional options to provide to resolve users, resolve room info and customize comment bodies React components.
|
|
194
|
+
*
|
|
195
|
+
* It returns a `ThreadNotificationEmailDataAsReact` or `null` if there are no unread comments (mention or replies).
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
199
|
+
* import { prepareThreadNotificationEmailAsReact } from "@liveblocks/emails"
|
|
200
|
+
*
|
|
201
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
202
|
+
* const emailData = prepareThreadNotificationEmailAsReact(
|
|
203
|
+
* liveblocks,
|
|
204
|
+
* event,
|
|
205
|
+
* {
|
|
206
|
+
* resolveUsers,
|
|
207
|
+
* resolveRoomInfo,
|
|
208
|
+
* components,
|
|
209
|
+
* }
|
|
210
|
+
* )
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
declare function prepareThreadNotificationEmailAsReact(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsReactOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsReact | null>;
|
|
214
|
+
|
|
215
|
+
export { type CommentBodyContainerComponentProps, type CommentBodyLinkComponentProps, type CommentBodyMentionComponentProps, type CommentBodyParagraphComponentProps, type CommentBodyTextComponentProps, type CommentEmailAsHtmlData, type CommentEmailAsReactData, type ConvertCommentBodyAsHtmlStyles, type ConvertCommentBodyAsReactComponents, type PrepareThreadNotificationEmailAsHtmlOptions, type PrepareThreadNotificationEmailAsReactOptions, type ResolveRoomInfoArgs, type ThreadNotificationEmailDataAsHtml, type ThreadNotificationEmailDataAsReact, prepareThreadNotificationEmailAsHtml, prepareThreadNotificationEmailAsReact };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise, CommentBody, DRI } from '@liveblocks/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Properties } from 'csstype';
|
|
4
|
+
import { Liveblocks, ThreadNotificationEvent } from '@liveblocks/node';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CSS properties object.
|
|
8
|
+
* Type alias for DX purposes.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
declare type CSSProperties = Properties;
|
|
12
|
+
|
|
13
|
+
declare type CommentBodyContainerComponentProps = {
|
|
14
|
+
/**
|
|
15
|
+
* The blocks of the comment body
|
|
16
|
+
*/
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
};
|
|
19
|
+
declare type CommentBodyParagraphComponentProps = {
|
|
20
|
+
/**
|
|
21
|
+
* The text content of the paragraph.
|
|
22
|
+
*/
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
declare type CommentBodyTextComponentProps = {
|
|
26
|
+
/**
|
|
27
|
+
* The text element.
|
|
28
|
+
*/
|
|
29
|
+
element: CommentBodyText;
|
|
30
|
+
};
|
|
31
|
+
declare type CommentBodyLinkComponentProps = {
|
|
32
|
+
/**
|
|
33
|
+
* The link element.
|
|
34
|
+
*/
|
|
35
|
+
element: CommentBodyLink;
|
|
36
|
+
/**
|
|
37
|
+
* The absolute URL of the link.
|
|
38
|
+
*/
|
|
39
|
+
href: string;
|
|
40
|
+
};
|
|
41
|
+
declare type CommentBodyMentionComponentProps<U extends BaseUserMeta = DU> = {
|
|
42
|
+
/**
|
|
43
|
+
* The mention element.
|
|
44
|
+
*/
|
|
45
|
+
element: CommentBodyMention;
|
|
46
|
+
/**
|
|
47
|
+
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
48
|
+
*/
|
|
49
|
+
user?: U["info"];
|
|
50
|
+
};
|
|
51
|
+
declare type ConvertCommentBodyAsReactComponents<U extends BaseUserMeta = DU> = {
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* The component used to act as a container to wrap comment body blocks,
|
|
55
|
+
*/
|
|
56
|
+
Container: React.ComponentType<CommentBodyContainerComponentProps>;
|
|
57
|
+
/**
|
|
58
|
+
* The component used to display paragraphs.
|
|
59
|
+
*/
|
|
60
|
+
Paragraph: React.ComponentType<CommentBodyParagraphComponentProps>;
|
|
61
|
+
/**
|
|
62
|
+
* The component used to display text elements.
|
|
63
|
+
*/
|
|
64
|
+
Text: React.ComponentType<CommentBodyTextComponentProps>;
|
|
65
|
+
/**
|
|
66
|
+
* The component used to display links.
|
|
67
|
+
*/
|
|
68
|
+
Link: React.ComponentType<CommentBodyLinkComponentProps>;
|
|
69
|
+
/**
|
|
70
|
+
* The component used to display mentions.
|
|
71
|
+
*/
|
|
72
|
+
Mention: React.ComponentType<CommentBodyMentionComponentProps<U>>;
|
|
73
|
+
};
|
|
74
|
+
declare type ConvertCommentBodyAsHtmlStyles = {
|
|
75
|
+
/**
|
|
76
|
+
* The default inline CSS styles used to display paragraphs.
|
|
77
|
+
*/
|
|
78
|
+
paragraph: CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* The default inline CSS styles used to display text `<strong />` elements.
|
|
81
|
+
*/
|
|
82
|
+
strong: CSSProperties;
|
|
83
|
+
/**
|
|
84
|
+
* The default inline CSS styles used to display text `<code />` elements.
|
|
85
|
+
*/
|
|
86
|
+
code: CSSProperties;
|
|
87
|
+
/**
|
|
88
|
+
* The default inline CSS styles used to display links.
|
|
89
|
+
*/
|
|
90
|
+
mention: CSSProperties;
|
|
91
|
+
/**
|
|
92
|
+
* The default inline CSS styles used to display mentions.
|
|
93
|
+
*/
|
|
94
|
+
link: CSSProperties;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare type CommentEmailBaseData = {
|
|
98
|
+
id: string;
|
|
99
|
+
threadId: string;
|
|
100
|
+
roomId: string;
|
|
101
|
+
userId: string;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
url?: string;
|
|
104
|
+
rawBody: CommentBody;
|
|
105
|
+
};
|
|
106
|
+
declare type ResolveRoomInfoArgs = {
|
|
107
|
+
/**
|
|
108
|
+
* The ID of the room to resolve
|
|
109
|
+
*/
|
|
110
|
+
roomId: string;
|
|
111
|
+
};
|
|
112
|
+
declare type PrepareThreadNotificationEmailBaseDataOptions = {
|
|
113
|
+
/**
|
|
114
|
+
* A function that returns room info from room IDs.
|
|
115
|
+
*/
|
|
116
|
+
resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
|
|
117
|
+
};
|
|
118
|
+
declare type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<CommentEmailBaseData, "userId" | "rawBody"> & {
|
|
119
|
+
author: U;
|
|
120
|
+
htmlBody: string;
|
|
121
|
+
};
|
|
122
|
+
declare type CommentEmailAsReactData<U extends BaseUserMeta = DU> = Omit<CommentEmailBaseData, "userId" | "rawBody"> & {
|
|
123
|
+
author: U;
|
|
124
|
+
reactBody: React.ReactNode;
|
|
125
|
+
};
|
|
126
|
+
declare type ThreadNotificationEmailUnreadRepliesData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = {
|
|
127
|
+
type: "unreadReplies";
|
|
128
|
+
comments: C[];
|
|
129
|
+
};
|
|
130
|
+
declare type ThreadNotificationEmailUnreadMentionsData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = {
|
|
131
|
+
type: "unreadMention";
|
|
132
|
+
comment: C;
|
|
133
|
+
};
|
|
134
|
+
declare type ThreadNotificationEmailData<U extends BaseUserMeta, C extends CommentEmailAsHtmlData<U> | CommentEmailAsReactData<U>> = (ThreadNotificationEmailUnreadRepliesData<U, C> | ThreadNotificationEmailUnreadMentionsData<U, C>) & {
|
|
135
|
+
roomInfo: DRI;
|
|
136
|
+
};
|
|
137
|
+
declare type PrepareThreadNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailBaseDataOptions & {
|
|
138
|
+
/**
|
|
139
|
+
* A function that returns info from user IDs.
|
|
140
|
+
*/
|
|
141
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
142
|
+
/**
|
|
143
|
+
* The styles used to customize the html elements in the resulting html safe string inside a comment body.
|
|
144
|
+
* Each styles has priority over the base styles inherited.
|
|
145
|
+
*/
|
|
146
|
+
styles?: Partial<ConvertCommentBodyAsHtmlStyles>;
|
|
147
|
+
};
|
|
148
|
+
declare type ThreadNotificationEmailDataAsHtml = ThreadNotificationEmailData<BaseUserMeta, CommentEmailAsHtmlData>;
|
|
149
|
+
/**
|
|
150
|
+
* Prepares data from a `ThreadNotificationEvent` and convert comment bodies as an html safe string.
|
|
151
|
+
*
|
|
152
|
+
* @param client The `Liveblocks` node client
|
|
153
|
+
* @param event The `ThreadNotificationEvent` received in the webhook handler
|
|
154
|
+
* @param options The optional options to provide to resolve users, resolve room info
|
|
155
|
+
* and customize comment bodies html elements styles with inline CSS.
|
|
156
|
+
*
|
|
157
|
+
* It returns a `ThreadNotificationEmailDataAsHtml` or `null` if there are no unread comments (mention or replies).
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
161
|
+
* import { prepareThreadNotificationEmailAsHtml } from "@liveblocks/emails"
|
|
162
|
+
*
|
|
163
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
164
|
+
* const emailData = prepareThreadNotificationEmailAsHtml(
|
|
165
|
+
* liveblocks,
|
|
166
|
+
* event,
|
|
167
|
+
* {
|
|
168
|
+
* resolveUsers,
|
|
169
|
+
* resolveRoomInfo,
|
|
170
|
+
* styles,
|
|
171
|
+
* }
|
|
172
|
+
* )
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
declare function prepareThreadNotificationEmailAsHtml(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsHtml | null>;
|
|
176
|
+
declare type PrepareThreadNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareThreadNotificationEmailBaseDataOptions & {
|
|
177
|
+
/**
|
|
178
|
+
* A function that returns info from user IDs.
|
|
179
|
+
*/
|
|
180
|
+
resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
|
|
181
|
+
/**
|
|
182
|
+
* The components used to customize the resulting React nodes inside a comment body.
|
|
183
|
+
* Each components has priority over the base components inherited internally defined.
|
|
184
|
+
*/
|
|
185
|
+
components?: Partial<ConvertCommentBodyAsReactComponents<U>>;
|
|
186
|
+
};
|
|
187
|
+
declare type ThreadNotificationEmailDataAsReact = ThreadNotificationEmailData<BaseUserMeta, CommentEmailAsReactData>;
|
|
188
|
+
/**
|
|
189
|
+
* Prepares data from a `ThreadNotificationEvent` and convert comment bodies as React nodes.
|
|
190
|
+
*
|
|
191
|
+
* @param client The `Liveblocks` node client
|
|
192
|
+
* @param event The `ThreadNotificationEvent` received in the webhook handler
|
|
193
|
+
* @param options The optional options to provide to resolve users, resolve room info and customize comment bodies React components.
|
|
194
|
+
*
|
|
195
|
+
* It returns a `ThreadNotificationEmailDataAsReact` or `null` if there are no unread comments (mention or replies).
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* import { Liveblocks} from "@liveblocks/node"
|
|
199
|
+
* import { prepareThreadNotificationEmailAsReact } from "@liveblocks/emails"
|
|
200
|
+
*
|
|
201
|
+
* const liveblocks = new Liveblocks({ secret: "sk_..." })
|
|
202
|
+
* const emailData = prepareThreadNotificationEmailAsReact(
|
|
203
|
+
* liveblocks,
|
|
204
|
+
* event,
|
|
205
|
+
* {
|
|
206
|
+
* resolveUsers,
|
|
207
|
+
* resolveRoomInfo,
|
|
208
|
+
* components,
|
|
209
|
+
* }
|
|
210
|
+
* )
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
declare function prepareThreadNotificationEmailAsReact(client: Liveblocks, event: ThreadNotificationEvent, options?: PrepareThreadNotificationEmailAsReactOptions<BaseUserMeta>): Promise<ThreadNotificationEmailDataAsReact | null>;
|
|
214
|
+
|
|
215
|
+
export { type CommentBodyContainerComponentProps, type CommentBodyLinkComponentProps, type CommentBodyMentionComponentProps, type CommentBodyParagraphComponentProps, type CommentBodyTextComponentProps, type CommentEmailAsHtmlData, type CommentEmailAsReactData, type ConvertCommentBodyAsHtmlStyles, type ConvertCommentBodyAsReactComponents, type PrepareThreadNotificationEmailAsHtmlOptions, type PrepareThreadNotificationEmailAsReactOptions, type ResolveRoomInfoArgs, type ThreadNotificationEmailDataAsHtml, type ThreadNotificationEmailDataAsReact, prepareThreadNotificationEmailAsHtml, prepareThreadNotificationEmailAsReact };
|