@stewardhq/cli 0.14.0 → 0.16.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/README.md +7 -2
- package/dist/bin.js +31 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ ESM, Node ≥ 22. Its only runtime dependency is `@stewardhq/sdk`.
|
|
|
26
26
|
| `steward endpoints add --url <url> --out <file> [--event-types a,b] [--description <text>] [--force]` | Generates the secret locally and writes it only to `--out` |
|
|
27
27
|
| `steward endpoints rotate <id> --out <file> [--force]` | New secret to `--out`; the product transitions with `new,old` |
|
|
28
28
|
| `steward endpoints deactivate <id>` | Not reversible |
|
|
29
|
-
| `steward discounts list [--archived] [--json]` / `steward discounts create --name <text> (--percent <n> \| --amount <CUR:minor>…) --duration once\|repeating\|forever [--months <n>] [--code <code>] [--plans a,b] [--starts <iso>] [--ends <iso>] [--max <n>] [--per-customer <n>\|unlimited]
|
|
29
|
+
| `steward discounts list [--archived] [--json]` / `steward discounts create --name <text> (--percent <n> \| --amount <CUR:minor>…) --duration once\|repeating\|forever [--months <n>] [--code <code>] [--plans a,b] [--starts <iso>] [--ends <iso>] [--max <n>] [--per-customer <n>\|unlimited] [--benefit <code>]…` / `steward discounts update <id> […]` / `steward discounts archive <id> [--yes]` | Discounts and discount codes (`/v1/admin/discounts`): a share or an amount per currency off a plan's base price, for the first invoice, a number of months or every invoice. `update` takes `none` to clear an optional field; the value, duration and benefits are fixed once redeemed. `--benefit` (repeatable) adds catalog benefits the account holds while its subscription runs with the discount. `create` warns when a sellable price would fall under the payment provider's minimum |
|
|
30
30
|
| `steward email-smtp get [--json]` / `steward email-smtp set --file <path> \| --stdin` / `steward email-smtp clear [--yes]` / `steward email-smtp verify [--to <address>] [--json]` | The product's own SMTP account for its billing emails (`/v1/admin/email-smtp`; otherwise the installation's). `set` reads the URL (`smtp://user:pass@host:587` or `smtps://…:465`) from a file or a pipe, never from an argument or a terminal; steward never returns it (`get` shows the host). `verify` asks `MAIL FROM` (the product's sender) and `RCPT TO`, stops before `DATA`, and exits 1 with the failed step and the server's reply when the account refuses |
|
|
31
31
|
| `steward keys list [--json]` | The product's API keys: prefix, scope, status (active, expired, revoked), expiry, last use |
|
|
32
32
|
| `steward keys create --name <n> --scope product\|checkout\|admin --out <file> [--expires-days <n> \| --no-expiry] [--force]` | Generates the key locally and writes it only to `--out`; steward stores its hash. An admin key always expires (default 90 days) |
|
|
@@ -151,6 +151,11 @@ Release: bump the version in `cli/package.json` and push the `cli-v<version>` ta
|
|
|
151
151
|
be published on npm. The notes of 0.4.0 to 0.10.0 are in
|
|
152
152
|
[this file at `cli-v0.10.0`](https://github.com/z9cloud/steward/blob/cli-v0.10.0/cli/README.md#versions).
|
|
153
153
|
|
|
154
|
+
- **0.16.0** (`@stewardhq/sdk` 0.16): `steward catalog push` shows a change of a credit's rollover carries (`rollover carries 1 → 2`,
|
|
155
|
+
the SDK's `meterCredit(…, { rollover: { capUnits, carries } })`). Needs steward 0.16.0 for the catalog to keep it.
|
|
156
|
+
- **0.15.0** (`@stewardhq/sdk` 0.15): `steward discounts create|update --benefit <code>` (repeatable; `--benefit none` clears on
|
|
157
|
+
update): catalog benefits granted while a subscription runs with the discount; `list` shows them. Needs steward
|
|
158
|
+
0.15.0.
|
|
154
159
|
- **0.14.0** (`@stewardhq/sdk` 0.14): `steward accounts list`, `steward events list`, `steward audit list`,
|
|
155
160
|
`steward emails list` and `steward payments list` (product-wide lists, paged with `--limit` / `--after`; need a
|
|
156
161
|
steward with `/v1/admin/accounts`, `/events`, `/audit`, `/emails` and `/payments`, 0.14.0 or later);
|
|
@@ -175,7 +180,7 @@ be published on npm. The notes of 0.4.0 to 0.10.0 are in
|
|
|
175
180
|
the provider's webhook, automatic renewal and the legal settings.
|
|
176
181
|
|
|
177
182
|
When packed, the `@stewardhq/sdk` dependency turns from `workspace:^` into the range of the
|
|
178
|
-
SDK version current at that time (0.
|
|
183
|
+
SDK version current at that time (0.16.0 → `^0.16.0`).
|
|
179
184
|
|
|
180
185
|
## License
|
|
181
186
|
|
package/dist/bin.js
CHANGED
|
@@ -175,6 +175,8 @@ function describeCreditChange({ code, from, to }) {
|
|
|
175
175
|
const cap = (units) => units === null ? "no rollover" : `rollover cap ${unitsText(units)}`;
|
|
176
176
|
parts.push(`${cap(from.rolloverCapUnits)} → ${cap(to.rolloverCapUnits)}`);
|
|
177
177
|
}
|
|
178
|
+
const carries = (terms) => terms.rolloverCarries ?? (terms.rolloverCapUnits === null ? null : 1);
|
|
179
|
+
if (from.rolloverCapUnits !== null && to.rolloverCapUnits !== null && carries(from) !== carries(to)) parts.push(`rollover carries ${carries(from)} → ${carries(to)}`);
|
|
178
180
|
return `${code} (${to.meter}): ${parts.join(", ")}`;
|
|
179
181
|
}
|
|
180
182
|
const list$1 = (items) => items.join(", ");
|
|
@@ -1878,10 +1880,11 @@ const DISCOUNTS_USAGE = `Usage:
|
|
|
1878
1880
|
steward discounts list [--archived] [--json]
|
|
1879
1881
|
steward discounts create --name <text> (--percent <n> | --amount <CUR:minor>...) --duration once|repeating|forever
|
|
1880
1882
|
[--months <n>] [--code <code>] [--plans <a,b>] [--starts <iso>] [--ends <iso>]
|
|
1881
|
-
[--max <n>] [--per-customer <n>|unlimited] [--json]
|
|
1883
|
+
[--max <n>] [--per-customer <n>|unlimited] [--benefit <code>]... [--json]
|
|
1882
1884
|
steward discounts update <id> [--name …] [--code <code>|none] [--plans <a,b>|none] [--starts <iso>|none]
|
|
1883
1885
|
[--ends <iso>|none] [--max <n>|none] [--per-customer <n>|unlimited]
|
|
1884
|
-
[--percent … | --amount …] [--duration … --months …]
|
|
1886
|
+
[--percent … | --amount …] [--duration … --months …]
|
|
1887
|
+
[--benefit <code>... | --benefit none] [--json]
|
|
1885
1888
|
steward discounts archive <id> [--yes]
|
|
1886
1889
|
|
|
1887
1890
|
The product's discounts (/v1/admin/discounts): a share (--percent 20, up to 99.99) or an amount per
|
|
@@ -1889,8 +1892,14 @@ currency in minor units (--amount USD:500 --amount EUR:450) off a plan's base pr
|
|
|
1889
1892
|
invoice (once), --months calendar months (repeating) or every invoice (forever). A discount with
|
|
1890
1893
|
--code is entered by the customer on the hosted checkout; one without is applied by the product
|
|
1891
1894
|
(checkout.create({ discountId })). Codes are case-insensitive. --plans restricts it (default:
|
|
1892
|
-
every listed plan). --per-customer defaults to 1.
|
|
1893
|
-
|
|
1895
|
+
every listed plan). --per-customer defaults to 1.
|
|
1896
|
+
|
|
1897
|
+
--benefit (repeatable) adds a catalog benefit the account is granted while its subscription runs
|
|
1898
|
+
with the discount: from the first period for a checkout, from the next renewal for a discount
|
|
1899
|
+
attached later, until the discount ends. A meter credit benefit with a rollover cap carries what
|
|
1900
|
+
is left of the last discounted period into the next one, once. On update the benefits given
|
|
1901
|
+
replace the list (--benefit none: no benefits). Once redeemed, its value, duration and benefits
|
|
1902
|
+
no longer change; archive it and create another instead.
|
|
1894
1903
|
|
|
1895
1904
|
create warns when the discount would bring a sellable price of the catalog to zero or under the
|
|
1896
1905
|
payment provider's minimum charge (such a price refuses the code at checkout).
|
|
@@ -1918,6 +1927,10 @@ const OPTIONS$1 = {
|
|
|
1918
1927
|
ends: { type: "string" },
|
|
1919
1928
|
max: { type: "string" },
|
|
1920
1929
|
"per-customer": { type: "string" },
|
|
1930
|
+
benefit: {
|
|
1931
|
+
type: "string",
|
|
1932
|
+
multiple: true
|
|
1933
|
+
},
|
|
1921
1934
|
json: { type: "boolean" }
|
|
1922
1935
|
};
|
|
1923
1936
|
const NONE = "none";
|
|
@@ -1939,6 +1952,16 @@ function parseAmounts(values) {
|
|
|
1939
1952
|
}
|
|
1940
1953
|
return out;
|
|
1941
1954
|
}
|
|
1955
|
+
/** `--benefit` values → benefit codes; `none` alone (update) → no benefits. */
|
|
1956
|
+
function benefitCodesOf(values, update) {
|
|
1957
|
+
const codes = values.map((v) => v.trim());
|
|
1958
|
+
if (codes.includes(NONE)) {
|
|
1959
|
+
if (!update) throw new UsageError("--benefit none: only on update (a new discount has no benefits without --benefit)");
|
|
1960
|
+
if (codes.length > 1) throw new UsageError("--benefit none: give it alone");
|
|
1961
|
+
return [];
|
|
1962
|
+
}
|
|
1963
|
+
return codes;
|
|
1964
|
+
}
|
|
1942
1965
|
/** The fields shared by create and update (update: `none` clears an optional one). */
|
|
1943
1966
|
function fieldsOf(values, update) {
|
|
1944
1967
|
const clearable = (value, read) => value === void 0 ? void 0 : update && value.trim() === NONE ? null : read(value);
|
|
@@ -1951,7 +1974,8 @@ function fieldsOf(values, update) {
|
|
|
1951
1974
|
startsAt: clearable(values.starts, (v) => v.trim()),
|
|
1952
1975
|
endsAt: clearable(values.ends, (v) => v.trim()),
|
|
1953
1976
|
maxRedemptions: clearable(values.max, (v) => parsePositiveInt(v, "--max")),
|
|
1954
|
-
maxRedemptionsPerCustomer: values["per-customer"] === void 0 ? void 0 : values["per-customer"].trim() === "unlimited" ? null : parsePositiveInt(values["per-customer"], "--per-customer")
|
|
1977
|
+
maxRedemptionsPerCustomer: values["per-customer"] === void 0 ? void 0 : values["per-customer"].trim() === "unlimited" ? null : parsePositiveInt(values["per-customer"], "--per-customer"),
|
|
1978
|
+
benefitCodes: values.benefit !== void 0 ? benefitCodesOf(values.benefit, update) : void 0
|
|
1955
1979
|
};
|
|
1956
1980
|
if (values.percent !== void 0 && values.amount !== void 0) throw new UsageError("give --percent or --amount, not both");
|
|
1957
1981
|
if (values.percent !== void 0) Object.assign(fields, {
|
|
@@ -2011,6 +2035,7 @@ function describe$1(d) {
|
|
|
2011
2035
|
d.maxRedemptions !== null ? `max ${d.maxRedemptions}` : null,
|
|
2012
2036
|
`per customer ${d.maxRedemptionsPerCustomer ?? "unlimited"}`,
|
|
2013
2037
|
d.planCodes.length > 0 ? `plans ${d.planCodes.join(",")}` : null,
|
|
2038
|
+
d.benefitCodes.length > 0 ? `benefits ${d.benefitCodes.join(",")}` : null,
|
|
2014
2039
|
d.startsAt ? `from ${d.startsAt}` : null,
|
|
2015
2040
|
d.endsAt ? `until ${d.endsAt}` : null
|
|
2016
2041
|
].filter(Boolean);
|
|
@@ -3653,7 +3678,7 @@ function help(out) {
|
|
|
3653
3678
|
return 0;
|
|
3654
3679
|
}
|
|
3655
3680
|
// src/main.ts
|
|
3656
|
-
const CLI_VERSION = "0.
|
|
3681
|
+
const CLI_VERSION = "0.16.0";
|
|
3657
3682
|
const USAGE = `steward — Steward CLI (@stewardhq/cli ${CLI_VERSION})
|
|
3658
3683
|
|
|
3659
3684
|
Usage: steward <command> [options]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stewardhq/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Steward CLI: doctor, catalog push, settings and webhook endpoint management.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/z9cloud/steward/tree/main/cli#readme",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"registry": "https://registry.npmjs.org"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@stewardhq/sdk": "^0.
|
|
31
|
+
"@stewardhq/sdk": "^0.16.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^26.6.6",
|