@nomalism-com/api 0.47.17 → 0.47.18
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/index.js +12 -4
- package/dist/lib/apiError.d.ts +10 -0
- package/package.json +10 -6
package/dist/index.js
CHANGED
|
@@ -139,6 +139,12 @@ import axios2, { AxiosHeaders } from "axios";
|
|
|
139
139
|
// src/lib/apiError.ts
|
|
140
140
|
import axios from "axios";
|
|
141
141
|
var RAW_ERROR = /* @__PURE__ */ Symbol("rawError");
|
|
142
|
+
function isRecord(value) {
|
|
143
|
+
return typeof value === "object" && value !== null;
|
|
144
|
+
}
|
|
145
|
+
function hasCaptureStackTrace(value) {
|
|
146
|
+
return isRecord(value) && typeof value.captureStackTrace === "function";
|
|
147
|
+
}
|
|
142
148
|
var ApiError = class _ApiError extends Error {
|
|
143
149
|
kind;
|
|
144
150
|
/** HTTP status code, when the server responded. */
|
|
@@ -166,8 +172,9 @@ var ApiError = class _ApiError extends Error {
|
|
|
166
172
|
writable: false,
|
|
167
173
|
configurable: true
|
|
168
174
|
});
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
if (hasCaptureStackTrace(Error)) {
|
|
176
|
+
Error.captureStackTrace(this, _ApiError);
|
|
177
|
+
}
|
|
171
178
|
}
|
|
172
179
|
/**
|
|
173
180
|
* The original underlying error (e.g. the raw AxiosError) for deep debugging.
|
|
@@ -194,7 +201,7 @@ function isApiError(error) {
|
|
|
194
201
|
}
|
|
195
202
|
function extractServerMessage(data, fallback) {
|
|
196
203
|
if (typeof data === "string" && data.trim()) return data;
|
|
197
|
-
if (data
|
|
204
|
+
if (isRecord(data)) {
|
|
198
205
|
const record = data;
|
|
199
206
|
const candidate = record.message ?? record.error ?? record.detail ?? record.title;
|
|
200
207
|
if (typeof candidate === "string" && candidate.trim()) return candidate;
|
|
@@ -1229,11 +1236,12 @@ var Repository32 = class {
|
|
|
1229
1236
|
const ac = new AbortController();
|
|
1230
1237
|
void (async () => {
|
|
1231
1238
|
try {
|
|
1239
|
+
const authHeader = this.api.defaults.headers.common.Authorization;
|
|
1232
1240
|
const resp = await fetch(`${this.route}prompt`, {
|
|
1233
1241
|
method: "POST",
|
|
1234
1242
|
headers: {
|
|
1235
1243
|
"Content-Type": "application/json",
|
|
1236
|
-
Authorization:
|
|
1244
|
+
Authorization: typeof authHeader === "string" ? authHeader : ""
|
|
1237
1245
|
},
|
|
1238
1246
|
body: JSON.stringify(data),
|
|
1239
1247
|
signal: ac.signal
|
package/dist/lib/apiError.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private slot for the original error. A Symbol is used (instead of `cause`)
|
|
3
|
+
* specifically because Node's `util.inspect` — i.e. `console.log` — special-cases
|
|
4
|
+
* the `cause` property of an Error and prints it even when non-enumerable. A
|
|
5
|
+
* non-enumerable Symbol property is never surfaced by the logger, so the raw
|
|
6
|
+
* axios object stays available for debugging without bloating logs.
|
|
7
|
+
*/
|
|
8
|
+
declare const RAW_ERROR: unique symbol;
|
|
1
9
|
/**
|
|
2
10
|
* Where the failure happened in the axios lifecycle.
|
|
3
11
|
*
|
|
@@ -25,6 +33,7 @@ export interface IApiErrorFields {
|
|
|
25
33
|
* debugging, but never dumped when the error is logged.
|
|
26
34
|
*/
|
|
27
35
|
export declare class ApiError extends Error {
|
|
36
|
+
readonly [RAW_ERROR]?: unknown;
|
|
28
37
|
readonly kind: ApiErrorKind;
|
|
29
38
|
/** HTTP status code, when the server responded. */
|
|
30
39
|
readonly status?: number;
|
|
@@ -55,3 +64,4 @@ export declare function isApiError(error: unknown): error is ApiError;
|
|
|
55
64
|
* themselves.
|
|
56
65
|
*/
|
|
57
66
|
export declare function parseApiError(error: unknown): ApiError;
|
|
67
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomalism-com/api",
|
|
3
3
|
"description": "A nomalism API package for performing HTTP requests on API endpoints",
|
|
4
|
-
"version": "0.47.
|
|
4
|
+
"version": "0.47.18",
|
|
5
5
|
"author": "Nomalism <it.nomalism@gmail.com> (https://https://nomalism.com/)",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"type": "module",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"prepare": "husky"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nomalism-com/types": "^0.47.
|
|
27
|
+
"@nomalism-com/types": "^0.47.24",
|
|
28
28
|
"axios": "^1.20.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@eslint/js": "^10.0.1",
|
|
32
32
|
"@swc/core": "^1.16.1",
|
|
33
|
-
"@types/node": "^26.
|
|
33
|
+
"@types/node": "^26.4.1",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
|
35
35
|
"@typescript-eslint/parser": "^8.62.0",
|
|
36
36
|
"eslint": "^10.9.1",
|
|
37
37
|
"eslint-config-prettier": "^10.1.8",
|
|
38
38
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
39
|
-
"globals": "^17.
|
|
39
|
+
"globals": "^17.12.0",
|
|
40
40
|
"husky": "^9.1.7",
|
|
41
|
-
"lint-staged": "^17.
|
|
41
|
+
"lint-staged": "^17.4.1",
|
|
42
42
|
"prettier": "^3.9.6",
|
|
43
43
|
"tsup": "^8.5.1",
|
|
44
|
-
"typescript-eslint": "^8.
|
|
44
|
+
"typescript-eslint": "^8.69.0"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
@@ -60,5 +60,9 @@
|
|
|
60
60
|
"*.{json,jsonc,css,scss,md,html,yml,yaml}": [
|
|
61
61
|
"prettier --write"
|
|
62
62
|
]
|
|
63
|
+
},
|
|
64
|
+
"allowScripts": {
|
|
65
|
+
"@swc/core@1.16.1": true,
|
|
66
|
+
"esbuild@0.27.7": true
|
|
63
67
|
}
|
|
64
68
|
}
|