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
package/dist/sdk/index.d.ts
CHANGED
|
@@ -487,6 +487,8 @@ declare const CheckoutParamsSchema: z.ZodObject<{
|
|
|
487
487
|
feature_id: z.ZodString;
|
|
488
488
|
quantity: z.ZodNumber;
|
|
489
489
|
}, z.core.$strip>>>;
|
|
490
|
+
force_checkout: z.ZodOptional<z.ZodBoolean>;
|
|
491
|
+
invoice: z.ZodOptional<z.ZodBoolean>;
|
|
490
492
|
success_url: z.ZodOptional<z.ZodString>;
|
|
491
493
|
customer_data: z.ZodOptional<z.ZodObject<{
|
|
492
494
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -670,9 +672,63 @@ declare class Autumn {
|
|
|
670
672
|
list: Feature[];
|
|
671
673
|
}, AutumnError>>;
|
|
672
674
|
};
|
|
673
|
-
|
|
675
|
+
/**
|
|
676
|
+
* Initiates a checkout flow for a product purchase.
|
|
677
|
+
*
|
|
678
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
679
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
680
|
+
* to Stripe based on the customer's state and product requirements.
|
|
681
|
+
*
|
|
682
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
683
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* ```typescript
|
|
687
|
+
* const result = await autumn.checkout({
|
|
688
|
+
* customer_id: "user_123",
|
|
689
|
+
* product_id: "pro",
|
|
690
|
+
* success_url: "https://myapp.com/success"
|
|
691
|
+
* });
|
|
692
|
+
*
|
|
693
|
+
* if (result.url) {
|
|
694
|
+
* // Redirect to Stripe checkout
|
|
695
|
+
* window.location.href = result.url;
|
|
696
|
+
* }
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
674
699
|
checkout(params: CheckoutParams): Promise<Result<CheckoutResult, AutumnError>>;
|
|
675
|
-
static
|
|
700
|
+
static checkout: (params: CheckoutParams) => Promise<Result<CheckoutResult, AutumnError>>;
|
|
701
|
+
static usage: (params: UsageParams) => Promise<Result<UsageResult, AutumnError>>;
|
|
702
|
+
/**
|
|
703
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
704
|
+
*
|
|
705
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
706
|
+
* When you attach a product:
|
|
707
|
+
* - The customer gains access to all features in the product
|
|
708
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
709
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
710
|
+
*
|
|
711
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
712
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```typescript
|
|
716
|
+
* const result = await autumn.attach({
|
|
717
|
+
* customer_id: "user_123",
|
|
718
|
+
* product_id: "pro",
|
|
719
|
+
* success_url: "https://myapp.com/success"
|
|
720
|
+
* });
|
|
721
|
+
*
|
|
722
|
+
* if (result.checkout_url) {
|
|
723
|
+
* // Payment required - redirect to checkout
|
|
724
|
+
* window.location.href = result.checkout_url;
|
|
725
|
+
* } else {
|
|
726
|
+
* // Product successfully attached
|
|
727
|
+
* console.log("Access granted:", result.message);
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
attach(params: AttachParams): Promise<Result<{
|
|
676
732
|
customer_id: string;
|
|
677
733
|
product_ids: string[];
|
|
678
734
|
code: string;
|
|
@@ -687,8 +743,7 @@ declare class Autumn {
|
|
|
687
743
|
currency: string;
|
|
688
744
|
} | undefined;
|
|
689
745
|
}, AutumnError>>;
|
|
690
|
-
static
|
|
691
|
-
attach(params: AttachParams): Promise<Result<{
|
|
746
|
+
static attach: (params: AttachParams) => Promise<Result<{
|
|
692
747
|
customer_id: string;
|
|
693
748
|
product_ids: string[];
|
|
694
749
|
code: string;
|
|
@@ -704,18 +759,76 @@ declare class Autumn {
|
|
|
704
759
|
} | undefined;
|
|
705
760
|
}, AutumnError>>;
|
|
706
761
|
static setupPayment: (params: SetupPaymentParams) => Promise<Result<SetupPaymentResult, AutumnError>>;
|
|
762
|
+
/**
|
|
763
|
+
* Sets up a payment method for a customer.
|
|
764
|
+
*
|
|
765
|
+
* This method allows you to set up payment methods for customers without
|
|
766
|
+
* immediately charging them. Useful for collecting payment information
|
|
767
|
+
* before product attachment or for updating existing payment methods.
|
|
768
|
+
*
|
|
769
|
+
* @param params - Setup payment parameters including customer information
|
|
770
|
+
* @returns Promise resolving to setup payment result
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```typescript
|
|
774
|
+
* const result = await autumn.setupPayment({
|
|
775
|
+
* customer_id: "user_123"
|
|
776
|
+
* });
|
|
777
|
+
* ```
|
|
778
|
+
*/
|
|
707
779
|
setupPayment(params: SetupPaymentParams): Promise<Result<SetupPaymentResult, AutumnError>>;
|
|
708
780
|
static cancel: (params: CancelParams) => Promise<Result<{
|
|
709
781
|
success: boolean;
|
|
710
782
|
customer_id: string;
|
|
711
783
|
product_id: string;
|
|
712
784
|
}, AutumnError>>;
|
|
785
|
+
/**
|
|
786
|
+
* Cancels a customer's subscription or product attachment.
|
|
787
|
+
*
|
|
788
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
789
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
790
|
+
*
|
|
791
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
792
|
+
* @returns Promise resolving to cancellation result
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```typescript
|
|
796
|
+
* const result = await autumn.cancel({
|
|
797
|
+
* customer_id: "user_123",
|
|
798
|
+
* product_id: "pro",
|
|
799
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
800
|
+
* });
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
713
803
|
cancel(params: CancelParams): Promise<Result<{
|
|
714
804
|
success: boolean;
|
|
715
805
|
customer_id: string;
|
|
716
806
|
product_id: string;
|
|
717
807
|
}, AutumnError>>;
|
|
718
808
|
static check: (params: CheckParams) => Promise<Result<CheckResult, AutumnError>>;
|
|
809
|
+
/**
|
|
810
|
+
* Checks if a customer has access to a specific feature.
|
|
811
|
+
*
|
|
812
|
+
* This method verifies whether a customer has permission to use a feature
|
|
813
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
814
|
+
* features and determine when to show upgrade prompts.
|
|
815
|
+
*
|
|
816
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
817
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
* ```typescript
|
|
821
|
+
* const result = await autumn.check({
|
|
822
|
+
* customer_id: "user_123",
|
|
823
|
+
* feature_id: "messages",
|
|
824
|
+
* required_balance: 1
|
|
825
|
+
* });
|
|
826
|
+
*
|
|
827
|
+
* if (!result.allowed) {
|
|
828
|
+
* console.log("Feature access denied - upgrade required");
|
|
829
|
+
* }
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
719
832
|
check(params: CheckParams): Promise<Result<CheckResult, AutumnError>>;
|
|
720
833
|
static track: (params: TrackParams) => Promise<Result<{
|
|
721
834
|
id: string;
|
|
@@ -724,6 +837,25 @@ declare class Autumn {
|
|
|
724
837
|
feature_id?: string | undefined;
|
|
725
838
|
event_name?: string | undefined;
|
|
726
839
|
}, AutumnError>>;
|
|
840
|
+
/**
|
|
841
|
+
* Tracks usage events for features or analytics.
|
|
842
|
+
*
|
|
843
|
+
* This method records usage events for metered features, updating the customer's
|
|
844
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
845
|
+
* accurate tracking that cannot be manipulated by users.
|
|
846
|
+
*
|
|
847
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
848
|
+
* @returns Promise resolving to tracking result
|
|
849
|
+
*
|
|
850
|
+
* @example
|
|
851
|
+
* ```typescript
|
|
852
|
+
* const result = await autumn.track({
|
|
853
|
+
* customer_id: "user_123",
|
|
854
|
+
* feature_id: "messages",
|
|
855
|
+
* value: 1 // Track 1 message sent
|
|
856
|
+
* });
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
727
859
|
track(params: TrackParams): Promise<Result<{
|
|
728
860
|
id: string;
|
|
729
861
|
code: string;
|
|
@@ -731,8 +863,46 @@ declare class Autumn {
|
|
|
731
863
|
feature_id?: string | undefined;
|
|
732
864
|
event_name?: string | undefined;
|
|
733
865
|
}, AutumnError>>;
|
|
866
|
+
/**
|
|
867
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
868
|
+
*
|
|
869
|
+
* This method fetches detailed usage information for a customer's features,
|
|
870
|
+
* including current balances, usage history, and analytics data. Useful
|
|
871
|
+
* for displaying usage dashboards or generating reports.
|
|
872
|
+
*
|
|
873
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
874
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```typescript
|
|
878
|
+
* const result = await autumn.usage({
|
|
879
|
+
* customer_id: "user_123",
|
|
880
|
+
* feature_id: "messages"
|
|
881
|
+
* value: 20 // Usage value
|
|
882
|
+
* });
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
734
885
|
usage(params: UsageParams): Promise<Result<UsageResult, AutumnError>>;
|
|
735
886
|
static query: (params: QueryParams) => Promise<Result<QueryResult, AutumnError>>;
|
|
887
|
+
/**
|
|
888
|
+
* Performs advanced queries on customer data and analytics.
|
|
889
|
+
*
|
|
890
|
+
* This method allows you to run complex queries against customer data,
|
|
891
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
892
|
+
* analytics, and custom data insights.
|
|
893
|
+
*
|
|
894
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
895
|
+
* @returns Promise resolving to query results with requested data
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```typescript
|
|
899
|
+
* const result = await autumn.query({
|
|
900
|
+
* customer_id: "user_123",
|
|
901
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
902
|
+
* });
|
|
903
|
+
*
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
736
906
|
query(params: QueryParams): Promise<Result<QueryResult, AutumnError>>;
|
|
737
907
|
}
|
|
738
908
|
|
package/dist/sdk/index.js
CHANGED
|
@@ -433,48 +433,216 @@ var Autumn = class {
|
|
|
433
433
|
});
|
|
434
434
|
return toContainerResult({ response, logger: this.logger });
|
|
435
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Initiates a checkout flow for a product purchase.
|
|
438
|
+
*
|
|
439
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
440
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
441
|
+
* to Stripe based on the customer's state and product requirements.
|
|
442
|
+
*
|
|
443
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
444
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const result = await autumn.checkout({
|
|
449
|
+
* customer_id: "user_123",
|
|
450
|
+
* product_id: "pro",
|
|
451
|
+
* success_url: "https://myapp.com/success"
|
|
452
|
+
* });
|
|
453
|
+
*
|
|
454
|
+
* if (result.url) {
|
|
455
|
+
* // Redirect to Stripe checkout
|
|
456
|
+
* window.location.href = result.url;
|
|
457
|
+
* }
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
436
460
|
async checkout(params) {
|
|
437
461
|
return handleCheckout({
|
|
438
462
|
instance: this,
|
|
439
463
|
params
|
|
440
464
|
});
|
|
441
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
468
|
+
*
|
|
469
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
470
|
+
* When you attach a product:
|
|
471
|
+
* - The customer gains access to all features in the product
|
|
472
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
473
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
474
|
+
*
|
|
475
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
476
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* const result = await autumn.attach({
|
|
481
|
+
* customer_id: "user_123",
|
|
482
|
+
* product_id: "pro",
|
|
483
|
+
* success_url: "https://myapp.com/success"
|
|
484
|
+
* });
|
|
485
|
+
*
|
|
486
|
+
* if (result.checkout_url) {
|
|
487
|
+
* // Payment required - redirect to checkout
|
|
488
|
+
* window.location.href = result.checkout_url;
|
|
489
|
+
* } else {
|
|
490
|
+
* // Product successfully attached
|
|
491
|
+
* console.log("Access granted:", result.message);
|
|
492
|
+
* }
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
442
495
|
async attach(params) {
|
|
443
496
|
return handleAttach({
|
|
444
497
|
instance: this,
|
|
445
498
|
params
|
|
446
499
|
});
|
|
447
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Sets up a payment method for a customer.
|
|
503
|
+
*
|
|
504
|
+
* This method allows you to set up payment methods for customers without
|
|
505
|
+
* immediately charging them. Useful for collecting payment information
|
|
506
|
+
* before product attachment or for updating existing payment methods.
|
|
507
|
+
*
|
|
508
|
+
* @param params - Setup payment parameters including customer information
|
|
509
|
+
* @returns Promise resolving to setup payment result
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```typescript
|
|
513
|
+
* const result = await autumn.setupPayment({
|
|
514
|
+
* customer_id: "user_123"
|
|
515
|
+
* });
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
448
518
|
async setupPayment(params) {
|
|
449
519
|
return handleSetupPayment({
|
|
450
520
|
instance: this,
|
|
451
521
|
params
|
|
452
522
|
});
|
|
453
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Cancels a customer's subscription or product attachment.
|
|
526
|
+
*
|
|
527
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
528
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
529
|
+
*
|
|
530
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
531
|
+
* @returns Promise resolving to cancellation result
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* const result = await autumn.cancel({
|
|
536
|
+
* customer_id: "user_123",
|
|
537
|
+
* product_id: "pro",
|
|
538
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
539
|
+
* });
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
454
542
|
async cancel(params) {
|
|
455
543
|
return handleCancel({
|
|
456
544
|
instance: this,
|
|
457
545
|
params
|
|
458
546
|
});
|
|
459
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Checks if a customer has access to a specific feature.
|
|
550
|
+
*
|
|
551
|
+
* This method verifies whether a customer has permission to use a feature
|
|
552
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
553
|
+
* features and determine when to show upgrade prompts.
|
|
554
|
+
*
|
|
555
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
556
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```typescript
|
|
560
|
+
* const result = await autumn.check({
|
|
561
|
+
* customer_id: "user_123",
|
|
562
|
+
* feature_id: "messages",
|
|
563
|
+
* required_balance: 1
|
|
564
|
+
* });
|
|
565
|
+
*
|
|
566
|
+
* if (!result.allowed) {
|
|
567
|
+
* console.log("Feature access denied - upgrade required");
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
460
571
|
async check(params) {
|
|
461
572
|
return handleCheck({
|
|
462
573
|
instance: this,
|
|
463
574
|
params
|
|
464
575
|
});
|
|
465
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Tracks usage events for features or analytics.
|
|
579
|
+
*
|
|
580
|
+
* This method records usage events for metered features, updating the customer's
|
|
581
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
582
|
+
* accurate tracking that cannot be manipulated by users.
|
|
583
|
+
*
|
|
584
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
585
|
+
* @returns Promise resolving to tracking result
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```typescript
|
|
589
|
+
* const result = await autumn.track({
|
|
590
|
+
* customer_id: "user_123",
|
|
591
|
+
* feature_id: "messages",
|
|
592
|
+
* value: 1 // Track 1 message sent
|
|
593
|
+
* });
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
466
596
|
async track(params) {
|
|
467
597
|
return handleTrack({
|
|
468
598
|
instance: this,
|
|
469
599
|
params
|
|
470
600
|
});
|
|
471
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
604
|
+
*
|
|
605
|
+
* This method fetches detailed usage information for a customer's features,
|
|
606
|
+
* including current balances, usage history, and analytics data. Useful
|
|
607
|
+
* for displaying usage dashboards or generating reports.
|
|
608
|
+
*
|
|
609
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
610
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```typescript
|
|
614
|
+
* const result = await autumn.usage({
|
|
615
|
+
* customer_id: "user_123",
|
|
616
|
+
* feature_id: "messages"
|
|
617
|
+
* value: 20 // Usage value
|
|
618
|
+
* });
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
472
621
|
async usage(params) {
|
|
473
622
|
return handleUsage({
|
|
474
623
|
instance: this,
|
|
475
624
|
params
|
|
476
625
|
});
|
|
477
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Performs advanced queries on customer data and analytics.
|
|
629
|
+
*
|
|
630
|
+
* This method allows you to run complex queries against customer data,
|
|
631
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
632
|
+
* analytics, and custom data insights.
|
|
633
|
+
*
|
|
634
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
635
|
+
* @returns Promise resolving to query results with requested data
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```typescript
|
|
639
|
+
* const result = await autumn.query({
|
|
640
|
+
* customer_id: "user_123",
|
|
641
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
642
|
+
* });
|
|
643
|
+
*
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
478
646
|
async query(params) {
|
|
479
647
|
return handleQuery({
|
|
480
648
|
instance: this,
|
|
@@ -488,8 +656,8 @@ __publicField(Autumn, "entities", entityMethods());
|
|
|
488
656
|
__publicField(Autumn, "referrals", referralMethods());
|
|
489
657
|
__publicField(Autumn, "features", featureMethods());
|
|
490
658
|
__publicField(Autumn, "checkout", (params) => staticWrapper(handleCheckout, void 0, { params }));
|
|
491
|
-
__publicField(Autumn, "attach", (params) => staticWrapper(handleAttach, void 0, { params }));
|
|
492
659
|
__publicField(Autumn, "usage", (params) => staticWrapper(handleUsage, void 0, { params }));
|
|
660
|
+
__publicField(Autumn, "attach", (params) => staticWrapper(handleAttach, void 0, { params }));
|
|
493
661
|
__publicField(Autumn, "setupPayment", (params) => staticWrapper(handleSetupPayment, void 0, { params }));
|
|
494
662
|
__publicField(Autumn, "cancel", (params) => staticWrapper(handleCancel, void 0, { params }));
|
|
495
663
|
__publicField(Autumn, "check", (params) => staticWrapper(handleCheck, void 0, { params }));
|
|
@@ -731,6 +899,8 @@ var CheckoutParamsSchema = v4.z.object({
|
|
|
731
899
|
product_id: v4.z.string(),
|
|
732
900
|
entity_id: v4.z.string().optional(),
|
|
733
901
|
options: v4.z.array(AttachFeatureOptionsSchema).optional(),
|
|
902
|
+
force_checkout: v4.z.boolean().optional(),
|
|
903
|
+
invoice: v4.z.boolean().optional(),
|
|
734
904
|
success_url: v4.z.string().optional(),
|
|
735
905
|
customer_data: CustomerDataSchema.optional(),
|
|
736
906
|
entity_data: v4.z.any().optional(),
|
package/dist/sdk/index.mjs
CHANGED
|
@@ -431,48 +431,216 @@ var Autumn = class {
|
|
|
431
431
|
});
|
|
432
432
|
return toContainerResult({ response, logger: this.logger });
|
|
433
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Initiates a checkout flow for a product purchase.
|
|
436
|
+
*
|
|
437
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
438
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
439
|
+
* to Stripe based on the customer's state and product requirements.
|
|
440
|
+
*
|
|
441
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
442
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```typescript
|
|
446
|
+
* const result = await autumn.checkout({
|
|
447
|
+
* customer_id: "user_123",
|
|
448
|
+
* product_id: "pro",
|
|
449
|
+
* success_url: "https://myapp.com/success"
|
|
450
|
+
* });
|
|
451
|
+
*
|
|
452
|
+
* if (result.url) {
|
|
453
|
+
* // Redirect to Stripe checkout
|
|
454
|
+
* window.location.href = result.url;
|
|
455
|
+
* }
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
434
458
|
async checkout(params) {
|
|
435
459
|
return handleCheckout({
|
|
436
460
|
instance: this,
|
|
437
461
|
params
|
|
438
462
|
});
|
|
439
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
466
|
+
*
|
|
467
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
468
|
+
* When you attach a product:
|
|
469
|
+
* - The customer gains access to all features in the product
|
|
470
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
471
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
472
|
+
*
|
|
473
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
474
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```typescript
|
|
478
|
+
* const result = await autumn.attach({
|
|
479
|
+
* customer_id: "user_123",
|
|
480
|
+
* product_id: "pro",
|
|
481
|
+
* success_url: "https://myapp.com/success"
|
|
482
|
+
* });
|
|
483
|
+
*
|
|
484
|
+
* if (result.checkout_url) {
|
|
485
|
+
* // Payment required - redirect to checkout
|
|
486
|
+
* window.location.href = result.checkout_url;
|
|
487
|
+
* } else {
|
|
488
|
+
* // Product successfully attached
|
|
489
|
+
* console.log("Access granted:", result.message);
|
|
490
|
+
* }
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
440
493
|
async attach(params) {
|
|
441
494
|
return handleAttach({
|
|
442
495
|
instance: this,
|
|
443
496
|
params
|
|
444
497
|
});
|
|
445
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Sets up a payment method for a customer.
|
|
501
|
+
*
|
|
502
|
+
* This method allows you to set up payment methods for customers without
|
|
503
|
+
* immediately charging them. Useful for collecting payment information
|
|
504
|
+
* before product attachment or for updating existing payment methods.
|
|
505
|
+
*
|
|
506
|
+
* @param params - Setup payment parameters including customer information
|
|
507
|
+
* @returns Promise resolving to setup payment result
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* const result = await autumn.setupPayment({
|
|
512
|
+
* customer_id: "user_123"
|
|
513
|
+
* });
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
446
516
|
async setupPayment(params) {
|
|
447
517
|
return handleSetupPayment({
|
|
448
518
|
instance: this,
|
|
449
519
|
params
|
|
450
520
|
});
|
|
451
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* Cancels a customer's subscription or product attachment.
|
|
524
|
+
*
|
|
525
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
526
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
527
|
+
*
|
|
528
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
529
|
+
* @returns Promise resolving to cancellation result
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```typescript
|
|
533
|
+
* const result = await autumn.cancel({
|
|
534
|
+
* customer_id: "user_123",
|
|
535
|
+
* product_id: "pro",
|
|
536
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
537
|
+
* });
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
452
540
|
async cancel(params) {
|
|
453
541
|
return handleCancel({
|
|
454
542
|
instance: this,
|
|
455
543
|
params
|
|
456
544
|
});
|
|
457
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* Checks if a customer has access to a specific feature.
|
|
548
|
+
*
|
|
549
|
+
* This method verifies whether a customer has permission to use a feature
|
|
550
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
551
|
+
* features and determine when to show upgrade prompts.
|
|
552
|
+
*
|
|
553
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
554
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* const result = await autumn.check({
|
|
559
|
+
* customer_id: "user_123",
|
|
560
|
+
* feature_id: "messages",
|
|
561
|
+
* required_balance: 1
|
|
562
|
+
* });
|
|
563
|
+
*
|
|
564
|
+
* if (!result.allowed) {
|
|
565
|
+
* console.log("Feature access denied - upgrade required");
|
|
566
|
+
* }
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
458
569
|
async check(params) {
|
|
459
570
|
return handleCheck({
|
|
460
571
|
instance: this,
|
|
461
572
|
params
|
|
462
573
|
});
|
|
463
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Tracks usage events for features or analytics.
|
|
577
|
+
*
|
|
578
|
+
* This method records usage events for metered features, updating the customer's
|
|
579
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
580
|
+
* accurate tracking that cannot be manipulated by users.
|
|
581
|
+
*
|
|
582
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
583
|
+
* @returns Promise resolving to tracking result
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* const result = await autumn.track({
|
|
588
|
+
* customer_id: "user_123",
|
|
589
|
+
* feature_id: "messages",
|
|
590
|
+
* value: 1 // Track 1 message sent
|
|
591
|
+
* });
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
464
594
|
async track(params) {
|
|
465
595
|
return handleTrack({
|
|
466
596
|
instance: this,
|
|
467
597
|
params
|
|
468
598
|
});
|
|
469
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
602
|
+
*
|
|
603
|
+
* This method fetches detailed usage information for a customer's features,
|
|
604
|
+
* including current balances, usage history, and analytics data. Useful
|
|
605
|
+
* for displaying usage dashboards or generating reports.
|
|
606
|
+
*
|
|
607
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
608
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* const result = await autumn.usage({
|
|
613
|
+
* customer_id: "user_123",
|
|
614
|
+
* feature_id: "messages"
|
|
615
|
+
* value: 20 // Usage value
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
470
619
|
async usage(params) {
|
|
471
620
|
return handleUsage({
|
|
472
621
|
instance: this,
|
|
473
622
|
params
|
|
474
623
|
});
|
|
475
624
|
}
|
|
625
|
+
/**
|
|
626
|
+
* Performs advanced queries on customer data and analytics.
|
|
627
|
+
*
|
|
628
|
+
* This method allows you to run complex queries against customer data,
|
|
629
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
630
|
+
* analytics, and custom data insights.
|
|
631
|
+
*
|
|
632
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
633
|
+
* @returns Promise resolving to query results with requested data
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```typescript
|
|
637
|
+
* const result = await autumn.query({
|
|
638
|
+
* customer_id: "user_123",
|
|
639
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
640
|
+
* });
|
|
641
|
+
*
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
476
644
|
async query(params) {
|
|
477
645
|
return handleQuery({
|
|
478
646
|
instance: this,
|
|
@@ -486,8 +654,8 @@ __publicField(Autumn, "entities", entityMethods());
|
|
|
486
654
|
__publicField(Autumn, "referrals", referralMethods());
|
|
487
655
|
__publicField(Autumn, "features", featureMethods());
|
|
488
656
|
__publicField(Autumn, "checkout", (params) => staticWrapper(handleCheckout, void 0, { params }));
|
|
489
|
-
__publicField(Autumn, "attach", (params) => staticWrapper(handleAttach, void 0, { params }));
|
|
490
657
|
__publicField(Autumn, "usage", (params) => staticWrapper(handleUsage, void 0, { params }));
|
|
658
|
+
__publicField(Autumn, "attach", (params) => staticWrapper(handleAttach, void 0, { params }));
|
|
491
659
|
__publicField(Autumn, "setupPayment", (params) => staticWrapper(handleSetupPayment, void 0, { params }));
|
|
492
660
|
__publicField(Autumn, "cancel", (params) => staticWrapper(handleCancel, void 0, { params }));
|
|
493
661
|
__publicField(Autumn, "check", (params) => staticWrapper(handleCheck, void 0, { params }));
|
|
@@ -729,6 +897,8 @@ var CheckoutParamsSchema = z.object({
|
|
|
729
897
|
product_id: z.string(),
|
|
730
898
|
entity_id: z.string().optional(),
|
|
731
899
|
options: z.array(AttachFeatureOptionsSchema).optional(),
|
|
900
|
+
force_checkout: z.boolean().optional(),
|
|
901
|
+
invoice: z.boolean().optional(),
|
|
732
902
|
success_url: z.string().optional(),
|
|
733
903
|
customer_data: CustomerDataSchema.optional(),
|
|
734
904
|
entity_data: z.any().optional(),
|