autumn-js 0.0.16 → 0.0.22

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 (47) hide show
  1. package/README.md +1 -2
  2. package/dist/next/AutumnProvider.js +3 -1
  3. package/dist/next/AutumnProvider.mjs +3 -1
  4. package/dist/next/client/AutumnProvider.d.mts +5 -1
  5. package/dist/next/client/AutumnProvider.d.ts +5 -1
  6. package/dist/next/client/AutumnProvider.js +15 -28
  7. package/dist/next/client/AutumnProvider.mjs +15 -28
  8. package/dist/next/client/{error-BUtm1Pks.d.mts → error-CG2LXoa7.d.mts} +1 -1
  9. package/dist/next/client/{error-BUtm1Pks.d.ts → error-CG2LXoa7.d.ts} +1 -1
  10. package/dist/next/client/hooks/useAutumn.d.mts +1 -1
  11. package/dist/next/client/hooks/useAutumn.d.ts +1 -1
  12. package/dist/next/client/hooks/useCustomer.d.mts +1 -1
  13. package/dist/next/client/hooks/useCustomer.d.ts +1 -1
  14. package/dist/next/client/hooks/useCustomer.js +5 -2
  15. package/dist/next/client/hooks/useCustomer.mjs +5 -2
  16. package/dist/next/client/hooks/usePricingTable.d.mts +15 -2
  17. package/dist/next/client/hooks/usePricingTable.d.ts +15 -2
  18. package/dist/next/client/hooks/usePricingTable.js +5 -2
  19. package/dist/next/client/hooks/usePricingTable.mjs +5 -2
  20. package/dist/next/client/types.d.mts +11 -1
  21. package/dist/next/client/types.d.ts +11 -1
  22. package/dist/next/client/types.js +20 -0
  23. package/dist/next/client/types.mjs +20 -0
  24. package/dist/next/index.d.mts +26 -5
  25. package/dist/next/index.d.ts +26 -5
  26. package/dist/next/server/auth/clerk-wrapper.js +4 -1
  27. package/dist/next/server/auth/clerk-wrapper.mjs +4 -1
  28. package/dist/next/server/auth/handleAuthProvider.js +1 -8
  29. package/dist/next/server/auth/handleAuthProvider.mjs +1 -8
  30. package/dist/next/server/auth/supabase-wrapper.js +5 -2
  31. package/dist/next/server/auth/supabase-wrapper.mjs +5 -2
  32. package/dist/next/server/cusActions.d.mts +1 -1
  33. package/dist/next/server/cusActions.d.ts +1 -1
  34. package/dist/next/server/{response-CtOCrwQ7.d.mts → response-CmSY57k6.d.mts} +1 -1
  35. package/dist/next/server/{response-CtOCrwQ7.d.ts → response-CmSY57k6.d.ts} +1 -1
  36. package/dist/next/server/utils.d.mts +1 -1
  37. package/dist/next/server/utils.d.ts +1 -1
  38. package/dist/next/webpack-ignore.js +33 -0
  39. package/dist/next/webpack-ignore.mjs +13 -0
  40. package/dist/sdk/index.d.mts +1 -1
  41. package/dist/sdk/index.d.ts +1 -1
  42. package/dist/sdk/index.js +2 -1
  43. package/dist/sdk/index.mjs +2 -1
  44. package/dist/utils/encryptUtils.js +330 -3
  45. package/dist/utils/encryptUtils.mjs +330 -3
  46. package/package.json +1 -1
  47. package/tsconfig.json +0 -25
package/README.md CHANGED
@@ -76,11 +76,10 @@ export default function RootLayout({
76
76
  import { useAutumn } from 'autumn-js/next'
77
77
 
78
78
  export default function BillingPage() {
79
- const { customer, attach, openBillingPortal } = useAutumn()
79
+ const { attach, openBillingPortal } = useAutumn()
80
80
 
81
81
  return (
82
82
  <div>
83
- <h1>Welcome {customer?.name}</h1>
84
83
  <button onClick={() => openBillingPortal()}>
85
84
  Manage Billing
86
85
  </button>
@@ -29,7 +29,8 @@ const AutumnProvider = ({
29
29
  customerId,
30
30
  customerData,
31
31
  authPlugin,
32
- children
32
+ children,
33
+ components
33
34
  }) => {
34
35
  if (typeof window !== "undefined") {
35
36
  throw new Error(
@@ -48,6 +49,7 @@ const AutumnProvider = ({
48
49
  {
49
50
  encryptedCustomerId,
50
51
  customerData,
52
+ components,
51
53
  children
52
54
  }
53
55
  );
@@ -6,7 +6,8 @@ const AutumnProvider = ({
6
6
  customerId,
7
7
  customerData,
8
8
  authPlugin,
9
- children
9
+ children,
10
+ components
10
11
  }) => {
11
12
  if (typeof window !== "undefined") {
12
13
  throw new Error(
@@ -25,6 +26,7 @@ const AutumnProvider = ({
25
26
  {
26
27
  encryptedCustomerId,
27
28
  customerData,
29
+ components,
28
30
  children
29
31
  }
30
32
  );
@@ -5,7 +5,11 @@ interface AutumnProviderProps {
5
5
  children?: React.ReactNode;
6
6
  encryptedCustomerId?: string;
7
7
  customerData?: CustomerData;
8
+ components?: {
9
+ paywallDialog?: any;
10
+ productChangeDialog?: any;
11
+ };
8
12
  }
9
- declare const AutumnClientProvider: ({ children, encryptedCustomerId, customerData, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
13
+ declare const AutumnClientProvider: ({ children, encryptedCustomerId, customerData, components, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
10
14
 
11
15
  export { AutumnClientProvider, type AutumnProviderProps };
@@ -5,7 +5,11 @@ interface AutumnProviderProps {
5
5
  children?: React.ReactNode;
6
6
  encryptedCustomerId?: string;
7
7
  customerData?: CustomerData;
8
+ components?: {
9
+ paywallDialog?: any;
10
+ productChangeDialog?: any;
11
+ };
8
12
  }
9
- declare const AutumnClientProvider: ({ children, encryptedCustomerId, customerData, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
13
+ declare const AutumnClientProvider: ({ children, encryptedCustomerId, customerData, components, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
10
14
 
11
15
  export { AutumnClientProvider, type AutumnProviderProps };
@@ -3,11 +3,10 @@
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { AutumnContext } from "./AutumnContext";
5
5
  import { useEffect, useState } from "react";
6
- const useDialog = (type) => {
6
+ const useDialog = (component) => {
7
7
  const [dialogFound, setDialogFound] = useState(false);
8
8
  const [dialogProps, setDialogProps] = useState(null);
9
9
  const [dialogOpen, setDialogOpen] = useState(false);
10
- const [DialogComponent, setDialogComponent] = useState(null);
11
10
  useEffect(() => {
12
11
  if (dialogProps) {
13
12
  setDialogOpen(true);
@@ -21,32 +20,22 @@ const useDialog = (type) => {
21
20
  }
22
21
  }, [dialogOpen]);
23
22
  const loadDialog = async () => {
24
- try {
25
- let module = await import(`@/components/pricing/${type}-dialog.tsx`);
26
- if (module.default && typeof module.default === "function") {
27
- setDialogComponent(() => module.default);
28
- setDialogFound(true);
29
- }
30
- } catch (error) {
23
+ if (component) {
24
+ setDialogFound(true);
25
+ } else {
31
26
  setDialogFound(false);
32
27
  }
33
28
  };
34
29
  useEffect(() => {
35
30
  loadDialog();
36
31
  }, []);
37
- return [
38
- dialogFound,
39
- dialogProps,
40
- setDialogProps,
41
- dialogOpen,
42
- setDialogOpen,
43
- DialogComponent
44
- ];
32
+ return [dialogFound, dialogProps, setDialogProps, dialogOpen, setDialogOpen];
45
33
  };
46
34
  const AutumnClientProvider = ({
47
35
  children,
48
36
  encryptedCustomerId,
49
- customerData
37
+ customerData,
38
+ components
50
39
  }) => {
51
40
  let [customer, setCustomer] = useState(null);
52
41
  const [
@@ -54,17 +43,15 @@ const AutumnClientProvider = ({
54
43
  prodChangeDialogProps,
55
44
  setProdChangeDialogProps,
56
45
  prodChangeDialogOpen,
57
- setProdChangeDialogOpen,
58
- ProdChangeDialogComponent
59
- ] = useDialog("product-change");
46
+ setProdChangeDialogOpen
47
+ ] = useDialog(components?.productChangeDialog);
60
48
  const [
61
49
  paywallFound,
62
50
  paywallProps,
63
51
  setPaywallProps,
64
52
  paywallOpen,
65
- setPaywallOpen,
66
- PaywallDialogComponent
67
- ] = useDialog("paywall");
53
+ setPaywallOpen
54
+ ] = useDialog(components?.paywallDialog);
68
55
  return /* @__PURE__ */ jsxs(
69
56
  AutumnContext.Provider,
70
57
  {
@@ -85,16 +72,16 @@ const AutumnClientProvider = ({
85
72
  }
86
73
  },
87
74
  children: [
88
- ProdChangeDialogComponent && /* @__PURE__ */ jsx(
89
- ProdChangeDialogComponent,
75
+ components?.productChangeDialog && /* @__PURE__ */ jsx(
76
+ components.productChangeDialog,
90
77
  {
91
78
  open: prodChangeDialogOpen,
92
79
  setOpen: setProdChangeDialogOpen,
93
80
  ...prodChangeDialogProps
94
81
  }
95
82
  ),
96
- PaywallDialogComponent && /* @__PURE__ */ jsx(
97
- PaywallDialogComponent,
83
+ components?.paywallDialog && /* @__PURE__ */ jsx(
84
+ components.paywallDialog,
98
85
  {
99
86
  open: paywallOpen,
100
87
  setOpen: setPaywallOpen,
@@ -3,11 +3,10 @@
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { AutumnContext } from "./AutumnContext";
5
5
  import { useEffect, useState } from "react";
6
- const useDialog = (type) => {
6
+ const useDialog = (component) => {
7
7
  const [dialogFound, setDialogFound] = useState(false);
8
8
  const [dialogProps, setDialogProps] = useState(null);
9
9
  const [dialogOpen, setDialogOpen] = useState(false);
10
- const [DialogComponent, setDialogComponent] = useState(null);
11
10
  useEffect(() => {
12
11
  if (dialogProps) {
13
12
  setDialogOpen(true);
@@ -21,32 +20,22 @@ const useDialog = (type) => {
21
20
  }
22
21
  }, [dialogOpen]);
23
22
  const loadDialog = async () => {
24
- try {
25
- let module = await import(`@/components/pricing/${type}-dialog.tsx`);
26
- if (module.default && typeof module.default === "function") {
27
- setDialogComponent(() => module.default);
28
- setDialogFound(true);
29
- }
30
- } catch (error) {
23
+ if (component) {
24
+ setDialogFound(true);
25
+ } else {
31
26
  setDialogFound(false);
32
27
  }
33
28
  };
34
29
  useEffect(() => {
35
30
  loadDialog();
36
31
  }, []);
37
- return [
38
- dialogFound,
39
- dialogProps,
40
- setDialogProps,
41
- dialogOpen,
42
- setDialogOpen,
43
- DialogComponent
44
- ];
32
+ return [dialogFound, dialogProps, setDialogProps, dialogOpen, setDialogOpen];
45
33
  };
46
34
  const AutumnClientProvider = ({
47
35
  children,
48
36
  encryptedCustomerId,
49
- customerData
37
+ customerData,
38
+ components
50
39
  }) => {
51
40
  let [customer, setCustomer] = useState(null);
52
41
  const [
@@ -54,17 +43,15 @@ const AutumnClientProvider = ({
54
43
  prodChangeDialogProps,
55
44
  setProdChangeDialogProps,
56
45
  prodChangeDialogOpen,
57
- setProdChangeDialogOpen,
58
- ProdChangeDialogComponent
59
- ] = useDialog("product-change");
46
+ setProdChangeDialogOpen
47
+ ] = useDialog(components?.productChangeDialog);
60
48
  const [
61
49
  paywallFound,
62
50
  paywallProps,
63
51
  setPaywallProps,
64
52
  paywallOpen,
65
- setPaywallOpen,
66
- PaywallDialogComponent
67
- ] = useDialog("paywall");
53
+ setPaywallOpen
54
+ ] = useDialog(components?.paywallDialog);
68
55
  return /* @__PURE__ */ jsxs(
69
56
  AutumnContext.Provider,
70
57
  {
@@ -85,16 +72,16 @@ const AutumnClientProvider = ({
85
72
  }
86
73
  },
87
74
  children: [
88
- ProdChangeDialogComponent && /* @__PURE__ */ jsx(
89
- ProdChangeDialogComponent,
75
+ components?.productChangeDialog && /* @__PURE__ */ jsx(
76
+ components.productChangeDialog,
90
77
  {
91
78
  open: prodChangeDialogOpen,
92
79
  setOpen: setProdChangeDialogOpen,
93
80
  ...prodChangeDialogProps
94
81
  }
95
82
  ),
96
- PaywallDialogComponent && /* @__PURE__ */ jsx(
97
- PaywallDialogComponent,
83
+ components?.paywallDialog && /* @__PURE__ */ jsx(
84
+ components.paywallDialog,
98
85
  {
99
86
  open: paywallOpen,
100
87
  setOpen: setPaywallOpen,
@@ -2,7 +2,7 @@ interface ErrorResponse {
2
2
  message: string;
3
3
  code: string;
4
4
  }
5
- declare class AutumnError {
5
+ declare class AutumnError extends Error {
6
6
  readonly message: string;
7
7
  readonly code: string;
8
8
  constructor(response: ErrorResponse);
@@ -2,7 +2,7 @@ interface ErrorResponse {
2
2
  message: string;
3
3
  code: string;
4
4
  }
5
- declare class AutumnError {
5
+ declare class AutumnError extends Error {
6
6
  readonly message: string;
7
7
  readonly code: string;
8
8
  constructor(response: ErrorResponse);
@@ -1,4 +1,4 @@
1
- import { A as AutumnError } from '../error-BUtm1Pks.mjs';
1
+ import { A as AutumnError } from '../error-CG2LXoa7.mjs';
2
2
  import { AttachParams } from './types.mjs';
3
3
 
4
4
  declare const useAutumn: () => {
@@ -1,4 +1,4 @@
1
- import { A as AutumnError } from '../error-BUtm1Pks.js';
1
+ import { A as AutumnError } from '../error-CG2LXoa7.js';
2
2
  import { AttachParams } from './types.js';
3
3
 
4
4
  declare const useAutumn: () => {
@@ -1,4 +1,4 @@
1
- import { A as AutumnError } from '../error-BUtm1Pks.mjs';
1
+ import { A as AutumnError } from '../error-CG2LXoa7.mjs';
2
2
 
3
3
  interface UseCustomerProps {
4
4
  autoCreate?: boolean;
@@ -1,4 +1,4 @@
1
- import { A as AutumnError } from '../error-BUtm1Pks.js';
1
+ import { A as AutumnError } from '../error-CG2LXoa7.js';
2
2
 
3
3
  interface UseCustomerProps {
4
4
  autoCreate?: boolean;
@@ -14,9 +14,10 @@ const useCustomer = (options) => {
14
14
  const { autoCreate } = finalOptions;
15
15
  const { encryptedCustomerId, customerData, customer, setCustomer } = useAutumnContext();
16
16
  const [error, setError] = useState(null);
17
- const [isLoading, setIsLoading] = useState(false);
17
+ const [isLoading, setIsLoading] = useState(true);
18
18
  const fetchCustomer = async () => {
19
19
  setIsLoading(true);
20
+ let returnData = null;
20
21
  try {
21
22
  let data = null;
22
23
  let error2 = null;
@@ -38,11 +39,13 @@ const useCustomer = (options) => {
38
39
  } else {
39
40
  setCustomer(data);
40
41
  }
42
+ returnData = data;
41
43
  } catch (error2) {
42
- console.log("Fetch customer error", error2);
44
+ console.error("(Autumn) Error fetching customer:", error2);
43
45
  setError(error2);
44
46
  }
45
47
  setIsLoading(false);
48
+ return returnData;
46
49
  };
47
50
  const refetch = async () => {
48
51
  await fetchCustomer();
@@ -14,9 +14,10 @@ const useCustomer = (options) => {
14
14
  const { autoCreate } = finalOptions;
15
15
  const { encryptedCustomerId, customerData, customer, setCustomer } = useAutumnContext();
16
16
  const [error, setError] = useState(null);
17
- const [isLoading, setIsLoading] = useState(false);
17
+ const [isLoading, setIsLoading] = useState(true);
18
18
  const fetchCustomer = async () => {
19
19
  setIsLoading(true);
20
+ let returnData = null;
20
21
  try {
21
22
  let data = null;
22
23
  let error2 = null;
@@ -38,11 +39,13 @@ const useCustomer = (options) => {
38
39
  } else {
39
40
  setCustomer(data);
40
41
  }
42
+ returnData = data;
41
43
  } catch (error2) {
42
- console.log("Fetch customer error", error2);
44
+ console.error("(Autumn) Error fetching customer:", error2);
43
45
  setError(error2);
44
46
  }
45
47
  setIsLoading(false);
48
+ return returnData;
46
49
  };
47
50
  const refetch = async () => {
48
51
  await fetchCustomer();
@@ -5,6 +5,19 @@ interface ProductDetails {
5
5
  buttonUrl?: string;
6
6
  recommendText?: string;
7
7
  }
8
+ interface PricingTableProduct {
9
+ id: string;
10
+ name: string;
11
+ buttonText: string;
12
+ price: {
13
+ primaryText: string;
14
+ secondaryText?: string;
15
+ };
16
+ items: {
17
+ primaryText: string;
18
+ secondaryText?: string;
19
+ }[];
20
+ }
8
21
  declare const usePricingTable: (options?: {
9
22
  productDetails: {
10
23
  id: string;
@@ -14,10 +27,10 @@ declare const usePricingTable: (options?: {
14
27
  recommendText?: string;
15
28
  }[];
16
29
  }) => {
17
- products: any[];
30
+ products: any[] | null;
18
31
  isLoading: boolean;
19
32
  error: any;
20
33
  refetch: () => Promise<any>;
21
34
  };
22
35
 
23
- export { type ProductDetails, usePricingTable };
36
+ export { type PricingTableProduct, type ProductDetails, usePricingTable };
@@ -5,6 +5,19 @@ interface ProductDetails {
5
5
  buttonUrl?: string;
6
6
  recommendText?: string;
7
7
  }
8
+ interface PricingTableProduct {
9
+ id: string;
10
+ name: string;
11
+ buttonText: string;
12
+ price: {
13
+ primaryText: string;
14
+ secondaryText?: string;
15
+ };
16
+ items: {
17
+ primaryText: string;
18
+ secondaryText?: string;
19
+ }[];
20
+ }
8
21
  declare const usePricingTable: (options?: {
9
22
  productDetails: {
10
23
  id: string;
@@ -14,10 +27,10 @@ declare const usePricingTable: (options?: {
14
27
  recommendText?: string;
15
28
  }[];
16
29
  }) => {
17
- products: any[];
30
+ products: any[] | null;
18
31
  isLoading: boolean;
19
32
  error: any;
20
33
  refetch: () => Promise<any>;
21
34
  };
22
35
 
23
- export { type ProductDetails, usePricingTable };
36
+ export { type PricingTableProduct, type ProductDetails, usePricingTable };
@@ -5,7 +5,7 @@ import { useAutumnContext } from "../AutumnContext";
5
5
  import { getPricingTableAction } from "../../server/componentActions";
6
6
  const mergeProductDetails = (products, productDetails) => {
7
7
  if (!products) {
8
- return [];
8
+ return null;
9
9
  }
10
10
  if (!productDetails) {
11
11
  return products;
@@ -28,8 +28,9 @@ const usePricingTable = (options) => {
28
28
  const { encryptedCustomerId } = useAutumnContext();
29
29
  const [isLoading, setIsLoading] = useState(true);
30
30
  const [error, setError] = useState(null);
31
- const [products, setProducts] = useState([]);
31
+ const [products, setProducts] = useState(null);
32
32
  const fetchProducts = async () => {
33
+ let returnData = null;
33
34
  try {
34
35
  setIsLoading(true);
35
36
  const res = await getPricingTableAction({
@@ -41,11 +42,13 @@ const usePricingTable = (options) => {
41
42
  }
42
43
  let products2 = res.data.list;
43
44
  setProducts(products2);
45
+ returnData = products2;
44
46
  } catch (error2) {
45
47
  setError(error2);
46
48
  } finally {
47
49
  setIsLoading(false);
48
50
  }
51
+ return returnData;
49
52
  };
50
53
  useEffect(() => {
51
54
  fetchProducts();
@@ -5,7 +5,7 @@ import { useAutumnContext } from "../AutumnContext";
5
5
  import { getPricingTableAction } from "../../server/componentActions";
6
6
  const mergeProductDetails = (products, productDetails) => {
7
7
  if (!products) {
8
- return [];
8
+ return null;
9
9
  }
10
10
  if (!productDetails) {
11
11
  return products;
@@ -28,8 +28,9 @@ const usePricingTable = (options) => {
28
28
  const { encryptedCustomerId } = useAutumnContext();
29
29
  const [isLoading, setIsLoading] = useState(true);
30
30
  const [error, setError] = useState(null);
31
- const [products, setProducts] = useState([]);
31
+ const [products, setProducts] = useState(null);
32
32
  const fetchProducts = async () => {
33
+ let returnData = null;
33
34
  try {
34
35
  setIsLoading(true);
35
36
  const res = await getPricingTableAction({
@@ -41,11 +42,13 @@ const usePricingTable = (options) => {
41
42
  }
42
43
  let products2 = res.data.list;
43
44
  setProducts(products2);
45
+ returnData = products2;
44
46
  } catch (error2) {
45
47
  setError(error2);
46
48
  } finally {
47
49
  setIsLoading(false);
48
50
  }
51
+ return returnData;
49
52
  };
50
53
  useEffect(() => {
51
54
  fetchProducts();
@@ -1,5 +1,15 @@
1
1
  import { C as CustomerData, a as Customer } from './cusTypes-BUiIMwvu.mjs';
2
2
 
3
+ declare class AutumnClientError {
4
+ message: string;
5
+ code: string;
6
+ constructor(message: string, code: string);
7
+ toString(): string;
8
+ toJSON(): {
9
+ message: string;
10
+ code: string;
11
+ };
12
+ }
3
13
  interface AutumnContextParams {
4
14
  encryptedCustomerId?: string;
5
15
  customerData?: CustomerData;
@@ -12,4 +22,4 @@ interface AutumnProviderProps extends AutumnContextParams {
12
22
  children?: React.ReactNode;
13
23
  }
14
24
 
15
- export type { AutumnContextParams, AutumnProviderProps };
25
+ export { AutumnClientError, type AutumnContextParams, type AutumnProviderProps };
@@ -1,5 +1,15 @@
1
1
  import { C as CustomerData, a as Customer } from './cusTypes-BUiIMwvu.js';
2
2
 
3
+ declare class AutumnClientError {
4
+ message: string;
5
+ code: string;
6
+ constructor(message: string, code: string);
7
+ toString(): string;
8
+ toJSON(): {
9
+ message: string;
10
+ code: string;
11
+ };
12
+ }
3
13
  interface AutumnContextParams {
4
14
  encryptedCustomerId?: string;
5
15
  customerData?: CustomerData;
@@ -12,4 +22,4 @@ interface AutumnProviderProps extends AutumnContextParams {
12
22
  children?: React.ReactNode;
13
23
  }
14
24
 
15
- export type { AutumnContextParams, AutumnProviderProps };
25
+ export { AutumnClientError, type AutumnContextParams, type AutumnProviderProps };
@@ -1,2 +1,22 @@
1
1
  "use client";
2
2
 
3
+ class AutumnClientError {
4
+ message;
5
+ code;
6
+ constructor(message, code) {
7
+ this.message = message;
8
+ this.code = code;
9
+ }
10
+ toString() {
11
+ return `${this.message} (${this.code})`;
12
+ }
13
+ toJSON() {
14
+ return {
15
+ message: this.message,
16
+ code: this.code
17
+ };
18
+ }
19
+ }
20
+ export {
21
+ AutumnClientError
22
+ };
@@ -1,2 +1,22 @@
1
1
  "use client";
2
2
 
3
+ class AutumnClientError {
4
+ message;
5
+ code;
6
+ constructor(message, code) {
7
+ this.message = message;
8
+ this.code = code;
9
+ }
10
+ toString() {
11
+ return `${this.message} (${this.code})`;
12
+ }
13
+ toJSON() {
14
+ return {
15
+ message: this.message,
16
+ code: this.code
17
+ };
18
+ }
19
+ }
20
+ export {
21
+ AutumnClientError
22
+ };
@@ -5,7 +5,7 @@ interface ErrorResponse {
5
5
  message: string;
6
6
  code: string;
7
7
  }
8
- declare class AutumnError {
8
+ declare class AutumnError extends Error {
9
9
  readonly message: string;
10
10
  readonly code: string;
11
11
  constructor(response: ErrorResponse);
@@ -105,6 +105,19 @@ interface ProductDetails {
105
105
  buttonUrl?: string;
106
106
  recommendText?: string;
107
107
  }
108
+ interface PricingTableProduct {
109
+ id: string;
110
+ name: string;
111
+ buttonText: string;
112
+ price: {
113
+ primaryText: string;
114
+ secondaryText?: string;
115
+ };
116
+ items: {
117
+ primaryText: string;
118
+ secondaryText?: string;
119
+ }[];
120
+ }
108
121
  declare const usePricingTable: (options?: {
109
122
  productDetails: {
110
123
  id: string;
@@ -114,7 +127,7 @@ declare const usePricingTable: (options?: {
114
127
  recommendText?: string;
115
128
  }[];
116
129
  }) => {
117
- products: any[];
130
+ products: any[] | null;
118
131
  isLoading: boolean;
119
132
  error: any;
120
133
  refetch: () => Promise<any>;
@@ -127,8 +140,12 @@ interface AutumnProviderProps$1 {
127
140
  children?: React.ReactNode;
128
141
  encryptedCustomerId?: string;
129
142
  customerData?: CustomerData;
143
+ components?: {
144
+ paywallDialog?: any;
145
+ productChangeDialog?: any;
146
+ };
130
147
  }
131
- declare const AutumnClientProvider: ({ children, encryptedCustomerId, customerData, }: AutumnProviderProps$1) => react_jsx_runtime.JSX.Element;
148
+ declare const AutumnClientProvider: ({ children, encryptedCustomerId, customerData, components, }: AutumnProviderProps$1) => react_jsx_runtime.JSX.Element;
132
149
 
133
150
  declare const withAuth: <T extends {
134
151
  customerId?: string;
@@ -157,7 +174,11 @@ interface AutumnProviderProps {
157
174
  customerData?: CustomerData;
158
175
  children?: React.ReactNode;
159
176
  authPlugin?: AuthPluginOptions;
177
+ components?: {
178
+ paywallDialog?: () => JSX.Element | React.ReactNode;
179
+ productChangeDialog?: () => JSX.Element | React.ReactNode;
180
+ };
160
181
  }
161
- declare const AutumnProvider: ({ customerId, customerData, authPlugin, children, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
182
+ declare const AutumnProvider: ({ customerId, customerData, authPlugin, children, components, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
162
183
 
163
- export { AutumnClientProvider, AutumnContext, AutumnProvider, type AutumnProviderProps$1 as AutumnProviderProps, type ProductDetails, type UseCustomerProps, useAutumn, useAutumnContext, useCustomer, usePricingTable, withAuth };
184
+ export { AutumnClientProvider, AutumnContext, AutumnProvider, type AutumnProviderProps$1 as AutumnProviderProps, type PricingTableProduct, type ProductDetails, type UseCustomerProps, useAutumn, useAutumnContext, useCustomer, usePricingTable, withAuth };