@aisa-one/cli 0.1.3 → 0.1.4
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/account.d.ts +1 -1
- package/dist/commands/account.js +8 -42
- package/dist/commands/api.d.ts +4 -4
- package/dist/commands/api.js +20 -110
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/package.json +1 -1
package/dist/commands/account.js
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
1
|
import chalk from "chalk";
|
|
3
2
|
import { requireApiKey } from "../config.js";
|
|
4
|
-
import {
|
|
5
|
-
import { error, table } from "../utils/display.js";
|
|
3
|
+
import { hint } from "../utils/display.js";
|
|
6
4
|
export async function balanceAction() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!res.success || !res.data) {
|
|
11
|
-
spinner.fail("Failed to fetch balance");
|
|
12
|
-
error(res.error || "Unknown error");
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
spinner.stop();
|
|
16
|
-
console.log(` Balance: ${chalk.green("$" + res.data.balance.toFixed(2))} ${res.data.currency}`);
|
|
17
|
-
console.log(chalk.gray(" Add credits at https://aisa.one/dashboard/wallet"));
|
|
5
|
+
requireApiKey();
|
|
6
|
+
console.log(chalk.yellow(" Balance API is not yet available."));
|
|
7
|
+
hint("Check your balance at https://aisa.one/dashboard");
|
|
18
8
|
}
|
|
19
|
-
export async function usageAction(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (options.limit)
|
|
24
|
-
query.limit = options.limit;
|
|
25
|
-
if (options.days)
|
|
26
|
-
query.days = options.days;
|
|
27
|
-
const res = await apiRequest(key, "credits/usage", { query });
|
|
28
|
-
if (!res.success || !res.data) {
|
|
29
|
-
spinner.fail("Failed to fetch usage");
|
|
30
|
-
error(res.error || "Unknown error");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
spinner.stop();
|
|
34
|
-
const { records } = res.data;
|
|
35
|
-
if (records.length === 0) {
|
|
36
|
-
console.log(" No usage records found.");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const rows = records.map((r) => [
|
|
40
|
-
new Date(r.timestamp).toLocaleDateString(),
|
|
41
|
-
r.api,
|
|
42
|
-
r.endpoint,
|
|
43
|
-
`$${r.cost.toFixed(4)}`,
|
|
44
|
-
r.status,
|
|
45
|
-
]);
|
|
46
|
-
console.log(table(["Date", "API", "Endpoint", "Cost", "Status"], rows));
|
|
9
|
+
export async function usageAction(_options) {
|
|
10
|
+
requireApiKey();
|
|
11
|
+
console.log(chalk.yellow(" Usage API is not yet available."));
|
|
12
|
+
hint("View usage history at https://aisa.one/dashboard");
|
|
47
13
|
}
|
package/dist/commands/api.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare function apiListAction(
|
|
1
|
+
export declare function apiListAction(_options: {
|
|
2
2
|
category?: string;
|
|
3
3
|
}): Promise<void>;
|
|
4
|
-
export declare function apiSearchAction(
|
|
4
|
+
export declare function apiSearchAction(_query: string, _options: {
|
|
5
5
|
limit?: string;
|
|
6
6
|
}): Promise<void>;
|
|
7
|
-
export declare function apiShowAction(
|
|
8
|
-
export declare function apiCodeAction(
|
|
7
|
+
export declare function apiShowAction(_slug: string, _path?: string): Promise<void>;
|
|
8
|
+
export declare function apiCodeAction(_slug: string, _path: string, _options: {
|
|
9
9
|
lang?: string;
|
|
10
10
|
}): Promise<void>;
|
package/dist/commands/api.js
CHANGED
|
@@ -1,116 +1,26 @@
|
|
|
1
|
-
import ora from "ora";
|
|
2
1
|
import chalk from "chalk";
|
|
3
2
|
import { requireApiKey } from "../config.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const res = await apiRequest(key, "cli/apis", { query });
|
|
13
|
-
if (!res.success || !res.data) {
|
|
14
|
-
spinner.fail("Failed to list APIs");
|
|
15
|
-
error(res.error || "Unknown error");
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
spinner.stop();
|
|
19
|
-
const { apis } = res.data;
|
|
20
|
-
if (apis.length === 0) {
|
|
21
|
-
console.log(" No APIs found.");
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
for (const api of apis) {
|
|
25
|
-
console.log(`\n ${chalk.cyan.bold(api.name)} ${chalk.gray(api.slug)} ${badge(api.category)}`);
|
|
26
|
-
console.log(` ${chalk.gray(api.description)}`);
|
|
27
|
-
const shown = api.endpoints.slice(0, 3);
|
|
28
|
-
for (const ep of shown) {
|
|
29
|
-
console.log(` ${chalk.yellow(ep.method.padEnd(6))} ${ep.path} ${chalk.gray("- " + truncate(ep.description, 50))}`);
|
|
30
|
-
}
|
|
31
|
-
if (api.endpoints.length > 3) {
|
|
32
|
-
hint(`+${api.endpoints.length - 3} more endpoints`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
console.log(chalk.gray("\n Run 'aisa api show <slug>' for endpoint details"));
|
|
3
|
+
import { hint } from "../utils/display.js";
|
|
4
|
+
const COMING_SOON = chalk.yellow(" API catalog is not yet available.");
|
|
5
|
+
const BROWSE_HINT = "Browse available APIs at https://docs.aisa.one/reference";
|
|
6
|
+
export async function apiListAction(_options) {
|
|
7
|
+
requireApiKey();
|
|
8
|
+
console.log(COMING_SOON);
|
|
9
|
+
hint(BROWSE_HINT);
|
|
10
|
+
hint("Use 'aisa run <slug> <path>' to call APIs directly");
|
|
36
11
|
}
|
|
37
|
-
export async function apiSearchAction(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
method: "POST",
|
|
42
|
-
body: { query, limit: parseInt(options.limit || "10") },
|
|
43
|
-
});
|
|
44
|
-
if (!res.success || !res.data) {
|
|
45
|
-
spinner.fail("Search failed");
|
|
46
|
-
error(res.error || "Unknown error");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
spinner.stop();
|
|
50
|
-
const { apis } = res.data;
|
|
51
|
-
if (apis.length === 0) {
|
|
52
|
-
console.log(` No APIs found for "${query}".`);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
for (const api of apis) {
|
|
56
|
-
console.log(`\n ${chalk.cyan.bold(api.name)} ${chalk.gray(api.slug)} ${badge(api.category)}`);
|
|
57
|
-
console.log(` ${chalk.gray(api.description)}`);
|
|
58
|
-
for (const ep of api.endpoints.slice(0, 2)) {
|
|
59
|
-
console.log(` ${chalk.yellow(ep.method.padEnd(6))} ${ep.path}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
console.log(chalk.gray("\n Run 'aisa run <slug> <path>' to execute"));
|
|
12
|
+
export async function apiSearchAction(_query, _options) {
|
|
13
|
+
requireApiKey();
|
|
14
|
+
console.log(COMING_SOON);
|
|
15
|
+
hint(BROWSE_HINT);
|
|
63
16
|
}
|
|
64
|
-
export async function apiShowAction(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const res = await apiRequest(key, endpoint);
|
|
69
|
-
if (!res.success || !res.data) {
|
|
70
|
-
spinner.fail("Failed to load API details");
|
|
71
|
-
error(res.error || "Unknown error");
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
spinner.stop();
|
|
75
|
-
const data = res.data;
|
|
76
|
-
if ("endpoints" in data) {
|
|
77
|
-
// ApiGroup
|
|
78
|
-
console.log(`\n ${chalk.cyan.bold(data.name)} ${badge(data.category)}`);
|
|
79
|
-
console.log(` ${data.description}\n`);
|
|
80
|
-
for (const ep of data.endpoints) {
|
|
81
|
-
console.log(` ${chalk.yellow(ep.method.padEnd(6))} ${ep.path}`);
|
|
82
|
-
console.log(` ${chalk.gray(ep.description)}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// ApiEndpoint with parameters
|
|
87
|
-
console.log(`\n ${chalk.yellow(data.method)} ${data.path}`);
|
|
88
|
-
console.log(` ${data.description}\n`);
|
|
89
|
-
if (data.parameters && data.parameters.length > 0) {
|
|
90
|
-
const rows = data.parameters.map((p) => [
|
|
91
|
-
p.name,
|
|
92
|
-
p.type,
|
|
93
|
-
p.required ? chalk.red("required") : "optional",
|
|
94
|
-
truncate(p.description, 40),
|
|
95
|
-
]);
|
|
96
|
-
console.log(table(["Name", "Type", "Required", "Description"], rows));
|
|
97
|
-
}
|
|
98
|
-
console.log(chalk.gray(`\n Example: aisa run ${slug} ${data.path} -q "param=value"`));
|
|
99
|
-
}
|
|
17
|
+
export async function apiShowAction(_slug, _path) {
|
|
18
|
+
requireApiKey();
|
|
19
|
+
console.log(COMING_SOON);
|
|
20
|
+
hint(BROWSE_HINT);
|
|
100
21
|
}
|
|
101
|
-
export async function apiCodeAction(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const res = await apiRequest(key, "cli/apis/code", {
|
|
106
|
-
method: "POST",
|
|
107
|
-
body: { slug, path, language: lang },
|
|
108
|
-
});
|
|
109
|
-
if (!res.success || !res.data) {
|
|
110
|
-
spinner.fail("Failed to generate code");
|
|
111
|
-
error(res.error || "Unknown error");
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
spinner.stop();
|
|
115
|
-
console.log(`\n${res.data.code}`);
|
|
22
|
+
export async function apiCodeAction(_slug, _path, _options) {
|
|
23
|
+
requireApiKey();
|
|
24
|
+
console.log(COMING_SOON);
|
|
25
|
+
hint(BROWSE_HINT);
|
|
116
26
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.4";
|
|
2
2
|
export declare const BASE_URL = "https://api.aisa.one";
|
|
3
3
|
export declare const CLI_BASE_URL = "https://api.aisa.one/v1";
|
|
4
4
|
export declare const APIS_BASE_URL = "https://api.aisa.one/apis/v1";
|
package/dist/constants.js
CHANGED
package/package.json
CHANGED