# @uipath/case-tool

CLI plugin for managing UiPath case management resources. Provides commands to pull, cache, and list resources from the UiPath platform.

## Installation

This package is a plugin for `uip`. It is loaded automatically when installed in the CLI's plugin directory.

## Prerequisites

You must be logged in before using any commands:

```bash
uip login
```

## Commands

All commands are available under the `case` prefix:

```
uip case <command>
```

### `registry pull`

Fetch and cache all resource types from the UiPath platform.

```bash
uip case registry pull [options]
```

| Option | Description |
| :--- | :--- |
| `-f, --force` | Force refresh, ignore local cache |
| `-s, --solutionId <id>` | Include entities from a specific solution |
| `-o, --format <type>` | Output format: `json`, `table`, `yaml`, `plain` (default: `json`) |

**Resource types pulled:**

| Type | Description |
| :--- | :--- |
| `agent` | Agent processes |
| `process` | RPA workflows |
| `api` | API workflows |
| `processOrchestration` | Agentic processes |
| `caseManagement` | Case management workflows |
| `typecache` | Studio activities (CrossPlatform / ProcessOrchestration) |
| `action-apps` | Deployed human action apps |
| `solution` | Solution entities (requires `--solutionId`) |

**Cache behavior:** Results are cached for 30 minutes in `~/.uipcli/case-resources/`. Subsequent `pull` calls within that window return cached data unless `--force` is passed.

**Example output:**

```json
{
  "Result": "Success",
  "Code": "PullResourcesSuccess",
  "Data": {
    "TotalNodesCount": 142,
    "FromCache": false,
    "ResourceTypes": [
      { "Type": "agent", "NodesCount": 12, "FromCache": false, "CacheWritten": true },
      { "Type": "process", "NodesCount": 87, "FromCache": false, "CacheWritten": true }
    ]
  }
}
```

---

### `registry list`

List all locally cached resources.

```bash
uip case registry list [options]
```

| Option | Description |
| :--- | :--- |
| `-o, --format <type>` | Output format: `json`, `table`, `yaml`, `plain` (default: `json`) |
| `-q, --quiet` | Quiet mode, no output |

If no cache exists, the command automatically fetches live data from the platform.

---

## Local Cache

Resources are stored in `~/.uipcli/case-resources/` as JSON files:

| File | Contents |
| :--- | :--- |
| `{type}-index.json` | Full resource array for that type |
| `{type}-index.meta.json` | Sync metadata: `lastSync`, `count`, `hash` |

Change detection uses SHA-256 hashing — if the fetched data is identical to the cache, only the timestamp is updated and the index is not rewritten.

## API Endpoints

| Resource type | Endpoint |
| :--- | :--- |
| `agent`, `process`, `api`, `processOrchestration`, `caseManagement` | `/{accountId}/{tenantId}/resourcecatalog_/Entities/Process?entitySubType=<type>` |
| `action-apps` | `/{accountId}/apps_/default/api/v1/default/action-apps?state=deployed` |
| `typecache` | `/{accountId}/studio_/typecache/api/Activities/SearchActivities` |
| `solution` | `/{accountId}/studio_/backend/api/resourcebuilder/solutions/{solutionId}/entities` |
