autumn-js 0.1.11 → 0.1.13
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.d.mts +4 -0
- package/dist/libraries/backend/better-auth.d.ts +4 -0
- package/dist/libraries/backend/better-auth.js +172 -2
- package/dist/libraries/backend/better-auth.mjs +7 -7
- package/dist/libraries/backend/{chunk-EW2R7722.mjs → chunk-2DWGCQCF.mjs} +1 -1
- package/dist/libraries/backend/{chunk-VNJ3MFJE.mjs → chunk-56RGUNOT.mjs} +1 -1
- package/dist/libraries/backend/{chunk-P3ARLB2M.mjs → chunk-6JI6MF4S.mjs} +1 -1
- package/dist/libraries/backend/{chunk-5DDCZMDB.mjs → chunk-FA5Z2MOT.mjs} +1 -1
- package/dist/libraries/backend/{chunk-RAHKKJED.mjs → chunk-NWPFUFXX.mjs} +6 -6
- package/dist/libraries/backend/{chunk-NAP2URIW.mjs → chunk-Q7SD535L.mjs} +172 -2
- package/dist/libraries/backend/{chunk-7K3RATTK.mjs → chunk-SDL7BFTH.mjs} +1 -1
- package/dist/libraries/backend/convex.js +172 -2
- package/dist/libraries/backend/convex.mjs +7 -7
- package/dist/libraries/backend/elysia.js +172 -2
- package/dist/libraries/backend/elysia.mjs +7 -7
- package/dist/libraries/backend/express.d.mts +1 -1
- package/dist/libraries/backend/express.d.ts +1 -1
- package/dist/libraries/backend/express.js +172 -2
- package/dist/libraries/backend/express.mjs +7 -7
- package/dist/libraries/backend/fastify.js +172 -2
- package/dist/libraries/backend/fastify.mjs +7 -7
- package/dist/libraries/backend/hono.js +172 -2
- package/dist/libraries/backend/hono.mjs +7 -7
- package/dist/libraries/backend/index.d.mts +1 -1
- package/dist/libraries/backend/index.d.ts +1 -1
- package/dist/libraries/backend/index.js +172 -2
- package/dist/libraries/backend/index.mjs +7 -7
- package/dist/libraries/backend/next.js +172 -2
- package/dist/libraries/backend/next.mjs +7 -7
- package/dist/libraries/backend/react-router.js +172 -2
- package/dist/libraries/backend/react-router.mjs +7 -7
- package/dist/libraries/backend/{referralTypes-C1eZ8cjO.d.mts → referralTypes-DSv2hpmP.d.mts} +178 -44
- package/dist/libraries/backend/{referralTypes-FlI0fYwz.d.ts → referralTypes-DdKvvqSK.d.ts} +178 -44
- package/dist/libraries/backend/remix_dep.js +172 -2
- package/dist/libraries/backend/remix_dep.mjs +7 -7
- package/dist/libraries/backend/routes/backendRouter.js +172 -2
- package/dist/libraries/backend/routes/backendRouter.mjs +7 -7
- package/dist/libraries/backend/routes/entityRoutes.js +172 -2
- package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/genRoutes.js +172 -2
- package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/productRoutes.js +172 -2
- package/dist/libraries/backend/routes/productRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/referralRoutes.js +172 -2
- package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
- package/dist/libraries/backend/supabase.js +172 -2
- package/dist/libraries/backend/supabase.mjs +7 -7
- package/dist/libraries/backend/tanstack.js +172 -2
- package/dist/libraries/backend/tanstack.mjs +7 -7
- package/dist/libraries/backend/utils/backendRes.js +172 -2
- package/dist/libraries/backend/utils/backendRes.mjs +1 -1
- package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
- package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
- package/dist/libraries/backend/utils/withAuth.js +172 -2
- package/dist/libraries/backend/utils/withAuth.mjs +2 -2
- package/dist/libraries/react/AutumnContext.js +176 -4
- package/dist/libraries/react/AutumnContext.mjs +4 -4
- package/dist/libraries/react/BaseAutumnProvider.js +176 -15
- package/dist/libraries/react/BaseAutumnProvider.mjs +9 -9
- package/dist/libraries/react/ReactAutumnProvider.js +176 -15
- package/dist/libraries/react/ReactAutumnProvider.mjs +10 -10
- package/dist/libraries/react/{chunk-2ENHPIYQ.mjs → chunk-52HVA7E4.mjs} +3 -3
- package/dist/libraries/react/{chunk-WYQMHQUE.mjs → chunk-5O3IHYFF.mjs} +172 -2
- package/dist/libraries/react/{chunk-JHFJKAXG.mjs → chunk-5YM6QT7V.mjs} +33 -33
- package/dist/libraries/react/{chunk-KP2Q65Y3.mjs → chunk-643J45JV.mjs} +2 -2
- package/dist/libraries/react/{chunk-YHT2JUXO.mjs → chunk-7HRCOEUW.mjs} +1 -1
- package/dist/libraries/react/{chunk-OMJJLT2Q.mjs → chunk-7JU3XHKL.mjs} +1 -1
- package/dist/libraries/react/{chunk-XK3AXQED.mjs → chunk-BT5OY2CA.mjs} +3 -13
- package/dist/libraries/react/{chunk-KMYL54B4.mjs → chunk-DKOF357C.mjs} +1 -1
- package/dist/libraries/react/{chunk-4NZ7ML7V.mjs → chunk-M3SON3SH.mjs} +2 -2
- package/dist/libraries/react/{chunk-67RWFVWN.mjs → chunk-OSYZMMQC.mjs} +2 -2
- package/dist/libraries/react/{chunk-6D6TYTTO.mjs → chunk-P6CAHZVT.mjs} +1 -2
- package/dist/libraries/react/{chunk-VZY225C6.mjs → chunk-RP56DI4O.mjs} +2 -2
- package/dist/libraries/react/{chunk-FDNQ6GRK.mjs → chunk-SWVRRNIW.mjs} +1 -1
- package/dist/libraries/react/{chunk-U3OQJXCW.mjs → chunk-TOAZUTY6.mjs} +8 -6
- package/dist/libraries/react/{chunk-3MF54MDU.mjs → chunk-WBBWID5F.mjs} +1 -1
- package/dist/libraries/react/{chunk-TTLL63A4.mjs → chunk-Z7REFVM4.mjs} +3 -3
- package/dist/libraries/react/client/ReactAutumnClient.js +176 -4
- package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
- package/dist/libraries/react/client/types/clientGenTypes.js +172 -2
- package/dist/libraries/react/client/types/clientGenTypes.mjs +1 -1
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.css +3 -0
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +181 -20
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.css +3 -0
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +176 -4
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.css +3 -0
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +181 -20
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +26 -26
- package/dist/libraries/react/components/ui/button.d.mts +2 -2
- package/dist/libraries/react/components/ui/button.d.ts +2 -2
- package/dist/libraries/react/components/ui/dialog.mjs +2 -2
- package/dist/libraries/react/components/ui/popover.mjs +2 -2
- package/dist/libraries/react/hooks/helpers/handleCheck.js +172 -2
- package/dist/libraries/react/hooks/helpers/handleCheck.mjs +2 -2
- package/dist/libraries/react/hooks/helpers/useAutumnBase.js +172 -3
- package/dist/libraries/react/hooks/helpers/useAutumnBase.mjs +3 -3
- package/dist/libraries/react/hooks/useAnalytics.js +176 -4
- package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
- package/dist/libraries/react/hooks/useCustomer.d.mts +60 -2
- package/dist/libraries/react/hooks/useCustomer.d.ts +60 -2
- package/dist/libraries/react/hooks/useCustomer.js +176 -15
- package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
- package/dist/libraries/react/hooks/useCustomerBase.d.mts +44 -3
- package/dist/libraries/react/hooks/useCustomerBase.d.ts +44 -3
- package/dist/libraries/react/hooks/useCustomerBase.js +176 -15
- package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
- package/dist/libraries/react/hooks/useEntity.js +176 -5
- package/dist/libraries/react/hooks/useEntity.mjs +9 -9
- package/dist/libraries/react/hooks/useEntityBase.js +176 -5
- package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
- package/dist/libraries/react/hooks/usePaywall.js +176 -4
- package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
- package/dist/libraries/react/hooks/usePricingTable.js +176 -4
- package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.js +172 -2
- package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
- package/dist/libraries/react/index.d.mts +104 -7
- package/dist/libraries/react/index.d.ts +104 -7
- package/dist/libraries/react/index.js +182 -21
- package/dist/libraries/react/index.mjs +182 -21
- package/dist/next/client/hooks/useCustomer.d.mts +44 -7
- package/dist/next/client/hooks/useCustomer.d.ts +44 -7
- package/dist/next/server/cusActions.d.mts +178 -44
- package/dist/next/server/cusActions.d.ts +178 -44
- package/dist/sdk/index.d.mts +178 -44
- package/dist/sdk/index.d.ts +178 -44
- package/dist/sdk/index.js +171 -1
- package/dist/sdk/index.mjs +171 -1
- package/dist/styles/global.css +3 -0
- package/dist/utils/encryptUtils.js +172 -2
- package/dist/utils/encryptUtils.mjs +172 -2
- package/package.json +1 -1
- package/dist/libraries/react/{chunk-7JNU5ABT.mjs → chunk-FJWZPMWU.mjs} +3 -3
- package/dist/libraries/react/{chunk-LCWL3TIT.mjs → chunk-OTZ65PCT.mjs} +3 -3
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
useCustomer
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-M3SON3SH.mjs";
|
|
6
|
+
import "../chunk-BT5OY2CA.mjs";
|
|
7
|
+
import "../chunk-DKOF357C.mjs";
|
|
8
|
+
import "../chunk-P6CAHZVT.mjs";
|
|
9
|
+
import "../chunk-7HRCOEUW.mjs";
|
|
10
|
+
import "../chunk-SWVRRNIW.mjs";
|
|
11
|
+
import "../chunk-TOAZUTY6.mjs";
|
|
12
|
+
import "../chunk-5O3IHYFF.mjs";
|
|
13
|
+
import "../chunk-JVCOY7ZL.mjs";
|
|
13
14
|
import "../chunk-CIBQ4BJU.mjs";
|
|
14
15
|
import "../chunk-V575SGOW.mjs";
|
|
15
16
|
import "../chunk-ZV4RPZTM.mjs";
|
|
16
|
-
import "../chunk-JVCOY7ZL.mjs";
|
|
17
17
|
import "../chunk-VTGR7VVK.mjs";
|
|
18
18
|
import "../chunk-WFFVOEUG.mjs";
|
|
19
19
|
import "../chunk-ZF2HUCN6.mjs";
|
|
@@ -9,28 +9,69 @@ import { CreateReferralCodeParams, RedeemReferralCodeParams } from '../client/ty
|
|
|
9
9
|
import { SWRConfiguration } from 'swr';
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import { TrackParams, CancelParams, SetupPaymentParams, OpenBillingPortalParams, CheckParams } from '../client/types/clientGenTypes.mjs';
|
|
12
|
-
import { AllowedParams } from './helpers/handleCheck.mjs';
|
|
13
12
|
import { AttachParams, CheckoutParams } from '../client/types/clientAttachTypes.mjs';
|
|
14
13
|
import '../prodTypes-B8NdKyKo.mjs';
|
|
15
14
|
import 'zod/v4';
|
|
16
|
-
import '../AutumnContext.mjs';
|
|
17
15
|
|
|
18
16
|
interface UseCustomerResult {
|
|
17
|
+
/** The current customer data including subscription and feature information */
|
|
19
18
|
customer: Customer | null;
|
|
19
|
+
/** Whether customer data is currently being loaded */
|
|
20
20
|
isLoading: boolean;
|
|
21
|
+
/** Any error that occurred while fetching customer data */
|
|
21
22
|
error: AutumnError | null;
|
|
23
|
+
/**
|
|
24
|
+
* Attaches a product to the current customer, enabling access and handling billing.
|
|
25
|
+
* Activates a product and applies all product items with automatic payment handling.
|
|
26
|
+
*/
|
|
22
27
|
attach: (params: AttachParams) => AutumnPromise<AttachResult | CheckResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Tracks usage events for metered features.
|
|
30
|
+
* Records feature usage and updates customer balances server-side.
|
|
31
|
+
*/
|
|
23
32
|
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Cancels a customer's subscription or product attachment.
|
|
35
|
+
* Can cancel immediately or at the end of the billing cycle.
|
|
36
|
+
*/
|
|
24
37
|
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets up a payment method for the customer.
|
|
40
|
+
* Collects payment information without immediately charging.
|
|
41
|
+
*/
|
|
25
42
|
setupPayment: (params: SetupPaymentParams) => AutumnPromise<SetupPaymentResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Opens the Stripe billing portal for the customer.
|
|
45
|
+
* Allows customers to manage their subscription and payment methods.
|
|
46
|
+
*/
|
|
26
47
|
openBillingPortal: (params?: OpenBillingPortalParams) => AutumnPromise<BillingPortalResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Initiates a checkout flow for product purchase.
|
|
50
|
+
* Handles payment collection and redirects to Stripe checkout when needed.
|
|
51
|
+
*/
|
|
27
52
|
checkout: (params: CheckoutParams) => AutumnPromise<CheckoutResult>;
|
|
53
|
+
/** Refetches the customer data from the server */
|
|
28
54
|
refetch: () => Promise<Customer | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates new entities for granular feature tracking.
|
|
57
|
+
* Entities allow per-user or per-workspace feature limits.
|
|
58
|
+
*/
|
|
29
59
|
createEntity: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a referral code for the customer.
|
|
62
|
+
* Generates codes that can be shared for referral programs.
|
|
63
|
+
*/
|
|
30
64
|
createReferralCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Redeems a referral code for the customer.
|
|
67
|
+
* Applies referral benefits when a valid code is provided.
|
|
68
|
+
*/
|
|
31
69
|
redeemReferralCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a customer has access to a feature and shows paywalls if needed.
|
|
72
|
+
* Client-side feature gating with optional dialog display for upgrades.
|
|
73
|
+
*/
|
|
32
74
|
check: (params: CheckParams) => Success<CheckResult>;
|
|
33
|
-
allowed: (params: AllowedParams) => boolean;
|
|
34
75
|
}
|
|
35
76
|
interface UseCustomerParams {
|
|
36
77
|
errorOnNotFound?: boolean;
|
|
@@ -9,28 +9,69 @@ import { CreateReferralCodeParams, RedeemReferralCodeParams } from '../client/ty
|
|
|
9
9
|
import { SWRConfiguration } from 'swr';
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import { TrackParams, CancelParams, SetupPaymentParams, OpenBillingPortalParams, CheckParams } from '../client/types/clientGenTypes.js';
|
|
12
|
-
import { AllowedParams } from './helpers/handleCheck.js';
|
|
13
12
|
import { AttachParams, CheckoutParams } from '../client/types/clientAttachTypes.js';
|
|
14
13
|
import '../prodTypes-B8NdKyKo.js';
|
|
15
14
|
import 'zod/v4';
|
|
16
|
-
import '../AutumnContext.js';
|
|
17
15
|
|
|
18
16
|
interface UseCustomerResult {
|
|
17
|
+
/** The current customer data including subscription and feature information */
|
|
19
18
|
customer: Customer | null;
|
|
19
|
+
/** Whether customer data is currently being loaded */
|
|
20
20
|
isLoading: boolean;
|
|
21
|
+
/** Any error that occurred while fetching customer data */
|
|
21
22
|
error: AutumnError | null;
|
|
23
|
+
/**
|
|
24
|
+
* Attaches a product to the current customer, enabling access and handling billing.
|
|
25
|
+
* Activates a product and applies all product items with automatic payment handling.
|
|
26
|
+
*/
|
|
22
27
|
attach: (params: AttachParams) => AutumnPromise<AttachResult | CheckResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Tracks usage events for metered features.
|
|
30
|
+
* Records feature usage and updates customer balances server-side.
|
|
31
|
+
*/
|
|
23
32
|
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Cancels a customer's subscription or product attachment.
|
|
35
|
+
* Can cancel immediately or at the end of the billing cycle.
|
|
36
|
+
*/
|
|
24
37
|
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets up a payment method for the customer.
|
|
40
|
+
* Collects payment information without immediately charging.
|
|
41
|
+
*/
|
|
25
42
|
setupPayment: (params: SetupPaymentParams) => AutumnPromise<SetupPaymentResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Opens the Stripe billing portal for the customer.
|
|
45
|
+
* Allows customers to manage their subscription and payment methods.
|
|
46
|
+
*/
|
|
26
47
|
openBillingPortal: (params?: OpenBillingPortalParams) => AutumnPromise<BillingPortalResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Initiates a checkout flow for product purchase.
|
|
50
|
+
* Handles payment collection and redirects to Stripe checkout when needed.
|
|
51
|
+
*/
|
|
27
52
|
checkout: (params: CheckoutParams) => AutumnPromise<CheckoutResult>;
|
|
53
|
+
/** Refetches the customer data from the server */
|
|
28
54
|
refetch: () => Promise<Customer | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates new entities for granular feature tracking.
|
|
57
|
+
* Entities allow per-user or per-workspace feature limits.
|
|
58
|
+
*/
|
|
29
59
|
createEntity: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a referral code for the customer.
|
|
62
|
+
* Generates codes that can be shared for referral programs.
|
|
63
|
+
*/
|
|
30
64
|
createReferralCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Redeems a referral code for the customer.
|
|
67
|
+
* Applies referral benefits when a valid code is provided.
|
|
68
|
+
*/
|
|
31
69
|
redeemReferralCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a customer has access to a feature and shows paywalls if needed.
|
|
72
|
+
* Client-side feature gating with optional dialog display for upgrades.
|
|
73
|
+
*/
|
|
32
74
|
check: (params: CheckParams) => Success<CheckResult>;
|
|
33
|
-
allowed: (params: AllowedParams) => boolean;
|
|
34
75
|
}
|
|
35
76
|
interface UseCustomerParams {
|
|
36
77
|
errorOnNotFound?: boolean;
|
|
@@ -502,22 +502,92 @@ var Autumn = class {
|
|
|
502
502
|
entities = entityMethods(this);
|
|
503
503
|
referrals = referralMethods(this);
|
|
504
504
|
features = featureMethods(this);
|
|
505
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Initiates a checkout flow for a product purchase.
|
|
507
|
+
*
|
|
508
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
509
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
510
|
+
* to Stripe based on the customer's state and product requirements.
|
|
511
|
+
*
|
|
512
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
513
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```typescript
|
|
517
|
+
* const result = await autumn.checkout({
|
|
518
|
+
* customer_id: "user_123",
|
|
519
|
+
* product_id: "pro",
|
|
520
|
+
* success_url: "https://myapp.com/success"
|
|
521
|
+
* });
|
|
522
|
+
*
|
|
523
|
+
* if (result.url) {
|
|
524
|
+
* // Redirect to Stripe checkout
|
|
525
|
+
* window.location.href = result.url;
|
|
526
|
+
* }
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
506
529
|
async checkout(params) {
|
|
507
530
|
return handleCheckout({
|
|
508
531
|
instance: this,
|
|
509
532
|
params
|
|
510
533
|
});
|
|
511
534
|
}
|
|
512
|
-
static
|
|
535
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
513
536
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
537
|
+
/**
|
|
538
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
539
|
+
*
|
|
540
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
541
|
+
* When you attach a product:
|
|
542
|
+
* - The customer gains access to all features in the product
|
|
543
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
544
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
545
|
+
*
|
|
546
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
547
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```typescript
|
|
551
|
+
* const result = await autumn.attach({
|
|
552
|
+
* customer_id: "user_123",
|
|
553
|
+
* product_id: "pro",
|
|
554
|
+
* success_url: "https://myapp.com/success"
|
|
555
|
+
* });
|
|
556
|
+
*
|
|
557
|
+
* if (result.checkout_url) {
|
|
558
|
+
* // Payment required - redirect to checkout
|
|
559
|
+
* window.location.href = result.checkout_url;
|
|
560
|
+
* } else {
|
|
561
|
+
* // Product successfully attached
|
|
562
|
+
* console.log("Access granted:", result.message);
|
|
563
|
+
* }
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
514
566
|
async attach(params) {
|
|
515
567
|
return handleAttach({
|
|
516
568
|
instance: this,
|
|
517
569
|
params
|
|
518
570
|
});
|
|
519
571
|
}
|
|
572
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
520
573
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
574
|
+
/**
|
|
575
|
+
* Sets up a payment method for a customer.
|
|
576
|
+
*
|
|
577
|
+
* This method allows you to set up payment methods for customers without
|
|
578
|
+
* immediately charging them. Useful for collecting payment information
|
|
579
|
+
* before product attachment or for updating existing payment methods.
|
|
580
|
+
*
|
|
581
|
+
* @param params - Setup payment parameters including customer information
|
|
582
|
+
* @returns Promise resolving to setup payment result
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```typescript
|
|
586
|
+
* const result = await autumn.setupPayment({
|
|
587
|
+
* customer_id: "user_123"
|
|
588
|
+
* });
|
|
589
|
+
* ```
|
|
590
|
+
*/
|
|
521
591
|
async setupPayment(params) {
|
|
522
592
|
return handleSetupPayment({
|
|
523
593
|
instance: this,
|
|
@@ -525,6 +595,24 @@ var Autumn = class {
|
|
|
525
595
|
});
|
|
526
596
|
}
|
|
527
597
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
598
|
+
/**
|
|
599
|
+
* Cancels a customer's subscription or product attachment.
|
|
600
|
+
*
|
|
601
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
602
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
603
|
+
*
|
|
604
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
605
|
+
* @returns Promise resolving to cancellation result
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```typescript
|
|
609
|
+
* const result = await autumn.cancel({
|
|
610
|
+
* customer_id: "user_123",
|
|
611
|
+
* product_id: "pro",
|
|
612
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
613
|
+
* });
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
528
616
|
async cancel(params) {
|
|
529
617
|
return handleCancel({
|
|
530
618
|
instance: this,
|
|
@@ -532,6 +620,29 @@ var Autumn = class {
|
|
|
532
620
|
});
|
|
533
621
|
}
|
|
534
622
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
623
|
+
/**
|
|
624
|
+
* Checks if a customer has access to a specific feature.
|
|
625
|
+
*
|
|
626
|
+
* This method verifies whether a customer has permission to use a feature
|
|
627
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
628
|
+
* features and determine when to show upgrade prompts.
|
|
629
|
+
*
|
|
630
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
631
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const result = await autumn.check({
|
|
636
|
+
* customer_id: "user_123",
|
|
637
|
+
* feature_id: "messages",
|
|
638
|
+
* required_balance: 1
|
|
639
|
+
* });
|
|
640
|
+
*
|
|
641
|
+
* if (!result.allowed) {
|
|
642
|
+
* console.log("Feature access denied - upgrade required");
|
|
643
|
+
* }
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
535
646
|
async check(params) {
|
|
536
647
|
return handleCheck({
|
|
537
648
|
instance: this,
|
|
@@ -539,12 +650,50 @@ var Autumn = class {
|
|
|
539
650
|
});
|
|
540
651
|
}
|
|
541
652
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
653
|
+
/**
|
|
654
|
+
* Tracks usage events for features or analytics.
|
|
655
|
+
*
|
|
656
|
+
* This method records usage events for metered features, updating the customer's
|
|
657
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
658
|
+
* accurate tracking that cannot be manipulated by users.
|
|
659
|
+
*
|
|
660
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
661
|
+
* @returns Promise resolving to tracking result
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* const result = await autumn.track({
|
|
666
|
+
* customer_id: "user_123",
|
|
667
|
+
* feature_id: "messages",
|
|
668
|
+
* value: 1 // Track 1 message sent
|
|
669
|
+
* });
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
542
672
|
async track(params) {
|
|
543
673
|
return handleTrack({
|
|
544
674
|
instance: this,
|
|
545
675
|
params
|
|
546
676
|
});
|
|
547
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
680
|
+
*
|
|
681
|
+
* This method fetches detailed usage information for a customer's features,
|
|
682
|
+
* including current balances, usage history, and analytics data. Useful
|
|
683
|
+
* for displaying usage dashboards or generating reports.
|
|
684
|
+
*
|
|
685
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
686
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```typescript
|
|
690
|
+
* const result = await autumn.usage({
|
|
691
|
+
* customer_id: "user_123",
|
|
692
|
+
* feature_id: "messages"
|
|
693
|
+
* value: 20 // Usage value
|
|
694
|
+
* });
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
548
697
|
async usage(params) {
|
|
549
698
|
return handleUsage({
|
|
550
699
|
instance: this,
|
|
@@ -552,6 +701,25 @@ var Autumn = class {
|
|
|
552
701
|
});
|
|
553
702
|
}
|
|
554
703
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
704
|
+
/**
|
|
705
|
+
* Performs advanced queries on customer data and analytics.
|
|
706
|
+
*
|
|
707
|
+
* This method allows you to run complex queries against customer data,
|
|
708
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
709
|
+
* analytics, and custom data insights.
|
|
710
|
+
*
|
|
711
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
712
|
+
* @returns Promise resolving to query results with requested data
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```typescript
|
|
716
|
+
* const result = await autumn.query({
|
|
717
|
+
* customer_id: "user_123",
|
|
718
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
719
|
+
* });
|
|
720
|
+
*
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
555
723
|
async query(params) {
|
|
556
724
|
return handleQuery({
|
|
557
725
|
instance: this,
|
|
@@ -767,6 +935,8 @@ var CheckoutParamsSchema = import_v47.z.object({
|
|
|
767
935
|
product_id: import_v47.z.string(),
|
|
768
936
|
entity_id: import_v47.z.string().optional(),
|
|
769
937
|
options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
|
|
938
|
+
force_checkout: import_v47.z.boolean().optional(),
|
|
939
|
+
invoice: import_v47.z.boolean().optional(),
|
|
770
940
|
success_url: import_v47.z.string().optional(),
|
|
771
941
|
customer_data: CustomerDataSchema.optional(),
|
|
772
942
|
entity_data: import_v47.z.any().optional(),
|
|
@@ -948,7 +1118,8 @@ var AutumnClient = class {
|
|
|
948
1118
|
await fetch(testEndpoint, {
|
|
949
1119
|
method: "POST",
|
|
950
1120
|
credentials: "include",
|
|
951
|
-
headers: { "Content-Type": "application/json" }
|
|
1121
|
+
headers: { "Content-Type": "application/json" },
|
|
1122
|
+
body: JSON.stringify({})
|
|
952
1123
|
});
|
|
953
1124
|
return { valid: true, includeCredentials: true };
|
|
954
1125
|
} catch (error) {
|
|
@@ -956,7 +1127,8 @@ var AutumnClient = class {
|
|
|
956
1127
|
await fetch(testEndpoint, {
|
|
957
1128
|
method: "POST",
|
|
958
1129
|
credentials: "omit",
|
|
959
|
-
headers: { "Content-Type": "application/json" }
|
|
1130
|
+
headers: { "Content-Type": "application/json" },
|
|
1131
|
+
body: JSON.stringify({})
|
|
960
1132
|
});
|
|
961
1133
|
return { valid: true, includeCredentials: false };
|
|
962
1134
|
} catch (error2) {
|
|
@@ -1466,7 +1638,6 @@ var useAutumnBase = ({
|
|
|
1466
1638
|
};
|
|
1467
1639
|
return {
|
|
1468
1640
|
attach,
|
|
1469
|
-
// check,
|
|
1470
1641
|
track,
|
|
1471
1642
|
cancel,
|
|
1472
1643
|
openBillingPortal,
|
|
@@ -1686,16 +1857,6 @@ var useCustomerBase = ({
|
|
|
1686
1857
|
context
|
|
1687
1858
|
});
|
|
1688
1859
|
return res;
|
|
1689
|
-
},
|
|
1690
|
-
/** @deprecated Use check() instead */
|
|
1691
|
-
allowed: (params2) => {
|
|
1692
|
-
const result = handleCheck2({
|
|
1693
|
-
customer,
|
|
1694
|
-
params: params2,
|
|
1695
|
-
isEntity: false,
|
|
1696
|
-
context
|
|
1697
|
-
});
|
|
1698
|
-
return result.data.allowed;
|
|
1699
1860
|
}
|
|
1700
1861
|
};
|
|
1701
1862
|
};
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
useCustomerBase
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-BT5OY2CA.mjs";
|
|
6
|
+
import "../chunk-DKOF357C.mjs";
|
|
7
|
+
import "../chunk-P6CAHZVT.mjs";
|
|
8
|
+
import "../chunk-7HRCOEUW.mjs";
|
|
9
|
+
import "../chunk-SWVRRNIW.mjs";
|
|
10
|
+
import "../chunk-TOAZUTY6.mjs";
|
|
11
|
+
import "../chunk-5O3IHYFF.mjs";
|
|
12
|
+
import "../chunk-JVCOY7ZL.mjs";
|
|
12
13
|
import "../chunk-CIBQ4BJU.mjs";
|
|
13
14
|
import "../chunk-V575SGOW.mjs";
|
|
14
15
|
import "../chunk-ZV4RPZTM.mjs";
|
|
15
|
-
import "../chunk-JVCOY7ZL.mjs";
|
|
16
16
|
import "../chunk-VTGR7VVK.mjs";
|
|
17
17
|
import "../chunk-WFFVOEUG.mjs";
|
|
18
18
|
import "../chunk-ZF2HUCN6.mjs";
|