@liveblocks/node 2.0.0 → 2.0.3-test1

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseUserMeta, DU, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData, LsonObject, ToImmutable, BaseMetadata, DE, DM, DS } from '@liveblocks/core';
1
+ import { BaseUserMeta, DU, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM, DS } 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
 
@@ -65,12 +65,12 @@ 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> = PartialUnless<U["info"], {
69
69
  userInfo: U["info"];
70
- };
71
- declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = {
70
+ }>;
71
+ declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = PartialUnless<U["info"], {
72
72
  userInfo: U["info"];
73
- };
73
+ }>;
74
74
  declare type AuthResponse = {
75
75
  status: number;
76
76
  body: string;
@@ -91,11 +91,9 @@ declare type CreateThreadOptions<M extends BaseMetadata> = {
91
91
  createdAt?: Date;
92
92
  body: CommentBody;
93
93
  };
94
- } & (Record<string, never> extends M ? {
95
- metadata?: M;
96
- } : {
94
+ } & PartialUnless<M, {
97
95
  metadata: M;
98
- });
96
+ }>;
99
97
  };
100
98
  declare type RoomPermission = [] | ["room:write"] | ["room:read", "room:presence:write"];
101
99
  declare type RoomAccesses = Record<string, [
@@ -155,7 +153,9 @@ declare class Liveblocks {
155
153
  * `other.info` property.
156
154
  *
157
155
  */
158
- prepareSession(userId: string, options?: CreateSessionOptions<U>): Session;
156
+ prepareSession(userId: string, ...rest: OptionalTupleUnless<CreateSessionOptions<U>, [
157
+ options: CreateSessionOptions<U>
158
+ ]>): Session;
159
159
  /**
160
160
  * Call this to authenticate the user as an actor you want to allow to use
161
161
  * Liveblocks.
@@ -188,7 +188,9 @@ declare class Liveblocks {
188
188
  * add here will be visible to all other clients in the room, through the
189
189
  * `other.info` property.
190
190
  */
191
- identifyUser(identity: string | Identity, options?: IdentifyUserOptions<U>): Promise<AuthResponse>;
191
+ identifyUser(identity: string | Identity, ...rest: OptionalTupleUnless<IdentifyUserOptions<U>, [
192
+ options: IdentifyUserOptions<U>
193
+ ]>): Promise<AuthResponse>;
192
194
  /**
193
195
  * 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
196
  * @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 +554,15 @@ declare class Liveblocks {
552
554
  * @returns The created thread. The thread will be created with the specified comment as its first comment.
553
555
  */
554
556
  createThread(params: CreateThreadOptions<M>): Promise<ThreadData<M>>;
557
+ /**
558
+ * Deletes a thread and all of its comments.
559
+ * @param params.roomId The room ID to delete the thread in.
560
+ * @param params.threadId The thread ID to delete.
561
+ */
562
+ deleteThread(params: {
563
+ roomId: string;
564
+ threadId: string;
565
+ }): Promise<void>;
555
566
  /**
556
567
  * Updates the metadata of the specified thread in a room.
557
568
  * @param params.roomId The room ID to update the thread in.
@@ -725,7 +736,7 @@ declare type WebhookRequest = {
725
736
  */
726
737
  rawBody: string;
727
738
  };
728
- declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | YDocUpdatedEvent;
739
+ declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | ThreadDeletedEvent | YDocUpdatedEvent;
729
740
  declare type StorageUpdatedEvent = {
730
741
  type: "storageUpdated";
731
742
  data: {
@@ -911,6 +922,19 @@ declare type ThreadCreatedEvent = {
911
922
  createdBy: string;
912
923
  };
913
924
  };
925
+ declare type ThreadDeletedEvent = {
926
+ type: "threadDeleted";
927
+ data: {
928
+ projectId: string;
929
+ roomId: string;
930
+ threadId: string;
931
+ /**
932
+ * ISO 8601 datestring
933
+ * @example "2021-03-01T12:00:00.000Z"
934
+ */
935
+ deletedAt: string;
936
+ };
937
+ };
914
938
  declare type ThreadNotificationEvent = {
915
939
  type: "notification";
916
940
  data: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseUserMeta, DU, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData, LsonObject, ToImmutable, BaseMetadata, DE, DM, DS } from '@liveblocks/core';
1
+ import { BaseUserMeta, DU, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, ActivityData, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM, DS } 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
 
@@ -65,12 +65,12 @@ 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> = PartialUnless<U["info"], {
69
69
  userInfo: U["info"];
70
- };
71
- declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = {
70
+ }>;
71
+ declare type IdentifyUserOptions<U extends BaseUserMeta = DU> = PartialUnless<U["info"], {
72
72
  userInfo: U["info"];
73
- };
73
+ }>;
74
74
  declare type AuthResponse = {
75
75
  status: number;
76
76
  body: string;
@@ -91,11 +91,9 @@ declare type CreateThreadOptions<M extends BaseMetadata> = {
91
91
  createdAt?: Date;
92
92
  body: CommentBody;
93
93
  };
94
- } & (Record<string, never> extends M ? {
95
- metadata?: M;
96
- } : {
94
+ } & PartialUnless<M, {
97
95
  metadata: M;
98
- });
96
+ }>;
99
97
  };
100
98
  declare type RoomPermission = [] | ["room:write"] | ["room:read", "room:presence:write"];
101
99
  declare type RoomAccesses = Record<string, [
@@ -155,7 +153,9 @@ declare class Liveblocks {
155
153
  * `other.info` property.
156
154
  *
157
155
  */
158
- prepareSession(userId: string, options?: CreateSessionOptions<U>): Session;
156
+ prepareSession(userId: string, ...rest: OptionalTupleUnless<CreateSessionOptions<U>, [
157
+ options: CreateSessionOptions<U>
158
+ ]>): Session;
159
159
  /**
160
160
  * Call this to authenticate the user as an actor you want to allow to use
161
161
  * Liveblocks.
@@ -188,7 +188,9 @@ declare class Liveblocks {
188
188
  * add here will be visible to all other clients in the room, through the
189
189
  * `other.info` property.
190
190
  */
191
- identifyUser(identity: string | Identity, options?: IdentifyUserOptions<U>): Promise<AuthResponse>;
191
+ identifyUser(identity: string | Identity, ...rest: OptionalTupleUnless<IdentifyUserOptions<U>, [
192
+ options: IdentifyUserOptions<U>
193
+ ]>): Promise<AuthResponse>;
192
194
  /**
193
195
  * 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
196
  * @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 +554,15 @@ declare class Liveblocks {
552
554
  * @returns The created thread. The thread will be created with the specified comment as its first comment.
553
555
  */
554
556
  createThread(params: CreateThreadOptions<M>): Promise<ThreadData<M>>;
557
+ /**
558
+ * Deletes a thread and all of its comments.
559
+ * @param params.roomId The room ID to delete the thread in.
560
+ * @param params.threadId The thread ID to delete.
561
+ */
562
+ deleteThread(params: {
563
+ roomId: string;
564
+ threadId: string;
565
+ }): Promise<void>;
555
566
  /**
556
567
  * Updates the metadata of the specified thread in a room.
557
568
  * @param params.roomId The room ID to update the thread in.
@@ -725,7 +736,7 @@ declare type WebhookRequest = {
725
736
  */
726
737
  rawBody: string;
727
738
  };
728
- declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | YDocUpdatedEvent;
739
+ declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | NotificationEvent | ThreadCreatedEvent | ThreadDeletedEvent | YDocUpdatedEvent;
729
740
  declare type StorageUpdatedEvent = {
730
741
  type: "storageUpdated";
731
742
  data: {
@@ -911,6 +922,19 @@ declare type ThreadCreatedEvent = {
911
922
  createdBy: string;
912
923
  };
913
924
  };
925
+ declare type ThreadDeletedEvent = {
926
+ type: "threadDeleted";
927
+ data: {
928
+ projectId: string;
929
+ roomId: string;
930
+ threadId: string;
931
+ /**
932
+ * ISO 8601 datestring
933
+ * @example "2021-03-01T12:00:00.000Z"
934
+ */
935
+ deletedAt: string;
936
+ };
937
+ };
914
938
  declare type ThreadNotificationEvent = {
915
939
  type: "notification";
916
940
  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.0";
6
+ var PKG_VERSION = "2.0.3-test1";
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, options) {
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, options) {
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)) {