nuki-api-js 1.0.0 → 1.1.1

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,68 @@
1
+ # nuki-api-js
2
+
3
+ Auto-generated, fully typed client for the [Nuki Web API](https://api.nuki.io/).
4
+
5
+ ## Features
6
+
7
+ - **Fully typed** - every operation, parameter and response is generated from the official OpenAPI spec
8
+ - **Tree-shakable** - only the operations you import end up in your bundle
9
+ - **Runtime agnostic** - uses the global `fetch`, or bring your own implementation
10
+ - **Effect support** - optional [Effect](https://effect.website) bindings via `nuki-api-js/effect`
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install nuki-api-js
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```ts
21
+ import { NukiApi } from "nuki-api-js";
22
+
23
+ const client = new NukiApi({ token: process.env.NUKI_TOKEN ?? null });
24
+
25
+ const accounts = await client.api.account.getAccountsResource({});
26
+ ```
27
+
28
+ Operations are grouped by tag: `client.api.<tag>.<operation>(params)`.
29
+
30
+ ### Custom fetch
31
+
32
+ ```ts
33
+ const client = new NukiApi({
34
+ token: process.env.NUKI_TOKEN ?? null,
35
+ fetch: myFetchImplementation,
36
+ });
37
+ ```
38
+
39
+ ## Effect
40
+
41
+ The `effect` entrypoint exposes every operation as an `Effect`. It requires `effect` as a peer dependency.
42
+
43
+ ```ts
44
+ import { Effect } from "effect";
45
+ import { ApiService, makeApiLayer } from "nuki-api-js/effect";
46
+
47
+ const program = ApiService.account.getAccountsResource({});
48
+
49
+ await Effect.runPromise(
50
+ program.pipe(Effect.provide(makeApiLayer({ token: process.env.NUKI_TOKEN })))
51
+ );
52
+ ```
53
+
54
+ Errors are typed as `ApiError`, `NetworkError` and `ValidationError`.
55
+
56
+ ## Entrypoints
57
+
58
+ | Import | Contents |
59
+ | --- | --- |
60
+ | `nuki-api-js` | client class, operations, schemas and types |
61
+ | `nuki-api-js/components` | operations grouped by tag and by path |
62
+ | `nuki-api-js/schemas` | Zod schemas for every operation |
63
+ | `nuki-api-js/types` | TypeScript types for every operation |
64
+ | `nuki-api-js/effect` | Effect bindings |
65
+
66
+ ## License
67
+
68
+ ISC