@revenexx/cli 0.0.9 → 0.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.
Files changed (56) hide show
  1. package/README.md +181 -2
  2. package/dist/bundle-win-arm64.mjs +2874 -627
  3. package/dist/cli.cjs +2890 -643
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/index.cjs +44 -2
  6. package/dist/index.js +44 -2
  7. package/dist/lib/alias.d.ts +44 -0
  8. package/dist/lib/alias.d.ts.map +1 -0
  9. package/dist/lib/client.d.ts +13 -0
  10. package/dist/lib/client.d.ts.map +1 -1
  11. package/dist/lib/commands/generic.d.ts.map +1 -1
  12. package/dist/lib/commands/repl.d.ts +3 -0
  13. package/dist/lib/commands/repl.d.ts.map +1 -0
  14. package/dist/lib/commands/services/apps.d.ts.map +1 -1
  15. package/dist/lib/commands/services/avatars.d.ts.map +1 -1
  16. package/dist/lib/commands/services/carts.d.ts.map +1 -1
  17. package/dist/lib/commands/services/channels.d.ts.map +1 -1
  18. package/dist/lib/commands/services/customers.d.ts.map +1 -1
  19. package/dist/lib/commands/services/forms.d.ts.map +1 -1
  20. package/dist/lib/commands/services/greetings.d.ts.map +1 -1
  21. package/dist/lib/commands/services/inventories.d.ts.map +1 -1
  22. package/dist/lib/commands/services/markets.d.ts.map +1 -1
  23. package/dist/lib/commands/services/messaging.d.ts.map +1 -1
  24. package/dist/lib/commands/services/orderlists.d.ts.map +1 -1
  25. package/dist/lib/commands/services/orders.d.ts.map +1 -1
  26. package/dist/lib/commands/services/pages.d.ts.map +1 -1
  27. package/dist/lib/commands/services/payments.d.ts.map +1 -1
  28. package/dist/lib/commands/services/prices.d.ts.map +1 -1
  29. package/dist/lib/commands/services/products.d.ts.map +1 -1
  30. package/dist/lib/commands/services/search.d.ts.map +1 -1
  31. package/dist/lib/commands/services/shipping.d.ts.map +1 -1
  32. package/dist/lib/commands/services/sites.d.ts.map +1 -1
  33. package/dist/lib/commands/services/storage.d.ts.map +1 -1
  34. package/dist/lib/commands/services/tokens.d.ts.map +1 -1
  35. package/dist/lib/commands/skills.d.ts.map +1 -1
  36. package/dist/lib/commands/status.d.ts +3 -0
  37. package/dist/lib/commands/status.d.ts.map +1 -0
  38. package/dist/lib/config.d.ts +17 -0
  39. package/dist/lib/config.d.ts.map +1 -1
  40. package/dist/lib/constants.d.ts +3 -3
  41. package/dist/lib/constants.d.ts.map +1 -1
  42. package/dist/lib/interactive.d.ts +7 -3
  43. package/dist/lib/interactive.d.ts.map +1 -1
  44. package/dist/lib/parser.d.ts +51 -2
  45. package/dist/lib/parser.d.ts.map +1 -1
  46. package/dist/lib/types.d.ts +19 -0
  47. package/dist/lib/types.d.ts.map +1 -1
  48. package/dist/lib/utils.d.ts +10 -0
  49. package/dist/lib/utils.d.ts.map +1 -1
  50. package/dist/tests/alias.test.d.ts +2 -0
  51. package/dist/tests/alias.test.d.ts.map +1 -0
  52. package/dist/tests/banner.test.d.ts +2 -0
  53. package/dist/tests/banner.test.d.ts.map +1 -0
  54. package/dist/tests/output-format.test.d.ts +2 -0
  55. package/dist/tests/output-format.test.d.ts.map +1 -0
  56. package/package.json +1 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ Once the installation is complete, you can verify the install using
28
28
 
29
29
  ```sh
30
30
  $ revenexx -v
31
- 0.0.9
31
+ 0.1.1
32
32
  ```
33
33
 
34
34
  ### Install using prebuilt binaries
@@ -62,7 +62,7 @@ $ scoop install https://raw.githubusercontent.com/revenexx-sdks/cli/master/scoop
62
62
  Once the installation completes, you can verify your install using
63
63
  ```
64
64
  $ revenexx -v
65
- 0.0.9
65
+ 0.1.1
66
66
  ```
67
67
 
68
68
  ## Getting Started
@@ -114,6 +114,19 @@ $ revenexx products products-list
114
114
 
115
115
  Ready-to-copy examples for every command are generated under [`docs/examples/`](docs/examples).
116
116
 
117
+ ### 4. Go faster
118
+
119
+ A few power-user conveniences once you're set up:
120
+
121
+ ```sh
122
+ $ revenexx status # identity, tenant, endpoint, token expiry & gateway health
123
+ $ revenexx p ls # built-in aliases: same as `products list`
124
+ $ revenexx alias set deploy "apps create-deployment --activate true"
125
+ $ revenexx repl # interactive shell — many commands, one session
126
+ ```
127
+
128
+ A **production safety banner** is printed before most commands showing which tenant/endpoint you're hitting (prominent and red for production). Silence it with `-q`/`--quiet`. See [Command aliases](../README.md#command-aliases), [Production safety banner](../README.md#production-safety-banner), [`status`](../README.md#status) and [Interactive shell (`repl`)](../README.md#interactive-shell-repl) in the README.
129
+
117
130
  > ### Note
118
131
  > By default, requests to domains with self-signed SSL certificates (or no certificates) are rejected. If you trust the host, you can bypass certificate validation using
119
132
  > ```sh
@@ -228,6 +241,91 @@ Use the `--image` flag on the script to pin a specific Node base (e.g. `--image
228
241
  | `revenexx tenants current` | ✅ Prints the active slug. Pass `--check` to verify it against the gateway. |
229
242
  | `revenexx tenants list` | ✅ Lists every tenant known to this machine (flag, env, `.revenexx.yaml`, `~/.revenexx/tenant`, login sessions) with its sources and whether the current API key can access it. The gateway doesn't expose a `/v1/tenants` endpoint (and by design never discloses whether a tenant exists), so this is a client-side aggregate verified per-slug. |
230
243
 
244
+ ## Command aliases
245
+
246
+ Type less. The CLI resolves both **built-in** abbreviations and your own **user-defined** aliases before running a command — git-style — so `revenexx p ls` reaches `revenexx products list`. A real command always wins over an alias of the same name, and a built-in alias is a no-op when its target service isn't part of this SDK.
247
+
248
+ ### Built-in abbreviations
249
+
250
+ | Kind | Examples |
251
+ |---|---|
252
+ | Services (first token) | `p`/`prod` → `products`, `o`/`ord` → `orders`, `cust` → `customers`, `cat` → `categories`, `inv` → `inventories`, `pay` → `payments`, `ship` → `shipping`, `msg` → `messaging` |
253
+ | Verbs (second token) | `ls`/`l` → `list`, `g` → `get`, `mk`/`new`/`add` → `create`, `up`/`upd`/`edit` → `update`, `rm`/`del`/`d` → `delete` |
254
+
255
+ Run `revenexx alias list` to see the full built-in table.
256
+
257
+ ### User-defined aliases
258
+
259
+ Persisted in `~/.revenexx/prefs.json` and shared across all sessions on the machine.
260
+
261
+ ```sh
262
+ # Create / update an alias (quote multi-word expansions):
263
+ $ revenexx alias set deploy "apps create-deployment --activate true"
264
+ $ revenexx deploy # runs the expansion above
265
+
266
+ # List and remove:
267
+ $ revenexx alias list
268
+ $ revenexx alias remove deploy
269
+ ```
270
+
271
+ ## Production safety banner
272
+
273
+ Before most commands, the CLI prints a one-line banner to **stderr** showing which tenant and endpoint you're about to hit. When the context is **production** the banner turns into a prominent red `PRODUCTION` badge — the single best guard against "I ran that against prod". It is suppressed automatically for context-free commands such as `status`, `alias`, and `repl`.
274
+
275
+ ```
276
+ PRODUCTION acme → api.revenexx.com # prod / sensitive
277
+ ● staging → staging.revenexx.internal # everything else (dim)
278
+ ```
279
+
280
+ A context is treated as production when any of these hold:
281
+
282
+ - the endpoint is the built-in default (the live production gateway),
283
+ - the endpoint or tenant slug contains `prod`, or
284
+ - the tenant is in your configured **sensitive** list.
285
+
286
+ Configure the sensitive list (comma-separated, empty string clears it) or point at it from the environment:
287
+
288
+ ```sh
289
+ $ revenexx client --sensitive-tenants "acme,globex"
290
+ $ REVENEXX_SENSITIVE_TENANTS="acme,globex" revenexx products list
291
+ ```
292
+
293
+ Because it's on stderr the banner never contaminates `--json` output, and it's suppressed automatically for `--json`, non-interactive (piped) runs, and when you pass `-q` / `--quiet`.
294
+
295
+ ## `status`
296
+
297
+ A one-glance health/identity panel — richer than `whoami`. Shows the signed-in user, active tenant and endpoint, auth method, the SSO **token expiry countdown**, and a live **gateway health** probe (with a short timeout so it never hangs offline).
298
+
299
+ ```sh
300
+ $ revenexx status
301
+ User : you@example.com
302
+ Auth method : SSO (Zitadel)
303
+ Tenant : acme
304
+ Endpoint : https://api.revenexx.com
305
+ Token expires : in 2h 41m
306
+ Gateway : ok (v1.4.0)
307
+ ```
308
+
309
+ Add `--json` for a machine-readable object.
310
+
311
+ ## Interactive shell (`repl`)
312
+
313
+ `revenexx repl` opens an authenticated interactive shell so you can run several commands without re-typing `revenexx` or re-resolving auth each time. It reuses the same command tree as the CLI, so everything — including built-in and user-defined aliases — works identically.
314
+
315
+ ```sh
316
+ $ revenexx repl
317
+ ℹ Interactive shell — type a command, help, or exit. Tab completes command names.
318
+ revenexx> products list
319
+ revenexx> p get --product-id abc123
320
+ revenexx> help
321
+ revenexx> exit
322
+ ```
323
+
324
+ - **Tab** completes top-level command names, then a service's subcommands.
325
+ - `help` (or `?`) prints the command list; `exit` (or `quit`, `q`, Ctrl-D) leaves the shell.
326
+ - Missing required options **prompt interactively** just like they do outside the shell (search/select), so `p get` will ask for the product id. Ctrl-C cancels the current line without leaving the shell.
327
+ - The [production safety banner](#production-safety-banner) is shown before **every** command in the session (prominent and red for production) — the safeguard matters most in a rapid-fire shell. Launch with `revenexx --quiet repl` to silence it for the session.
328
+
231
329
  ## Global Configuration
232
330
 
233
331
  The CLI stores its state in `~/.revenexx/prefs.json`. It holds one entry per signed-in **session**, keyed by a generated session ID, plus a top-level `current` that points at the active one. You don't normally edit this by hand — it's written by `login`, `logout`, `tenants use`, and `client`.
@@ -266,6 +364,87 @@ $ revenexx client --key YOUR_API_KEY
266
364
  $ revenexx client --self-signed true
267
365
  ```
268
366
 
367
+ ## Scripting & automation
368
+
369
+ The CLI is built to drop into shell scripts and CI pipelines.
370
+
371
+ ### Output formats
372
+
373
+ Pick a renderer with `-o, --output <format>`:
374
+
375
+ | Format | Use |
376
+ |--------|-----|
377
+ | `table` (default) | Human-readable, aligned columns; adapts to the terminal width. |
378
+ | `json` | Byte-stable, uncolored JSON for piping to `jq` etc. `--json` (`-j`) is a shorthand. |
379
+ | `jsonl` (`ndjson`) | NDJSON / JSON Lines — one compact record per line, ideal for streaming large lists into `jq -c`, `xargs`, or log pipelines. `--jsonl` is a shorthand. |
380
+ | `csv` | RFC 4180 rows — a header line plus one line per record. `--csv` is a shorthand. |
381
+ | `yaml` | Losslessly structured YAML. `--yaml` is a shorthand. |
382
+ | `markdown` (`md`) | GitHub-flavored Markdown table — handy for docs, PR comments, and issues. `--markdown` / `--md` are shorthands. |
383
+
384
+ Narrow the columns/fields with `--fields`. On a list response it projects the columns of the returned collection; on a single record it keeps just those keys:
385
+
386
+ ```sh
387
+ $ revenexx <service> list -o csv --fields id,name,createdAt
388
+ $ revenexx <service> get <id> -o json --fields id,status | jq .status
389
+ ```
390
+
391
+ > On a terminal, all formats prompt for any missing required option; when the output is piped (non-TTY) the command fails fast instead of hanging — so automation never blocks on a prompt.
392
+
393
+ ### Machine-readable errors & exit codes
394
+
395
+ Under `--json`/`-o json` or `--quiet`, failures are written to **stderr** as `{ "error": { "message", "code", "type", "requestId" } }` and the process exits with a meaningful code so scripts can branch on *why* a command failed:
396
+
397
+ | Exit code | Meaning |
398
+ |-----------|---------|
399
+ | `0` | Success |
400
+ | `2` | Usage error (bad flags/arguments) |
401
+ | `4` | Authentication/authorization failure (401/403) |
402
+ | `5` | Not found (404) |
403
+ | `8` | Rate limited (429) |
404
+ | `1` | Generic failure (network, timeout, 5xx, …) |
405
+
406
+ `--quiet` opts into structured errors and exit codes without committing to a specific stdout format — useful when you only care about success/failure, or want to pair it with a non-JSON renderer.
407
+
408
+ ```sh
409
+ if ! revenexx --quiet <service> get "$id" > /dev/null; then
410
+ case $? in
411
+ 4) echo "not authenticated" ;;
412
+ 5) echo "no such resource" ;;
413
+ 8) echo "rate limited — back off and retry" ;;
414
+ *) echo "request failed" ;;
415
+ esac
416
+ fi
417
+ ```
418
+
419
+ ### Request bodies from a file or stdin
420
+
421
+ Create/update commands accept a JSON body inline, from a file (`@path`), or from stdin (`-`) via `--data`, so you can round-trip resources:
422
+
423
+ ```sh
424
+ $ revenexx <service> get <id> -o json > body.json
425
+ # edit body.json ...
426
+ $ revenexx <service> update <id> --data @body.json
427
+
428
+ # or straight through a pipe
429
+ $ cat body.json | revenexx <service> create --data -
430
+ ```
431
+
432
+ Explicit flags (e.g. `--name`) override matching keys from `--data`.
433
+
434
+ ### Putting it together
435
+
436
+ ```sh
437
+ # Stream a large list one record per line straight into jq
438
+ $ revenexx <service> list --jsonl | jq -r 'select(.status == "active") | .id'
439
+
440
+ # Edit-in-place round-trip
441
+ $ revenexx <service> get "$id" -o json > item.json
442
+ $ jq '.name = "Renamed"' item.json | revenexx <service> update "$id" --data -
443
+
444
+ # Drop a Markdown table into a PR comment or report
445
+ $ revenexx <service> list --md --fields id,name,status >> report.md
446
+ ```
447
+
269
448
  ## Sample
270
449
 
271
450
  See a runnable example for this SDK in the [samples repo](https://github.com/revenexx-sdks/samples/tree/main/cli).