@myapihq/cli 2.29.1 → 2.30.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/dist/commands/billing.js +25 -0
- package/package.json +2 -2
package/dist/commands/billing.js
CHANGED
|
@@ -10,6 +10,7 @@ export const SCHEMA = {
|
|
|
10
10
|
'monthly-cap': 'string', // auto-recharge: max auto-recharged per month ($)
|
|
11
11
|
};
|
|
12
12
|
export const EXPOSES = [
|
|
13
|
+
'GET /hq/pricing',
|
|
13
14
|
'GET /hq/billing/balance',
|
|
14
15
|
'GET /hq/billing/history',
|
|
15
16
|
'GET /hq/billing/usage',
|
|
@@ -64,6 +65,28 @@ The account-level spend ceiling (IAM "Layer 2") — a self-imposed limit
|
|
|
64
65
|
This is distinct from a per-key cap (myapi keys create --spend-cap). The
|
|
65
66
|
account cap is the aggregate backstop; per-key caps bound each credential.`,
|
|
66
67
|
};
|
|
68
|
+
// What the next call costs, as opposed to what last month did. `usage` answers
|
|
69
|
+
// the second; nothing answered the first, though the API has published the list
|
|
70
|
+
// all along.
|
|
71
|
+
async function pricing(flags) {
|
|
72
|
+
const config = requireConfig();
|
|
73
|
+
const res = await hq.getPricing(config.api_key);
|
|
74
|
+
const rows = (res.prices ?? []).slice().sort((a, b) => a.key.localeCompare(b.key));
|
|
75
|
+
if (flags.json) {
|
|
76
|
+
printJson(rows);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!rows.length) {
|
|
80
|
+
info('No prices published.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
printTable(rows.map(r => ({
|
|
84
|
+
key: r.key,
|
|
85
|
+
price: r.cents === 0 ? 'free' : (r.cents < 100 ? `${r.cents}¢` : `$${(r.cents / 100).toFixed(2)}`),
|
|
86
|
+
per: r.unit,
|
|
87
|
+
description: r.description,
|
|
88
|
+
})), { flags, empty: 'No prices published.' });
|
|
89
|
+
}
|
|
67
90
|
export async function run(subcommand, args, flags) {
|
|
68
91
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
69
92
|
info(`Usage: myapi billing <subcommand>
|
|
@@ -72,6 +95,7 @@ Subcommands:
|
|
|
72
95
|
auto-recharge Keep the wallet funded automatically (show/set/disable)
|
|
73
96
|
balance Check balance, credits, and payment method status
|
|
74
97
|
history View recent transactions and top-ups
|
|
98
|
+
pricing What each metered operation costs, per unit — ask before spending
|
|
75
99
|
setup Open a checkout link to add or update payment method
|
|
76
100
|
spend-cap Set/show/clear the account-level spend ceiling (IAM Layer 2)
|
|
77
101
|
topup Top up your balance (whole dollars)
|
|
@@ -90,6 +114,7 @@ Subcommands:
|
|
|
90
114
|
case 'balance': return balance(flags);
|
|
91
115
|
case 'history': return history(flags);
|
|
92
116
|
case 'usage': return usage(flags);
|
|
117
|
+
case 'pricing': return pricing(flags);
|
|
93
118
|
case 'topup': return topup(args[0], flags);
|
|
94
119
|
case 'setup': return setup(flags);
|
|
95
120
|
case 'spend-cap': return spendCap(args[0], flags);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myapihq/cli",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.30.0",
|
|
5
5
|
"description": "MyAPI command-line interface",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"lint:skills:strict": "node scripts/copy-skills.js && node scripts/lint-skills.js --strict"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@myapihq/sdk": "^2.
|
|
50
|
+
"@myapihq/sdk": "^2.30.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^25.6.0",
|