@carlonicora/nextjs-jsonapi 2.2.1 → 2.2.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 (50) hide show
  1. package/dist/{BlockNoteEditor-2LGNETXD.mjs → BlockNoteEditor-ADT6II2V.mjs} +5 -5
  2. package/dist/{BlockNoteEditor-EAEGUVFI.js → BlockNoteEditor-QTIDATPF.js} +20 -20
  3. package/dist/{BlockNoteEditor-EAEGUVFI.js.map → BlockNoteEditor-QTIDATPF.js.map} +1 -1
  4. package/dist/{JsonApiRequest-F5LBESSA.mjs → JsonApiRequest-3UWVIIFL.mjs} +2 -2
  5. package/dist/JsonApiRequest-QRU3IPIU.js +26 -0
  6. package/dist/{JsonApiRequest-YAPUG4ND.js.map → JsonApiRequest-QRU3IPIU.js.map} +1 -1
  7. package/dist/billing/index.js +447 -447
  8. package/dist/billing/index.js.map +1 -1
  9. package/dist/billing/index.mjs +62 -62
  10. package/dist/billing/index.mjs.map +1 -1
  11. package/dist/{chunk-B34NBMKV.mjs → chunk-7DJOQTNN.mjs} +3 -3
  12. package/dist/{chunk-R57FRJ6H.mjs → chunk-DLTMYGLR.mjs} +5 -5
  13. package/dist/{chunk-Z2CB63VG.mjs → chunk-E5YA5Z5X.mjs} +2 -2
  14. package/dist/chunk-E5YA5Z5X.mjs.map +1 -0
  15. package/dist/{chunk-4I2W336O.js → chunk-F3BPNQDB.js} +737 -737
  16. package/dist/{chunk-4I2W336O.js.map → chunk-F3BPNQDB.js.map} +1 -1
  17. package/dist/{chunk-QWCAOLBD.js → chunk-FPO4DLZN.js} +12 -12
  18. package/dist/{chunk-QWCAOLBD.js.map → chunk-FPO4DLZN.js.map} +1 -1
  19. package/dist/{chunk-DQJ5C5TV.js → chunk-KSU6CCW6.js} +30 -30
  20. package/dist/{chunk-DQJ5C5TV.js.map → chunk-KSU6CCW6.js.map} +1 -1
  21. package/dist/{chunk-BLKR2Q7F.js → chunk-LANOKEFZ.js} +9 -9
  22. package/dist/{chunk-BLKR2Q7F.js.map → chunk-LANOKEFZ.js.map} +1 -1
  23. package/dist/{chunk-OC7F4L7K.mjs → chunk-YEPE2HT6.mjs} +6 -6
  24. package/dist/client/index.js +5 -5
  25. package/dist/client/index.mjs +4 -4
  26. package/dist/components/index.js +5 -5
  27. package/dist/components/index.mjs +4 -4
  28. package/dist/contexts/index.js +5 -5
  29. package/dist/contexts/index.mjs +4 -4
  30. package/dist/core/index.js +3 -3
  31. package/dist/core/index.mjs +2 -2
  32. package/dist/features/help/index.js +38 -38
  33. package/dist/features/help/index.mjs +4 -4
  34. package/dist/features/tokenusage/index.js +72 -72
  35. package/dist/features/tokenusage/index.mjs +4 -4
  36. package/dist/index.js +4 -4
  37. package/dist/index.mjs +3 -3
  38. package/dist/server/index.js +12 -12
  39. package/dist/server/index.mjs +2 -2
  40. package/package.json +1 -1
  41. package/src/core/utils/__tests__/translateResponse.test.ts +64 -0
  42. package/src/core/utils/translateResponse.ts +4 -1
  43. package/src/features/billing/components/containers/BillingDashboardContainer.tsx +71 -68
  44. package/dist/JsonApiRequest-YAPUG4ND.js +0 -26
  45. package/dist/chunk-Z2CB63VG.mjs.map +0 -1
  46. /package/dist/{BlockNoteEditor-2LGNETXD.mjs.map → BlockNoteEditor-ADT6II2V.mjs.map} +0 -0
  47. /package/dist/{JsonApiRequest-F5LBESSA.mjs.map → JsonApiRequest-3UWVIIFL.mjs.map} +0 -0
  48. /package/dist/{chunk-B34NBMKV.mjs.map → chunk-7DJOQTNN.mjs.map} +0 -0
  49. /package/dist/{chunk-R57FRJ6H.mjs.map → chunk-DLTMYGLR.mjs.map} +0 -0
  50. /package/dist/{chunk-OC7F4L7K.mjs.map → chunk-YEPE2HT6.mjs.map} +0 -0
@@ -48,11 +48,11 @@ import {
48
48
  TabsList,
49
49
  TabsTrigger,
50
50
  useCurrentUserContext
51
- } from "../chunk-OC7F4L7K.mjs";
51
+ } from "../chunk-YEPE2HT6.mjs";
52
52
  import {
53
53
  getRoleId,
54
54
  getStripePublishableKey
55
- } from "../chunk-B34NBMKV.mjs";
55
+ } from "../chunk-7DJOQTNN.mjs";
56
56
  import {
57
57
  FeatureService,
58
58
  StripeCustomerService,
@@ -63,10 +63,10 @@ import {
63
63
  StripeSubscriptionService,
64
64
  StripeUsageService,
65
65
  cn
66
- } from "../chunk-R57FRJ6H.mjs";
66
+ } from "../chunk-DLTMYGLR.mjs";
67
67
  import "../chunk-AUXK7QSA.mjs";
68
68
  import "../chunk-C7C7VY4F.mjs";
69
- import "../chunk-Z2CB63VG.mjs";
69
+ import "../chunk-E5YA5Z5X.mjs";
70
70
  import "../chunk-VOXD3ZLY.mjs";
71
71
  import {
72
72
  __name
@@ -2766,70 +2766,70 @@ function BillingDashboardContainer() {
2766
2766
  setNoCustomerExists(false);
2767
2767
  } catch (error) {
2768
2768
  console.error("[BillingDashboard] Failed to load customer:", error);
2769
- const errorMessage = error instanceof Error ? error.message : String(error);
2770
- if (errorMessage.includes("Not Found") || errorMessage.includes("not found")) {
2769
+ if (error?.status === 404) {
2771
2770
  setNoCustomerExists(true);
2772
- setLoading({
2773
- customer: false,
2774
- subscriptions: false,
2775
- paymentMethods: false,
2776
- invoices: false,
2777
- usage: false
2778
- });
2779
- return;
2771
+ } else {
2772
+ setErrors((prev) => ({ ...prev, customer: "Failed to load billing account" }));
2780
2773
  }
2781
- setErrors((prev) => ({ ...prev, customer: "Failed to load billing account" }));
2782
2774
  } finally {
2783
2775
  setLoading((prev) => ({ ...prev, customer: false }));
2784
2776
  }
2785
- if (customer) {
2786
- const fetchSubscriptions = /* @__PURE__ */ __name(async () => {
2787
- try {
2788
- const subscriptions2 = await StripeSubscriptionService.listSubscriptions();
2789
- setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
2790
- setErrors((prev) => ({ ...prev, subscriptions: null }));
2791
- return subscriptions2;
2792
- } catch (error) {
2793
- console.error("[BillingDashboard] Failed to load subscriptions:", error);
2794
- setErrors((prev) => ({ ...prev, subscriptions: "Failed to load subscriptions" }));
2795
- return [];
2796
- } finally {
2797
- setLoading((prev) => ({ ...prev, subscriptions: false }));
2798
- }
2799
- }, "fetchSubscriptions");
2800
- const fetchPaymentMethods = /* @__PURE__ */ __name(async () => {
2801
- try {
2802
- const paymentMethods = await StripeCustomerService.listPaymentMethods();
2803
- setData((prev) => ({ ...prev, paymentMethods }));
2804
- setErrors((prev) => ({ ...prev, paymentMethods: null }));
2805
- } catch (error) {
2806
- console.error("[BillingDashboard] Failed to load payment methods:", error);
2807
- setErrors((prev) => ({ ...prev, paymentMethods: "Failed to load payment methods" }));
2808
- } finally {
2809
- setLoading((prev) => ({ ...prev, paymentMethods: false }));
2810
- }
2811
- }, "fetchPaymentMethods");
2812
- const fetchInvoices = /* @__PURE__ */ __name(async () => {
2813
- try {
2814
- const invoices = await StripeInvoiceService.listInvoices();
2815
- setData((prev) => ({ ...prev, invoices }));
2816
- setErrors((prev) => ({ ...prev, invoices: null }));
2817
- } catch (error) {
2818
- console.error("[BillingDashboard] Failed to load invoices:", error);
2819
- setErrors((prev) => ({ ...prev, invoices: "Failed to load invoices" }));
2820
- } finally {
2821
- setLoading((prev) => ({ ...prev, invoices: false }));
2822
- }
2823
- }, "fetchInvoices");
2824
- const [subscriptions] = await Promise.all([fetchSubscriptions(), fetchPaymentMethods(), fetchInvoices()]);
2825
- const hasMetered = subscriptions.some(
2826
- (sub) => sub.price?.recurring?.usageType === "metered"
2827
- );
2828
- if (hasMetered) {
2829
- await fetchUsageData();
2830
- } else {
2831
- setLoading((prev) => ({ ...prev, usage: false }));
2777
+ if (!customer) {
2778
+ setLoading({
2779
+ customer: false,
2780
+ subscriptions: false,
2781
+ paymentMethods: false,
2782
+ invoices: false,
2783
+ usage: false
2784
+ });
2785
+ return;
2786
+ }
2787
+ const fetchSubscriptions = /* @__PURE__ */ __name(async () => {
2788
+ try {
2789
+ const subscriptions2 = await StripeSubscriptionService.listSubscriptions();
2790
+ setData((prev) => ({ ...prev, subscriptions: subscriptions2 }));
2791
+ setErrors((prev) => ({ ...prev, subscriptions: null }));
2792
+ return subscriptions2;
2793
+ } catch (error) {
2794
+ console.error("[BillingDashboard] Failed to load subscriptions:", error);
2795
+ setErrors((prev) => ({ ...prev, subscriptions: "Failed to load subscriptions" }));
2796
+ return [];
2797
+ } finally {
2798
+ setLoading((prev) => ({ ...prev, subscriptions: false }));
2832
2799
  }
2800
+ }, "fetchSubscriptions");
2801
+ const fetchPaymentMethods = /* @__PURE__ */ __name(async () => {
2802
+ try {
2803
+ const paymentMethods = await StripeCustomerService.listPaymentMethods();
2804
+ setData((prev) => ({ ...prev, paymentMethods }));
2805
+ setErrors((prev) => ({ ...prev, paymentMethods: null }));
2806
+ } catch (error) {
2807
+ console.error("[BillingDashboard] Failed to load payment methods:", error);
2808
+ setErrors((prev) => ({ ...prev, paymentMethods: "Failed to load payment methods" }));
2809
+ } finally {
2810
+ setLoading((prev) => ({ ...prev, paymentMethods: false }));
2811
+ }
2812
+ }, "fetchPaymentMethods");
2813
+ const fetchInvoices = /* @__PURE__ */ __name(async () => {
2814
+ try {
2815
+ const invoices = await StripeInvoiceService.listInvoices();
2816
+ setData((prev) => ({ ...prev, invoices }));
2817
+ setErrors((prev) => ({ ...prev, invoices: null }));
2818
+ } catch (error) {
2819
+ console.error("[BillingDashboard] Failed to load invoices:", error);
2820
+ setErrors((prev) => ({ ...prev, invoices: "Failed to load invoices" }));
2821
+ } finally {
2822
+ setLoading((prev) => ({ ...prev, invoices: false }));
2823
+ }
2824
+ }, "fetchInvoices");
2825
+ const [subscriptions] = await Promise.all([fetchSubscriptions(), fetchPaymentMethods(), fetchInvoices()]);
2826
+ const hasMetered = subscriptions.some(
2827
+ (sub) => sub.price?.recurring?.usageType === "metered"
2828
+ );
2829
+ if (hasMetered) {
2830
+ await fetchUsageData();
2831
+ } else {
2832
+ setLoading((prev) => ({ ...prev, usage: false }));
2833
2833
  }
2834
2834
  }, []);
2835
2835
  const handleCreateCustomer = /* @__PURE__ */ __name(async () => {