@01.software/sdk 0.25.0 → 0.26.0

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/server.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- export { ab as ClientServerConfig, aL as CollectionClient, n as CommunityClient, aS as ModerationApi, a9 as ServerClient, aM as ServerCollectionClient, aO as ServerCommerceClient, a8 as createServerClient } from './server-CkGfBnSx.cjs';
2
- import './payload-types-BaK4zCQ8.cjs';
1
+ export { ab as ClientServerConfig, aL as CollectionClient, n as CommunityClient, aS as ModerationApi, a9 as ServerClient, aM as ServerCollectionClient, aO as ServerCommerceClient, a8 as createServerClient } from './server-CZrUwqDs.cjs';
2
+ import './payload-types-BF8VVFt6.cjs';
3
3
  import '@tanstack/react-query';
4
4
  import 'payload';
5
5
  import 'next';
6
- import './types-BH-YBrFs.cjs';
7
- import './const-C8UhtzLn.cjs';
6
+ import './types-lPRgx_rC.cjs';
7
+ import './const-CEiFBZMW.cjs';
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { ab as ClientServerConfig, aL as CollectionClient, n as CommunityClient, aS as ModerationApi, a9 as ServerClient, aM as ServerCollectionClient, aO as ServerCommerceClient, a8 as createServerClient } from './server-DQYWLnkt.js';
2
- import './payload-types-BaK4zCQ8.js';
1
+ export { ab as ClientServerConfig, aL as CollectionClient, n as CommunityClient, aS as ModerationApi, a9 as ServerClient, aM as ServerCollectionClient, aO as ServerCommerceClient, a8 as createServerClient } from './server-DULueNYi.js';
2
+ import './payload-types-BF8VVFt6.js';
3
3
  import '@tanstack/react-query';
4
4
  import 'payload';
5
5
  import 'next';
6
- import './types-DjaaBExv.js';
7
- import './const-Bs-QcTj0.js';
6
+ import './types-CZ1laT6s.js';
7
+ import './const-R3AyqOHY.js';
package/dist/server.js CHANGED
@@ -353,14 +353,23 @@ function debugLog(debug, type, message, data) {
353
353
  }
354
354
  }
355
355
  function getErrorSuggestion(status) {
356
- if (status === 400) return "The request data failed validation. Check field values and types.";
356
+ if (status === 400)
357
+ return "The request data failed validation. Check field values and types.";
357
358
  if (status === 401) return "Please check your authentication credentials.";
358
- if (status === 403) return "Access denied. Check your credentials or permissions.";
359
+ if (status === 403)
360
+ return "Access denied. Check your credentials or permissions.";
359
361
  if (status === 404) return "The requested resource was not found.";
360
362
  if (status === 422) return "The request data failed validation.";
361
363
  if (status >= 500) return "A server error occurred. Please try again later.";
362
364
  return void 0;
363
365
  }
366
+ function isUsageLimitExceededResponse(response) {
367
+ if (response.status !== 429) return false;
368
+ const limit = parseInt(response.headers.get("X-Usage-Limit") || "", 10);
369
+ const current = parseInt(response.headers.get("X-Usage-Current") || "", 10);
370
+ if (!Number.isFinite(limit) || !Number.isFinite(current)) return false;
371
+ return response.headers.get("X-Usage-Exceeded") === "true" || current > limit;
372
+ }
364
373
  async function parseErrorBody(response) {
365
374
  const fallback = {
366
375
  errorMessage: `HTTP ${response.status}: ${response.statusText}`,
@@ -560,7 +569,7 @@ async function httpFetch(url, options) {
560
569
  headers: Object.fromEntries(response.headers.entries())
561
570
  });
562
571
  if (!response.ok) {
563
- if (response.status === 429 && response.headers.get("X-Usage-Limit")) {
572
+ if (isUsageLimitExceededResponse(response)) {
564
573
  const limit = parseInt(
565
574
  response.headers.get("X-Usage-Limit") || "0",
566
575
  10
@@ -577,7 +586,11 @@ async function httpFetch(url, options) {
577
586
  createUsageLimitError(
578
587
  `Monthly API usage limit exceeded (${current.toLocaleString()}/${limit.toLocaleString()})`,
579
588
  { limit, current, remaining },
580
- { url, method: requestInit.method || "GET", attempt: attempt + 1 },
589
+ {
590
+ url,
591
+ method: requestInit.method || "GET",
592
+ attempt: attempt + 1
593
+ },
581
594
  "Monthly API call limit exceeded. Please upgrade your plan.",
582
595
  "Upgrade your tenant plan to increase the monthly API call limit."
583
596
  ),