# @coda/dashboards-api

ConnectRPC client and proto definitions for dashboard management.

## Installation

```jsonc
// package.json
{ "dependencies": { "@coda/dashboards-api": "workspace:*" } }
```

## Usage

```ts
import { DashboardClient } from "@coda/dashboards-api";

const dashboards = new DashboardClient({ baseUrl: "http://localhost:8080" });

// List dashboards
const list = await dashboards.listDashboards({ tenantId: "t_456" });
if (list.ok) {
  for (const d of list.data.dashboards) {
    console.log(d.name, d.description);
  }
}

// Create a dashboard
const created = await dashboards.createDashboard({
  tenantId: "t_456",
  name: "Revenue Overview",
  description: "Monthly revenue by account",
});

// Update
await dashboards.updateDashboard({ dashboardId: "d_789", name: "Q2 Revenue" });

// Delete
await dashboards.deleteDashboard({ dashboardId: "d_789" });
```

## API Reference

### DashboardClient

| Method                 | Description                  | Default Timeout | Retries |
| ---------------------- | ---------------------------- | --------------- | ------- |
| `listDashboards(req)`  | List dashboards for a tenant | 2 s             | Yes (3) |
| `getDashboard(req)`    | Fetch a dashboard by ID      | 2 s             | Yes (3) |
| `createDashboard(req)` | Create a new dashboard       | 2 s             | No      |
| `updateDashboard(req)` | Update dashboard metadata    | 2 s             | No      |
| `deleteDashboard(req)` | Delete a dashboard           | 2 s             | No      |

## Configuration

All clients accept `BaseClientConfig` from `@coda/api-common`:

```ts
interface BaseClientConfig {
  baseUrl: string;
  transport?: "connect" | "grpc";
  interceptors?: Interceptor[];
  defaultTimeoutMs?: number;
  onError?: (method: string, err: unknown) => void;
}
```

All methods return `RpcResult<T>` — a discriminated union that never throws. See `@coda/api-common` for details.

## Exported Types

| Type                      | Description                                            |
| ------------------------- | ------------------------------------------------------ |
| `DashboardClientConfig`   | Client constructor config (extends `BaseClientConfig`) |
| `Dashboard`               | Dashboard entity                                       |
| `ListDashboardsResponse`  | Paginated dashboard list                               |
| `GetDashboardResponse`    | Single dashboard response                              |
| `CreateDashboardResponse` | Created dashboard                                      |
| `UpdateDashboardResponse` | Updated dashboard                                      |
| `DeleteDashboardResponse` | Deletion confirmation                                  |

## Proto sources

`proto/dashboards/` — `.proto` files defining the RPC service and message types.

## Generated code

`gen/` — auto-generated TypeScript. Do not edit manually.

## Regenerate

```bash
pnpm buf:generate
```

Requires [Buf CLI](https://buf.build/). Generated output is committed to the repo.
