@beel_es/cli 0.1.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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/index.js +11388 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BeeL (beel.es)
|
|
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
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @beel_es/cli
|
|
2
|
+
|
|
3
|
+
Agent-first CLI for the [BeeL](https://beel.es) invoicing API. Every command is derived at startup from the embedded OpenAPI spec — when the API gains an endpoint, the next CLI release gains the command, with zero hand-written wrappers.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @beel_es/cli --help
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
No install, no brew. Node 20+.
|
|
10
|
+
|
|
11
|
+
## Auth
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Option A (recommended for agents/CI): env var
|
|
15
|
+
export BEEL_API_KEY=beel_sk_test_...
|
|
16
|
+
|
|
17
|
+
# Option B: store keys in ~/.config/beel/config.json (chmod 600)
|
|
18
|
+
npx @beel_es/cli login --api-key beel_sk_test_...
|
|
19
|
+
npx @beel_es/cli login --api-key beel_sk_live_... # both can coexist
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The key prefix decides the slot: `beel_sk_test_*` → sandbox, `beel_sk_live_*` → production.
|
|
23
|
+
|
|
24
|
+
**Sandbox is the default.** Every command uses the test key unless you pass `--live`. A live key in `BEEL_API_KEY` without `--live` is an error, not a silent upgrade — production access is always explicit.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx @beel_es/cli invoices list --status PAID --limit 5
|
|
30
|
+
npx @beel_es/cli invoices get <invoice_id>
|
|
31
|
+
npx @beel_es/cli invoices create --data @invoice.json
|
|
32
|
+
npx @beel_es/cli invoices issue <invoice_id> --wait-for-pdf
|
|
33
|
+
npx @beel_es/cli customers create --data '{"fiscal_name":"ACME SL", ...}'
|
|
34
|
+
npx @beel_es/cli nif validate --data '{"nif":"B12345678"}'
|
|
35
|
+
npx @beel_es/cli invoices export-excel --output invoices.xlsx
|
|
36
|
+
npx @beel_es/cli --live invoices list # production
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`--data` accepts inline JSON, `@file.json`, or `-` for stdin. Binary responses (PDF, ZIP, Excel) require `--output <path>`.
|
|
40
|
+
|
|
41
|
+
Discover everything with `--help` at any level: `beel --help`, `beel invoices --help`, `beel invoices list --help` (flags, enums and defaults come from the API spec).
|
|
42
|
+
|
|
43
|
+
### Generic escape hatch
|
|
44
|
+
|
|
45
|
+
Any endpoint, even ones this CLI version doesn't know yet:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx @beel_es/cli request GET /v1/invoices --query status=PAID --query limit=5
|
|
49
|
+
npx @beel_es/cli request POST /v1/customers --data @customer.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Output contract (for agents)
|
|
53
|
+
|
|
54
|
+
- **stdout**: response JSON, pretty-printed. Nothing else.
|
|
55
|
+
- **stderr**: errors as JSON: `{"error": {"code", "message", "status", "details", "request_id"}}`.
|
|
56
|
+
- **Exit codes**: `0` ok · `1` unexpected · `2` usage/config · `3` auth (401/403) · `4` not found · `5` validation (400/409/422) · `6` rate limit (429) · `7` server (5xx).
|
|
57
|
+
|
|
58
|
+
POST requests get an automatic `Idempotency-Key`. `BEEL_BASE_URL` overrides the API host; `BEEL_CONFIG_DIR` overrides the config location.
|
|
59
|
+
|
|
60
|
+
## How it stays in sync with the API
|
|
61
|
+
|
|
62
|
+
The OpenAPI spec ships inside the package and the command tree is interpreted from it at startup ([src/runtime.ts](src/runtime.ts)). When the backend publishes a spec change, a `repository_dispatch` syncs `openapi/public-api.yaml`, CI rebuilds, and a patch release is published. Updating the CLI = `npx` picking the new version.
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install
|
|
68
|
+
npm run dev -- invoices --help # run from source
|
|
69
|
+
npm test # vitest
|
|
70
|
+
npm run build # single-file bundle in dist/ (zero runtime deps)
|
|
71
|
+
```
|