@aexhq/cli 0.45.0 → 0.46.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 +2 -1
- package/package.json +2 -2
- package/src/index.mjs +6 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Node.js 22 or newer. The CLI uses `@aexhq/sdk` and the same public Aex HTTP API
|
|
|
4
4
|
the dashboard. No dashboard cookies, site credentials or operator credentials are needed.
|
|
5
5
|
|
|
6
6
|
```sh
|
|
7
|
-
npm install -g @aexhq/cli@0.
|
|
7
|
+
npm install -g @aexhq/cli@0.46.0
|
|
8
8
|
aex login
|
|
9
9
|
aex keys create "My application"
|
|
10
10
|
aex keys list
|
|
@@ -13,6 +13,7 @@ aex keys revoke KEY_ID
|
|
|
13
13
|
aex account
|
|
14
14
|
aex billing
|
|
15
15
|
aex usage
|
|
16
|
+
aex usage SESSION_ID
|
|
16
17
|
aex docs
|
|
17
18
|
aex logout
|
|
18
19
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Aex account and API key management from the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"tag": "next"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aexhq/sdk": "0.
|
|
27
|
+
"@aexhq/sdk": "0.79.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"test": "node --test test/*.test.mjs"
|
package/src/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ const help = `Usage: aex <command>
|
|
|
20
20
|
billing refund <topup> <cents> <key> Request a refund of unused credits
|
|
21
21
|
billing topups Show payments and receipt links
|
|
22
22
|
billing refunds Show refund status
|
|
23
|
-
usage
|
|
23
|
+
usage [session-id] Show account usage or one session's token usage
|
|
24
24
|
docs Open the documentation
|
|
25
25
|
|
|
26
26
|
Results are JSON on stdout; login progress and errors go to stderr.
|
|
@@ -33,7 +33,10 @@ async function main() {
|
|
|
33
33
|
if (values.help || !positionals.length) { process.stdout.write(help); return; }
|
|
34
34
|
const [command, operation, ...args] = positionals;
|
|
35
35
|
const expected = { "keys list": 0, "keys create": 1, "keys rename": 2, "keys revoke": 1, "billing ledger":0, "billing set":2, "billing topup":2, "billing refund":3, "billing topups":0, "billing refunds":0 };
|
|
36
|
-
|
|
36
|
+
const invalid = command === "usage" ? positionals.length > 2
|
|
37
|
+
: command === "keys" || (command === "billing" && operation) ? expected[`${command} ${operation}`] !== args.length
|
|
38
|
+
: !["login", "logout", "account", "billing", "docs"].includes(command) || positionals.length !== 1;
|
|
39
|
+
if (invalid) throw new Error("Unknown command or incorrect arguments. Run aex --help.");
|
|
37
40
|
const explicitApi = values["api-url"] ?? process.env.AEX_API_URL;
|
|
38
41
|
const siteUrl = origin(values["site-url"] ?? "https://aex.dev");
|
|
39
42
|
if (command === "docs") {
|
|
@@ -76,7 +79,7 @@ async function main() {
|
|
|
76
79
|
else if (operation === "refund") result = await client.billing.refund({topup:args[0],amount_cents:integer(args[1])},args[2]);
|
|
77
80
|
else result = await client.billing[operation]();
|
|
78
81
|
}
|
|
79
|
-
else if (command === "usage") result = await client.account.usage();
|
|
82
|
+
else if (command === "usage") result = operation ? await client.account.modelUsage(operation) : await client.account.usage();
|
|
80
83
|
else if (operation === "list") result = await client.keys.list();
|
|
81
84
|
else if (operation === "create") result = await client.keys.create({ name: args[0] });
|
|
82
85
|
else if (operation === "rename") result = await client.keys.update(args[0], { name: args[1] });
|