@orth/cli 0.2.32 → 0.2.34
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 +3 -4
- package/dist/api.d.ts +2 -0
- package/dist/commands/api.js +13 -2
- package/dist/commands/search.js +10 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,11 +226,10 @@ Credentials from `orth login` are stored in your OS user-config directory (manag
|
|
|
226
226
|
|
|
227
227
|
## Programmatic Use
|
|
228
228
|
|
|
229
|
-
Building an application instead of scripting the terminal? Use the official
|
|
229
|
+
Building an application instead of scripting the terminal? Use one of the official SDKs:
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
```
|
|
231
|
+
- **[`@orth/sdk`](https://www.npmjs.com/package/@orth/sdk)** — TypeScript/JavaScript (`npm install @orth/sdk`)
|
|
232
|
+
- **[`orth`](https://pypi.org/project/orth/)** — Python (`pip install orth`)
|
|
234
233
|
|
|
235
234
|
## Development
|
|
236
235
|
|
package/dist/api.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface SearchResponse {
|
|
|
13
13
|
price?: number;
|
|
14
14
|
hasDynamicPricing?: boolean;
|
|
15
15
|
pricing_formula?: string;
|
|
16
|
+
apiSlug?: string;
|
|
16
17
|
}>;
|
|
17
18
|
}>;
|
|
18
19
|
count: number;
|
|
@@ -139,6 +140,7 @@ export interface ApiBySlugResponse {
|
|
|
139
140
|
required: boolean;
|
|
140
141
|
description?: string;
|
|
141
142
|
}>;
|
|
143
|
+
apiSlug?: string;
|
|
142
144
|
}>;
|
|
143
145
|
count: number;
|
|
144
146
|
}
|
package/dist/commands/api.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.apiCommand = apiCommand;
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const ora_1 = __importDefault(require("ora"));
|
|
9
9
|
const api_js_1 = require("../api.js");
|
|
10
|
+
const utils_js_1 = require("../utils.js");
|
|
10
11
|
async function apiCommand(slug, path, options) {
|
|
11
12
|
const spinner = (0, ora_1.default)("Loading...").start();
|
|
12
13
|
try {
|
|
@@ -162,7 +163,14 @@ async function apiCommand(slug, path, options) {
|
|
|
162
163
|
? chalk_1.default.dim(ep)
|
|
163
164
|
: chalk_1.default.dim(`$${parseFloat(Number(ep).toFixed(4))}`);
|
|
164
165
|
})();
|
|
165
|
-
|
|
166
|
+
// Group members commonly collide on the same upstream path (e.g.
|
|
167
|
+
// AbstractAPI's many products all expose "/v1") — when the endpoint's
|
|
168
|
+
// own callable slug differs from the card's flat slug, show it so the
|
|
169
|
+
// right identifier is obvious before calling `orth run`.
|
|
170
|
+
const memberTag = endpoint.apiSlug && endpoint.apiSlug !== api.slug
|
|
171
|
+
? chalk_1.default.dim(` [${(0, utils_js_1.sanitizeForTerminal)(endpoint.apiSlug)}]`)
|
|
172
|
+
: "";
|
|
173
|
+
console.log(`${method} ${chalk_1.default.white(endpoint.path)} ${price}${memberTag}`);
|
|
166
174
|
if (endpoint.description) {
|
|
167
175
|
console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
|
|
168
176
|
}
|
|
@@ -195,7 +203,10 @@ async function apiCommand(slug, path, options) {
|
|
|
195
203
|
? chalk_1.default.dim(ep2)
|
|
196
204
|
: chalk_1.default.dim(`$${parseFloat(Number(ep2).toFixed(4))}`);
|
|
197
205
|
})();
|
|
198
|
-
|
|
206
|
+
const memberTag = endpoint.apiSlug && endpoint.apiSlug !== api.slug
|
|
207
|
+
? chalk_1.default.dim(` [${(0, utils_js_1.sanitizeForTerminal)(endpoint.apiSlug)}]`)
|
|
208
|
+
: "";
|
|
209
|
+
console.log(`${method} ${chalk_1.default.white(endpoint.path)} ${price}${memberTag}`);
|
|
199
210
|
if (endpoint.description) {
|
|
200
211
|
console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
|
|
201
212
|
}
|
package/dist/commands/search.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.searchCommand = searchCommand;
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const ora_1 = __importDefault(require("ora"));
|
|
9
9
|
const api_js_1 = require("../api.js");
|
|
10
|
+
const utils_js_1 = require("../utils.js");
|
|
10
11
|
async function searchCommand(query, options) {
|
|
11
12
|
const spinner = (0, ora_1.default)("Searching APIs...").start();
|
|
12
13
|
try {
|
|
@@ -21,9 +22,17 @@ async function searchCommand(query, options) {
|
|
|
21
22
|
console.log(chalk_1.default.cyan.bold(`${api.name}`) + chalk_1.default.gray(` (${api.slug})`));
|
|
22
23
|
for (const endpoint of api.endpoints.slice(0, 3)) {
|
|
23
24
|
const method = endpoint.method.padEnd(6);
|
|
25
|
+
// Group members commonly collide on the same upstream path (e.g.
|
|
26
|
+
// AbstractAPI's many products all expose "/v1") — when the endpoint's
|
|
27
|
+
// own callable slug differs from the card's flat slug, show it so the
|
|
28
|
+
// right identifier is obvious before calling `orth run`.
|
|
29
|
+
const memberTag = endpoint.apiSlug && endpoint.apiSlug !== api.slug
|
|
30
|
+
? chalk_1.default.dim(` [${(0, utils_js_1.sanitizeForTerminal)(endpoint.apiSlug)}]`)
|
|
31
|
+
: "";
|
|
24
32
|
console.log(chalk_1.default.gray(" ") +
|
|
25
33
|
chalk_1.default.yellow(method) +
|
|
26
|
-
chalk_1.default.white(endpoint.path)
|
|
34
|
+
chalk_1.default.white(endpoint.path) +
|
|
35
|
+
memberTag);
|
|
27
36
|
if (endpoint.description) {
|
|
28
37
|
console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
|
|
29
38
|
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sanitizeForTerminal(value: string): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeForTerminal = sanitizeForTerminal;
|
|
4
|
+
// Strips ASCII control characters (including ESC, 0x1B) from a string before
|
|
5
|
+
// it's written to the terminal. Needed for any remotely-sourced value we
|
|
6
|
+
// render directly (e.g. apiSlug, which an API owner sets) — without this, a
|
|
7
|
+
// crafted value containing terminal escape sequences could manipulate another
|
|
8
|
+
// user's terminal (spoofed output, hidden/cleared text, deceptive hyperlinks).
|
|
9
|
+
function sanitizeForTerminal(value) {
|
|
10
|
+
// eslint-disable-next-line no-control-regex
|
|
11
|
+
return value.replace(/[\x00-\x1F\x7F]/g, "");
|
|
12
|
+
}
|