@carlonicora/nextjs-jsonapi 1.28.0 → 1.29.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.
Files changed (95) hide show
  1. package/dist/{BlockNoteEditor-CAUNVZUF.js → BlockNoteEditor-YBVEOPV4.js} +13 -13
  2. package/dist/{BlockNoteEditor-CAUNVZUF.js.map → BlockNoteEditor-YBVEOPV4.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-EOA4OEVX.mjs → BlockNoteEditor-ZM4YPXHO.mjs} +3 -3
  4. package/dist/billing/index.d.mts +47 -17
  5. package/dist/billing/index.d.ts +47 -17
  6. package/dist/billing/index.js +1241 -1073
  7. package/dist/billing/index.js.map +1 -1
  8. package/dist/billing/index.mjs +1375 -1207
  9. package/dist/billing/index.mjs.map +1 -1
  10. package/dist/{chunk-IXI4GAKB.js → chunk-3X7EEFMN.js} +488 -431
  11. package/dist/chunk-3X7EEFMN.js.map +1 -0
  12. package/dist/{chunk-ORFXBO7F.mjs → chunk-DU64WMZD.mjs} +6 -3
  13. package/dist/chunk-DU64WMZD.mjs.map +1 -0
  14. package/dist/{chunk-TSEU4KZ2.js → chunk-J22NEVSK.js} +21 -18
  15. package/dist/chunk-J22NEVSK.js.map +1 -0
  16. package/dist/{chunk-PYASRX75.mjs → chunk-UCD5CUE4.mjs} +81 -24
  17. package/dist/chunk-UCD5CUE4.mjs.map +1 -0
  18. package/dist/client/index.d.mts +14 -5
  19. package/dist/client/index.d.ts +14 -5
  20. package/dist/client/index.js +5 -3
  21. package/dist/client/index.js.map +1 -1
  22. package/dist/client/index.mjs +4 -2
  23. package/dist/components/index.d.mts +2 -2
  24. package/dist/components/index.d.ts +2 -2
  25. package/dist/components/index.js +3 -3
  26. package/dist/components/index.mjs +2 -2
  27. package/dist/{config-B4pZpLT9.d.ts → config-CHwoRDOp.d.ts} +1 -1
  28. package/dist/{config-DT1K-t6I.d.mts → config-DiWyJzk9.d.mts} +1 -1
  29. package/dist/{content.interface-B2Ldg0vg.d.mts → content.interface-BSpowEiW.d.mts} +1 -1
  30. package/dist/{content.interface-D8NHv3DX.d.ts → content.interface-DFQ7mkpL.d.ts} +1 -1
  31. package/dist/contexts/index.d.mts +2 -2
  32. package/dist/contexts/index.d.ts +2 -2
  33. package/dist/contexts/index.js +3 -3
  34. package/dist/contexts/index.mjs +2 -2
  35. package/dist/core/index.d.mts +39 -37
  36. package/dist/core/index.d.ts +39 -37
  37. package/dist/core/index.js +2 -2
  38. package/dist/core/index.mjs +1 -1
  39. package/dist/index.d.mts +4 -4
  40. package/dist/index.d.ts +4 -4
  41. package/dist/index.js +2 -2
  42. package/dist/index.mjs +1 -1
  43. package/dist/{notification.interface-H0L9WBge.d.ts → notification.interface-CmKmObIU.d.ts} +1 -0
  44. package/dist/{notification.interface-DEn-Yp_b.d.mts → notification.interface-D5MbtfZK.d.mts} +1 -0
  45. package/dist/{s3.service-BNytYanU.d.mts → s3.service-BMT7W6KS.d.mts} +19 -19
  46. package/dist/{s3.service-C7f_Ygz5.d.ts → s3.service-DsXo9nop.d.ts} +19 -19
  47. package/dist/server/index.d.mts +3 -3
  48. package/dist/server/index.d.ts +3 -3
  49. package/dist/server/index.js +3 -3
  50. package/dist/server/index.mjs +1 -1
  51. package/dist/{useSocket-BcnThTD0.d.mts → useSocket-DUqGoPya.d.mts} +1 -1
  52. package/dist/{useSocket-QZTOCzRF.d.ts → useSocket-QuHa0ZmO.d.ts} +1 -1
  53. package/package.json +1 -1
  54. package/src/client/index.ts +1 -0
  55. package/src/components/forms/FormSelect.tsx +2 -1
  56. package/src/features/auth/data/auth.ts +0 -2
  57. package/src/features/billing/components/containers/BillingDashboardContainer.tsx +60 -3
  58. package/src/features/billing/stripe-customer/components/forms/PaymentMethodEditor.tsx +12 -152
  59. package/src/features/billing/stripe-customer/components/forms/PaymentMethodForm.tsx +168 -0
  60. package/src/features/billing/stripe-customer/components/forms/index.ts +1 -0
  61. package/src/features/billing/stripe-price/components/forms/PriceEditor.tsx +19 -1
  62. package/src/features/billing/stripe-product/components/forms/ProductEditor.tsx +2 -2
  63. package/src/features/billing/stripe-subscription/components/containers/SubscriptionsContainer.tsx +24 -235
  64. package/src/features/billing/stripe-subscription/components/details/SubscriptionDetails.tsx +7 -18
  65. package/src/features/billing/stripe-subscription/components/forms/index.ts +0 -1
  66. package/src/features/billing/stripe-subscription/components/lists/SubscriptionsList.tsx +10 -1
  67. package/src/features/billing/stripe-subscription/components/widgets/IntervalToggle.tsx +28 -0
  68. package/src/features/billing/stripe-subscription/components/widgets/ProductPricingList.tsx +128 -0
  69. package/src/features/billing/stripe-subscription/components/widgets/ProductPricingRow.tsx +54 -0
  70. package/src/features/billing/stripe-subscription/components/widgets/SubscriptionConfirmation.tsx +68 -0
  71. package/src/features/billing/stripe-subscription/components/widgets/index.ts +4 -1
  72. package/src/features/billing/stripe-subscription/components/wizards/SubscriptionWizard.tsx +114 -0
  73. package/src/features/billing/stripe-subscription/components/wizards/WizardProgressIndicator.tsx +66 -0
  74. package/src/features/billing/stripe-subscription/components/wizards/WizardStepPaymentMethod.tsx +32 -0
  75. package/src/features/billing/stripe-subscription/components/wizards/WizardStepPlanSelection.tsx +103 -0
  76. package/src/features/billing/stripe-subscription/components/wizards/WizardStepReview.tsx +133 -0
  77. package/src/features/billing/stripe-subscription/components/wizards/index.ts +6 -0
  78. package/src/features/billing/stripe-subscription/hooks/useSubscriptionWizard.ts +217 -0
  79. package/src/features/billing/stripe-subscription/index.ts +3 -2
  80. package/src/features/company/components/details/TokenStatusIndicator.tsx +19 -9
  81. package/src/features/company/data/company.interface.ts +2 -0
  82. package/src/features/company/data/company.ts +7 -0
  83. package/src/features/company/hooks/index.ts +1 -0
  84. package/src/features/company/hooks/useSubscriptionStatus.ts +71 -0
  85. package/src/features/user/components/forms/UserEditor.tsx +1 -1
  86. package/src/features/user/components/lists/AdminUsersList.tsx +1 -1
  87. package/src/features/user/contexts/CurrentUserContext.tsx +1 -1
  88. package/src/features/user/data/user.ts +1 -1
  89. package/dist/chunk-IXI4GAKB.js.map +0 -1
  90. package/dist/chunk-ORFXBO7F.mjs.map +0 -1
  91. package/dist/chunk-PYASRX75.mjs.map +0 -1
  92. package/dist/chunk-TSEU4KZ2.js.map +0 -1
  93. package/src/features/billing/stripe-subscription/components/forms/SubscriptionEditor.tsx +0 -331
  94. package/src/features/billing/stripe-subscription/components/widgets/PricingCardsGrid.tsx +0 -110
  95. /package/dist/{BlockNoteEditor-EOA4OEVX.mjs.map → BlockNoteEditor-ZM4YPXHO.mjs.map} +0 -0
@@ -36,7 +36,7 @@ import {
36
36
  rehydrate,
37
37
  useComposedRefs,
38
38
  useIsMobile
39
- } from "./chunk-ORFXBO7F.mjs";
39
+ } from "./chunk-DU64WMZD.mjs";
40
40
  import {
41
41
  JsonApiContext
42
42
  } from "./chunk-VOXD3ZLY.mjs";
@@ -8697,7 +8697,8 @@ function FormSelect({
8697
8697
  field.onChange(e);
8698
8698
  if (onChange) onChange(e);
8699
8699
  },
8700
- defaultValue: field.value,
8700
+ value: field.value,
8701
+ disabled,
8701
8702
  "data-testid": testId,
8702
8703
  children: [
8703
8704
  /* @__PURE__ */ jsx71(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx71(SelectValue, {}) }),
@@ -9649,6 +9650,7 @@ __name(CompanyContainer, "CompanyContainer");
9649
9650
 
9650
9651
  // src/features/company/components/details/TokenStatusIndicator.tsx
9651
9652
  import { Battery, BatteryFull, BatteryLow, BatteryMedium, PlusCircle } from "lucide-react";
9653
+ import Link2 from "next/link";
9652
9654
  import { useTranslations as useTranslations26 } from "next-intl";
9653
9655
  import { jsx as jsx99, jsxs as jsxs57 } from "react/jsx-runtime";
9654
9656
  function TokenStatusIndicator({ className, size = "md", showExtraPages = true }) {
@@ -9723,13 +9725,16 @@ function TokenStatusIndicator({ className, size = "md", showExtraPages = true })
9723
9725
  "%"
9724
9726
  ] })
9725
9727
  ] }),
9726
- showExtraPages && /* @__PURE__ */ jsxs57("div", { className: "flex items-center justify-between gap-4 border-t pt-1 mt-1", children: [
9728
+ /* @__PURE__ */ jsx99(Link2, { href: "/settings/billing?action=subscribe", className: "w-full flex justify-end my-4", children: /* @__PURE__ */ jsx99(Button, { variant: "outline", size: "sm", children: t("generic.tokens.upgrade_plan", { defaultValue: "Upgrade plan" }) }) }),
9729
+ /* @__PURE__ */ jsx99(Separator, {}),
9730
+ /* @__PURE__ */ jsxs57("div", { className: "flex items-center justify-between gap-4 pt-1 mt-1", children: [
9727
9731
  /* @__PURE__ */ jsxs57("span", { className: "text-muted-foreground", children: [
9728
9732
  t("generic.tokens.available_extra", { defaultValue: "Extra Pages" }),
9729
9733
  ":"
9730
9734
  ] }),
9731
9735
  /* @__PURE__ */ jsx99("span", { className: "font-medium text-blue-500", children: availableExtraTokens })
9732
- ] })
9736
+ ] }),
9737
+ /* @__PURE__ */ jsx99(Link2, { href: "/settings/billing?action=subscribe", className: "w-full flex justify-end my-4", children: /* @__PURE__ */ jsx99(Button, { variant: "outline", size: "sm", children: t("generic.tokens.purchase_extra", { defaultValue: "Purchase additional analysis" }) }) })
9733
9738
  ] })
9734
9739
  ] });
9735
9740
  return /* @__PURE__ */ jsxs57(Tooltip2, { children: [
@@ -11146,7 +11151,7 @@ __name(AllowedUsersDetails, "AllowedUsersDetails");
11146
11151
  import dynamic from "next/dynamic";
11147
11152
  import React15 from "react";
11148
11153
  import { jsx as jsx122 } from "react/jsx-runtime";
11149
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-EOA4OEVX.mjs"), {
11154
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-ZM4YPXHO.mjs"), {
11150
11155
  ssr: false
11151
11156
  });
11152
11157
  var BlockNoteEditorContainer = React15.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -11599,14 +11604,65 @@ var useCompanyTableStructure = /* @__PURE__ */ __name((params) => {
11599
11604
  return useMemo14(() => ({ data: tableData, columns }), [tableData, columns]);
11600
11605
  }, "useCompanyTableStructure");
11601
11606
 
11607
+ // src/features/company/hooks/useSubscriptionStatus.ts
11608
+ import { useMemo as useMemo15 } from "react";
11609
+ var TRIAL_DAYS = 14;
11610
+ var GRACE_DAYS = 3;
11611
+ function useSubscriptionStatus() {
11612
+ const { company, currentUser } = useCurrentUserContext();
11613
+ return useMemo15(() => {
11614
+ if (currentUser === null) {
11615
+ return {
11616
+ status: "loading",
11617
+ trialEndsAt: null,
11618
+ daysRemaining: 0,
11619
+ isGracePeriod: false,
11620
+ isBlocked: false
11621
+ };
11622
+ }
11623
+ if (!company) {
11624
+ return {
11625
+ status: "expired",
11626
+ trialEndsAt: null,
11627
+ daysRemaining: 0,
11628
+ isGracePeriod: false,
11629
+ isBlocked: true
11630
+ };
11631
+ }
11632
+ if (company.isActiveSubscription) {
11633
+ return {
11634
+ status: "active",
11635
+ trialEndsAt: null,
11636
+ daysRemaining: 0,
11637
+ isGracePeriod: false,
11638
+ isBlocked: false
11639
+ };
11640
+ }
11641
+ const createdAt = new Date(company.createdAt);
11642
+ const trialEndsAt = new Date(createdAt);
11643
+ trialEndsAt.setDate(trialEndsAt.getDate() + TRIAL_DAYS);
11644
+ const now = /* @__PURE__ */ new Date();
11645
+ const msRemaining = trialEndsAt.getTime() - now.getTime();
11646
+ const daysRemaining = Math.ceil(msRemaining / (1e3 * 60 * 60 * 24));
11647
+ return {
11648
+ status: daysRemaining > 0 ? "trial" : "expired",
11649
+ trialEndsAt,
11650
+ daysRemaining: Math.max(0, daysRemaining),
11651
+ isGracePeriod: daysRemaining > 0 && daysRemaining <= GRACE_DAYS,
11652
+ isBlocked: daysRemaining <= 0
11653
+ };
11654
+ }, [company, currentUser]);
11655
+ }
11656
+ __name(useSubscriptionStatus, "useSubscriptionStatus");
11657
+
11602
11658
  // src/features/role/hooks/useRoleTableStructure.tsx
11603
11659
  import { useTranslations as useTranslations43 } from "next-intl";
11604
- import { useMemo as useMemo15 } from "react";
11660
+ import { useMemo as useMemo16 } from "react";
11605
11661
  import { Fragment as Fragment15, jsx as jsx131 } from "react/jsx-runtime";
11606
11662
  var useRoleTableStructure = /* @__PURE__ */ __name((params) => {
11607
11663
  const t = useTranslations43();
11608
11664
  const generateUrl = usePageUrlGenerator();
11609
- const tableData = useMemo15(() => {
11665
+ const tableData = useMemo16(() => {
11610
11666
  return params.data.map((role) => {
11611
11667
  const entry = {
11612
11668
  jsonApiData: role
@@ -11648,10 +11704,10 @@ var useRoleTableStructure = /* @__PURE__ */ __name((params) => {
11648
11704
  title: t(`generic.date.create`)
11649
11705
  })
11650
11706
  };
11651
- const columns = useMemo15(() => {
11707
+ const columns = useMemo16(() => {
11652
11708
  return params.fields.map((field) => fieldColumnMap[field]?.()).filter((col) => col !== void 0);
11653
11709
  }, [params.fields, fieldColumnMap, t, generateUrl]);
11654
- return useMemo15(() => ({ data: tableData, columns }), [tableData, columns]);
11710
+ return useMemo16(() => ({ data: tableData, columns }), [tableData, columns]);
11655
11711
  }, "useRoleTableStructure");
11656
11712
 
11657
11713
  // src/features/user/hooks/useUserSearch.ts
@@ -11701,12 +11757,12 @@ var useUserSearch = /* @__PURE__ */ __name(() => {
11701
11757
 
11702
11758
  // src/features/user/hooks/useUserTableStructure.tsx
11703
11759
  import { useTranslations as useTranslations44 } from "next-intl";
11704
- import { useMemo as useMemo16 } from "react";
11760
+ import { useMemo as useMemo17 } from "react";
11705
11761
  import { Fragment as Fragment16, jsx as jsx132, jsxs as jsxs74 } from "react/jsx-runtime";
11706
11762
  var useUserTableStructure = /* @__PURE__ */ __name((params) => {
11707
11763
  const t = useTranslations44();
11708
11764
  const generateUrl = usePageUrlGenerator();
11709
- const tableData = useMemo16(() => {
11765
+ const tableData = useMemo17(() => {
11710
11766
  return params.data.map((user) => {
11711
11767
  const entry = {
11712
11768
  jsonApiData: user
@@ -11791,20 +11847,20 @@ var useUserTableStructure = /* @__PURE__ */ __name((params) => {
11791
11847
  title: t(`generic.date.create`)
11792
11848
  })
11793
11849
  };
11794
- const columns = useMemo16(() => {
11850
+ const columns = useMemo17(() => {
11795
11851
  return params.fields.map((field) => fieldColumnMap[field]?.()).filter((col) => col !== void 0);
11796
11852
  }, [params.fields, fieldColumnMap, t, generateUrl]);
11797
- return useMemo16(() => ({ data: tableData, columns }), [tableData, columns]);
11853
+ return useMemo17(() => ({ data: tableData, columns }), [tableData, columns]);
11798
11854
  }, "useUserTableStructure");
11799
11855
 
11800
11856
  // src/features/content/hooks/useContentTableStructure.tsx
11801
11857
  import { useTranslations as useTranslations45 } from "next-intl";
11802
- import { useMemo as useMemo17 } from "react";
11858
+ import { useMemo as useMemo18 } from "react";
11803
11859
  import { Fragment as Fragment17, jsx as jsx133, jsxs as jsxs75 } from "react/jsx-runtime";
11804
11860
  var useContentTableStructure = /* @__PURE__ */ __name((params) => {
11805
11861
  const t = useTranslations45();
11806
11862
  const generateUrl = usePageUrlGenerator();
11807
- const tableData = useMemo17(() => {
11863
+ const tableData = useMemo18(() => {
11808
11864
  return params.data.map((content) => {
11809
11865
  const entry = {
11810
11866
  jsonApiData: content
@@ -11889,7 +11945,7 @@ var useContentTableStructure = /* @__PURE__ */ __name((params) => {
11889
11945
  title: t(`generic.date.update`)
11890
11946
  })
11891
11947
  };
11892
- const columns = useMemo17(() => {
11948
+ const columns = useMemo18(() => {
11893
11949
  return params.fields.map((field) => {
11894
11950
  const localHandler = fieldColumnMap[field];
11895
11951
  if (localHandler) return localHandler();
@@ -11898,7 +11954,7 @@ var useContentTableStructure = /* @__PURE__ */ __name((params) => {
11898
11954
  return void 0;
11899
11955
  }).filter((col) => col !== void 0);
11900
11956
  }, [params.fields, fieldColumnMap, t, generateUrl, params.context?.customCells]);
11901
- return useMemo17(() => ({ data: tableData, columns }), [tableData, columns]);
11957
+ return useMemo18(() => ({ data: tableData, columns }), [tableData, columns]);
11902
11958
  }, "useContentTableStructure");
11903
11959
 
11904
11960
  // src/features/oauth/hooks/useOAuthClients.ts
@@ -12197,7 +12253,7 @@ registerTableGenerator("companies", useCompanyTableStructure);
12197
12253
  // src/components/tables/ContentListTable.tsx
12198
12254
  import { flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
12199
12255
  import { ChevronLeft, ChevronRight } from "lucide-react";
12200
- import { memo, useMemo as useMemo18 } from "react";
12256
+ import { memo, useMemo as useMemo19 } from "react";
12201
12257
 
12202
12258
  // src/components/tables/ContentTableSearch.tsx
12203
12259
  import { RefreshCw, Search, X } from "lucide-react";
@@ -12302,7 +12358,7 @@ var ContentListTable = memo(/* @__PURE__ */ __name(function ContentListTable2(pr
12302
12358
  dataRetriever: data,
12303
12359
  context: props.context
12304
12360
  });
12305
- const columnVisibility = useMemo18(
12361
+ const columnVisibility = useMemo19(
12306
12362
  () => fields.reduce(
12307
12363
  (acc, columnId) => {
12308
12364
  acc[columnId] = true;
@@ -12377,7 +12433,7 @@ var ContentListTable = memo(/* @__PURE__ */ __name(function ContentListTable2(pr
12377
12433
  import Image8 from "next/image";
12378
12434
 
12379
12435
  // src/features/auth/contexts/AuthContext.tsx
12380
- import { createContext as createContext15, useContext as useContext16, useMemo as useMemo19, useState as useState46 } from "react";
12436
+ import { createContext as createContext15, useContext as useContext16, useMemo as useMemo20, useState as useState46 } from "react";
12381
12437
 
12382
12438
  // src/features/auth/components/forms/Register.tsx
12383
12439
  import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
@@ -12517,7 +12573,7 @@ var AuthContextProvider = /* @__PURE__ */ __name(({
12517
12573
  }) => {
12518
12574
  const [componentType, setComponentType] = useState46(initialComponentType);
12519
12575
  const [params, setParams] = useState46(initialParams);
12520
- const activeComponent = useMemo19(() => {
12576
+ const activeComponent = useMemo20(() => {
12521
12577
  if (componentType === void 0) return null;
12522
12578
  switch (componentType) {
12523
12579
  case 0 /* Login */:
@@ -13301,7 +13357,7 @@ __name(NotificationsListContainer, "NotificationsListContainer");
13301
13357
  // src/features/notification/components/modals/NotificationModal.tsx
13302
13358
  import { BellIcon } from "lucide-react";
13303
13359
  import { useTranslations as useTranslations59 } from "next-intl";
13304
- import { Fragment as Fragment28, useCallback as useCallback21, useEffect as useEffect44, useMemo as useMemo20, useRef as useRef18, useState as useState52 } from "react";
13360
+ import { Fragment as Fragment28, useCallback as useCallback21, useEffect as useEffect44, useMemo as useMemo21, useRef as useRef18, useState as useState52 } from "react";
13305
13361
  import { toast as toast9 } from "sonner";
13306
13362
  import { jsx as jsx152, jsxs as jsxs89 } from "react/jsx-runtime";
13307
13363
  function NotificationModalContent({ isOpen, setIsOpen }) {
@@ -13343,7 +13399,7 @@ function NotificationModalContent({ isOpen, setIsOpen }) {
13343
13399
  }
13344
13400
  return !breaker.isOpen;
13345
13401
  }, []);
13346
- const { unreadCount, unreadIds } = useMemo20(() => {
13402
+ const { unreadCount, unreadIds } = useMemo21(() => {
13347
13403
  const unreadNotifications2 = notifications.filter((notif) => !notif.isRead);
13348
13404
  return {
13349
13405
  unreadCount: unreadNotifications2.length,
@@ -15043,10 +15099,11 @@ export {
15043
15099
  useNotificationSync,
15044
15100
  usePageTracker,
15045
15101
  useSocket,
15102
+ useSubscriptionStatus,
15046
15103
  useUserSearch,
15047
15104
  useUserTableStructure,
15048
15105
  useContentTableStructure,
15049
15106
  useOAuthClients,
15050
15107
  useOAuthClient
15051
15108
  };
15052
- //# sourceMappingURL=chunk-PYASRX75.mjs.map
15109
+ //# sourceMappingURL=chunk-UCD5CUE4.mjs.map