@liveblocks/node 3.22.0-file1 → 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 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-file1";
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}/active_users`,
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}/broadcast_event`,
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
  * -----------------------------------------------------------------------------------------------*/
@@ -1176,18 +1258,6 @@ var Liveblocks = class {
1176
1258
  }
1177
1259
  return await res.json();
1178
1260
  }
1179
- async getStorageFile(params, options) {
1180
- const { roomId, fileId } = params;
1181
- const res = await this.#get(
1182
- _core.url`/v2/rooms/${roomId}/storage-files/${fileId}`,
1183
- void 0,
1184
- options
1185
- );
1186
- if (!res.ok) {
1187
- throw await LiveblocksError.from(res);
1188
- }
1189
- return await res.json();
1190
- }
1191
1261
  /**
1192
1262
  * Creates a new thread. The thread will be created with the specified comment as its first comment.
1193
1263
  * If the thread already exists, a `LiveblocksError` will be thrown with status code 409.
@@ -1945,7 +2015,7 @@ var Liveblocks = class {
1945
2015
  try {
1946
2016
  const resp = await this.#requestStorageMutation(roomId, { signal });
1947
2017
  const { actor, nodes } = resp;
1948
- const pool = _core.createManagedPool.call(void 0, roomId, {
2018
+ const pool = _core.createManagedPool.call(void 0, {
1949
2019
  getCurrentConnectionId: () => actor,
1950
2020
  onDispatch: (ops, _reverse, _storageUpdates) => {
1951
2021
  if (ops.length === 0) return;