@liveblocks/node 1.12.0 → 2.0.0-alpha1
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 +14 -101
- package/dist/index.d.ts +14 -101
- package/dist/index.js +13 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,95 +1,7 @@
|
|
|
1
|
-
import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core';
|
|
1
|
+
import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, DM, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core';
|
|
2
2
|
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
7
|
-
*/
|
|
8
|
-
declare type AuthorizeOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* The secret API key for your Liveblocks account. You can find it on
|
|
11
|
-
* https://liveblocks.io/dashboard/apikeys
|
|
12
|
-
*/
|
|
13
|
-
secret: string;
|
|
14
|
-
/**
|
|
15
|
-
* The room ID for which to authorize the user. This will authorize the user
|
|
16
|
-
* to enter the Liveblocks room.
|
|
17
|
-
*/
|
|
18
|
-
room: string;
|
|
19
|
-
/**
|
|
20
|
-
* Associates a user ID to the session that is being authorized. The user ID
|
|
21
|
-
* is typically set to the user ID from your own database.
|
|
22
|
-
*
|
|
23
|
-
* It can also be used to generate a token that gives access to a private
|
|
24
|
-
* room where the userId is configured in the room accesses.
|
|
25
|
-
*
|
|
26
|
-
* This user ID will be used as the unique identifier to compute your
|
|
27
|
-
* Liveblocks account's Monthly Active Users.
|
|
28
|
-
*/
|
|
29
|
-
userId: string;
|
|
30
|
-
/**
|
|
31
|
-
* Arbitrary metadata associated to this user session.
|
|
32
|
-
*
|
|
33
|
-
* You can use it to store a small amount of static metadata for a user
|
|
34
|
-
* session. It is public information, that will be visible to other users in
|
|
35
|
-
* the same room, like name, avatar URL, etc.
|
|
36
|
-
*
|
|
37
|
-
* It's only suitable for static info that won't change during a session. If
|
|
38
|
-
* you want to store dynamic metadata on a user session, don't keep that in
|
|
39
|
-
* the session token, but use Presence instead.
|
|
40
|
-
*
|
|
41
|
-
* Can't exceed 1KB when serialized as JSON.
|
|
42
|
-
*/
|
|
43
|
-
userInfo?: unknown;
|
|
44
|
-
/**
|
|
45
|
-
* Tell Liveblocks which group IDs this user belongs to. This will authorize
|
|
46
|
-
* the user session to access private rooms that have at least one of these
|
|
47
|
-
* group IDs listed in their room access configuration.
|
|
48
|
-
*
|
|
49
|
-
* See https://liveblocks.io/docs/guides/managing-rooms-users-permissions#permissions
|
|
50
|
-
* for how to configure your room's permissions to use this feature.
|
|
51
|
-
*/
|
|
52
|
-
groupIds?: string[];
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
56
|
-
*/
|
|
57
|
-
declare type AuthorizeResponse = {
|
|
58
|
-
status: number;
|
|
59
|
-
body: string;
|
|
60
|
-
error?: Error;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Since 1.2, we’re deprecating single-room tokens in favor of
|
|
64
|
-
* either access tokens or ID tokens. Single-room tokens are still supported,
|
|
65
|
-
* but support for them will be dropped in the future. Please refer to our
|
|
66
|
-
* Upgrade Guide to learn how to adopt the new-style authorization, see
|
|
67
|
-
* https://liveblocks.io/docs/platform/upgrading/1.2
|
|
68
|
-
*
|
|
69
|
-
* Tells Liveblocks that a user should be allowed access to a room, which user
|
|
70
|
-
* this session is for, and what metadata to associate with the user (like
|
|
71
|
-
* name, avatar, etc.)
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* export default async function auth(req, res) {
|
|
75
|
-
*
|
|
76
|
-
* // Implement your own security here.
|
|
77
|
-
*
|
|
78
|
-
* const room = req.body.room;
|
|
79
|
-
* const response = await authorize({
|
|
80
|
-
* room,
|
|
81
|
-
* secret,
|
|
82
|
-
* userId: "123",
|
|
83
|
-
* userInfo: { // Optional
|
|
84
|
-
* name: "Ada Lovelace"
|
|
85
|
-
* },
|
|
86
|
-
* groupIds: ["group1"] // Optional
|
|
87
|
-
* });
|
|
88
|
-
* return res.status(response.status).end(response.body);
|
|
89
|
-
* }
|
|
90
|
-
*/
|
|
91
|
-
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
92
|
-
|
|
93
5
|
declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read"];
|
|
94
6
|
declare type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
95
7
|
/**
|
|
@@ -274,7 +186,8 @@ declare class Liveblocks {
|
|
|
274
186
|
limit?: number;
|
|
275
187
|
startingAfter?: string;
|
|
276
188
|
/**
|
|
277
|
-
* @deprecated Use `query` instead.
|
|
189
|
+
* @deprecated Use `query` property instead. Support for the `metadata`
|
|
190
|
+
* field will be removed in a future version.
|
|
278
191
|
*/
|
|
279
192
|
metadata?: QueryRoomMetadata;
|
|
280
193
|
userId?: string;
|
|
@@ -492,7 +405,7 @@ declare class Liveblocks {
|
|
|
492
405
|
* @param params.query The query to filter threads by. It is based on our query language and can filter by metadata.
|
|
493
406
|
* @returns A list of threads.
|
|
494
407
|
*/
|
|
495
|
-
getThreads<
|
|
408
|
+
getThreads<M extends BaseMetadata = DM>(params: {
|
|
496
409
|
roomId: string;
|
|
497
410
|
/**
|
|
498
411
|
* The query to filter threads by. It is based on our query language.
|
|
@@ -520,10 +433,10 @@ declare class Liveblocks {
|
|
|
520
433
|
* ```
|
|
521
434
|
*/
|
|
522
435
|
query?: string | {
|
|
523
|
-
metadata?: Partial<QueryMetadata<
|
|
436
|
+
metadata?: Partial<QueryMetadata<M>>;
|
|
524
437
|
};
|
|
525
438
|
}): Promise<{
|
|
526
|
-
data: ThreadData[];
|
|
439
|
+
data: ThreadData<M>[];
|
|
527
440
|
}>;
|
|
528
441
|
/**
|
|
529
442
|
* Gets a thread.
|
|
@@ -532,10 +445,10 @@ declare class Liveblocks {
|
|
|
532
445
|
* @param params.threadId The thread ID.
|
|
533
446
|
* @returns A thread.
|
|
534
447
|
*/
|
|
535
|
-
getThread<
|
|
448
|
+
getThread<M extends BaseMetadata = DM>(params: {
|
|
536
449
|
roomId: string;
|
|
537
450
|
threadId: string;
|
|
538
|
-
}): Promise<ThreadData<
|
|
451
|
+
}): Promise<ThreadData<M>>;
|
|
539
452
|
/**
|
|
540
453
|
* Gets a thread's participants.
|
|
541
454
|
*
|
|
@@ -621,17 +534,17 @@ declare class Liveblocks {
|
|
|
621
534
|
* @param params.thread.comment.body The body of the comment.
|
|
622
535
|
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
623
536
|
*/
|
|
624
|
-
createThread<
|
|
537
|
+
createThread<M extends BaseMetadata = DM>(params: {
|
|
625
538
|
roomId: string;
|
|
626
539
|
data: {
|
|
627
|
-
metadata?: [
|
|
540
|
+
metadata?: [M] extends [never] ? Record<string, never> : M;
|
|
628
541
|
comment: {
|
|
629
542
|
userId: string;
|
|
630
543
|
createdAt?: Date;
|
|
631
544
|
body: CommentBody;
|
|
632
545
|
};
|
|
633
546
|
};
|
|
634
|
-
}): Promise<ThreadData<
|
|
547
|
+
}): Promise<ThreadData<M>>;
|
|
635
548
|
/**
|
|
636
549
|
* Updates the metadata of the specified thread in a room.
|
|
637
550
|
* @param params.roomId The room ID to update the thread in.
|
|
@@ -641,7 +554,7 @@ declare class Liveblocks {
|
|
|
641
554
|
* @param params.data.updatedAt (optional) The date the thread is set to be updated.
|
|
642
555
|
* @returns The updated thread.
|
|
643
556
|
*/
|
|
644
|
-
editThreadMetadata<
|
|
557
|
+
editThreadMetadata<M extends BaseMetadata = DM>(params: {
|
|
645
558
|
roomId: string;
|
|
646
559
|
threadId: string;
|
|
647
560
|
data: {
|
|
@@ -649,7 +562,7 @@ declare class Liveblocks {
|
|
|
649
562
|
userId: string;
|
|
650
563
|
updatedAt?: Date;
|
|
651
564
|
};
|
|
652
|
-
}): Promise<
|
|
565
|
+
}): Promise<M>;
|
|
653
566
|
/**
|
|
654
567
|
* Adds a new comment reaction to a comment.
|
|
655
568
|
* @param params.roomId The room ID to add the comment reaction in.
|
|
@@ -1009,4 +922,4 @@ declare type NotificationEvent = {
|
|
|
1009
922
|
};
|
|
1010
923
|
};
|
|
1011
924
|
|
|
1012
|
-
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest
|
|
925
|
+
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,95 +1,7 @@
|
|
|
1
|
-
import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core';
|
|
1
|
+
import { IUserInfo, Json, PlainLsonObject, JsonObject, BaseMetadata, DM, QueryMetadata, ThreadData, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData } from '@liveblocks/core';
|
|
2
2
|
export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionedIdsFromCommentBody, stringifyCommentBody } from '@liveblocks/core';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
7
|
-
*/
|
|
8
|
-
declare type AuthorizeOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* The secret API key for your Liveblocks account. You can find it on
|
|
11
|
-
* https://liveblocks.io/dashboard/apikeys
|
|
12
|
-
*/
|
|
13
|
-
secret: string;
|
|
14
|
-
/**
|
|
15
|
-
* The room ID for which to authorize the user. This will authorize the user
|
|
16
|
-
* to enter the Liveblocks room.
|
|
17
|
-
*/
|
|
18
|
-
room: string;
|
|
19
|
-
/**
|
|
20
|
-
* Associates a user ID to the session that is being authorized. The user ID
|
|
21
|
-
* is typically set to the user ID from your own database.
|
|
22
|
-
*
|
|
23
|
-
* It can also be used to generate a token that gives access to a private
|
|
24
|
-
* room where the userId is configured in the room accesses.
|
|
25
|
-
*
|
|
26
|
-
* This user ID will be used as the unique identifier to compute your
|
|
27
|
-
* Liveblocks account's Monthly Active Users.
|
|
28
|
-
*/
|
|
29
|
-
userId: string;
|
|
30
|
-
/**
|
|
31
|
-
* Arbitrary metadata associated to this user session.
|
|
32
|
-
*
|
|
33
|
-
* You can use it to store a small amount of static metadata for a user
|
|
34
|
-
* session. It is public information, that will be visible to other users in
|
|
35
|
-
* the same room, like name, avatar URL, etc.
|
|
36
|
-
*
|
|
37
|
-
* It's only suitable for static info that won't change during a session. If
|
|
38
|
-
* you want to store dynamic metadata on a user session, don't keep that in
|
|
39
|
-
* the session token, but use Presence instead.
|
|
40
|
-
*
|
|
41
|
-
* Can't exceed 1KB when serialized as JSON.
|
|
42
|
-
*/
|
|
43
|
-
userInfo?: unknown;
|
|
44
|
-
/**
|
|
45
|
-
* Tell Liveblocks which group IDs this user belongs to. This will authorize
|
|
46
|
-
* the user session to access private rooms that have at least one of these
|
|
47
|
-
* group IDs listed in their room access configuration.
|
|
48
|
-
*
|
|
49
|
-
* See https://liveblocks.io/docs/guides/managing-rooms-users-permissions#permissions
|
|
50
|
-
* for how to configure your room's permissions to use this feature.
|
|
51
|
-
*/
|
|
52
|
-
groupIds?: string[];
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* TODO Officially mark as DEPRECATED, point to migration guide.
|
|
56
|
-
*/
|
|
57
|
-
declare type AuthorizeResponse = {
|
|
58
|
-
status: number;
|
|
59
|
-
body: string;
|
|
60
|
-
error?: Error;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Since 1.2, we’re deprecating single-room tokens in favor of
|
|
64
|
-
* either access tokens or ID tokens. Single-room tokens are still supported,
|
|
65
|
-
* but support for them will be dropped in the future. Please refer to our
|
|
66
|
-
* Upgrade Guide to learn how to adopt the new-style authorization, see
|
|
67
|
-
* https://liveblocks.io/docs/platform/upgrading/1.2
|
|
68
|
-
*
|
|
69
|
-
* Tells Liveblocks that a user should be allowed access to a room, which user
|
|
70
|
-
* this session is for, and what metadata to associate with the user (like
|
|
71
|
-
* name, avatar, etc.)
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* export default async function auth(req, res) {
|
|
75
|
-
*
|
|
76
|
-
* // Implement your own security here.
|
|
77
|
-
*
|
|
78
|
-
* const room = req.body.room;
|
|
79
|
-
* const response = await authorize({
|
|
80
|
-
* room,
|
|
81
|
-
* secret,
|
|
82
|
-
* userId: "123",
|
|
83
|
-
* userInfo: { // Optional
|
|
84
|
-
* name: "Ada Lovelace"
|
|
85
|
-
* },
|
|
86
|
-
* groupIds: ["group1"] // Optional
|
|
87
|
-
* });
|
|
88
|
-
* return res.status(response.status).end(response.body);
|
|
89
|
-
* }
|
|
90
|
-
*/
|
|
91
|
-
declare function authorize(options: AuthorizeOptions): Promise<AuthorizeResponse>;
|
|
92
|
-
|
|
93
5
|
declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read"];
|
|
94
6
|
declare type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
95
7
|
/**
|
|
@@ -274,7 +186,8 @@ declare class Liveblocks {
|
|
|
274
186
|
limit?: number;
|
|
275
187
|
startingAfter?: string;
|
|
276
188
|
/**
|
|
277
|
-
* @deprecated Use `query` instead.
|
|
189
|
+
* @deprecated Use `query` property instead. Support for the `metadata`
|
|
190
|
+
* field will be removed in a future version.
|
|
278
191
|
*/
|
|
279
192
|
metadata?: QueryRoomMetadata;
|
|
280
193
|
userId?: string;
|
|
@@ -492,7 +405,7 @@ declare class Liveblocks {
|
|
|
492
405
|
* @param params.query The query to filter threads by. It is based on our query language and can filter by metadata.
|
|
493
406
|
* @returns A list of threads.
|
|
494
407
|
*/
|
|
495
|
-
getThreads<
|
|
408
|
+
getThreads<M extends BaseMetadata = DM>(params: {
|
|
496
409
|
roomId: string;
|
|
497
410
|
/**
|
|
498
411
|
* The query to filter threads by. It is based on our query language.
|
|
@@ -520,10 +433,10 @@ declare class Liveblocks {
|
|
|
520
433
|
* ```
|
|
521
434
|
*/
|
|
522
435
|
query?: string | {
|
|
523
|
-
metadata?: Partial<QueryMetadata<
|
|
436
|
+
metadata?: Partial<QueryMetadata<M>>;
|
|
524
437
|
};
|
|
525
438
|
}): Promise<{
|
|
526
|
-
data: ThreadData[];
|
|
439
|
+
data: ThreadData<M>[];
|
|
527
440
|
}>;
|
|
528
441
|
/**
|
|
529
442
|
* Gets a thread.
|
|
@@ -532,10 +445,10 @@ declare class Liveblocks {
|
|
|
532
445
|
* @param params.threadId The thread ID.
|
|
533
446
|
* @returns A thread.
|
|
534
447
|
*/
|
|
535
|
-
getThread<
|
|
448
|
+
getThread<M extends BaseMetadata = DM>(params: {
|
|
536
449
|
roomId: string;
|
|
537
450
|
threadId: string;
|
|
538
|
-
}): Promise<ThreadData<
|
|
451
|
+
}): Promise<ThreadData<M>>;
|
|
539
452
|
/**
|
|
540
453
|
* Gets a thread's participants.
|
|
541
454
|
*
|
|
@@ -621,17 +534,17 @@ declare class Liveblocks {
|
|
|
621
534
|
* @param params.thread.comment.body The body of the comment.
|
|
622
535
|
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
623
536
|
*/
|
|
624
|
-
createThread<
|
|
537
|
+
createThread<M extends BaseMetadata = DM>(params: {
|
|
625
538
|
roomId: string;
|
|
626
539
|
data: {
|
|
627
|
-
metadata?: [
|
|
540
|
+
metadata?: [M] extends [never] ? Record<string, never> : M;
|
|
628
541
|
comment: {
|
|
629
542
|
userId: string;
|
|
630
543
|
createdAt?: Date;
|
|
631
544
|
body: CommentBody;
|
|
632
545
|
};
|
|
633
546
|
};
|
|
634
|
-
}): Promise<ThreadData<
|
|
547
|
+
}): Promise<ThreadData<M>>;
|
|
635
548
|
/**
|
|
636
549
|
* Updates the metadata of the specified thread in a room.
|
|
637
550
|
* @param params.roomId The room ID to update the thread in.
|
|
@@ -641,7 +554,7 @@ declare class Liveblocks {
|
|
|
641
554
|
* @param params.data.updatedAt (optional) The date the thread is set to be updated.
|
|
642
555
|
* @returns The updated thread.
|
|
643
556
|
*/
|
|
644
|
-
editThreadMetadata<
|
|
557
|
+
editThreadMetadata<M extends BaseMetadata = DM>(params: {
|
|
645
558
|
roomId: string;
|
|
646
559
|
threadId: string;
|
|
647
560
|
data: {
|
|
@@ -649,7 +562,7 @@ declare class Liveblocks {
|
|
|
649
562
|
userId: string;
|
|
650
563
|
updatedAt?: Date;
|
|
651
564
|
};
|
|
652
|
-
}): Promise<
|
|
565
|
+
}): Promise<M>;
|
|
653
566
|
/**
|
|
654
567
|
* Adds a new comment reaction to a comment.
|
|
655
568
|
* @param params.roomId The room ID to add the comment reaction in.
|
|
@@ -1009,4 +922,4 @@ declare type NotificationEvent = {
|
|
|
1009
922
|
};
|
|
1010
923
|
};
|
|
1011
924
|
|
|
1012
|
-
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest
|
|
925
|
+
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest };
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,18 @@ var _core = require('@liveblocks/core');
|
|
|
3
3
|
|
|
4
4
|
// src/version.ts
|
|
5
5
|
var PKG_NAME = "@liveblocks/node";
|
|
6
|
-
var PKG_VERSION = "
|
|
6
|
+
var PKG_VERSION = "2.0.0-alpha1";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
|
+
// src/client.ts
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
9
18
|
// src/utils.ts
|
|
10
19
|
var DEFAULT_BASE_URL = "https://api.liveblocks.io";
|
|
11
20
|
function getBaseUrl(baseUrl) {
|
|
@@ -66,57 +75,6 @@ function url(strings, ...values) {
|
|
|
66
75
|
);
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
// src/authorize.ts
|
|
70
|
-
async function authorize(options) {
|
|
71
|
-
let url2 = null;
|
|
72
|
-
try {
|
|
73
|
-
const { room, secret, userId, userInfo, groupIds } = (
|
|
74
|
-
// Ensure we'll validate inputs at runtime
|
|
75
|
-
options
|
|
76
|
-
);
|
|
77
|
-
assertNonEmpty(secret, "secret");
|
|
78
|
-
assertNonEmpty(room, "room");
|
|
79
|
-
assertNonEmpty(userId, "userId");
|
|
80
|
-
url2 = buildLiveblocksAuthorizeEndpoint(options, room);
|
|
81
|
-
const fetch = await fetchPolyfill();
|
|
82
|
-
const resp = await fetch(url2, {
|
|
83
|
-
method: "POST",
|
|
84
|
-
headers: {
|
|
85
|
-
Authorization: `Bearer ${secret}`,
|
|
86
|
-
"Content-Type": "application/json"
|
|
87
|
-
},
|
|
88
|
-
body: JSON.stringify({
|
|
89
|
-
userId,
|
|
90
|
-
userInfo,
|
|
91
|
-
groupIds
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
return {
|
|
95
|
-
status: normalizeStatusCode(resp.status),
|
|
96
|
-
body: await resp.text()
|
|
97
|
-
};
|
|
98
|
-
} catch (er) {
|
|
99
|
-
return {
|
|
100
|
-
status: 503,
|
|
101
|
-
body: (url2 ? `Call to "${url2}" failed.` : "Invalid authorize request.") + ' See "error" for more information.',
|
|
102
|
-
error: er
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function buildLiveblocksAuthorizeEndpoint(options, roomId) {
|
|
107
|
-
const path = `/v2/rooms/${encodeURIComponent(roomId)}/authorize`;
|
|
108
|
-
return urljoin(getBaseUrl(options.baseUrl), path);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// src/client.ts
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
78
|
// src/Session.ts
|
|
121
79
|
var ALL_PERMISSIONS = Object.freeze([
|
|
122
80
|
"room:write",
|
|
@@ -838,9 +796,7 @@ var Liveblocks = class {
|
|
|
838
796
|
const text = await res.text();
|
|
839
797
|
throw new LiveblocksError(res.status, text);
|
|
840
798
|
}
|
|
841
|
-
return _core.convertToThreadData.call(void 0,
|
|
842
|
-
await res.json()
|
|
843
|
-
);
|
|
799
|
+
return _core.convertToThreadData.call(void 0, await res.json());
|
|
844
800
|
}
|
|
845
801
|
/**
|
|
846
802
|
* Gets a thread's participants.
|
|
@@ -970,9 +926,7 @@ var Liveblocks = class {
|
|
|
970
926
|
const text = await res.text();
|
|
971
927
|
throw new LiveblocksError(res.status, text);
|
|
972
928
|
}
|
|
973
|
-
return _core.convertToThreadData.call(void 0,
|
|
974
|
-
await res.json()
|
|
975
|
-
);
|
|
929
|
+
return _core.convertToThreadData.call(void 0, await res.json());
|
|
976
930
|
}
|
|
977
931
|
/**
|
|
978
932
|
* Updates the metadata of the specified thread in a room.
|
|
@@ -1286,6 +1240,5 @@ _core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
1286
1240
|
|
|
1287
1241
|
|
|
1288
1242
|
|
|
1289
|
-
|
|
1290
|
-
exports.Liveblocks = Liveblocks; exports.LiveblocksError = LiveblocksError; exports.WebhookHandler = WebhookHandler; exports.authorize = authorize; exports.getMentionedIdsFromCommentBody = _core.getMentionedIdsFromCommentBody; exports.stringifyCommentBody = _core.stringifyCommentBody;
|
|
1243
|
+
exports.Liveblocks = Liveblocks; exports.LiveblocksError = LiveblocksError; exports.WebhookHandler = WebhookHandler; exports.getMentionedIdsFromCommentBody = _core.getMentionedIdsFromCommentBody; exports.stringifyCommentBody = _core.stringifyCommentBody;
|
|
1291
1244
|
//# sourceMappingURL=index.js.map
|