@stewardhq/cli 0.7.0 → 0.9.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.
Files changed (3) hide show
  1. package/README.md +47 -12
  2. package/dist/bin.js +499 -188
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -14,7 +14,9 @@ ESM, Node ≥ 22. Its only runtime dependency is `@stewardhq/sdk`.
14
14
  | Command | What it does |
15
15
  | --- | --- |
16
16
  | `steward doctor [--json]` | `GET /v1/doctor`; `APP_URL` ↔ steward `appUrl` / return origins. Exits 1 when not ready. For a product with meters, a `metering` line (the catalog's meters and metered prices, and steward's `events`, `meters`, `overage` capabilities) plus the report's `events` section (backlog, rollup lag, unmatched event names in the last 7 days' sample, invalid values, meters receiving no events) and `overage` section (`chargeMode`, metered price, subscriptions with no locked rate, rolled-over records) |
17
- | `steward catalog push <file> [--yes]` | `PUT /v1/admin/catalog`; version and counts. Before the push: benefit, price, meter, credit and metered price diff against the current catalog; price and metered price changes need confirmation (prompt, or `--yes`); a catalog with benefits needs the `benefits` capability, one with meters the `meters` capability (`GET /v1/me`) |
17
+ | `steward catalog push <file> [--yes]` | `PUT /v1/admin/catalog`; version and counts. Before the push: benefit, price, meter, credit and metered price diff against the current catalog; price and metered price changes need confirmation (prompt, or `--yes`); a catalog with benefits needs the `benefits` capability, one with meters the `meters` capability, one with an unlisted plan the `unlisted_plans` capability (`GET /v1/me`) |
18
+ | `steward accounts get <ref> [--include a,b] [--json]` | `GET /v1/accounts/:ref`: name, plan, the primary subscription and the metadata; `--include` adds `profile`, `subscriptions`, `checkouts`, `payments`, `invoices`, `grants` |
19
+ | `steward accounts metadata set <ref> <key>=<value>… [--reason <text>] [--json]` / `steward accounts metadata unset <ref> <key>… [--reason <text>] [--json]` | `PATCH /v1/accounts/:ref/metadata`: sets or removes single metadata keys and leaves the others as they are; prints each key before → after. Needs the `account_metadata` capability (`GET /v1/me`); never creates an account |
18
20
  | `steward meters get <ref> [--periods <n>] [--json]` | `GET /v1/accounts/:ref/meters`: per meter the open period, usage, credit, balance, standing and estimated overage; `--periods` adds the most recent closed periods |
19
21
  | `steward events send <ref> <name> [--meta k=v]… [--external-id <id>] [--timestamp <iso>] [--json]` | A single event via `POST /v1/events/ingest` (for local trials); when `externalId` is omitted one is generated and printed. Exits 1 on a rejected event |
20
22
  | `steward settings get` | `GET /v1/admin/settings` |
@@ -31,7 +33,7 @@ ESM, Node ≥ 22. Its only runtime dependency is `@stewardhq/sdk`.
31
33
  | `steward meters recompute <ref> [--meter <code>]` / `steward meters close-periods <ref> [--meter <code>] [--force]` | Metering repairs (admin) |
32
34
  | `steward credits adjust <ref> <meter> --units=<n> --reason <text>` | A credit ledger entry; negative units = adjustment |
33
35
  | `steward events redeliver <eventId>…` | Requeues every delivery of webhook events (admin) |
34
- | `steward bank-transfers list [--status pending\|expired]` / `steward bank-transfers record <code> --amount <minor> --currency <CUR> --received-at <iso> --bank-ref <ref> […] [--yes]` | Bank transfer reconciliation; recording asks for confirmation |
36
+ | `steward bank-transfers list [--status pending\|expired] [--rate <rate>]` / `steward bank-transfers record <code> --amount <minor> --currency <CUR> --received-at <iso> --bank-ref <ref> [--rate <rate>] […] [--yes]` / `steward bank-transfers fx-report [--from <iso>] [--to <iso>] [--json\|--csv]` | Bank transfer reconciliation; recording asks for confirmation. `--rate`: a transfer in another currency than the item's, at the exchange rate you enter (`list --rate` previews the expected amounts); `fx-report`: those payments for the accountant |
35
37
 
36
38
  Exit codes: 0 success, 1 error (or doctor not ready), 2 incorrect usage.
37
39
 
@@ -39,22 +41,21 @@ Exit codes: 0 success, 1 error (or doctor not ready), 2 incorrect usage.
39
41
 
40
42
  - Admin commands (`catalog`, `settings`, `endpoints`, `keys`, `dunning`, `reprice`, `credits`,
41
43
  `bank-transfers`, `meters recompute|close-periods`, `events redeliver`): `STEWARD_ADMIN_URL` +
42
- `STEWARD_ADMIN_API_KEY`. The admin API is reachable through the public host once `/v1` is exposed;
43
- otherwise through a port-forward (e.g. `kubectl -n steward port-forward svc/steward 13002:80` →
44
- `http://localhost:13002`). The key comes from the operator.
45
- - `doctor`, `meters`, `events`: `STEWARD_URL` + `STEWARD_API_KEY`; if neither is set, the admin
44
+ `STEWARD_ADMIN_API_KEY`. The URL is the address where your steward serves `/v1`, for example
45
+ `https://billing.example.com`: its public address if the deployment exposes `/v1` there,
46
+ otherwise an address inside its network. The key comes from the operator.
47
+ - `doctor`, `accounts`, `meters`, `events`: `STEWARD_URL` + `STEWARD_API_KEY`; if neither is set, the admin
46
48
  pair. A half pair (only the URL or only the key) does not fall back to the other pair — it
47
49
  fails with a clear error.
48
50
  - **The source is chosen as a whole.** If even one of `STEWARD_URL`, `STEWARD_API_KEY`,
49
51
  `STEWARD_ADMIN_URL`, `STEWARD_ADMIN_API_KEY` is defined in the environment, the connection
50
52
  values and `APP_URL` are read from the environment only, and the `.env.local` in the working
51
53
  directory is not read at all. If none of them is in the environment, all of them come from
52
- `.env.local`. That way, when the environment is set for a port-forwarded production target,
53
- a product repo's `.env.local` cannot redirect it.
54
+ `.env.local`. That way, when the environment is set for a production target, a product repo's
55
+ `.env.local` cannot redirect it.
54
56
  - Commands print the source they used to stderr (not the values — the pair names and the
55
- origin). Some CLI output is still in Turkish for historical reasons, so this line currently
56
- reads: `bağlantı: ortam · STEWARD_ADMIN_URL + STEWARD_ADMIN_API_KEY → http://localhost:13002`
57
- (`ortam` = environment, the alternative being `.env.local`).
57
+ origin), e.g. `connection: environment · STEWARD_ADMIN_URL + STEWARD_ADMIN_API_KEY →
58
+ https://billing.example.com` (the source is `environment` or `.env.local`).
58
59
  - Changes carry `X-Actor-Ref: operator:<operating system user>`.
59
60
 
60
61
  ## Secrets
@@ -92,6 +93,11 @@ counted a period: steward refuses the push with `422 meter_locked`, and the new
92
93
  meter code. A catalog with `meters` or `meteredPrices` is pushed only when `GET /v1/me` lists the
93
94
  `meters` capability.
94
95
 
96
+ Unlisted plans: a plan with `listed: false` is sellable but not offered in the hosted portal's
97
+ "Change plan". The diff shows a plan that becomes unlisted, or listed again (`plan listing`). A
98
+ catalog with an unlisted plan is pushed only when `GET /v1/me` lists the `unlisted_plans`
99
+ capability: an older steward would drop the key and offer the plan.
100
+
95
101
  ## Meters and events
96
102
 
97
103
  - `steward meters get <ref>` prints the account's meter reading (the numbers the product sees
@@ -107,6 +113,23 @@ meter code. A catalog with `meters` or `meteredPrices` is pushed only when `GET
107
113
  rollup job processes it (seconds).
108
114
  - Details: [metering guide](https://github.com/z9cloud/steward/blob/main/docs/integrate/metering.md).
109
115
 
116
+ ## Account metadata
117
+
118
+ - `steward accounts get <ref>` prints the account as the product sees it at `GET /v1/accounts/:ref`,
119
+ with its metadata keys and values.
120
+ - `steward accounts metadata set <ref> tier=gold --reason "moved to gold"` and
121
+ `steward accounts metadata unset <ref> tier` change single keys. `key=value` is split at the
122
+ first `=`; a key is at most 64 characters, a value at most 500. The command checks that steward
123
+ lists the `account_metadata` capability, reads the account, prints each key's value before and
124
+ after (`tier: silver → gold`, `tier: gold → (removed)`), then sends one `PATCH`. An invalid
125
+ key or value is exit 2 and nothing is sent.
126
+ - Steward merges the keys in one atomic write: a key the product (or another operator) changes at
127
+ the same time is not overwritten. The change is in steward's audit trail with the key names,
128
+ `--reason` and `operator:<user>`; the account state does not change and no event is sent, so
129
+ running it again is harmless and there is no confirmation prompt.
130
+ - The account must exist: the commands never create one (exit 1 on `account_not_found`). Do not
131
+ put personal data (name, email, phone) in metadata.
132
+
110
133
  ## Versions
111
134
 
112
135
  Release: bump the version in `cli/package.json` and push the `cli-v<version>` tag
@@ -114,11 +137,23 @@ Release: bump the version in `cli/package.json` and push the `cli-v<version>` ta
114
137
  be published on npm. **The first version on npmjs is 0.5.0** (2026-09-21); 0.4.0 was not
115
138
  published.
116
139
 
140
+ - **0.9.0** (`@stewardhq/sdk` 0.9, which adds `accounts.updateMetadata`):
141
+ `steward accounts get`, `steward accounts metadata set` and `unset` (single metadata keys, merged
142
+ by steward in one atomic write; requires the `account_metadata` capability). Also: the connection
143
+ hint and the "could not reach steward" hint no longer name one deployment's host or assume a
144
+ particular way of reaching steward (messages only).
145
+ - **0.8.0** (`@stewardhq/sdk` 0.8, bank transfers in another currency, issue #55):
146
+ `bank-transfers record --rate`, `bank-transfers list --rate [--currency]`,
147
+ `bank-transfers fx-report [--from] [--to] [--json|--csv]`. Unlisted plans: `catalog push` shows
148
+ the `plan listing` diff and requires the `unlisted_plans` capability for a plan with
149
+ `listed: false`. Help, errors, `doctor` and `endpoints` output and the connection line are now
150
+ in English (they were partly Turkish); flags, command names, JSON output and exit codes are
151
+ unchanged.
117
152
  - **0.7.0** (`@stewardhq/sdk` 0.7, admin operations, issue #57): `steward keys`, `steward dunning`,
118
153
  `steward reprice`, `steward credits adjust`, `steward bank-transfers`, `steward meters recompute` and
119
154
  `close-periods`, `steward events redeliver`, `settings set --provider`. These replace the pod CLI
120
155
  commands of the same jobs. `doctor` lists the active API keys with age, last use and expiry; the
121
- connection hint names the public admin host (`STEWARD_ADMIN_URL=https://billing.zone9.cloud`).
156
+ connection hint names the public admin host.
122
157
  - **0.5.0** (`@stewardhq/sdk` 0.5, metering phase 2): `steward meters get`, `steward events
123
158
  send`; meter, credit and metered price diff in `catalog push` (a metered price change asks
124
159
  for confirmation; a catalog with meters is not pushed without the `meters` capability);