@orth/cli 0.2.24 → 0.2.26

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.
@@ -56,6 +56,16 @@ async function apiCommand(slug, path, options) {
56
56
  // Get description from endpoint or action object if available
57
57
  const desc = data.description || data.endpoint?.description || data.action?.description;
58
58
  console.log(chalk_1.default.gray(desc || "No description"));
59
+ // Show price
60
+ const endpointPrice = data.price ?? data.endpoint?.price;
61
+ if (endpointPrice !== undefined && endpointPrice !== null) {
62
+ const isFree = endpointPrice === 0 || endpointPrice === "free" || endpointPrice === "0";
63
+ const priceDisplay = typeof endpointPrice === 'string'
64
+ ? endpointPrice
65
+ : `$${parseFloat(Number(endpointPrice).toFixed(4))}`;
66
+ console.log(chalk_1.default.bold("Price: ") +
67
+ (isFree ? chalk_1.default.green("free") : chalk_1.default.yellow(priceDisplay)));
68
+ }
59
69
  // Get params from nested endpoint or action object if needed
60
70
  const actionParams = data.action?.parameters ?? [];
61
71
  const queryParams = data.parameters?.query || data.endpoint?.queryParams || [];
@@ -134,9 +144,13 @@ async function apiCommand(slug, path, options) {
134
144
  console.log(chalk_1.default.bold(`\n${chalk_1.default.cyan(api.name)} (${api.slug})\n`));
135
145
  for (const endpoint of apiData.endpoints) {
136
146
  const method = chalk_1.default.yellow(endpoint.method.padEnd(6));
137
- const price = endpoint.price === 0 || endpoint.price === null || endpoint.price === undefined
147
+ const ep = endpoint.price;
148
+ const isFreePrice = ep === 0 || ep == null || ep === "free" || ep === "0";
149
+ const price = isFreePrice
138
150
  ? chalk_1.default.green("free")
139
- : "";
151
+ : typeof ep === 'string'
152
+ ? chalk_1.default.dim(ep)
153
+ : chalk_1.default.dim(`$${parseFloat(Number(ep).toFixed(4))}`);
140
154
  console.log(`${method} ${chalk_1.default.white(endpoint.path)} ${price}`);
141
155
  if (endpoint.description) {
142
156
  console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
@@ -158,9 +172,13 @@ async function apiCommand(slug, path, options) {
158
172
  console.log(chalk_1.default.bold(`\n${chalk_1.default.cyan(api.name)} (${api.slug})\n`));
159
173
  for (const endpoint of api.endpoints) {
160
174
  const method = chalk_1.default.yellow(endpoint.method.padEnd(6));
161
- const price = endpoint.price === 0 || endpoint.price === null || endpoint.price === undefined
175
+ const ep2 = endpoint.price;
176
+ const isFreePrice = ep2 === 0 || ep2 == null || ep2 === "free" || ep2 === "0";
177
+ const price = isFreePrice
162
178
  ? chalk_1.default.green("free")
163
- : "";
179
+ : typeof ep2 === 'string'
180
+ ? chalk_1.default.dim(ep2)
181
+ : chalk_1.default.dim(`$${parseFloat(Number(ep2).toFixed(4))}`);
164
182
  console.log(`${method} ${chalk_1.default.white(endpoint.path)} ${price}`);
165
183
  if (endpoint.description) {
166
184
  console.log(chalk_1.default.gray(` ${endpoint.description.slice(0, 80)}${endpoint.description.length > 80 ? "..." : ""}`));
@@ -58,6 +58,14 @@ function isBinaryEnvelope(data) {
58
58
  typeof data.contentType === "string" &&
59
59
  typeof data.size === "number");
60
60
  }
61
+ function formatCost(result) {
62
+ if (result.price)
63
+ return result.price;
64
+ if (result.priceCents != null && result.priceCents > 0) {
65
+ return `$${parseFloat((result.priceCents / 100).toFixed(4))}`;
66
+ }
67
+ return null;
68
+ }
61
69
  async function runCommand(api, path, options) {
62
70
  const spinner = (0, ora_1.default)(`Calling ${api}${path}...`).start();
63
71
  try {
@@ -124,6 +132,9 @@ async function runCommand(api, path, options) {
124
132
  const queryHint = options.query?.length ? " -q '...'" : "";
125
133
  console.log(chalk_1.default.yellow(`\nResponse contains binary ${ext.toUpperCase()} data (${result.data.size} bytes).` +
126
134
  `\nUse -o to save it: orth api run ${api} ${path}${methodHint}${queryHint}${bodyHint} -o output.${ext}`));
135
+ const cost0 = formatCost(result);
136
+ if (cost0)
137
+ console.log(chalk_1.default.dim(`\nCost: ${cost0}`));
127
138
  return;
128
139
  }
129
140
  const ext = extFromContentType(result.data.contentType);
@@ -135,6 +146,9 @@ async function runCommand(api, path, options) {
135
146
  const buffer = Buffer.from(result.data.data, result.data.encoding);
136
147
  writeExclusive(outputPath, buffer);
137
148
  console.log(chalk_1.default.green(`\n${ext.toUpperCase()} saved to: ${outputPath} (${buffer.length} bytes)`));
149
+ const cost1 = formatCost(result);
150
+ if (cost1)
151
+ console.log(chalk_1.default.dim(`\nCost: ${cost1}`));
138
152
  return;
139
153
  }
140
154
  // If --output specified for non-binary data, save JSON to file
@@ -142,6 +156,9 @@ async function runCommand(api, path, options) {
142
156
  const outputPath = (0, path_1.resolve)(options.output);
143
157
  writeExclusive(outputPath, JSON.stringify(result.data, null, 2));
144
158
  console.log(chalk_1.default.green(`\nResponse saved to: ${outputPath}`));
159
+ const cost2 = formatCost(result);
160
+ if (cost2)
161
+ console.log(chalk_1.default.dim(`\nCost: ${cost2}`));
145
162
  return;
146
163
  }
147
164
  if (options.raw) {
@@ -152,6 +169,11 @@ async function runCommand(api, path, options) {
152
169
  console.log(chalk_1.default.bold("\nResponse:\n"));
153
170
  console.log(JSON.stringify(result.data, null, 2));
154
171
  }
172
+ // Show price if returned
173
+ const cost3 = formatCost(result);
174
+ if (cost3) {
175
+ console.log(chalk_1.default.dim(`\nCost: ${cost3}`));
176
+ }
155
177
  }
156
178
  catch (error) {
157
179
  spinner.stop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orth/cli",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "CLI to access all APIs and skills on the Orthogonal platform",
5
5
  "main": "dist/index.js",
6
6
  "bin": {