@liveblocks/node 3.20.0-rc1 → 3.20.0

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.cts CHANGED
@@ -1,48 +1,45 @@
1
- import { Json, DFMD, FeedCreateMetadata, OptionalTupleUnless, BaseUserMeta, DU, PartialUnless, DE, JsonObject, PlainLsonObject, ToJson, DS, QueryMetadata, DTM, ThreadData, DCM, UserSubscriptionData, CommentData, BaseMetadata, CommentBody, Patchable, SubscriptionData, CommentUserReaction, InboxNotificationData, UserRoomSubscriptionSettings, RoomSubscriptionSettings, KDAD, DAD, NotificationSettings, PartialNotificationSettings, GroupScopes, GroupData, LiveObject, Awaitable, DFM, Feed, FeedUpdateMetadata, FeedMessage, NotificationChannel } from '@liveblocks/core';
2
- export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveMap, LiveObject, LiveStructure, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionsFromCommentBody, isNotificationChannelEnabled, stringifyCommentBody } from '@liveblocks/core';
1
+ import { Permission, Json, DFMD, FeedCreateMetadata, RoomPermissions, RoomAccesses, OptionalTupleUnless, BaseUserMeta, DU, PartialUnless, UpdateRoomAccesses, DE, JsonObject, PlainLsonObject, ToJson, DS, QueryMetadata, DTM, ThreadData, DCM, UserSubscriptionData, CommentData, BaseMetadata, CommentBody, Patchable, SubscriptionData, CommentUserReaction, InboxNotificationData, UserRoomSubscriptionSettings, RoomSubscriptionSettings, KDAD, DAD, NotificationSettings, PartialNotificationSettings, GroupScopes, GroupData, LiveObject, Awaitable, DFM, Feed, FeedUpdateMetadata, FeedMessage, NotificationChannel } from '@liveblocks/core';
2
+ export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveMap, LiveObject, LiveStructure, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, RoomAccesses, RoomPermissions, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionsFromCommentBody, isNotificationChannelEnabled, stringifyCommentBody } from '@liveblocks/core';
3
3
  import { IncomingHttpHeaders } from 'http';
4
4
 
5
- declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read", "feeds:write"];
6
- type Permission = (typeof ALL_PERMISSIONS)[number];
7
5
  /**
8
- * Class to help you construct the exact permission set to grant a user, used
9
- * when making `.authorizeUser()` calls.
6
+ * Class to help you construct the exact permission set to grant a user.
10
7
  *
11
8
  * Usage:
12
9
  *
13
10
  * const session = liveblocks.prepareSession();
14
- * session.allow(roomId, permissions) // or...
11
+ * session.allow(roomId, permissions)
15
12
  *
16
- * For the `permissions` argument, you can pass a list of specific permissions,
17
- * or use one of our presets:
13
+ * For the `permissions` argument, pass a list of permission scopes.
18
14
  *
19
- * session.allow('my-room', session.FULL_ACCESS) // Read + write access to room storage and comments
20
- * session.allow('my-room', session.READ_ACCESS) // Read-only access to room storage and comments
15
+ * session.allow('my-room', ['*:write']) // Read + write access
16
+ * session.allow('my-room', ['*:read']) // Read-only access
17
+ * session.allow('my-room', [
18
+ * '*:write', // Read + write access by default
19
+ * 'comments:read' // But read-only access to comments
20
+ * 'feeds:none' // And no access to feeds
21
+ * ])
21
22
  *
22
23
  * Rooms can be specified with a prefix match, if the name ends in an asterisk.
23
24
  * In that case, access is granted to *all* rooms that start with that prefix:
24
25
  *
25
26
  * // Read + write access to *all* rooms that start with "abc:"
26
- * session.allow('abc:*', session.FULL_ACCESS)
27
+ * session.allow('abc:*', ['*:write'])
27
28
  *
28
29
  * You can define at most 10 room IDs (or patterns) in a single token,
29
30
  * otherwise the token would become too large and unwieldy.
30
31
  *
31
- * All permissions granted are additive. You cannot "remove" permissions once
32
- * you grant them. For example:
33
- *
34
- * session
35
- * .allow('abc:*', session.FULL_ACCESS)
36
- * .allow('abc:123', session.READ_ACCESS)
37
- *
38
- * Here, room `abc:123` would have full access. The second .allow() call only
39
- * _adds_ read permissions, but that has no effect since full access
40
- * permissions were already added to the set.
41
32
  */
42
33
  declare class Session {
43
34
  #private;
44
- readonly FULL_ACCESS: readonly ["room:write"];
45
- readonly READ_ACCESS: readonly ["room:read", "room:presence:write", "comments:read"];
35
+ /**
36
+ * @deprecated Use `["*:write"]` instead.
37
+ */
38
+ readonly FULL_ACCESS: readonly ["*:write"];
39
+ /**
40
+ * @deprecated Use `["*:read"]` instead.
41
+ */
42
+ readonly READ_ACCESS: readonly ["*:read"];
46
43
  allow(roomIdOrPattern: string, newPerms: readonly Permission[]): this;
47
44
  /**
48
45
  * Call this to authorize the session to access Liveblocks. Note that this
@@ -130,8 +127,6 @@ type CreateCommentOptions<CM extends BaseMetadata> = {
130
127
  metadata: CM;
131
128
  }>;
132
129
  };
133
- type RoomPermission = [] | ["room:write"] | ["room:read", "room:presence:write"] | ["room:read", "room:presence:write", "comments:write"];
134
- type RoomAccesses = Record<string, ["room:write"] | ["room:read", "room:presence:write"] | ["room:read", "room:presence:write", "comments:write"]>;
135
130
  type RoomMetadata = Record<string, string | string[]>;
136
131
  type QueryRoomMetadata = Record<string, string>;
137
132
  type RoomData = {
@@ -140,7 +135,7 @@ type RoomData = {
140
135
  createdAt: Date;
141
136
  lastConnectionAt?: Date;
142
137
  organizationId: string;
143
- defaultAccesses: RoomPermission;
138
+ defaultAccesses: RoomPermissions;
144
139
  usersAccesses: RoomAccesses;
145
140
  groupsAccesses: RoomAccesses;
146
141
  metadata: RoomMetadata;
@@ -318,7 +313,7 @@ type Page<T> = {
318
313
  type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions;
319
314
  type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
320
315
  type CreateRoomOptions = {
321
- defaultAccesses: RoomPermission;
316
+ defaultAccesses: RoomPermissions;
322
317
  groupsAccesses?: RoomAccesses;
323
318
  usersAccesses?: RoomAccesses;
324
319
  metadata?: RoomMetadata;
@@ -327,20 +322,11 @@ type CreateRoomOptions = {
327
322
  */
328
323
  tenantId?: string;
329
324
  organizationId?: string;
330
- /**
331
- * @deprecated This flag no longer has any effect and will be removed in
332
- * a future version. All rooms now use the v2 storage engine by default.
333
- */
334
- engine?: 1 | 2;
335
325
  };
336
326
  type UpdateRoomOptions = {
337
- defaultAccesses?: RoomPermission | null;
338
- groupsAccesses?: Record<string, [
339
- "room:write"
340
- ] | ["room:read", "room:presence:write"] | null>;
341
- usersAccesses?: Record<string, [
342
- "room:write"
343
- ] | ["room:read", "room:presence:write"] | null>;
327
+ defaultAccesses?: RoomPermissions | null;
328
+ groupsAccesses?: UpdateRoomAccesses;
329
+ usersAccesses?: UpdateRoomAccesses;
344
330
  metadata?: Record<string, string | string[] | null>;
345
331
  };
346
332
  type UpsertRoomOptions = {
@@ -2001,4 +1987,9 @@ declare function isTextMentionNotificationEvent(event: WebhookEvent): event is T
2001
1987
  */
2002
1988
  declare function isCustomNotificationEvent(event: WebhookEvent): event is CustomNotificationEvent;
2003
1989
 
2004
- export { type AiCopilot, type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateAiCopilotOptions, type CreateFeedMessageOptions, type CreateFeedOptions, type CreateFileKnowledgeSourceOptions, type CreateRoomOptions, type CreateWebKnowledgeSourceOptions, type CustomNotificationEvent, type GetAiCopilotsOptions, type GetInboxNotificationsOptions, type GetKnowledgeSourcesOptions, type GetRoomsOptions, type GetWebKnowledgeSourceLinksOptions, type InboxNotificationsQueryCriteria, type KnowledgeSource, Liveblocks, LiveblocksError, type LiveblocksOptions, type MassMutateStorageCallback, type MassMutateStorageOptions, type MutateStorageCallback, type MutateStorageOptions, type NotificationEvent, type Page, type PaginationOptions, type RoomAccesses, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomPermission, type RoomUser, type RoomsQueryCriteria, type SetPresenceOptions, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UpdateAiCopilotOptions, type UpdateFeedMessageOptions, type UpdateFeedOptions, type UpdateRoomOptions, type UpsertRoomOptions, type UserEnteredEvent, type UserLeftEvent, type WebKnowledgeSourceLink, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent, markdownToCommentBody };
1990
+ /**
1991
+ * @deprecated Use `RoomPermissions` instead.
1992
+ */
1993
+ type RoomPermission = RoomPermissions;
1994
+
1995
+ export { type AiCopilot, type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateAiCopilotOptions, type CreateFeedMessageOptions, type CreateFeedOptions, type CreateFileKnowledgeSourceOptions, type CreateRoomOptions, type CreateWebKnowledgeSourceOptions, type CustomNotificationEvent, type GetAiCopilotsOptions, type GetInboxNotificationsOptions, type GetKnowledgeSourcesOptions, type GetRoomsOptions, type GetWebKnowledgeSourceLinksOptions, type InboxNotificationsQueryCriteria, type KnowledgeSource, Liveblocks, LiveblocksError, type LiveblocksOptions, type MassMutateStorageCallback, type MassMutateStorageOptions, type MutateStorageCallback, type MutateStorageOptions, type NotificationEvent, type Page, type PaginationOptions, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomPermission, type RoomUser, type RoomsQueryCriteria, type SetPresenceOptions, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UpdateAiCopilotOptions, type UpdateFeedMessageOptions, type UpdateFeedOptions, type UpdateRoomOptions, type UpsertRoomOptions, type UserEnteredEvent, type UserLeftEvent, type WebKnowledgeSourceLink, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent, markdownToCommentBody };
package/dist/index.d.ts CHANGED
@@ -1,48 +1,45 @@
1
- import { Json, DFMD, FeedCreateMetadata, OptionalTupleUnless, BaseUserMeta, DU, PartialUnless, DE, JsonObject, PlainLsonObject, ToJson, DS, QueryMetadata, DTM, ThreadData, DCM, UserSubscriptionData, CommentData, BaseMetadata, CommentBody, Patchable, SubscriptionData, CommentUserReaction, InboxNotificationData, UserRoomSubscriptionSettings, RoomSubscriptionSettings, KDAD, DAD, NotificationSettings, PartialNotificationSettings, GroupScopes, GroupData, LiveObject, Awaitable, DFM, Feed, FeedUpdateMetadata, FeedMessage, NotificationChannel } from '@liveblocks/core';
2
- export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveMap, LiveObject, LiveStructure, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionsFromCommentBody, isNotificationChannelEnabled, stringifyCommentBody } from '@liveblocks/core';
1
+ import { Permission, Json, DFMD, FeedCreateMetadata, RoomPermissions, RoomAccesses, OptionalTupleUnless, BaseUserMeta, DU, PartialUnless, UpdateRoomAccesses, DE, JsonObject, PlainLsonObject, ToJson, DS, QueryMetadata, DTM, ThreadData, DCM, UserSubscriptionData, CommentData, BaseMetadata, CommentBody, Patchable, SubscriptionData, CommentUserReaction, InboxNotificationData, UserRoomSubscriptionSettings, RoomSubscriptionSettings, KDAD, DAD, NotificationSettings, PartialNotificationSettings, GroupScopes, GroupData, LiveObject, Awaitable, DFM, Feed, FeedUpdateMetadata, FeedMessage, NotificationChannel } from '@liveblocks/core';
2
+ export { CommentBody, CommentBodyBlockElement, CommentBodyElement, CommentBodyInlineElement, CommentBodyLink, CommentBodyLinkElementArgs, CommentBodyMention, CommentBodyMentionElementArgs, CommentBodyParagraph, CommentBodyParagraphElementArgs, CommentBodyText, CommentBodyTextElementArgs, CommentData, CommentUserReaction, IUserInfo, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveMap, LiveObject, LiveStructure, Lson, LsonObject, PlainLsonObject, ResolveUsersArgs, RoomAccesses, RoomPermissions, StringifyCommentBodyElements, StringifyCommentBodyOptions, ThreadData, User, getMentionsFromCommentBody, isNotificationChannelEnabled, stringifyCommentBody } from '@liveblocks/core';
3
3
  import { IncomingHttpHeaders } from 'http';
4
4
 
5
- declare const ALL_PERMISSIONS: readonly ["room:write", "room:read", "room:presence:write", "comments:write", "comments:read", "feeds:write"];
6
- type Permission = (typeof ALL_PERMISSIONS)[number];
7
5
  /**
8
- * Class to help you construct the exact permission set to grant a user, used
9
- * when making `.authorizeUser()` calls.
6
+ * Class to help you construct the exact permission set to grant a user.
10
7
  *
11
8
  * Usage:
12
9
  *
13
10
  * const session = liveblocks.prepareSession();
14
- * session.allow(roomId, permissions) // or...
11
+ * session.allow(roomId, permissions)
15
12
  *
16
- * For the `permissions` argument, you can pass a list of specific permissions,
17
- * or use one of our presets:
13
+ * For the `permissions` argument, pass a list of permission scopes.
18
14
  *
19
- * session.allow('my-room', session.FULL_ACCESS) // Read + write access to room storage and comments
20
- * session.allow('my-room', session.READ_ACCESS) // Read-only access to room storage and comments
15
+ * session.allow('my-room', ['*:write']) // Read + write access
16
+ * session.allow('my-room', ['*:read']) // Read-only access
17
+ * session.allow('my-room', [
18
+ * '*:write', // Read + write access by default
19
+ * 'comments:read' // But read-only access to comments
20
+ * 'feeds:none' // And no access to feeds
21
+ * ])
21
22
  *
22
23
  * Rooms can be specified with a prefix match, if the name ends in an asterisk.
23
24
  * In that case, access is granted to *all* rooms that start with that prefix:
24
25
  *
25
26
  * // Read + write access to *all* rooms that start with "abc:"
26
- * session.allow('abc:*', session.FULL_ACCESS)
27
+ * session.allow('abc:*', ['*:write'])
27
28
  *
28
29
  * You can define at most 10 room IDs (or patterns) in a single token,
29
30
  * otherwise the token would become too large and unwieldy.
30
31
  *
31
- * All permissions granted are additive. You cannot "remove" permissions once
32
- * you grant them. For example:
33
- *
34
- * session
35
- * .allow('abc:*', session.FULL_ACCESS)
36
- * .allow('abc:123', session.READ_ACCESS)
37
- *
38
- * Here, room `abc:123` would have full access. The second .allow() call only
39
- * _adds_ read permissions, but that has no effect since full access
40
- * permissions were already added to the set.
41
32
  */
42
33
  declare class Session {
43
34
  #private;
44
- readonly FULL_ACCESS: readonly ["room:write"];
45
- readonly READ_ACCESS: readonly ["room:read", "room:presence:write", "comments:read"];
35
+ /**
36
+ * @deprecated Use `["*:write"]` instead.
37
+ */
38
+ readonly FULL_ACCESS: readonly ["*:write"];
39
+ /**
40
+ * @deprecated Use `["*:read"]` instead.
41
+ */
42
+ readonly READ_ACCESS: readonly ["*:read"];
46
43
  allow(roomIdOrPattern: string, newPerms: readonly Permission[]): this;
47
44
  /**
48
45
  * Call this to authorize the session to access Liveblocks. Note that this
@@ -130,8 +127,6 @@ type CreateCommentOptions<CM extends BaseMetadata> = {
130
127
  metadata: CM;
131
128
  }>;
132
129
  };
133
- type RoomPermission = [] | ["room:write"] | ["room:read", "room:presence:write"] | ["room:read", "room:presence:write", "comments:write"];
134
- type RoomAccesses = Record<string, ["room:write"] | ["room:read", "room:presence:write"] | ["room:read", "room:presence:write", "comments:write"]>;
135
130
  type RoomMetadata = Record<string, string | string[]>;
136
131
  type QueryRoomMetadata = Record<string, string>;
137
132
  type RoomData = {
@@ -140,7 +135,7 @@ type RoomData = {
140
135
  createdAt: Date;
141
136
  lastConnectionAt?: Date;
142
137
  organizationId: string;
143
- defaultAccesses: RoomPermission;
138
+ defaultAccesses: RoomPermissions;
144
139
  usersAccesses: RoomAccesses;
145
140
  groupsAccesses: RoomAccesses;
146
141
  metadata: RoomMetadata;
@@ -318,7 +313,7 @@ type Page<T> = {
318
313
  type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions;
319
314
  type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
320
315
  type CreateRoomOptions = {
321
- defaultAccesses: RoomPermission;
316
+ defaultAccesses: RoomPermissions;
322
317
  groupsAccesses?: RoomAccesses;
323
318
  usersAccesses?: RoomAccesses;
324
319
  metadata?: RoomMetadata;
@@ -327,20 +322,11 @@ type CreateRoomOptions = {
327
322
  */
328
323
  tenantId?: string;
329
324
  organizationId?: string;
330
- /**
331
- * @deprecated This flag no longer has any effect and will be removed in
332
- * a future version. All rooms now use the v2 storage engine by default.
333
- */
334
- engine?: 1 | 2;
335
325
  };
336
326
  type UpdateRoomOptions = {
337
- defaultAccesses?: RoomPermission | null;
338
- groupsAccesses?: Record<string, [
339
- "room:write"
340
- ] | ["room:read", "room:presence:write"] | null>;
341
- usersAccesses?: Record<string, [
342
- "room:write"
343
- ] | ["room:read", "room:presence:write"] | null>;
327
+ defaultAccesses?: RoomPermissions | null;
328
+ groupsAccesses?: UpdateRoomAccesses;
329
+ usersAccesses?: UpdateRoomAccesses;
344
330
  metadata?: Record<string, string | string[] | null>;
345
331
  };
346
332
  type UpsertRoomOptions = {
@@ -2001,4 +1987,9 @@ declare function isTextMentionNotificationEvent(event: WebhookEvent): event is T
2001
1987
  */
2002
1988
  declare function isCustomNotificationEvent(event: WebhookEvent): event is CustomNotificationEvent;
2003
1989
 
2004
- export { type AiCopilot, type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateAiCopilotOptions, type CreateFeedMessageOptions, type CreateFeedOptions, type CreateFileKnowledgeSourceOptions, type CreateRoomOptions, type CreateWebKnowledgeSourceOptions, type CustomNotificationEvent, type GetAiCopilotsOptions, type GetInboxNotificationsOptions, type GetKnowledgeSourcesOptions, type GetRoomsOptions, type GetWebKnowledgeSourceLinksOptions, type InboxNotificationsQueryCriteria, type KnowledgeSource, Liveblocks, LiveblocksError, type LiveblocksOptions, type MassMutateStorageCallback, type MassMutateStorageOptions, type MutateStorageCallback, type MutateStorageOptions, type NotificationEvent, type Page, type PaginationOptions, type RoomAccesses, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomPermission, type RoomUser, type RoomsQueryCriteria, type SetPresenceOptions, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UpdateAiCopilotOptions, type UpdateFeedMessageOptions, type UpdateFeedOptions, type UpdateRoomOptions, type UpsertRoomOptions, type UserEnteredEvent, type UserLeftEvent, type WebKnowledgeSourceLink, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent, markdownToCommentBody };
1990
+ /**
1991
+ * @deprecated Use `RoomPermissions` instead.
1992
+ */
1993
+ type RoomPermission = RoomPermissions;
1994
+
1995
+ export { type AiCopilot, type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateAiCopilotOptions, type CreateFeedMessageOptions, type CreateFeedOptions, type CreateFileKnowledgeSourceOptions, type CreateRoomOptions, type CreateWebKnowledgeSourceOptions, type CustomNotificationEvent, type GetAiCopilotsOptions, type GetInboxNotificationsOptions, type GetKnowledgeSourcesOptions, type GetRoomsOptions, type GetWebKnowledgeSourceLinksOptions, type InboxNotificationsQueryCriteria, type KnowledgeSource, Liveblocks, LiveblocksError, type LiveblocksOptions, type MassMutateStorageCallback, type MassMutateStorageOptions, type MutateStorageCallback, type MutateStorageOptions, type NotificationEvent, type Page, type PaginationOptions, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomPermission, type RoomUser, type RoomsQueryCriteria, type SetPresenceOptions, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UpdateAiCopilotOptions, type UpdateFeedMessageOptions, type UpdateFeedOptions, type UpdateRoomOptions, type UpsertRoomOptions, type UserEnteredEvent, type UserLeftEvent, type WebKnowledgeSourceLink, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent, markdownToCommentBody };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { detectDupes } from "@liveblocks/core";
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/node";
6
- var PKG_VERSION = "3.20.0-rc1";
6
+ var PKG_VERSION = "3.20.0";
7
7
  var PKG_FORMAT = "esm";
8
8
 
9
9
  // src/client.ts
@@ -22,6 +22,9 @@ import {
22
22
  isPlainObject,
23
23
  LiveObject,
24
24
  makeAbortController,
25
+ normalizeRoomAccesses,
26
+ normalizeRoomPermissions as normalizeRoomPermissions2,
27
+ normalizeUpdateRoomAccesses,
25
28
  objectToQuery,
26
29
  tryParseJson,
27
30
  url as url2,
@@ -106,7 +109,7 @@ function xwarn(resp, method, path) {
106
109
  }
107
110
 
108
111
  // src/Session.ts
109
- import { url } from "@liveblocks/core";
112
+ import { normalizeRoomPermissions, Permission, url } from "@liveblocks/core";
110
113
 
111
114
  // src/utils.ts
112
115
  var DEFAULT_BASE_URL = "https://api.liveblocks.io";
@@ -160,29 +163,18 @@ function normalizeStatusCode(statusCode) {
160
163
  }
161
164
 
162
165
  // src/Session.ts
163
- var ALL_PERMISSIONS = Object.freeze([
164
- "room:write",
165
- "room:read",
166
- "room:presence:write",
167
- "comments:write",
168
- "comments:read",
169
- "feeds:write"
170
- ]);
171
- function isPermission(value) {
172
- return ALL_PERMISSIONS.includes(value);
173
- }
174
166
  var MAX_PERMS_PER_SET = 10;
175
- var READ_ACCESS = Object.freeze([
176
- "room:read",
177
- "room:presence:write",
178
- // TODO: Remove once backend no longer requires this
179
- "comments:read"
180
- // TODO: Remove — implied by room:read
181
- ]);
182
- var FULL_ACCESS = Object.freeze(["room:write"]);
167
+ var READ_ACCESS = Object.freeze([Permission.Read]);
168
+ var FULL_ACCESS = Object.freeze([Permission.Write]);
183
169
  var roomPatternRegex = /^([*]|[^*]{1,128}[*]?)$/;
184
170
  var Session = class {
171
+ /**
172
+ * @deprecated Use `["*:write"]` instead.
173
+ */
185
174
  FULL_ACCESS = FULL_ACCESS;
175
+ /**
176
+ * @deprecated Use `["*:read"]` instead.
177
+ */
186
178
  READ_ACCESS = READ_ACCESS;
187
179
  #postFn;
188
180
  #userId;
@@ -229,11 +221,9 @@ var Session = class {
229
221
  if (newPerms.length === 0) {
230
222
  throw new Error("Permission list cannot be empty");
231
223
  }
224
+ const permissions = normalizeRoomPermissions(newPerms);
232
225
  const existingPerms = this.#getOrCreate(roomIdOrPattern);
233
- for (const perm of newPerms) {
234
- if (!isPermission(perm)) {
235
- throw new Error(`Not a valid permission: ${perm}`);
236
- }
226
+ for (const perm of permissions) {
237
227
  existingPerms.add(perm);
238
228
  }
239
229
  return this;
@@ -308,6 +298,22 @@ function inflateRoomData(room) {
308
298
  lastConnectionAt
309
299
  };
310
300
  }
301
+ function normalizeCreateRoomOptions(options) {
302
+ return {
303
+ ...options,
304
+ defaultAccesses: normalizeRoomPermissions2(options.defaultAccesses),
305
+ groupsAccesses: normalizeRoomAccesses(options.groupsAccesses),
306
+ usersAccesses: normalizeRoomAccesses(options.usersAccesses)
307
+ };
308
+ }
309
+ function normalizeUpdateRoomOptions(options) {
310
+ return {
311
+ ...options,
312
+ defaultAccesses: options.defaultAccesses === void 0 || options.defaultAccesses === null ? options.defaultAccesses : normalizeRoomPermissions2(options.defaultAccesses),
313
+ groupsAccesses: normalizeUpdateRoomAccesses(options.groupsAccesses),
314
+ usersAccesses: normalizeUpdateRoomAccesses(options.usersAccesses)
315
+ };
316
+ }
311
317
  function inflateAiCopilot(copilot) {
312
318
  return {
313
319
  ...copilot,
@@ -614,6 +620,7 @@ var Liveblocks = class {
614
620
  * @returns The created room.
615
621
  */
616
622
  async createRoom(roomId, params, options) {
623
+ const normalizedParams = normalizeCreateRoomOptions(params);
617
624
  const {
618
625
  defaultAccesses,
619
626
  groupsAccesses,
@@ -621,7 +628,7 @@ var Liveblocks = class {
621
628
  metadata,
622
629
  tenantId,
623
630
  organizationId
624
- } = params;
631
+ } = normalizedParams;
625
632
  const body = {
626
633
  id: roomId,
627
634
  defaultAccesses,
@@ -674,9 +681,13 @@ var Liveblocks = class {
674
681
  * @returns The room.
675
682
  */
676
683
  async upsertRoom(roomId, params, options) {
684
+ const body = {
685
+ update: normalizeUpdateRoomOptions(params.update),
686
+ create: params.create === void 0 ? void 0 : normalizeCreateRoomOptions(params.create)
687
+ };
677
688
  const res = await this.#post(
678
689
  url2`/v2/rooms/${roomId}/upsert`,
679
- params,
690
+ body,
680
691
  options
681
692
  );
682
693
  if (!res.ok) {
@@ -711,7 +722,7 @@ var Liveblocks = class {
711
722
  * @returns The updated room.
712
723
  */
713
724
  async updateRoom(roomId, params, options) {
714
- const { defaultAccesses, groupsAccesses, usersAccesses, metadata } = params;
725
+ const { defaultAccesses, groupsAccesses, usersAccesses, metadata } = normalizeUpdateRoomOptions(params);
715
726
  const res = await this.#post(
716
727
  url2`/v2/rooms/${roomId}`,
717
728
  {