@silverfish-app/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @silverfish-app/sdk
2
+
3
+ Official TypeScript client for the [Silverfish](../../README.md) API, **generated
4
+ from its OpenAPI contract** — it is a typed HTTP client and nothing more (no
5
+ domain logic lives here; that runs once, in the Python core, behind the API).
6
+
7
+ The contract (`openapi.json`) is the source of truth: it is committed and the
8
+ client is regenerated from it, so the SDK always matches the API.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @silverfish-app/sdk
14
+ # or: pnpm add @silverfish-app/sdk
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Create a client pointed at your Silverfish API, then call the typed methods:
20
+
21
+ ```ts
22
+ import { Sdk } from '@silverfish-app/sdk';
23
+ import { createClient, createConfig } from '@silverfish-app/sdk/client';
24
+
25
+ const sdk = new Sdk({
26
+ client: createClient(createConfig({ baseUrl: 'http://localhost:8000' })),
27
+ });
28
+
29
+ // List books (typed response).
30
+ const { data } = await sdk.listBooks({ query: { page: 1, page_size: 50 } });
31
+ for (const book of data!.items) {
32
+ console.log(book.id, book.title);
33
+ }
34
+
35
+ // Get one book by its public id.
36
+ const { data: book } = await sdk.getBook({ path: { book_id: '8X2k' } });
37
+
38
+ // Start an export (async job) — the download link is emailed when ready.
39
+ const { data: job } = await sdk.startExport({ body: { to_email: 'me@example.com' } });
40
+ console.log(job!.status); // 'queued' | 'running' | 'done' | 'error'
41
+ ```
42
+
43
+ Errors, request bodies and responses are fully typed per operation. By default
44
+ methods return `{ data, error }`; pass `throwOnError: true` to get the data
45
+ directly and have failures throw instead.
46
+
47
+ ## Regenerating
48
+
49
+ The client is generated from the committed contract — the generated `src/` and
50
+ compiled `dist/` are build artifacts and are not committed.
51
+
52
+ ```bash
53
+ pnpm install
54
+ pnpm run generate # regenerate src/ from openapi.json
55
+ pnpm run build # compile to dist/
56
+ ```
57
+
58
+ `openapi.json` itself is produced from the API by
59
+ `scripts/export_openapi.py` (run at release from a clean tag build, so it carries
60
+ the real release version). Other languages can be generated from the same file
61
+ with [openapi-generator](https://openapi-generator.tech/).