docs: add TypeScript SDK reference section#284
Conversation
Adds four pages under typescript-sdk/ covering overview, retries and timeouts, pagination, and error handling. Registers the SDK under a new "SDKs" menu item in the Reference tab, positioned after CLI and API reference.
|
Claude finished @dangrondahl's task in 1m 52s —— View job Review complete
SummarySolid set of reference pages — well structured, clear code examples, correct use of Mintlify components, and proper early-access warning. No critical issues found. Checklist results:
Findings
Improvements:
Suggestions: All findings posted as inline comments on the relevant lines. |
|
|
||
| const trails = Array.isArray(result) ? result : result.data ?? []; |
There was a problem hiding this comment.
Improvement: result.data appears here as a fallback but isn't explained anywhere on the page. If the SDK response actually has a .data property, it would be worth documenting the response shape (e.g. { data: Trail[], pagination?: {...} }) so readers know what to expect. If it doesn't, this fallback may confuse more than it helps.
| - **Bun**: v1 and above | ||
| - **Deno**: v1.39+ | ||
|
|
||
| For TypeScript projects, add `"lib": ["es2020", "dom", "dom.iterable"]` to your `tsconfig.json` to get full type support for async iterables, streams, and fetch-related APIs. |
There was a problem hiding this comment.
Suggestion: This reads as though users should set lib to exactly these three entries. Consider phrasing as "ensure your lib array includes at least…" so users with existing entries (e.g. "es2021", "webworker") don't accidentally drop them.
| For TypeScript projects, add `"lib": ["es2020", "dom", "dom.iterable"]` to your `tsconfig.json` to get full type support for async iterables, streams, and fetch-related APIs. | |
| For TypeScript projects, ensure your `tsconfig.json` `lib` array includes at least `"es2020"`, `"dom"`, and `"dom.iterable"` for full type support for async iterables, streams, and fetch-related APIs. |
| A small number of operations can throw additional error types for specific conditions: | ||
|
|
||
| | Class | Status | Description | | ||
| |-------|--------|-------------| | ||
| | `ConflictResponseModelError` | `409` | Conflict (e.g. resource already exists) | | ||
| | `RequestEntityTooLargeResponseModelError` | `413` | Request body too large | | ||
| | `ResponseValidationError` | - | Response from server did not match the expected schema; inspect `error.rawValue` or call `error.pretty()` | | ||
|
|
||
| Check the method's documentation to see which errors apply to a specific operation. |
There was a problem hiding this comment.
Improvement: These additional error types aren't shown in the import * as errors from "@kosli/sdk/models/errors" examples above. A brief note confirming they come from the same import path would save readers from guessing.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
| while (true) { | ||
| const result = await kosli.trails.list({}, { org, flowName, page, perPage }); | ||
|
|
||
| const trails = Array.isArray(result) ? result : result.data ?? []; |
There was a problem hiding this comment.
Improvement: The result.data ?? [] fallback introduces a property (data) that isn't mentioned elsewhere on this page. This makes the example harder to follow — readers won't know when the response is an array vs. an object with .data.
Consider either:
- Documenting the response shape where
.dataapplies, or - Simplifying to only the
pagination-based pattern, since that's the documented API:
| const trails = Array.isArray(result) ? result : result.data ?? []; | |
| const trails = result.trails ?? []; |
(Replace .trails with whatever the actual array property is, or just use result directly if the list endpoint returns an array.)
| - **Bun**: v1 and above | ||
| - **Deno**: v1.39+ | ||
|
|
||
| For TypeScript projects, add `"lib": ["es2020", "dom", "dom.iterable"]` to your `tsconfig.json` to get full type support for async iterables, streams, and fetch-related APIs. |
There was a problem hiding this comment.
Suggestion: The current phrasing ("add "lib": [...]") reads as "replace your lib with exactly these three entries," which could cause users to accidentally drop existing entries like "es2021" or "webworker".
| For TypeScript projects, add `"lib": ["es2020", "dom", "dom.iterable"]` to your `tsconfig.json` to get full type support for async iterables, streams, and fetch-related APIs. | |
| For TypeScript projects, ensure your `tsconfig.json` `lib` array includes at least `"es2020"`, `"dom"`, and `"dom.iterable"` for full type support for async iterables, streams, and fetch-related APIs. |
| A small number of operations can throw additional error types for specific conditions: | ||
|
|
||
| | Class | Status | Description | | ||
| |-------|--------|-------------| | ||
| | `ConflictResponseModelError` | `409` | Conflict (e.g. resource already exists) | | ||
| | `RequestEntityTooLargeResponseModelError` | `413` | Request body too large | | ||
| | `ResponseValidationError` | - | Response from server did not match the expected schema; inspect `error.rawValue` or call `error.pretty()` | | ||
|
|
||
| Check the method's documentation to see which errors apply to a specific operation. |
There was a problem hiding this comment.
Improvement: The "Other errors" table introduces three additional error classes (ConflictResponseModelError, RequestEntityTooLargeResponseModelError, ResponseValidationError) that aren't shown in either code example. It would help to confirm they come from the same @kosli/sdk/models/errors import, e.g.:
These classes are imported from the same path as the errors above:
import * as errors from "@kosli/sdk/models/errors";
| "groups": [ | ||
| { | ||
| "group": "TypeScript", | ||
| "icon": "js", |
There was a problem hiding this comment.
Suggestion: The "js" icon is a reasonable choice, but Font Awesome also has a "node-js" and a more specific TypeScript-related icon ("code"). Since this is a TypeScript SDK specifically, consider whether "js" best represents it — or if the broader "code" icon would be less misleading for TS-first users. Minor point, current choice works fine.
Summary
typescript-sdk/:AbortSignalpage/perPageparams, body pagination object, Link header pattern, page-iteration exampleKosliErrorbase class, named error subclasses (BadRequestError,UnauthorizedError,NotFoundError,RateLimitedError), network errorsNotes
Test plan
/user/personal_api_keysand/administration/authentication/service_accountsresolve