# The TypeScript package

An ESM package with strict types and no runtime dependencies. It uses the standard `fetch`, so it runs on Node.js 20+, Deno, Bun, Cloudflare Workers and in browsers, and it never calls Latitude 10.

## Its files

| File | What it holds |
| --- | --- |
| `package.json` | The name and version, `"type": "module"` and `"engines": { "node": ">=20" }`. |
| `src/client.ts` | The client class, named by `clientName`. |
| `src/resources/` | The operations, grouped by tag, a method each. |
| `src/models.ts` | The types from your document's schemas. |
| `src/core.ts` | The runtime, the same file in every SDK we generate. It holds no text from your document. |
| `src/index.ts` | What the package exports. |
| `README.md` | Install, use, each resource's methods, errors and retries. |
| `GENERATION.md` | How it was generated, and anything skipped. |
| `CHANGELOG.md` | What changed in each version. |
| `LICENSE` | MIT, in the holder's name. |
| `tsconfig.json` | The build settings. |

## Auth

The client takes `apiKeys` by security scheme name, `bearerToken` as a string or a function it asks before every request, so you can refresh it, or `username` and `password` for basic auth. Each operation sends the first of its schemes the client has credentials for.

## Retries and timeouts

- Connection errors, timeouts, `408`, `429` and `5xx` are retried with backoff, and `Retry-After` is honoured.
- `POST` and `PATCH` are retried only with an idempotency key: `idempotencyKey` in a call's options, or one made for you when the operation declares an `Idempotency-Key` header.
- Set `maxRetries` and `timeoutMs` on the client or per call, and pass `signal` to cancel.

## Errors

A response outside `2xx` throws an `APIError` with `status`, `headers`, `body` and `requestId`, as one of `BadRequestError`, `AuthenticationError`, `PermissionDeniedError`, `NotFoundError`, `ConflictError`, `UnprocessableEntityError`, `RateLimitError` or `InternalServerError`. A network failure throws `APIConnectionError`, a timeout `APITimeoutError`. All of them extend the client's own error class.

Every method also has a `…WithResponse` sibling that returns `{ data, response }`, for the headers and the status.

## Pagination

An operation that pages, by cursor, offset or page number, returns a page you can await for the first page, or walk with `for await` for every item of every page. [OpenAPI extensions](openapi-extensions) says how a paging operation is found, and `GENERATION.md` says which methods page.

## Where this comes from

- `app/sdk/_lib/typescript/emit.ts`
- `app/sdk/_lib/typescript/runtime/core.ts`
- `app/sdk/_lib/model.ts`
- `tests/fixtures/sdk/petstore/expected/README.md`
