@01.software/sdk 0.4.0 → 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.
Files changed (39) hide show
  1. package/dist/auth.d.cts +1 -1
  2. package/dist/auth.d.ts +1 -1
  3. package/dist/{const-BpirbGBD.d.cts → const-CWZ70tFe.d.cts} +1 -1
  4. package/dist/{const-qZSQiSSC.d.ts → const-nftKBzYp.d.ts} +1 -1
  5. package/dist/index.cjs +73 -9
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +6 -6
  8. package/dist/index.d.ts +6 -6
  9. package/dist/index.js +73 -9
  10. package/dist/index.js.map +1 -1
  11. package/dist/{payload-types-CZiaL4Wr.d.cts → payload-types-BbEEk9Ji.d.cts} +68 -3
  12. package/dist/{payload-types-CZiaL4Wr.d.ts → payload-types-BbEEk9Ji.d.ts} +68 -3
  13. package/dist/realtime.cjs +5 -3
  14. package/dist/realtime.cjs.map +1 -1
  15. package/dist/realtime.d.cts +2 -2
  16. package/dist/realtime.d.ts +2 -2
  17. package/dist/realtime.js +5 -3
  18. package/dist/realtime.js.map +1 -1
  19. package/dist/ui/flow.cjs +264 -36
  20. package/dist/ui/flow.cjs.map +1 -1
  21. package/dist/ui/flow.d.cts +105 -4
  22. package/dist/ui/flow.d.ts +105 -4
  23. package/dist/ui/flow.js +252 -21
  24. package/dist/ui/flow.js.map +1 -1
  25. package/dist/ui/form.d.cts +1 -1
  26. package/dist/ui/form.d.ts +1 -1
  27. package/dist/ui/rich-text.cjs +8 -1
  28. package/dist/ui/rich-text.cjs.map +1 -1
  29. package/dist/ui/rich-text.d.cts +20 -1
  30. package/dist/ui/rich-text.d.ts +20 -1
  31. package/dist/ui/rich-text.js +8 -1
  32. package/dist/ui/rich-text.js.map +1 -1
  33. package/dist/ui/video.d.cts +1 -1
  34. package/dist/ui/video.d.ts +1 -1
  35. package/dist/{webhook-DuTqrH9x.d.ts → webhook-C4nmpBmQ.d.ts} +2 -2
  36. package/dist/{webhook-3iL9OEyq.d.cts → webhook-DRGm9rPn.d.cts} +2 -2
  37. package/dist/webhook.d.cts +3 -3
  38. package/dist/webhook.d.ts +3 -3
  39. package/package.json +2 -1
package/dist/auth.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import './payload-types-CZiaL4Wr.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-CZiaL4Wr.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-CZiaL4Wr.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-CZiaL4Wr.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
@@ -342,9 +342,11 @@ var createUsageLimitError = (message, usage, details, userMessage, suggestion) =
342
342
 
343
343
  // src/core/client/types.ts
344
344
  function resolveApiUrl() {
345
- const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
346
- if (envUrl) {
347
- return envUrl.replace(/\/$/, "");
345
+ if (typeof process !== "undefined" && process.env) {
346
+ const envUrl = process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL;
347
+ if (envUrl) {
348
+ return envUrl.replace(/\/$/, "");
349
+ }
348
350
  }
349
351
  return "https://api.01.software";
350
352
  }
@@ -352,7 +354,7 @@ function resolveApiUrl() {
352
354
  // src/core/internal/utils/http.ts
353
355
  var DEFAULT_TIMEOUT = 3e4;
354
356
  var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
355
- var NON_RETRYABLE_STATUSES = [401, 403, 404, 422];
357
+ var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 422];
356
358
  var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
357
359
  function debugLog(debug, type, message, data) {
358
360
  if (!debug) return;
@@ -364,11 +366,66 @@ function debugLog(debug, type, message, data) {
364
366
  }
365
367
  }
366
368
  function getErrorSuggestion(status) {
369
+ if (status === 400) return "The request data failed validation. Check field values and types.";
367
370
  if (status === 401) return "Please check your authentication credentials.";
371
+ if (status === 403) return "Access denied. Check your credentials or permissions.";
368
372
  if (status === 404) return "The requested resource was not found.";
373
+ if (status === 422) return "The request data failed validation.";
369
374
  if (status >= 500) return "A server error occurred. Please try again later.";
370
375
  return void 0;
371
376
  }
377
+ function parseErrorBody(response) {
378
+ return __async(this, null, function* () {
379
+ var _a;
380
+ const fallback = {
381
+ errorMessage: `HTTP ${response.status}: ${response.statusText}`,
382
+ userMessage: `Request failed (status: ${response.status})`
383
+ };
384
+ try {
385
+ const body = yield response.json();
386
+ if (body.errors && Array.isArray(body.errors)) {
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(
401
+ (e) => e.field ? `${e.field}: ${e.message}` : e.message
402
+ ).filter(Boolean).join("; ");
403
+ if (details) {
404
+ return {
405
+ errorMessage: `HTTP ${response.status}: ${details}`,
406
+ userMessage: details,
407
+ errors: fieldErrors.length > 0 ? fieldErrors : body.errors
408
+ };
409
+ }
410
+ }
411
+ if (typeof body.error === "string") {
412
+ return {
413
+ errorMessage: `HTTP ${response.status}: ${body.error}`,
414
+ userMessage: body.error
415
+ };
416
+ }
417
+ if (body.message) {
418
+ return {
419
+ errorMessage: `HTTP ${response.status}: ${body.message}`,
420
+ userMessage: body.message
421
+ };
422
+ }
423
+ return fallback;
424
+ } catch (e) {
425
+ return fallback;
426
+ }
427
+ });
428
+ }
372
429
  function delay(ms) {
373
430
  return __async(this, null, function* () {
374
431
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -477,19 +534,26 @@ function httpFetch(url, options) {
477
534
  }
478
535
  }
479
536
  if (NON_RETRYABLE_STATUSES.includes(response.status)) {
537
+ const parsed2 = yield parseErrorBody(response);
538
+ const details = __spreadValues({
539
+ url,
540
+ method: requestInit.method || "GET",
541
+ attempt: attempt + 1
542
+ }, parsed2.errors && { errors: parsed2.errors });
480
543
  throw createNetworkError(
481
- `HTTP ${response.status}: ${response.statusText}`,
544
+ parsed2.errorMessage,
482
545
  response.status,
483
- { url, method: requestInit.method || "GET", attempt: attempt + 1 },
484
- `Request failed (status: ${response.status})`,
546
+ details,
547
+ parsed2.userMessage,
485
548
  getErrorSuggestion(response.status)
486
549
  );
487
550
  }
551
+ const parsed = yield parseErrorBody(response);
488
552
  const error = createNetworkError(
489
- `HTTP ${response.status}: ${response.statusText}`,
553
+ parsed.errorMessage,
490
554
  response.status,
491
555
  { url, method: requestInit.method || "GET", attempt: attempt + 1 },
492
- `Request failed (status: ${response.status})`,
556
+ parsed.userMessage,
493
557
  getErrorSuggestion(response.status)
494
558
  );
495
559
  const method = (requestInit.method || "GET").toUpperCase();