@01.software/sdk 0.4.1 → 0.4.2

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/auth.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import './payload-types-BsjHfeAF.cjs';
1
+ import './payload-types-BbEEk9Ji.cjs';
2
2
 
3
3
  interface JwtPayload {
4
4
  clientKey: string;
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import './payload-types-BsjHfeAF.js';
1
+ import './payload-types-BbEEk9Ji.js';
2
2
 
3
3
  interface JwtPayload {
4
4
  clientKey: string;
@@ -1,4 +1,4 @@
1
- import { C as Config } from './payload-types-BsjHfeAF.cjs';
1
+ import { C as Config } from './payload-types-BbEEk9Ji.cjs';
2
2
 
3
3
  /**
4
4
  * Collection type derived from Payload Config.
@@ -1,4 +1,4 @@
1
- import { C as Config } from './payload-types-BsjHfeAF.js';
1
+ import { C as Config } from './payload-types-BbEEk9Ji.js';
2
2
 
3
3
  /**
4
4
  * Collection type derived from Payload Config.
package/dist/index.cjs CHANGED
@@ -354,7 +354,7 @@ function resolveApiUrl() {
354
354
  // src/core/internal/utils/http.ts
355
355
  var DEFAULT_TIMEOUT = 3e4;
356
356
  var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
357
- var NON_RETRYABLE_STATUSES = [401, 403, 404, 422];
357
+ var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 422];
358
358
  var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
359
359
  function debugLog(debug, type, message, data) {
360
360
  if (!debug) return;
@@ -366,6 +366,7 @@ function debugLog(debug, type, message, data) {
366
366
  }
367
367
  }
368
368
  function getErrorSuggestion(status) {
369
+ if (status === 400) return "The request data failed validation. Check field values and types.";
369
370
  if (status === 401) return "Please check your authentication credentials.";
370
371
  if (status === 403) return "Access denied. Check your credentials or permissions.";
371
372
  if (status === 404) return "The requested resource was not found.";
@@ -375,6 +376,7 @@ function getErrorSuggestion(status) {
375
376
  }
376
377
  function parseErrorBody(response) {
377
378
  return __async(this, null, function* () {
379
+ var _a;
378
380
  const fallback = {
379
381
  errorMessage: `HTTP ${response.status}: ${response.statusText}`,
380
382
  userMessage: `Request failed (status: ${response.status})`
@@ -382,14 +384,27 @@ function parseErrorBody(response) {
382
384
  try {
383
385
  const body = yield response.json();
384
386
  if (body.errors && Array.isArray(body.errors)) {
385
- const details = body.errors.map(
387
+ const fieldErrors = [];
388
+ for (const e of body.errors) {
389
+ if (((_a = e.data) == null ? void 0 : _a.errors) && Array.isArray(e.data.errors) && e.data.errors.length > 0) {
390
+ for (const fe of e.data.errors) {
391
+ fieldErrors.push({
392
+ field: fe.path || fe.field,
393
+ message: fe.message
394
+ });
395
+ }
396
+ } else if (e.field || e.message) {
397
+ fieldErrors.push({ field: e.field, message: e.message });
398
+ }
399
+ }
400
+ const details = (fieldErrors.length > 0 ? fieldErrors : body.errors).map(
386
401
  (e) => e.field ? `${e.field}: ${e.message}` : e.message
387
402
  ).filter(Boolean).join("; ");
388
403
  if (details) {
389
404
  return {
390
405
  errorMessage: `HTTP ${response.status}: ${details}`,
391
406
  userMessage: details,
392
- errors: body.errors
407
+ errors: fieldErrors.length > 0 ? fieldErrors : body.errors
393
408
  };
394
409
  }
395
410
  }