@orth/cli 0.2.6 → 0.2.7
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/api.d.ts +33 -0
- package/dist/api.js +4 -0
- package/dist/commands/account.js +7 -3
- package/dist/commands/api.js +40 -16
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -72,6 +72,39 @@ export interface IntegrateResponse {
|
|
|
72
72
|
snippets: Record<string, string>;
|
|
73
73
|
}
|
|
74
74
|
export declare function search(prompt: string, limit?: number): Promise<SearchResponse>;
|
|
75
|
+
export interface ApiBySlugResponse {
|
|
76
|
+
success: boolean;
|
|
77
|
+
api: {
|
|
78
|
+
name: string;
|
|
79
|
+
slug: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
baseUrl: string;
|
|
82
|
+
verified: boolean;
|
|
83
|
+
};
|
|
84
|
+
endpoints: Array<{
|
|
85
|
+
id: string;
|
|
86
|
+
path: string;
|
|
87
|
+
method: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
price?: number;
|
|
90
|
+
isPayable?: boolean;
|
|
91
|
+
docsUrl?: string;
|
|
92
|
+
queryParams?: Array<{
|
|
93
|
+
name: string;
|
|
94
|
+
type: string;
|
|
95
|
+
required: boolean;
|
|
96
|
+
description?: string;
|
|
97
|
+
}>;
|
|
98
|
+
bodyParams?: Array<{
|
|
99
|
+
name: string;
|
|
100
|
+
type: string;
|
|
101
|
+
required: boolean;
|
|
102
|
+
description?: string;
|
|
103
|
+
}>;
|
|
104
|
+
}>;
|
|
105
|
+
count: number;
|
|
106
|
+
}
|
|
107
|
+
export declare function getApiBySlug(slug: string): Promise<ApiBySlugResponse>;
|
|
75
108
|
export declare function getDetails(api: string, path: string): Promise<DetailsResponse>;
|
|
76
109
|
export declare function run(api: string, path: string, options?: {
|
|
77
110
|
method?: string;
|
package/dist/api.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.apiRequest = apiRequest;
|
|
4
4
|
exports.search = search;
|
|
5
|
+
exports.getApiBySlug = getApiBySlug;
|
|
5
6
|
exports.getDetails = getDetails;
|
|
6
7
|
exports.run = run;
|
|
7
8
|
exports.integrate = integrate;
|
|
@@ -59,6 +60,9 @@ async function search(prompt, limit = 10) {
|
|
|
59
60
|
body: { prompt, limit },
|
|
60
61
|
});
|
|
61
62
|
}
|
|
63
|
+
async function getApiBySlug(slug) {
|
|
64
|
+
return apiRequest(`/api-directory/${encodeURIComponent(slug)}`);
|
|
65
|
+
}
|
|
62
66
|
async function getDetails(api, path) {
|
|
63
67
|
return apiRequest("/details", {
|
|
64
68
|
method: "POST",
|
package/dist/commands/account.js
CHANGED
|
@@ -54,11 +54,15 @@ async function usageCommand(options) {
|
|
|
54
54
|
minute: "2-digit",
|
|
55
55
|
});
|
|
56
56
|
const statusIcon = item.status === "completed" ? "" : chalk_1.default.yellow(" ⚠");
|
|
57
|
+
const api = item.api ?? "unknown";
|
|
58
|
+
const method = item.method ?? "";
|
|
59
|
+
const path = item.path ?? "";
|
|
60
|
+
const cost = item.cost ?? "$0.00";
|
|
57
61
|
console.log(" " +
|
|
58
62
|
chalk_1.default.gray(date.padEnd(18)) +
|
|
59
|
-
chalk_1.default.cyan(
|
|
60
|
-
chalk_1.default.white((
|
|
61
|
-
chalk_1.default.green(
|
|
63
|
+
chalk_1.default.cyan(api.padEnd(20)) +
|
|
64
|
+
chalk_1.default.white((method + " " + path).substring(0, 30).padEnd(32)) +
|
|
65
|
+
chalk_1.default.green(cost.padStart(10)) +
|
|
62
66
|
statusIcon);
|
|
63
67
|
}
|
|
64
68
|
// Summary
|
package/dist/commands/api.js
CHANGED
|
@@ -116,25 +116,49 @@ async function apiCommand(slug, path, options) {
|
|
|
116
116
|
}
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
// Show API endpoints
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
console.log(chalk_1.default.
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
// Show API endpoints - direct lookup by slug
|
|
120
|
+
try {
|
|
121
|
+
const apiData = await (0, api_js_1.getApiBySlug)(slug);
|
|
122
|
+
spinner.stop();
|
|
123
|
+
const api = apiData.api;
|
|
124
|
+
console.log(chalk_1.default.bold(`\n${chalk_1.default.cyan(api.name)} (${api.slug})\n`));
|
|
125
|
+
for (const endpoint of apiData.endpoints) {
|
|
126
|
+
const method = chalk_1.default.yellow(endpoint.method.padEnd(6));
|
|
127
|
+
const price = endpoint.price === 0 || endpoint.price === null || endpoint.price === undefined
|
|
128
|
+
? chalk_1.default.green("free")
|
|
129
|
+
: "";
|
|
130
|
+
console.log(`${method} ${chalk_1.default.white(endpoint.path)} ${price}`);
|
|
131
|
+
if (endpoint.description) {
|
|
132
|
+
console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
console.log(chalk_1.default.gray("\nRun 'orth api show " + slug + " <path>' for endpoint details"));
|
|
136
|
+
console.log(chalk_1.default.gray("Run 'orth run " + slug + " <path>' to call an endpoint"));
|
|
127
137
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
catch {
|
|
139
|
+
// Fallback to search if direct lookup fails (e.g. older backend)
|
|
140
|
+
const data = await (0, api_js_1.search)(slug, 20);
|
|
141
|
+
spinner.stop();
|
|
142
|
+
const api = data.results.find((a) => a.slug === slug);
|
|
143
|
+
if (!api) {
|
|
144
|
+
console.log(chalk_1.default.yellow(`API '${slug}' not found.`));
|
|
145
|
+
console.log(chalk_1.default.gray("Run 'orth api' to see available APIs"));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
console.log(chalk_1.default.bold(`\n${chalk_1.default.cyan(api.name)} (${api.slug})\n`));
|
|
149
|
+
for (const endpoint of api.endpoints) {
|
|
150
|
+
const method = chalk_1.default.yellow(endpoint.method.padEnd(6));
|
|
151
|
+
const price = endpoint.price === 0 || endpoint.price === null || endpoint.price === undefined
|
|
152
|
+
? chalk_1.default.green("free")
|
|
153
|
+
: "";
|
|
154
|
+
console.log(`${method} ${chalk_1.default.white(endpoint.path)} ${price}`);
|
|
155
|
+
if (endpoint.description) {
|
|
156
|
+
console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
|
|
157
|
+
}
|
|
134
158
|
}
|
|
159
|
+
console.log(chalk_1.default.gray("\nRun 'orth api show " + slug + " <path>' for endpoint details"));
|
|
160
|
+
console.log(chalk_1.default.gray("Run 'orth run " + slug + " <path>' to call an endpoint"));
|
|
135
161
|
}
|
|
136
|
-
console.log(chalk_1.default.gray("\nRun 'orth api show " + slug + " <path>' for endpoint details"));
|
|
137
|
-
console.log(chalk_1.default.gray("Run 'orth run " + slug + " <path>' to call an endpoint"));
|
|
138
162
|
}
|
|
139
163
|
catch (error) {
|
|
140
164
|
spinner.stop();
|