npm package: @lushly-dev/fabric-api-client
Description: Fabric REST API client with Bearer token auth, error normalization, and typed connectors for all Fabric item types.
Latest version: 0.2.0

# @lushly-dev/fabric-api-client

Typed Fabric REST API client with Bearer token auth, error normalization, and modular connectors for all Fabric item types.

## Install

```bash
npm install @lushly-dev/fabric-api-client
```

## Usage

### Core client

```typescript
import { setAccessToken, fabricGet } from '@lushly-dev/fabric-api-client';

// Set token from Azure CLI:
// az account get-access-token --resource https://api.fabric.microsoft.com
setAccessToken(token);

const result = await fabricGet('/workspaces', 'List workspaces');
if (result.ok) {
  console.log(result.data);
} else {
  console.error(result.error.message);
  console.log(result.error.suggestion);
}
```

### Typed connectors

```typescript
import { setAccessToken } from '@lushly-dev/fabric-api-client';
import { listWorkspaces, getWorkspace } from '@lushly-dev/fabric-api-client/connectors';

setAccessToken(token);

const workspaces = await listWorkspaces();
const workspace = await getWorkspace('workspace-id');
```

### Admin APIs

```typescript
import { adminWorkspaces, adminTenants } from '@lushly-dev/fabric-api-client/connectors';

const workspaces = await adminWorkspaces.listWorkspaces();
const settings = await adminTenants.listTenantSettings();
```

## API coverage

| Group | Module | Functions |
|-------|--------|-----------|
| **Core** | workspaces | listWorkspaces, getWorkspace, createWorkspace, updateWorkspace, deleteWorkspace, listRoleAssignments, addRoleAssignment, updateRoleAssignment, deleteRoleAssignment, assignToCapacity |
| | items | listItems, getItem, createItem, updateItem, deleteItem, getItemDefinition, updateItemDefinition, listItemConnections |
| | capacities | listCapacities |
| | connections | listConnections, getConnection, createConnection, updateConnection, deleteConnection, listRoleAssignments, addRoleAssignment, deleteRoleAssignment |
| | operations | getOperationState, getOperationResult |
| **Platform** | job-scheduler | runOnDemandJob, getJobInstance, cancelJobInstance, listJobInstances, getItemSchedule, createItemSchedule, updateItemSchedule |
| | git | getConnection, connect, disconnect, getStatus, commitToGit, updateFromGit, initializeConnection, getMyCredentials, updateMyCredentials |
| | deployment-pipelines | listPipelines, getPipeline, createPipeline, updatePipeline, deletePipeline, listStages, getStage, listStageItems, assignWorkspace, unassignWorkspace, deploy |
| | onelake-shortcuts | listShortcuts, getShortcut, createShortcut, deleteShortcut |
| | folders | listFolders, getFolder |
| **Data Engineering** | lakehouses, warehouses, notebooks, environments, spark-job-definitions | CRUD + definitions |
| **Data Factory** | data-pipelines, dataflows, copy-jobs | CRUD + definitions |
| **BI** | reports, semantic-models, paginated-reports, dashboards | CRUD + definitions |
| **Real-Time Intelligence** | eventhouses, eventstreams, kql-databases, kql-querysets, kql-dashboards, reflex | CRUD + definitions |
| **Data Science** | ml-experiments, ml-models | CRUD |
| **Data Integration** | mirrored-databases, sql-databases, graphql-apis | CRUD + definitions |
| **Admin** | admin/workspaces, admin/items, admin/domains, admin/tenants, admin/users | Tenant management, access auditing |

## Architecture

```
src/
├── index.ts                  # Core client (auth, HTTP helpers, ApiResult<T>)
├── types.ts                  # Shared Fabric REST API types
└── connectors/
    ├── index.ts              # Barrel re-export of all connectors
    ├── workspaces.ts         # One file per API group
    ├── items.ts
    ├── ...28 more...
    └── admin/
        ├── index.ts          # Namespaced admin re-exports
        ├── workspaces.ts
        ├── items.ts
        ├── domains.ts
        ├── tenants.ts
        └── users.ts
```

Two entry points:
- `@lushly-dev/fabric-api-client` — Core client + all shared types
- `@lushly-dev/fabric-api-client/connectors` — All typed connector functions

## License

MIT