@liveblocks/node 1.10.0-beta1 → 1.10.0-beta3

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 { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData } from '@liveblocks/core';
1
+ import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings } 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
 
@@ -621,10 +621,44 @@ declare class Liveblocks {
621
621
  removedAt?: Date;
622
622
  };
623
623
  }): Promise<void>;
624
+ /**
625
+ * Returns the inbox notifications for a user.
626
+ * @param params.userId The user ID to get the inbox notifications from.
627
+ * @param params.inboxNotificationId The ID of the inbox notification to get.
628
+ */
624
629
  getInboxNotification(params: {
625
630
  userId: string;
626
631
  inboxNotificationId: string;
627
632
  }): Promise<InboxNotificationData>;
633
+ /**
634
+ * Gets the user's room notification settings.
635
+ * @param params.userId The user ID to get the room notifications from.
636
+ * @param params.roomId The room ID to get the room notification settings from.
637
+ */
638
+ getRoomNotificationSettings(params: {
639
+ userId: string;
640
+ roomId: string;
641
+ }): Promise<RoomNotificationSettings>;
642
+ /**
643
+ * Updates the user's room notification settings.
644
+ * @param params.userId The user ID to update the room notification settings for.
645
+ * @param params.roomId The room ID to update the room notification settings for.
646
+ * @param params.data The new room notification settings for the user.
647
+ */
648
+ updateRoomNotificationSettings(params: {
649
+ userId: string;
650
+ roomId: string;
651
+ data: RoomNotificationSettings;
652
+ }): Promise<RoomNotificationSettings>;
653
+ /**
654
+ * Delete the user's room notification settings.
655
+ * @param params.userId The user ID to delete the room notification settings from.
656
+ * @param params.roomId The room ID to delete the room notification settings from.
657
+ */
658
+ deleteRoomNotificationSettings(params: {
659
+ userId: string;
660
+ roomId: string;
661
+ }): Promise<void>;
628
662
  }
629
663
 
630
664
  declare class WebhookHandler {
@@ -683,7 +717,7 @@ declare type WebhookRequest = {
683
717
  */
684
718
  rawBody: string;
685
719
  };
686
- declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | ThreadCreatedEvent | YDocUpdatedEvent;
720
+ declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | ThreadEmailNotificationEvent | ThreadCreatedEvent | YDocUpdatedEvent;
687
721
  declare type StorageUpdatedEvent = {
688
722
  type: "storageUpdated";
689
723
  data: {
@@ -864,5 +898,20 @@ declare type ThreadCreatedEvent = {
864
898
  createdBy: string;
865
899
  };
866
900
  };
901
+ declare type ThreadEmailNotificationEvent = {
902
+ type: "threadEmailNotification";
903
+ data: {
904
+ projectId: string;
905
+ roomId: string;
906
+ userId: string;
907
+ threadId: string;
908
+ inboxNotificationId: string;
909
+ /**
910
+ * ISO 8601 datestring
911
+ * @example "2021-03-01T12:00:00.000Z"
912
+ */
913
+ createdAt: string;
914
+ };
915
+ };
867
916
 
868
- export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, type LiveblocksOptions, 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, authorize };
917
+ export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, type LiveblocksOptions, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadEmailNotificationEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, authorize };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData } from '@liveblocks/core';
1
+ import { IUserInfo, Json, PlainLsonObject, JsonObject, ThreadData, BaseMetadata, CommentData, CommentBody, CommentUserReaction, InboxNotificationData, RoomNotificationSettings } 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
 
@@ -621,10 +621,44 @@ declare class Liveblocks {
621
621
  removedAt?: Date;
622
622
  };
623
623
  }): Promise<void>;
624
+ /**
625
+ * Returns the inbox notifications for a user.
626
+ * @param params.userId The user ID to get the inbox notifications from.
627
+ * @param params.inboxNotificationId The ID of the inbox notification to get.
628
+ */
624
629
  getInboxNotification(params: {
625
630
  userId: string;
626
631
  inboxNotificationId: string;
627
632
  }): Promise<InboxNotificationData>;
633
+ /**
634
+ * Gets the user's room notification settings.
635
+ * @param params.userId The user ID to get the room notifications from.
636
+ * @param params.roomId The room ID to get the room notification settings from.
637
+ */
638
+ getRoomNotificationSettings(params: {
639
+ userId: string;
640
+ roomId: string;
641
+ }): Promise<RoomNotificationSettings>;
642
+ /**
643
+ * Updates the user's room notification settings.
644
+ * @param params.userId The user ID to update the room notification settings for.
645
+ * @param params.roomId The room ID to update the room notification settings for.
646
+ * @param params.data The new room notification settings for the user.
647
+ */
648
+ updateRoomNotificationSettings(params: {
649
+ userId: string;
650
+ roomId: string;
651
+ data: RoomNotificationSettings;
652
+ }): Promise<RoomNotificationSettings>;
653
+ /**
654
+ * Delete the user's room notification settings.
655
+ * @param params.userId The user ID to delete the room notification settings from.
656
+ * @param params.roomId The room ID to delete the room notification settings from.
657
+ */
658
+ deleteRoomNotificationSettings(params: {
659
+ userId: string;
660
+ roomId: string;
661
+ }): Promise<void>;
628
662
  }
629
663
 
630
664
  declare class WebhookHandler {
@@ -683,7 +717,7 @@ declare type WebhookRequest = {
683
717
  */
684
718
  rawBody: string;
685
719
  };
686
- declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | ThreadCreatedEvent | YDocUpdatedEvent;
720
+ declare type WebhookEvent = StorageUpdatedEvent | UserEnteredEvent | UserLeftEvent | RoomCreatedEvent | RoomDeletedEvent | CommentCreatedEvent | CommentEditedEvent | CommentDeletedEvent | CommentReactionAdded | CommentReactionRemoved | ThreadMetadataUpdatedEvent | ThreadEmailNotificationEvent | ThreadCreatedEvent | YDocUpdatedEvent;
687
721
  declare type StorageUpdatedEvent = {
688
722
  type: "storageUpdated";
689
723
  data: {
@@ -864,5 +898,20 @@ declare type ThreadCreatedEvent = {
864
898
  createdBy: string;
865
899
  };
866
900
  };
901
+ declare type ThreadEmailNotificationEvent = {
902
+ type: "threadEmailNotification";
903
+ data: {
904
+ projectId: string;
905
+ roomId: string;
906
+ userId: string;
907
+ threadId: string;
908
+ inboxNotificationId: string;
909
+ /**
910
+ * ISO 8601 datestring
911
+ * @example "2021-03-01T12:00:00.000Z"
912
+ */
913
+ createdAt: string;
914
+ };
915
+ };
867
916
 
868
- export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, type LiveblocksOptions, 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, authorize };
917
+ export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, Liveblocks, type LiveblocksOptions, type RoomAccesses, type RoomCreatedEvent, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type ThreadCreatedEvent, type ThreadEmailNotificationEvent, type ThreadMetadataUpdatedEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, authorize };
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.10.0-beta1";
6
+ var PKG_VERSION = "1.10.0-beta3";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // src/utils.ts
@@ -126,7 +126,7 @@ var READ_ACCESS = Object.freeze([
126
126
  "comments:read"
127
127
  ]);
128
128
  var FULL_ACCESS = Object.freeze(["room:write", "comments:write"]);
129
- var roomPatternRegex = /^[^*]{1,128}[*]?$/;
129
+ var roomPatternRegex = /^([*]|[^*]{1,128}[*]?)$/;
130
130
  var Session = class {
131
131
  /** @internal */
132
132
  constructor(postFn, userId, userInfo) {
@@ -161,6 +161,9 @@ var Session = class {
161
161
  }
162
162
  }
163
163
  allow(roomIdOrPattern, newPerms) {
164
+ if (typeof roomIdOrPattern !== "string") {
165
+ throw new Error("Room name or pattern must be a string");
166
+ }
164
167
  if (!roomPatternRegex.test(roomIdOrPattern)) {
165
168
  throw new Error("Invalid room name or pattern");
166
169
  }
@@ -1015,6 +1018,11 @@ var Liveblocks = class {
1015
1018
  throw new LiveblocksError(res.status, text);
1016
1019
  }
1017
1020
  }
1021
+ /**
1022
+ * Returns the inbox notifications for a user.
1023
+ * @param params.userId The user ID to get the inbox notifications from.
1024
+ * @param params.inboxNotificationId The ID of the inbox notification to get.
1025
+ */
1018
1026
  async getInboxNotification(params) {
1019
1027
  const { userId, inboxNotificationId } = params;
1020
1028
  const res = await this.get(
@@ -1031,6 +1039,55 @@ var Liveblocks = class {
1031
1039
  readAt: data.readAt ? new Date(data.readAt) : null
1032
1040
  };
1033
1041
  }
1042
+ /**
1043
+ * Gets the user's room notification settings.
1044
+ * @param params.userId The user ID to get the room notifications from.
1045
+ * @param params.roomId The room ID to get the room notification settings from.
1046
+ */
1047
+ async getRoomNotificationSettings(params) {
1048
+ const { userId, roomId } = params;
1049
+ const res = await this.get(
1050
+ url`/v2/rooms/${roomId}/users/${userId}/notification-settings`
1051
+ );
1052
+ if (!res.ok) {
1053
+ const text = await res.text();
1054
+ throw new LiveblocksError(res.status, text);
1055
+ }
1056
+ return await res.json();
1057
+ }
1058
+ /**
1059
+ * Updates the user's room notification settings.
1060
+ * @param params.userId The user ID to update the room notification settings for.
1061
+ * @param params.roomId The room ID to update the room notification settings for.
1062
+ * @param params.data The new room notification settings for the user.
1063
+ */
1064
+ async updateRoomNotificationSettings(params) {
1065
+ const { userId, roomId, data } = params;
1066
+ const res = await this.post(
1067
+ url`/v2/rooms/${roomId}/users/${userId}/notification-settings`,
1068
+ data
1069
+ );
1070
+ if (!res.ok) {
1071
+ const text = await res.text();
1072
+ throw new LiveblocksError(res.status, text);
1073
+ }
1074
+ return await res.json();
1075
+ }
1076
+ /**
1077
+ * Delete the user's room notification settings.
1078
+ * @param params.userId The user ID to delete the room notification settings from.
1079
+ * @param params.roomId The room ID to delete the room notification settings from.
1080
+ */
1081
+ async deleteRoomNotificationSettings(params) {
1082
+ const { userId, roomId } = params;
1083
+ const res = await this.delete(
1084
+ url`/v2/rooms/${roomId}/users/${userId}/notification-settings`
1085
+ );
1086
+ if (!res.ok) {
1087
+ const text = await res.text();
1088
+ throw new LiveblocksError(res.status, text);
1089
+ }
1090
+ }
1034
1091
  };
1035
1092
  var LiveblocksError = class extends Error {
1036
1093
  constructor(status, message = "") {
@@ -1145,6 +1202,7 @@ var _WebhookHandler = class _WebhookHandler {
1145
1202
  "commentReactionAdded",
1146
1203
  "commentReactionRemoved",
1147
1204
  "threadMetadataUpdated",
1205
+ "threadEmailNotification",
1148
1206
  "threadCreated",
1149
1207
  "ydocUpdated"
1150
1208
  ].includes(event.type))