@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.
@@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-D7HtUpqt.cjs';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
3
- import { P as PublicCollection } from './const-C8UhtzLn.cjs';
4
- import './payload-types-BaK4zCQ8.cjs';
3
+ import { P as PublicCollection } from './const-CEiFBZMW.cjs';
4
+ import './payload-types-BF8VVFt6.cjs';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
@@ -1,7 +1,7 @@
1
1
  import { R as RealtimeEvent } from './realtime-D7HtUpqt.js';
2
2
  export { a as RealtimeConnection, b as RealtimeListener } from './realtime-D7HtUpqt.js';
3
- import { P as PublicCollection } from './const-Bs-QcTj0.js';
4
- import './payload-types-BaK4zCQ8.js';
3
+ import { P as PublicCollection } from './const-R3AyqOHY.js';
4
+ import './payload-types-BF8VVFt6.js';
5
5
 
6
6
  interface UseRealtimeQueryOptions {
7
7
  /** Filter events to specific collections. Empty/undefined = all collections. */
@@ -1,10 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, InfiniteData } from '@tanstack/react-query';
3
- import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BaK4zCQ8.cjs';
3
+ import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BF8VVFt6.cjs';
4
4
  import { Sort, Where } from 'payload';
5
5
  import { Metadata } from 'next';
6
- import { C as CollectionType } from './types-BH-YBrFs.cjs';
7
- import { P as PublicCollection, S as ServerCollection } from './const-C8UhtzLn.cjs';
6
+ import { C as CollectionType } from './types-lPRgx_rC.cjs';
7
+ import { P as PublicCollection, S as ServerCollection } from './const-CEiFBZMW.cjs';
8
8
 
9
9
  declare function resolveApiUrl(): string;
10
10
  interface ClientConfig {
@@ -1,10 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, InfiniteData } from '@tanstack/react-query';
3
- import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BaK4zCQ8.js';
3
+ import { O as Order, d as Cart, e as CartItem, f as Product, l as OrderItem, m as Transaction, n as Fulfillment, o as Return } from './payload-types-BF8VVFt6.js';
4
4
  import { Sort, Where } from 'payload';
5
5
  import { Metadata } from 'next';
6
- import { C as CollectionType } from './types-DjaaBExv.js';
7
- import { P as PublicCollection, S as ServerCollection } from './const-Bs-QcTj0.js';
6
+ import { C as CollectionType } from './types-CZ1laT6s.js';
7
+ import { P as PublicCollection, S as ServerCollection } from './const-R3AyqOHY.js';
8
8
 
9
9
  declare function resolveApiUrl(): string;
10
10
  interface ClientConfig {
package/dist/server.cjs CHANGED
@@ -385,14 +385,23 @@ function debugLog(debug, type, message, data) {
385
385
  }
386
386
  }
387
387
  function getErrorSuggestion(status) {
388
- if (status === 400) return "The request data failed validation. Check field values and types.";
388
+ if (status === 400)
389
+ return "The request data failed validation. Check field values and types.";
389
390
  if (status === 401) return "Please check your authentication credentials.";
390
- if (status === 403) return "Access denied. Check your credentials or permissions.";
391
+ if (status === 403)
392
+ return "Access denied. Check your credentials or permissions.";
391
393
  if (status === 404) return "The requested resource was not found.";
392
394
  if (status === 422) return "The request data failed validation.";
393
395
  if (status >= 500) return "A server error occurred. Please try again later.";
394
396
  return void 0;
395
397
  }
398
+ function isUsageLimitExceededResponse(response) {
399
+ if (response.status !== 429) return false;
400
+ const limit = parseInt(response.headers.get("X-Usage-Limit") || "", 10);
401
+ const current = parseInt(response.headers.get("X-Usage-Current") || "", 10);
402
+ if (!Number.isFinite(limit) || !Number.isFinite(current)) return false;
403
+ return response.headers.get("X-Usage-Exceeded") === "true" || current > limit;
404
+ }
396
405
  async function parseErrorBody(response) {
397
406
  const fallback = {
398
407
  errorMessage: `HTTP ${response.status}: ${response.statusText}`,
@@ -592,7 +601,7 @@ async function httpFetch(url, options) {
592
601
  headers: Object.fromEntries(response.headers.entries())
593
602
  });
594
603
  if (!response.ok) {
595
- if (response.status === 429 && response.headers.get("X-Usage-Limit")) {
604
+ if (isUsageLimitExceededResponse(response)) {
596
605
  const limit = parseInt(
597
606
  response.headers.get("X-Usage-Limit") || "0",
598
607
  10
@@ -609,7 +618,11 @@ async function httpFetch(url, options) {
609
618
  createUsageLimitError(
610
619
  `Monthly API usage limit exceeded (${current.toLocaleString()}/${limit.toLocaleString()})`,
611
620
  { limit, current, remaining },
612
- { url, method: requestInit.method || "GET", attempt: attempt + 1 },
621
+ {
622
+ url,
623
+ method: requestInit.method || "GET",
624
+ attempt: attempt + 1
625
+ },
613
626
  "Monthly API call limit exceeded. Please upgrade your plan.",
614
627
  "Upgrade your tenant plan to increase the monthly API call limit."
615
628
  ),