# Ejemplos

> Ejecuta ejemplos de Collaboration SDK por función y consulta sus guías y entradas de servidor y Web.

- Human documentation: [https://docs.univer.ai/es-ES/server/collaboration/examples](https://docs.univer.ai/es-ES/server/collaboration/examples)

- Agent Markdown: [https://docs.univer.ai/es-ES/server/collaboration/examples.md](https://docs.univer.ai/es-ES/server/collaboration/examples.md)

- Requested language: `es-ES`

- Content language: `es-ES`

- Documentation version: `1.2.0`

- Source: [collaboration/examples.es-ES.mdx](https://github.com/dream-num/documentation/blob/dev/content/server/collaboration/examples.es-ES.mdx)

---

Todos los ejemplos están en [univer-collaboration-examples](https://github.com/dream-num/univer-collaboration-examples). Usan la misma estructura mínima `web/main.ts + server/main.ts` y se ejecutan de forma independiente. Completa el inicio rápido y elige después según tu integración.

| Ejemplo                                         | Concepto principal              | Comando                         |
| ----------------------------------------------- | ------------------------------- | ------------------------------- |
| [Inicio rápido](#quick-start)                   | Circuito colaborativo principal | `pnpm example:quick-start`      |
| [Adaptador de base de datos](#database-adapter) | Adaptadores de base de datos    | `pnpm example:database-adapter` |
| [Permisos](#permissions)                        | Identidad y autorización        | `pnpm example:permissions`      |
| [Historial](#history)                           | Historial derivado              | `pnpm example:history`          |
| [Comentarios](#comments)                        | Comentarios independientes      | `pnpm example:comments`         |
| [Worktree](#worktree)                           | Edición aislada y fusión        | `pnpm example:worktree`         |
| [Conversión de archivos](#exchange)             | Conversión Office               | `pnpm example:exchange`         |
| [Despliegue en varios nodos](#multi-node)       | Escalado horizontal             | `pnpm example:multi-node`       |

## Inicio rápido

Combina Collaboration Client, Transport, Endpoint, Service y Memory Adapter. Verifica en dos navegadores la carga HTTP, Sessions WebSocket, Room, ACK y difusión para la misma Sheet.

```bash
pnpm example:quick-start
```

Abre `http://127.0.0.1:3010/?unit=quick-start-sheet`.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/quick-start/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/quick-start/server/main.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/quick-start/web/main.ts)
* [Guía paso a paso de este sitio](https://docs.univer.ai/es-ES/server/collaboration/quick-start.md)

## Adaptador de base de datos

Este ejemplo muestra cómo usar el SQLite Adapter integrado e implementar un Database Adapter personalizado.

```bash
pnpm example:database-adapter
```

Abre `http://127.0.0.1:3010/?unit=persistent-sheet`.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/database-adapter/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/database-adapter/server/main.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/database-adapter/web/main.ts)

## Permisos

Crea una identidad fiable desde una cookie y protege por separado lectura HTTP Unit, JOIN en tiempo real y envío de cambios. La página alterna entre un **Alice · Editor** didáctico y un **Bob · Viewer** de solo lectura.

```bash
pnpm example:permissions
```

Abre `http://127.0.0.1:3010`.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/permissions/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/permissions/server/main.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/permissions/web/main.ts)
* [Guía de identidad y autorización](https://docs.univer.ai/es-ES/server/collaboration/identity-and-authorization.md)

## Historial

Añade fuera del núcleo History Service, un Adapter separado, History Endpoint y la entrada de historial del navegador. Los Events de creación Unit y commit construyen un índice derivado reconstruible.

```bash
pnpm example:history
```

Abre `http://127.0.0.1:3010/?unit=history-sheet`, edita la Sheet y selecciona `History` arriba.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/history/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/history/server/main.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/history/web/main.ts)

## Comentarios

Añade Thread Comment Service, un Adapter separado, Comment Endpoint y la entrada frontend. Comment Endpoint reutiliza las Sessions y Rooms Unit del Endpoint principal.

```bash
pnpm example:comments
```

Abre `http://127.0.0.1:3010/?unit=comments-sheet`, selecciona una celda y usa la entrada de comentarios.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/comments/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/comments/server/main.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/comments/web/main.ts)

## Worktree

Demuestra el ciclo completo de borrador aislado, Ready, Reopen y Merge por Unit. Alterna tronco y borrador para ver cómo los cambios del AI Agent quedan aislados antes de fusionar.

```bash
pnpm example:worktree
```

Abre `http://127.0.0.1:3010/?unit=worktree-sheet&worktree=demo-worktree`.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/worktree/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/worktree/server/main.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/worktree/web/main.ts)
* [CLI y revisión humana](https://docs.univer.ai/es-ES/ai/worktree.md)

## Conversión de archivos

Combina `@univerjs-pro/exchange-node` y Collaboration Service para importar/exportar Sheet en servidor, consultar tareas, importar instantáneas y exportar revisiones confirmadas.

```bash
pnpm example:exchange
```

Abre `http://127.0.0.1:3010/?unit=exchange-sheet`. Importa con **File → Open (File)** y exporta con **File → Save As**.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/README.md)
* [Entrada del servidor](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/server/main.ts)
* [Flujo de conversión](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/server/exchange.ts)
* [Entrada Web](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/exchange/web/main.ts)

## Despliegue en varios nodos

Ejecuta dos nodos de colaboración detrás de Nginx. Redis reenvía las actualizaciones en tiempo real entre nodos y comparte los session tickets, de modo que cualquier nodo puede atender cualquier solicitud. Requiere Docker Compose.

```bash
pnpm example:multi-node
```

Abre `http://127.0.0.1:3010/` y haz clic en **New Sheet** para crear un archivo. Copia la URL completa en otra pestaña para verificar la edición colaborativa del mismo documento. Después, crea algunos archivos más para observar cómo se distribuyen entre los nodos.

* [Guía del ejemplo](https://github.com/dream-num/univer-collaboration-examples/blob/main/examples/multi-node/README.md)

> [!NOTE: Los ejemplos no son aplicaciones de producción]
> Usuarios fijos, autorización didáctica, Memory Adapters, secretos locales y almacenamiento de archivos y tareas en memoria son solo educativos. La aplicación gestiona identidad, autorización, persistencia, secretos, archivos, despliegue e interacción.
