netlify-api 1.2.0 → 1.3.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,69 @@
1
+ # netlify-api
2
+
3
+ Auto-generated, fully typed client for the [Netlify API](https://docs.netlify.com/api/get-started/).
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 `netlify-api/effect`
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install netlify-api
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```ts
21
+ import { NetlifyApi } from "netlify-api";
22
+
23
+ const client = new NetlifyApi({ token: process.env.NETLIFY_TOKEN ?? "" });
24
+
25
+ const sites = await client.api.site.listSites({});
26
+ ```
27
+
28
+ Operations are grouped by tag: `client.api.<tag>.<operation>(params)`.
29
+
30
+ ### Options
31
+
32
+ ```ts
33
+ const client = new NetlifyApi({
34
+ token: process.env.NETLIFY_TOKEN ?? "",
35
+ basePath: "https://api.netlify.com/api/v1", // optional override
36
+ fetch: myFetchImplementation, // optional
37
+ });
38
+ ```
39
+
40
+ ## Effect
41
+
42
+ The `effect` entrypoint exposes every operation as an `Effect`. It requires `effect` as a peer dependency.
43
+
44
+ ```ts
45
+ import { Effect } from "effect";
46
+ import { ApiService, makeApiLayer } from "netlify-api/effect";
47
+
48
+ const program = ApiService.site.listSites({});
49
+
50
+ await Effect.runPromise(
51
+ program.pipe(Effect.provide(makeApiLayer({ token: process.env.NETLIFY_TOKEN })))
52
+ );
53
+ ```
54
+
55
+ Errors are typed as `ApiError`, `NetworkError` and `ValidationError`.
56
+
57
+ ## Entrypoints
58
+
59
+ | Import | Contents |
60
+ | --- | --- |
61
+ | `netlify-api` | client class, operations, schemas and types |
62
+ | `netlify-api/components` | operations grouped by tag and by path |
63
+ | `netlify-api/schemas` | Zod schemas for every operation |
64
+ | `netlify-api/types` | TypeScript types for every operation |
65
+ | `netlify-api/effect` | Effect bindings |
66
+
67
+ ## License
68
+
69
+ ISC