@liveblocks/node 1.8.1 → 1.8.2
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.mts +3 -259
- package/dist/index.d.ts +3 -259
- package/dist/index.js +19 -310
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -306
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, CommentData } from '@liveblocks/core';
|
|
2
|
+
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyResolveUsersArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
|
|
1
3
|
import { IncomingHttpHeaders } from 'http';
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -88,174 +90,6 @@ declare type AuthorizeResponse = {
|
|
|
88
90
|
*/
|
|
89
91
|
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
90
92
|
|
|
91
|
-
/**
|
|
92
|
-
* Represents an indefinitely deep arbitrary JSON data structure. There are
|
|
93
|
-
* four types that make up the Json family:
|
|
94
|
-
*
|
|
95
|
-
* - Json any legal JSON value
|
|
96
|
-
* - JsonScalar any legal JSON leaf value (no lists or objects)
|
|
97
|
-
* - JsonArray a JSON value whose outer type is an array
|
|
98
|
-
* - JsonObject a JSON value whose outer type is an object
|
|
99
|
-
*
|
|
100
|
-
*/
|
|
101
|
-
declare type Json = JsonScalar | JsonArray | JsonObject;
|
|
102
|
-
declare type JsonScalar = string | number | boolean | null;
|
|
103
|
-
declare type JsonArray = Json[];
|
|
104
|
-
declare type JsonObject = {
|
|
105
|
-
[key: string]: Json | undefined;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* "Plain LSON" is a JSON-based format that's used when serializing Live structures
|
|
110
|
-
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial
|
|
111
|
-
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
112
|
-
*
|
|
113
|
-
* In the client, you would typically create LSON values using:
|
|
114
|
-
*
|
|
115
|
-
* new LiveObject({ x: 0, y: 0 })
|
|
116
|
-
*
|
|
117
|
-
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
118
|
-
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
119
|
-
* control which parts of their data structure should be considered "Live"
|
|
120
|
-
* objects, and which parts are "normal" objects.
|
|
121
|
-
*
|
|
122
|
-
* So if they have a structure like:
|
|
123
|
-
*
|
|
124
|
-
* { x: 0, y: 0 }
|
|
125
|
-
*
|
|
126
|
-
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
127
|
-
* a special "annotation":
|
|
128
|
-
*
|
|
129
|
-
* {
|
|
130
|
-
* "liveblocksType": "LiveObject",
|
|
131
|
-
* "data": { x: 0, y: 0 },
|
|
132
|
-
* }
|
|
133
|
-
*
|
|
134
|
-
* This "Plain LSON" data format defines exactly those wrappings.
|
|
135
|
-
*
|
|
136
|
-
* To summarize:
|
|
137
|
-
*
|
|
138
|
-
* LSON value | Plain LSON equivalent
|
|
139
|
-
* ----------------------+----------------------------------------------
|
|
140
|
-
* 42 | 42
|
|
141
|
-
* [1, 2, 3] | [1, 2, 3]
|
|
142
|
-
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
143
|
-
* ----------------------+----------------------------------------------
|
|
144
|
-
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
145
|
-
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
146
|
-
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
declare type PlainLsonFields = Record<string, PlainLson>;
|
|
151
|
-
declare type PlainLsonObject = {
|
|
152
|
-
liveblocksType: "LiveObject";
|
|
153
|
-
data: PlainLsonFields;
|
|
154
|
-
};
|
|
155
|
-
declare type PlainLsonMap = {
|
|
156
|
-
liveblocksType: "LiveMap";
|
|
157
|
-
data: PlainLsonFields;
|
|
158
|
-
};
|
|
159
|
-
declare type PlainLsonList = {
|
|
160
|
-
liveblocksType: "LiveList";
|
|
161
|
-
data: PlainLson[];
|
|
162
|
-
};
|
|
163
|
-
declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Represents some constraints for user info. Basically read this as: "any JSON
|
|
167
|
-
* object is fine, but _if_ it has a name field, it _must_ be a string."
|
|
168
|
-
* (Ditto for avatar.)
|
|
169
|
-
*/
|
|
170
|
-
declare type IUserInfo = {
|
|
171
|
-
[key: string]: Json | undefined;
|
|
172
|
-
name?: string;
|
|
173
|
-
avatar?: string;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* This type is used by clients to define the metadata for a user.
|
|
177
|
-
*/
|
|
178
|
-
declare type BaseUserMeta = {
|
|
179
|
-
/**
|
|
180
|
-
* The id of the user that has been set in the authentication endpoint.
|
|
181
|
-
* Useful to get additional information about the connected user.
|
|
182
|
-
*/
|
|
183
|
-
id?: string;
|
|
184
|
-
/**
|
|
185
|
-
* Additional user information that has been set in the authentication endpoint.
|
|
186
|
-
*/
|
|
187
|
-
info?: IUserInfo;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
declare type BaseMetadata = Record<string, string | boolean | number>;
|
|
191
|
-
|
|
192
|
-
declare type CommentBodyBlockElement = CommentBodyParagraph;
|
|
193
|
-
declare type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
|
|
194
|
-
declare type CommentBodyParagraph = {
|
|
195
|
-
type: "paragraph";
|
|
196
|
-
children: CommentBodyInlineElement[];
|
|
197
|
-
};
|
|
198
|
-
declare type CommentBodyMention = {
|
|
199
|
-
type: "mention";
|
|
200
|
-
id: string;
|
|
201
|
-
};
|
|
202
|
-
declare type CommentBodyLink = {
|
|
203
|
-
type: "link";
|
|
204
|
-
url: string;
|
|
205
|
-
};
|
|
206
|
-
declare type CommentBodyText = {
|
|
207
|
-
bold?: boolean;
|
|
208
|
-
italic?: boolean;
|
|
209
|
-
strikethrough?: boolean;
|
|
210
|
-
code?: boolean;
|
|
211
|
-
text: string;
|
|
212
|
-
};
|
|
213
|
-
declare type CommentBody = {
|
|
214
|
-
version: 1;
|
|
215
|
-
content: CommentBodyBlockElement[];
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
declare type CommentReactionUser = {
|
|
219
|
-
id: string;
|
|
220
|
-
};
|
|
221
|
-
declare type CommentReaction = {
|
|
222
|
-
emoji: string;
|
|
223
|
-
createdAt: string;
|
|
224
|
-
users: CommentReactionUser[];
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Represents a comment.
|
|
228
|
-
*/
|
|
229
|
-
declare type CommentData = {
|
|
230
|
-
type: "comment";
|
|
231
|
-
id: string;
|
|
232
|
-
threadId: string;
|
|
233
|
-
roomId: string;
|
|
234
|
-
userId: string;
|
|
235
|
-
createdAt: string;
|
|
236
|
-
editedAt?: string;
|
|
237
|
-
reactions: CommentReaction[];
|
|
238
|
-
} & ({
|
|
239
|
-
body: CommentBody;
|
|
240
|
-
deletedAt?: never;
|
|
241
|
-
} | {
|
|
242
|
-
body?: never;
|
|
243
|
-
deletedAt: string;
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Represents a thread of comments.
|
|
248
|
-
*/
|
|
249
|
-
declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
|
|
250
|
-
type: "thread";
|
|
251
|
-
id: string;
|
|
252
|
-
roomId: string;
|
|
253
|
-
createdAt: string;
|
|
254
|
-
updatedAt?: string;
|
|
255
|
-
comments: CommentData[];
|
|
256
|
-
metadata: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
93
|
declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read"];
|
|
260
94
|
declare type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
261
95
|
/**
|
|
@@ -659,96 +493,6 @@ declare class Liveblocks {
|
|
|
659
493
|
}): Promise<CommentData>;
|
|
660
494
|
}
|
|
661
495
|
|
|
662
|
-
declare type PromiseOrNot<T> = T | Promise<T>;
|
|
663
|
-
declare type CommentBodyResolveUsersArgs = {
|
|
664
|
-
/**
|
|
665
|
-
* The ID of the users to resolve.
|
|
666
|
-
*/
|
|
667
|
-
userIds: string[];
|
|
668
|
-
};
|
|
669
|
-
declare type CommentBodyParagraphElementArgs = {
|
|
670
|
-
/**
|
|
671
|
-
* The paragraph element.
|
|
672
|
-
*/
|
|
673
|
-
element: CommentBodyParagraph;
|
|
674
|
-
/**
|
|
675
|
-
* The text content of the paragraph.
|
|
676
|
-
*/
|
|
677
|
-
children: string;
|
|
678
|
-
};
|
|
679
|
-
declare type CommentBodyTextElementArgs = {
|
|
680
|
-
/**
|
|
681
|
-
* The text element.
|
|
682
|
-
*/
|
|
683
|
-
element: CommentBodyText;
|
|
684
|
-
};
|
|
685
|
-
declare type CommentBodyLinkElementArgs = {
|
|
686
|
-
/**
|
|
687
|
-
* The link element.
|
|
688
|
-
*/
|
|
689
|
-
element: CommentBodyLink;
|
|
690
|
-
/**
|
|
691
|
-
* The absolute URL of the link.
|
|
692
|
-
*/
|
|
693
|
-
href: string;
|
|
694
|
-
};
|
|
695
|
-
declare type CommentBodyMentionElementArgs<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
|
|
696
|
-
/**
|
|
697
|
-
* The mention element.
|
|
698
|
-
*/
|
|
699
|
-
element: CommentBodyMention;
|
|
700
|
-
/**
|
|
701
|
-
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
702
|
-
*/
|
|
703
|
-
user?: TUserMeta["info"];
|
|
704
|
-
};
|
|
705
|
-
declare type StringifyCommentBodyElements<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
|
|
706
|
-
/**
|
|
707
|
-
* The element used to display paragraphs.
|
|
708
|
-
*/
|
|
709
|
-
paragraph: (args: CommentBodyParagraphElementArgs, index: number) => string;
|
|
710
|
-
/**
|
|
711
|
-
* The element used to display text elements.
|
|
712
|
-
*/
|
|
713
|
-
text: (args: CommentBodyTextElementArgs, index: number) => string;
|
|
714
|
-
/**
|
|
715
|
-
* The element used to display links.
|
|
716
|
-
*/
|
|
717
|
-
link: (args: CommentBodyLinkElementArgs, index: number) => string;
|
|
718
|
-
/**
|
|
719
|
-
* The element used to display mentions.
|
|
720
|
-
*/
|
|
721
|
-
mention: (args: CommentBodyMentionElementArgs<TUserMeta>, index: number) => string;
|
|
722
|
-
};
|
|
723
|
-
declare type StringifyCommentBodyOptions<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
|
|
724
|
-
/**
|
|
725
|
-
* Which format to convert the comment to.
|
|
726
|
-
*/
|
|
727
|
-
format?: "plain" | "html" | "markdown";
|
|
728
|
-
/**
|
|
729
|
-
* The elements used to customize the resulting string. Each element has
|
|
730
|
-
* priority over the defaults inherited from the `format` option.
|
|
731
|
-
*/
|
|
732
|
-
elements?: Partial<StringifyCommentBodyElements<TUserMeta>>;
|
|
733
|
-
/**
|
|
734
|
-
* The separator used between paragraphs.
|
|
735
|
-
*/
|
|
736
|
-
separator?: string;
|
|
737
|
-
/**
|
|
738
|
-
* A function that returns user info from user IDs.
|
|
739
|
-
*/
|
|
740
|
-
resolveUsers?: (args: CommentBodyResolveUsersArgs) => PromiseOrNot<(TUserMeta["info"] | undefined)[] | undefined>;
|
|
741
|
-
};
|
|
742
|
-
/**
|
|
743
|
-
* Get an array of each user's ID that has been mentioned in a `CommentBody`.
|
|
744
|
-
*/
|
|
745
|
-
declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
|
|
746
|
-
/**
|
|
747
|
-
* Convert a `CommentBody` into either a plain string,
|
|
748
|
-
* Markdown, HTML, or a custom format.
|
|
749
|
-
*/
|
|
750
|
-
declare function stringifyCommentBody<TUserMeta extends BaseUserMeta = BaseUserMeta>(body: CommentBody, options?: StringifyCommentBodyOptions<TUserMeta>): Promise<string>;
|
|
751
|
-
|
|
752
496
|
declare class WebhookHandler {
|
|
753
497
|
private secretBuffer;
|
|
754
498
|
private static secretPrefix;
|
|
@@ -987,4 +731,4 @@ declare type ThreadCreatedEvent = {
|
|
|
987
731
|
};
|
|
988
732
|
};
|
|
989
733
|
|
|
990
|
-
export {
|
|
734
|
+
export { CommentCreatedEvent, CommentDeletedEvent, CommentEditedEvent, CommentReactionAdded, CommentReactionRemoved, Liveblocks, LiveblocksOptions, RoomAccesses, RoomCreatedEvent, RoomDeletedEvent, RoomInfo, RoomPermission, RoomUser, Schema, StorageUpdatedEvent, ThreadCreatedEvent, ThreadMetadataUpdatedEvent, ThreadParticipants, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, CommentData } from '@liveblocks/core';
|
|
2
|
+
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyResolveUsersArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
|
|
1
3
|
import { IncomingHttpHeaders } from 'http';
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -88,174 +90,6 @@ declare type AuthorizeResponse = {
|
|
|
88
90
|
*/
|
|
89
91
|
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
90
92
|
|
|
91
|
-
/**
|
|
92
|
-
* Represents an indefinitely deep arbitrary JSON data structure. There are
|
|
93
|
-
* four types that make up the Json family:
|
|
94
|
-
*
|
|
95
|
-
* - Json any legal JSON value
|
|
96
|
-
* - JsonScalar any legal JSON leaf value (no lists or objects)
|
|
97
|
-
* - JsonArray a JSON value whose outer type is an array
|
|
98
|
-
* - JsonObject a JSON value whose outer type is an object
|
|
99
|
-
*
|
|
100
|
-
*/
|
|
101
|
-
declare type Json = JsonScalar | JsonArray | JsonObject;
|
|
102
|
-
declare type JsonScalar = string | number | boolean | null;
|
|
103
|
-
declare type JsonArray = Json[];
|
|
104
|
-
declare type JsonObject = {
|
|
105
|
-
[key: string]: Json | undefined;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* "Plain LSON" is a JSON-based format that's used when serializing Live structures
|
|
110
|
-
* to send them over HTTP (e.g. in the API endpoint to let users upload their initial
|
|
111
|
-
* Room storage, in the API endpoint to fetch a Room's storage, ...).
|
|
112
|
-
*
|
|
113
|
-
* In the client, you would typically create LSON values using:
|
|
114
|
-
*
|
|
115
|
-
* new LiveObject({ x: 0, y: 0 })
|
|
116
|
-
*
|
|
117
|
-
* But over HTTP, this has to be serialized somehow. The "Plain LSON" format
|
|
118
|
-
* is what's used in the POST /init-storage-new endpoint, to allow users to
|
|
119
|
-
* control which parts of their data structure should be considered "Live"
|
|
120
|
-
* objects, and which parts are "normal" objects.
|
|
121
|
-
*
|
|
122
|
-
* So if they have a structure like:
|
|
123
|
-
*
|
|
124
|
-
* { x: 0, y: 0 }
|
|
125
|
-
*
|
|
126
|
-
* And want to make it a Live object, they can serialize it by wrapping it in
|
|
127
|
-
* a special "annotation":
|
|
128
|
-
*
|
|
129
|
-
* {
|
|
130
|
-
* "liveblocksType": "LiveObject",
|
|
131
|
-
* "data": { x: 0, y: 0 },
|
|
132
|
-
* }
|
|
133
|
-
*
|
|
134
|
-
* This "Plain LSON" data format defines exactly those wrappings.
|
|
135
|
-
*
|
|
136
|
-
* To summarize:
|
|
137
|
-
*
|
|
138
|
-
* LSON value | Plain LSON equivalent
|
|
139
|
-
* ----------------------+----------------------------------------------
|
|
140
|
-
* 42 | 42
|
|
141
|
-
* [1, 2, 3] | [1, 2, 3]
|
|
142
|
-
* { x: 0, y: 0 } | { x: 0, y: 0 }
|
|
143
|
-
* ----------------------+----------------------------------------------
|
|
144
|
-
* new LiveList(...) | { liveblocksType: "LiveList", data: ... }
|
|
145
|
-
* new LiveMap(...) | { liveblocksType: "LiveMap", data: ... }
|
|
146
|
-
* new LiveObject(...) | { liveblocksType: "LiveObject", data: ... }
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
declare type PlainLsonFields = Record<string, PlainLson>;
|
|
151
|
-
declare type PlainLsonObject = {
|
|
152
|
-
liveblocksType: "LiveObject";
|
|
153
|
-
data: PlainLsonFields;
|
|
154
|
-
};
|
|
155
|
-
declare type PlainLsonMap = {
|
|
156
|
-
liveblocksType: "LiveMap";
|
|
157
|
-
data: PlainLsonFields;
|
|
158
|
-
};
|
|
159
|
-
declare type PlainLsonList = {
|
|
160
|
-
liveblocksType: "LiveList";
|
|
161
|
-
data: PlainLson[];
|
|
162
|
-
};
|
|
163
|
-
declare type PlainLson = PlainLsonObject | PlainLsonMap | PlainLsonList | Json;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Represents some constraints for user info. Basically read this as: "any JSON
|
|
167
|
-
* object is fine, but _if_ it has a name field, it _must_ be a string."
|
|
168
|
-
* (Ditto for avatar.)
|
|
169
|
-
*/
|
|
170
|
-
declare type IUserInfo = {
|
|
171
|
-
[key: string]: Json | undefined;
|
|
172
|
-
name?: string;
|
|
173
|
-
avatar?: string;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* This type is used by clients to define the metadata for a user.
|
|
177
|
-
*/
|
|
178
|
-
declare type BaseUserMeta = {
|
|
179
|
-
/**
|
|
180
|
-
* The id of the user that has been set in the authentication endpoint.
|
|
181
|
-
* Useful to get additional information about the connected user.
|
|
182
|
-
*/
|
|
183
|
-
id?: string;
|
|
184
|
-
/**
|
|
185
|
-
* Additional user information that has been set in the authentication endpoint.
|
|
186
|
-
*/
|
|
187
|
-
info?: IUserInfo;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
declare type BaseMetadata = Record<string, string | boolean | number>;
|
|
191
|
-
|
|
192
|
-
declare type CommentBodyBlockElement = CommentBodyParagraph;
|
|
193
|
-
declare type CommentBodyInlineElement = CommentBodyText | CommentBodyMention | CommentBodyLink;
|
|
194
|
-
declare type CommentBodyParagraph = {
|
|
195
|
-
type: "paragraph";
|
|
196
|
-
children: CommentBodyInlineElement[];
|
|
197
|
-
};
|
|
198
|
-
declare type CommentBodyMention = {
|
|
199
|
-
type: "mention";
|
|
200
|
-
id: string;
|
|
201
|
-
};
|
|
202
|
-
declare type CommentBodyLink = {
|
|
203
|
-
type: "link";
|
|
204
|
-
url: string;
|
|
205
|
-
};
|
|
206
|
-
declare type CommentBodyText = {
|
|
207
|
-
bold?: boolean;
|
|
208
|
-
italic?: boolean;
|
|
209
|
-
strikethrough?: boolean;
|
|
210
|
-
code?: boolean;
|
|
211
|
-
text: string;
|
|
212
|
-
};
|
|
213
|
-
declare type CommentBody = {
|
|
214
|
-
version: 1;
|
|
215
|
-
content: CommentBodyBlockElement[];
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
declare type CommentReactionUser = {
|
|
219
|
-
id: string;
|
|
220
|
-
};
|
|
221
|
-
declare type CommentReaction = {
|
|
222
|
-
emoji: string;
|
|
223
|
-
createdAt: string;
|
|
224
|
-
users: CommentReactionUser[];
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Represents a comment.
|
|
228
|
-
*/
|
|
229
|
-
declare type CommentData = {
|
|
230
|
-
type: "comment";
|
|
231
|
-
id: string;
|
|
232
|
-
threadId: string;
|
|
233
|
-
roomId: string;
|
|
234
|
-
userId: string;
|
|
235
|
-
createdAt: string;
|
|
236
|
-
editedAt?: string;
|
|
237
|
-
reactions: CommentReaction[];
|
|
238
|
-
} & ({
|
|
239
|
-
body: CommentBody;
|
|
240
|
-
deletedAt?: never;
|
|
241
|
-
} | {
|
|
242
|
-
body?: never;
|
|
243
|
-
deletedAt: string;
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Represents a thread of comments.
|
|
248
|
-
*/
|
|
249
|
-
declare type ThreadData<TThreadMetadata extends BaseMetadata = never> = {
|
|
250
|
-
type: "thread";
|
|
251
|
-
id: string;
|
|
252
|
-
roomId: string;
|
|
253
|
-
createdAt: string;
|
|
254
|
-
updatedAt?: string;
|
|
255
|
-
comments: CommentData[];
|
|
256
|
-
metadata: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
93
|
declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read"];
|
|
260
94
|
declare type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
261
95
|
/**
|
|
@@ -659,96 +493,6 @@ declare class Liveblocks {
|
|
|
659
493
|
}): Promise<CommentData>;
|
|
660
494
|
}
|
|
661
495
|
|
|
662
|
-
declare type PromiseOrNot<T> = T | Promise<T>;
|
|
663
|
-
declare type CommentBodyResolveUsersArgs = {
|
|
664
|
-
/**
|
|
665
|
-
* The ID of the users to resolve.
|
|
666
|
-
*/
|
|
667
|
-
userIds: string[];
|
|
668
|
-
};
|
|
669
|
-
declare type CommentBodyParagraphElementArgs = {
|
|
670
|
-
/**
|
|
671
|
-
* The paragraph element.
|
|
672
|
-
*/
|
|
673
|
-
element: CommentBodyParagraph;
|
|
674
|
-
/**
|
|
675
|
-
* The text content of the paragraph.
|
|
676
|
-
*/
|
|
677
|
-
children: string;
|
|
678
|
-
};
|
|
679
|
-
declare type CommentBodyTextElementArgs = {
|
|
680
|
-
/**
|
|
681
|
-
* The text element.
|
|
682
|
-
*/
|
|
683
|
-
element: CommentBodyText;
|
|
684
|
-
};
|
|
685
|
-
declare type CommentBodyLinkElementArgs = {
|
|
686
|
-
/**
|
|
687
|
-
* The link element.
|
|
688
|
-
*/
|
|
689
|
-
element: CommentBodyLink;
|
|
690
|
-
/**
|
|
691
|
-
* The absolute URL of the link.
|
|
692
|
-
*/
|
|
693
|
-
href: string;
|
|
694
|
-
};
|
|
695
|
-
declare type CommentBodyMentionElementArgs<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
|
|
696
|
-
/**
|
|
697
|
-
* The mention element.
|
|
698
|
-
*/
|
|
699
|
-
element: CommentBodyMention;
|
|
700
|
-
/**
|
|
701
|
-
* The mention's user info, if the `resolvedUsers` option was provided.
|
|
702
|
-
*/
|
|
703
|
-
user?: TUserMeta["info"];
|
|
704
|
-
};
|
|
705
|
-
declare type StringifyCommentBodyElements<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
|
|
706
|
-
/**
|
|
707
|
-
* The element used to display paragraphs.
|
|
708
|
-
*/
|
|
709
|
-
paragraph: (args: CommentBodyParagraphElementArgs, index: number) => string;
|
|
710
|
-
/**
|
|
711
|
-
* The element used to display text elements.
|
|
712
|
-
*/
|
|
713
|
-
text: (args: CommentBodyTextElementArgs, index: number) => string;
|
|
714
|
-
/**
|
|
715
|
-
* The element used to display links.
|
|
716
|
-
*/
|
|
717
|
-
link: (args: CommentBodyLinkElementArgs, index: number) => string;
|
|
718
|
-
/**
|
|
719
|
-
* The element used to display mentions.
|
|
720
|
-
*/
|
|
721
|
-
mention: (args: CommentBodyMentionElementArgs<TUserMeta>, index: number) => string;
|
|
722
|
-
};
|
|
723
|
-
declare type StringifyCommentBodyOptions<TUserMeta extends BaseUserMeta = BaseUserMeta> = {
|
|
724
|
-
/**
|
|
725
|
-
* Which format to convert the comment to.
|
|
726
|
-
*/
|
|
727
|
-
format?: "plain" | "html" | "markdown";
|
|
728
|
-
/**
|
|
729
|
-
* The elements used to customize the resulting string. Each element has
|
|
730
|
-
* priority over the defaults inherited from the `format` option.
|
|
731
|
-
*/
|
|
732
|
-
elements?: Partial<StringifyCommentBodyElements<TUserMeta>>;
|
|
733
|
-
/**
|
|
734
|
-
* The separator used between paragraphs.
|
|
735
|
-
*/
|
|
736
|
-
separator?: string;
|
|
737
|
-
/**
|
|
738
|
-
* A function that returns user info from user IDs.
|
|
739
|
-
*/
|
|
740
|
-
resolveUsers?: (args: CommentBodyResolveUsersArgs) => PromiseOrNot<(TUserMeta["info"] | undefined)[] | undefined>;
|
|
741
|
-
};
|
|
742
|
-
/**
|
|
743
|
-
* Get an array of each user's ID that has been mentioned in a `CommentBody`.
|
|
744
|
-
*/
|
|
745
|
-
declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
|
|
746
|
-
/**
|
|
747
|
-
* Convert a `CommentBody` into either a plain string,
|
|
748
|
-
* Markdown, HTML, or a custom format.
|
|
749
|
-
*/
|
|
750
|
-
declare function stringifyCommentBody<TUserMeta extends BaseUserMeta = BaseUserMeta>(body: CommentBody, options?: StringifyCommentBodyOptions<TUserMeta>): Promise<string>;
|
|
751
|
-
|
|
752
496
|
declare class WebhookHandler {
|
|
753
497
|
private secretBuffer;
|
|
754
498
|
private static secretPrefix;
|
|
@@ -987,4 +731,4 @@ declare type ThreadCreatedEvent = {
|
|
|
987
731
|
};
|
|
988
732
|
};
|
|
989
733
|
|
|
990
|
-
export {
|
|
734
|
+
export { CommentCreatedEvent, CommentDeletedEvent, CommentEditedEvent, CommentReactionAdded, CommentReactionRemoved, Liveblocks, LiveblocksOptions, RoomAccesses, RoomCreatedEvent, RoomDeletedEvent, RoomInfo, RoomPermission, RoomUser, Schema, StorageUpdatedEvent, ThreadCreatedEvent, ThreadMetadataUpdatedEvent, ThreadParticipants, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize };
|