@liveblocks/node 2.0.0 → 2.0.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 +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -65,10 +65,14 @@ declare type LiveblocksOptions = {
|
|
|
65
65
|
*/
|
|
66
66
|
secret: string;
|
|
67
67
|
};
|
|
68
|
-
declare type CreateSessionOptions<U extends BaseUserMeta = DU> = {
|
|
68
|
+
declare type CreateSessionOptions<U extends BaseUserMeta = DU> = Record<string, never> extends U["info"] ? {
|
|
69
|
+
userInfo?: U["info"];
|
|
70
|
+
} : {
|
|
69
71
|
userInfo: U["info"];
|
|
70
72
|
};
|
|
71
|
-
declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = {
|
|
73
|
+
declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = Record<string, never> extends U["info"] ? {
|
|
74
|
+
userInfo?: U["info"];
|
|
75
|
+
} : {
|
|
72
76
|
userInfo: U["info"];
|
|
73
77
|
};
|
|
74
78
|
declare type AuthResponse = {
|
|
@@ -155,7 +159,7 @@ declare class Liveblocks {
|
|
|
155
159
|
* `other.info` property.
|
|
156
160
|
*
|
|
157
161
|
*/
|
|
158
|
-
prepareSession(userId: string, options?: CreateSessionOptions<U>): Session;
|
|
162
|
+
prepareSession(userId: string, ...rest: Record<string, never> extends CreateSessionOptions<U> ? [options?: CreateSessionOptions<U>] : [options: CreateSessionOptions<U>]): Session;
|
|
159
163
|
/**
|
|
160
164
|
* Call this to authenticate the user as an actor you want to allow to use
|
|
161
165
|
* Liveblocks.
|
|
@@ -188,7 +192,7 @@ declare class Liveblocks {
|
|
|
188
192
|
* add here will be visible to all other clients in the room, through the
|
|
189
193
|
* `other.info` property.
|
|
190
194
|
*/
|
|
191
|
-
identifyUser(identity: string | Identity, options?: IdentifyUserOptions<U>): Promise<AuthResponse>;
|
|
195
|
+
identifyUser(identity: string | Identity, ...rest: Record<string, never> extends IdentifyUserOptions<U> ? [options?: IdentifyUserOptions<U>] : [options: IdentifyUserOptions<U>]): Promise<AuthResponse>;
|
|
192
196
|
/**
|
|
193
197
|
* 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.
|
|
194
198
|
* @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.
|
|
@@ -552,6 +556,15 @@ declare class Liveblocks {
|
|
|
552
556
|
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
553
557
|
*/
|
|
554
558
|
createThread(params: CreateThreadOptions<M>): Promise<ThreadData<M>>;
|
|
559
|
+
/**
|
|
560
|
+
* Deletes a thread and all of its comments.
|
|
561
|
+
* @param params.roomId The room ID to delete the thread in.
|
|
562
|
+
* @param params.threadId The thread ID to delete.
|
|
563
|
+
*/
|
|
564
|
+
deleteThread(params: {
|
|
565
|
+
roomId: string;
|
|
566
|
+
threadId: string;
|
|
567
|
+
}): Promise<void>;
|
|
555
568
|
/**
|
|
556
569
|
* Updates the metadata of the specified thread in a room.
|
|
557
570
|
* @param params.roomId The room ID to update the thread in.
|
|
@@ -725,7 +738,7 @@ declare type WebhookRequest = {
|
|
|
725
738
|
*/
|
|
726
739
|
rawBody: string;
|
|
727
740
|
};
|
|
728
|
-
declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | YDocUpdatedEvent;
|
|
741
|
+
declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | ThreadDeletedEvent | YDocUpdatedEvent;
|
|
729
742
|
declare type StorageUpdatedEvent = {
|
|
730
743
|
type: "storageUpdated";
|
|
731
744
|
data: {
|
|
@@ -911,6 +924,19 @@ declare type ThreadCreatedEvent = {
|
|
|
911
924
|
createdBy: string;
|
|
912
925
|
};
|
|
913
926
|
};
|
|
927
|
+
declare type ThreadDeletedEvent = {
|
|
928
|
+
type: "threadDeleted";
|
|
929
|
+
data: {
|
|
930
|
+
projectId: string;
|
|
931
|
+
roomId: string;
|
|
932
|
+
threadId: string;
|
|
933
|
+
/**
|
|
934
|
+
* ISO 8601 datestring
|
|
935
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
936
|
+
*/
|
|
937
|
+
deletedAt: string;
|
|
938
|
+
};
|
|
939
|
+
};
|
|
914
940
|
declare type ThreadNotificationEvent = {
|
|
915
941
|
type: "notification";
|
|
916
942
|
data: {
|
package/dist/index.d.ts
CHANGED
|
@@ -65,10 +65,14 @@ declare type LiveblocksOptions = {
|
|
|
65
65
|
*/
|
|
66
66
|
secret: string;
|
|
67
67
|
};
|
|
68
|
-
declare type CreateSessionOptions<U extends BaseUserMeta = DU> = {
|
|
68
|
+
declare type CreateSessionOptions<U extends BaseUserMeta = DU> = Record<string, never> extends U["info"] ? {
|
|
69
|
+
userInfo?: U["info"];
|
|
70
|
+
} : {
|
|
69
71
|
userInfo: U["info"];
|
|
70
72
|
};
|
|
71
|
-
declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = {
|
|
73
|
+
declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = Record<string, never> extends U["info"] ? {
|
|
74
|
+
userInfo?: U["info"];
|
|
75
|
+
} : {
|
|
72
76
|
userInfo: U["info"];
|
|
73
77
|
};
|
|
74
78
|
declare type AuthResponse = {
|
|
@@ -155,7 +159,7 @@ declare class Liveblocks {
|
|
|
155
159
|
* `other.info` property.
|
|
156
160
|
*
|
|
157
161
|
*/
|
|
158
|
-
prepareSession(userId: string, options?: CreateSessionOptions<U>): Session;
|
|
162
|
+
prepareSession(userId: string, ...rest: Record<string, never> extends CreateSessionOptions<U> ? [options?: CreateSessionOptions<U>] : [options: CreateSessionOptions<U>]): Session;
|
|
159
163
|
/**
|
|
160
164
|
* Call this to authenticate the user as an actor you want to allow to use
|
|
161
165
|
* Liveblocks.
|
|
@@ -188,7 +192,7 @@ declare class Liveblocks {
|
|
|
188
192
|
* add here will be visible to all other clients in the room, through the
|
|
189
193
|
* `other.info` property.
|
|
190
194
|
*/
|
|
191
|
-
identifyUser(identity: string | Identity, options?: IdentifyUserOptions<U>): Promise<AuthResponse>;
|
|
195
|
+
identifyUser(identity: string | Identity, ...rest: Record<string, never> extends IdentifyUserOptions<U> ? [options?: IdentifyUserOptions<U>] : [options: IdentifyUserOptions<U>]): Promise<AuthResponse>;
|
|
192
196
|
/**
|
|
193
197
|
* 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.
|
|
194
198
|
* @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.
|
|
@@ -552,6 +556,15 @@ declare class Liveblocks {
|
|
|
552
556
|
* @returns The created thread. The thread will be created with the specified comment as its first comment.
|
|
553
557
|
*/
|
|
554
558
|
createThread(params: CreateThreadOptions<M>): Promise<ThreadData<M>>;
|
|
559
|
+
/**
|
|
560
|
+
* Deletes a thread and all of its comments.
|
|
561
|
+
* @param params.roomId The room ID to delete the thread in.
|
|
562
|
+
* @param params.threadId The thread ID to delete.
|
|
563
|
+
*/
|
|
564
|
+
deleteThread(params: {
|
|
565
|
+
roomId: string;
|
|
566
|
+
threadId: string;
|
|
567
|
+
}): Promise<void>;
|
|
555
568
|
/**
|
|
556
569
|
* Updates the metadata of the specified thread in a room.
|
|
557
570
|
* @param params.roomId The room ID to update the thread in.
|
|
@@ -725,7 +738,7 @@ declare type WebhookRequest = {
|
|
|
725
738
|
*/
|
|
726
739
|
rawBody: string;
|
|
727
740
|
};
|
|
728
|
-
declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | YDocUpdatedEvent;
|
|
741
|
+
declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | ThreadDeletedEvent | YDocUpdatedEvent;
|
|
729
742
|
declare type StorageUpdatedEvent = {
|
|
730
743
|
type: "storageUpdated";
|
|
731
744
|
data: {
|
|
@@ -911,6 +924,19 @@ declare type ThreadCreatedEvent = {
|
|
|
911
924
|
createdBy: string;
|
|
912
925
|
};
|
|
913
926
|
};
|
|
927
|
+
declare type ThreadDeletedEvent = {
|
|
928
|
+
type: "threadDeleted";
|
|
929
|
+
data: {
|
|
930
|
+
projectId: string;
|
|
931
|
+
roomId: string;
|
|
932
|
+
threadId: string;
|
|
933
|
+
/**
|
|
934
|
+
* ISO 8601 datestring
|
|
935
|
+
* @example "2021-03-01T12:00:00.000Z"
|
|
936
|
+
*/
|
|
937
|
+
deletedAt: string;
|
|
938
|
+
};
|
|
939
|
+
};
|
|
914
940
|
declare type ThreadNotificationEvent = {
|
|
915
941
|
type: "notification";
|
|
916
942
|
data: {
|
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 = "2.0.
|
|
6
|
+
var PKG_VERSION = "2.0.2";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -292,7 +292,8 @@ var Liveblocks = class {
|
|
|
292
292
|
* `other.info` property.
|
|
293
293
|
*
|
|
294
294
|
*/
|
|
295
|
-
prepareSession(userId,
|
|
295
|
+
prepareSession(userId, ...rest) {
|
|
296
|
+
const options = rest[0];
|
|
296
297
|
return new Session(this.post.bind(this), userId, _optionalChain([options, 'optionalAccess', _ => _.userInfo]));
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
@@ -328,7 +329,8 @@ var Liveblocks = class {
|
|
|
328
329
|
* `other.info` property.
|
|
329
330
|
*/
|
|
330
331
|
// These fields define the security identity of the user. Whatever you pass in here will define which
|
|
331
|
-
async identifyUser(identity,
|
|
332
|
+
async identifyUser(identity, ...rest) {
|
|
333
|
+
const options = rest[0];
|
|
332
334
|
const path = url`/v2/identify-user`;
|
|
333
335
|
const userId = typeof identity === "string" ? identity : identity.userId;
|
|
334
336
|
const groupIds = typeof identity === "string" ? void 0 : identity.groupIds;
|
|
@@ -928,6 +930,19 @@ var Liveblocks = class {
|
|
|
928
930
|
}
|
|
929
931
|
return _core.convertToThreadData.call(void 0, await res.json());
|
|
930
932
|
}
|
|
933
|
+
/**
|
|
934
|
+
* Deletes a thread and all of its comments.
|
|
935
|
+
* @param params.roomId The room ID to delete the thread in.
|
|
936
|
+
* @param params.threadId The thread ID to delete.
|
|
937
|
+
*/
|
|
938
|
+
async deleteThread(params) {
|
|
939
|
+
const { roomId, threadId } = params;
|
|
940
|
+
const res = await this.delete(url`/v2/rooms/${roomId}/threads/${threadId}`);
|
|
941
|
+
if (!res.ok) {
|
|
942
|
+
const text = await res.text();
|
|
943
|
+
throw new LiveblocksError(res.status, text);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
931
946
|
/**
|
|
932
947
|
* Updates the metadata of the specified thread in a room.
|
|
933
948
|
* @param params.roomId The room ID to update the thread in.
|
|
@@ -1212,6 +1227,7 @@ var _WebhookHandler = class _WebhookHandler {
|
|
|
1212
1227
|
"commentReactionRemoved",
|
|
1213
1228
|
"threadMetadataUpdated",
|
|
1214
1229
|
"threadCreated",
|
|
1230
|
+
"threadDeleted",
|
|
1215
1231
|
"ydocUpdated",
|
|
1216
1232
|
"notification"
|
|
1217
1233
|
].includes(event.type)) {
|