# Shaper

> Connect DSUI to a Shaper server to browse, edit, and share dashboards, watch tasks, and run SQL.

The Shaper adapter talks to a Shaper server with an API key. It has a single connection method, `api`.

## Add a Shaper service

Declare the adapter and the service in `dsui.yaml`:

```yaml
adapters:
  shaper:
    source: git
    repository: "git+https://github.com/northgraindata/dsui"
    path: packages/adapter-shaper

services:
  - id: shaper
    adapter: shaper
    name: Shaper
    connection:
      method: api
      baseUrl: http://shaper:5454
      apiKey: ${SHAPER_API_KEY}
      # Optional, needed to share dashboards. See "Sharing" below.
      userEmail: ${SHAPER_USER_EMAIL}
      userPassword: ${SHAPER_USER_PASSWORD}
```

Use the Compose service name when DSUI and Shaper run in the same Compose project.
`localhost` points back to the DSUI container, not Shaper.

## API key permissions

Create the key in Shaper under API keys.
The adapter works with a partial key and reports the missing permission when a feature needs it.

| Permission | Used for |
| --- | --- |
| `deploy` | Listing, creating, editing, moving, and deleting dashboards and tasks |
| `deploy:dry-run` | Validating dashboard SQL before saving |
| `schema:read` | The query explorer |
| `data:query` | The SQL page |
| `jwt` | Rendering dashboards and exporting them |
| `dashboard:read` | Dashboard exports |

## Available

- An overview of task health, failing tasks, upcoming runs, and recent dashboards
- Browse dashboards and tasks, including their folders
- View dashboards natively in DSUI, with Shaper's tables, values, line, bar, pie, donut and gauge views and its dropdown, text and date controls
- Create, edit, validate, and delete dashboards and tasks as SQL
- Export a dashboard as PDF, PNG, CSV, or XLSX
- Share a dashboard publicly or behind a password and get the link to send
- Run single SQL statements with a DuckDB schema explorer
- AI agents can read a dashboard's values with `dashboard-summary` and run read-only queries with `sql-preview`, which only accepts allowlisted statements

The adapter polls tasks every minute and emits `shaper.task-failed` and `shaper.task-succeeded` signals when a task's last run changes.
The first poll only records history, so existing runs are not announced.

## Sharing

Shaper lets only signed-in users change a dashboard's visibility or password.
An API key cannot do it, and neither can the dashboard tokens minted from one.
To share dashboards, add the email and password of a Shaper user to the connection.
DSUI signs in as that user only when you share a dashboard.

The `share-dashboard` action sets a dashboard to `private`, `public`, or `password-protected` and returns the link.
For a password-protected dashboard you can choose the password.
If you do not, DSUI generates one and returns it once, because Shaper stores only a hash and never shows it again.
Sharing fails with a clear message when the Shaper server has disabled public or password-protected sharing.

Use a dedicated Shaper user for this connection and give it only the access it needs.

## Limits

- Dashboards render from the data Shaper returns, so a chart type DSUI has no view for appears as a table that names the type.
- Shaper returns at most 3000 rows per dashboard query.
- SQL results arrive as text from `/api/sql`, without column types, and the page shows at most 5000 rows.
- Shaper hides query errors from the tokens used to render dashboards.
  On failure DSUI validates the saved SQL with the API key and shows the real error.
- Shaper keeps only the latest run of each task, so there is no run history.

## Not yet available

- Folders, which Shaper only allows for signed-in users
- Users, invitations, and API key management
- Running a saved task on demand
- Embedding the original Shaper page, because Shaper sends `X-Frame-Options: SAMEORIGIN`

Use Shaper's own UI for workflows outside this list.
