@orth/cli 0.2.9 → 0.2.11
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 +20 -0
- package/dist/api.js +4 -0
- package/dist/commands/api.js +34 -25
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -71,6 +71,26 @@ export interface IntegrateResponse {
|
|
|
71
71
|
path: string;
|
|
72
72
|
snippets: Record<string, string>;
|
|
73
73
|
}
|
|
74
|
+
export interface ListApisResponse {
|
|
75
|
+
success: boolean;
|
|
76
|
+
apis: Array<{
|
|
77
|
+
name: string;
|
|
78
|
+
slug: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
baseUrl: string;
|
|
81
|
+
verified: boolean;
|
|
82
|
+
endpoints: Array<{
|
|
83
|
+
path: string;
|
|
84
|
+
method: string;
|
|
85
|
+
description?: string;
|
|
86
|
+
price?: number;
|
|
87
|
+
isPayable?: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
}>;
|
|
90
|
+
count: number;
|
|
91
|
+
hasMore: boolean;
|
|
92
|
+
}
|
|
93
|
+
export declare function listApis(limit?: number, offset?: number): Promise<ListApisResponse>;
|
|
74
94
|
export declare function search(prompt: string, limit?: number): Promise<SearchResponse>;
|
|
75
95
|
export interface ApiBySlugResponse {
|
|
76
96
|
success: boolean;
|
package/dist/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.apiRequest = apiRequest;
|
|
4
|
+
exports.listApis = listApis;
|
|
4
5
|
exports.search = search;
|
|
5
6
|
exports.getApiBySlug = getApiBySlug;
|
|
6
7
|
exports.getDetails = getDetails;
|
|
@@ -54,6 +55,9 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
54
55
|
// Return the whole response, not just data field
|
|
55
56
|
return data;
|
|
56
57
|
}
|
|
58
|
+
async function listApis(limit = 100, offset = 0) {
|
|
59
|
+
return apiRequest(`/list-endpoints?limit=${limit}&offset=${offset}`);
|
|
60
|
+
}
|
|
57
61
|
async function search(prompt, limit = 10) {
|
|
58
62
|
return apiRequest("/search", {
|
|
59
63
|
method: "POST",
|
package/dist/commands/api.js
CHANGED
|
@@ -11,32 +11,41 @@ async function apiCommand(slug, path, options) {
|
|
|
11
11
|
const spinner = (0, ora_1.default)("Loading...").start();
|
|
12
12
|
try {
|
|
13
13
|
if (!slug) {
|
|
14
|
-
// List all APIs
|
|
15
|
-
|
|
16
|
-
(0, api_js_1.
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
// List all APIs using the list-endpoints endpoint
|
|
15
|
+
try {
|
|
16
|
+
const data = await (0, api_js_1.listApis)(500);
|
|
17
|
+
spinner.stop();
|
|
18
|
+
console.log(chalk_1.default.bold("\nAvailable APIs:\n"));
|
|
19
|
+
const apis = (data.apis || []).sort((a, b) => a.slug.localeCompare(b.slug));
|
|
20
|
+
for (const api of apis) {
|
|
21
|
+
console.log(chalk_1.default.cyan.bold(api.slug.padEnd(20)) +
|
|
22
|
+
chalk_1.default.white(api.name || "") +
|
|
23
|
+
chalk_1.default.gray(` (${api.endpoints?.length || 0} endpoints)`));
|
|
24
|
+
}
|
|
25
|
+
console.log(chalk_1.default.gray("\nRun 'orth api show <slug>' to see endpoints for an API"));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Fallback to search-based listing if list-endpoints not available
|
|
29
|
+
const searches = await Promise.all([
|
|
30
|
+
(0, api_js_1.search)("api", 50),
|
|
31
|
+
(0, api_js_1.search)("data", 50),
|
|
32
|
+
(0, api_js_1.search)("search", 50),
|
|
33
|
+
(0, api_js_1.search)("email", 50),
|
|
34
|
+
]);
|
|
35
|
+
spinner.stop();
|
|
36
|
+
const allResults = searches.flatMap(s => s.results || []);
|
|
37
|
+
console.log(chalk_1.default.bold("\nAvailable APIs:\n"));
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
for (const api of allResults) {
|
|
40
|
+
if (!api.slug || seen.has(api.slug))
|
|
41
|
+
continue;
|
|
42
|
+
seen.add(api.slug);
|
|
43
|
+
console.log(chalk_1.default.cyan.bold(api.slug.padEnd(20)) +
|
|
44
|
+
chalk_1.default.white(api.name || "") +
|
|
45
|
+
chalk_1.default.gray(` (${api.endpoints?.length || 0} endpoints)`));
|
|
46
|
+
}
|
|
47
|
+
console.log(chalk_1.default.gray("\nRun 'orth api show <slug>' to see endpoints for an API"));
|
|
38
48
|
}
|
|
39
|
-
console.log(chalk_1.default.gray("\nRun 'orth api show <slug>' to see endpoints for an API"));
|
|
40
49
|
return;
|
|
41
50
|
}
|
|
42
51
|
if (path) {
|