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
|
@@ -512,22 +512,92 @@ var Autumn = class {
|
|
|
512
512
|
entities = entityMethods(this);
|
|
513
513
|
referrals = referralMethods(this);
|
|
514
514
|
features = featureMethods(this);
|
|
515
|
-
|
|
515
|
+
/**
|
|
516
|
+
* Initiates a checkout flow for a product purchase.
|
|
517
|
+
*
|
|
518
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
519
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
520
|
+
* to Stripe based on the customer's state and product requirements.
|
|
521
|
+
*
|
|
522
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
523
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* const result = await autumn.checkout({
|
|
528
|
+
* customer_id: "user_123",
|
|
529
|
+
* product_id: "pro",
|
|
530
|
+
* success_url: "https://myapp.com/success"
|
|
531
|
+
* });
|
|
532
|
+
*
|
|
533
|
+
* if (result.url) {
|
|
534
|
+
* // Redirect to Stripe checkout
|
|
535
|
+
* window.location.href = result.url;
|
|
536
|
+
* }
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
516
539
|
async checkout(params) {
|
|
517
540
|
return handleCheckout({
|
|
518
541
|
instance: this,
|
|
519
542
|
params
|
|
520
543
|
});
|
|
521
544
|
}
|
|
522
|
-
static
|
|
545
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
523
546
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
547
|
+
/**
|
|
548
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
549
|
+
*
|
|
550
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
551
|
+
* When you attach a product:
|
|
552
|
+
* - The customer gains access to all features in the product
|
|
553
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
554
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
555
|
+
*
|
|
556
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
557
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```typescript
|
|
561
|
+
* const result = await autumn.attach({
|
|
562
|
+
* customer_id: "user_123",
|
|
563
|
+
* product_id: "pro",
|
|
564
|
+
* success_url: "https://myapp.com/success"
|
|
565
|
+
* });
|
|
566
|
+
*
|
|
567
|
+
* if (result.checkout_url) {
|
|
568
|
+
* // Payment required - redirect to checkout
|
|
569
|
+
* window.location.href = result.checkout_url;
|
|
570
|
+
* } else {
|
|
571
|
+
* // Product successfully attached
|
|
572
|
+
* console.log("Access granted:", result.message);
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
524
576
|
async attach(params) {
|
|
525
577
|
return handleAttach({
|
|
526
578
|
instance: this,
|
|
527
579
|
params
|
|
528
580
|
});
|
|
529
581
|
}
|
|
582
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
530
583
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
584
|
+
/**
|
|
585
|
+
* Sets up a payment method for a customer.
|
|
586
|
+
*
|
|
587
|
+
* This method allows you to set up payment methods for customers without
|
|
588
|
+
* immediately charging them. Useful for collecting payment information
|
|
589
|
+
* before product attachment or for updating existing payment methods.
|
|
590
|
+
*
|
|
591
|
+
* @param params - Setup payment parameters including customer information
|
|
592
|
+
* @returns Promise resolving to setup payment result
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* const result = await autumn.setupPayment({
|
|
597
|
+
* customer_id: "user_123"
|
|
598
|
+
* });
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
531
601
|
async setupPayment(params) {
|
|
532
602
|
return handleSetupPayment({
|
|
533
603
|
instance: this,
|
|
@@ -535,6 +605,24 @@ var Autumn = class {
|
|
|
535
605
|
});
|
|
536
606
|
}
|
|
537
607
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
608
|
+
/**
|
|
609
|
+
* Cancels a customer's subscription or product attachment.
|
|
610
|
+
*
|
|
611
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
612
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
613
|
+
*
|
|
614
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
615
|
+
* @returns Promise resolving to cancellation result
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* const result = await autumn.cancel({
|
|
620
|
+
* customer_id: "user_123",
|
|
621
|
+
* product_id: "pro",
|
|
622
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
623
|
+
* });
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
538
626
|
async cancel(params) {
|
|
539
627
|
return handleCancel({
|
|
540
628
|
instance: this,
|
|
@@ -542,6 +630,29 @@ var Autumn = class {
|
|
|
542
630
|
});
|
|
543
631
|
}
|
|
544
632
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
633
|
+
/**
|
|
634
|
+
* Checks if a customer has access to a specific feature.
|
|
635
|
+
*
|
|
636
|
+
* This method verifies whether a customer has permission to use a feature
|
|
637
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
638
|
+
* features and determine when to show upgrade prompts.
|
|
639
|
+
*
|
|
640
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
641
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* const result = await autumn.check({
|
|
646
|
+
* customer_id: "user_123",
|
|
647
|
+
* feature_id: "messages",
|
|
648
|
+
* required_balance: 1
|
|
649
|
+
* });
|
|
650
|
+
*
|
|
651
|
+
* if (!result.allowed) {
|
|
652
|
+
* console.log("Feature access denied - upgrade required");
|
|
653
|
+
* }
|
|
654
|
+
* ```
|
|
655
|
+
*/
|
|
545
656
|
async check(params) {
|
|
546
657
|
return handleCheck({
|
|
547
658
|
instance: this,
|
|
@@ -549,12 +660,50 @@ var Autumn = class {
|
|
|
549
660
|
});
|
|
550
661
|
}
|
|
551
662
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
663
|
+
/**
|
|
664
|
+
* Tracks usage events for features or analytics.
|
|
665
|
+
*
|
|
666
|
+
* This method records usage events for metered features, updating the customer's
|
|
667
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
668
|
+
* accurate tracking that cannot be manipulated by users.
|
|
669
|
+
*
|
|
670
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
671
|
+
* @returns Promise resolving to tracking result
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const result = await autumn.track({
|
|
676
|
+
* customer_id: "user_123",
|
|
677
|
+
* feature_id: "messages",
|
|
678
|
+
* value: 1 // Track 1 message sent
|
|
679
|
+
* });
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
552
682
|
async track(params) {
|
|
553
683
|
return handleTrack({
|
|
554
684
|
instance: this,
|
|
555
685
|
params
|
|
556
686
|
});
|
|
557
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
690
|
+
*
|
|
691
|
+
* This method fetches detailed usage information for a customer's features,
|
|
692
|
+
* including current balances, usage history, and analytics data. Useful
|
|
693
|
+
* for displaying usage dashboards or generating reports.
|
|
694
|
+
*
|
|
695
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
696
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const result = await autumn.usage({
|
|
701
|
+
* customer_id: "user_123",
|
|
702
|
+
* feature_id: "messages"
|
|
703
|
+
* value: 20 // Usage value
|
|
704
|
+
* });
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
558
707
|
async usage(params) {
|
|
559
708
|
return handleUsage({
|
|
560
709
|
instance: this,
|
|
@@ -562,6 +711,25 @@ var Autumn = class {
|
|
|
562
711
|
});
|
|
563
712
|
}
|
|
564
713
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
714
|
+
/**
|
|
715
|
+
* Performs advanced queries on customer data and analytics.
|
|
716
|
+
*
|
|
717
|
+
* This method allows you to run complex queries against customer data,
|
|
718
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
719
|
+
* analytics, and custom data insights.
|
|
720
|
+
*
|
|
721
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
722
|
+
* @returns Promise resolving to query results with requested data
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```typescript
|
|
726
|
+
* const result = await autumn.query({
|
|
727
|
+
* customer_id: "user_123",
|
|
728
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
729
|
+
* });
|
|
730
|
+
*
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
565
733
|
async query(params) {
|
|
566
734
|
return handleQuery({
|
|
567
735
|
instance: this,
|
|
@@ -777,6 +945,8 @@ var CheckoutParamsSchema = z7.object({
|
|
|
777
945
|
product_id: z7.string(),
|
|
778
946
|
entity_id: z7.string().optional(),
|
|
779
947
|
options: z7.array(AttachFeatureOptionsSchema).optional(),
|
|
948
|
+
force_checkout: z7.boolean().optional(),
|
|
949
|
+
invoice: z7.boolean().optional(),
|
|
780
950
|
success_url: z7.string().optional(),
|
|
781
951
|
customer_data: CustomerDataSchema.optional(),
|
|
782
952
|
entity_data: z7.any().optional(),
|
|
@@ -1476,7 +1646,6 @@ var useAutumnBase = ({
|
|
|
1476
1646
|
};
|
|
1477
1647
|
return {
|
|
1478
1648
|
attach,
|
|
1479
|
-
// check,
|
|
1480
1649
|
track,
|
|
1481
1650
|
cancel,
|
|
1482
1651
|
openBillingPortal,
|
|
@@ -1696,16 +1865,6 @@ var useCustomerBase = ({
|
|
|
1696
1865
|
context
|
|
1697
1866
|
});
|
|
1698
1867
|
return res;
|
|
1699
|
-
},
|
|
1700
|
-
/** @deprecated Use check() instead */
|
|
1701
|
-
allowed: (params2) => {
|
|
1702
|
-
const result = handleCheck2({
|
|
1703
|
-
customer,
|
|
1704
|
-
params: params2,
|
|
1705
|
-
isEntity: false,
|
|
1706
|
-
context
|
|
1707
|
-
});
|
|
1708
|
-
return result.data.allowed;
|
|
1709
1868
|
}
|
|
1710
1869
|
};
|
|
1711
1870
|
};
|
|
@@ -168,4 +168,4 @@ interface Product {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
export { AppEnv as A, type CheckFeaturePreview as C, type Product as P, type
|
|
171
|
+
export { AppEnv as A, type CheckFeaturePreview as C, type Product as P, type CheckFeatureResult as a, type CheckProductResult as b, type ProductItem as c, ProductItemInterval as d, type ProductScenario as e };
|
|
@@ -168,4 +168,4 @@ interface Product {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
export { AppEnv as A, type CheckFeaturePreview as C, type Product as P, type
|
|
171
|
+
export { AppEnv as A, type CheckFeaturePreview as C, type Product as P, type CheckFeatureResult as a, type CheckProductResult as b, type ProductItem as c, ProductItemInterval as d, type ProductScenario as e };
|
|
@@ -17,28 +17,65 @@ declare const RedeemReferralCodeParamsSchema: z.ZodObject<{
|
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
type RedeemReferralCodeParams = z.infer<typeof RedeemReferralCodeParamsSchema>;
|
|
19
19
|
|
|
20
|
-
interface AllowedParams {
|
|
21
|
-
featureId?: string;
|
|
22
|
-
productId?: string;
|
|
23
|
-
requiredBalance?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
20
|
interface UseCustomerResult {
|
|
21
|
+
/** The current customer data including subscription and feature information */
|
|
27
22
|
customer: Customer | null;
|
|
23
|
+
/** Whether customer data is currently being loaded */
|
|
28
24
|
isLoading: boolean;
|
|
25
|
+
/** Any error that occurred while fetching customer data */
|
|
29
26
|
error: AutumnError | null;
|
|
27
|
+
/**
|
|
28
|
+
* Attaches a product to the current customer, enabling access and handling billing.
|
|
29
|
+
* Activates a product and applies all product items with automatic payment handling.
|
|
30
|
+
*/
|
|
30
31
|
attach: (params: AttachParams) => AutumnPromise<AttachResult | CheckResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Tracks usage events for metered features.
|
|
34
|
+
* Records feature usage and updates customer balances server-side.
|
|
35
|
+
*/
|
|
31
36
|
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Cancels a customer's subscription or product attachment.
|
|
39
|
+
* Can cancel immediately or at the end of the billing cycle.
|
|
40
|
+
*/
|
|
32
41
|
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Sets up a payment method for the customer.
|
|
44
|
+
* Collects payment information without immediately charging.
|
|
45
|
+
*/
|
|
33
46
|
setupPayment: (params: SetupPaymentParams) => AutumnPromise<SetupPaymentResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Opens the Stripe billing portal for the customer.
|
|
49
|
+
* Allows customers to manage their subscription and payment methods.
|
|
50
|
+
*/
|
|
34
51
|
openBillingPortal: (params?: OpenBillingPortalParams) => AutumnPromise<BillingPortalResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Initiates a checkout flow for product purchase.
|
|
54
|
+
* Handles payment collection and redirects to Stripe checkout when needed.
|
|
55
|
+
*/
|
|
35
56
|
checkout: (params: CheckoutParams) => AutumnPromise<CheckoutResult>;
|
|
57
|
+
/** Refetches the customer data from the server */
|
|
36
58
|
refetch: () => Promise<Customer | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates new entities for granular feature tracking.
|
|
61
|
+
* Entities allow per-user or per-workspace feature limits.
|
|
62
|
+
*/
|
|
37
63
|
createEntity: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a referral code for the customer.
|
|
66
|
+
* Generates codes that can be shared for referral programs.
|
|
67
|
+
*/
|
|
38
68
|
createReferralCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Redeems a referral code for the customer.
|
|
71
|
+
* Applies referral benefits when a valid code is provided.
|
|
72
|
+
*/
|
|
39
73
|
redeemReferralCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a customer has access to a feature and shows paywalls if needed.
|
|
76
|
+
* Client-side feature gating with optional dialog display for upgrades.
|
|
77
|
+
*/
|
|
40
78
|
check: (params: CheckParams) => Success<CheckResult>;
|
|
41
|
-
allowed: (params: AllowedParams) => boolean;
|
|
42
79
|
}
|
|
43
80
|
interface UseCustomerParams {
|
|
44
81
|
errorOnNotFound?: boolean;
|
|
@@ -17,28 +17,65 @@ declare const RedeemReferralCodeParamsSchema: z.ZodObject<{
|
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
type RedeemReferralCodeParams = z.infer<typeof RedeemReferralCodeParamsSchema>;
|
|
19
19
|
|
|
20
|
-
interface AllowedParams {
|
|
21
|
-
featureId?: string;
|
|
22
|
-
productId?: string;
|
|
23
|
-
requiredBalance?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
20
|
interface UseCustomerResult {
|
|
21
|
+
/** The current customer data including subscription and feature information */
|
|
27
22
|
customer: Customer | null;
|
|
23
|
+
/** Whether customer data is currently being loaded */
|
|
28
24
|
isLoading: boolean;
|
|
25
|
+
/** Any error that occurred while fetching customer data */
|
|
29
26
|
error: AutumnError | null;
|
|
27
|
+
/**
|
|
28
|
+
* Attaches a product to the current customer, enabling access and handling billing.
|
|
29
|
+
* Activates a product and applies all product items with automatic payment handling.
|
|
30
|
+
*/
|
|
30
31
|
attach: (params: AttachParams) => AutumnPromise<AttachResult | CheckResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Tracks usage events for metered features.
|
|
34
|
+
* Records feature usage and updates customer balances server-side.
|
|
35
|
+
*/
|
|
31
36
|
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Cancels a customer's subscription or product attachment.
|
|
39
|
+
* Can cancel immediately or at the end of the billing cycle.
|
|
40
|
+
*/
|
|
32
41
|
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Sets up a payment method for the customer.
|
|
44
|
+
* Collects payment information without immediately charging.
|
|
45
|
+
*/
|
|
33
46
|
setupPayment: (params: SetupPaymentParams) => AutumnPromise<SetupPaymentResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Opens the Stripe billing portal for the customer.
|
|
49
|
+
* Allows customers to manage their subscription and payment methods.
|
|
50
|
+
*/
|
|
34
51
|
openBillingPortal: (params?: OpenBillingPortalParams) => AutumnPromise<BillingPortalResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Initiates a checkout flow for product purchase.
|
|
54
|
+
* Handles payment collection and redirects to Stripe checkout when needed.
|
|
55
|
+
*/
|
|
35
56
|
checkout: (params: CheckoutParams) => AutumnPromise<CheckoutResult>;
|
|
57
|
+
/** Refetches the customer data from the server */
|
|
36
58
|
refetch: () => Promise<Customer | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates new entities for granular feature tracking.
|
|
61
|
+
* Entities allow per-user or per-workspace feature limits.
|
|
62
|
+
*/
|
|
37
63
|
createEntity: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a referral code for the customer.
|
|
66
|
+
* Generates codes that can be shared for referral programs.
|
|
67
|
+
*/
|
|
38
68
|
createReferralCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Redeems a referral code for the customer.
|
|
71
|
+
* Applies referral benefits when a valid code is provided.
|
|
72
|
+
*/
|
|
39
73
|
redeemReferralCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a customer has access to a feature and shows paywalls if needed.
|
|
76
|
+
* Client-side feature gating with optional dialog display for upgrades.
|
|
77
|
+
*/
|
|
40
78
|
check: (params: CheckParams) => Success<CheckResult>;
|
|
41
|
-
allowed: (params: AllowedParams) => boolean;
|
|
42
79
|
}
|
|
43
80
|
interface UseCustomerParams {
|
|
44
81
|
errorOnNotFound?: boolean;
|
|
@@ -114,6 +114,8 @@ declare const CheckoutParamsSchema: z.ZodObject<{
|
|
|
114
114
|
feature_id: z.ZodString;
|
|
115
115
|
quantity: z.ZodNumber;
|
|
116
116
|
}, z.core.$strip>>>;
|
|
117
|
+
force_checkout: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
invoice: z.ZodOptional<z.ZodBoolean>;
|
|
117
119
|
success_url: z.ZodOptional<z.ZodString>;
|
|
118
120
|
customer_data: z.ZodOptional<z.ZodObject<{
|
|
119
121
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -178,11 +180,11 @@ declare const FeatureSchema: z$1.ZodObject<{
|
|
|
178
180
|
}, "strip", z$1.ZodTypeAny, {
|
|
179
181
|
id: string;
|
|
180
182
|
type: FeatureType;
|
|
183
|
+
name?: string | null | undefined;
|
|
181
184
|
credit_schema?: {
|
|
182
185
|
metered_feature_id: string;
|
|
183
186
|
credit_cost: number;
|
|
184
187
|
}[] | null | undefined;
|
|
185
|
-
name?: string | null | undefined;
|
|
186
188
|
display?: {
|
|
187
189
|
singular: string;
|
|
188
190
|
plural: string;
|
|
@@ -190,11 +192,11 @@ declare const FeatureSchema: z$1.ZodObject<{
|
|
|
190
192
|
}, {
|
|
191
193
|
id: string;
|
|
192
194
|
type: FeatureType;
|
|
195
|
+
name?: string | null | undefined;
|
|
193
196
|
credit_schema?: {
|
|
194
197
|
metered_feature_id: string;
|
|
195
198
|
credit_cost: number;
|
|
196
199
|
}[] | null | undefined;
|
|
197
|
-
name?: string | null | undefined;
|
|
198
200
|
display?: {
|
|
199
201
|
singular: string;
|
|
200
202
|
plural: string;
|
|
@@ -279,9 +281,63 @@ declare class Autumn {
|
|
|
279
281
|
list: Feature[];
|
|
280
282
|
}, AutumnError>>;
|
|
281
283
|
};
|
|
282
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Initiates a checkout flow for a product purchase.
|
|
286
|
+
*
|
|
287
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
288
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
289
|
+
* to Stripe based on the customer's state and product requirements.
|
|
290
|
+
*
|
|
291
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
292
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* const result = await autumn.checkout({
|
|
297
|
+
* customer_id: "user_123",
|
|
298
|
+
* product_id: "pro",
|
|
299
|
+
* success_url: "https://myapp.com/success"
|
|
300
|
+
* });
|
|
301
|
+
*
|
|
302
|
+
* if (result.url) {
|
|
303
|
+
* // Redirect to Stripe checkout
|
|
304
|
+
* window.location.href = result.url;
|
|
305
|
+
* }
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
283
308
|
checkout(params: CheckoutParams): Promise<Result<CheckoutResult, AutumnError>>;
|
|
284
|
-
static
|
|
309
|
+
static checkout: (params: CheckoutParams) => Promise<Result<CheckoutResult, AutumnError>>;
|
|
310
|
+
static usage: (params: UsageParams) => Promise<Result<UsageResult, AutumnError>>;
|
|
311
|
+
/**
|
|
312
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
313
|
+
*
|
|
314
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
315
|
+
* When you attach a product:
|
|
316
|
+
* - The customer gains access to all features in the product
|
|
317
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
318
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
319
|
+
*
|
|
320
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
321
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const result = await autumn.attach({
|
|
326
|
+
* customer_id: "user_123",
|
|
327
|
+
* product_id: "pro",
|
|
328
|
+
* success_url: "https://myapp.com/success"
|
|
329
|
+
* });
|
|
330
|
+
*
|
|
331
|
+
* if (result.checkout_url) {
|
|
332
|
+
* // Payment required - redirect to checkout
|
|
333
|
+
* window.location.href = result.checkout_url;
|
|
334
|
+
* } else {
|
|
335
|
+
* // Product successfully attached
|
|
336
|
+
* console.log("Access granted:", result.message);
|
|
337
|
+
* }
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
attach(params: AttachParams): Promise<Result<{
|
|
285
341
|
customer_id: string;
|
|
286
342
|
product_ids: string[];
|
|
287
343
|
code: string;
|
|
@@ -296,8 +352,7 @@ declare class Autumn {
|
|
|
296
352
|
currency: string;
|
|
297
353
|
} | undefined;
|
|
298
354
|
}, AutumnError>>;
|
|
299
|
-
static
|
|
300
|
-
attach(params: AttachParams): Promise<Result<{
|
|
355
|
+
static attach: (params: AttachParams) => Promise<Result<{
|
|
301
356
|
customer_id: string;
|
|
302
357
|
product_ids: string[];
|
|
303
358
|
code: string;
|
|
@@ -313,18 +368,76 @@ declare class Autumn {
|
|
|
313
368
|
} | undefined;
|
|
314
369
|
}, AutumnError>>;
|
|
315
370
|
static setupPayment: (params: SetupPaymentParams) => Promise<Result<SetupPaymentResult, AutumnError>>;
|
|
371
|
+
/**
|
|
372
|
+
* Sets up a payment method for a customer.
|
|
373
|
+
*
|
|
374
|
+
* This method allows you to set up payment methods for customers without
|
|
375
|
+
* immediately charging them. Useful for collecting payment information
|
|
376
|
+
* before product attachment or for updating existing payment methods.
|
|
377
|
+
*
|
|
378
|
+
* @param params - Setup payment parameters including customer information
|
|
379
|
+
* @returns Promise resolving to setup payment result
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```typescript
|
|
383
|
+
* const result = await autumn.setupPayment({
|
|
384
|
+
* customer_id: "user_123"
|
|
385
|
+
* });
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
316
388
|
setupPayment(params: SetupPaymentParams): Promise<Result<SetupPaymentResult, AutumnError>>;
|
|
317
389
|
static cancel: (params: CancelParams) => Promise<Result<{
|
|
318
390
|
success: boolean;
|
|
319
391
|
customer_id: string;
|
|
320
392
|
product_id: string;
|
|
321
393
|
}, AutumnError>>;
|
|
394
|
+
/**
|
|
395
|
+
* Cancels a customer's subscription or product attachment.
|
|
396
|
+
*
|
|
397
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
398
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
399
|
+
*
|
|
400
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
401
|
+
* @returns Promise resolving to cancellation result
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* const result = await autumn.cancel({
|
|
406
|
+
* customer_id: "user_123",
|
|
407
|
+
* product_id: "pro",
|
|
408
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
409
|
+
* });
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
322
412
|
cancel(params: CancelParams): Promise<Result<{
|
|
323
413
|
success: boolean;
|
|
324
414
|
customer_id: string;
|
|
325
415
|
product_id: string;
|
|
326
416
|
}, AutumnError>>;
|
|
327
417
|
static check: (params: CheckParams) => Promise<Result<CheckResult, AutumnError>>;
|
|
418
|
+
/**
|
|
419
|
+
* Checks if a customer has access to a specific feature.
|
|
420
|
+
*
|
|
421
|
+
* This method verifies whether a customer has permission to use a feature
|
|
422
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
423
|
+
* features and determine when to show upgrade prompts.
|
|
424
|
+
*
|
|
425
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
426
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* const result = await autumn.check({
|
|
431
|
+
* customer_id: "user_123",
|
|
432
|
+
* feature_id: "messages",
|
|
433
|
+
* required_balance: 1
|
|
434
|
+
* });
|
|
435
|
+
*
|
|
436
|
+
* if (!result.allowed) {
|
|
437
|
+
* console.log("Feature access denied - upgrade required");
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
328
441
|
check(params: CheckParams): Promise<Result<CheckResult, AutumnError>>;
|
|
329
442
|
static track: (params: TrackParams) => Promise<Result<{
|
|
330
443
|
id: string;
|
|
@@ -333,6 +446,25 @@ declare class Autumn {
|
|
|
333
446
|
feature_id?: string | undefined;
|
|
334
447
|
event_name?: string | undefined;
|
|
335
448
|
}, AutumnError>>;
|
|
449
|
+
/**
|
|
450
|
+
* Tracks usage events for features or analytics.
|
|
451
|
+
*
|
|
452
|
+
* This method records usage events for metered features, updating the customer's
|
|
453
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
454
|
+
* accurate tracking that cannot be manipulated by users.
|
|
455
|
+
*
|
|
456
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
457
|
+
* @returns Promise resolving to tracking result
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const result = await autumn.track({
|
|
462
|
+
* customer_id: "user_123",
|
|
463
|
+
* feature_id: "messages",
|
|
464
|
+
* value: 1 // Track 1 message sent
|
|
465
|
+
* });
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
336
468
|
track(params: TrackParams): Promise<Result<{
|
|
337
469
|
id: string;
|
|
338
470
|
code: string;
|
|
@@ -340,8 +472,46 @@ declare class Autumn {
|
|
|
340
472
|
feature_id?: string | undefined;
|
|
341
473
|
event_name?: string | undefined;
|
|
342
474
|
}, AutumnError>>;
|
|
475
|
+
/**
|
|
476
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
477
|
+
*
|
|
478
|
+
* This method fetches detailed usage information for a customer's features,
|
|
479
|
+
* including current balances, usage history, and analytics data. Useful
|
|
480
|
+
* for displaying usage dashboards or generating reports.
|
|
481
|
+
*
|
|
482
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
483
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* const result = await autumn.usage({
|
|
488
|
+
* customer_id: "user_123",
|
|
489
|
+
* feature_id: "messages"
|
|
490
|
+
* value: 20 // Usage value
|
|
491
|
+
* });
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
343
494
|
usage(params: UsageParams): Promise<Result<UsageResult, AutumnError>>;
|
|
344
495
|
static query: (params: QueryParams) => Promise<Result<QueryResult, AutumnError>>;
|
|
496
|
+
/**
|
|
497
|
+
* Performs advanced queries on customer data and analytics.
|
|
498
|
+
*
|
|
499
|
+
* This method allows you to run complex queries against customer data,
|
|
500
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
501
|
+
* analytics, and custom data insights.
|
|
502
|
+
*
|
|
503
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
504
|
+
* @returns Promise resolving to query results with requested data
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* const result = await autumn.query({
|
|
509
|
+
* customer_id: "user_123",
|
|
510
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
511
|
+
* });
|
|
512
|
+
*
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
345
515
|
query(params: QueryParams): Promise<Result<QueryResult, AutumnError>>;
|
|
346
516
|
}
|
|
347
517
|
|