@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,4 +1,4 @@
1
- import { c as Config } from './payload-types-BaK4zCQ8.cjs';
1
+ import { c as Config } from './payload-types-BF8VVFt6.cjs';
2
2
 
3
3
  /**
4
4
  * Collection type derived from Payload Config.
@@ -9,7 +9,7 @@ type Collection = keyof Config['collections'];
9
9
  * Internal collections that should not be exposed via SDK.
10
10
  * Includes Payload system collections and admin-only collections.
11
11
  */
12
- declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
12
+ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
13
13
  type InternalCollection = (typeof INTERNAL_COLLECTIONS)[number];
14
14
  /**
15
15
  * Array of all public collection names for runtime use (e.g., Zod enum validation).
@@ -1,4 +1,4 @@
1
- import { c as Config } from './payload-types-BaK4zCQ8.js';
1
+ import { c as Config } from './payload-types-BF8VVFt6.js';
2
2
 
3
3
  /**
4
4
  * Collection type derived from Payload Config.
@@ -9,7 +9,7 @@ type Collection = keyof Config['collections'];
9
9
  * Internal collections that should not be exposed via SDK.
10
10
  * Includes Payload system collections and admin-only collections.
11
11
  */
12
- declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
12
+ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
13
13
  type InternalCollection = (typeof INTERNAL_COLLECTIONS)[number];
14
14
  /**
15
15
  * Array of all public collection names for runtime use (e.g., Zod enum validation).
package/dist/index.cjs CHANGED
@@ -574,14 +574,23 @@ function debugLog(debug, type, message, data) {
574
574
  }
575
575
  }
576
576
  function getErrorSuggestion(status) {
577
- if (status === 400) return "The request data failed validation. Check field values and types.";
577
+ if (status === 400)
578
+ return "The request data failed validation. Check field values and types.";
578
579
  if (status === 401) return "Please check your authentication credentials.";
579
- if (status === 403) return "Access denied. Check your credentials or permissions.";
580
+ if (status === 403)
581
+ return "Access denied. Check your credentials or permissions.";
580
582
  if (status === 404) return "The requested resource was not found.";
581
583
  if (status === 422) return "The request data failed validation.";
582
584
  if (status >= 500) return "A server error occurred. Please try again later.";
583
585
  return void 0;
584
586
  }
587
+ function isUsageLimitExceededResponse(response) {
588
+ if (response.status !== 429) return false;
589
+ const limit = parseInt(response.headers.get("X-Usage-Limit") || "", 10);
590
+ const current = parseInt(response.headers.get("X-Usage-Current") || "", 10);
591
+ if (!Number.isFinite(limit) || !Number.isFinite(current)) return false;
592
+ return response.headers.get("X-Usage-Exceeded") === "true" || current > limit;
593
+ }
585
594
  async function parseErrorBody(response) {
586
595
  const fallback = {
587
596
  errorMessage: `HTTP ${response.status}: ${response.statusText}`,
@@ -781,7 +790,7 @@ async function httpFetch(url, options) {
781
790
  headers: Object.fromEntries(response.headers.entries())
782
791
  });
783
792
  if (!response.ok) {
784
- if (response.status === 429 && response.headers.get("X-Usage-Limit")) {
793
+ if (isUsageLimitExceededResponse(response)) {
785
794
  const limit = parseInt(
786
795
  response.headers.get("X-Usage-Limit") || "0",
787
796
  10
@@ -798,7 +807,11 @@ async function httpFetch(url, options) {
798
807
  createUsageLimitError(
799
808
  `Monthly API usage limit exceeded (${current.toLocaleString()}/${limit.toLocaleString()})`,
800
809
  { limit, current, remaining },
801
- { url, method: requestInit.method || "GET", attempt: attempt + 1 },
810
+ {
811
+ url,
812
+ method: requestInit.method || "GET",
813
+ attempt: attempt + 1
814
+ },
802
815
  "Monthly API call limit exceeded. Please upgrade your plan.",
803
816
  "Upgrade your tenant plan to increase the monthly API call limit."
804
817
  ),
@@ -1243,6 +1256,7 @@ var INTERNAL_COLLECTIONS = [
1243
1256
  "email-logs",
1244
1257
  "api-usage",
1245
1258
  "tenant-analytics-daily",
1259
+ "tenant-web-analytics-config",
1246
1260
  "analytics-event-schemas",
1247
1261
  "subscriptions",
1248
1262
  "billing-history",
@@ -1250,6 +1264,7 @@ var INTERNAL_COLLECTIONS = [
1250
1264
  "api-keys",
1251
1265
  "personal-access-tokens",
1252
1266
  "tenant-entitlements",
1267
+ "tenant-purge-jobs",
1253
1268
  "direct-upload-sessions",
1254
1269
  "webhook-events",
1255
1270
  "webhook-deliveries",