@liveblocks/node 1.7.1-pre1 → 1.8.0
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 +410 -4
- package/dist/index.d.ts +410 -4
- package/dist/index.js +784 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +782 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -88,6 +88,105 @@ declare type AuthorizeResponse = {
|
|
|
88
88
|
*/
|
|
89
89
|
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
90
90
|
|
|
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
|
+
|
|
91
190
|
declare type BaseMetadata = Record<string, string | boolean | number>;
|
|
92
191
|
|
|
93
192
|
declare type CommentBodyBlockElement = CommentBodyParagraph;
|
|
@@ -220,7 +319,7 @@ declare type LiveblocksOptions = {
|
|
|
220
319
|
secret: string;
|
|
221
320
|
};
|
|
222
321
|
declare type CreateSessionOptions = {
|
|
223
|
-
userInfo:
|
|
322
|
+
userInfo: IUserInfo;
|
|
224
323
|
};
|
|
225
324
|
declare type AuthResponse = {
|
|
226
325
|
status: number;
|
|
@@ -234,6 +333,35 @@ declare type Identity = {
|
|
|
234
333
|
declare type ThreadParticipants = {
|
|
235
334
|
participantIds: string[];
|
|
236
335
|
};
|
|
336
|
+
declare type RoomPermission = [] | ["room:write"] | ["room:read", "room:presence:write"];
|
|
337
|
+
declare type RoomAccesses = Record<string, [
|
|
338
|
+
"room:write"
|
|
339
|
+
] | ["room:read", "room:presence:write"]>;
|
|
340
|
+
declare type RoomMetadata = Record<string, string | string[]>;
|
|
341
|
+
declare type RoomInfo = {
|
|
342
|
+
type: "room";
|
|
343
|
+
id: string;
|
|
344
|
+
metadata: RoomMetadata;
|
|
345
|
+
groupsAccesses: RoomAccesses;
|
|
346
|
+
usersAccesses: RoomAccesses;
|
|
347
|
+
defaultAccesses: RoomPermission;
|
|
348
|
+
lastConnectionAt?: Date;
|
|
349
|
+
createdAt?: Date;
|
|
350
|
+
};
|
|
351
|
+
declare type RoomUser<Info> = {
|
|
352
|
+
type: "user";
|
|
353
|
+
id: string | null;
|
|
354
|
+
connectionId: number;
|
|
355
|
+
info: Info;
|
|
356
|
+
};
|
|
357
|
+
declare type Schema = {
|
|
358
|
+
id: string;
|
|
359
|
+
name: string;
|
|
360
|
+
version: number;
|
|
361
|
+
body: string;
|
|
362
|
+
createdAt: Date;
|
|
363
|
+
updatedAt: Date;
|
|
364
|
+
};
|
|
237
365
|
/**
|
|
238
366
|
* Interact with the Liveblocks API from your Node.js backend.
|
|
239
367
|
*/
|
|
@@ -292,8 +420,194 @@ declare class Liveblocks {
|
|
|
292
420
|
* `other.info` property.
|
|
293
421
|
*/
|
|
294
422
|
identifyUser(identity: string | Identity, options?: {
|
|
295
|
-
userInfo:
|
|
423
|
+
userInfo: IUserInfo;
|
|
296
424
|
}): Promise<AuthResponse>;
|
|
425
|
+
/**
|
|
426
|
+
* Returns a list of your rooms. The rooms are returned sorted by creation date, from newest to oldest. You can filter rooms by metadata, users accesses and groups accesses.
|
|
427
|
+
* @param params.limit (optional) A limit on the number of rooms to be returned. The limit can range between 1 and 100, and defaults to 20.
|
|
428
|
+
* @param params.startingAfter (optional) A cursor used for pagination. You get the value from the response of the previous page.
|
|
429
|
+
* @param params.userId (optional) A filter on users accesses.
|
|
430
|
+
* @param params.metadata (optional) A filter on metadata. Multiple metadata keys can be used to filter rooms.
|
|
431
|
+
* @param params.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
|
|
432
|
+
* @returns A list of rooms.
|
|
433
|
+
*/
|
|
434
|
+
getRooms(params?: {
|
|
435
|
+
limit?: number;
|
|
436
|
+
startingAfter?: string;
|
|
437
|
+
metadata?: RoomMetadata;
|
|
438
|
+
userId?: string;
|
|
439
|
+
groupIds?: string[];
|
|
440
|
+
}): Promise<{
|
|
441
|
+
nextPage: string | null;
|
|
442
|
+
data: RoomInfo[];
|
|
443
|
+
}>;
|
|
444
|
+
/**
|
|
445
|
+
* Creates a new room with the given id.
|
|
446
|
+
* @param roomId The id of the room to create.
|
|
447
|
+
* @param params.defaultAccesses The default accesses for the room.
|
|
448
|
+
* @param params.groupAccesses (optional) The group accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
449
|
+
* @param params.userAccesses (optional) The user accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
450
|
+
* @param params.metadata (optional) The metadata for the room. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
451
|
+
* @returns The created room.
|
|
452
|
+
*/
|
|
453
|
+
createRoom(roomId: string, params: {
|
|
454
|
+
defaultAccesses: RoomPermission;
|
|
455
|
+
groupsAccesses?: RoomAccesses;
|
|
456
|
+
usersAccesses?: RoomAccesses;
|
|
457
|
+
metadata?: RoomMetadata;
|
|
458
|
+
}): Promise<RoomInfo>;
|
|
459
|
+
/**
|
|
460
|
+
* Returns a room with the given id.
|
|
461
|
+
* @param roomId The id of the room to return.
|
|
462
|
+
* @returns The room with the given id.
|
|
463
|
+
*/
|
|
464
|
+
getRoom(roomId: string): Promise<RoomInfo>;
|
|
465
|
+
/**
|
|
466
|
+
* Updates specific properties of a room. It’s not necessary to provide the entire room’s information.
|
|
467
|
+
* Setting a property to `null` means to delete this property.
|
|
468
|
+
* @param roomId The id of the room to update.
|
|
469
|
+
* @param params.defaultAccesses (optional) The default accesses for the room.
|
|
470
|
+
* @param params.groupAccesses (optional) The group accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
471
|
+
* @param params.userAccesses (optional) The user accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
472
|
+
* @param params.metadata (optional) The metadata for the room. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
473
|
+
* @returns The updated room.
|
|
474
|
+
*/
|
|
475
|
+
updateRoom(roomId: string, params: {
|
|
476
|
+
defaultAccesses?: RoomPermission | null;
|
|
477
|
+
groupsAccesses?: Record<string, [
|
|
478
|
+
"room:write"
|
|
479
|
+
] | ["room:read", "room:presence:write"] | null>;
|
|
480
|
+
usersAccesses?: Record<string, [
|
|
481
|
+
"room:write"
|
|
482
|
+
] | ["room:read", "room:presence:write"] | null>;
|
|
483
|
+
metadata?: Record<string, string | string[] | null>;
|
|
484
|
+
}): Promise<RoomInfo>;
|
|
485
|
+
/**
|
|
486
|
+
* Deletes a room with the given id. A deleted room is no longer accessible from the API or the dashboard and it cannot be restored.
|
|
487
|
+
* @param roomId The id of the room to delete.
|
|
488
|
+
*/
|
|
489
|
+
deleteRoom(roomId: string): Promise<void>;
|
|
490
|
+
/**
|
|
491
|
+
* Returns a list of users currently present in the requested room. For better performance, we recommand to call this endpoint every 10 seconds maximum. Duplicates can happen if a user is in the requested room with multiple browser tabs opened.
|
|
492
|
+
* @param roomId The id of the room to get the users from.
|
|
493
|
+
* @returns A list of users currently present in the requested room.
|
|
494
|
+
*/
|
|
495
|
+
getActiveUsers<T = unknown>(roomId: string): Promise<RoomUser<T>[]>;
|
|
496
|
+
/**
|
|
497
|
+
* Boadcasts an event to a room without having to connect to it via the client from @liveblocks/client. The connectionId passed to event listeners is -1 when using this API.
|
|
498
|
+
* @param roomId The id of the room to broadcast the event to.
|
|
499
|
+
* @param message The message to broadcast. It can be any JSON serializable value.
|
|
500
|
+
*/
|
|
501
|
+
broadcastEvent(roomId: string, message: Json): Promise<void>;
|
|
502
|
+
/**
|
|
503
|
+
* Returns the contents of the room’s Storage tree.
|
|
504
|
+
* The default outputted format is called “plain LSON”, which includes information on the Live data structures in the tree.
|
|
505
|
+
* These nodes show up in the output as objects with two properties:
|
|
506
|
+
*
|
|
507
|
+
* ```json
|
|
508
|
+
* {
|
|
509
|
+
* "liveblocksType": "LiveObject",
|
|
510
|
+
* "data": ...
|
|
511
|
+
* }
|
|
512
|
+
* ```
|
|
513
|
+
*
|
|
514
|
+
* If you’re not interested in this information, you can use the `format` parameter to get a more compact output.
|
|
515
|
+
*
|
|
516
|
+
* @param roomId The id of the room to get the storage from.
|
|
517
|
+
* @param format (optional) Set to return `plan-lson` representation by default. If set to `json`, the output will be formatted as a simplified JSON representation of the Storage tree.
|
|
518
|
+
* In that format, each LiveObject and LiveMap will be formatted as a simple JSON object, and each LiveList will be formatted as a simple JSON array. This is a lossy format because information about the original data structures is not retained, but it may be easier to work with.
|
|
519
|
+
*/
|
|
520
|
+
getStorageDocument(roomId: string, format: "plain-lson"): Promise<PlainLsonObject>;
|
|
521
|
+
getStorageDocument(roomId: string): Promise<PlainLsonObject>;
|
|
522
|
+
getStorageDocument(roomId: string, format: "json"): Promise<JsonObject>;
|
|
523
|
+
/**
|
|
524
|
+
* Initializes a room’s Storage. The room must already exist and have an empty Storage.
|
|
525
|
+
* Calling this endpoint will disconnect all users from the room if there are any.
|
|
526
|
+
*
|
|
527
|
+
* @param roomId The id of the room to initialize the storage from.
|
|
528
|
+
* @param document The document to initialize the storage with.
|
|
529
|
+
* @returns The initialized storage document. It is of the same format as the one passed in.
|
|
530
|
+
*/
|
|
531
|
+
initializeStorageDocument(roomId: string, document: PlainLsonObject): Promise<PlainLsonObject>;
|
|
532
|
+
/**
|
|
533
|
+
* Deletes all of the room’s Storage data and disconnect all users from the room if there are any. Note that this does not delete the Yjs document in the room if one exists.
|
|
534
|
+
* @param roomId The id of the room to delete the storage from.
|
|
535
|
+
*/
|
|
536
|
+
deleteStorageDocument(roomId: string): Promise<void>;
|
|
537
|
+
/**
|
|
538
|
+
* Returns a JSON representation of the room’s Yjs document.
|
|
539
|
+
* @param roomId The id of the room to get the Yjs document from.
|
|
540
|
+
* @param params.format (optional) If true, YText will return formatting.
|
|
541
|
+
* @param params.key (optional) If provided, returns only a single key’s value, e.g. doc.get(key).toJSON().
|
|
542
|
+
* @param params.type (optional) Used with key to override the inferred type, i.e. "ymap" will return doc.get(key, Y.Map).
|
|
543
|
+
* @returns A JSON representation of the room’s Yjs document.
|
|
544
|
+
*/
|
|
545
|
+
getYjsDocument(roomId: string, params?: {
|
|
546
|
+
format?: boolean;
|
|
547
|
+
key?: string;
|
|
548
|
+
type?: string;
|
|
549
|
+
}): Promise<JsonObject>;
|
|
550
|
+
/**
|
|
551
|
+
* Send a Yjs binary update to the room’s Yjs document. You can use this endpoint to initialize Yjs data for the room or to update the room’s Yjs document.
|
|
552
|
+
* @param roomId The id of the room to send the Yjs binary update to.
|
|
553
|
+
* @param params The Yjs binary update to send. Read the [Yjs documentation](https://docs.yjs.dev/api/document-updates) to learn how to create a binary update.
|
|
554
|
+
*/
|
|
555
|
+
sendYjsBinaryUpdate(roomId: string, params: {
|
|
556
|
+
update: string;
|
|
557
|
+
}): Promise<void>;
|
|
558
|
+
/**
|
|
559
|
+
* Returns the room’s Yjs document encoded as a single binary update. This can be used by Y.applyUpdate(responseBody) to get a copy of the document in your backend.
|
|
560
|
+
* See [Yjs documentation](https://docs.yjs.dev/api/document-updates) for more information on working with updates.
|
|
561
|
+
* @param roomId The id of the room to get the Yjs document from.
|
|
562
|
+
* @returns The room’s Yjs document encoded as a single binary update.
|
|
563
|
+
*/
|
|
564
|
+
getYjsDocumentAsBinaryUpdate(roomId: string): Promise<ArrayBuffer>;
|
|
565
|
+
/**
|
|
566
|
+
* Creates a new schema which can be referenced later to enforce a room’s Storage data structure.
|
|
567
|
+
* @param name The name used to reference the schema. Must be a non-empty string with less than 65 characters and only contain lowercase letters, numbers and dashes
|
|
568
|
+
* @param body The exact allowed shape of data in the room. It is a multi-line string written in the [Liveblocks schema syntax](https://liveblocks.io/docs/platform/schema-validation/syntax).
|
|
569
|
+
* @returns The created schema.
|
|
570
|
+
*/
|
|
571
|
+
createSchema(name: string, body: string): Promise<Schema>;
|
|
572
|
+
/**
|
|
573
|
+
* Returns a schema by its id.
|
|
574
|
+
* @param schemaId Id of the schema - this is the combination of the schema name and version of the schema to update. For example, `my-schema@1`.
|
|
575
|
+
* @returns The schema with the given id.
|
|
576
|
+
*/
|
|
577
|
+
getSchema(schemaId: string): Promise<Schema>;
|
|
578
|
+
/**
|
|
579
|
+
* Updates the body for the schema. A schema can only be updated if it is not used by any room.
|
|
580
|
+
* @param schemaId Id of the schema - this is the combination of the schema name and version of the schema to update. For example, `my-schema@1`.
|
|
581
|
+
* @param body The exact allowed shape of data in the room. It is a multi-line string written in the [Liveblocks schema syntax](https://liveblocks.io/docs/platform/schema-validation/syntax).
|
|
582
|
+
* @returns The updated schema. The version of the schema will be incremented.
|
|
583
|
+
*/
|
|
584
|
+
updateSchema(schemaId: string, body: string): Promise<Schema>;
|
|
585
|
+
/**
|
|
586
|
+
* Deletes a schema by its id. A schema can only be deleted if it is not used by any room.
|
|
587
|
+
* @param schemaId Id of the schema - this is the combination of the schema name and version of the schema to update. For example, `my-schema@1`.
|
|
588
|
+
*/
|
|
589
|
+
deleteSchema(schemaId: string): Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* Returns the schema attached to a room.
|
|
592
|
+
* @param roomId The id of the room to get the schema from.
|
|
593
|
+
* @returns
|
|
594
|
+
*/
|
|
595
|
+
getSchemaByRoomId(roomId: string): Promise<Schema>;
|
|
596
|
+
/**
|
|
597
|
+
* Attaches a schema to a room, and instantly enables runtime schema validation for the room.
|
|
598
|
+
* If the current contents of the room’s Storage do not match the schema, attaching will fail and the error message will give details on why the schema failed to attach.
|
|
599
|
+
* @param roomId The id of the room to attach the schema to.
|
|
600
|
+
* @param schemaId Id of the schema - this is the combination of the schema name and version of the schema to update. For example, `my-schema@1`.
|
|
601
|
+
* @returns The schema id as JSON.
|
|
602
|
+
*/
|
|
603
|
+
attachSchemaToRoom(roomId: string, schemaId: string): Promise<{
|
|
604
|
+
schema: string;
|
|
605
|
+
}>;
|
|
606
|
+
/**
|
|
607
|
+
* Detaches a schema from a room, and disables runtime schema validation for the room.
|
|
608
|
+
* @param roomId The id of the room to detach the schema from.
|
|
609
|
+
*/
|
|
610
|
+
detachSchemaFromRoom(roomId: string): Promise<void>;
|
|
297
611
|
/**
|
|
298
612
|
* Gets all the threads in a room.
|
|
299
613
|
*
|
|
@@ -302,7 +616,9 @@ declare class Liveblocks {
|
|
|
302
616
|
*/
|
|
303
617
|
getThreads(params: {
|
|
304
618
|
roomId: string;
|
|
305
|
-
}): Promise<
|
|
619
|
+
}): Promise<{
|
|
620
|
+
data: ThreadData[];
|
|
621
|
+
}>;
|
|
306
622
|
/**
|
|
307
623
|
* Gets a thread.
|
|
308
624
|
*
|
|
@@ -343,6 +659,96 @@ declare class Liveblocks {
|
|
|
343
659
|
}): Promise<CommentData>;
|
|
344
660
|
}
|
|
345
661
|
|
|
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
|
+
|
|
346
752
|
declare class WebhookHandler {
|
|
347
753
|
private secretBuffer;
|
|
348
754
|
private static secretPrefix;
|
|
@@ -581,4 +987,4 @@ declare type ThreadCreatedEvent = {
|
|
|
581
987
|
};
|
|
582
988
|
};
|
|
583
989
|
|
|
584
|
-
export { CommentCreatedEvent, CommentDeletedEvent, CommentEditedEvent, CommentReactionAdded, CommentReactionRemoved, Liveblocks, LiveblocksOptions, RoomCreatedEvent, RoomDeletedEvent, StorageUpdatedEvent, ThreadCreatedEvent, ThreadMetadataUpdatedEvent, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize };
|
|
990
|
+
export { CommentBodyLinkElementArgs, CommentBodyMentionElementArgs, CommentBodyParagraphElementArgs, CommentBodyResolveUsersArgs, CommentBodyTextElementArgs, CommentCreatedEvent, CommentData, CommentDeletedEvent, CommentEditedEvent, CommentReactionAdded, CommentReactionRemoved, IUserInfo, Json, JsonObject, Liveblocks, LiveblocksOptions, PlainLsonObject, RoomAccesses, RoomCreatedEvent, RoomDeletedEvent, RoomInfo, RoomPermission, RoomUser, Schema, StorageUpdatedEvent, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadCreatedEvent, ThreadData, ThreadMetadataUpdatedEvent, ThreadParticipants, UserEnteredEvent, UserLeftEvent, WebhookEvent, WebhookHandler, WebhookRequest, authorize, getMentionedIdsFromCommentBody, stringifyCommentBody };
|