@bunny.net/api-client-zod-database 0.0.0-stage → 1.0.202611301153
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/dist/mod.d.ts +24 -0
- package/dist/mod.js +24 -0
- package/dist/mod.js.map +1 -0
- package/dist/src/generated/client.d.ts +2182 -0
- package/dist/src/generated/client.js +516 -0
- package/dist/src/generated/client.js.map +1 -0
- package/dist/src/generated/schemas.d.ts +312 -0
- package/dist/src/generated/schemas.js +169 -0
- package/dist/src/generated/schemas.js.map +1 -0
- package/package.json +41 -3
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bunny.net
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://bunny.net">
|
|
3
|
+
<img src="https://github.com/BunnyWay/bunnynet-typescript/blob/main/asset/bunny.png?raw=true" width="500" height="auto" alt="Bunny"/>
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
# Bunny Database API client with Zod
|
|
8
|
+
|
|
9
|
+
This package contains `@bunny.net/api-client-zod-database`, the Bunny Database
|
|
10
|
+
API with [Zod](https://zod.dev) schemas and plain `async` methods over `fetch`:
|
|
11
|
+
databases, their usage and statistics, their access tokens, the regions and
|
|
12
|
+
limits, and live metrics. It is generated from the official OpenAPI spec, so
|
|
13
|
+
there is one method per endpoint, a schema per model and a typed error per
|
|
14
|
+
documented status.
|
|
15
|
+
|
|
16
|
+
## 🥕 Usage
|
|
17
|
+
|
|
18
|
+
Install it together with `zod`:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install @bunny.net/api-client-zod-database zod
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Listing your databases
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createBunnyDatabase } from "@bunny.net/api-client-zod-database";
|
|
28
|
+
import { BunnyResponseError } from "@bunny.net/api-client-zod-runtime";
|
|
29
|
+
|
|
30
|
+
const database = createBunnyDatabase({
|
|
31
|
+
accessKey: process.env.BUNNYNET_API_KEY!,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const databases = await database.listDatabasesV3({ query: { page: 1 } });
|
|
36
|
+
for (const db of databases.value.Items) {
|
|
37
|
+
console.log(db.Id, db.Name);
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof BunnyResponseError) console.log(error.response.status);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The client talks to `https://api.bunny.net/database`; pass `baseUrl` to target
|
|
45
|
+
another host and `fetch` to supply your own, for retries, timeouts or tests.
|
|
46
|
+
Every method resolves with `{ status, value }` typed by the documented success
|
|
47
|
+
statuses. A documented error status rejects with `BunnyResponseError`, carrying
|
|
48
|
+
the status and the decoded body, and anything else with another
|
|
49
|
+
`BunnyClientError`.
|
|
50
|
+
|
|
51
|
+
The credential is an API key or a JWT:
|
|
52
|
+
`createBunnyDatabase({ bearerToken: jwt })` sends the token bare, as
|
|
53
|
+
`Authorization: <jwt>`, instead of the key. Passing both is a type error. The
|
|
54
|
+
key may be a scoped one. A scoped key works on the operations for which Bunny's
|
|
55
|
+
API reference names a permission, and needs that permission: one of
|
|
56
|
+
`Database.Create`, `Database.Delete`, `Database.Read`, `Database.Statistics` and
|
|
57
|
+
`Database.Update`. The other operations take the account key or a JWT only. The
|
|
58
|
+
generated code does not say which operation needs which; the API reference does.
|
|
59
|
+
|
|
60
|
+
The package exports the client, `securitySchemes`, the component schemas and the
|
|
61
|
+
per-operation `*Input` types. The spec names several response schemas like
|
|
62
|
+
per-operation aliases, so the response aliases are not re-exported. The same API
|
|
63
|
+
for Effect is `@bunny.net/api-client-effect-database`. On Deno, import
|
|
64
|
+
`npm:@bunny.net/api-client-zod-database`; the package also runs in browsers.
|
|
65
|
+
|
|
66
|
+
Versions are `<spec major>.<minor>.<fetch time>`: a breaking change in Bunny's
|
|
67
|
+
spec raises the minor, so the caret range `npm install` writes follows breaking
|
|
68
|
+
upstream changes; depend with `~` to review them first.
|
|
69
|
+
|
|
70
|
+
## 🔧 Contributing
|
|
71
|
+
|
|
72
|
+
This package is generated from the official OpenAPI spec and versioned from it.
|
|
73
|
+
How to regenerate it, how versions are derived and how to run the checks is
|
|
74
|
+
described in
|
|
75
|
+
[docs/human_development.md](https://github.com/BunnyWay/bunnynet-typescript/blob/main/docs/human_development.md).
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated barrel for the Bunny Database API: `/v3/databases` (create, read,
|
|
3
|
+
* update and delete a database, its usage and statistics, its access
|
|
4
|
+
* tokens), `/v3/config` (regions and limits) and `/v3/live` (live metrics).
|
|
5
|
+
* The default server is the host the spec documents,
|
|
6
|
+
* `https://api.bunny.net/database`.
|
|
7
|
+
*
|
|
8
|
+
* `./src/generated/{schemas,client}.ts` are produced by
|
|
9
|
+
* `pnpm codegen:database-zod`. Do not hand-edit them: a re-run overwrites
|
|
10
|
+
* both.
|
|
11
|
+
*
|
|
12
|
+
* This barrel does not `export *` from both generated files. The spec names
|
|
13
|
+
* three response component schemas (`CreateDatabaseV3Response`,
|
|
14
|
+
* `ListConfigV3Response`, `UpdateDatabaseV3Response`) exactly as the client
|
|
15
|
+
* names the response type of the operations that return them, so a double
|
|
16
|
+
* `export *` is ambiguous. The component schemas are the shapes a caller
|
|
17
|
+
* wants: `schemas.ts` is exported whole, and from `client.ts` only the client,
|
|
18
|
+
* its factory and `securitySchemes` and the per-operation `*Input` types, none
|
|
19
|
+
* of which collide. The list below is written by hand; a new operation's input
|
|
20
|
+
* type is added to it.
|
|
21
|
+
*/
|
|
22
|
+
export * from "./src/generated/schemas.js";
|
|
23
|
+
export { type BunnyDatabase, createBunnyDatabase, securitySchemes, } from "./src/generated/client.js";
|
|
24
|
+
export type { CreateDatabaseV3Input, DeleteDatabaseV3Input, GenerateDatabaseTokenV3Input, GetDatabaseStatisticsV3Input, GetDatabaseUsageV3Input, GetDatabaseV3Input, GetLiveDatabasesMetricsV3Input, GetOptimalConfigV3Input, GetOptimalSingleRegionConfigV3Input, ListDatabasesV3Input, RevokeDatabaseTokensV3Input, UpdateDatabaseV3Input, } from "./src/generated/client.js";
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated barrel for the Bunny Database API: `/v3/databases` (create, read,
|
|
3
|
+
* update and delete a database, its usage and statistics, its access
|
|
4
|
+
* tokens), `/v3/config` (regions and limits) and `/v3/live` (live metrics).
|
|
5
|
+
* The default server is the host the spec documents,
|
|
6
|
+
* `https://api.bunny.net/database`.
|
|
7
|
+
*
|
|
8
|
+
* `./src/generated/{schemas,client}.ts` are produced by
|
|
9
|
+
* `pnpm codegen:database-zod`. Do not hand-edit them: a re-run overwrites
|
|
10
|
+
* both.
|
|
11
|
+
*
|
|
12
|
+
* This barrel does not `export *` from both generated files. The spec names
|
|
13
|
+
* three response component schemas (`CreateDatabaseV3Response`,
|
|
14
|
+
* `ListConfigV3Response`, `UpdateDatabaseV3Response`) exactly as the client
|
|
15
|
+
* names the response type of the operations that return them, so a double
|
|
16
|
+
* `export *` is ambiguous. The component schemas are the shapes a caller
|
|
17
|
+
* wants: `schemas.ts` is exported whole, and from `client.ts` only the client,
|
|
18
|
+
* its factory and `securitySchemes` and the per-operation `*Input` types, none
|
|
19
|
+
* of which collide. The list below is written by hand; a new operation's input
|
|
20
|
+
* type is added to it.
|
|
21
|
+
*/
|
|
22
|
+
export * from "./src/generated/schemas.js";
|
|
23
|
+
export { createBunnyDatabase, securitySchemes, } from "./src/generated/client.js";
|
|
24
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAEL,mBAAmB,EACnB,eAAe,GAChB,MAAM,2BAA2B,CAAC","sourcesContent":["/**\n * Curated barrel for the Bunny Database API: `/v3/databases` (create, read,\n * update and delete a database, its usage and statistics, its access\n * tokens), `/v3/config` (regions and limits) and `/v3/live` (live metrics).\n * The default server is the host the spec documents,\n * `https://api.bunny.net/database`.\n *\n * `./src/generated/{schemas,client}.ts` are produced by\n * `pnpm codegen:database-zod`. Do not hand-edit them: a re-run overwrites\n * both.\n *\n * This barrel does not `export *` from both generated files. The spec names\n * three response component schemas (`CreateDatabaseV3Response`,\n * `ListConfigV3Response`, `UpdateDatabaseV3Response`) exactly as the client\n * names the response type of the operations that return them, so a double\n * `export *` is ambiguous. The component schemas are the shapes a caller\n * wants: `schemas.ts` is exported whole, and from `client.ts` only the client,\n * its factory and `securitySchemes` and the per-operation `*Input` types, none\n * of which collide. The list below is written by hand; a new operation's input\n * type is added to it.\n */\nexport * from \"./src/generated/schemas.ts\";\nexport {\n type BunnyDatabase,\n createBunnyDatabase,\n securitySchemes,\n} from \"./src/generated/client.ts\";\nexport type {\n CreateDatabaseV3Input,\n DeleteDatabaseV3Input,\n GenerateDatabaseTokenV3Input,\n GetDatabaseStatisticsV3Input,\n GetDatabaseUsageV3Input,\n GetDatabaseV3Input,\n GetLiveDatabasesMetricsV3Input,\n GetOptimalConfigV3Input,\n GetOptimalSingleRegionConfigV3Input,\n ListDatabasesV3Input,\n RevokeDatabaseTokensV3Input,\n UpdateDatabaseV3Input,\n} from \"./src/generated/client.ts\";\n"]}
|