autumn-js 0.0.23 → 0.0.25

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 (53) hide show
  1. package/dist/next/client/AutumnContext.d.mts +4 -2
  2. package/dist/next/client/AutumnContext.d.ts +4 -2
  3. package/dist/next/client/AutumnContext.js +16 -2
  4. package/dist/next/client/AutumnContext.mjs +16 -2
  5. package/dist/next/client/AutumnProvider.d.mts +1 -1
  6. package/dist/next/client/AutumnProvider.d.ts +1 -1
  7. package/dist/next/client/clientUtils.d.mts +2 -2
  8. package/dist/next/client/clientUtils.d.ts +2 -2
  9. package/dist/next/client/clientUtils.js +1 -1
  10. package/dist/next/client/clientUtils.mjs +1 -1
  11. package/dist/next/client/{cusTypes-BUiIMwvu.d.mts → cusTypes-sGWmB2Vf.d.mts} +16 -9
  12. package/dist/next/client/{cusTypes-BUiIMwvu.d.ts → cusTypes-sGWmB2Vf.d.ts} +16 -9
  13. package/dist/next/client/hooks/types.d.mts +1 -0
  14. package/dist/next/client/hooks/types.d.ts +1 -0
  15. package/dist/next/client/hooks/useAutumn.d.mts +4 -2
  16. package/dist/next/client/hooks/useAutumn.d.ts +4 -2
  17. package/dist/next/client/hooks/useAutumn.js +10 -7
  18. package/dist/next/client/hooks/useAutumn.mjs +10 -7
  19. package/dist/next/client/hooks/useCustomer.d.mts +2 -1
  20. package/dist/next/client/hooks/useCustomer.d.ts +2 -1
  21. package/dist/next/client/hooks/usePricingTable.d.mts +1 -1
  22. package/dist/next/client/hooks/usePricingTable.d.ts +1 -1
  23. package/dist/next/client/types.d.mts +13 -2
  24. package/dist/next/client/types.d.ts +13 -2
  25. package/dist/next/index.d.mts +89 -5
  26. package/dist/next/index.d.ts +89 -5
  27. package/dist/next/server/auth/withAuth.d.mts +1 -1
  28. package/dist/next/server/auth/withAuth.d.ts +1 -1
  29. package/dist/next/server/componentActions.d.mts +1 -1
  30. package/dist/next/server/componentActions.d.ts +1 -1
  31. package/dist/next/server/cusActions.d.mts +2 -2
  32. package/dist/next/server/cusActions.d.ts +2 -2
  33. package/dist/next/server/{cusTypes-B9N9G7Vr.d.mts → cusTypes-DtlCmw72.d.mts} +17 -10
  34. package/dist/next/server/{cusTypes-B9N9G7Vr.d.ts → cusTypes-DtlCmw72.d.ts} +17 -10
  35. package/dist/next/server/genActions.d.mts +2 -2
  36. package/dist/next/server/genActions.d.ts +2 -2
  37. package/dist/next/server/{genTypes-BDibiu0E.d.ts → genTypes-B8lkg6J-.d.ts} +1 -1
  38. package/dist/next/server/{genTypes-DDkwFU_V.d.mts → genTypes-CmWo5C2C.d.mts} +1 -1
  39. package/dist/sdk/cusTypes-BIzuiqvx.d.mts +74 -0
  40. package/dist/sdk/cusTypes-HqJzG9Vv.d.ts +74 -0
  41. package/dist/sdk/customers.d.mts +2 -2
  42. package/dist/sdk/customers.d.ts +2 -2
  43. package/dist/sdk/general.d.mts +2 -2
  44. package/dist/sdk/general.d.ts +2 -2
  45. package/dist/sdk/index.d.mts +4 -5
  46. package/dist/sdk/index.d.ts +4 -5
  47. package/dist/sdk/index.js +1 -0
  48. package/dist/sdk/index.mjs +1 -0
  49. package/dist/sdk/prodEnums-CuZfnjiK.d.mts +27 -0
  50. package/dist/sdk/prodEnums-CuZfnjiK.d.ts +27 -0
  51. package/dist/sdk/products.d.mts +1 -1
  52. package/dist/sdk/products.d.ts +1 -1
  53. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  import * as react from 'react';
2
+ import { AutumnContextParams } from './types.mjs';
3
+ import './cusTypes-sGWmB2Vf.mjs';
2
4
 
3
- declare const AutumnContext: react.Context<any>;
4
- declare const useAutumnContext: () => any;
5
+ declare const AutumnContext: react.Context<AutumnContextParams>;
6
+ declare const useAutumnContext: () => AutumnContextParams;
5
7
 
6
8
  export { AutumnContext, useAutumnContext };
@@ -1,6 +1,8 @@
1
1
  import * as react from 'react';
2
+ import { AutumnContextParams } from './types.js';
3
+ import './cusTypes-sGWmB2Vf.js';
2
4
 
3
- declare const AutumnContext: react.Context<any>;
4
- declare const useAutumnContext: () => any;
5
+ declare const AutumnContext: react.Context<AutumnContextParams>;
6
+ declare const useAutumnContext: () => AutumnContextParams;
5
7
 
6
8
  export { AutumnContext, useAutumnContext };
@@ -8,8 +8,22 @@ const AutumnContext = createContext({
8
8
  customer: null,
9
9
  setCustomer: () => {
10
10
  },
11
- paywallOpen: false,
12
- setPaywallOpen: () => {
11
+ prodChangeDialog: {
12
+ found: false,
13
+ setProps: () => {
14
+ },
15
+ setOpen: () => {
16
+ }
17
+ },
18
+ paywallDialog: {
19
+ found: false,
20
+ setProps: () => {
21
+ },
22
+ setOpen: () => {
23
+ }
24
+ },
25
+ pricingTableProducts: null,
26
+ setPricingTableProducts: () => {
13
27
  }
14
28
  });
15
29
  const useAutumnContext = () => {
@@ -8,8 +8,22 @@ const AutumnContext = createContext({
8
8
  customer: null,
9
9
  setCustomer: () => {
10
10
  },
11
- paywallOpen: false,
12
- setPaywallOpen: () => {
11
+ prodChangeDialog: {
12
+ found: false,
13
+ setProps: () => {
14
+ },
15
+ setOpen: () => {
16
+ }
17
+ },
18
+ paywallDialog: {
19
+ found: false,
20
+ setProps: () => {
21
+ },
22
+ setOpen: () => {
23
+ }
24
+ },
25
+ pricingTableProducts: null,
26
+ setPricingTableProducts: () => {
13
27
  }
14
28
  });
15
29
  const useAutumnContext = () => {
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as CustomerData } from './cusTypes-BUiIMwvu.mjs';
2
+ import { C as CustomerData } from './cusTypes-sGWmB2Vf.mjs';
3
3
 
4
4
  interface AutumnProviderProps {
5
5
  children?: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as CustomerData } from './cusTypes-BUiIMwvu.js';
2
+ import { C as CustomerData } from './cusTypes-sGWmB2Vf.js';
3
3
 
4
4
  interface AutumnProviderProps {
5
5
  children?: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import { AutumnClientError, PricingTableProduct } from './types.mjs';
2
- import './cusTypes-BUiIMwvu.mjs';
2
+ import './cusTypes-sGWmB2Vf.mjs';
3
3
 
4
4
  declare const toClientErrorResponse: (error: any) => {
5
5
  data: null;
@@ -9,7 +9,7 @@ declare const fetchPricingTableData: ({ setIsLoading, setError, setProducts, enc
9
9
  setIsLoading?: (isLoading: boolean) => void;
10
10
  setError?: (error: any) => void;
11
11
  setProducts: (products: PricingTableProduct[]) => void;
12
- encryptedCustomerId: string;
12
+ encryptedCustomerId?: string;
13
13
  }) => Promise<any>;
14
14
 
15
15
  export { fetchPricingTableData, toClientErrorResponse };
@@ -1,5 +1,5 @@
1
1
  import { AutumnClientError, PricingTableProduct } from './types.js';
2
- import './cusTypes-BUiIMwvu.js';
2
+ import './cusTypes-sGWmB2Vf.js';
3
3
 
4
4
  declare const toClientErrorResponse: (error: any) => {
5
5
  data: null;
@@ -9,7 +9,7 @@ declare const fetchPricingTableData: ({ setIsLoading, setError, setProducts, enc
9
9
  setIsLoading?: (isLoading: boolean) => void;
10
10
  setError?: (error: any) => void;
11
11
  setProducts: (products: PricingTableProduct[]) => void;
12
- encryptedCustomerId: string;
12
+ encryptedCustomerId?: string;
13
13
  }) => Promise<any>;
14
14
 
15
15
  export { fetchPricingTableData, toClientErrorResponse };
@@ -11,7 +11,7 @@ const toClientErrorResponse = (error) => {
11
11
  if (error?.code) {
12
12
  code = error.code;
13
13
  }
14
- console.error(msg);
14
+ console.error("Autumn Error: ", msg);
15
15
  return {
16
16
  data: null,
17
17
  error: new AutumnClientError({ message: msg, code })
@@ -11,7 +11,7 @@ const toClientErrorResponse = (error) => {
11
11
  if (error?.code) {
12
12
  code = error.code;
13
13
  }
14
- console.error(msg);
14
+ console.error("Autumn Error: ", msg);
15
15
  return {
16
16
  data: null,
17
17
  error: new AutumnClientError({ message: msg, code })
@@ -11,7 +11,8 @@ declare enum ProductItemInterval {
11
11
  Month = "month",
12
12
  Quarter = "quarter",
13
13
  SemiAnnual = "semi_annual",
14
- Year = "year"
14
+ Year = "year",
15
+ Multiple = "multiple"
15
16
  }
16
17
 
17
18
  declare enum ProductStatus {
@@ -22,13 +23,21 @@ declare enum ProductStatus {
22
23
  }
23
24
 
24
25
  interface CustomerFeature {
25
- feature_id: string;
26
+ id: string;
27
+ name: string;
26
28
  unlimited?: boolean;
27
29
  interval?: ProductItemInterval | null;
28
30
  balance?: number;
29
31
  usage?: number;
30
32
  included_usage?: number;
31
- next_reset_at?: number;
33
+ next_reset_at?: number | null;
34
+ breakdown?: {
35
+ interval: ProductItemInterval;
36
+ balance?: number;
37
+ usage?: number;
38
+ included_usage?: number;
39
+ next_reset_at?: number;
40
+ }[];
32
41
  }
33
42
  interface CustomerProduct {
34
43
  id: string;
@@ -42,17 +51,15 @@ interface CustomerProduct {
42
51
  current_period_end?: number | null;
43
52
  }
44
53
  interface Customer {
45
- autumn_id: string;
46
- created_at: number;
47
- env: AppEnv;
48
54
  id: string | null;
55
+ created_at: number;
49
56
  name: string | null;
50
57
  email: string | null;
51
58
  fingerprint: string | null;
52
59
  stripe_id: string | null;
53
- products: CustomerProduct[];
54
- add_ons: CustomerProduct[];
55
- features: CustomerFeature[];
60
+ env: AppEnv;
61
+ products: Record<string, CustomerProduct>;
62
+ features: Record<string, CustomerFeature>;
56
63
  }
57
64
  interface CustomerData {
58
65
  name?: string;
@@ -11,7 +11,8 @@ declare enum ProductItemInterval {
11
11
  Month = "month",
12
12
  Quarter = "quarter",
13
13
  SemiAnnual = "semi_annual",
14
- Year = "year"
14
+ Year = "year",
15
+ Multiple = "multiple"
15
16
  }
16
17
 
17
18
  declare enum ProductStatus {
@@ -22,13 +23,21 @@ declare enum ProductStatus {
22
23
  }
23
24
 
24
25
  interface CustomerFeature {
25
- feature_id: string;
26
+ id: string;
27
+ name: string;
26
28
  unlimited?: boolean;
27
29
  interval?: ProductItemInterval | null;
28
30
  balance?: number;
29
31
  usage?: number;
30
32
  included_usage?: number;
31
- next_reset_at?: number;
33
+ next_reset_at?: number | null;
34
+ breakdown?: {
35
+ interval: ProductItemInterval;
36
+ balance?: number;
37
+ usage?: number;
38
+ included_usage?: number;
39
+ next_reset_at?: number;
40
+ }[];
32
41
  }
33
42
  interface CustomerProduct {
34
43
  id: string;
@@ -42,17 +51,15 @@ interface CustomerProduct {
42
51
  current_period_end?: number | null;
43
52
  }
44
53
  interface Customer {
45
- autumn_id: string;
46
- created_at: number;
47
- env: AppEnv;
48
54
  id: string | null;
55
+ created_at: number;
49
56
  name: string | null;
50
57
  email: string | null;
51
58
  fingerprint: string | null;
52
59
  stripe_id: string | null;
53
- products: CustomerProduct[];
54
- add_ons: CustomerProduct[];
55
- features: CustomerFeature[];
60
+ env: AppEnv;
61
+ products: Record<string, CustomerProduct>;
62
+ features: Record<string, CustomerFeature>;
56
63
  }
57
64
  interface CustomerData {
58
65
  name?: string;
@@ -9,6 +9,7 @@ interface AttachParams {
9
9
  forceCheckout?: boolean;
10
10
  metadata?: Record<string, string>;
11
11
  callback?: () => Promise<void>;
12
+ withPreview?: "formatted" | "raw";
12
13
  }
13
14
 
14
15
  export type { AttachParams };
@@ -9,6 +9,7 @@ interface AttachParams {
9
9
  forceCheckout?: boolean;
10
10
  metadata?: Record<string, string>;
11
11
  callback?: () => Promise<void>;
12
+ withPreview?: "formatted" | "raw";
12
13
  }
13
14
 
14
15
  export type { AttachParams };
@@ -1,14 +1,16 @@
1
1
  import { A as AutumnError } from '../error-CG2LXoa7.mjs';
2
+ import { a as Customer } from '../cusTypes-sGWmB2Vf.mjs';
2
3
  import { AttachParams } from './types.mjs';
3
4
 
4
5
  declare const useAutumn: () => {
5
6
  attach: ({ dialog, productId, options, successUrl, forceCheckout, metadata, callback, }: AttachParams) => Promise<any>;
6
- check: ({ dialog, featureId, productId, requiredQuantity, sendEvent, }: {
7
+ check: ({ dialog, featureId, productId, requiredQuantity, sendEvent, withPreview, }: {
7
8
  dialog?: boolean;
8
9
  featureId?: string;
9
10
  productId?: string;
10
11
  requiredQuantity?: number;
11
12
  sendEvent?: boolean;
13
+ withPreview?: "formatted" | "raw";
12
14
  }) => Promise<any>;
13
15
  track: ({ featureId, value, }: {
14
16
  featureId: string;
@@ -36,7 +38,7 @@ declare const useAutumn: () => {
36
38
  * @deprecated Use the useCustomer() hook instead.
37
39
  * This property is deprecated and will be removed in a future version.
38
40
  */
39
- customer: any;
41
+ customer: Customer | null;
40
42
  /**
41
43
  * @deprecated Use the useCustomer() hook instead.
42
44
  * This property is deprecated and will be removed in a future version.
@@ -1,14 +1,16 @@
1
1
  import { A as AutumnError } from '../error-CG2LXoa7.js';
2
+ import { a as Customer } from '../cusTypes-sGWmB2Vf.js';
2
3
  import { AttachParams } from './types.js';
3
4
 
4
5
  declare const useAutumn: () => {
5
6
  attach: ({ dialog, productId, options, successUrl, forceCheckout, metadata, callback, }: AttachParams) => Promise<any>;
6
- check: ({ dialog, featureId, productId, requiredQuantity, sendEvent, }: {
7
+ check: ({ dialog, featureId, productId, requiredQuantity, sendEvent, withPreview, }: {
7
8
  dialog?: boolean;
8
9
  featureId?: string;
9
10
  productId?: string;
10
11
  requiredQuantity?: number;
11
12
  sendEvent?: boolean;
13
+ withPreview?: "formatted" | "raw";
12
14
  }) => Promise<any>;
13
15
  track: ({ featureId, value, }: {
14
16
  featureId: string;
@@ -36,7 +38,7 @@ declare const useAutumn: () => {
36
38
  * @deprecated Use the useCustomer() hook instead.
37
39
  * This property is deprecated and will be removed in a future version.
38
40
  */
39
- customer: any;
41
+ customer: Customer | null;
40
42
  /**
41
43
  * @deprecated Use the useCustomer() hook instead.
42
44
  * This property is deprecated and will be removed in a future version.
@@ -149,7 +149,8 @@ const useAutumn = () => {
149
149
  featureId,
150
150
  productId,
151
151
  requiredQuantity,
152
- sendEvent
152
+ sendEvent,
153
+ withPreview
153
154
  }) => {
154
155
  const res = await checkAction({
155
156
  encryptedCustomerId,
@@ -157,22 +158,24 @@ const useAutumn = () => {
157
158
  productId,
158
159
  requiredQuantity,
159
160
  sendEvent,
160
- withPreview: dialog ? "formatted" : void 0
161
+ withPreview: dialog ? "formatted" : withPreview
161
162
  });
162
163
  if (res.error) {
163
164
  return toClientErrorResponse(res.error);
164
165
  }
165
166
  let data = res.data;
166
- if (data && data.preview) {
167
+ if (data && data.preview && dialog) {
167
168
  let nextActionData = {};
168
169
  let preview = data.preview;
169
170
  if (preview.upgrade_product_id) {
170
171
  nextActionData = {
171
172
  onClick: async () => {
172
- await attach({
173
- dialog: true,
174
- productId: preview.upgrade_product_id
175
- });
173
+ if (preview.upgrade_product_id) {
174
+ await attach({
175
+ dialog: true,
176
+ productId: preview.upgrade_product_id
177
+ });
178
+ }
176
179
  setPaywallDialogOpen(false);
177
180
  },
178
181
  buttonText: preview.button_text
@@ -149,7 +149,8 @@ const useAutumn = () => {
149
149
  featureId,
150
150
  productId,
151
151
  requiredQuantity,
152
- sendEvent
152
+ sendEvent,
153
+ withPreview
153
154
  }) => {
154
155
  const res = await checkAction({
155
156
  encryptedCustomerId,
@@ -157,22 +158,24 @@ const useAutumn = () => {
157
158
  productId,
158
159
  requiredQuantity,
159
160
  sendEvent,
160
- withPreview: dialog ? "formatted" : void 0
161
+ withPreview: dialog ? "formatted" : withPreview
161
162
  });
162
163
  if (res.error) {
163
164
  return toClientErrorResponse(res.error);
164
165
  }
165
166
  let data = res.data;
166
- if (data && data.preview) {
167
+ if (data && data.preview && dialog) {
167
168
  let nextActionData = {};
168
169
  let preview = data.preview;
169
170
  if (preview.upgrade_product_id) {
170
171
  nextActionData = {
171
172
  onClick: async () => {
172
- await attach({
173
- dialog: true,
174
- productId: preview.upgrade_product_id
175
- });
173
+ if (preview.upgrade_product_id) {
174
+ await attach({
175
+ dialog: true,
176
+ productId: preview.upgrade_product_id
177
+ });
178
+ }
176
179
  setPaywallDialogOpen(false);
177
180
  },
178
181
  buttonText: preview.button_text
@@ -1,10 +1,11 @@
1
1
  import { A as AutumnError } from '../error-CG2LXoa7.mjs';
2
+ import { a as Customer } from '../cusTypes-sGWmB2Vf.mjs';
2
3
 
3
4
  interface UseCustomerProps {
4
5
  autoCreate?: boolean;
5
6
  }
6
7
  declare const useCustomer: (options?: UseCustomerProps) => {
7
- customer: any;
8
+ customer: Customer | null;
8
9
  isLoading: boolean;
9
10
  error: AutumnError | null;
10
11
  refetch: () => Promise<void>;
@@ -1,10 +1,11 @@
1
1
  import { A as AutumnError } from '../error-CG2LXoa7.js';
2
+ import { a as Customer } from '../cusTypes-sGWmB2Vf.js';
2
3
 
3
4
  interface UseCustomerProps {
4
5
  autoCreate?: boolean;
5
6
  }
6
7
  declare const useCustomer: (options?: UseCustomerProps) => {
7
- customer: any;
8
+ customer: Customer | null;
8
9
  isLoading: boolean;
9
10
  error: AutumnError | null;
10
11
  refetch: () => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { PricingTableProduct } from '../types.mjs';
2
- import '../cusTypes-BUiIMwvu.mjs';
2
+ import '../cusTypes-sGWmB2Vf.mjs';
3
3
 
4
4
  declare const usePricingTable: (options?: {
5
5
  productDetails: {
@@ -1,5 +1,5 @@
1
1
  import { PricingTableProduct } from '../types.js';
2
- import '../cusTypes-BUiIMwvu.js';
2
+ import '../cusTypes-sGWmB2Vf.js';
3
3
 
4
4
  declare const usePricingTable: (options?: {
5
5
  productDetails: {
@@ -1,4 +1,4 @@
1
- import { C as CustomerData, a as Customer } from './cusTypes-BUiIMwvu.mjs';
1
+ import { C as CustomerData, a as Customer } from './cusTypes-sGWmB2Vf.mjs';
2
2
 
3
3
  interface ProductDetails {
4
4
  id: string;
@@ -38,7 +38,18 @@ interface AutumnContextParams {
38
38
  authProvider?: "clerk" | "better-auth";
39
39
  customer: Customer | null;
40
40
  setCustomer: (customer: Customer | null) => void;
41
- paywallExists: boolean;
41
+ prodChangeDialog: {
42
+ found: boolean;
43
+ setProps: (props: any) => void;
44
+ setOpen: (open: boolean) => void;
45
+ };
46
+ paywallDialog: {
47
+ found: boolean;
48
+ setProps: (props: any) => void;
49
+ setOpen: (open: boolean) => void;
50
+ };
51
+ pricingTableProducts: PricingTableProduct[] | null;
52
+ setPricingTableProducts: (products: PricingTableProduct[]) => void;
42
53
  }
43
54
  interface AutumnProviderProps extends AutumnContextParams {
44
55
  children?: React.ReactNode;
@@ -1,4 +1,4 @@
1
- import { C as CustomerData, a as Customer } from './cusTypes-BUiIMwvu.js';
1
+ import { C as CustomerData, a as Customer } from './cusTypes-sGWmB2Vf.js';
2
2
 
3
3
  interface ProductDetails {
4
4
  id: string;
@@ -38,7 +38,18 @@ interface AutumnContextParams {
38
38
  authProvider?: "clerk" | "better-auth";
39
39
  customer: Customer | null;
40
40
  setCustomer: (customer: Customer | null) => void;
41
- paywallExists: boolean;
41
+ prodChangeDialog: {
42
+ found: boolean;
43
+ setProps: (props: any) => void;
44
+ setOpen: (open: boolean) => void;
45
+ };
46
+ paywallDialog: {
47
+ found: boolean;
48
+ setProps: (props: any) => void;
49
+ setOpen: (open: boolean) => void;
50
+ };
51
+ pricingTableProducts: PricingTableProduct[] | null;
52
+ setPricingTableProducts: (products: PricingTableProduct[]) => void;
42
53
  }
43
54
  interface AutumnProviderProps extends AutumnContextParams {
44
55
  children?: React.ReactNode;
@@ -16,6 +16,69 @@ declare class AutumnError extends Error {
16
16
  };
17
17
  }
18
18
 
19
+ declare enum AppEnv {
20
+ Sandbox = "sandbox",
21
+ Live = "live"
22
+ }
23
+
24
+ declare enum ProductItemInterval {
25
+ Minute = "minute",
26
+ Hour = "hour",
27
+ Day = "day",
28
+ Week = "week",
29
+ Month = "month",
30
+ Quarter = "quarter",
31
+ SemiAnnual = "semi_annual",
32
+ Year = "year",
33
+ Multiple = "multiple"
34
+ }
35
+
36
+ declare enum ProductStatus {
37
+ Active = "active",
38
+ Expired = "expired",
39
+ Trialing = "trialing",
40
+ Scheduled = "scheduled"
41
+ }
42
+
43
+ interface CustomerFeature {
44
+ id: string;
45
+ name: string;
46
+ unlimited?: boolean;
47
+ interval?: ProductItemInterval | null;
48
+ balance?: number;
49
+ usage?: number;
50
+ included_usage?: number;
51
+ next_reset_at?: number | null;
52
+ breakdown?: {
53
+ interval: ProductItemInterval;
54
+ balance?: number;
55
+ usage?: number;
56
+ included_usage?: number;
57
+ next_reset_at?: number;
58
+ }[];
59
+ }
60
+ interface CustomerProduct {
61
+ id: string;
62
+ name: string | null;
63
+ group: string | null;
64
+ status: ProductStatus;
65
+ started_at: number;
66
+ canceled_at: number | null;
67
+ subscription_ids?: string[] | null;
68
+ current_period_start?: number | null;
69
+ current_period_end?: number | null;
70
+ }
71
+ interface Customer {
72
+ id: string | null;
73
+ created_at: number;
74
+ name: string | null;
75
+ email: string | null;
76
+ fingerprint: string | null;
77
+ stripe_id: string | null;
78
+ env: AppEnv;
79
+ products: Record<string, CustomerProduct>;
80
+ features: Record<string, CustomerFeature>;
81
+ }
19
82
  interface CustomerData {
20
83
  name?: string;
21
84
  email?: string;
@@ -33,16 +96,18 @@ interface AttachParams {
33
96
  forceCheckout?: boolean;
34
97
  metadata?: Record<string, string>;
35
98
  callback?: () => Promise<void>;
99
+ withPreview?: "formatted" | "raw";
36
100
  }
37
101
 
38
102
  declare const useAutumn: () => {
39
103
  attach: ({ dialog, productId, options, successUrl, forceCheckout, metadata, callback, }: AttachParams) => Promise<any>;
40
- check: ({ dialog, featureId, productId, requiredQuantity, sendEvent, }: {
104
+ check: ({ dialog, featureId, productId, requiredQuantity, sendEvent, withPreview, }: {
41
105
  dialog?: boolean;
42
106
  featureId?: string;
43
107
  productId?: string;
44
108
  requiredQuantity?: number;
45
109
  sendEvent?: boolean;
110
+ withPreview?: "formatted" | "raw";
46
111
  }) => Promise<any>;
47
112
  track: ({ featureId, value, }: {
48
113
  featureId: string;
@@ -70,7 +135,7 @@ declare const useAutumn: () => {
70
135
  * @deprecated Use the useCustomer() hook instead.
71
136
  * This property is deprecated and will be removed in a future version.
72
137
  */
73
- customer: any;
138
+ customer: Customer | null;
74
139
  /**
75
140
  * @deprecated Use the useCustomer() hook instead.
76
141
  * This property is deprecated and will be removed in a future version.
@@ -92,7 +157,7 @@ interface UseCustomerProps {
92
157
  autoCreate?: boolean;
93
158
  }
94
159
  declare const useCustomer: (options?: UseCustomerProps) => {
95
- customer: any;
160
+ customer: Customer | null;
96
161
  isLoading: boolean;
97
162
  error: AutumnError | null;
98
163
  refetch: () => Promise<void>;
@@ -111,6 +176,25 @@ interface PricingTableProduct {
111
176
  secondaryText?: string;
112
177
  }[];
113
178
  }
179
+ interface AutumnContextParams {
180
+ encryptedCustomerId?: string;
181
+ customerData?: CustomerData;
182
+ authProvider?: "clerk" | "better-auth";
183
+ customer: Customer | null;
184
+ setCustomer: (customer: Customer | null) => void;
185
+ prodChangeDialog: {
186
+ found: boolean;
187
+ setProps: (props: any) => void;
188
+ setOpen: (open: boolean) => void;
189
+ };
190
+ paywallDialog: {
191
+ found: boolean;
192
+ setProps: (props: any) => void;
193
+ setOpen: (open: boolean) => void;
194
+ };
195
+ pricingTableProducts: PricingTableProduct[] | null;
196
+ setPricingTableProducts: (products: PricingTableProduct[]) => void;
197
+ }
114
198
 
115
199
  declare const usePricingTable: (options?: {
116
200
  productDetails: {
@@ -127,8 +211,8 @@ declare const usePricingTable: (options?: {
127
211
  refetch: () => Promise<PricingTableProduct[] | null>;
128
212
  };
129
213
 
130
- declare const AutumnContext: react.Context<any>;
131
- declare const useAutumnContext: () => any;
214
+ declare const AutumnContext: react.Context<AutumnContextParams>;
215
+ declare const useAutumnContext: () => AutumnContextParams;
132
216
 
133
217
  interface AutumnProviderProps$1 {
134
218
  children?: React.ReactNode;