@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.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var _core = require('@liveblocks/core');
|
|
|
3
3
|
|
|
4
4
|
// src/version.ts
|
|
5
5
|
var PKG_NAME = "@liveblocks/node";
|
|
6
|
-
var PKG_VERSION = "3.22.0
|
|
6
|
+
var PKG_VERSION = "3.22.0";
|
|
7
7
|
var PKG_FORMAT = "cjs";
|
|
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
|
-
_core.url`/v2/rooms/${roomId}/
|
|
786
|
+
_core.url`/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
|
-
_core.url`/v2/rooms/${roomId}/
|
|
803
|
+
_core.url`/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
|
+
_core.url`/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
|
+
_core.url`/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
|
+
_core.url`/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
|
+
_core.url`/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 = _core.createManagedPool.call(void 0,
|
|
2018
|
+
const pool = _core.createManagedPool.call(void 0, {
|
|
1937
2019
|
getCurrentConnectionId: () => actor,
|
|
1938
2020
|
onDispatch: (ops, _reverse, _storageUpdates) => {
|
|
1939
2021
|
if (ops.length === 0) return;
|