@liveblocks/node 3.22.0-rc1 → 3.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 +86 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +86 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -311,6 +311,22 @@ type Page<T> = {
|
|
|
311
311
|
nextCursor: string | null;
|
|
312
312
|
data: T[];
|
|
313
313
|
};
|
|
314
|
+
type HistoryVersion = {
|
|
315
|
+
id: string;
|
|
316
|
+
createdAt: Date;
|
|
317
|
+
authors: {
|
|
318
|
+
id: string;
|
|
319
|
+
}[];
|
|
320
|
+
};
|
|
321
|
+
type GetVersionHistoryOptions = {
|
|
322
|
+
limit?: number;
|
|
323
|
+
cursor?: string;
|
|
324
|
+
};
|
|
325
|
+
type CreateVersionHistorySnapshotResponse = {
|
|
326
|
+
data: {
|
|
327
|
+
id: string;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
314
330
|
type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions;
|
|
315
331
|
type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
|
|
316
332
|
type CreateRoomOptions = {
|
|
@@ -761,6 +777,43 @@ declare class Liveblocks {
|
|
|
761
777
|
getYjsDocumentAsBinaryUpdate(roomId: string, params?: {
|
|
762
778
|
guid?: string;
|
|
763
779
|
}, options?: RequestOptions): Promise<ArrayBuffer>;
|
|
780
|
+
/**
|
|
781
|
+
* Returns the version history snapshots for the room, sorted by creation date from newest to oldest.
|
|
782
|
+
* @param roomId The ID of the room to get the version history from.
|
|
783
|
+
* @param params.limit (optional) The number of versions to return. The limit can range between 1 and 100, and defaults to 20.
|
|
784
|
+
* @param params.cursor (optional) A cursor used for pagination. Get the value from the `nextCursor` response of the previous page.
|
|
785
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
786
|
+
* @returns A list of version history snapshots and the next page cursor.
|
|
787
|
+
*/
|
|
788
|
+
getVersionHistory(roomId: string, params?: GetVersionHistoryOptions, options?: RequestOptions): Promise<Page<HistoryVersion>>;
|
|
789
|
+
/**
|
|
790
|
+
* Creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.
|
|
791
|
+
* @param roomId The ID of the room to create a version history snapshot for.
|
|
792
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
793
|
+
* @returns The created version ID.
|
|
794
|
+
*/
|
|
795
|
+
createVersionHistorySnapshot(roomId: string, options?: RequestOptions): Promise<CreateVersionHistorySnapshotResponse>;
|
|
796
|
+
/**
|
|
797
|
+
* Returns a specific version of the room's Yjs document encoded as a binary Yjs update.
|
|
798
|
+
* @param params.roomId The room ID to get the Yjs document version from.
|
|
799
|
+
* @param params.versionId The ID of the version to get.
|
|
800
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
801
|
+
* @returns The version's Yjs document encoded as a binary update.
|
|
802
|
+
*/
|
|
803
|
+
getYjsVersion(params: {
|
|
804
|
+
roomId: string;
|
|
805
|
+
versionId: string;
|
|
806
|
+
}, options?: RequestOptions): Promise<ArrayBuffer>;
|
|
807
|
+
/**
|
|
808
|
+
* Permanently deletes a version from the room's history.
|
|
809
|
+
* @param params.roomId The room ID to delete the version in.
|
|
810
|
+
* @param params.versionId The ID of the version to delete.
|
|
811
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
812
|
+
*/
|
|
813
|
+
deleteVersion(params: {
|
|
814
|
+
roomId: string;
|
|
815
|
+
versionId: string;
|
|
816
|
+
}, options?: RequestOptions): Promise<void>;
|
|
764
817
|
/**
|
|
765
818
|
* Gets all the threads in a room.
|
|
766
819
|
*
|
|
@@ -1995,4 +2048,4 @@ declare function isCustomNotificationEvent(event: WebhookEvent): event is Custom
|
|
|
1995
2048
|
*/
|
|
1996
2049
|
type RoomPermission = RoomPermissions;
|
|
1997
2050
|
|
|
1998
|
-
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 };
|
|
2051
|
+
export { type AiCopilot, type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateAiCopilotOptions, type CreateFeedMessageOptions, type CreateFeedOptions, type CreateFileKnowledgeSourceOptions, type CreateRoomOptions, type CreateVersionHistorySnapshotResponse, type CreateWebKnowledgeSourceOptions, type CustomNotificationEvent, type GetAiCopilotsOptions, type GetInboxNotificationsOptions, type GetKnowledgeSourcesOptions, type GetRoomsOptions, type GetVersionHistoryOptions, type GetWebKnowledgeSourceLinksOptions, type HistoryVersion, 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
|
@@ -311,6 +311,22 @@ type Page<T> = {
|
|
|
311
311
|
nextCursor: string | null;
|
|
312
312
|
data: T[];
|
|
313
313
|
};
|
|
314
|
+
type HistoryVersion = {
|
|
315
|
+
id: string;
|
|
316
|
+
createdAt: Date;
|
|
317
|
+
authors: {
|
|
318
|
+
id: string;
|
|
319
|
+
}[];
|
|
320
|
+
};
|
|
321
|
+
type GetVersionHistoryOptions = {
|
|
322
|
+
limit?: number;
|
|
323
|
+
cursor?: string;
|
|
324
|
+
};
|
|
325
|
+
type CreateVersionHistorySnapshotResponse = {
|
|
326
|
+
data: {
|
|
327
|
+
id: string;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
314
330
|
type GetRoomsOptions = RoomsQueryCriteria & PaginationOptions;
|
|
315
331
|
type GetInboxNotificationsOptions = InboxNotificationsQueryCriteria & PaginationOptions;
|
|
316
332
|
type CreateRoomOptions = {
|
|
@@ -761,6 +777,43 @@ declare class Liveblocks {
|
|
|
761
777
|
getYjsDocumentAsBinaryUpdate(roomId: string, params?: {
|
|
762
778
|
guid?: string;
|
|
763
779
|
}, options?: RequestOptions): Promise<ArrayBuffer>;
|
|
780
|
+
/**
|
|
781
|
+
* Returns the version history snapshots for the room, sorted by creation date from newest to oldest.
|
|
782
|
+
* @param roomId The ID of the room to get the version history from.
|
|
783
|
+
* @param params.limit (optional) The number of versions to return. The limit can range between 1 and 100, and defaults to 20.
|
|
784
|
+
* @param params.cursor (optional) A cursor used for pagination. Get the value from the `nextCursor` response of the previous page.
|
|
785
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
786
|
+
* @returns A list of version history snapshots and the next page cursor.
|
|
787
|
+
*/
|
|
788
|
+
getVersionHistory(roomId: string, params?: GetVersionHistoryOptions, options?: RequestOptions): Promise<Page<HistoryVersion>>;
|
|
789
|
+
/**
|
|
790
|
+
* Creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.
|
|
791
|
+
* @param roomId The ID of the room to create a version history snapshot for.
|
|
792
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
793
|
+
* @returns The created version ID.
|
|
794
|
+
*/
|
|
795
|
+
createVersionHistorySnapshot(roomId: string, options?: RequestOptions): Promise<CreateVersionHistorySnapshotResponse>;
|
|
796
|
+
/**
|
|
797
|
+
* Returns a specific version of the room's Yjs document encoded as a binary Yjs update.
|
|
798
|
+
* @param params.roomId The room ID to get the Yjs document version from.
|
|
799
|
+
* @param params.versionId The ID of the version to get.
|
|
800
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
801
|
+
* @returns The version's Yjs document encoded as a binary update.
|
|
802
|
+
*/
|
|
803
|
+
getYjsVersion(params: {
|
|
804
|
+
roomId: string;
|
|
805
|
+
versionId: string;
|
|
806
|
+
}, options?: RequestOptions): Promise<ArrayBuffer>;
|
|
807
|
+
/**
|
|
808
|
+
* Permanently deletes a version from the room's history.
|
|
809
|
+
* @param params.roomId The room ID to delete the version in.
|
|
810
|
+
* @param params.versionId The ID of the version to delete.
|
|
811
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
812
|
+
*/
|
|
813
|
+
deleteVersion(params: {
|
|
814
|
+
roomId: string;
|
|
815
|
+
versionId: string;
|
|
816
|
+
}, options?: RequestOptions): Promise<void>;
|
|
764
817
|
/**
|
|
765
818
|
* Gets all the threads in a room.
|
|
766
819
|
*
|
|
@@ -1995,4 +2048,4 @@ declare function isCustomNotificationEvent(event: WebhookEvent): event is Custom
|
|
|
1995
2048
|
*/
|
|
1996
2049
|
type RoomPermission = RoomPermissions;
|
|
1997
2050
|
|
|
1998
|
-
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 };
|
|
2051
|
+
export { type AiCopilot, type CommentCreatedEvent, type CommentDeletedEvent, type CommentEditedEvent, type CommentReactionAdded, type CommentReactionRemoved, type CreateAiCopilotOptions, type CreateFeedMessageOptions, type CreateFeedOptions, type CreateFileKnowledgeSourceOptions, type CreateRoomOptions, type CreateVersionHistorySnapshotResponse, type CreateWebKnowledgeSourceOptions, type CustomNotificationEvent, type GetAiCopilotsOptions, type GetInboxNotificationsOptions, type GetKnowledgeSourcesOptions, type GetRoomsOptions, type GetVersionHistoryOptions, type GetWebKnowledgeSourceLinksOptions, type HistoryVersion, 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.22.0
|
|
6
|
+
var PKG_VERSION = "3.22.0";
|
|
7
7
|
var PKG_FORMAT = "esm";
|
|
8
8
|
|
|
9
9
|
// src/client.ts
|
|
@@ -337,6 +337,12 @@ function inflateWebKnowledgeSourceLink(link) {
|
|
|
337
337
|
lastIndexedAt: new Date(link.lastIndexedAt)
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
|
+
function inflateHistoryVersion(version) {
|
|
341
|
+
return {
|
|
342
|
+
...version,
|
|
343
|
+
createdAt: new Date(version.createdAt)
|
|
344
|
+
};
|
|
345
|
+
}
|
|
340
346
|
var Liveblocks = class {
|
|
341
347
|
#secret;
|
|
342
348
|
#baseUrl;
|
|
@@ -777,7 +783,7 @@ var Liveblocks = class {
|
|
|
777
783
|
*/
|
|
778
784
|
async getActiveUsers(roomId, options) {
|
|
779
785
|
const res = await this.#get(
|
|
780
|
-
url2`/v2/rooms/${roomId}/
|
|
786
|
+
url2`/v2/rooms/${roomId}/active-users`,
|
|
781
787
|
void 0,
|
|
782
788
|
options
|
|
783
789
|
);
|
|
@@ -794,7 +800,7 @@ var Liveblocks = class {
|
|
|
794
800
|
*/
|
|
795
801
|
async broadcastEvent(roomId, message, options) {
|
|
796
802
|
const res = await this.#post(
|
|
797
|
-
url2`/v2/rooms/${roomId}/
|
|
803
|
+
url2`/v2/rooms/${roomId}/broadcast-event`,
|
|
798
804
|
message,
|
|
799
805
|
options
|
|
800
806
|
);
|
|
@@ -961,6 +967,82 @@ var Liveblocks = class {
|
|
|
961
967
|
}
|
|
962
968
|
return res.arrayBuffer();
|
|
963
969
|
}
|
|
970
|
+
/**
|
|
971
|
+
* Returns the version history snapshots for the room, sorted by creation date from newest to oldest.
|
|
972
|
+
* @param roomId The ID of the room to get the version history from.
|
|
973
|
+
* @param params.limit (optional) The number of versions to return. The limit can range between 1 and 100, and defaults to 20.
|
|
974
|
+
* @param params.cursor (optional) A cursor used for pagination. Get the value from the `nextCursor` response of the previous page.
|
|
975
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
976
|
+
* @returns A list of version history snapshots and the next page cursor.
|
|
977
|
+
*/
|
|
978
|
+
async getVersionHistory(roomId, params = {}, options) {
|
|
979
|
+
const res = await this.#get(
|
|
980
|
+
url2`/v2/rooms/${roomId}/versions`,
|
|
981
|
+
{ limit: params.limit, cursor: params.cursor },
|
|
982
|
+
options
|
|
983
|
+
);
|
|
984
|
+
if (!res.ok) {
|
|
985
|
+
throw await LiveblocksError.from(res);
|
|
986
|
+
}
|
|
987
|
+
const page = await res.json();
|
|
988
|
+
return {
|
|
989
|
+
nextCursor: page.nextCursor,
|
|
990
|
+
data: page.data.map(inflateHistoryVersion)
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.
|
|
995
|
+
* @param roomId The ID of the room to create a version history snapshot for.
|
|
996
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
997
|
+
* @returns The created version ID.
|
|
998
|
+
*/
|
|
999
|
+
async createVersionHistorySnapshot(roomId, options) {
|
|
1000
|
+
const res = await this.#post(
|
|
1001
|
+
url2`/v2/rooms/${roomId}/versions`,
|
|
1002
|
+
{},
|
|
1003
|
+
options
|
|
1004
|
+
);
|
|
1005
|
+
if (!res.ok) {
|
|
1006
|
+
throw await LiveblocksError.from(res);
|
|
1007
|
+
}
|
|
1008
|
+
return await res.json();
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Returns a specific version of the room's Yjs document encoded as a binary Yjs update.
|
|
1012
|
+
* @param params.roomId The room ID to get the Yjs document version from.
|
|
1013
|
+
* @param params.versionId The ID of the version to get.
|
|
1014
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1015
|
+
* @returns The version's Yjs document encoded as a binary update.
|
|
1016
|
+
*/
|
|
1017
|
+
async getYjsVersion(params, options) {
|
|
1018
|
+
const { roomId, versionId } = params;
|
|
1019
|
+
const res = await this.#get(
|
|
1020
|
+
url2`/v2/rooms/${roomId}/versions/${versionId}/yjs`,
|
|
1021
|
+
void 0,
|
|
1022
|
+
options
|
|
1023
|
+
);
|
|
1024
|
+
if (!res.ok) {
|
|
1025
|
+
throw await LiveblocksError.from(res);
|
|
1026
|
+
}
|
|
1027
|
+
return res.arrayBuffer();
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Permanently deletes a version from the room's history.
|
|
1031
|
+
* @param params.roomId The room ID to delete the version in.
|
|
1032
|
+
* @param params.versionId The ID of the version to delete.
|
|
1033
|
+
* @param options.signal (optional) An abort signal to cancel the request.
|
|
1034
|
+
*/
|
|
1035
|
+
async deleteVersion(params, options) {
|
|
1036
|
+
const { roomId, versionId } = params;
|
|
1037
|
+
const res = await this.#delete(
|
|
1038
|
+
url2`/v2/rooms/${roomId}/versions/${versionId}`,
|
|
1039
|
+
void 0,
|
|
1040
|
+
options
|
|
1041
|
+
);
|
|
1042
|
+
if (!res.ok) {
|
|
1043
|
+
throw await LiveblocksError.from(res);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
964
1046
|
/* -------------------------------------------------------------------------------------------------
|
|
965
1047
|
* Comments
|
|
966
1048
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -1933,7 +2015,7 @@ var Liveblocks = class {
|
|
|
1933
2015
|
try {
|
|
1934
2016
|
const resp = await this.#requestStorageMutation(roomId, { signal });
|
|
1935
2017
|
const { actor, nodes } = resp;
|
|
1936
|
-
const pool = createManagedPool(
|
|
2018
|
+
const pool = createManagedPool({
|
|
1937
2019
|
getCurrentConnectionId: () => actor,
|
|
1938
2020
|
onDispatch: (ops, _reverse, _storageUpdates) => {
|
|
1939
2021
|
if (ops.length === 0) return;
|