# @nech/api

Generated TypeScript clients for the [Nech.PL APIs](https://api.nech.pl). One
package, **per-domain subpath imports** — you only bundle what you import.

```bash
# one-time: point the @nech scope at the private registry
echo '@nech:registry=https://npm.nech.pl' >> .npmrc
npm i @nech/api
```

## Usage

```ts
import { AudioApi, Configuration } from '@nech/api/audio'

const audio = new AudioApi(new Configuration({
  basePath: 'https://api.nech.pl/audio/v1',
  accessToken: process.env.NECH_TOKEN,   // your platform token (npl_live_…)
}))

// every analysis is a multipart POST of one audio clip → JSON
const emotion = await audio.analyzeEmotion({ file: clip })   // clip: Blob | File
const grade   = await audio.grade({ file: clip })
```

Method names come straight from the API's `operationId`s, so the call site
tracks the spec. `clip` is a `Blob`/`File` (browser) or a `Blob` from
`fs.openAsBlob()` (Node ≥20).

Future domains land as sibling subpaths: `@nech/api/geo`, `@nech/api/iris`.

## This package is generated — don't hand-edit `src/`

Everything under `src/<domain>/` is emitted by
[openapi-generator](https://openapi-generator.tech) (`typescript-fetch`) from the
checked-in OpenAPI snapshot, then bundled with tsup.

```bash
# 1. refresh the snapshot from the live app (run from ../, in the venv)
~/.virtualenvs/fourier/bin/python ../refresh_openapi.py
# 2. regenerate + bundle every domain
./codegen.sh
```

`dist/` is built on publish (`prepublishOnly`); it's gitignored.

## Publishing (private registry)

Published to **Verdaccio at `https://npm.nech.pl`** (see
`../../VERDACCIO.md` for the erable deploy).

```bash
npm login --registry https://npm.nech.pl     # one-time
npm publish                                   # runs the build first
```
