@01.software/sdk 0.4.0 → 0.4.1

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-BsO3aVX_.d.cts} +1 -1
  4. package/dist/{const-qZSQiSSC.d.ts → const-DZyvV9wU.d.ts} +1 -1
  5. package/dist/index.cjs +57 -8
  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 +57 -8
  10. package/dist/index.js.map +1 -1
  11. package/dist/{payload-types-CZiaL4Wr.d.cts → payload-types-BsjHfeAF.d.cts} +62 -2
  12. package/dist/{payload-types-CZiaL4Wr.d.ts → payload-types-BsjHfeAF.d.ts} +62 -2
  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 +104 -3
  22. package/dist/ui/flow.d.ts +104 -3
  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-BBWl8O2f.d.ts} +2 -2
  36. package/dist/{webhook-3iL9OEyq.d.cts → webhook-CkL56e65.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-BsjHfeAF.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-BsjHfeAF.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-BsjHfeAF.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-BsjHfeAF.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
  }
@@ -365,10 +367,50 @@ function debugLog(debug, type, message, data) {
365
367
  }
366
368
  function getErrorSuggestion(status) {
367
369
  if (status === 401) return "Please check your authentication credentials.";
370
+ if (status === 403) return "Access denied. Check your credentials or permissions.";
368
371
  if (status === 404) return "The requested resource was not found.";
372
+ if (status === 422) return "The request data failed validation.";
369
373
  if (status >= 500) return "A server error occurred. Please try again later.";
370
374
  return void 0;
371
375
  }
376
+ function parseErrorBody(response) {
377
+ return __async(this, null, function* () {
378
+ const fallback = {
379
+ errorMessage: `HTTP ${response.status}: ${response.statusText}`,
380
+ userMessage: `Request failed (status: ${response.status})`
381
+ };
382
+ try {
383
+ const body = yield response.json();
384
+ if (body.errors && Array.isArray(body.errors)) {
385
+ const details = body.errors.map(
386
+ (e) => e.field ? `${e.field}: ${e.message}` : e.message
387
+ ).filter(Boolean).join("; ");
388
+ if (details) {
389
+ return {
390
+ errorMessage: `HTTP ${response.status}: ${details}`,
391
+ userMessage: details,
392
+ errors: body.errors
393
+ };
394
+ }
395
+ }
396
+ if (typeof body.error === "string") {
397
+ return {
398
+ errorMessage: `HTTP ${response.status}: ${body.error}`,
399
+ userMessage: body.error
400
+ };
401
+ }
402
+ if (body.message) {
403
+ return {
404
+ errorMessage: `HTTP ${response.status}: ${body.message}`,
405
+ userMessage: body.message
406
+ };
407
+ }
408
+ return fallback;
409
+ } catch (e) {
410
+ return fallback;
411
+ }
412
+ });
413
+ }
372
414
  function delay(ms) {
373
415
  return __async(this, null, function* () {
374
416
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -477,19 +519,26 @@ function httpFetch(url, options) {
477
519
  }
478
520
  }
479
521
  if (NON_RETRYABLE_STATUSES.includes(response.status)) {
522
+ const parsed2 = yield parseErrorBody(response);
523
+ const details = __spreadValues({
524
+ url,
525
+ method: requestInit.method || "GET",
526
+ attempt: attempt + 1
527
+ }, parsed2.errors && { errors: parsed2.errors });
480
528
  throw createNetworkError(
481
- `HTTP ${response.status}: ${response.statusText}`,
529
+ parsed2.errorMessage,
482
530
  response.status,
483
- { url, method: requestInit.method || "GET", attempt: attempt + 1 },
484
- `Request failed (status: ${response.status})`,
531
+ details,
532
+ parsed2.userMessage,
485
533
  getErrorSuggestion(response.status)
486
534
  );
487
535
  }
536
+ const parsed = yield parseErrorBody(response);
488
537
  const error = createNetworkError(
489
- `HTTP ${response.status}: ${response.statusText}`,
538
+ parsed.errorMessage,
490
539
  response.status,
491
540
  { url, method: requestInit.method || "GET", attempt: attempt + 1 },
492
- `Request failed (status: ${response.status})`,
541
+ parsed.userMessage,
493
542
  getErrorSuggestion(response.status)
494
543
  );
495
544
  const method = (requestInit.method || "GET").toUpperCase();