Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/api-reference/liveblocks-react-ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4122,7 +4122,7 @@ Version history enables you to track and restore versions of your
[Yjs](/docs/api-reference/liveblocks-yjs) document. Versions can be
automatically created when enabled in your project settings, or manually created
using the
[REST API](/docs/api-reference/rest-api-endpoints#post-rooms-roomId-version).
[REST API](/docs/api-reference/rest-api-endpoints#create-version-history-snapshot).
These components aid in displaying a list of those versions.

### Default components [#Version-History-Components]
Expand Down
61 changes: 54 additions & 7 deletions docs/references/v2.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@
}
}
},
"/rooms/{roomId}/active_users": {
"/rooms/{roomId}/active-users": {
"get": {
"summary": "Get active users",
"tags": ["Room"],
Expand Down Expand Up @@ -907,7 +907,7 @@
}
}
},
"/rooms/{roomId}/broadcast_event": {
"/rooms/{roomId}/broadcast-event": {
"post": {
"summary": "Broadcast event to a room",
"description": "This endpoint enables the broadcast of an event to a room without having to connect to it via the `client` from `@liveblocks/client`. It takes any valid JSON as a request body. The `connectionId` passed to event listeners is `-1` when using this API. Corresponds to [`liveblocks.broadcastEvent`](https://liveblocks.io/docs/api-reference/liveblocks-node#post-broadcast-event).",
Expand Down Expand Up @@ -1488,8 +1488,8 @@
"/rooms/{roomId}/versions": {
"get": {
"summary": "Get Version History",
"description": "This endpoint returns a list of version history snapshots for the room's Yjs document. The versions are returned sorted by creation date, from newest to oldest.",
"tags": ["Yjs"],
"description": "This endpoint returns a list of version history snapshots for the room. The versions are returned sorted by creation date, from newest to oldest.",
"tags": ["Version History"],
"operationId": "get-version-history",
"parameters": [
{
Expand Down Expand Up @@ -1569,8 +1569,8 @@
},
"post": {
"summary": "Create version history snapshot",
"description": "This endpoint creates a new version history snapshot for the room. Currently only works for Yjs.",
"tags": ["Yjs"],
"description": "This endpoint creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.",
"tags": ["Version History"],
"operationId": "create-version-history-snapshot",
"parameters": [
{
Expand Down Expand Up @@ -1620,7 +1620,7 @@
"get": {
"summary": "Get Yjs document version",
"description": "This endpoint returns a specific version of the room's Yjs document encoded as a binary Yjs update.",
"tags": ["Yjs"],
"tags": ["Version History"],
"operationId": "get-yjs-version",
"parameters": [
{
Expand Down Expand Up @@ -1668,6 +1668,50 @@
}
}
},
"/rooms/{roomId}/versions/{versionId}": {
"delete": {
"summary": "Delete a version",
"description": "This endpoint permanently deletes a version from the room's history.",
"tags": ["Version History"],
"operationId": "delete-version",
"parameters": [
{
"name": "roomId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"description": "ID of the room",
"example": "my-room-id"
}
},
{
"name": "versionId",
"in": "path",
"required": true,
"schema": {
"type": "string",
"description": "ID of the version",
"example": "vh_abc123"
}
}
],
"responses": {
"204": {
"description": "Success. The version was deleted."
},
"401": {
"$ref": "#/components/responses/401"
},
"403": {
"$ref": "#/components/responses/403"
},
"404": {
"$ref": "#/components/responses/404"
}
}
}
},
"/rooms/{roomId}/threads": {
"get": {
"summary": "Get room threads",
Expand Down Expand Up @@ -12012,6 +12056,9 @@
{
"name": "Yjs"
},
{
"name": "Version History"
},
{
"name": "Comments"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-chat-sdk-adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/chat-sdk-adapter",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "Liveblocks adapter for the Chat SDK.",
"license": "Apache-2.0",
"author": "Liveblocks Inc.",
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/client",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "A client that lets you interact with Liveblocks servers. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
"license": "Apache-2.0",
"author": "Liveblocks Inc.",
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/core",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "Private internals for Liveblocks. DO NOT import directly from this package!",
"type": "module",
"main": "./dist/index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-emails/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/emails",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "A set of functions and utilities to make sending emails based on Liveblocks notification events easy. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
"license": "Apache-2.0",
"author": "Liveblocks Inc.",
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-node-lexical/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/node-lexical",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "A server-side utility that lets you modify lexical documents hosted in Liveblocks.",
"license": "Apache-2.0",
"author": "Liveblocks Inc.",
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-node-prosemirror/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/node-prosemirror",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "A server-side utility that lets you modify prosemirror and tiptap documents hosted in Liveblocks.",
"license": "Apache-2.0",
"author": "Liveblocks Inc.",
Expand Down
2 changes: 1 addition & 1 deletion packages/liveblocks-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveblocks/node",
"version": "3.21.0",
"version": "3.22.0-rc1",
"description": "A server-side utility that lets you set up a Liveblocks authentication endpoint. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
"license": "Apache-2.0",
"author": "Liveblocks Inc.",
Expand Down
27 changes: 25 additions & 2 deletions packages/liveblocks-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,11 @@ print(result)

---

### Version_history

#### `get_version_history`

This endpoint returns a list of version history snapshots for the room's Yjs document. The versions are returned sorted by creation date, from newest to oldest.
This endpoint returns a list of version history snapshots for the room. The versions are returned sorted by creation date, from newest to oldest.

**Example**
```python
Expand All @@ -604,7 +606,7 @@ print(result)

#### `create_version_history_snapshot`

This endpoint creates a new version history snapshot for the room. Currently only works for Yjs.
This endpoint creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.

**Example**
```python
Expand Down Expand Up @@ -642,6 +644,27 @@ print(result)
| `version_id` | `str` | Yes | ID of the version |


---

#### `delete_version`

This endpoint permanently deletes a version from the room's history.

**Example**
```python
client.delete_version(
room_id="my-room-id",
version_id="vh_abc123",
)
```
**Parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `room_id` | `str` | Yes | ID of the room |
| `version_id` | `str` | Yes | ID of the version |


---

### Comments
Expand Down
35 changes: 33 additions & 2 deletions packages/liveblocks-python/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,11 @@ print(result)
</PropertiesList>


## Version_history

### get_version_history

This endpoint returns a list of version history snapshots for the room's Yjs document. The versions are returned sorted by creation date, from newest to oldest.
This endpoint returns a list of version history snapshots for the room. The versions are returned sorted by creation date, from newest to oldest.

```python
result = client.get_version_history(
Expand Down Expand Up @@ -765,7 +767,7 @@ print(result)

### create_version_history_snapshot

This endpoint creates a new version history snapshot for the room. Currently only works for Yjs.
This endpoint creates a new version history snapshot of the room, capturing both its Storage and Yjs documents.

```python
result = client.create_version_history_snapshot(
Expand Down Expand Up @@ -815,6 +817,35 @@ print(result)
</PropertiesList>


### delete_version

This endpoint permanently deletes a version from the room's history.

```python
client.delete_version(
room_id="my-room-id",
version_id="vh_abc123",
)
```

<PropertiesList title="Parameters">
<PropertiesListItem
name="room_id"
type="str"
>
ID of the room

</PropertiesListItem>
<PropertiesListItem
name="version_id"
type="str"
>
ID of the version

</PropertiesListItem>
</PropertiesList>


## Comments

### get_threads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _get_kwargs(

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v2/rooms/{room_id}/broadcast_event".format(
"url": "/v2/rooms/{room_id}/broadcast-event".format(
room_id=quote(str(room_id), safe=""),
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def _get_kwargs(

_kwargs: dict[str, Any] = {
"method": "get",
"url": "/v2/rooms/{room_id}/active_users".format(
"url": "/v2/rooms/{room_id}/active-users".format(
room_id=quote(str(room_id), safe=""),
),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors


def _get_kwargs(
room_id: str,
version_id: str,
) -> dict[str, Any]:

_kwargs: dict[str, Any] = {
"method": "delete",
"url": "/v2/rooms/{room_id}/versions/{version_id}".format(
room_id=quote(str(room_id), safe=""),
version_id=quote(str(version_id), safe=""),
),
}

return _kwargs


def _parse_response(*, response: httpx.Response) -> None:
if response.status_code == 204:
return None

raise errors.LiveblocksError.from_response(response)


def _sync(
room_id: str,
version_id: str,
*,
client: httpx.Client,
) -> None:
kwargs = _get_kwargs(
room_id=room_id,
version_id=version_id,
)

response = client.request(
**kwargs,
)
return _parse_response(response=response)


async def _asyncio(
room_id: str,
version_id: str,
*,
client: httpx.AsyncClient,
) -> None:
kwargs = _get_kwargs(
room_id=room_id,
version_id=version_id,
)

response = await client.request(
**kwargs,
)

return _parse_response(response=response)
Loading
Loading