@liveblocks/node 2.21.0-emails3 → 2.22.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.cjs +332 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +188 -89
- package/dist/index.d.ts +188 -89
- package/dist/index.js +325 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUserMeta, DU, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, KDAD, DAD, UserNotificationSettings, PartialUserNotificationSettings, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM,
|
|
1
|
+
import { BaseUserMeta, DU, LiveObject, Awaitable, DS, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, KDAD, DAD, UserNotificationSettings, PartialUserNotificationSettings, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM, NotificationChannel } 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, isNotificationChannelEnabled, stringifyCommentBody } from '@liveblocks/core';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
|
|
@@ -133,10 +133,113 @@ type Schema = {
|
|
|
133
133
|
createdAt: Date;
|
|
134
134
|
updatedAt: Date;
|
|
135
135
|
};
|
|
136
|
+
type MutateStorageCallback = (context: {
|
|
137
|
+
root: LiveObject<S>;
|
|
138
|
+
}) => Awaitable<void>;
|
|
139
|
+
type MutateStorageOptions = RequestOptions;
|
|
140
|
+
type MassMutateStorageCallback = (context: {
|
|
141
|
+
room: RoomData;
|
|
142
|
+
root: LiveObject<S>;
|
|
143
|
+
}) => Awaitable<void>;
|
|
144
|
+
type MassMutateStorageOptions = MutateStorageOptions & {
|
|
145
|
+
concurrency?: number;
|
|
146
|
+
};
|
|
136
147
|
type E = DE;
|
|
137
148
|
type M = DM;
|
|
138
149
|
type S = DS;
|
|
139
150
|
type U = DU;
|
|
151
|
+
type RoomsQueryCriteria = {
|
|
152
|
+
userId?: string;
|
|
153
|
+
groupIds?: string[];
|
|
154
|
+
/**
|
|
155
|
+
* The query to filter rooms by. It is based on our query language.
|
|
156
|
+
* @example
|
|
157
|
+
* ```
|
|
158
|
+
* {
|
|
159
|
+
* query: 'metadata["status"]:"open" AND roomId^"liveblocks:"'
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
* @example
|
|
163
|
+
* ```
|
|
164
|
+
* {
|
|
165
|
+
* query: {
|
|
166
|
+
* metadata: {
|
|
167
|
+
* status: "open",
|
|
168
|
+
* },
|
|
169
|
+
* roomId: {
|
|
170
|
+
* startsWith: "liveblocks:"
|
|
171
|
+
* }
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
query?: string | {
|
|
177
|
+
metadata?: QueryRoomMetadata;
|
|
178
|
+
roomId?: {
|
|
179
|
+
startsWith: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
type InboxNotificationsQueryCriteria = {
|
|
184
|
+
userId: string;
|
|
185
|
+
/**
|
|
186
|
+
* The query to filter inbox notifications by. It is based on our query language.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```
|
|
190
|
+
* {
|
|
191
|
+
* query: "unread:true"
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```
|
|
197
|
+
* {
|
|
198
|
+
* query: {
|
|
199
|
+
* unread: true
|
|
200
|
+
* }
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
*/
|
|
205
|
+
query?: string | {
|
|
206
|
+
unread: boolean;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
type PaginationOptions = {
|
|
210
|
+
limit?: number;
|
|
211
|
+
startingAfter?: string;
|
|
212
|
+
};
|
|
213
|
+
type Page<T> = {
|
|
214
|
+
/** @deprecated Prefer to rely on `nextCursor` instead. */
|
|
215
|
+
nextPage?: string | null;
|
|
216
|
+
nextCursor: string | null;
|
|
217
|
+
data: T[];
|
|
218
|
+
};
|
|
219
|
+
type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions & {
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated Use `query` property instead. Support for the `metadata`
|
|
222
|
+
* field will be removed in a future version.
|
|
223
|
+
*/
|
|
224
|
+
metadata?: QueryRoomMetadata;
|
|
225
|
+
};
|
|
226
|
+
type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
|
|
227
|
+
type CreateRoomOptions = {
|
|
228
|
+
defaultAccesses: RoomPermission;
|
|
229
|
+
groupsAccesses?: RoomAccesses;
|
|
230
|
+
usersAccesses?: RoomAccesses;
|
|
231
|
+
metadata?: RoomMetadata;
|
|
232
|
+
};
|
|
233
|
+
type UpdateRoomOptions = {
|
|
234
|
+
defaultAccesses?: RoomPermission | null;
|
|
235
|
+
groupsAccesses?: Record<string, [
|
|
236
|
+
"room:write"
|
|
237
|
+
] | ["room:read", "room:presence:write"] | null>;
|
|
238
|
+
usersAccesses?: Record<string, [
|
|
239
|
+
"room:write"
|
|
240
|
+
] | ["room:read", "room:presence:write"] | null>;
|
|
241
|
+
metadata?: Record<string, string | string[] | null>;
|
|
242
|
+
};
|
|
140
243
|
type RequestOptions = {
|
|
141
244
|
signal?: AbortSignal;
|
|
142
245
|
};
|
|
@@ -214,49 +317,24 @@ declare class Liveblocks {
|
|
|
214
317
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
215
318
|
* @returns A list of rooms.
|
|
216
319
|
*/
|
|
217
|
-
getRooms(params?:
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
* @example
|
|
236
|
-
* ```
|
|
237
|
-
* {
|
|
238
|
-
* query: {
|
|
239
|
-
* metadata: {
|
|
240
|
-
* status: "open",
|
|
241
|
-
* },
|
|
242
|
-
* roomId: {
|
|
243
|
-
* startsWith: "liveblocks:"
|
|
244
|
-
* }
|
|
245
|
-
* }
|
|
246
|
-
* }
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
query?: string | {
|
|
250
|
-
metadata?: QueryRoomMetadata;
|
|
251
|
-
roomId?: {
|
|
252
|
-
startsWith: string;
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
}, options?: RequestOptions): Promise<{
|
|
256
|
-
nextPage: string | null;
|
|
257
|
-
nextCursor: string | null;
|
|
258
|
-
data: RoomData[];
|
|
259
|
-
}>;
|
|
320
|
+
getRooms(params?: GetRoomsOptions, options?: RequestOptions): Promise<Page<RoomData>>;
|
|
321
|
+
/**
|
|
322
|
+
* Iterates over all rooms that match the given criteria.
|
|
323
|
+
*
|
|
324
|
+
* The difference with .getRooms() is that pagination will happen
|
|
325
|
+
* automatically under the hood, using the given `pageSize`.
|
|
326
|
+
*
|
|
327
|
+
* @param criteria.userId (optional) A filter on users accesses.
|
|
328
|
+
* @param criteria.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
|
|
329
|
+
* @param criteria.query.roomId (optional) A filter by room ID.
|
|
330
|
+
* @param criteria.query.metadata (optional) A filter by metadata.
|
|
331
|
+
*
|
|
332
|
+
* @param options.pageSize (optional) The page size to use for each request.
|
|
333
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
334
|
+
*/
|
|
335
|
+
iterRooms(criteria: RoomsQueryCriteria, options?: RequestOptions & {
|
|
336
|
+
pageSize?: number;
|
|
337
|
+
}): AsyncGenerator<RoomData>;
|
|
260
338
|
/**
|
|
261
339
|
* Creates a new room with the given id.
|
|
262
340
|
* @param roomId The id of the room to create.
|
|
@@ -267,12 +345,32 @@ declare class Liveblocks {
|
|
|
267
345
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
268
346
|
* @returns The created room.
|
|
269
347
|
*/
|
|
270
|
-
createRoom(roomId: string, params:
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
348
|
+
createRoom(roomId: string, params: CreateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
349
|
+
/**
|
|
350
|
+
* Returns a room with the given id, or creates one with the given creation
|
|
351
|
+
* options if it doesn't exist yet.
|
|
352
|
+
*
|
|
353
|
+
* @param roomId The id of the room.
|
|
354
|
+
* @param params.defaultAccesses The default accesses for the room if the room will be created.
|
|
355
|
+
* @param params.groupsAccesses (optional) The group accesses for the room if the room will be created. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
356
|
+
* @param params.usersAccesses (optional) The user accesses for the room if the room will be created. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
357
|
+
* @param params.metadata (optional) The metadata for the room if the room will be created. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
358
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
359
|
+
* @returns The room.
|
|
360
|
+
*/
|
|
361
|
+
getOrCreateRoom(roomId: string, params: CreateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
362
|
+
/**
|
|
363
|
+
* Updates or creates a new room with the given properties.
|
|
364
|
+
*
|
|
365
|
+
* @param roomId The id of the room to update or create.
|
|
366
|
+
* @param params.defaultAccesses The default accesses for the room.
|
|
367
|
+
* @param params.groupsAccesses (optional) The group accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
368
|
+
* @param params.usersAccesses (optional) The user accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
369
|
+
* @param params.metadata (optional) The metadata for the room. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
370
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
371
|
+
* @returns The room.
|
|
372
|
+
*/
|
|
373
|
+
upsertRoom(roomId: string, params: CreateRoomOptions & UpdateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
276
374
|
/**
|
|
277
375
|
* Returns a room with the given id.
|
|
278
376
|
* @param roomId The id of the room to return.
|
|
@@ -291,16 +389,7 @@ declare class Liveblocks {
|
|
|
291
389
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
292
390
|
* @returns The updated room.
|
|
293
391
|
*/
|
|
294
|
-
updateRoom(roomId: string, params:
|
|
295
|
-
defaultAccesses?: RoomPermission | null;
|
|
296
|
-
groupsAccesses?: Record<string, [
|
|
297
|
-
"room:write"
|
|
298
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
299
|
-
usersAccesses?: Record<string, [
|
|
300
|
-
"room:write"
|
|
301
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
302
|
-
metadata?: Record<string, string | string[] | null>;
|
|
303
|
-
}, options?: RequestOptions): Promise<RoomData>;
|
|
392
|
+
updateRoom(roomId: string, params: UpdateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
304
393
|
/**
|
|
305
394
|
* Deletes a room with the given id. A deleted room is no longer accessible from the API or the dashboard and it cannot be restored.
|
|
306
395
|
* @param roomId The id of the room to delete.
|
|
@@ -712,34 +801,21 @@ declare class Liveblocks {
|
|
|
712
801
|
* @param params.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
713
802
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
714
803
|
*/
|
|
715
|
-
getInboxNotifications(params:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
* query: {
|
|
731
|
-
* unread: true
|
|
732
|
-
* }
|
|
733
|
-
* }
|
|
734
|
-
* ```
|
|
735
|
-
*
|
|
736
|
-
*/
|
|
737
|
-
query?: string | {
|
|
738
|
-
unread: boolean;
|
|
739
|
-
};
|
|
740
|
-
}, options?: RequestOptions): Promise<{
|
|
741
|
-
data: InboxNotificationData[];
|
|
742
|
-
}>;
|
|
804
|
+
getInboxNotifications(params: GetInboxNotificationsOptions, options?: RequestOptions): Promise<Page<InboxNotificationData>>;
|
|
805
|
+
/**
|
|
806
|
+
* Iterates over all inbox notifications for a user.
|
|
807
|
+
*
|
|
808
|
+
* The difference with .getInboxNotifications() is that pagination will
|
|
809
|
+
* happen automatically under the hood, using the given `pageSize`.
|
|
810
|
+
*
|
|
811
|
+
* @param criteria.userId The user ID to get the inbox notifications from.
|
|
812
|
+
* @param criteria.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
813
|
+
* @param options.pageSize (optional) The page size to use for each request.
|
|
814
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
815
|
+
*/
|
|
816
|
+
iterInboxNotifications(criteria: InboxNotificationsQueryCriteria, options?: RequestOptions & {
|
|
817
|
+
pageSize?: number;
|
|
818
|
+
}): AsyncGenerator<InboxNotificationData>;
|
|
743
819
|
/**
|
|
744
820
|
* Gets the user's room notification settings.
|
|
745
821
|
* @param params.userId The user ID to get the room notifications from.
|
|
@@ -833,6 +909,29 @@ declare class Liveblocks {
|
|
|
833
909
|
deleteNotificationSettings(params: {
|
|
834
910
|
userId: string;
|
|
835
911
|
}, options?: RequestOptions): Promise<void>;
|
|
912
|
+
/**
|
|
913
|
+
* Retrieves the current Storage contents for the given room ID and calls the
|
|
914
|
+
* provided callback function, in which you can mutate the Storage contents
|
|
915
|
+
* at will.
|
|
916
|
+
*
|
|
917
|
+
* If you need to run the same mutation across multiple rooms, prefer using
|
|
918
|
+
* `.massMutateStorage()` instead of looping over room IDs yourself.
|
|
919
|
+
*/
|
|
920
|
+
mutateStorage(roomId: string, callback: MutateStorageCallback, options?: MutateStorageOptions): Promise<void>;
|
|
921
|
+
/**
|
|
922
|
+
* Retrieves the Storage contents for each room that matches the given
|
|
923
|
+
* criteria and calls the provided callback function, in which you can mutate
|
|
924
|
+
* the Storage contents at will.
|
|
925
|
+
*
|
|
926
|
+
* You can use the `criteria` parameter to select which rooms to process by
|
|
927
|
+
* their metadata. If you pass `{}` (empty object), all rooms will be
|
|
928
|
+
* selected and processed.
|
|
929
|
+
*
|
|
930
|
+
* This method will execute mutations in parallel, using the specified
|
|
931
|
+
* `concurrency` value. If you which to run the mutations serially, set
|
|
932
|
+
* `concurrency` to 1.
|
|
933
|
+
*/
|
|
934
|
+
massMutateStorage(criteria: RoomsQueryCriteria, callback: MassMutateStorageCallback, massOptions?: MassMutateStorageOptions): Promise<void>;
|
|
836
935
|
}
|
|
837
936
|
declare class LiveblocksError extends Error {
|
|
838
937
|
readonly status: number;
|
|
@@ -1204,4 +1303,4 @@ declare function isCustomNotificationEvent(event: WebhookEvent): event is Custom
|
|
|
1204
1303
|
*/
|
|
1205
1304
|
type RoomInfo = RoomData;
|
|
1206
1305
|
|
|
1207
|
-
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CustomNotificationEvent, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent };
|
|
1306
|
+
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateRoomOptions, type CustomNotificationEvent, type GetInboxNotificationsOptions, type GetRoomsOptions, type InboxNotificationsQueryCriteria, 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 RoomInfo, type RoomPermission, type RoomUser, type RoomsQueryCriteria, type Schema, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UpdateRoomOptions, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUserMeta, DU, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, KDAD, DAD, UserNotificationSettings, PartialUserNotificationSettings, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM,
|
|
1
|
+
import { BaseUserMeta, DU, LiveObject, Awaitable, DS, OptionalTupleUnless, PlainLsonObject, JsonObject, QueryMetadata, ThreadData, CommentData, CommentBody, Patchable, CommentUserReaction, InboxNotificationData, RoomNotificationSettings, KDAD, DAD, UserNotificationSettings, PartialUserNotificationSettings, LsonObject, ToImmutable, PartialUnless, BaseMetadata, DE, DM, NotificationChannel } 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, isNotificationChannelEnabled, stringifyCommentBody } from '@liveblocks/core';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
|
|
@@ -133,10 +133,113 @@ type Schema = {
|
|
|
133
133
|
createdAt: Date;
|
|
134
134
|
updatedAt: Date;
|
|
135
135
|
};
|
|
136
|
+
type MutateStorageCallback = (context: {
|
|
137
|
+
root: LiveObject<S>;
|
|
138
|
+
}) => Awaitable<void>;
|
|
139
|
+
type MutateStorageOptions = RequestOptions;
|
|
140
|
+
type MassMutateStorageCallback = (context: {
|
|
141
|
+
room: RoomData;
|
|
142
|
+
root: LiveObject<S>;
|
|
143
|
+
}) => Awaitable<void>;
|
|
144
|
+
type MassMutateStorageOptions = MutateStorageOptions & {
|
|
145
|
+
concurrency?: number;
|
|
146
|
+
};
|
|
136
147
|
type E = DE;
|
|
137
148
|
type M = DM;
|
|
138
149
|
type S = DS;
|
|
139
150
|
type U = DU;
|
|
151
|
+
type RoomsQueryCriteria = {
|
|
152
|
+
userId?: string;
|
|
153
|
+
groupIds?: string[];
|
|
154
|
+
/**
|
|
155
|
+
* The query to filter rooms by. It is based on our query language.
|
|
156
|
+
* @example
|
|
157
|
+
* ```
|
|
158
|
+
* {
|
|
159
|
+
* query: 'metadata["status"]:"open" AND roomId^"liveblocks:"'
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
* @example
|
|
163
|
+
* ```
|
|
164
|
+
* {
|
|
165
|
+
* query: {
|
|
166
|
+
* metadata: {
|
|
167
|
+
* status: "open",
|
|
168
|
+
* },
|
|
169
|
+
* roomId: {
|
|
170
|
+
* startsWith: "liveblocks:"
|
|
171
|
+
* }
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
query?: string | {
|
|
177
|
+
metadata?: QueryRoomMetadata;
|
|
178
|
+
roomId?: {
|
|
179
|
+
startsWith: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
type InboxNotificationsQueryCriteria = {
|
|
184
|
+
userId: string;
|
|
185
|
+
/**
|
|
186
|
+
* The query to filter inbox notifications by. It is based on our query language.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```
|
|
190
|
+
* {
|
|
191
|
+
* query: "unread:true"
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```
|
|
197
|
+
* {
|
|
198
|
+
* query: {
|
|
199
|
+
* unread: true
|
|
200
|
+
* }
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
*/
|
|
205
|
+
query?: string | {
|
|
206
|
+
unread: boolean;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
type PaginationOptions = {
|
|
210
|
+
limit?: number;
|
|
211
|
+
startingAfter?: string;
|
|
212
|
+
};
|
|
213
|
+
type Page<T> = {
|
|
214
|
+
/** @deprecated Prefer to rely on `nextCursor` instead. */
|
|
215
|
+
nextPage?: string | null;
|
|
216
|
+
nextCursor: string | null;
|
|
217
|
+
data: T[];
|
|
218
|
+
};
|
|
219
|
+
type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions & {
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated Use `query` property instead. Support for the `metadata`
|
|
222
|
+
* field will be removed in a future version.
|
|
223
|
+
*/
|
|
224
|
+
metadata?: QueryRoomMetadata;
|
|
225
|
+
};
|
|
226
|
+
type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
|
|
227
|
+
type CreateRoomOptions = {
|
|
228
|
+
defaultAccesses: RoomPermission;
|
|
229
|
+
groupsAccesses?: RoomAccesses;
|
|
230
|
+
usersAccesses?: RoomAccesses;
|
|
231
|
+
metadata?: RoomMetadata;
|
|
232
|
+
};
|
|
233
|
+
type UpdateRoomOptions = {
|
|
234
|
+
defaultAccesses?: RoomPermission | null;
|
|
235
|
+
groupsAccesses?: Record<string, [
|
|
236
|
+
"room:write"
|
|
237
|
+
] | ["room:read", "room:presence:write"] | null>;
|
|
238
|
+
usersAccesses?: Record<string, [
|
|
239
|
+
"room:write"
|
|
240
|
+
] | ["room:read", "room:presence:write"] | null>;
|
|
241
|
+
metadata?: Record<string, string | string[] | null>;
|
|
242
|
+
};
|
|
140
243
|
type RequestOptions = {
|
|
141
244
|
signal?: AbortSignal;
|
|
142
245
|
};
|
|
@@ -214,49 +317,24 @@ declare class Liveblocks {
|
|
|
214
317
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
215
318
|
* @returns A list of rooms.
|
|
216
319
|
*/
|
|
217
|
-
getRooms(params?:
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
* @example
|
|
236
|
-
* ```
|
|
237
|
-
* {
|
|
238
|
-
* query: {
|
|
239
|
-
* metadata: {
|
|
240
|
-
* status: "open",
|
|
241
|
-
* },
|
|
242
|
-
* roomId: {
|
|
243
|
-
* startsWith: "liveblocks:"
|
|
244
|
-
* }
|
|
245
|
-
* }
|
|
246
|
-
* }
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
query?: string | {
|
|
250
|
-
metadata?: QueryRoomMetadata;
|
|
251
|
-
roomId?: {
|
|
252
|
-
startsWith: string;
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
}, options?: RequestOptions): Promise<{
|
|
256
|
-
nextPage: string | null;
|
|
257
|
-
nextCursor: string | null;
|
|
258
|
-
data: RoomData[];
|
|
259
|
-
}>;
|
|
320
|
+
getRooms(params?: GetRoomsOptions, options?: RequestOptions): Promise<Page<RoomData>>;
|
|
321
|
+
/**
|
|
322
|
+
* Iterates over all rooms that match the given criteria.
|
|
323
|
+
*
|
|
324
|
+
* The difference with .getRooms() is that pagination will happen
|
|
325
|
+
* automatically under the hood, using the given `pageSize`.
|
|
326
|
+
*
|
|
327
|
+
* @param criteria.userId (optional) A filter on users accesses.
|
|
328
|
+
* @param criteria.groupIds (optional) A filter on groups accesses. Multiple groups can be used.
|
|
329
|
+
* @param criteria.query.roomId (optional) A filter by room ID.
|
|
330
|
+
* @param criteria.query.metadata (optional) A filter by metadata.
|
|
331
|
+
*
|
|
332
|
+
* @param options.pageSize (optional) The page size to use for each request.
|
|
333
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
334
|
+
*/
|
|
335
|
+
iterRooms(criteria: RoomsQueryCriteria, options?: RequestOptions & {
|
|
336
|
+
pageSize?: number;
|
|
337
|
+
}): AsyncGenerator<RoomData>;
|
|
260
338
|
/**
|
|
261
339
|
* Creates a new room with the given id.
|
|
262
340
|
* @param roomId The id of the room to create.
|
|
@@ -267,12 +345,32 @@ declare class Liveblocks {
|
|
|
267
345
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
268
346
|
* @returns The created room.
|
|
269
347
|
*/
|
|
270
|
-
createRoom(roomId: string, params:
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
348
|
+
createRoom(roomId: string, params: CreateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
349
|
+
/**
|
|
350
|
+
* Returns a room with the given id, or creates one with the given creation
|
|
351
|
+
* options if it doesn't exist yet.
|
|
352
|
+
*
|
|
353
|
+
* @param roomId The id of the room.
|
|
354
|
+
* @param params.defaultAccesses The default accesses for the room if the room will be created.
|
|
355
|
+
* @param params.groupsAccesses (optional) The group accesses for the room if the room will be created. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
356
|
+
* @param params.usersAccesses (optional) The user accesses for the room if the room will be created. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
357
|
+
* @param params.metadata (optional) The metadata for the room if the room will be created. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
358
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
359
|
+
* @returns The room.
|
|
360
|
+
*/
|
|
361
|
+
getOrCreateRoom(roomId: string, params: CreateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
362
|
+
/**
|
|
363
|
+
* Updates or creates a new room with the given properties.
|
|
364
|
+
*
|
|
365
|
+
* @param roomId The id of the room to update or create.
|
|
366
|
+
* @param params.defaultAccesses The default accesses for the room.
|
|
367
|
+
* @param params.groupsAccesses (optional) The group accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
368
|
+
* @param params.usersAccesses (optional) The user accesses for the room. Can contain a maximum of 100 entries. Key length has a limit of 40 characters.
|
|
369
|
+
* @param params.metadata (optional) The metadata for the room. Supports upto a maximum of 50 entries. Key length has a limit of 40 characters. Value length has a limit of 256 characters.
|
|
370
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
371
|
+
* @returns The room.
|
|
372
|
+
*/
|
|
373
|
+
upsertRoom(roomId: string, params: CreateRoomOptions & UpdateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
276
374
|
/**
|
|
277
375
|
* Returns a room with the given id.
|
|
278
376
|
* @param roomId The id of the room to return.
|
|
@@ -291,16 +389,7 @@ declare class Liveblocks {
|
|
|
291
389
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
292
390
|
* @returns The updated room.
|
|
293
391
|
*/
|
|
294
|
-
updateRoom(roomId: string, params:
|
|
295
|
-
defaultAccesses?: RoomPermission | null;
|
|
296
|
-
groupsAccesses?: Record<string, [
|
|
297
|
-
"room:write"
|
|
298
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
299
|
-
usersAccesses?: Record<string, [
|
|
300
|
-
"room:write"
|
|
301
|
-
] | ["room:read", "room:presence:write"] | null>;
|
|
302
|
-
metadata?: Record<string, string | string[] | null>;
|
|
303
|
-
}, options?: RequestOptions): Promise<RoomData>;
|
|
392
|
+
updateRoom(roomId: string, params: UpdateRoomOptions, options?: RequestOptions): Promise<RoomData>;
|
|
304
393
|
/**
|
|
305
394
|
* Deletes a room with the given id. A deleted room is no longer accessible from the API or the dashboard and it cannot be restored.
|
|
306
395
|
* @param roomId The id of the room to delete.
|
|
@@ -712,34 +801,21 @@ declare class Liveblocks {
|
|
|
712
801
|
* @param params.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
713
802
|
* @param options.signal (optional) An abort signal to cancel the request.
|
|
714
803
|
*/
|
|
715
|
-
getInboxNotifications(params:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
* query: {
|
|
731
|
-
* unread: true
|
|
732
|
-
* }
|
|
733
|
-
* }
|
|
734
|
-
* ```
|
|
735
|
-
*
|
|
736
|
-
*/
|
|
737
|
-
query?: string | {
|
|
738
|
-
unread: boolean;
|
|
739
|
-
};
|
|
740
|
-
}, options?: RequestOptions): Promise<{
|
|
741
|
-
data: InboxNotificationData[];
|
|
742
|
-
}>;
|
|
804
|
+
getInboxNotifications(params: GetInboxNotificationsOptions, options?: RequestOptions): Promise<Page<InboxNotificationData>>;
|
|
805
|
+
/**
|
|
806
|
+
* Iterates over all inbox notifications for a user.
|
|
807
|
+
*
|
|
808
|
+
* The difference with .getInboxNotifications() is that pagination will
|
|
809
|
+
* happen automatically under the hood, using the given `pageSize`.
|
|
810
|
+
*
|
|
811
|
+
* @param criteria.userId The user ID to get the inbox notifications from.
|
|
812
|
+
* @param criteria.query The query to filter inbox notifications by. It is based on our query language and can filter by unread.
|
|
813
|
+
* @param options.pageSize (optional) The page size to use for each request.
|
|
814
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
815
|
+
*/
|
|
816
|
+
iterInboxNotifications(criteria: InboxNotificationsQueryCriteria, options?: RequestOptions & {
|
|
817
|
+
pageSize?: number;
|
|
818
|
+
}): AsyncGenerator<InboxNotificationData>;
|
|
743
819
|
/**
|
|
744
820
|
* Gets the user's room notification settings.
|
|
745
821
|
* @param params.userId The user ID to get the room notifications from.
|
|
@@ -833,6 +909,29 @@ declare class Liveblocks {
|
|
|
833
909
|
deleteNotificationSettings(params: {
|
|
834
910
|
userId: string;
|
|
835
911
|
}, options?: RequestOptions): Promise<void>;
|
|
912
|
+
/**
|
|
913
|
+
* Retrieves the current Storage contents for the given room ID and calls the
|
|
914
|
+
* provided callback function, in which you can mutate the Storage contents
|
|
915
|
+
* at will.
|
|
916
|
+
*
|
|
917
|
+
* If you need to run the same mutation across multiple rooms, prefer using
|
|
918
|
+
* `.massMutateStorage()` instead of looping over room IDs yourself.
|
|
919
|
+
*/
|
|
920
|
+
mutateStorage(roomId: string, callback: MutateStorageCallback, options?: MutateStorageOptions): Promise<void>;
|
|
921
|
+
/**
|
|
922
|
+
* Retrieves the Storage contents for each room that matches the given
|
|
923
|
+
* criteria and calls the provided callback function, in which you can mutate
|
|
924
|
+
* the Storage contents at will.
|
|
925
|
+
*
|
|
926
|
+
* You can use the `criteria` parameter to select which rooms to process by
|
|
927
|
+
* their metadata. If you pass `{}` (empty object), all rooms will be
|
|
928
|
+
* selected and processed.
|
|
929
|
+
*
|
|
930
|
+
* This method will execute mutations in parallel, using the specified
|
|
931
|
+
* `concurrency` value. If you which to run the mutations serially, set
|
|
932
|
+
* `concurrency` to 1.
|
|
933
|
+
*/
|
|
934
|
+
massMutateStorage(criteria: RoomsQueryCriteria, callback: MassMutateStorageCallback, massOptions?: MassMutateStorageOptions): Promise<void>;
|
|
836
935
|
}
|
|
837
936
|
declare class LiveblocksError extends Error {
|
|
838
937
|
readonly status: number;
|
|
@@ -1204,4 +1303,4 @@ declare function isCustomNotificationEvent(event: WebhookEvent): event is Custom
|
|
|
1204
1303
|
*/
|
|
1205
1304
|
type RoomInfo = RoomData;
|
|
1206
1305
|
|
|
1207
|
-
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CustomNotificationEvent, Liveblocks, LiveblocksError, type LiveblocksOptions, type NotificationEvent, type RoomAccesses, type RoomCreatedEvent, type RoomData, type RoomDeletedEvent, type RoomInfo, type RoomPermission, type RoomUser, type Schema, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent };
|
|
1306
|
+
export { type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateRoomOptions, type CustomNotificationEvent, type GetInboxNotificationsOptions, type GetRoomsOptions, type InboxNotificationsQueryCriteria, 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 RoomInfo, type RoomPermission, type RoomUser, type RoomsQueryCriteria, type Schema, type StorageUpdatedEvent, type TextMentionNotificationEvent, type ThreadCreatedEvent, type ThreadDeletedEvent, type ThreadMarkedAsResolvedEvent, type ThreadMarkedAsUnresolvedEvent, type ThreadMetadataUpdatedEvent, type ThreadNotificationEvent, type ThreadParticipants, type UpdateRoomOptions, type UserEnteredEvent, type UserLeftEvent, type WebhookEvent, WebhookHandler, type WebhookRequest, type YDocUpdatedEvent, isCustomNotificationEvent, isTextMentionNotificationEvent, isThreadNotificationEvent };
|