@liveblocks/emails 2.25.0-aiprivatebeta13 → 2.25.0-aiprivatebeta15

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.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { BaseUserMeta, DU, ResolveUsersArgs, Awaitable, DRI, CommentBodyText, CommentBodyLink, CommentBodyMention } from '@liveblocks/core';
1
+ import { Relax, BaseUserMeta, DU, MentionData, DRI, Awaitable, ResolveUsersArgs, CommentBodyText, CommentBodyLink, CommentBodyMention } from '@liveblocks/core';
2
2
  export { ResolveUsersArgs } from '@liveblocks/core';
3
+ import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
3
4
  import { ReactNode, ComponentType } from 'react';
4
5
  import { Properties } from 'csstype';
5
- import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
6
6
 
7
7
  type ResolveRoomInfoArgs = {
8
8
  /**
@@ -35,24 +35,36 @@ type LiveblocksTextEditorTextNode = {
35
35
  type: "text";
36
36
  text: string;
37
37
  } & LiveblocksTextEditorTextFormat;
38
- type LiveblocksTextEditorMentionNode = {
38
+ type LiveblocksTextEditorMentionNode = Relax<LiveblocksTextEditorUserMentionNode>;
39
+ type LiveblocksTextEditorUserMentionNode = {
39
40
  type: "mention";
40
- userId: string;
41
+ kind: "user";
42
+ id: string;
43
+ };
44
+
45
+ type MentionEmailData<ContentType, U extends BaseUserMeta = DU> = MentionData & {
46
+ textMentionId: string;
47
+ roomId: string;
48
+ author: U;
49
+ createdAt: Date;
50
+ content: ContentType;
51
+ };
52
+ type MentionEmailAsHtmlData<U extends BaseUserMeta = DU> = MentionEmailData<string, U>;
53
+ type MentionEmailAsReactData<U extends BaseUserMeta = DU> = MentionEmailData<ReactNode, U>;
54
+ type TextMentionNotificationEmailData<ContentType, U extends BaseUserMeta = DU, M extends MentionEmailData<ContentType, U> = MentionEmailData<ContentType, U>> = {
55
+ mention: M;
56
+ roomInfo: DRI;
57
+ };
58
+ type PrepareTextMentionNotificationEmailOptions<U extends BaseUserMeta = DU> = {
59
+ /**
60
+ * A function that returns room info from room IDs.
61
+ */
62
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
63
+ /**
64
+ * A function that returns info from user IDs.
65
+ */
66
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
41
67
  };
42
- /**
43
- * -------------------------------------------------------------------------------------------------
44
- * `LiveblocksTextEditorNode` is common structure to represents text editor nodes coming from
45
- * like `Lexical`, `TipTap` or so.
46
- *
47
- * This (simple) structure is made to be scalable and to accommodate with other text editors we could potentially
48
- * want to support in the future.
49
- *
50
- * It allows to manipulate nodes more easily and converts them with ease either as React nodes or as an html safe string.
51
- * From a DX standpoint it provides to developers the same structure to use when using custom React components or inline css
52
- * to represents a text mention with its surrounding text.
53
- * -------------------------------------------------------------------------------------------------
54
- */
55
- type LiveblocksTextEditorNode = LiveblocksTextEditorTextNode | LiveblocksTextEditorMentionNode;
56
68
  type TextEditorContainerComponentProps = {
57
69
  /**
58
70
  * The nodes of the text editor
@@ -90,62 +102,14 @@ type ConvertTextEditorNodesAsReactComponents<U extends BaseUserMeta = DU> = {
90
102
  */
91
103
  Text: ComponentType<TextEditorTextComponentProps>;
92
104
  };
93
- type ConvertTextEditorNodesAsHtmlStyles = {
94
- /**
95
- * The default inline CSS styles used to display container element.
96
- */
97
- container: CSSProperties;
98
- /**
99
- * The default inline CSS styles used to display text `<strong />` elements.
100
- */
101
- strong: CSSProperties;
102
- /**
103
- * The default inline CSS styles used to display text `<code />` elements.
104
- */
105
- code: CSSProperties;
106
- /**
107
- * The default inline CSS styles used to display mentions.
108
- */
109
- mention: CSSProperties;
110
- };
111
-
112
- type MentionEmailBaseData = {
113
- id: string;
114
- roomId: string;
115
- userId: string;
116
- textEditorNodes: LiveblocksTextEditorNode[];
117
- createdAt: Date;
118
- };
119
- type PrepareTextMentionNotificationEmailBaseDataOptions = {
120
- /**
121
- * A function that returns room info from room IDs.
122
- */
123
- resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
124
- };
125
- type MentionEmailAsReactData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
126
- author: U;
127
- reactContent: ReactNode;
128
- };
129
- type MentionEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
130
- author: U;
131
- htmlContent: string;
132
- };
133
- type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
134
- /**
135
- * A function that returns info from user IDs.
136
- */
137
- resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
105
+ type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailOptions & {
138
106
  /**
139
107
  * The components used to customize the resulting React nodes. Each components has
140
108
  * priority over the base components inherited.
141
109
  */
142
110
  components?: Partial<ConvertTextEditorNodesAsReactComponents<U>>;
143
111
  };
144
- type TextMentionNotificationEmailData<U extends BaseUserMeta, M extends MentionEmailAsReactData<U> | MentionEmailAsHtmlData<U>> = {
145
- mention: M;
146
- roomInfo: DRI;
147
- };
148
- type TextMentionNotificationEmailDataAsReact = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsReactData>;
112
+ type TextMentionNotificationEmailDataAsReact<U extends BaseUserMeta = DU> = TextMentionNotificationEmailData<ReactNode, U, MentionEmailAsReactData<U>>;
149
113
  /**
150
114
  * Prepares data from a `TextMentionNotificationEvent` and convert content as React nodes.
151
115
  *
@@ -171,18 +135,32 @@ type TextMentionNotificationEmailDataAsReact = TextMentionNotificationEmailData<
171
135
  * )
172
136
  */
173
137
  declare function prepareTextMentionNotificationEmailAsReact(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsReactOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsReact | null>;
174
- type PrepareTextMentionNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
138
+ type ConvertTextEditorNodesAsHtmlStyles = {
175
139
  /**
176
- * A function that returns info from user IDs.
140
+ * The default inline CSS styles used to display container element.
177
141
  */
178
- resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
142
+ container: CSSProperties;
143
+ /**
144
+ * The default inline CSS styles used to display text `<strong />` elements.
145
+ */
146
+ strong: CSSProperties;
147
+ /**
148
+ * The default inline CSS styles used to display text `<code />` elements.
149
+ */
150
+ code: CSSProperties;
151
+ /**
152
+ * The default inline CSS styles used to display mentions.
153
+ */
154
+ mention: CSSProperties;
155
+ };
156
+ type PrepareTextMentionNotificationEmailAsHtmlOptions = PrepareTextMentionNotificationEmailOptions & {
179
157
  /**
180
158
  * The styles used to customize the html elements in the resulting html safe string.
181
159
  * Each styles has priority over the base styles inherited.
182
160
  */
183
161
  styles?: Partial<ConvertTextEditorNodesAsHtmlStyles>;
184
162
  };
185
- type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsHtmlData>;
163
+ type TextMentionNotificationEmailDataAsHtml<U extends BaseUserMeta = DU> = TextMentionNotificationEmailData<string, U, MentionEmailAsHtmlData<U>>;
186
164
  /**
187
165
  * Prepares data from a `TextMentionNotificationEvent` and convert content as an html safe string.
188
166
  *
@@ -207,7 +185,7 @@ type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<B
207
185
  * }
208
186
  * )
209
187
  */
210
- declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsHtml | null>;
188
+ declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions): Promise<TextMentionNotificationEmailDataAsHtml | null>;
211
189
 
212
190
  type CommentEmailData<BodyType, U extends BaseUserMeta = DU> = {
213
191
  id: string;
@@ -227,14 +205,8 @@ type ThreadNotificationEmailData<BodyType, U extends BaseUserMeta = DU, C extend
227
205
  }) & {
228
206
  roomInfo: DRI;
229
207
  };
230
- type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = CommentEmailData<string, U> & {
231
- /** @deprecated Use `body` property instead. */
232
- htmlBody: string;
233
- };
234
- type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<ReactNode, U> & {
235
- /** @deprecated Use `body` property instead. */
236
- reactBody: ReactNode;
237
- };
208
+ type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = CommentEmailData<string, U>;
209
+ type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<ReactNode, U>;
238
210
  type PrepareThreadNotificationEmailOptions<U extends BaseUserMeta = DU> = {
239
211
  /**
240
212
  * A function that returns room info from room IDs.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { BaseUserMeta, DU, ResolveUsersArgs, Awaitable, DRI, CommentBodyText, CommentBodyLink, CommentBodyMention } from '@liveblocks/core';
1
+ import { Relax, BaseUserMeta, DU, MentionData, DRI, Awaitable, ResolveUsersArgs, CommentBodyText, CommentBodyLink, CommentBodyMention } from '@liveblocks/core';
2
2
  export { ResolveUsersArgs } from '@liveblocks/core';
3
+ import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
3
4
  import { ReactNode, ComponentType } from 'react';
4
5
  import { Properties } from 'csstype';
5
- import { Liveblocks, TextMentionNotificationEvent, ThreadNotificationEvent } from '@liveblocks/node';
6
6
 
7
7
  type ResolveRoomInfoArgs = {
8
8
  /**
@@ -35,24 +35,36 @@ type LiveblocksTextEditorTextNode = {
35
35
  type: "text";
36
36
  text: string;
37
37
  } & LiveblocksTextEditorTextFormat;
38
- type LiveblocksTextEditorMentionNode = {
38
+ type LiveblocksTextEditorMentionNode = Relax<LiveblocksTextEditorUserMentionNode>;
39
+ type LiveblocksTextEditorUserMentionNode = {
39
40
  type: "mention";
40
- userId: string;
41
+ kind: "user";
42
+ id: string;
43
+ };
44
+
45
+ type MentionEmailData<ContentType, U extends BaseUserMeta = DU> = MentionData & {
46
+ textMentionId: string;
47
+ roomId: string;
48
+ author: U;
49
+ createdAt: Date;
50
+ content: ContentType;
51
+ };
52
+ type MentionEmailAsHtmlData<U extends BaseUserMeta = DU> = MentionEmailData<string, U>;
53
+ type MentionEmailAsReactData<U extends BaseUserMeta = DU> = MentionEmailData<ReactNode, U>;
54
+ type TextMentionNotificationEmailData<ContentType, U extends BaseUserMeta = DU, M extends MentionEmailData<ContentType, U> = MentionEmailData<ContentType, U>> = {
55
+ mention: M;
56
+ roomInfo: DRI;
57
+ };
58
+ type PrepareTextMentionNotificationEmailOptions<U extends BaseUserMeta = DU> = {
59
+ /**
60
+ * A function that returns room info from room IDs.
61
+ */
62
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
63
+ /**
64
+ * A function that returns info from user IDs.
65
+ */
66
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
41
67
  };
42
- /**
43
- * -------------------------------------------------------------------------------------------------
44
- * `LiveblocksTextEditorNode` is common structure to represents text editor nodes coming from
45
- * like `Lexical`, `TipTap` or so.
46
- *
47
- * This (simple) structure is made to be scalable and to accommodate with other text editors we could potentially
48
- * want to support in the future.
49
- *
50
- * It allows to manipulate nodes more easily and converts them with ease either as React nodes or as an html safe string.
51
- * From a DX standpoint it provides to developers the same structure to use when using custom React components or inline css
52
- * to represents a text mention with its surrounding text.
53
- * -------------------------------------------------------------------------------------------------
54
- */
55
- type LiveblocksTextEditorNode = LiveblocksTextEditorTextNode | LiveblocksTextEditorMentionNode;
56
68
  type TextEditorContainerComponentProps = {
57
69
  /**
58
70
  * The nodes of the text editor
@@ -90,62 +102,14 @@ type ConvertTextEditorNodesAsReactComponents<U extends BaseUserMeta = DU> = {
90
102
  */
91
103
  Text: ComponentType<TextEditorTextComponentProps>;
92
104
  };
93
- type ConvertTextEditorNodesAsHtmlStyles = {
94
- /**
95
- * The default inline CSS styles used to display container element.
96
- */
97
- container: CSSProperties;
98
- /**
99
- * The default inline CSS styles used to display text `<strong />` elements.
100
- */
101
- strong: CSSProperties;
102
- /**
103
- * The default inline CSS styles used to display text `<code />` elements.
104
- */
105
- code: CSSProperties;
106
- /**
107
- * The default inline CSS styles used to display mentions.
108
- */
109
- mention: CSSProperties;
110
- };
111
-
112
- type MentionEmailBaseData = {
113
- id: string;
114
- roomId: string;
115
- userId: string;
116
- textEditorNodes: LiveblocksTextEditorNode[];
117
- createdAt: Date;
118
- };
119
- type PrepareTextMentionNotificationEmailBaseDataOptions = {
120
- /**
121
- * A function that returns room info from room IDs.
122
- */
123
- resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
124
- };
125
- type MentionEmailAsReactData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
126
- author: U;
127
- reactContent: ReactNode;
128
- };
129
- type MentionEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
130
- author: U;
131
- htmlContent: string;
132
- };
133
- type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
134
- /**
135
- * A function that returns info from user IDs.
136
- */
137
- resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
105
+ type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailOptions & {
138
106
  /**
139
107
  * The components used to customize the resulting React nodes. Each components has
140
108
  * priority over the base components inherited.
141
109
  */
142
110
  components?: Partial<ConvertTextEditorNodesAsReactComponents<U>>;
143
111
  };
144
- type TextMentionNotificationEmailData<U extends BaseUserMeta, M extends MentionEmailAsReactData<U> | MentionEmailAsHtmlData<U>> = {
145
- mention: M;
146
- roomInfo: DRI;
147
- };
148
- type TextMentionNotificationEmailDataAsReact = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsReactData>;
112
+ type TextMentionNotificationEmailDataAsReact<U extends BaseUserMeta = DU> = TextMentionNotificationEmailData<ReactNode, U, MentionEmailAsReactData<U>>;
149
113
  /**
150
114
  * Prepares data from a `TextMentionNotificationEvent` and convert content as React nodes.
151
115
  *
@@ -171,18 +135,32 @@ type TextMentionNotificationEmailDataAsReact = TextMentionNotificationEmailData<
171
135
  * )
172
136
  */
173
137
  declare function prepareTextMentionNotificationEmailAsReact(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsReactOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsReact | null>;
174
- type PrepareTextMentionNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> = PrepareTextMentionNotificationEmailBaseDataOptions & {
138
+ type ConvertTextEditorNodesAsHtmlStyles = {
175
139
  /**
176
- * A function that returns info from user IDs.
140
+ * The default inline CSS styles used to display container element.
177
141
  */
178
- resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
142
+ container: CSSProperties;
143
+ /**
144
+ * The default inline CSS styles used to display text `<strong />` elements.
145
+ */
146
+ strong: CSSProperties;
147
+ /**
148
+ * The default inline CSS styles used to display text `<code />` elements.
149
+ */
150
+ code: CSSProperties;
151
+ /**
152
+ * The default inline CSS styles used to display mentions.
153
+ */
154
+ mention: CSSProperties;
155
+ };
156
+ type PrepareTextMentionNotificationEmailAsHtmlOptions = PrepareTextMentionNotificationEmailOptions & {
179
157
  /**
180
158
  * The styles used to customize the html elements in the resulting html safe string.
181
159
  * Each styles has priority over the base styles inherited.
182
160
  */
183
161
  styles?: Partial<ConvertTextEditorNodesAsHtmlStyles>;
184
162
  };
185
- type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<BaseUserMeta, MentionEmailAsHtmlData>;
163
+ type TextMentionNotificationEmailDataAsHtml<U extends BaseUserMeta = DU> = TextMentionNotificationEmailData<string, U, MentionEmailAsHtmlData<U>>;
186
164
  /**
187
165
  * Prepares data from a `TextMentionNotificationEvent` and convert content as an html safe string.
188
166
  *
@@ -207,7 +185,7 @@ type TextMentionNotificationEmailDataAsHtml = TextMentionNotificationEmailData<B
207
185
  * }
208
186
  * )
209
187
  */
210
- declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions<BaseUserMeta>): Promise<TextMentionNotificationEmailDataAsHtml | null>;
188
+ declare function prepareTextMentionNotificationEmailAsHtml(client: Liveblocks, event: TextMentionNotificationEvent, options?: PrepareTextMentionNotificationEmailAsHtmlOptions): Promise<TextMentionNotificationEmailDataAsHtml | null>;
211
189
 
212
190
  type CommentEmailData<BodyType, U extends BaseUserMeta = DU> = {
213
191
  id: string;
@@ -227,14 +205,8 @@ type ThreadNotificationEmailData<BodyType, U extends BaseUserMeta = DU, C extend
227
205
  }) & {
228
206
  roomInfo: DRI;
229
207
  };
230
- type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = CommentEmailData<string, U> & {
231
- /** @deprecated Use `body` property instead. */
232
- htmlBody: string;
233
- };
234
- type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<ReactNode, U> & {
235
- /** @deprecated Use `body` property instead. */
236
- reactBody: ReactNode;
237
- };
208
+ type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = CommentEmailData<string, U>;
209
+ type CommentEmailAsReactData<U extends BaseUserMeta = DU> = CommentEmailData<ReactNode, U>;
238
210
  type PrepareThreadNotificationEmailOptions<U extends BaseUserMeta = DU> = {
239
211
  /**
240
212
  * A function that returns room info from room IDs.