@liveblocks/node 1.8.2 → 1.9.0-example1
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 +136 -5
- package/dist/index.d.ts +136 -5
- package/dist/index.js +193 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +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
|
+
import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction } from '@liveblocks/core';
|
|
2
|
+
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyResolveUsersArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -152,6 +152,9 @@ declare type LiveblocksOptions = {
|
|
|
152
152
|
*/
|
|
153
153
|
secret: string;
|
|
154
154
|
};
|
|
155
|
+
declare type Nullable<T> = {
|
|
156
|
+
[P in keyof T]: T[P] | null;
|
|
157
|
+
};
|
|
155
158
|
declare type CreateSessionOptions = {
|
|
156
159
|
userInfo: IUserInfo;
|
|
157
160
|
};
|
|
@@ -326,7 +329,9 @@ declare class Liveblocks {
|
|
|
326
329
|
* @param roomId The id of the room to get the users from.
|
|
327
330
|
* @returns A list of users currently present in the requested room.
|
|
328
331
|
*/
|
|
329
|
-
getActiveUsers<T = unknown>(roomId: string): Promise<
|
|
332
|
+
getActiveUsers<T = unknown>(roomId: string): Promise<{
|
|
333
|
+
data: RoomUser<T>[];
|
|
334
|
+
}>;
|
|
330
335
|
/**
|
|
331
336
|
* 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.
|
|
332
337
|
* @param roomId The id of the room to broadcast the event to.
|
|
@@ -460,10 +465,10 @@ declare class Liveblocks {
|
|
|
460
465
|
* @param params.threadId The thread ID.
|
|
461
466
|
* @returns A thread.
|
|
462
467
|
*/
|
|
463
|
-
getThread(params: {
|
|
468
|
+
getThread<TThreadMetadata extends BaseMetadata = never>(params: {
|
|
464
469
|
roomId: string;
|
|
465
470
|
threadId: string;
|
|
466
|
-
}): Promise<ThreadData
|
|
471
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
467
472
|
/**
|
|
468
473
|
* Gets a thread's participants.
|
|
469
474
|
*
|
|
@@ -491,6 +496,132 @@ declare class Liveblocks {
|
|
|
491
496
|
threadId: string;
|
|
492
497
|
commentId: string;
|
|
493
498
|
}): Promise<CommentData>;
|
|
499
|
+
/**
|
|
500
|
+
* Creates a comment.
|
|
501
|
+
*
|
|
502
|
+
* @param params.roomId The room ID to create the comment in.
|
|
503
|
+
* @param params.threadId The thread ID to create the comment in.
|
|
504
|
+
* @param params.data.userId The user ID of the user who is set to create the comment.
|
|
505
|
+
* @param params.data.createdAt (optional) The date the comment is set to be created.
|
|
506
|
+
* @param params.data.body The body of the comment.
|
|
507
|
+
* @returns The created comment.
|
|
508
|
+
*/
|
|
509
|
+
createComment(params: {
|
|
510
|
+
roomId: string;
|
|
511
|
+
threadId: string;
|
|
512
|
+
data: {
|
|
513
|
+
userId: string;
|
|
514
|
+
createdAt?: Date;
|
|
515
|
+
body: CommentBody;
|
|
516
|
+
};
|
|
517
|
+
}): Promise<CommentData>;
|
|
518
|
+
/**
|
|
519
|
+
* Edits a comment.
|
|
520
|
+
* @param params.roomId The room ID to edit the comment in.
|
|
521
|
+
* @param params.threadId The thread ID to edit the comment in.
|
|
522
|
+
* @param params.commentId The comment ID to edit.
|
|
523
|
+
* @param params.data.body The body of the comment.
|
|
524
|
+
* @param params.data.editedAt (optional) The date the comment was edited.
|
|
525
|
+
* @returns The edited comment.
|
|
526
|
+
*/
|
|
527
|
+
editComment(params: {
|
|
528
|
+
roomId: string;
|
|
529
|
+
threadId: string;
|
|
530
|
+
commentId: string;
|
|
531
|
+
data: {
|
|
532
|
+
body: CommentBody;
|
|
533
|
+
editedAt?: Date;
|
|
534
|
+
};
|
|
535
|
+
}): Promise<CommentData>;
|
|
536
|
+
/**
|
|
537
|
+
* Deletes a comment. Deletes a comment. If there are no remaining comments in the thread, the thread is also deleted.
|
|
538
|
+
* @param params.roomId The room ID to delete the comment in.
|
|
539
|
+
* @param params.threadId The thread ID to delete the comment in.
|
|
540
|
+
* @param params.commentId The comment ID to delete.
|
|
541
|
+
*/
|
|
542
|
+
deleteComment(params: {
|
|
543
|
+
roomId: string;
|
|
544
|
+
threadId: string;
|
|
545
|
+
commentId: string;
|
|
546
|
+
}): Promise<void>;
|
|
547
|
+
/**
|
|
548
|
+
* Creates a new thread. The thread will be created with the specified comment as its first comment.
|
|
549
|
+
* If the thread already exists, a `LiveblocksError` will be thrown with status code 409.
|
|
550
|
+
* @param params.roomId The room ID to create the thread in.
|
|
551
|
+
* @param params.thread.metadata (optional) The metadata for the thread. Supports upto a maximum of 10 entries. Value must be a string, boolean or number
|
|
552
|
+
* @param params.thread.comment.userId The user ID of the user who created the comment.
|
|
553
|
+
* @param params.thread.comment.createdAt (optional) The date the comment was created.
|
|
554
|
+
* @param params.thread.comment.body The body of the comment.
|
|
555
|
+
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
556
|
+
*/
|
|
557
|
+
createThread<TThreadMetadata extends BaseMetadata = never>(params: {
|
|
558
|
+
roomId: string;
|
|
559
|
+
data: {
|
|
560
|
+
metadata?: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
|
|
561
|
+
comment: {
|
|
562
|
+
userId: string;
|
|
563
|
+
createdAt?: Date;
|
|
564
|
+
body: CommentBody;
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
568
|
+
/**
|
|
569
|
+
* Updates the metadata of the specified thread in a room.
|
|
570
|
+
* @param params.roomId The room ID to update the thread in.
|
|
571
|
+
* @param params.threadId The thread ID to update.
|
|
572
|
+
* @param params.data.metadata The metadata for the thread. Value must be a string, boolean or number
|
|
573
|
+
* @param params.data.userId The user ID of the user who updated the thread.
|
|
574
|
+
* @param params.data.updatedAt (optional) The date the thread is set to be updated.
|
|
575
|
+
* @returns The updated thread.
|
|
576
|
+
*/
|
|
577
|
+
editThreadMetadata<TThreadMetadata extends BaseMetadata = never>(params: {
|
|
578
|
+
roomId: string;
|
|
579
|
+
threadId: string;
|
|
580
|
+
data: {
|
|
581
|
+
metadata: Nullable<BaseMetadata>;
|
|
582
|
+
userId: string;
|
|
583
|
+
updatedAt?: Date;
|
|
584
|
+
};
|
|
585
|
+
}): Promise<TThreadMetadata>;
|
|
586
|
+
/**
|
|
587
|
+
* Adds a new comment reaction to a comment.
|
|
588
|
+
* @param params.roomId The room ID to add the comment reaction in.
|
|
589
|
+
* @param params.threadId The thread ID to add the comment reaction in.
|
|
590
|
+
* @param params.commentId The comment ID to add the reaction in.
|
|
591
|
+
* @param params.data.emoji The (emoji) reaction to add.
|
|
592
|
+
* @param params.data.userId The user ID of the user associated with the reaction.
|
|
593
|
+
* @param params.data.createdAt (optional) The date the reaction is set to be created.
|
|
594
|
+
* @returns The created comment reaction.
|
|
595
|
+
*/
|
|
596
|
+
addCommentReaction(params: {
|
|
597
|
+
roomId: string;
|
|
598
|
+
threadId: string;
|
|
599
|
+
commentId: string;
|
|
600
|
+
data: {
|
|
601
|
+
emoji: string;
|
|
602
|
+
userId: string;
|
|
603
|
+
createdAt?: Date;
|
|
604
|
+
};
|
|
605
|
+
}): Promise<CommentUserReaction>;
|
|
606
|
+
/**
|
|
607
|
+
* Removes a reaction from a comment.
|
|
608
|
+
* @param params.roomId The room ID to remove the comment reaction from.
|
|
609
|
+
* @param params.threadId The thread ID to remove the comment reaction from.
|
|
610
|
+
* @param params.commentId The comment ID to remove the reaction from.
|
|
611
|
+
* @param params.data.emoji The (emoji) reaction to remove.
|
|
612
|
+
* @param params.data.userId The user ID of the user associated with the reaction.
|
|
613
|
+
* @param params.data.removedAt (optional) The date the reaction is set to be removed.
|
|
614
|
+
*/
|
|
615
|
+
removeCommentReaction(params: {
|
|
616
|
+
roomId: string;
|
|
617
|
+
threadId: string;
|
|
618
|
+
commentId: string;
|
|
619
|
+
data: {
|
|
620
|
+
emoji: string;
|
|
621
|
+
userId: string;
|
|
622
|
+
removedAt?: Date;
|
|
623
|
+
};
|
|
624
|
+
}): Promise<void>;
|
|
494
625
|
}
|
|
495
626
|
|
|
496
627
|
declare class WebhookHandler {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +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
|
+
import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction } from '@liveblocks/core';
|
|
2
|
+
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyResolveUsersArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -152,6 +152,9 @@ declare type LiveblocksOptions = {
|
|
|
152
152
|
*/
|
|
153
153
|
secret: string;
|
|
154
154
|
};
|
|
155
|
+
declare type Nullable<T> = {
|
|
156
|
+
[P in keyof T]: T[P] | null;
|
|
157
|
+
};
|
|
155
158
|
declare type CreateSessionOptions = {
|
|
156
159
|
userInfo: IUserInfo;
|
|
157
160
|
};
|
|
@@ -326,7 +329,9 @@ declare class Liveblocks {
|
|
|
326
329
|
* @param roomId The id of the room to get the users from.
|
|
327
330
|
* @returns A list of users currently present in the requested room.
|
|
328
331
|
*/
|
|
329
|
-
getActiveUsers<T = unknown>(roomId: string): Promise<
|
|
332
|
+
getActiveUsers<T = unknown>(roomId: string): Promise<{
|
|
333
|
+
data: RoomUser<T>[];
|
|
334
|
+
}>;
|
|
330
335
|
/**
|
|
331
336
|
* 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.
|
|
332
337
|
* @param roomId The id of the room to broadcast the event to.
|
|
@@ -460,10 +465,10 @@ declare class Liveblocks {
|
|
|
460
465
|
* @param params.threadId The thread ID.
|
|
461
466
|
* @returns A thread.
|
|
462
467
|
*/
|
|
463
|
-
getThread(params: {
|
|
468
|
+
getThread<TThreadMetadata extends BaseMetadata = never>(params: {
|
|
464
469
|
roomId: string;
|
|
465
470
|
threadId: string;
|
|
466
|
-
}): Promise<ThreadData
|
|
471
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
467
472
|
/**
|
|
468
473
|
* Gets a thread's participants.
|
|
469
474
|
*
|
|
@@ -491,6 +496,132 @@ declare class Liveblocks {
|
|
|
491
496
|
threadId: string;
|
|
492
497
|
commentId: string;
|
|
493
498
|
}): Promise<CommentData>;
|
|
499
|
+
/**
|
|
500
|
+
* Creates a comment.
|
|
501
|
+
*
|
|
502
|
+
* @param params.roomId The room ID to create the comment in.
|
|
503
|
+
* @param params.threadId The thread ID to create the comment in.
|
|
504
|
+
* @param params.data.userId The user ID of the user who is set to create the comment.
|
|
505
|
+
* @param params.data.createdAt (optional) The date the comment is set to be created.
|
|
506
|
+
* @param params.data.body The body of the comment.
|
|
507
|
+
* @returns The created comment.
|
|
508
|
+
*/
|
|
509
|
+
createComment(params: {
|
|
510
|
+
roomId: string;
|
|
511
|
+
threadId: string;
|
|
512
|
+
data: {
|
|
513
|
+
userId: string;
|
|
514
|
+
createdAt?: Date;
|
|
515
|
+
body: CommentBody;
|
|
516
|
+
};
|
|
517
|
+
}): Promise<CommentData>;
|
|
518
|
+
/**
|
|
519
|
+
* Edits a comment.
|
|
520
|
+
* @param params.roomId The room ID to edit the comment in.
|
|
521
|
+
* @param params.threadId The thread ID to edit the comment in.
|
|
522
|
+
* @param params.commentId The comment ID to edit.
|
|
523
|
+
* @param params.data.body The body of the comment.
|
|
524
|
+
* @param params.data.editedAt (optional) The date the comment was edited.
|
|
525
|
+
* @returns The edited comment.
|
|
526
|
+
*/
|
|
527
|
+
editComment(params: {
|
|
528
|
+
roomId: string;
|
|
529
|
+
threadId: string;
|
|
530
|
+
commentId: string;
|
|
531
|
+
data: {
|
|
532
|
+
body: CommentBody;
|
|
533
|
+
editedAt?: Date;
|
|
534
|
+
};
|
|
535
|
+
}): Promise<CommentData>;
|
|
536
|
+
/**
|
|
537
|
+
* Deletes a comment. Deletes a comment. If there are no remaining comments in the thread, the thread is also deleted.
|
|
538
|
+
* @param params.roomId The room ID to delete the comment in.
|
|
539
|
+
* @param params.threadId The thread ID to delete the comment in.
|
|
540
|
+
* @param params.commentId The comment ID to delete.
|
|
541
|
+
*/
|
|
542
|
+
deleteComment(params: {
|
|
543
|
+
roomId: string;
|
|
544
|
+
threadId: string;
|
|
545
|
+
commentId: string;
|
|
546
|
+
}): Promise<void>;
|
|
547
|
+
/**
|
|
548
|
+
* Creates a new thread. The thread will be created with the specified comment as its first comment.
|
|
549
|
+
* If the thread already exists, a `LiveblocksError` will be thrown with status code 409.
|
|
550
|
+
* @param params.roomId The room ID to create the thread in.
|
|
551
|
+
* @param params.thread.metadata (optional) The metadata for the thread. Supports upto a maximum of 10 entries. Value must be a string, boolean or number
|
|
552
|
+
* @param params.thread.comment.userId The user ID of the user who created the comment.
|
|
553
|
+
* @param params.thread.comment.createdAt (optional) The date the comment was created.
|
|
554
|
+
* @param params.thread.comment.body The body of the comment.
|
|
555
|
+
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
556
|
+
*/
|
|
557
|
+
createThread<TThreadMetadata extends BaseMetadata = never>(params: {
|
|
558
|
+
roomId: string;
|
|
559
|
+
data: {
|
|
560
|
+
metadata?: [TThreadMetadata] extends [never] ? Record<string, never> : TThreadMetadata;
|
|
561
|
+
comment: {
|
|
562
|
+
userId: string;
|
|
563
|
+
createdAt?: Date;
|
|
564
|
+
body: CommentBody;
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
}): Promise<ThreadData<TThreadMetadata>>;
|
|
568
|
+
/**
|
|
569
|
+
* Updates the metadata of the specified thread in a room.
|
|
570
|
+
* @param params.roomId The room ID to update the thread in.
|
|
571
|
+
* @param params.threadId The thread ID to update.
|
|
572
|
+
* @param params.data.metadata The metadata for the thread. Value must be a string, boolean or number
|
|
573
|
+
* @param params.data.userId The user ID of the user who updated the thread.
|
|
574
|
+
* @param params.data.updatedAt (optional) The date the thread is set to be updated.
|
|
575
|
+
* @returns The updated thread.
|
|
576
|
+
*/
|
|
577
|
+
editThreadMetadata<TThreadMetadata extends BaseMetadata = never>(params: {
|
|
578
|
+
roomId: string;
|
|
579
|
+
threadId: string;
|
|
580
|
+
data: {
|
|
581
|
+
metadata: Nullable<BaseMetadata>;
|
|
582
|
+
userId: string;
|
|
583
|
+
updatedAt?: Date;
|
|
584
|
+
};
|
|
585
|
+
}): Promise<TThreadMetadata>;
|
|
586
|
+
/**
|
|
587
|
+
* Adds a new comment reaction to a comment.
|
|
588
|
+
* @param params.roomId The room ID to add the comment reaction in.
|
|
589
|
+
* @param params.threadId The thread ID to add the comment reaction in.
|
|
590
|
+
* @param params.commentId The comment ID to add the reaction in.
|
|
591
|
+
* @param params.data.emoji The (emoji) reaction to add.
|
|
592
|
+
* @param params.data.userId The user ID of the user associated with the reaction.
|
|
593
|
+
* @param params.data.createdAt (optional) The date the reaction is set to be created.
|
|
594
|
+
* @returns The created comment reaction.
|
|
595
|
+
*/
|
|
596
|
+
addCommentReaction(params: {
|
|
597
|
+
roomId: string;
|
|
598
|
+
threadId: string;
|
|
599
|
+
commentId: string;
|
|
600
|
+
data: {
|
|
601
|
+
emoji: string;
|
|
602
|
+
userId: string;
|
|
603
|
+
createdAt?: Date;
|
|
604
|
+
};
|
|
605
|
+
}): Promise<CommentUserReaction>;
|
|
606
|
+
/**
|
|
607
|
+
* Removes a reaction from a comment.
|
|
608
|
+
* @param params.roomId The room ID to remove the comment reaction from.
|
|
609
|
+
* @param params.threadId The thread ID to remove the comment reaction from.
|
|
610
|
+
* @param params.commentId The comment ID to remove the reaction from.
|
|
611
|
+
* @param params.data.emoji The (emoji) reaction to remove.
|
|
612
|
+
* @param params.data.userId The user ID of the user associated with the reaction.
|
|
613
|
+
* @param params.data.removedAt (optional) The date the reaction is set to be removed.
|
|
614
|
+
*/
|
|
615
|
+
removeCommentReaction(params: {
|
|
616
|
+
roomId: string;
|
|
617
|
+
threadId: string;
|
|
618
|
+
commentId: string;
|
|
619
|
+
data: {
|
|
620
|
+
emoji: string;
|
|
621
|
+
userId: string;
|
|
622
|
+
removedAt?: Date;
|
|
623
|
+
};
|
|
624
|
+
}): Promise<void>;
|
|
494
625
|
}
|
|
495
626
|
|
|
496
627
|
declare class WebhookHandler {
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var _core = require('@liveblocks/core');
|
|
|
3
3
|
|
|
4
4
|
// src/version.ts
|
|
5
5
|
var PKG_NAME = "@liveblocks/node";
|
|
6
|
-
var PKG_VERSION = "1.
|
|
6
|
+
var PKG_VERSION = "1.9.0-example1";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
@@ -101,6 +101,13 @@ function buildLiveblocksAuthorizeEndpoint(options, roomId) {
|
|
|
101
101
|
return urljoin(options.baseUrl || DEFAULT_BASE_URL, path);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
// src/client.ts
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
104
111
|
// src/Session.ts
|
|
105
112
|
var ALL_PERMISSIONS = Object.freeze([
|
|
106
113
|
"room:write",
|
|
@@ -281,6 +288,7 @@ var Liveblocks = class {
|
|
|
281
288
|
/** @internal */
|
|
282
289
|
async get(path, params) {
|
|
283
290
|
const url2 = urljoin(this._baseUrl, path, params);
|
|
291
|
+
console.log("url", url2);
|
|
284
292
|
const headers = {
|
|
285
293
|
Authorization: `Bearer ${this._secret}`
|
|
286
294
|
};
|
|
@@ -763,12 +771,17 @@ var Liveblocks = class {
|
|
|
763
771
|
*/
|
|
764
772
|
async getThreads(params) {
|
|
765
773
|
const { roomId } = params;
|
|
766
|
-
const res = await this.get(url`/v2/rooms/${roomId}/threads
|
|
774
|
+
const res = await this.get(url`/v2/rooms/${roomId}/threads`, {
|
|
775
|
+
"metadata.resolved": "false"
|
|
776
|
+
});
|
|
767
777
|
if (!res.ok) {
|
|
768
778
|
const text = await res.text();
|
|
769
779
|
throw new LiveblocksError(res.status, text);
|
|
770
780
|
}
|
|
771
|
-
|
|
781
|
+
const { data } = await res.json();
|
|
782
|
+
return {
|
|
783
|
+
data: data.map((thread) => _core.convertToThreadData.call(void 0, thread))
|
|
784
|
+
};
|
|
772
785
|
}
|
|
773
786
|
/**
|
|
774
787
|
* Gets a thread.
|
|
@@ -784,7 +797,9 @@ var Liveblocks = class {
|
|
|
784
797
|
const text = await res.text();
|
|
785
798
|
throw new LiveblocksError(res.status, text);
|
|
786
799
|
}
|
|
787
|
-
return
|
|
800
|
+
return _core.convertToThreadData.call(void 0,
|
|
801
|
+
await res.json()
|
|
802
|
+
);
|
|
788
803
|
}
|
|
789
804
|
/**
|
|
790
805
|
* Gets a thread's participants.
|
|
@@ -824,8 +839,173 @@ var Liveblocks = class {
|
|
|
824
839
|
const text = await res.text();
|
|
825
840
|
throw new LiveblocksError(res.status, text);
|
|
826
841
|
}
|
|
842
|
+
return _core.convertToCommentData.call(void 0, await res.json());
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Creates a comment.
|
|
846
|
+
*
|
|
847
|
+
* @param params.roomId The room ID to create the comment in.
|
|
848
|
+
* @param params.threadId The thread ID to create the comment in.
|
|
849
|
+
* @param params.data.userId The user ID of the user who is set to create the comment.
|
|
850
|
+
* @param params.data.createdAt (optional) The date the comment is set to be created.
|
|
851
|
+
* @param params.data.body The body of the comment.
|
|
852
|
+
* @returns The created comment.
|
|
853
|
+
*/
|
|
854
|
+
async createComment(params) {
|
|
855
|
+
const { roomId, threadId, data } = params;
|
|
856
|
+
const res = await this.post(
|
|
857
|
+
url`/v2/rooms/${roomId}/threads/${threadId}/comments`,
|
|
858
|
+
{
|
|
859
|
+
...data,
|
|
860
|
+
createdAt: _optionalChain([data, 'access', _3 => _3.createdAt, 'optionalAccess', _4 => _4.toISOString, 'call', _5 => _5()])
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
if (!res.ok) {
|
|
864
|
+
const text = await res.text();
|
|
865
|
+
throw new LiveblocksError(res.status, text);
|
|
866
|
+
}
|
|
867
|
+
return _core.convertToCommentData.call(void 0, await res.json());
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Edits a comment.
|
|
871
|
+
* @param params.roomId The room ID to edit the comment in.
|
|
872
|
+
* @param params.threadId The thread ID to edit the comment in.
|
|
873
|
+
* @param params.commentId The comment ID to edit.
|
|
874
|
+
* @param params.data.body The body of the comment.
|
|
875
|
+
* @param params.data.editedAt (optional) The date the comment was edited.
|
|
876
|
+
* @returns The edited comment.
|
|
877
|
+
*/
|
|
878
|
+
async editComment(params) {
|
|
879
|
+
const { roomId, threadId, commentId, data } = params;
|
|
880
|
+
const res = await this.post(
|
|
881
|
+
url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`,
|
|
882
|
+
{
|
|
883
|
+
...data,
|
|
884
|
+
editedAt: _optionalChain([data, 'access', _6 => _6.editedAt, 'optionalAccess', _7 => _7.toISOString, 'call', _8 => _8()])
|
|
885
|
+
}
|
|
886
|
+
);
|
|
887
|
+
if (!res.ok) {
|
|
888
|
+
const text = await res.text();
|
|
889
|
+
throw new LiveblocksError(res.status, text);
|
|
890
|
+
}
|
|
891
|
+
return _core.convertToCommentData.call(void 0, await res.json());
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Deletes a comment. Deletes a comment. If there are no remaining comments in the thread, the thread is also deleted.
|
|
895
|
+
* @param params.roomId The room ID to delete the comment in.
|
|
896
|
+
* @param params.threadId The thread ID to delete the comment in.
|
|
897
|
+
* @param params.commentId The comment ID to delete.
|
|
898
|
+
*/
|
|
899
|
+
async deleteComment(params) {
|
|
900
|
+
const { roomId, threadId, commentId } = params;
|
|
901
|
+
const res = await this.delete(
|
|
902
|
+
url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}`
|
|
903
|
+
);
|
|
904
|
+
if (!res.ok) {
|
|
905
|
+
const text = await res.text();
|
|
906
|
+
throw new LiveblocksError(res.status, text);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Creates a new thread. The thread will be created with the specified comment as its first comment.
|
|
911
|
+
* If the thread already exists, a `LiveblocksError` will be thrown with status code 409.
|
|
912
|
+
* @param params.roomId The room ID to create the thread in.
|
|
913
|
+
* @param params.thread.metadata (optional) The metadata for the thread. Supports upto a maximum of 10 entries. Value must be a string, boolean or number
|
|
914
|
+
* @param params.thread.comment.userId The user ID of the user who created the comment.
|
|
915
|
+
* @param params.thread.comment.createdAt (optional) The date the comment was created.
|
|
916
|
+
* @param params.thread.comment.body The body of the comment.
|
|
917
|
+
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
918
|
+
*/
|
|
919
|
+
async createThread(params) {
|
|
920
|
+
const { roomId, data } = params;
|
|
921
|
+
const res = await this.post(url`/v2/rooms/${roomId}/threads`, {
|
|
922
|
+
...data,
|
|
923
|
+
comment: {
|
|
924
|
+
...data.comment,
|
|
925
|
+
createdAt: _optionalChain([data, 'access', _9 => _9.comment, 'access', _10 => _10.createdAt, 'optionalAccess', _11 => _11.toISOString, 'call', _12 => _12()])
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
if (!res.ok) {
|
|
929
|
+
const text = await res.text();
|
|
930
|
+
throw new LiveblocksError(res.status, text);
|
|
931
|
+
}
|
|
932
|
+
return _core.convertToThreadData.call(void 0,
|
|
933
|
+
await res.json()
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Updates the metadata of the specified thread in a room.
|
|
938
|
+
* @param params.roomId The room ID to update the thread in.
|
|
939
|
+
* @param params.threadId The thread ID to update.
|
|
940
|
+
* @param params.data.metadata The metadata for the thread. Value must be a string, boolean or number
|
|
941
|
+
* @param params.data.userId The user ID of the user who updated the thread.
|
|
942
|
+
* @param params.data.updatedAt (optional) The date the thread is set to be updated.
|
|
943
|
+
* @returns The updated thread.
|
|
944
|
+
*/
|
|
945
|
+
async editThreadMetadata(params) {
|
|
946
|
+
const { roomId, threadId, data } = params;
|
|
947
|
+
const res = await this.post(
|
|
948
|
+
url`/v2/rooms/${roomId}/threads/${threadId}/metadata`,
|
|
949
|
+
{
|
|
950
|
+
...data,
|
|
951
|
+
updatedAt: _optionalChain([data, 'access', _13 => _13.updatedAt, 'optionalAccess', _14 => _14.toISOString, 'call', _15 => _15()])
|
|
952
|
+
}
|
|
953
|
+
);
|
|
954
|
+
if (!res.ok) {
|
|
955
|
+
const text = await res.text();
|
|
956
|
+
throw new LiveblocksError(res.status, text);
|
|
957
|
+
}
|
|
827
958
|
return await res.json();
|
|
828
959
|
}
|
|
960
|
+
/**
|
|
961
|
+
* Adds a new comment reaction to a comment.
|
|
962
|
+
* @param params.roomId The room ID to add the comment reaction in.
|
|
963
|
+
* @param params.threadId The thread ID to add the comment reaction in.
|
|
964
|
+
* @param params.commentId The comment ID to add the reaction in.
|
|
965
|
+
* @param params.data.emoji The (emoji) reaction to add.
|
|
966
|
+
* @param params.data.userId The user ID of the user associated with the reaction.
|
|
967
|
+
* @param params.data.createdAt (optional) The date the reaction is set to be created.
|
|
968
|
+
* @returns The created comment reaction.
|
|
969
|
+
*/
|
|
970
|
+
async addCommentReaction(params) {
|
|
971
|
+
const { roomId, threadId, commentId, data } = params;
|
|
972
|
+
const res = await this.post(
|
|
973
|
+
url`/v2/rooms/${roomId}/threads/${threadId}/comments/${commentId}/add-reaction`,
|
|
974
|
+
{
|
|
975
|
+
...data,
|
|
976
|
+
createdAt: _optionalChain([data, 'access', _16 => _16.createdAt, 'optionalAccess', _17 => _17.toISOString, 'call', _18 => _18()])
|
|
977
|
+
}
|
|
978
|
+
);
|
|
979
|
+
if (!res.ok) {
|
|
980
|
+
const text = await res.text();
|
|
981
|
+
throw new LiveblocksError(res.status, text);
|
|
982
|
+
}
|
|
983
|
+
const reaction = await res.json();
|
|
984
|
+
return _core.convertToCommentUserReaction.call(void 0, reaction);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Removes a reaction from a comment.
|
|
988
|
+
* @param params.roomId The room ID to remove the comment reaction from.
|
|
989
|
+
* @param params.threadId The thread ID to remove the comment reaction from.
|
|
990
|
+
* @param params.commentId The comment ID to remove the reaction from.
|
|
991
|
+
* @param params.data.emoji The (emoji) reaction to remove.
|
|
992
|
+
* @param params.data.userId The user ID of the user associated with the reaction.
|
|
993
|
+
* @param params.data.removedAt (optional) The date the reaction is set to be removed.
|
|
994
|
+
*/
|
|
995
|
+
async removeCommentReaction(params) {
|
|
996
|
+
const { roomId, threadId, data } = params;
|
|
997
|
+
const res = await this.post(
|
|
998
|
+
url`/v2/rooms/${roomId}/threads/${threadId}/comments/${params.commentId}/remove-reaction`,
|
|
999
|
+
{
|
|
1000
|
+
...data,
|
|
1001
|
+
removedAt: _optionalChain([data, 'access', _19 => _19.removedAt, 'optionalAccess', _20 => _20.toISOString, 'call', _21 => _21()])
|
|
1002
|
+
}
|
|
1003
|
+
);
|
|
1004
|
+
if (!res.ok) {
|
|
1005
|
+
const text = await res.text();
|
|
1006
|
+
throw new LiveblocksError(res.status, text);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
829
1009
|
};
|
|
830
1010
|
var LiveblocksError = class extends Error {
|
|
831
1011
|
constructor(status, message = "") {
|
|
@@ -853,11 +1033,15 @@ var _WebhookHandler = class _WebhookHandler {
|
|
|
853
1033
|
* Verifies a webhook request and returns the event
|
|
854
1034
|
*/
|
|
855
1035
|
verifyRequest(request) {
|
|
856
|
-
const {
|
|
857
|
-
|
|
858
|
-
)
|
|
1036
|
+
const { headers, rawBody } = request;
|
|
1037
|
+
const { webhookId, timestamp, rawSignatures } = this.verifyHeaders(headers);
|
|
1038
|
+
if (typeof rawBody !== "string") {
|
|
1039
|
+
throw new Error(
|
|
1040
|
+
`Invalid rawBody field, must be a string, got "${typeof rawBody}" instead. It is likely that you need to JSON.stringify the body before passing it.`
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
859
1043
|
this.verifyTimestamp(timestamp);
|
|
860
|
-
const signature = this.sign(`${webhookId}.${timestamp}.${
|
|
1044
|
+
const signature = this.sign(`${webhookId}.${timestamp}.${rawBody}`);
|
|
861
1045
|
const expectedSignatures = rawSignatures.split(" ").map((rawSignature) => {
|
|
862
1046
|
const [, parsedSignature] = rawSignature.split(",");
|
|
863
1047
|
return parsedSignature;
|
|
@@ -868,7 +1052,7 @@ var _WebhookHandler = class _WebhookHandler {
|
|
|
868
1052
|
", "
|
|
869
1053
|
)}, got ${signature}`
|
|
870
1054
|
);
|
|
871
|
-
const event = JSON.parse(
|
|
1055
|
+
const event = JSON.parse(rawBody);
|
|
872
1056
|
this.verifyWebhookEventType(event);
|
|
873
1057
|
return event;
|
|
874
1058
|
}
|