@bunny.net/api-client-effect-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 +78 -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 +528 -0
- package/dist/src/generated/client.js.map +1 -0
- package/dist/src/generated/schemas.d.ts +311 -0
- package/dist/src/generated/schemas.js +160 -0
- package/dist/src/generated/schemas.js.map +1 -0
- package/package.json +44 -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,79 @@
|
|
|
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 for Effect
|
|
8
|
+
|
|
9
|
+
This package contains `@bunny.net/api-client-effect-database`, the Bunny
|
|
10
|
+
Database API as an [Effect](https://effect.website) service: databases, their
|
|
11
|
+
usage and statistics, their access tokens, the regions and limits, and live
|
|
12
|
+
metrics. It is generated from the official OpenAPI spec, so there is one method
|
|
13
|
+
per endpoint, a schema per model and a typed error per documented status.
|
|
14
|
+
|
|
15
|
+
## 🥕 Usage
|
|
16
|
+
|
|
17
|
+
Install it together with `effect` and `@effect/platform`:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @bunny.net/api-client-effect-database effect @effect/platform
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Listing your databases
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Effect, Layer } from "effect";
|
|
27
|
+
import { FetchHttpClient } from "@effect/platform";
|
|
28
|
+
import { BunnyDatabase } from "@bunny.net/api-client-effect-database";
|
|
29
|
+
import { BunnyCredentials } from "@bunny.net/api-client-effect-runtime";
|
|
30
|
+
|
|
31
|
+
const program = Effect.gen(function* () {
|
|
32
|
+
const database = yield* BunnyDatabase;
|
|
33
|
+
const databases = yield* database.listDatabasesV3({ query: { page: 1 } });
|
|
34
|
+
for (const db of databases.value.Items) {
|
|
35
|
+
console.log(db.Id, db.Name);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const Live = BunnyDatabase.Default.pipe(
|
|
40
|
+
Layer.provide(BunnyCredentials.fromEnv()), // reads BUNNYNET_API_KEY
|
|
41
|
+
Layer.provide(FetchHttpClient.layer),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
await Effect.runPromise(program.pipe(Effect.provide(Live)));
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`BunnyDatabase.Default` talks to `https://api.bunny.net/database`;
|
|
48
|
+
`BunnyDatabase.layer({ baseUrl })` targets another host. Every method returns
|
|
49
|
+
`{ status, value }` typed by the documented success statuses. A documented error
|
|
50
|
+
status fails with `BunnyResponseError`, carrying the status and the decoded
|
|
51
|
+
body, and anything else with another `BunnyClientError`. Transport failures come
|
|
52
|
+
through as `@effect/platform`'s `HttpClientError`, so retries, timeouts and
|
|
53
|
+
tracing are whatever your `HttpClient` layer does.
|
|
54
|
+
|
|
55
|
+
The credential is an API key or a JWT: provide `BunnyCredentials.bearer(jwt)` in
|
|
56
|
+
place of `BunnyCredentials.fromEnv()` and the token is sent bare, as
|
|
57
|
+
`Authorization: <jwt>`, instead of the key. The key may be a scoped one. A
|
|
58
|
+
scoped key works on the operations for which Bunny's API reference names a
|
|
59
|
+
permission, and needs that permission: one of `Database.Create`,
|
|
60
|
+
`Database.Delete`, `Database.Read`, `Database.Statistics` and `Database.Update`.
|
|
61
|
+
The other operations take the account key or a JWT only. The generated code does
|
|
62
|
+
not say which operation needs which; the API reference does.
|
|
63
|
+
|
|
64
|
+
The package exports the service, `securitySchemes`, the component schemas and
|
|
65
|
+
the per-operation `*Input` types. The spec names several response schemas like
|
|
66
|
+
per-operation aliases, so the response aliases are not re-exported. The same API
|
|
67
|
+
with Zod schemas instead of Effect is `@bunny.net/api-client-zod-database`. On
|
|
68
|
+
Deno, import `npm:@bunny.net/api-client-effect-database`.
|
|
69
|
+
|
|
70
|
+
Versions are `<spec major>.<minor>.<fetch time>`: a breaking change in Bunny's
|
|
71
|
+
spec raises the minor, so the caret range `npm install` writes follows breaking
|
|
72
|
+
upstream changes; depend with `~` to review them first.
|
|
73
|
+
|
|
74
|
+
## 🔧 Contributing
|
|
75
|
+
|
|
76
|
+
This package is generated from the official OpenAPI spec and versioned from it.
|
|
77
|
+
How to regenerate it, how versions are derived and how to run the checks is
|
|
78
|
+
described in
|
|
79
|
+
[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`. 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 service,
|
|
18
|
+
* its type and `securitySchemes` and the per-operation `*Input` types, none of
|
|
19
|
+
* 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 { BunnyDatabase, type BunnyDatabaseService, 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`. 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 service,
|
|
18
|
+
* its type and `securitySchemes` and the per-operation `*Input` types, none of
|
|
19
|
+
* 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 { BunnyDatabase, 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,EACL,aAAa,EAEb,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`. 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 service,\n * its type and `securitySchemes` and the per-operation `*Input` types, none of\n * 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 BunnyDatabase,\n type BunnyDatabaseService,\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"]}
|