autumn-js 0.1.11 → 0.1.12
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 +30 -26
- package/dist/libraries/backend/better-auth.d.ts +30 -26
- 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-BOsjdpOb.d.mts} +176 -6
- package/dist/libraries/backend/{referralTypes-FlI0fYwz.d.ts → referralTypes-DcfU8B6R.d.ts} +176 -6
- 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.d.mts +6 -6
- package/dist/libraries/react/AutumnContext.d.ts +6 -6
- package/dist/libraries/react/AutumnContext.js +172 -2
- package/dist/libraries/react/AutumnContext.mjs +4 -4
- package/dist/libraries/react/BaseAutumnProvider.d.mts +6 -6
- package/dist/libraries/react/BaseAutumnProvider.d.ts +6 -6
- package/dist/libraries/react/BaseAutumnProvider.js +172 -13
- package/dist/libraries/react/BaseAutumnProvider.mjs +9 -9
- package/dist/libraries/react/{ReactAutumnClient-CfDtucnL.d.ts → ReactAutumnClient-CIAkiqwV.d.ts} +5 -5
- package/dist/libraries/react/{ReactAutumnClient-IFdMWiu5.d.mts → ReactAutumnClient-zBxnpPLM.d.mts} +5 -5
- package/dist/libraries/react/ReactAutumnProvider.d.mts +2 -2
- package/dist/libraries/react/ReactAutumnProvider.d.ts +2 -2
- package/dist/libraries/react/ReactAutumnProvider.js +172 -13
- package/dist/libraries/react/ReactAutumnProvider.mjs +10 -10
- package/dist/libraries/react/{attachTypes-CLK4jfuj.d.ts → attachTypes-BQaZHr5e.d.ts} +1 -1
- package/dist/libraries/react/{attachTypes-C5gcbNrS.d.mts → attachTypes-Cuxn1ThG.d.mts} +1 -1
- package/dist/libraries/react/{chunk-4NZ7ML7V.mjs → chunk-26K62U62.mjs} +2 -2
- package/dist/libraries/react/{chunk-WYQMHQUE.mjs → chunk-5O3IHYFF.mjs} +172 -2
- package/dist/libraries/react/{chunk-3MF54MDU.mjs → chunk-5RTUQSYZ.mjs} +1 -1
- package/dist/libraries/react/{chunk-XK3AXQED.mjs → chunk-6X76WFOV.mjs} +3 -13
- package/dist/libraries/react/{chunk-JHFJKAXG.mjs → chunk-7A2PZDUO.mjs} +25 -25
- package/dist/libraries/react/{chunk-YHT2JUXO.mjs → chunk-7HRCOEUW.mjs} +1 -1
- package/dist/libraries/react/{chunk-KP2Q65Y3.mjs → chunk-CMUWZZWV.mjs} +2 -2
- package/dist/libraries/react/{chunk-KMYL54B4.mjs → chunk-DKOF357C.mjs} +1 -1
- package/dist/libraries/react/{chunk-67RWFVWN.mjs → chunk-HNIU2WNT.mjs} +2 -2
- package/dist/libraries/react/{chunk-U3OQJXCW.mjs → chunk-JTYEHM27.mjs} +4 -4
- package/dist/libraries/react/{chunk-6D6TYTTO.mjs → chunk-P6CAHZVT.mjs} +1 -2
- package/dist/libraries/react/{chunk-TTLL63A4.mjs → chunk-QNMB7QR6.mjs} +3 -3
- package/dist/libraries/react/{chunk-2ENHPIYQ.mjs → chunk-RK4NRHHQ.mjs} +3 -3
- package/dist/libraries/react/{chunk-VZY225C6.mjs → chunk-ROKCGZ77.mjs} +2 -2
- package/dist/libraries/react/{chunk-FDNQ6GRK.mjs → chunk-TE2MOBO7.mjs} +1 -1
- package/dist/libraries/react/{chunk-OMJJLT2Q.mjs → chunk-VGNA76RG.mjs} +1 -1
- package/dist/libraries/react/client/ReactAutumnClient.d.mts +6 -6
- package/dist/libraries/react/client/ReactAutumnClient.d.ts +6 -6
- package/dist/libraries/react/client/ReactAutumnClient.js +172 -2
- package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
- package/dist/libraries/react/client/clientCompMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientCompMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientCusMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientCusMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientEntityMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientEntityMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientGenMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientGenMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientProdMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientProdMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientReferralMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientReferralMethods.d.ts +6 -6
- 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.d.mts +2 -2
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.ts +2 -2
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +172 -13
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.mts +2 -2
- package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.ts +2 -2
- package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.mts +1 -1
- package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.ts +1 -1
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +172 -2
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.mts +1 -1
- package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.ts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +172 -13
- 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/{cusTypes-CBapqjzm.d.mts → cusTypes-B2m4-oz4.d.mts} +1 -1
- package/dist/libraries/react/{cusTypes-D13MXEN7.d.ts → cusTypes-lMnznWYJ.d.ts} +1 -1
- package/dist/libraries/react/{entTypes-C1bM1Zpv.d.mts → entTypes-D-gn1jj2.d.mts} +1 -1
- package/dist/libraries/react/{entTypes-DbIrfEpl.d.ts → entTypes-WMQRyYAv.d.ts} +1 -1
- package/dist/libraries/react/{genTypes-C_ilxndU.d.mts → genTypes-DdYlVEah.d.mts} +1 -1
- package/dist/libraries/react/{genTypes-DjcQWIOM.d.ts → genTypes-aPPwPimh.d.ts} +1 -1
- package/dist/libraries/react/hooks/helpers/handleCheck.d.mts +6 -6
- package/dist/libraries/react/hooks/helpers/handleCheck.d.ts +6 -6
- 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.d.mts +6 -6
- package/dist/libraries/react/hooks/helpers/useAutumnBase.d.ts +6 -6
- 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.d.mts +2 -2
- package/dist/libraries/react/hooks/useAnalytics.d.ts +2 -2
- package/dist/libraries/react/hooks/useAnalytics.js +172 -2
- package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
- package/dist/libraries/react/hooks/useCustomer.d.mts +66 -8
- package/dist/libraries/react/hooks/useCustomer.d.ts +66 -8
- package/dist/libraries/react/hooks/useCustomer.js +172 -13
- package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
- package/dist/libraries/react/hooks/useCustomerBase.d.mts +50 -9
- package/dist/libraries/react/hooks/useCustomerBase.d.ts +50 -9
- package/dist/libraries/react/hooks/useCustomerBase.js +172 -13
- package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
- package/dist/libraries/react/hooks/useEntity.d.mts +4 -4
- package/dist/libraries/react/hooks/useEntity.d.ts +4 -4
- package/dist/libraries/react/hooks/useEntity.js +172 -3
- package/dist/libraries/react/hooks/useEntity.mjs +9 -9
- package/dist/libraries/react/hooks/useEntityBase.d.mts +6 -6
- package/dist/libraries/react/hooks/useEntityBase.d.ts +6 -6
- package/dist/libraries/react/hooks/useEntityBase.js +172 -3
- package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
- package/dist/libraries/react/hooks/usePaywall.d.mts +1 -1
- package/dist/libraries/react/hooks/usePaywall.d.ts +1 -1
- package/dist/libraries/react/hooks/usePaywall.js +172 -2
- package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
- package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
- package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
- package/dist/libraries/react/hooks/usePricingTable.js +172 -2
- package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.d.mts +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.d.ts +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.js +172 -2
- package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
- package/dist/libraries/react/hooks/useProductsBase.d.mts +6 -6
- package/dist/libraries/react/hooks/useProductsBase.d.ts +6 -6
- package/dist/libraries/react/index.d.mts +104 -7
- package/dist/libraries/react/index.d.ts +104 -7
- package/dist/libraries/react/index.js +172 -13
- package/dist/libraries/react/index.mjs +172 -13
- package/dist/libraries/react/{prodTypes-B8NdKyKo.d.ts → prodTypes-C8xRoBP7.d.mts} +1 -1
- package/dist/libraries/react/{prodTypes-B8NdKyKo.d.mts → prodTypes-C8xRoBP7.d.ts} +1 -1
- 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 +176 -6
- package/dist/next/server/cusActions.d.ts +176 -6
- package/dist/sdk/index.d.mts +174 -4
- package/dist/sdk/index.d.ts +174 -4
- package/dist/sdk/index.js +171 -1
- package/dist/sdk/index.mjs +171 -1
- 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
|
@@ -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(),
|
|
@@ -1602,7 +1772,6 @@ var useAutumnBase = ({
|
|
|
1602
1772
|
};
|
|
1603
1773
|
return {
|
|
1604
1774
|
attach,
|
|
1605
|
-
// check,
|
|
1606
1775
|
track,
|
|
1607
1776
|
cancel,
|
|
1608
1777
|
openBillingPortal,
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
useEntityBase
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-CIBQ4BJU.mjs";
|
|
5
|
+
} from "../chunk-RK4NRHHQ.mjs";
|
|
6
|
+
import "../chunk-DKOF357C.mjs";
|
|
7
|
+
import "../chunk-P6CAHZVT.mjs";
|
|
8
|
+
import "../chunk-7HRCOEUW.mjs";
|
|
9
|
+
import "../chunk-TE2MOBO7.mjs";
|
|
10
|
+
import "../chunk-JTYEHM27.mjs";
|
|
11
|
+
import "../chunk-5O3IHYFF.mjs";
|
|
13
12
|
import "../chunk-V575SGOW.mjs";
|
|
14
13
|
import "../chunk-ZV4RPZTM.mjs";
|
|
15
14
|
import "../chunk-JVCOY7ZL.mjs";
|
|
15
|
+
import "../chunk-CIBQ4BJU.mjs";
|
|
16
16
|
import "../chunk-VTGR7VVK.mjs";
|
|
17
17
|
import "../chunk-WFFVOEUG.mjs";
|
|
18
18
|
import "../chunk-ZF2HUCN6.mjs";
|
|
@@ -500,22 +500,92 @@ var Autumn = class {
|
|
|
500
500
|
entities = entityMethods(this);
|
|
501
501
|
referrals = referralMethods(this);
|
|
502
502
|
features = featureMethods(this);
|
|
503
|
-
|
|
503
|
+
/**
|
|
504
|
+
* Initiates a checkout flow for a product purchase.
|
|
505
|
+
*
|
|
506
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
507
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
508
|
+
* to Stripe based on the customer's state and product requirements.
|
|
509
|
+
*
|
|
510
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
511
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* const result = await autumn.checkout({
|
|
516
|
+
* customer_id: "user_123",
|
|
517
|
+
* product_id: "pro",
|
|
518
|
+
* success_url: "https://myapp.com/success"
|
|
519
|
+
* });
|
|
520
|
+
*
|
|
521
|
+
* if (result.url) {
|
|
522
|
+
* // Redirect to Stripe checkout
|
|
523
|
+
* window.location.href = result.url;
|
|
524
|
+
* }
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
504
527
|
async checkout(params) {
|
|
505
528
|
return handleCheckout({
|
|
506
529
|
instance: this,
|
|
507
530
|
params
|
|
508
531
|
});
|
|
509
532
|
}
|
|
510
|
-
static
|
|
533
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
511
534
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
535
|
+
/**
|
|
536
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
537
|
+
*
|
|
538
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
539
|
+
* When you attach a product:
|
|
540
|
+
* - The customer gains access to all features in the product
|
|
541
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
542
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
543
|
+
*
|
|
544
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
545
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* ```typescript
|
|
549
|
+
* const result = await autumn.attach({
|
|
550
|
+
* customer_id: "user_123",
|
|
551
|
+
* product_id: "pro",
|
|
552
|
+
* success_url: "https://myapp.com/success"
|
|
553
|
+
* });
|
|
554
|
+
*
|
|
555
|
+
* if (result.checkout_url) {
|
|
556
|
+
* // Payment required - redirect to checkout
|
|
557
|
+
* window.location.href = result.checkout_url;
|
|
558
|
+
* } else {
|
|
559
|
+
* // Product successfully attached
|
|
560
|
+
* console.log("Access granted:", result.message);
|
|
561
|
+
* }
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
512
564
|
async attach(params) {
|
|
513
565
|
return handleAttach({
|
|
514
566
|
instance: this,
|
|
515
567
|
params
|
|
516
568
|
});
|
|
517
569
|
}
|
|
570
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
518
571
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
572
|
+
/**
|
|
573
|
+
* Sets up a payment method for a customer.
|
|
574
|
+
*
|
|
575
|
+
* This method allows you to set up payment methods for customers without
|
|
576
|
+
* immediately charging them. Useful for collecting payment information
|
|
577
|
+
* before product attachment or for updating existing payment methods.
|
|
578
|
+
*
|
|
579
|
+
* @param params - Setup payment parameters including customer information
|
|
580
|
+
* @returns Promise resolving to setup payment result
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```typescript
|
|
584
|
+
* const result = await autumn.setupPayment({
|
|
585
|
+
* customer_id: "user_123"
|
|
586
|
+
* });
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
519
589
|
async setupPayment(params) {
|
|
520
590
|
return handleSetupPayment({
|
|
521
591
|
instance: this,
|
|
@@ -523,6 +593,24 @@ var Autumn = class {
|
|
|
523
593
|
});
|
|
524
594
|
}
|
|
525
595
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
596
|
+
/**
|
|
597
|
+
* Cancels a customer's subscription or product attachment.
|
|
598
|
+
*
|
|
599
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
600
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
601
|
+
*
|
|
602
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
603
|
+
* @returns Promise resolving to cancellation result
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```typescript
|
|
607
|
+
* const result = await autumn.cancel({
|
|
608
|
+
* customer_id: "user_123",
|
|
609
|
+
* product_id: "pro",
|
|
610
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
611
|
+
* });
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
526
614
|
async cancel(params) {
|
|
527
615
|
return handleCancel({
|
|
528
616
|
instance: this,
|
|
@@ -530,6 +618,29 @@ var Autumn = class {
|
|
|
530
618
|
});
|
|
531
619
|
}
|
|
532
620
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
621
|
+
/**
|
|
622
|
+
* Checks if a customer has access to a specific feature.
|
|
623
|
+
*
|
|
624
|
+
* This method verifies whether a customer has permission to use a feature
|
|
625
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
626
|
+
* features and determine when to show upgrade prompts.
|
|
627
|
+
*
|
|
628
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
629
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* const result = await autumn.check({
|
|
634
|
+
* customer_id: "user_123",
|
|
635
|
+
* feature_id: "messages",
|
|
636
|
+
* required_balance: 1
|
|
637
|
+
* });
|
|
638
|
+
*
|
|
639
|
+
* if (!result.allowed) {
|
|
640
|
+
* console.log("Feature access denied - upgrade required");
|
|
641
|
+
* }
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
533
644
|
async check(params) {
|
|
534
645
|
return handleCheck({
|
|
535
646
|
instance: this,
|
|
@@ -537,12 +648,50 @@ var Autumn = class {
|
|
|
537
648
|
});
|
|
538
649
|
}
|
|
539
650
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
651
|
+
/**
|
|
652
|
+
* Tracks usage events for features or analytics.
|
|
653
|
+
*
|
|
654
|
+
* This method records usage events for metered features, updating the customer's
|
|
655
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
656
|
+
* accurate tracking that cannot be manipulated by users.
|
|
657
|
+
*
|
|
658
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
659
|
+
* @returns Promise resolving to tracking result
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* const result = await autumn.track({
|
|
664
|
+
* customer_id: "user_123",
|
|
665
|
+
* feature_id: "messages",
|
|
666
|
+
* value: 1 // Track 1 message sent
|
|
667
|
+
* });
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
540
670
|
async track(params) {
|
|
541
671
|
return handleTrack({
|
|
542
672
|
instance: this,
|
|
543
673
|
params
|
|
544
674
|
});
|
|
545
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
678
|
+
*
|
|
679
|
+
* This method fetches detailed usage information for a customer's features,
|
|
680
|
+
* including current balances, usage history, and analytics data. Useful
|
|
681
|
+
* for displaying usage dashboards or generating reports.
|
|
682
|
+
*
|
|
683
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
684
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* const result = await autumn.usage({
|
|
689
|
+
* customer_id: "user_123",
|
|
690
|
+
* feature_id: "messages"
|
|
691
|
+
* value: 20 // Usage value
|
|
692
|
+
* });
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
546
695
|
async usage(params) {
|
|
547
696
|
return handleUsage({
|
|
548
697
|
instance: this,
|
|
@@ -550,6 +699,25 @@ var Autumn = class {
|
|
|
550
699
|
});
|
|
551
700
|
}
|
|
552
701
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
702
|
+
/**
|
|
703
|
+
* Performs advanced queries on customer data and analytics.
|
|
704
|
+
*
|
|
705
|
+
* This method allows you to run complex queries against customer data,
|
|
706
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
707
|
+
* analytics, and custom data insights.
|
|
708
|
+
*
|
|
709
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
710
|
+
* @returns Promise resolving to query results with requested data
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* ```typescript
|
|
714
|
+
* const result = await autumn.query({
|
|
715
|
+
* customer_id: "user_123",
|
|
716
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
717
|
+
* });
|
|
718
|
+
*
|
|
719
|
+
* ```
|
|
720
|
+
*/
|
|
553
721
|
async query(params) {
|
|
554
722
|
return handleQuery({
|
|
555
723
|
instance: this,
|
|
@@ -765,6 +933,8 @@ var CheckoutParamsSchema = import_v47.z.object({
|
|
|
765
933
|
product_id: import_v47.z.string(),
|
|
766
934
|
entity_id: import_v47.z.string().optional(),
|
|
767
935
|
options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
|
|
936
|
+
force_checkout: import_v47.z.boolean().optional(),
|
|
937
|
+
invoice: import_v47.z.boolean().optional(),
|
|
768
938
|
success_url: import_v47.z.string().optional(),
|
|
769
939
|
customer_data: CustomerDataSchema.optional(),
|
|
770
940
|
entity_data: import_v47.z.any().optional(),
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
usePaywall
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-CIBQ4BJU.mjs";
|
|
5
|
+
} from "../chunk-5RTUQSYZ.mjs";
|
|
6
|
+
import "../chunk-TE2MOBO7.mjs";
|
|
7
|
+
import "../chunk-JTYEHM27.mjs";
|
|
8
|
+
import "../chunk-5O3IHYFF.mjs";
|
|
10
9
|
import "../chunk-V575SGOW.mjs";
|
|
11
10
|
import "../chunk-ZV4RPZTM.mjs";
|
|
12
11
|
import "../chunk-JVCOY7ZL.mjs";
|
|
12
|
+
import "../chunk-CIBQ4BJU.mjs";
|
|
13
13
|
import "../chunk-VTGR7VVK.mjs";
|
|
14
14
|
import "../chunk-WFFVOEUG.mjs";
|
|
15
15
|
import "../chunk-ZF2HUCN6.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { A as AutumnError } from '../error-DHbclCVh.mjs';
|
|
3
|
-
import { P as Product } from '../prodTypes-
|
|
3
|
+
import { P as Product } from '../prodTypes-C8xRoBP7.mjs';
|
|
4
4
|
import { ProductDetails } from '../client/types/clientPricingTableTypes.mjs';
|
|
5
5
|
import 'zod/v4';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { A as AutumnError } from '../error-DHbclCVh.js';
|
|
3
|
-
import { P as Product } from '../prodTypes-
|
|
3
|
+
import { P as Product } from '../prodTypes-C8xRoBP7.js';
|
|
4
4
|
import { ProductDetails } from '../client/types/clientPricingTableTypes.js';
|
|
5
5
|
import 'zod/v4';
|
|
6
6
|
|