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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { QueryParams } from '../client/types/clientGenTypes.mjs';
|
|
3
3
|
import { A as AutumnError } from '../error-DHbclCVh.mjs';
|
|
4
|
-
import { Q as QueryResult } from '../genTypes-
|
|
4
|
+
import { Q as QueryResult } from '../genTypes-DdYlVEah.mjs';
|
|
5
5
|
import 'zod/v4';
|
|
6
|
-
import '../prodTypes-
|
|
6
|
+
import '../prodTypes-C8xRoBP7.mjs';
|
|
7
7
|
|
|
8
8
|
declare const useAnalytics: (params: QueryParams) => {
|
|
9
9
|
data: ({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { QueryParams } from '../client/types/clientGenTypes.js';
|
|
3
3
|
import { A as AutumnError } from '../error-DHbclCVh.js';
|
|
4
|
-
import { Q as QueryResult } from '../genTypes-
|
|
4
|
+
import { Q as QueryResult } from '../genTypes-aPPwPimh.js';
|
|
5
5
|
import 'zod/v4';
|
|
6
|
-
import '../prodTypes-
|
|
6
|
+
import '../prodTypes-C8xRoBP7.js';
|
|
7
7
|
|
|
8
8
|
declare const useAnalytics: (params: QueryParams) => {
|
|
9
9
|
data: ({
|
|
@@ -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
|
useAnalytics
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-CIBQ4BJU.mjs";
|
|
5
|
+
} from "../chunk-ROKCGZ77.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,21 +1,79 @@
|
|
|
1
1
|
import { UseCustomerParams, UseCustomerResult } from './useCustomerBase.mjs';
|
|
2
2
|
import '../error-DHbclCVh.mjs';
|
|
3
|
-
import '../genTypes-
|
|
4
|
-
import '../prodTypes-
|
|
3
|
+
import '../genTypes-DdYlVEah.mjs';
|
|
4
|
+
import '../prodTypes-C8xRoBP7.mjs';
|
|
5
5
|
import 'zod/v4';
|
|
6
|
-
import '../attachTypes-
|
|
7
|
-
import '../entTypes-
|
|
8
|
-
import '../cusTypes-
|
|
9
|
-
import '../ReactAutumnClient-
|
|
6
|
+
import '../attachTypes-Cuxn1ThG.mjs';
|
|
7
|
+
import '../entTypes-D-gn1jj2.mjs';
|
|
8
|
+
import '../cusTypes-B2m4-oz4.mjs';
|
|
9
|
+
import '../ReactAutumnClient-zBxnpPLM.mjs';
|
|
10
10
|
import '../client/types/clientEntTypes.mjs';
|
|
11
11
|
import '../client/types/clientGenTypes.mjs';
|
|
12
12
|
import '../client/types/clientReferralTypes.mjs';
|
|
13
13
|
import 'swr';
|
|
14
14
|
import 'react';
|
|
15
|
-
import './helpers/handleCheck.mjs';
|
|
16
|
-
import '../AutumnContext.mjs';
|
|
17
15
|
import '../client/types/clientAttachTypes.mjs';
|
|
18
16
|
|
|
17
|
+
/**
|
|
18
|
+
* React hook for managing customer billing, subscriptions, and feature access.
|
|
19
|
+
*
|
|
20
|
+
* Provides access to all Autumn billing functions including product attachment,
|
|
21
|
+
* subscription management, usage tracking, and feature gating. Automatically
|
|
22
|
+
* handles customer data fetching and caching.
|
|
23
|
+
*
|
|
24
|
+
* @param params - Optional configuration for the hook
|
|
25
|
+
* @returns Object containing customer data and billing functions
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useCustomer } from "autumn-js/react";
|
|
30
|
+
*
|
|
31
|
+
* function MyComponent() {
|
|
32
|
+
* const {
|
|
33
|
+
* customer,
|
|
34
|
+
* isLoading,
|
|
35
|
+
* attach,
|
|
36
|
+
* cancel,
|
|
37
|
+
* check,
|
|
38
|
+
* track,
|
|
39
|
+
* checkout,
|
|
40
|
+
* openBillingPortal,
|
|
41
|
+
* setupPayment,
|
|
42
|
+
* createReferralCode,
|
|
43
|
+
* redeemReferralCode,
|
|
44
|
+
* createEntity,
|
|
45
|
+
* refetch
|
|
46
|
+
* } = useCustomer();
|
|
47
|
+
*
|
|
48
|
+
* return (
|
|
49
|
+
* <div>
|
|
50
|
+
* <button onClick={() => attach({ productId: "pro" })}>
|
|
51
|
+
* Upgrade to Pro
|
|
52
|
+
* </button>
|
|
53
|
+
* <button onClick={() => cancel({ productId: "pro" })}>
|
|
54
|
+
* Cancel Subscription
|
|
55
|
+
* </button>
|
|
56
|
+
* </div>
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @returns {Object} Hook result object
|
|
62
|
+
* @returns {Customer | null} returns.customer - Current customer data with subscription info
|
|
63
|
+
* @returns {boolean} returns.isLoading - Whether customer data is loading
|
|
64
|
+
* @returns {AutumnError | null} returns.error - Any error from customer data fetching
|
|
65
|
+
* @returns {Function} returns.attach - Attach product to customer with billing
|
|
66
|
+
* @returns {Function} returns.cancel - Cancel customer subscription/product
|
|
67
|
+
* @returns {Function} returns.check - Check feature access and show paywalls
|
|
68
|
+
* @returns {Function} returns.track - Track feature usage events
|
|
69
|
+
* @returns {Function} returns.checkout - Initiate product checkout flow
|
|
70
|
+
* @returns {Function} returns.openBillingPortal - Open Stripe billing portal
|
|
71
|
+
* @returns {Function} returns.setupPayment - Setup payment method
|
|
72
|
+
* @returns {Function} returns.createReferralCode - Create referral codes
|
|
73
|
+
* @returns {Function} returns.redeemReferralCode - Redeem referral codes
|
|
74
|
+
* @returns {Function} returns.createEntity - Create entities for granular tracking
|
|
75
|
+
* @returns {Function} returns.refetch - Manually refetch customer data
|
|
76
|
+
*/
|
|
19
77
|
declare const useCustomer: (params?: UseCustomerParams) => UseCustomerResult;
|
|
20
78
|
|
|
21
79
|
export { useCustomer };
|
|
@@ -1,21 +1,79 @@
|
|
|
1
1
|
import { UseCustomerParams, UseCustomerResult } from './useCustomerBase.js';
|
|
2
2
|
import '../error-DHbclCVh.js';
|
|
3
|
-
import '../genTypes-
|
|
4
|
-
import '../prodTypes-
|
|
3
|
+
import '../genTypes-aPPwPimh.js';
|
|
4
|
+
import '../prodTypes-C8xRoBP7.js';
|
|
5
5
|
import 'zod/v4';
|
|
6
|
-
import '../attachTypes-
|
|
7
|
-
import '../entTypes-
|
|
8
|
-
import '../cusTypes-
|
|
9
|
-
import '../ReactAutumnClient-
|
|
6
|
+
import '../attachTypes-BQaZHr5e.js';
|
|
7
|
+
import '../entTypes-WMQRyYAv.js';
|
|
8
|
+
import '../cusTypes-lMnznWYJ.js';
|
|
9
|
+
import '../ReactAutumnClient-CIAkiqwV.js';
|
|
10
10
|
import '../client/types/clientEntTypes.js';
|
|
11
11
|
import '../client/types/clientGenTypes.js';
|
|
12
12
|
import '../client/types/clientReferralTypes.js';
|
|
13
13
|
import 'swr';
|
|
14
14
|
import 'react';
|
|
15
|
-
import './helpers/handleCheck.js';
|
|
16
|
-
import '../AutumnContext.js';
|
|
17
15
|
import '../client/types/clientAttachTypes.js';
|
|
18
16
|
|
|
17
|
+
/**
|
|
18
|
+
* React hook for managing customer billing, subscriptions, and feature access.
|
|
19
|
+
*
|
|
20
|
+
* Provides access to all Autumn billing functions including product attachment,
|
|
21
|
+
* subscription management, usage tracking, and feature gating. Automatically
|
|
22
|
+
* handles customer data fetching and caching.
|
|
23
|
+
*
|
|
24
|
+
* @param params - Optional configuration for the hook
|
|
25
|
+
* @returns Object containing customer data and billing functions
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useCustomer } from "autumn-js/react";
|
|
30
|
+
*
|
|
31
|
+
* function MyComponent() {
|
|
32
|
+
* const {
|
|
33
|
+
* customer,
|
|
34
|
+
* isLoading,
|
|
35
|
+
* attach,
|
|
36
|
+
* cancel,
|
|
37
|
+
* check,
|
|
38
|
+
* track,
|
|
39
|
+
* checkout,
|
|
40
|
+
* openBillingPortal,
|
|
41
|
+
* setupPayment,
|
|
42
|
+
* createReferralCode,
|
|
43
|
+
* redeemReferralCode,
|
|
44
|
+
* createEntity,
|
|
45
|
+
* refetch
|
|
46
|
+
* } = useCustomer();
|
|
47
|
+
*
|
|
48
|
+
* return (
|
|
49
|
+
* <div>
|
|
50
|
+
* <button onClick={() => attach({ productId: "pro" })}>
|
|
51
|
+
* Upgrade to Pro
|
|
52
|
+
* </button>
|
|
53
|
+
* <button onClick={() => cancel({ productId: "pro" })}>
|
|
54
|
+
* Cancel Subscription
|
|
55
|
+
* </button>
|
|
56
|
+
* </div>
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @returns {Object} Hook result object
|
|
62
|
+
* @returns {Customer | null} returns.customer - Current customer data with subscription info
|
|
63
|
+
* @returns {boolean} returns.isLoading - Whether customer data is loading
|
|
64
|
+
* @returns {AutumnError | null} returns.error - Any error from customer data fetching
|
|
65
|
+
* @returns {Function} returns.attach - Attach product to customer with billing
|
|
66
|
+
* @returns {Function} returns.cancel - Cancel customer subscription/product
|
|
67
|
+
* @returns {Function} returns.check - Check feature access and show paywalls
|
|
68
|
+
* @returns {Function} returns.track - Track feature usage events
|
|
69
|
+
* @returns {Function} returns.checkout - Initiate product checkout flow
|
|
70
|
+
* @returns {Function} returns.openBillingPortal - Open Stripe billing portal
|
|
71
|
+
* @returns {Function} returns.setupPayment - Setup payment method
|
|
72
|
+
* @returns {Function} returns.createReferralCode - Create referral codes
|
|
73
|
+
* @returns {Function} returns.redeemReferralCode - Redeem referral codes
|
|
74
|
+
* @returns {Function} returns.createEntity - Create entities for granular tracking
|
|
75
|
+
* @returns {Function} returns.refetch - Manually refetch customer data
|
|
76
|
+
*/
|
|
19
77
|
declare const useCustomer: (params?: UseCustomerParams) => UseCustomerResult;
|
|
20
78
|
|
|
21
79
|
export { useCustomer };
|