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.
- package/dist/next/client/AutumnContext.d.mts +4 -2
- package/dist/next/client/AutumnContext.d.ts +4 -2
- package/dist/next/client/AutumnContext.js +16 -2
- package/dist/next/client/AutumnContext.mjs +16 -2
- package/dist/next/client/AutumnProvider.d.mts +1 -1
- package/dist/next/client/AutumnProvider.d.ts +1 -1
- package/dist/next/client/clientUtils.d.mts +2 -2
- package/dist/next/client/clientUtils.d.ts +2 -2
- package/dist/next/client/clientUtils.js +1 -1
- package/dist/next/client/clientUtils.mjs +1 -1
- package/dist/next/client/{cusTypes-BUiIMwvu.d.mts → cusTypes-sGWmB2Vf.d.mts} +16 -9
- package/dist/next/client/{cusTypes-BUiIMwvu.d.ts → cusTypes-sGWmB2Vf.d.ts} +16 -9
- package/dist/next/client/hooks/types.d.mts +1 -0
- package/dist/next/client/hooks/types.d.ts +1 -0
- package/dist/next/client/hooks/useAutumn.d.mts +4 -2
- package/dist/next/client/hooks/useAutumn.d.ts +4 -2
- package/dist/next/client/hooks/useAutumn.js +10 -7
- package/dist/next/client/hooks/useAutumn.mjs +10 -7
- package/dist/next/client/hooks/useCustomer.d.mts +2 -1
- package/dist/next/client/hooks/useCustomer.d.ts +2 -1
- package/dist/next/client/hooks/usePricingTable.d.mts +1 -1
- package/dist/next/client/hooks/usePricingTable.d.ts +1 -1
- package/dist/next/client/types.d.mts +13 -2
- package/dist/next/client/types.d.ts +13 -2
- package/dist/next/index.d.mts +89 -5
- package/dist/next/index.d.ts +89 -5
- package/dist/next/server/auth/withAuth.d.mts +1 -1
- package/dist/next/server/auth/withAuth.d.ts +1 -1
- package/dist/next/server/componentActions.d.mts +1 -1
- package/dist/next/server/componentActions.d.ts +1 -1
- package/dist/next/server/cusActions.d.mts +2 -2
- package/dist/next/server/cusActions.d.ts +2 -2
- package/dist/next/server/{cusTypes-B9N9G7Vr.d.mts → cusTypes-DtlCmw72.d.mts} +17 -10
- package/dist/next/server/{cusTypes-B9N9G7Vr.d.ts → cusTypes-DtlCmw72.d.ts} +17 -10
- package/dist/next/server/genActions.d.mts +2 -2
- package/dist/next/server/genActions.d.ts +2 -2
- package/dist/next/server/{genTypes-BDibiu0E.d.ts → genTypes-B8lkg6J-.d.ts} +1 -1
- package/dist/next/server/{genTypes-DDkwFU_V.d.mts → genTypes-CmWo5C2C.d.mts} +1 -1
- package/dist/sdk/cusTypes-BIzuiqvx.d.mts +74 -0
- package/dist/sdk/cusTypes-HqJzG9Vv.d.ts +74 -0
- package/dist/sdk/customers.d.mts +2 -2
- package/dist/sdk/customers.d.ts +2 -2
- package/dist/sdk/general.d.mts +2 -2
- package/dist/sdk/general.d.ts +2 -2
- package/dist/sdk/index.d.mts +4 -5
- package/dist/sdk/index.d.ts +4 -5
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.mjs +1 -0
- package/dist/sdk/prodEnums-CuZfnjiK.d.mts +27 -0
- package/dist/sdk/prodEnums-CuZfnjiK.d.ts +27 -0
- package/dist/sdk/products.d.mts +1 -1
- package/dist/sdk/products.d.ts +1 -1
- 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<
|
|
4
|
-
declare const useAutumnContext: () =>
|
|
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<
|
|
4
|
-
declare const useAutumnContext: () =>
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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 { AutumnClientError, PricingTableProduct } from './types.mjs';
|
|
2
|
-
import './cusTypes-
|
|
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
|
|
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-
|
|
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
|
|
12
|
+
encryptedCustomerId?: string;
|
|
13
13
|
}) => Promise<any>;
|
|
14
14
|
|
|
15
15
|
export { fetchPricingTableData, toClientErrorResponse };
|
|
@@ -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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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;
|
|
@@ -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:
|
|
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:
|
|
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" :
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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" :
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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:
|
|
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:
|
|
8
|
+
customer: Customer | null;
|
|
8
9
|
isLoading: boolean;
|
|
9
10
|
error: AutumnError | null;
|
|
10
11
|
refetch: () => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomerData, a as Customer } from './cusTypes-
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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;
|
package/dist/next/index.d.mts
CHANGED
|
@@ -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:
|
|
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:
|
|
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<
|
|
131
|
-
declare const useAutumnContext: () =>
|
|
214
|
+
declare const AutumnContext: react.Context<AutumnContextParams>;
|
|
215
|
+
declare const useAutumnContext: () => AutumnContextParams;
|
|
132
216
|
|
|
133
217
|
interface AutumnProviderProps$1 {
|
|
134
218
|
children?: React.ReactNode;
|