@spacelr/sdk 0.10.4 → 0.10.6
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.d.mts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +27 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -58,6 +58,12 @@ var SpacelrSearchFilterRequiredError = class extends SpacelrError {
|
|
|
58
58
|
this.missingFields = Array.isArray(fields) ? fields.filter((f) => typeof f === "string") : [];
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
+
var SpacelrScanLimitExceededError = class extends SpacelrError {
|
|
62
|
+
constructor(message, details) {
|
|
63
|
+
super(message, "SCAN_LIMIT_EXCEEDED", 400, details);
|
|
64
|
+
this.name = "SpacelrScanLimitExceededError";
|
|
65
|
+
}
|
|
66
|
+
};
|
|
61
67
|
var SpacelrEmailVerificationRequiredError = class extends SpacelrError {
|
|
62
68
|
constructor(emailSent, details) {
|
|
63
69
|
super(
|
|
@@ -304,14 +310,27 @@ var HttpClient = class {
|
|
|
304
310
|
}
|
|
305
311
|
throwHttpError(statusCode, body) {
|
|
306
312
|
const apiBody = body;
|
|
307
|
-
const message = apiBody.error?.message ?? `HTTP ${statusCode}`;
|
|
308
|
-
const code = apiBody.error?.code ?? `HTTP_${statusCode}`;
|
|
309
|
-
const details = apiBody.error?.details;
|
|
310
313
|
const flatBody = body;
|
|
314
|
+
const flatMessage = (() => {
|
|
315
|
+
const m = flatBody["message"];
|
|
316
|
+
if (typeof m === "string" && m.length > 0) return m;
|
|
317
|
+
if (Array.isArray(m)) {
|
|
318
|
+
const parts = m.filter((x) => typeof x === "string");
|
|
319
|
+
if (parts.length > 0) return parts.join("; ");
|
|
320
|
+
}
|
|
321
|
+
return void 0;
|
|
322
|
+
})();
|
|
323
|
+
const message = apiBody.error?.message ?? flatMessage ?? `HTTP ${statusCode}`;
|
|
324
|
+
const code = apiBody.error?.code ?? `HTTP_${statusCode}`;
|
|
325
|
+
const details = apiBody.error?.details ?? (flatMessage !== void 0 ? flatBody : void 0);
|
|
311
326
|
if (statusCode === 400 && flatBody["errorCode"] === "SEARCH_FILTER_REQUIRED") {
|
|
312
|
-
const
|
|
327
|
+
const flatMessage2 = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
|
|
313
328
|
const missingFields = Array.isArray(flatBody["missingFields"]) ? flatBody["missingFields"] : [];
|
|
314
|
-
throw new SpacelrSearchFilterRequiredError(
|
|
329
|
+
throw new SpacelrSearchFilterRequiredError(flatMessage2, { missingFields });
|
|
330
|
+
}
|
|
331
|
+
if (statusCode === 400 && flatBody["errorCode"] === "SCAN_LIMIT_EXCEEDED") {
|
|
332
|
+
const flatMessage2 = typeof flatBody["message"] === "string" ? flatBody["message"] : message;
|
|
333
|
+
throw new SpacelrScanLimitExceededError(flatMessage2);
|
|
315
334
|
}
|
|
316
335
|
if (statusCode === 401 || statusCode === 403) {
|
|
317
336
|
throw new SpacelrAuthError(message, statusCode, details);
|
|
@@ -2316,7 +2335,7 @@ var Paginator = class {
|
|
|
2316
2335
|
return { documents: [], hasMore: false };
|
|
2317
2336
|
}
|
|
2318
2337
|
this.cursor = result.documents[result.documents.length - 1]._id;
|
|
2319
|
-
const hasMore = result.mode === "cursor" ? result.hasMore : result.documents.length < result.total;
|
|
2338
|
+
const hasMore = result.mode === "cursor" ? result.hasMore : result.hasMore ?? (result.total !== void 0 ? result.documents.length < result.total : false);
|
|
2320
2339
|
return { documents: result.documents, hasMore };
|
|
2321
2340
|
}
|
|
2322
2341
|
};
|
|
@@ -3342,6 +3361,7 @@ export {
|
|
|
3342
3361
|
SpacelrEmailVerificationRequiredError,
|
|
3343
3362
|
SpacelrError,
|
|
3344
3363
|
SpacelrNetworkError,
|
|
3364
|
+
SpacelrScanLimitExceededError,
|
|
3345
3365
|
SpacelrSearchFilterRequiredError,
|
|
3346
3366
|
SpacelrTimeoutError,
|
|
3347
3367
|
SpacelrTwoFactorRequiredError,
|