autumn-js 0.1.42 → 0.1.43
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/libraries/backend/better-auth.mjs +0 -1
- package/dist/libraries/backend/constants.mjs +0 -1
- package/dist/libraries/backend/convex.mjs +0 -1
- package/dist/libraries/backend/elysia.mjs +0 -1
- package/dist/libraries/backend/express.mjs +0 -1
- package/dist/libraries/backend/fastify.mjs +0 -1
- package/dist/libraries/backend/hono.mjs +0 -1
- package/dist/libraries/backend/index.mjs +0 -1
- package/dist/libraries/backend/next.js +3 -3500
- package/dist/libraries/backend/next.mjs +5 -3504
- package/dist/libraries/backend/react-router.mjs +0 -1
- package/dist/libraries/backend/remix_dep.mjs +0 -1
- package/dist/libraries/backend/routes/backendRouter.mjs +0 -1
- package/dist/libraries/backend/routes/entityRoutes.mjs +0 -1
- package/dist/libraries/backend/routes/genRoutes.mjs +0 -1
- package/dist/libraries/backend/routes/productRoutes.mjs +0 -1
- package/dist/libraries/backend/routes/referralRoutes.mjs +0 -1
- package/dist/libraries/backend/schemas/zod.mjs +0 -2
- package/dist/libraries/backend/supabase.mjs +0 -1
- package/dist/libraries/backend/tanstack.js +4 -96
- package/dist/libraries/backend/tanstack.mjs +1 -98
- package/dist/libraries/backend/utils/backendRes.mjs +0 -1
- package/dist/libraries/backend/utils/betterAuth/middlewares.mjs +0 -1
- package/dist/libraries/backend/utils/logBackendErrors.mjs +0 -1
- package/dist/libraries/backend/utils/secretKeyCheck.mjs +0 -1
- package/dist/libraries/backend/utils/withAuth.mjs +0 -1
- package/dist/libraries/react/{chunk-CBCX366C.mjs → chunk-MFENLDKQ.mjs} +21 -21
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +11 -11
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +11 -11
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +11 -11
- package/dist/libraries/react/components/ui/dialog.mjs +2 -2
- package/dist/libraries/react/components/ui/popover.mjs +2 -2
- package/dist/next/client/AutumnClientProvider.d.mts +2 -0
- package/dist/next/client/AutumnClientProvider.d.ts +2 -0
- package/dist/next/client/NextAutumnClient.d.mts +253 -0
- package/dist/next/client/NextAutumnClient.d.ts +253 -0
- package/dist/next/client/NextAutumnProvider.d.mts +12 -0
- package/dist/next/client/NextAutumnProvider.d.ts +12 -0
- package/dist/next/client/clientAttachTypes-BtZh00uu.d.ts +121 -0
- package/dist/next/client/clientAttachTypes-yOuJqDWt.d.mts +121 -0
- package/dist/next/client/clientEntTypes-Bsi7ciUF.d.ts +73 -0
- package/dist/next/client/clientEntTypes-aLfa3lyP.d.mts +73 -0
- package/dist/next/client/clientUtils.d.mts +19 -0
- package/dist/next/client/clientUtils.d.ts +19 -0
- package/dist/next/client/cusTypes-B-rJwpui.d.ts +123 -0
- package/dist/next/client/cusTypes-CXjHwB-c.d.mts +123 -0
- package/dist/next/client/entTypes-BkN-Puru.d.mts +22 -0
- package/dist/next/client/entTypes-DjKFS-Zk.d.ts +22 -0
- package/dist/next/client/error-DHbclCVh.d.mts +17 -0
- package/dist/next/client/error-DHbclCVh.d.ts +17 -0
- package/dist/next/client/hooks/useAutumn.d.mts +19 -0
- package/dist/next/client/hooks/useAutumn.d.ts +19 -0
- package/dist/next/client/hooks/useCustomer.d.mts +87 -0
- package/dist/next/client/hooks/useCustomer.d.ts +87 -0
- package/dist/next/client/hooks/useEntity.d.mts +33 -0
- package/dist/next/client/hooks/useEntity.d.ts +33 -0
- package/dist/next/client/hooks/usePricingTable.d.mts +34 -0
- package/dist/next/client/hooks/usePricingTable.d.ts +34 -0
- package/dist/next/client/prodTypes-B_VMILpU.d.mts +162 -0
- package/dist/next/client/prodTypes-B_VMILpU.d.ts +162 -0
- package/dist/next/client/types.d.mts +75 -0
- package/dist/next/client/types.d.ts +75 -0
- package/dist/next/server/auth/authPlugin.d.mts +13 -0
- package/dist/next/server/auth/authPlugin.d.ts +13 -0
- package/dist/next/server/auth/clerk-wrapper.d.mts +3 -0
- package/dist/next/server/auth/clerk-wrapper.d.ts +3 -0
- package/dist/next/server/auth/get-next-headers.d.mts +6 -0
- package/dist/next/server/auth/get-next-headers.d.ts +6 -0
- package/dist/next/server/auth/handleAuthProvider.d.mts +44 -0
- package/dist/next/server/auth/handleAuthProvider.d.ts +44 -0
- package/dist/next/server/auth/supabase-wrapper.d.mts +3 -0
- package/dist/next/server/auth/supabase-wrapper.d.ts +3 -0
- package/dist/next/server/auth/withNextAuth.d.mts +16 -0
- package/dist/next/server/auth/withNextAuth.d.ts +16 -0
- package/dist/next/server/componentActions.d.mts +12 -0
- package/dist/next/server/componentActions.d.ts +12 -0
- package/dist/next/server/cusActions.d.mts +633 -0
- package/dist/next/server/cusActions.d.ts +633 -0
- package/dist/next/server/cusTypes-CrLBF0Kx.d.mts +327 -0
- package/dist/next/server/cusTypes-CrLBF0Kx.d.ts +327 -0
- package/dist/next/server/genActions.d.mts +84 -0
- package/dist/next/server/genActions.d.ts +84 -0
- package/dist/next/server/response-eH4S4sg0.d.mts +29 -0
- package/dist/next/server/response-eH4S4sg0.d.ts +29 -0
- package/dist/next/server/utils.d.mts +5 -0
- package/dist/next/server/utils.d.ts +5 -0
- package/dist/utils/encryptUtils.d.mts +4 -0
- package/dist/utils/encryptUtils.d.ts +4 -0
- package/dist/utils/entityUtils.d.mts +3 -0
- package/dist/utils/entityUtils.d.ts +3 -0
- package/dist/utils/logger.d.mts +45 -0
- package/dist/utils/logger.d.ts +45 -0
- package/dist/utils/toSnakeCase.d.mts +7 -0
- package/dist/utils/toSnakeCase.d.ts +7 -0
- package/package.json +1 -1
- package/dist/libraries/backend/chunk-6DZX6EAA.mjs +0 -37
- package/dist/libraries/react/chunk-5AWCXHI3.mjs +0 -743
- package/dist/libraries/react/{chunk-BVLKOMJA.mjs → chunk-74TUFYHU.mjs} +3 -3
- package/dist/libraries/react/{chunk-AHFPBGNV.mjs → chunk-MM4LTFTB.mjs} +3 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { A as AutumnError } from '../error-DHbclCVh.mjs';
|
|
2
|
+
import { A as AttachParams, a as AutumnPromise, g as CheckResult, T as TrackParams, b as TrackResult, C as CancelParams, c as CancelResult, S as SetupPaymentParams, d as SetupPaymentResult, O as OpenBillingPortalParams, e as CheckoutParams, f as CheckParams, h as Success } from '../clientAttachTypes-yOuJqDWt.mjs';
|
|
3
|
+
import { A as AttachResult, C as CheckoutResult, b as CreateEntityParams, a as CreateReferralCodeResult, R as RedeemReferralCodeResult } from '../clientEntTypes-aLfa3lyP.mjs';
|
|
4
|
+
import { f as CustomerExpandOption, a as Customer, B as BillingPortalResult } from '../cusTypes-CXjHwB-c.mjs';
|
|
5
|
+
import { E as Entity } from '../entTypes-BkN-Puru.mjs';
|
|
6
|
+
import { SWRConfiguration } from 'swr';
|
|
7
|
+
import { z } from 'zod/v4';
|
|
8
|
+
import '../prodTypes-B_VMILpU.mjs';
|
|
9
|
+
|
|
10
|
+
declare const CreateReferralCodeParamsSchema: z.ZodObject<{
|
|
11
|
+
programId: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
type CreateReferralCodeParams = z.infer<typeof CreateReferralCodeParamsSchema>;
|
|
14
|
+
declare const RedeemReferralCodeParamsSchema: z.ZodObject<{
|
|
15
|
+
code: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
type RedeemReferralCodeParams = z.infer<typeof RedeemReferralCodeParamsSchema>;
|
|
18
|
+
|
|
19
|
+
interface UseCustomerResult {
|
|
20
|
+
/** The current customer data including subscription and feature information */
|
|
21
|
+
customer: Customer | null;
|
|
22
|
+
/** Whether customer data is currently being loaded */
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
/** Any error that occurred while fetching customer data */
|
|
25
|
+
error: AutumnError | null;
|
|
26
|
+
/**
|
|
27
|
+
* Attaches a product to the current customer, enabling access and handling billing.
|
|
28
|
+
* Activates a product and applies all product items with automatic payment handling.
|
|
29
|
+
*/
|
|
30
|
+
attach: (params: AttachParams) => AutumnPromise<AttachResult | CheckResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Tracks usage events for metered features.
|
|
33
|
+
* Records feature usage and updates customer balances server-side.
|
|
34
|
+
*/
|
|
35
|
+
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Cancels a customer's subscription or product attachment.
|
|
38
|
+
* Can cancel immediately or at the end of the billing cycle.
|
|
39
|
+
*/
|
|
40
|
+
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Sets up a payment method for the customer.
|
|
43
|
+
* Collects payment information without immediately charging.
|
|
44
|
+
*/
|
|
45
|
+
setupPayment: (params: SetupPaymentParams) => AutumnPromise<SetupPaymentResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Opens the Stripe billing portal for the customer.
|
|
48
|
+
* Allows customers to manage their subscription and payment methods.
|
|
49
|
+
*/
|
|
50
|
+
openBillingPortal: (params?: OpenBillingPortalParams) => AutumnPromise<BillingPortalResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Initiates a checkout flow for product purchase.
|
|
53
|
+
* Handles payment collection and redirects to Stripe checkout when needed.
|
|
54
|
+
*/
|
|
55
|
+
checkout: (params: CheckoutParams) => AutumnPromise<CheckoutResult>;
|
|
56
|
+
/** Refetches the customer data from the server */
|
|
57
|
+
refetch: () => Promise<Customer | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Creates new entities for granular feature tracking.
|
|
60
|
+
* Entities allow per-user or per-workspace feature limits.
|
|
61
|
+
*/
|
|
62
|
+
createEntity: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a referral code for the customer.
|
|
65
|
+
* Generates codes that can be shared for referral programs.
|
|
66
|
+
*/
|
|
67
|
+
createReferralCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Redeems a referral code for the customer.
|
|
70
|
+
* Applies referral benefits when a valid code is provided.
|
|
71
|
+
*/
|
|
72
|
+
redeemReferralCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a customer has access to a feature and shows paywalls if needed.
|
|
75
|
+
* Client-side feature gating with optional dialog display for upgrades.
|
|
76
|
+
*/
|
|
77
|
+
check: (params: CheckParams) => Success<CheckResult>;
|
|
78
|
+
}
|
|
79
|
+
interface UseCustomerParams {
|
|
80
|
+
errorOnNotFound?: boolean;
|
|
81
|
+
expand?: CustomerExpandOption[];
|
|
82
|
+
swrConfig?: SWRConfiguration;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare const useCustomer: (params?: UseCustomerParams) => UseCustomerResult;
|
|
86
|
+
|
|
87
|
+
export { useCustomer };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { A as AutumnError } from '../error-DHbclCVh.js';
|
|
2
|
+
import { A as AttachParams, a as AutumnPromise, g as CheckResult, T as TrackParams, b as TrackResult, C as CancelParams, c as CancelResult, S as SetupPaymentParams, d as SetupPaymentResult, O as OpenBillingPortalParams, e as CheckoutParams, f as CheckParams, h as Success } from '../clientAttachTypes-BtZh00uu.js';
|
|
3
|
+
import { A as AttachResult, C as CheckoutResult, b as CreateEntityParams, a as CreateReferralCodeResult, R as RedeemReferralCodeResult } from '../clientEntTypes-Bsi7ciUF.js';
|
|
4
|
+
import { f as CustomerExpandOption, a as Customer, B as BillingPortalResult } from '../cusTypes-B-rJwpui.js';
|
|
5
|
+
import { E as Entity } from '../entTypes-DjKFS-Zk.js';
|
|
6
|
+
import { SWRConfiguration } from 'swr';
|
|
7
|
+
import { z } from 'zod/v4';
|
|
8
|
+
import '../prodTypes-B_VMILpU.js';
|
|
9
|
+
|
|
10
|
+
declare const CreateReferralCodeParamsSchema: z.ZodObject<{
|
|
11
|
+
programId: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
type CreateReferralCodeParams = z.infer<typeof CreateReferralCodeParamsSchema>;
|
|
14
|
+
declare const RedeemReferralCodeParamsSchema: z.ZodObject<{
|
|
15
|
+
code: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
type RedeemReferralCodeParams = z.infer<typeof RedeemReferralCodeParamsSchema>;
|
|
18
|
+
|
|
19
|
+
interface UseCustomerResult {
|
|
20
|
+
/** The current customer data including subscription and feature information */
|
|
21
|
+
customer: Customer | null;
|
|
22
|
+
/** Whether customer data is currently being loaded */
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
/** Any error that occurred while fetching customer data */
|
|
25
|
+
error: AutumnError | null;
|
|
26
|
+
/**
|
|
27
|
+
* Attaches a product to the current customer, enabling access and handling billing.
|
|
28
|
+
* Activates a product and applies all product items with automatic payment handling.
|
|
29
|
+
*/
|
|
30
|
+
attach: (params: AttachParams) => AutumnPromise<AttachResult | CheckResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Tracks usage events for metered features.
|
|
33
|
+
* Records feature usage and updates customer balances server-side.
|
|
34
|
+
*/
|
|
35
|
+
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Cancels a customer's subscription or product attachment.
|
|
38
|
+
* Can cancel immediately or at the end of the billing cycle.
|
|
39
|
+
*/
|
|
40
|
+
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Sets up a payment method for the customer.
|
|
43
|
+
* Collects payment information without immediately charging.
|
|
44
|
+
*/
|
|
45
|
+
setupPayment: (params: SetupPaymentParams) => AutumnPromise<SetupPaymentResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Opens the Stripe billing portal for the customer.
|
|
48
|
+
* Allows customers to manage their subscription and payment methods.
|
|
49
|
+
*/
|
|
50
|
+
openBillingPortal: (params?: OpenBillingPortalParams) => AutumnPromise<BillingPortalResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Initiates a checkout flow for product purchase.
|
|
53
|
+
* Handles payment collection and redirects to Stripe checkout when needed.
|
|
54
|
+
*/
|
|
55
|
+
checkout: (params: CheckoutParams) => AutumnPromise<CheckoutResult>;
|
|
56
|
+
/** Refetches the customer data from the server */
|
|
57
|
+
refetch: () => Promise<Customer | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Creates new entities for granular feature tracking.
|
|
60
|
+
* Entities allow per-user or per-workspace feature limits.
|
|
61
|
+
*/
|
|
62
|
+
createEntity: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a referral code for the customer.
|
|
65
|
+
* Generates codes that can be shared for referral programs.
|
|
66
|
+
*/
|
|
67
|
+
createReferralCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Redeems a referral code for the customer.
|
|
70
|
+
* Applies referral benefits when a valid code is provided.
|
|
71
|
+
*/
|
|
72
|
+
redeemReferralCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a customer has access to a feature and shows paywalls if needed.
|
|
75
|
+
* Client-side feature gating with optional dialog display for upgrades.
|
|
76
|
+
*/
|
|
77
|
+
check: (params: CheckParams) => Success<CheckResult>;
|
|
78
|
+
}
|
|
79
|
+
interface UseCustomerParams {
|
|
80
|
+
errorOnNotFound?: boolean;
|
|
81
|
+
expand?: CustomerExpandOption[];
|
|
82
|
+
swrConfig?: SWRConfiguration;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare const useCustomer: (params?: UseCustomerParams) => UseCustomerResult;
|
|
86
|
+
|
|
87
|
+
export { useCustomer };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { f as CheckParams, g as CheckResult, A as AttachParams, C as CancelParams, a as AutumnPromise, T as TrackParams } from '../clientAttachTypes-yOuJqDWt.mjs';
|
|
2
|
+
import { G as GetEntityParams, E as Entity } from '../entTypes-BkN-Puru.mjs';
|
|
3
|
+
import * as swr from 'swr';
|
|
4
|
+
import '../prodTypes-B_VMILpU.mjs';
|
|
5
|
+
import 'zod/v4';
|
|
6
|
+
import '../error-DHbclCVh.mjs';
|
|
7
|
+
import '../cusTypes-CXjHwB-c.mjs';
|
|
8
|
+
|
|
9
|
+
declare const useEntity: (entityId: string | null, params?: GetEntityParams) => {
|
|
10
|
+
entity: Entity | null;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
error: any;
|
|
13
|
+
refetch: swr.KeyedMutator<Entity | null>;
|
|
14
|
+
check: (params: CheckParams) => {
|
|
15
|
+
data: CheckResult;
|
|
16
|
+
error: null;
|
|
17
|
+
};
|
|
18
|
+
attach: (params: AttachParams) => Promise<any>;
|
|
19
|
+
cancel: (params: CancelParams) => AutumnPromise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
customer_id: string;
|
|
22
|
+
product_id: string;
|
|
23
|
+
}>;
|
|
24
|
+
track: (params: TrackParams) => AutumnPromise<{
|
|
25
|
+
id: string;
|
|
26
|
+
code: string;
|
|
27
|
+
customer_id: string;
|
|
28
|
+
feature_id?: string | undefined;
|
|
29
|
+
event_name?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useEntity };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { f as CheckParams, g as CheckResult, A as AttachParams, C as CancelParams, a as AutumnPromise, T as TrackParams } from '../clientAttachTypes-BtZh00uu.js';
|
|
2
|
+
import { G as GetEntityParams, E as Entity } from '../entTypes-DjKFS-Zk.js';
|
|
3
|
+
import * as swr from 'swr';
|
|
4
|
+
import '../prodTypes-B_VMILpU.js';
|
|
5
|
+
import 'zod/v4';
|
|
6
|
+
import '../error-DHbclCVh.js';
|
|
7
|
+
import '../cusTypes-B-rJwpui.js';
|
|
8
|
+
|
|
9
|
+
declare const useEntity: (entityId: string | null, params?: GetEntityParams) => {
|
|
10
|
+
entity: Entity | null;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
error: any;
|
|
13
|
+
refetch: swr.KeyedMutator<Entity | null>;
|
|
14
|
+
check: (params: CheckParams) => {
|
|
15
|
+
data: CheckResult;
|
|
16
|
+
error: null;
|
|
17
|
+
};
|
|
18
|
+
attach: (params: AttachParams) => Promise<any>;
|
|
19
|
+
cancel: (params: CancelParams) => AutumnPromise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
customer_id: string;
|
|
22
|
+
product_id: string;
|
|
23
|
+
}>;
|
|
24
|
+
track: (params: TrackParams) => AutumnPromise<{
|
|
25
|
+
id: string;
|
|
26
|
+
code: string;
|
|
27
|
+
customer_id: string;
|
|
28
|
+
feature_id?: string | undefined;
|
|
29
|
+
event_name?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useEntity };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import { A as AutumnError } from '../error-DHbclCVh.mjs';
|
|
3
|
+
import { P as Product } from '../prodTypes-B_VMILpU.mjs';
|
|
4
|
+
import 'zod/v4';
|
|
5
|
+
|
|
6
|
+
interface ProductDetails {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
buttonText?: string;
|
|
11
|
+
buttonUrl?: string;
|
|
12
|
+
recommendText?: string;
|
|
13
|
+
everythingFrom?: string;
|
|
14
|
+
price?: {
|
|
15
|
+
primaryText: string;
|
|
16
|
+
secondaryText?: string;
|
|
17
|
+
};
|
|
18
|
+
items?: {
|
|
19
|
+
featureId?: string;
|
|
20
|
+
primaryText?: string;
|
|
21
|
+
secondaryText?: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const usePricingTable: (params?: {
|
|
26
|
+
productDetails?: ProductDetails[];
|
|
27
|
+
}) => {
|
|
28
|
+
products: Product[] | null;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
error: AutumnError | undefined;
|
|
31
|
+
refetch: swr.KeyedMutator<Product[]>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { usePricingTable };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import { A as AutumnError } from '../error-DHbclCVh.js';
|
|
3
|
+
import { P as Product } from '../prodTypes-B_VMILpU.js';
|
|
4
|
+
import 'zod/v4';
|
|
5
|
+
|
|
6
|
+
interface ProductDetails {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
buttonText?: string;
|
|
11
|
+
buttonUrl?: string;
|
|
12
|
+
recommendText?: string;
|
|
13
|
+
everythingFrom?: string;
|
|
14
|
+
price?: {
|
|
15
|
+
primaryText: string;
|
|
16
|
+
secondaryText?: string;
|
|
17
|
+
};
|
|
18
|
+
items?: {
|
|
19
|
+
featureId?: string;
|
|
20
|
+
primaryText?: string;
|
|
21
|
+
secondaryText?: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const usePricingTable: (params?: {
|
|
26
|
+
productDetails?: ProductDetails[];
|
|
27
|
+
}) => {
|
|
28
|
+
products: Product[] | null;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
error: AutumnError | undefined;
|
|
31
|
+
refetch: swr.KeyedMutator<Product[]>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { usePricingTable };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
|
|
3
|
+
declare const Infinite = "inf";
|
|
4
|
+
declare enum FreeTrialDuration {
|
|
5
|
+
Day = "day"
|
|
6
|
+
}
|
|
7
|
+
declare enum UsageModel {
|
|
8
|
+
Prepaid = "prepaid",
|
|
9
|
+
PayPerUse = "pay_per_use"
|
|
10
|
+
}
|
|
11
|
+
type UsageModelType = "prepaid" | "pay_per_use";
|
|
12
|
+
declare enum ProductItemInterval {
|
|
13
|
+
Minute = "minute",
|
|
14
|
+
Hour = "hour",
|
|
15
|
+
Day = "day",
|
|
16
|
+
Week = "week",
|
|
17
|
+
Month = "month",
|
|
18
|
+
Quarter = "quarter",
|
|
19
|
+
SemiAnnual = "semi_annual",
|
|
20
|
+
Year = "year",
|
|
21
|
+
Multiple = "multiple"
|
|
22
|
+
}
|
|
23
|
+
type ProductItemIntervalType = "minute" | "hour" | "day" | "week" | "month" | "quarter" | "semi_annual" | "year" | "multiple";
|
|
24
|
+
|
|
25
|
+
declare const CheckFeatureResultSchema: z.ZodObject<{
|
|
26
|
+
allowed: z.ZodBoolean;
|
|
27
|
+
feature_id: z.ZodString;
|
|
28
|
+
customer_id: z.ZodString;
|
|
29
|
+
entity_id: z.ZodOptional<z.ZodString>;
|
|
30
|
+
required_balance: z.ZodNumber;
|
|
31
|
+
unlimited: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
interval: z.ZodOptional<z.ZodEnum<typeof ProductItemInterval>>;
|
|
33
|
+
balance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
usage: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
included_usage: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
next_reset_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
37
|
+
overage_allowed: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
usage_limit: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
rollovers: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
balance: z.ZodNumber;
|
|
41
|
+
expires_at: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
breakdown: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
44
|
+
interval: z.ZodEnum<typeof ProductItemInterval>;
|
|
45
|
+
balance: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
usage: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
included_usage: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
next_reset_at: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, z.core.$strip>>>;
|
|
50
|
+
credit_schema: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
feature_id: z.ZodString;
|
|
52
|
+
credit_amount: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
type CheckFeatureResult = z.infer<typeof CheckFeatureResultSchema>;
|
|
56
|
+
type ProductScenario = "scheduled" | "active" | "new" | "renew" | "upgrade" | "downgrade" | "cancel";
|
|
57
|
+
interface CheckProductResult {
|
|
58
|
+
allowed: boolean;
|
|
59
|
+
customer_id: string;
|
|
60
|
+
product_id: string;
|
|
61
|
+
entity_id?: string;
|
|
62
|
+
status?: string;
|
|
63
|
+
preview?: CheckProductPreview;
|
|
64
|
+
}
|
|
65
|
+
interface CheckProductPreview {
|
|
66
|
+
scenario: ProductScenario;
|
|
67
|
+
product_id: string;
|
|
68
|
+
product_name: string;
|
|
69
|
+
recurring: boolean;
|
|
70
|
+
error_on_attach?: boolean;
|
|
71
|
+
next_cycle_at?: number;
|
|
72
|
+
current_product_name?: string;
|
|
73
|
+
items?: {
|
|
74
|
+
price: string;
|
|
75
|
+
description: string;
|
|
76
|
+
usage_model?: UsageModelType;
|
|
77
|
+
}[];
|
|
78
|
+
options?: {
|
|
79
|
+
feature_id: string;
|
|
80
|
+
feature_name: string;
|
|
81
|
+
billing_units: number;
|
|
82
|
+
price?: number;
|
|
83
|
+
tiers?: {
|
|
84
|
+
to: number | string;
|
|
85
|
+
amount: number;
|
|
86
|
+
}[];
|
|
87
|
+
}[];
|
|
88
|
+
due_today?: {
|
|
89
|
+
price: number;
|
|
90
|
+
currency: string;
|
|
91
|
+
};
|
|
92
|
+
due_next_cycle?: {
|
|
93
|
+
price: number;
|
|
94
|
+
currency: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare enum AppEnv {
|
|
99
|
+
Sandbox = "sandbox",
|
|
100
|
+
Live = "live"
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface Feature {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
type: "boolean" | "continuous_use" | "single_use" | "credit_system";
|
|
107
|
+
}
|
|
108
|
+
interface ProductItem {
|
|
109
|
+
type?: "feature" | "priced_feature" | "price";
|
|
110
|
+
feature_id?: string;
|
|
111
|
+
included_usage?: number | typeof Infinite;
|
|
112
|
+
interval?: ProductItemIntervalType;
|
|
113
|
+
feature?: Feature;
|
|
114
|
+
usage_model?: UsageModel;
|
|
115
|
+
price?: number;
|
|
116
|
+
billing_units?: number;
|
|
117
|
+
entity_feature_id?: string;
|
|
118
|
+
reset_usage_when_enabled?: boolean;
|
|
119
|
+
quantity?: number;
|
|
120
|
+
next_cycle_quantity?: number;
|
|
121
|
+
display?: {
|
|
122
|
+
primary_text?: string;
|
|
123
|
+
secondary_text?: string;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
interface FreeTrial {
|
|
127
|
+
duration: FreeTrialDuration;
|
|
128
|
+
length: number;
|
|
129
|
+
unique_fingerprint: boolean;
|
|
130
|
+
trial_available?: boolean;
|
|
131
|
+
}
|
|
132
|
+
interface Product {
|
|
133
|
+
id: string;
|
|
134
|
+
created_at: number;
|
|
135
|
+
name: string;
|
|
136
|
+
env: AppEnv;
|
|
137
|
+
is_add_on: boolean;
|
|
138
|
+
is_default: boolean;
|
|
139
|
+
group: string;
|
|
140
|
+
version: number;
|
|
141
|
+
items: ProductItem[];
|
|
142
|
+
free_trial: FreeTrial | null;
|
|
143
|
+
scenario?: ProductScenario;
|
|
144
|
+
base_variant_id: string | null;
|
|
145
|
+
properties: {
|
|
146
|
+
is_free: boolean;
|
|
147
|
+
is_one_off: boolean;
|
|
148
|
+
interval_group: string;
|
|
149
|
+
has_trial: boolean;
|
|
150
|
+
updateable: boolean;
|
|
151
|
+
};
|
|
152
|
+
display?: {
|
|
153
|
+
name?: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
button_text?: string;
|
|
156
|
+
recommend_text?: string;
|
|
157
|
+
everything_from?: string;
|
|
158
|
+
button_url?: string;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { AppEnv as A, type CheckFeatureResult as C, type Product as P, type ProductItem as a, ProductItemInterval as b, type CheckProductResult as c };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
|
|
3
|
+
declare const Infinite = "inf";
|
|
4
|
+
declare enum FreeTrialDuration {
|
|
5
|
+
Day = "day"
|
|
6
|
+
}
|
|
7
|
+
declare enum UsageModel {
|
|
8
|
+
Prepaid = "prepaid",
|
|
9
|
+
PayPerUse = "pay_per_use"
|
|
10
|
+
}
|
|
11
|
+
type UsageModelType = "prepaid" | "pay_per_use";
|
|
12
|
+
declare enum ProductItemInterval {
|
|
13
|
+
Minute = "minute",
|
|
14
|
+
Hour = "hour",
|
|
15
|
+
Day = "day",
|
|
16
|
+
Week = "week",
|
|
17
|
+
Month = "month",
|
|
18
|
+
Quarter = "quarter",
|
|
19
|
+
SemiAnnual = "semi_annual",
|
|
20
|
+
Year = "year",
|
|
21
|
+
Multiple = "multiple"
|
|
22
|
+
}
|
|
23
|
+
type ProductItemIntervalType = "minute" | "hour" | "day" | "week" | "month" | "quarter" | "semi_annual" | "year" | "multiple";
|
|
24
|
+
|
|
25
|
+
declare const CheckFeatureResultSchema: z.ZodObject<{
|
|
26
|
+
allowed: z.ZodBoolean;
|
|
27
|
+
feature_id: z.ZodString;
|
|
28
|
+
customer_id: z.ZodString;
|
|
29
|
+
entity_id: z.ZodOptional<z.ZodString>;
|
|
30
|
+
required_balance: z.ZodNumber;
|
|
31
|
+
unlimited: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
interval: z.ZodOptional<z.ZodEnum<typeof ProductItemInterval>>;
|
|
33
|
+
balance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
usage: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
included_usage: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
next_reset_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
37
|
+
overage_allowed: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
usage_limit: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
rollovers: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
balance: z.ZodNumber;
|
|
41
|
+
expires_at: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
breakdown: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
44
|
+
interval: z.ZodEnum<typeof ProductItemInterval>;
|
|
45
|
+
balance: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
usage: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
included_usage: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
next_reset_at: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, z.core.$strip>>>;
|
|
50
|
+
credit_schema: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
feature_id: z.ZodString;
|
|
52
|
+
credit_amount: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
type CheckFeatureResult = z.infer<typeof CheckFeatureResultSchema>;
|
|
56
|
+
type ProductScenario = "scheduled" | "active" | "new" | "renew" | "upgrade" | "downgrade" | "cancel";
|
|
57
|
+
interface CheckProductResult {
|
|
58
|
+
allowed: boolean;
|
|
59
|
+
customer_id: string;
|
|
60
|
+
product_id: string;
|
|
61
|
+
entity_id?: string;
|
|
62
|
+
status?: string;
|
|
63
|
+
preview?: CheckProductPreview;
|
|
64
|
+
}
|
|
65
|
+
interface CheckProductPreview {
|
|
66
|
+
scenario: ProductScenario;
|
|
67
|
+
product_id: string;
|
|
68
|
+
product_name: string;
|
|
69
|
+
recurring: boolean;
|
|
70
|
+
error_on_attach?: boolean;
|
|
71
|
+
next_cycle_at?: number;
|
|
72
|
+
current_product_name?: string;
|
|
73
|
+
items?: {
|
|
74
|
+
price: string;
|
|
75
|
+
description: string;
|
|
76
|
+
usage_model?: UsageModelType;
|
|
77
|
+
}[];
|
|
78
|
+
options?: {
|
|
79
|
+
feature_id: string;
|
|
80
|
+
feature_name: string;
|
|
81
|
+
billing_units: number;
|
|
82
|
+
price?: number;
|
|
83
|
+
tiers?: {
|
|
84
|
+
to: number | string;
|
|
85
|
+
amount: number;
|
|
86
|
+
}[];
|
|
87
|
+
}[];
|
|
88
|
+
due_today?: {
|
|
89
|
+
price: number;
|
|
90
|
+
currency: string;
|
|
91
|
+
};
|
|
92
|
+
due_next_cycle?: {
|
|
93
|
+
price: number;
|
|
94
|
+
currency: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare enum AppEnv {
|
|
99
|
+
Sandbox = "sandbox",
|
|
100
|
+
Live = "live"
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface Feature {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
type: "boolean" | "continuous_use" | "single_use" | "credit_system";
|
|
107
|
+
}
|
|
108
|
+
interface ProductItem {
|
|
109
|
+
type?: "feature" | "priced_feature" | "price";
|
|
110
|
+
feature_id?: string;
|
|
111
|
+
included_usage?: number | typeof Infinite;
|
|
112
|
+
interval?: ProductItemIntervalType;
|
|
113
|
+
feature?: Feature;
|
|
114
|
+
usage_model?: UsageModel;
|
|
115
|
+
price?: number;
|
|
116
|
+
billing_units?: number;
|
|
117
|
+
entity_feature_id?: string;
|
|
118
|
+
reset_usage_when_enabled?: boolean;
|
|
119
|
+
quantity?: number;
|
|
120
|
+
next_cycle_quantity?: number;
|
|
121
|
+
display?: {
|
|
122
|
+
primary_text?: string;
|
|
123
|
+
secondary_text?: string;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
interface FreeTrial {
|
|
127
|
+
duration: FreeTrialDuration;
|
|
128
|
+
length: number;
|
|
129
|
+
unique_fingerprint: boolean;
|
|
130
|
+
trial_available?: boolean;
|
|
131
|
+
}
|
|
132
|
+
interface Product {
|
|
133
|
+
id: string;
|
|
134
|
+
created_at: number;
|
|
135
|
+
name: string;
|
|
136
|
+
env: AppEnv;
|
|
137
|
+
is_add_on: boolean;
|
|
138
|
+
is_default: boolean;
|
|
139
|
+
group: string;
|
|
140
|
+
version: number;
|
|
141
|
+
items: ProductItem[];
|
|
142
|
+
free_trial: FreeTrial | null;
|
|
143
|
+
scenario?: ProductScenario;
|
|
144
|
+
base_variant_id: string | null;
|
|
145
|
+
properties: {
|
|
146
|
+
is_free: boolean;
|
|
147
|
+
is_one_off: boolean;
|
|
148
|
+
interval_group: string;
|
|
149
|
+
has_trial: boolean;
|
|
150
|
+
updateable: boolean;
|
|
151
|
+
};
|
|
152
|
+
display?: {
|
|
153
|
+
name?: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
button_text?: string;
|
|
156
|
+
recommend_text?: string;
|
|
157
|
+
everything_from?: string;
|
|
158
|
+
button_url?: string;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { AppEnv as A, type CheckFeatureResult as C, type Product as P, type ProductItem as a, ProductItemInterval as b, type CheckProductResult as c };
|