@liveblocks/node 3.20.0-exp6 → 3.20.0-perm1
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.cjs +40 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -28
- package/dist/index.d.ts +14 -28
- package/dist/index.js +41 -28
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
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 { RoomPermissionInput, Json, DFMD, FeedCreateMetadata, RoomAccessesInput, OptionalTupleUnless, BaseUserMeta, DU, PartialUnless, RoomPermission, RoomAccesses, RoomAccessesUpdateInput, 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, RoomPermission, 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
6
|
* Class to help you construct the exact permission set to grant a user, used
|
|
9
7
|
* when making `.authorizeUser()` calls.
|
|
@@ -28,22 +26,15 @@ type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
|
28
26
|
* You can define at most 10 room IDs (or patterns) in a single token,
|
|
29
27
|
* otherwise the token would become too large and unwieldy.
|
|
30
28
|
*
|
|
31
|
-
*
|
|
32
|
-
* you grant them. For example:
|
|
29
|
+
* You can also use object notation for resource-specific access:
|
|
33
30
|
*
|
|
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.
|
|
31
|
+
* session.allow('my-room', { default: 'write', storage: 'none' })
|
|
41
32
|
*/
|
|
42
33
|
declare class Session {
|
|
43
34
|
#private;
|
|
44
35
|
readonly FULL_ACCESS: readonly ["room:write"];
|
|
45
|
-
readonly READ_ACCESS: readonly ["room:read"
|
|
46
|
-
allow(roomIdOrPattern: string, newPerms:
|
|
36
|
+
readonly READ_ACCESS: readonly ["room:read"];
|
|
37
|
+
allow(roomIdOrPattern: string, newPerms: RoomPermissionInput): this;
|
|
47
38
|
/**
|
|
48
39
|
* Call this to authorize the session to access Liveblocks. Note that this
|
|
49
40
|
* will return a Liveblocks "access token". Anyone that obtains such access
|
|
@@ -130,8 +121,7 @@ type CreateCommentOptions<CM extends BaseMetadata> = {
|
|
|
130
121
|
metadata: CM;
|
|
131
122
|
}>;
|
|
132
123
|
};
|
|
133
|
-
|
|
134
|
-
type RoomAccesses = Record<string, ["room:write"] | ["room:read", "room:presence:write"] | ["room:read", "room:presence:write", "comments:write"]>;
|
|
124
|
+
|
|
135
125
|
type RoomMetadata = Record<string, string | string[]>;
|
|
136
126
|
type QueryRoomMetadata = Record<string, string>;
|
|
137
127
|
type RoomData = {
|
|
@@ -318,9 +308,9 @@ type Page<T> = {
|
|
|
318
308
|
type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions;
|
|
319
309
|
type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
|
|
320
310
|
type CreateRoomOptions = {
|
|
321
|
-
defaultAccesses:
|
|
322
|
-
groupsAccesses?:
|
|
323
|
-
usersAccesses?:
|
|
311
|
+
defaultAccesses: RoomPermissionInput;
|
|
312
|
+
groupsAccesses?: RoomAccessesInput;
|
|
313
|
+
usersAccesses?: RoomAccessesInput;
|
|
324
314
|
metadata?: RoomMetadata;
|
|
325
315
|
/**
|
|
326
316
|
* @deprecated Use `organizationId` instead.
|
|
@@ -334,13 +324,9 @@ type CreateRoomOptions = {
|
|
|
334
324
|
engine?: 1 | 2;
|
|
335
325
|
};
|
|
336
326
|
type UpdateRoomOptions = {
|
|
337
|
-
defaultAccesses?:
|
|
338
|
-
groupsAccesses?:
|
|
339
|
-
|
|
340
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
341
|
-
usersAccesses?: Record<string, [
|
|
342
|
-
"room:write"
|
|
343
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
327
|
+
defaultAccesses?: RoomPermissionInput | null;
|
|
328
|
+
groupsAccesses?: RoomAccessesUpdateInput;
|
|
329
|
+
usersAccesses?: RoomAccessesUpdateInput;
|
|
344
330
|
metadata?: Record<string, string | string[] | null>;
|
|
345
331
|
};
|
|
346
332
|
type UpsertRoomOptions = {
|
|
@@ -2001,4 +1987,4 @@ 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
|
|
1990
|
+
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 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,9 +1,7 @@
|
|
|
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 { RoomPermissionInput, Json, DFMD, FeedCreateMetadata, RoomAccessesInput, OptionalTupleUnless, BaseUserMeta, DU, PartialUnless, RoomPermission, RoomAccesses, RoomAccessesUpdateInput, 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, RoomPermission, 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
6
|
* Class to help you construct the exact permission set to grant a user, used
|
|
9
7
|
* when making `.authorizeUser()` calls.
|
|
@@ -28,22 +26,15 @@ type Permission = (typeof ALL_PERMISSIONS)[number];
|
|
|
28
26
|
* You can define at most 10 room IDs (or patterns) in a single token,
|
|
29
27
|
* otherwise the token would become too large and unwieldy.
|
|
30
28
|
*
|
|
31
|
-
*
|
|
32
|
-
* you grant them. For example:
|
|
29
|
+
* You can also use object notation for resource-specific access:
|
|
33
30
|
*
|
|
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.
|
|
31
|
+
* session.allow('my-room', { default: 'write', storage: 'none' })
|
|
41
32
|
*/
|
|
42
33
|
declare class Session {
|
|
43
34
|
#private;
|
|
44
35
|
readonly FULL_ACCESS: readonly ["room:write"];
|
|
45
|
-
readonly READ_ACCESS: readonly ["room:read"
|
|
46
|
-
allow(roomIdOrPattern: string, newPerms:
|
|
36
|
+
readonly READ_ACCESS: readonly ["room:read"];
|
|
37
|
+
allow(roomIdOrPattern: string, newPerms: RoomPermissionInput): this;
|
|
47
38
|
/**
|
|
48
39
|
* Call this to authorize the session to access Liveblocks. Note that this
|
|
49
40
|
* will return a Liveblocks "access token". Anyone that obtains such access
|
|
@@ -130,8 +121,7 @@ type CreateCommentOptions<CM extends BaseMetadata> = {
|
|
|
130
121
|
metadata: CM;
|
|
131
122
|
}>;
|
|
132
123
|
};
|
|
133
|
-
|
|
134
|
-
type RoomAccesses = Record<string, ["room:write"] | ["room:read", "room:presence:write"] | ["room:read", "room:presence:write", "comments:write"]>;
|
|
124
|
+
|
|
135
125
|
type RoomMetadata = Record<string, string | string[]>;
|
|
136
126
|
type QueryRoomMetadata = Record<string, string>;
|
|
137
127
|
type RoomData = {
|
|
@@ -318,9 +308,9 @@ type Page<T> = {
|
|
|
318
308
|
type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions;
|
|
319
309
|
type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
|
|
320
310
|
type CreateRoomOptions = {
|
|
321
|
-
defaultAccesses:
|
|
322
|
-
groupsAccesses?:
|
|
323
|
-
usersAccesses?:
|
|
311
|
+
defaultAccesses: RoomPermissionInput;
|
|
312
|
+
groupsAccesses?: RoomAccessesInput;
|
|
313
|
+
usersAccesses?: RoomAccessesInput;
|
|
324
314
|
metadata?: RoomMetadata;
|
|
325
315
|
/**
|
|
326
316
|
* @deprecated Use `organizationId` instead.
|
|
@@ -334,13 +324,9 @@ type CreateRoomOptions = {
|
|
|
334
324
|
engine?: 1 | 2;
|
|
335
325
|
};
|
|
336
326
|
type UpdateRoomOptions = {
|
|
337
|
-
defaultAccesses?:
|
|
338
|
-
groupsAccesses?:
|
|
339
|
-
|
|
340
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
341
|
-
usersAccesses?: Record<string, [
|
|
342
|
-
"room:write"
|
|
343
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
327
|
+
defaultAccesses?: RoomPermissionInput | null;
|
|
328
|
+
groupsAccesses?: RoomAccessesUpdateInput;
|
|
329
|
+
usersAccesses?: RoomAccessesUpdateInput;
|
|
344
330
|
metadata?: Record<string, string | string[] | null>;
|
|
345
331
|
};
|
|
346
332
|
type UpsertRoomOptions = {
|
|
@@ -2001,4 +1987,4 @@ 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
|
|
1990
|
+
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 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-
|
|
6
|
+
var PKG_VERSION = "3.20.0-perm1";
|
|
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
|
+
normalizeRoomAccessesInput,
|
|
26
|
+
normalizeRoomAccessesUpdateInput,
|
|
27
|
+
normalizeRoomPermissionInput as normalizeRoomPermissionInput2,
|
|
25
28
|
objectToQuery,
|
|
26
29
|
tryParseJson,
|
|
27
30
|
url as url2,
|
|
@@ -106,7 +109,12 @@ function xwarn(resp, method, path) {
|
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
// src/Session.ts
|
|
109
|
-
import {
|
|
112
|
+
import {
|
|
113
|
+
getRoomPermissionConflicts,
|
|
114
|
+
normalizeRoomPermissionInput,
|
|
115
|
+
Permission,
|
|
116
|
+
url
|
|
117
|
+
} from "@liveblocks/core";
|
|
110
118
|
|
|
111
119
|
// src/utils.ts
|
|
112
120
|
var DEFAULT_BASE_URL = "https://api.liveblocks.io";
|
|
@@ -160,26 +168,9 @@ function normalizeStatusCode(statusCode) {
|
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
// 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
171
|
var MAX_PERMS_PER_SET = 10;
|
|
175
|
-
var READ_ACCESS = Object.freeze([
|
|
176
|
-
|
|
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"]);
|
|
172
|
+
var READ_ACCESS = Object.freeze([Permission.RoomRead]);
|
|
173
|
+
var FULL_ACCESS = Object.freeze([Permission.RoomWrite]);
|
|
183
174
|
var roomPatternRegex = /^([*]|[^*]{1,128}[*]?)$/;
|
|
184
175
|
var Session = class {
|
|
185
176
|
FULL_ACCESS = FULL_ACCESS;
|
|
@@ -226,13 +217,14 @@ var Session = class {
|
|
|
226
217
|
if (!roomPatternRegex.test(roomIdOrPattern)) {
|
|
227
218
|
throw new Error("Invalid room name or pattern");
|
|
228
219
|
}
|
|
229
|
-
|
|
220
|
+
const normalizedPermissions = normalizeRoomPermissionInput(newPerms);
|
|
221
|
+
if (normalizedPermissions.length === 0) {
|
|
230
222
|
throw new Error("Permission list cannot be empty");
|
|
231
223
|
}
|
|
232
224
|
const existingPerms = this.#getOrCreate(roomIdOrPattern);
|
|
233
|
-
for (const perm of
|
|
234
|
-
|
|
235
|
-
|
|
225
|
+
for (const perm of normalizedPermissions) {
|
|
226
|
+
for (const conflictingPerm of getRoomPermissionConflicts(perm)) {
|
|
227
|
+
existingPerms.delete(conflictingPerm);
|
|
236
228
|
}
|
|
237
229
|
existingPerms.add(perm);
|
|
238
230
|
}
|
|
@@ -308,6 +300,22 @@ function inflateRoomData(room) {
|
|
|
308
300
|
lastConnectionAt
|
|
309
301
|
};
|
|
310
302
|
}
|
|
303
|
+
function normalizeCreateRoomOptions(options) {
|
|
304
|
+
return {
|
|
305
|
+
...options,
|
|
306
|
+
defaultAccesses: normalizeRoomPermissionInput2(options.defaultAccesses),
|
|
307
|
+
groupsAccesses: normalizeRoomAccessesInput(options.groupsAccesses),
|
|
308
|
+
usersAccesses: normalizeRoomAccessesInput(options.usersAccesses)
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function normalizeUpdateRoomOptions(options) {
|
|
312
|
+
return {
|
|
313
|
+
...options,
|
|
314
|
+
defaultAccesses: options.defaultAccesses === void 0 || options.defaultAccesses === null ? options.defaultAccesses : normalizeRoomPermissionInput2(options.defaultAccesses),
|
|
315
|
+
groupsAccesses: normalizeRoomAccessesUpdateInput(options.groupsAccesses),
|
|
316
|
+
usersAccesses: normalizeRoomAccessesUpdateInput(options.usersAccesses)
|
|
317
|
+
};
|
|
318
|
+
}
|
|
311
319
|
function inflateAiCopilot(copilot) {
|
|
312
320
|
return {
|
|
313
321
|
...copilot,
|
|
@@ -614,6 +622,7 @@ var Liveblocks = class {
|
|
|
614
622
|
* @returns The created room.
|
|
615
623
|
*/
|
|
616
624
|
async createRoom(roomId, params, options) {
|
|
625
|
+
const normalizedParams = normalizeCreateRoomOptions(params);
|
|
617
626
|
const {
|
|
618
627
|
defaultAccesses,
|
|
619
628
|
groupsAccesses,
|
|
@@ -621,7 +630,7 @@ var Liveblocks = class {
|
|
|
621
630
|
metadata,
|
|
622
631
|
tenantId,
|
|
623
632
|
organizationId
|
|
624
|
-
} =
|
|
633
|
+
} = normalizedParams;
|
|
625
634
|
const body = {
|
|
626
635
|
id: roomId,
|
|
627
636
|
defaultAccesses,
|
|
@@ -674,9 +683,13 @@ var Liveblocks = class {
|
|
|
674
683
|
* @returns The room.
|
|
675
684
|
*/
|
|
676
685
|
async upsertRoom(roomId, params, options) {
|
|
686
|
+
const body = {
|
|
687
|
+
update: normalizeUpdateRoomOptions(params.update),
|
|
688
|
+
create: params.create === void 0 ? void 0 : normalizeCreateRoomOptions(params.create)
|
|
689
|
+
};
|
|
677
690
|
const res = await this.#post(
|
|
678
691
|
url2`/v2/rooms/${roomId}/upsert`,
|
|
679
|
-
|
|
692
|
+
body,
|
|
680
693
|
options
|
|
681
694
|
);
|
|
682
695
|
if (!res.ok) {
|
|
@@ -711,7 +724,7 @@ var Liveblocks = class {
|
|
|
711
724
|
* @returns The updated room.
|
|
712
725
|
*/
|
|
713
726
|
async updateRoom(roomId, params, options) {
|
|
714
|
-
const { defaultAccesses, groupsAccesses, usersAccesses, metadata } = params;
|
|
727
|
+
const { defaultAccesses, groupsAccesses, usersAccesses, metadata } = normalizeUpdateRoomOptions(params);
|
|
715
728
|
const res = await this.#post(
|
|
716
729
|
url2`/v2/rooms/${roomId}`,
|
|
717
730
|
{
|