@asteroidai/cli 1.9.481 → 1.9.485
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/asteroid.js +28 -3
- package/dist/core.js +1 -1
- package/package.json +1 -1
package/dist/asteroid.js
CHANGED
|
@@ -1590,7 +1590,7 @@ var COMMANDS = [
|
|
|
1590
1590
|
flag: "answer",
|
|
1591
1591
|
type: "json",
|
|
1592
1592
|
required: true,
|
|
1593
|
-
description:
|
|
1593
|
+
description: 'An answer to a question. Send `{"kind": "value", "value": ...}` with a value that matches its answer schema, or `{"kind": "free_text", "text": ...}` when it allows free text. A bare value is refused with 422.'
|
|
1594
1594
|
}
|
|
1595
1595
|
],
|
|
1596
1596
|
files: [],
|
|
@@ -8307,7 +8307,7 @@ var ApiError = class extends Error {
|
|
|
8307
8307
|
status;
|
|
8308
8308
|
body;
|
|
8309
8309
|
};
|
|
8310
|
-
var VERSION = "1.9.
|
|
8310
|
+
var VERSION = "1.9.485";
|
|
8311
8311
|
function problem(status, body, fallback) {
|
|
8312
8312
|
if (body && typeof body === "object") {
|
|
8313
8313
|
const record2 = body;
|
|
@@ -8318,6 +8318,31 @@ function problem(status, body, fallback) {
|
|
|
8318
8318
|
}
|
|
8319
8319
|
return fallback.trim() || `HTTP ${status}`;
|
|
8320
8320
|
}
|
|
8321
|
+
var MAX_LISTED_ERRORS = 20;
|
|
8322
|
+
function listed(body) {
|
|
8323
|
+
if (!body || typeof body !== "object") return "";
|
|
8324
|
+
const errors = body.errors;
|
|
8325
|
+
if (!Array.isArray(errors)) return "";
|
|
8326
|
+
const lines = errors.map(errorLine).filter((line2) => line2 !== "");
|
|
8327
|
+
const shown = lines.slice(0, MAX_LISTED_ERRORS).map((line2) => `
|
|
8328
|
+
- ${line2}`);
|
|
8329
|
+
if (lines.length > MAX_LISTED_ERRORS)
|
|
8330
|
+
shown.push(`
|
|
8331
|
+
- and ${lines.length - MAX_LISTED_ERRORS} more`);
|
|
8332
|
+
return shown.join("");
|
|
8333
|
+
}
|
|
8334
|
+
function errorLine(error) {
|
|
8335
|
+
if (typeof error === "string") return error;
|
|
8336
|
+
if (!error || typeof error !== "object") return "";
|
|
8337
|
+
const record2 = error;
|
|
8338
|
+
const text3 = firstString(record2.message, record2.detail);
|
|
8339
|
+
if (text3 === void 0) return "";
|
|
8340
|
+
const where = firstString(record2.path, record2.parameter);
|
|
8341
|
+
return where ? `${where}: ${text3}` : text3;
|
|
8342
|
+
}
|
|
8343
|
+
function firstString(...values) {
|
|
8344
|
+
return values.find((value2) => typeof value2 === "string");
|
|
8345
|
+
}
|
|
8321
8346
|
async function send(apiUrl, auth, request, binary, fetchImpl = fetch) {
|
|
8322
8347
|
const query = request.query.toString();
|
|
8323
8348
|
const url = `${apiUrl}${request.path}${query ? `?${query}` : ""}`;
|
|
@@ -8380,7 +8405,7 @@ async function send(apiUrl, auth, request, binary, fetchImpl = fetch) {
|
|
|
8380
8405
|
message = `ASTEROID_API_KEY was rejected: ${message}. Check the key. ${UNSET_API_KEY}`;
|
|
8381
8406
|
else if (sentKey && response.status === 403)
|
|
8382
8407
|
message = `${message} (sent with ASTEROID_API_KEY. ${UNSET_API_KEY})`;
|
|
8383
|
-
throw new ApiError(response.status, message
|
|
8408
|
+
throw new ApiError(response.status, `${message}${listed(parsed)}`, parsed);
|
|
8384
8409
|
}
|
|
8385
8410
|
if (binary)
|
|
8386
8411
|
return {
|
package/dist/core.js
CHANGED
|
@@ -1611,7 +1611,7 @@ var COMMANDS = [
|
|
|
1611
1611
|
flag: "answer",
|
|
1612
1612
|
type: "json",
|
|
1613
1613
|
required: true,
|
|
1614
|
-
description:
|
|
1614
|
+
description: 'An answer to a question. Send `{"kind": "value", "value": ...}` with a value that matches its answer schema, or `{"kind": "free_text", "text": ...}` when it allows free text. A bare value is refused with 422.'
|
|
1615
1615
|
}
|
|
1616
1616
|
],
|
|
1617
1617
|
files: [],
|