autumn-js 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/backend/better-auth.d.mts +4 -0
- package/dist/libraries/backend/better-auth.d.ts +4 -0
- package/dist/libraries/backend/better-auth.js +172 -2
- package/dist/libraries/backend/better-auth.mjs +7 -7
- package/dist/libraries/backend/{chunk-EW2R7722.mjs → chunk-2DWGCQCF.mjs} +1 -1
- package/dist/libraries/backend/{chunk-VNJ3MFJE.mjs → chunk-56RGUNOT.mjs} +1 -1
- package/dist/libraries/backend/{chunk-P3ARLB2M.mjs → chunk-6JI6MF4S.mjs} +1 -1
- package/dist/libraries/backend/{chunk-5DDCZMDB.mjs → chunk-FA5Z2MOT.mjs} +1 -1
- package/dist/libraries/backend/{chunk-RAHKKJED.mjs → chunk-NWPFUFXX.mjs} +6 -6
- package/dist/libraries/backend/{chunk-NAP2URIW.mjs → chunk-Q7SD535L.mjs} +172 -2
- package/dist/libraries/backend/{chunk-7K3RATTK.mjs → chunk-SDL7BFTH.mjs} +1 -1
- package/dist/libraries/backend/convex.js +172 -2
- package/dist/libraries/backend/convex.mjs +7 -7
- package/dist/libraries/backend/elysia.js +172 -2
- package/dist/libraries/backend/elysia.mjs +7 -7
- package/dist/libraries/backend/express.d.mts +1 -1
- package/dist/libraries/backend/express.d.ts +1 -1
- package/dist/libraries/backend/express.js +172 -2
- package/dist/libraries/backend/express.mjs +7 -7
- package/dist/libraries/backend/fastify.js +172 -2
- package/dist/libraries/backend/fastify.mjs +7 -7
- package/dist/libraries/backend/hono.js +172 -2
- package/dist/libraries/backend/hono.mjs +7 -7
- package/dist/libraries/backend/index.d.mts +1 -1
- package/dist/libraries/backend/index.d.ts +1 -1
- package/dist/libraries/backend/index.js +172 -2
- package/dist/libraries/backend/index.mjs +7 -7
- package/dist/libraries/backend/next.js +172 -2
- package/dist/libraries/backend/next.mjs +7 -7
- package/dist/libraries/backend/react-router.js +172 -2
- package/dist/libraries/backend/react-router.mjs +7 -7
- package/dist/libraries/backend/{referralTypes-C1eZ8cjO.d.mts → referralTypes-DSv2hpmP.d.mts} +178 -44
- package/dist/libraries/backend/{referralTypes-FlI0fYwz.d.ts → referralTypes-DdKvvqSK.d.ts} +178 -44
- package/dist/libraries/backend/remix_dep.js +172 -2
- package/dist/libraries/backend/remix_dep.mjs +7 -7
- package/dist/libraries/backend/routes/backendRouter.js +172 -2
- package/dist/libraries/backend/routes/backendRouter.mjs +7 -7
- package/dist/libraries/backend/routes/entityRoutes.js +172 -2
- package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/genRoutes.js +172 -2
- package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/productRoutes.js +172 -2
- package/dist/libraries/backend/routes/productRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/referralRoutes.js +172 -2
- package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
- package/dist/libraries/backend/supabase.js +172 -2
- package/dist/libraries/backend/supabase.mjs +7 -7
- package/dist/libraries/backend/tanstack.js +172 -2
- package/dist/libraries/backend/tanstack.mjs +7 -7
- package/dist/libraries/backend/utils/backendRes.js +172 -2
- package/dist/libraries/backend/utils/backendRes.mjs +1 -1
- package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
- package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
- package/dist/libraries/backend/utils/withAuth.js +172 -2
- package/dist/libraries/backend/utils/withAuth.mjs +2 -2
- package/dist/libraries/react/AutumnContext.js +176 -4
- package/dist/libraries/react/AutumnContext.mjs +4 -4
- package/dist/libraries/react/BaseAutumnProvider.js +176 -15
- package/dist/libraries/react/BaseAutumnProvider.mjs +9 -9
- package/dist/libraries/react/ReactAutumnProvider.js +176 -15
- package/dist/libraries/react/ReactAutumnProvider.mjs +10 -10
- package/dist/libraries/react/{chunk-2ENHPIYQ.mjs → chunk-52HVA7E4.mjs} +3 -3
- package/dist/libraries/react/{chunk-WYQMHQUE.mjs → chunk-5O3IHYFF.mjs} +172 -2
- package/dist/libraries/react/{chunk-JHFJKAXG.mjs → chunk-5YM6QT7V.mjs} +33 -33
- package/dist/libraries/react/{chunk-KP2Q65Y3.mjs → chunk-643J45JV.mjs} +2 -2
- package/dist/libraries/react/{chunk-YHT2JUXO.mjs → chunk-7HRCOEUW.mjs} +1 -1
- package/dist/libraries/react/{chunk-OMJJLT2Q.mjs → chunk-7JU3XHKL.mjs} +1 -1
- package/dist/libraries/react/{chunk-XK3AXQED.mjs → chunk-BT5OY2CA.mjs} +3 -13
- package/dist/libraries/react/{chunk-KMYL54B4.mjs → chunk-DKOF357C.mjs} +1 -1
- package/dist/libraries/react/{chunk-4NZ7ML7V.mjs → chunk-M3SON3SH.mjs} +2 -2
- package/dist/libraries/react/{chunk-67RWFVWN.mjs → chunk-OSYZMMQC.mjs} +2 -2
- package/dist/libraries/react/{chunk-6D6TYTTO.mjs → chunk-P6CAHZVT.mjs} +1 -2
- package/dist/libraries/react/{chunk-VZY225C6.mjs → chunk-RP56DI4O.mjs} +2 -2
- package/dist/libraries/react/{chunk-FDNQ6GRK.mjs → chunk-SWVRRNIW.mjs} +1 -1
- package/dist/libraries/react/{chunk-U3OQJXCW.mjs → chunk-TOAZUTY6.mjs} +8 -6
- package/dist/libraries/react/{chunk-3MF54MDU.mjs → chunk-WBBWID5F.mjs} +1 -1
- package/dist/libraries/react/{chunk-TTLL63A4.mjs → chunk-Z7REFVM4.mjs} +3 -3
- package/dist/libraries/react/client/ReactAutumnClient.js +176 -4
- package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
- package/dist/libraries/react/client/types/clientGenTypes.js +172 -2
- package/dist/libraries/react/client/types/clientGenTypes.mjs +1 -1
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.css +3 -0
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +181 -20
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.css +3 -0
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +176 -4
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.css +3 -0
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +181 -20
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +26 -26
- package/dist/libraries/react/components/ui/button.d.mts +2 -2
- package/dist/libraries/react/components/ui/button.d.ts +2 -2
- package/dist/libraries/react/components/ui/dialog.mjs +2 -2
- package/dist/libraries/react/components/ui/popover.mjs +2 -2
- package/dist/libraries/react/hooks/helpers/handleCheck.js +172 -2
- package/dist/libraries/react/hooks/helpers/handleCheck.mjs +2 -2
- package/dist/libraries/react/hooks/helpers/useAutumnBase.js +172 -3
- package/dist/libraries/react/hooks/helpers/useAutumnBase.mjs +3 -3
- package/dist/libraries/react/hooks/useAnalytics.js +176 -4
- package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
- package/dist/libraries/react/hooks/useCustomer.d.mts +60 -2
- package/dist/libraries/react/hooks/useCustomer.d.ts +60 -2
- package/dist/libraries/react/hooks/useCustomer.js +176 -15
- package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
- package/dist/libraries/react/hooks/useCustomerBase.d.mts +44 -3
- package/dist/libraries/react/hooks/useCustomerBase.d.ts +44 -3
- package/dist/libraries/react/hooks/useCustomerBase.js +176 -15
- package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
- package/dist/libraries/react/hooks/useEntity.js +176 -5
- package/dist/libraries/react/hooks/useEntity.mjs +9 -9
- package/dist/libraries/react/hooks/useEntityBase.js +176 -5
- package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
- package/dist/libraries/react/hooks/usePaywall.js +176 -4
- package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
- package/dist/libraries/react/hooks/usePricingTable.js +176 -4
- package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.js +172 -2
- package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
- package/dist/libraries/react/index.d.mts +104 -7
- package/dist/libraries/react/index.d.ts +104 -7
- package/dist/libraries/react/index.js +182 -21
- package/dist/libraries/react/index.mjs +182 -21
- package/dist/next/client/hooks/useCustomer.d.mts +44 -7
- package/dist/next/client/hooks/useCustomer.d.ts +44 -7
- package/dist/next/server/cusActions.d.mts +178 -44
- package/dist/next/server/cusActions.d.ts +178 -44
- package/dist/sdk/index.d.mts +178 -44
- package/dist/sdk/index.d.ts +178 -44
- package/dist/sdk/index.js +171 -1
- package/dist/sdk/index.mjs +171 -1
- package/dist/styles/global.css +3 -0
- package/dist/utils/encryptUtils.js +172 -2
- package/dist/utils/encryptUtils.mjs +172 -2
- package/package.json +1 -1
- package/dist/libraries/react/{chunk-7JNU5ABT.mjs → chunk-FJWZPMWU.mjs} +3 -3
- package/dist/libraries/react/{chunk-LCWL3TIT.mjs → chunk-OTZ65PCT.mjs} +3 -3
|
@@ -491,22 +491,92 @@ var Autumn = class {
|
|
|
491
491
|
entities = entityMethods(this);
|
|
492
492
|
referrals = referralMethods(this);
|
|
493
493
|
features = featureMethods(this);
|
|
494
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Initiates a checkout flow for a product purchase.
|
|
496
|
+
*
|
|
497
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
498
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
499
|
+
* to Stripe based on the customer's state and product requirements.
|
|
500
|
+
*
|
|
501
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
502
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* const result = await autumn.checkout({
|
|
507
|
+
* customer_id: "user_123",
|
|
508
|
+
* product_id: "pro",
|
|
509
|
+
* success_url: "https://myapp.com/success"
|
|
510
|
+
* });
|
|
511
|
+
*
|
|
512
|
+
* if (result.url) {
|
|
513
|
+
* // Redirect to Stripe checkout
|
|
514
|
+
* window.location.href = result.url;
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
495
518
|
async checkout(params) {
|
|
496
519
|
return handleCheckout({
|
|
497
520
|
instance: this,
|
|
498
521
|
params
|
|
499
522
|
});
|
|
500
523
|
}
|
|
501
|
-
static
|
|
524
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
502
525
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
526
|
+
/**
|
|
527
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
528
|
+
*
|
|
529
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
530
|
+
* When you attach a product:
|
|
531
|
+
* - The customer gains access to all features in the product
|
|
532
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
533
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
534
|
+
*
|
|
535
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
536
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```typescript
|
|
540
|
+
* const result = await autumn.attach({
|
|
541
|
+
* customer_id: "user_123",
|
|
542
|
+
* product_id: "pro",
|
|
543
|
+
* success_url: "https://myapp.com/success"
|
|
544
|
+
* });
|
|
545
|
+
*
|
|
546
|
+
* if (result.checkout_url) {
|
|
547
|
+
* // Payment required - redirect to checkout
|
|
548
|
+
* window.location.href = result.checkout_url;
|
|
549
|
+
* } else {
|
|
550
|
+
* // Product successfully attached
|
|
551
|
+
* console.log("Access granted:", result.message);
|
|
552
|
+
* }
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
503
555
|
async attach(params) {
|
|
504
556
|
return handleAttach({
|
|
505
557
|
instance: this,
|
|
506
558
|
params
|
|
507
559
|
});
|
|
508
560
|
}
|
|
561
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
509
562
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
563
|
+
/**
|
|
564
|
+
* Sets up a payment method for a customer.
|
|
565
|
+
*
|
|
566
|
+
* This method allows you to set up payment methods for customers without
|
|
567
|
+
* immediately charging them. Useful for collecting payment information
|
|
568
|
+
* before product attachment or for updating existing payment methods.
|
|
569
|
+
*
|
|
570
|
+
* @param params - Setup payment parameters including customer information
|
|
571
|
+
* @returns Promise resolving to setup payment result
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* ```typescript
|
|
575
|
+
* const result = await autumn.setupPayment({
|
|
576
|
+
* customer_id: "user_123"
|
|
577
|
+
* });
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
510
580
|
async setupPayment(params) {
|
|
511
581
|
return handleSetupPayment({
|
|
512
582
|
instance: this,
|
|
@@ -514,6 +584,24 @@ var Autumn = class {
|
|
|
514
584
|
});
|
|
515
585
|
}
|
|
516
586
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
587
|
+
/**
|
|
588
|
+
* Cancels a customer's subscription or product attachment.
|
|
589
|
+
*
|
|
590
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
591
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
592
|
+
*
|
|
593
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
594
|
+
* @returns Promise resolving to cancellation result
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```typescript
|
|
598
|
+
* const result = await autumn.cancel({
|
|
599
|
+
* customer_id: "user_123",
|
|
600
|
+
* product_id: "pro",
|
|
601
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
602
|
+
* });
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
517
605
|
async cancel(params) {
|
|
518
606
|
return handleCancel({
|
|
519
607
|
instance: this,
|
|
@@ -521,6 +609,29 @@ var Autumn = class {
|
|
|
521
609
|
});
|
|
522
610
|
}
|
|
523
611
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
612
|
+
/**
|
|
613
|
+
* Checks if a customer has access to a specific feature.
|
|
614
|
+
*
|
|
615
|
+
* This method verifies whether a customer has permission to use a feature
|
|
616
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
617
|
+
* features and determine when to show upgrade prompts.
|
|
618
|
+
*
|
|
619
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
620
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```typescript
|
|
624
|
+
* const result = await autumn.check({
|
|
625
|
+
* customer_id: "user_123",
|
|
626
|
+
* feature_id: "messages",
|
|
627
|
+
* required_balance: 1
|
|
628
|
+
* });
|
|
629
|
+
*
|
|
630
|
+
* if (!result.allowed) {
|
|
631
|
+
* console.log("Feature access denied - upgrade required");
|
|
632
|
+
* }
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
524
635
|
async check(params) {
|
|
525
636
|
return handleCheck({
|
|
526
637
|
instance: this,
|
|
@@ -528,12 +639,50 @@ var Autumn = class {
|
|
|
528
639
|
});
|
|
529
640
|
}
|
|
530
641
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
642
|
+
/**
|
|
643
|
+
* Tracks usage events for features or analytics.
|
|
644
|
+
*
|
|
645
|
+
* This method records usage events for metered features, updating the customer's
|
|
646
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
647
|
+
* accurate tracking that cannot be manipulated by users.
|
|
648
|
+
*
|
|
649
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
650
|
+
* @returns Promise resolving to tracking result
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```typescript
|
|
654
|
+
* const result = await autumn.track({
|
|
655
|
+
* customer_id: "user_123",
|
|
656
|
+
* feature_id: "messages",
|
|
657
|
+
* value: 1 // Track 1 message sent
|
|
658
|
+
* });
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
531
661
|
async track(params) {
|
|
532
662
|
return handleTrack({
|
|
533
663
|
instance: this,
|
|
534
664
|
params
|
|
535
665
|
});
|
|
536
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
669
|
+
*
|
|
670
|
+
* This method fetches detailed usage information for a customer's features,
|
|
671
|
+
* including current balances, usage history, and analytics data. Useful
|
|
672
|
+
* for displaying usage dashboards or generating reports.
|
|
673
|
+
*
|
|
674
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
675
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* ```typescript
|
|
679
|
+
* const result = await autumn.usage({
|
|
680
|
+
* customer_id: "user_123",
|
|
681
|
+
* feature_id: "messages"
|
|
682
|
+
* value: 20 // Usage value
|
|
683
|
+
* });
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
537
686
|
async usage(params) {
|
|
538
687
|
return handleUsage({
|
|
539
688
|
instance: this,
|
|
@@ -541,6 +690,25 @@ var Autumn = class {
|
|
|
541
690
|
});
|
|
542
691
|
}
|
|
543
692
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
693
|
+
/**
|
|
694
|
+
* Performs advanced queries on customer data and analytics.
|
|
695
|
+
*
|
|
696
|
+
* This method allows you to run complex queries against customer data,
|
|
697
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
698
|
+
* analytics, and custom data insights.
|
|
699
|
+
*
|
|
700
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
701
|
+
* @returns Promise resolving to query results with requested data
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* const result = await autumn.query({
|
|
706
|
+
* customer_id: "user_123",
|
|
707
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
708
|
+
* });
|
|
709
|
+
*
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
544
712
|
async query(params) {
|
|
545
713
|
return handleQuery({
|
|
546
714
|
instance: this,
|
|
@@ -756,6 +924,8 @@ var CheckoutParamsSchema = import_v47.z.object({
|
|
|
756
924
|
product_id: import_v47.z.string(),
|
|
757
925
|
entity_id: import_v47.z.string().optional(),
|
|
758
926
|
options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
|
|
927
|
+
force_checkout: import_v47.z.boolean().optional(),
|
|
928
|
+
invoice: import_v47.z.boolean().optional(),
|
|
759
929
|
success_url: import_v47.z.string().optional(),
|
|
760
930
|
customer_data: CustomerDataSchema.optional(),
|
|
761
931
|
entity_data: import_v47.z.any().optional(),
|
|
@@ -937,7 +1107,8 @@ var AutumnClient = class {
|
|
|
937
1107
|
await fetch(testEndpoint, {
|
|
938
1108
|
method: "POST",
|
|
939
1109
|
credentials: "include",
|
|
940
|
-
headers: { "Content-Type": "application/json" }
|
|
1110
|
+
headers: { "Content-Type": "application/json" },
|
|
1111
|
+
body: JSON.stringify({})
|
|
941
1112
|
});
|
|
942
1113
|
return { valid: true, includeCredentials: true };
|
|
943
1114
|
} catch (error) {
|
|
@@ -945,7 +1116,8 @@ var AutumnClient = class {
|
|
|
945
1116
|
await fetch(testEndpoint, {
|
|
946
1117
|
method: "POST",
|
|
947
1118
|
credentials: "omit",
|
|
948
|
-
headers: { "Content-Type": "application/json" }
|
|
1119
|
+
headers: { "Content-Type": "application/json" },
|
|
1120
|
+
body: JSON.stringify({})
|
|
949
1121
|
});
|
|
950
1122
|
return { valid: true, includeCredentials: false };
|
|
951
1123
|
} catch (error2) {
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import {
|
|
4
4
|
AutumnContext,
|
|
5
5
|
useAutumnContext
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-SWVRRNIW.mjs";
|
|
7
|
+
import "./chunk-TOAZUTY6.mjs";
|
|
8
|
+
import "./chunk-5O3IHYFF.mjs";
|
|
9
|
+
import "./chunk-JVCOY7ZL.mjs";
|
|
9
10
|
import "./chunk-CIBQ4BJU.mjs";
|
|
10
11
|
import "./chunk-V575SGOW.mjs";
|
|
11
12
|
import "./chunk-ZV4RPZTM.mjs";
|
|
12
|
-
import "./chunk-JVCOY7ZL.mjs";
|
|
13
13
|
import "./chunk-VTGR7VVK.mjs";
|
|
14
14
|
import "./chunk-WFFVOEUG.mjs";
|
|
15
15
|
import "./chunk-ZF2HUCN6.mjs";
|
|
@@ -522,22 +522,92 @@ var Autumn = class {
|
|
|
522
522
|
entities = entityMethods(this);
|
|
523
523
|
referrals = referralMethods(this);
|
|
524
524
|
features = featureMethods(this);
|
|
525
|
-
|
|
525
|
+
/**
|
|
526
|
+
* Initiates a checkout flow for a product purchase.
|
|
527
|
+
*
|
|
528
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
529
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
530
|
+
* to Stripe based on the customer's state and product requirements.
|
|
531
|
+
*
|
|
532
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
533
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```typescript
|
|
537
|
+
* const result = await autumn.checkout({
|
|
538
|
+
* customer_id: "user_123",
|
|
539
|
+
* product_id: "pro",
|
|
540
|
+
* success_url: "https://myapp.com/success"
|
|
541
|
+
* });
|
|
542
|
+
*
|
|
543
|
+
* if (result.url) {
|
|
544
|
+
* // Redirect to Stripe checkout
|
|
545
|
+
* window.location.href = result.url;
|
|
546
|
+
* }
|
|
547
|
+
* ```
|
|
548
|
+
*/
|
|
526
549
|
async checkout(params) {
|
|
527
550
|
return handleCheckout({
|
|
528
551
|
instance: this,
|
|
529
552
|
params
|
|
530
553
|
});
|
|
531
554
|
}
|
|
532
|
-
static
|
|
555
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
533
556
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
557
|
+
/**
|
|
558
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
559
|
+
*
|
|
560
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
561
|
+
* When you attach a product:
|
|
562
|
+
* - The customer gains access to all features in the product
|
|
563
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
564
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
565
|
+
*
|
|
566
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
567
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```typescript
|
|
571
|
+
* const result = await autumn.attach({
|
|
572
|
+
* customer_id: "user_123",
|
|
573
|
+
* product_id: "pro",
|
|
574
|
+
* success_url: "https://myapp.com/success"
|
|
575
|
+
* });
|
|
576
|
+
*
|
|
577
|
+
* if (result.checkout_url) {
|
|
578
|
+
* // Payment required - redirect to checkout
|
|
579
|
+
* window.location.href = result.checkout_url;
|
|
580
|
+
* } else {
|
|
581
|
+
* // Product successfully attached
|
|
582
|
+
* console.log("Access granted:", result.message);
|
|
583
|
+
* }
|
|
584
|
+
* ```
|
|
585
|
+
*/
|
|
534
586
|
async attach(params) {
|
|
535
587
|
return handleAttach({
|
|
536
588
|
instance: this,
|
|
537
589
|
params
|
|
538
590
|
});
|
|
539
591
|
}
|
|
592
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
540
593
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
594
|
+
/**
|
|
595
|
+
* Sets up a payment method for a customer.
|
|
596
|
+
*
|
|
597
|
+
* This method allows you to set up payment methods for customers without
|
|
598
|
+
* immediately charging them. Useful for collecting payment information
|
|
599
|
+
* before product attachment or for updating existing payment methods.
|
|
600
|
+
*
|
|
601
|
+
* @param params - Setup payment parameters including customer information
|
|
602
|
+
* @returns Promise resolving to setup payment result
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* const result = await autumn.setupPayment({
|
|
607
|
+
* customer_id: "user_123"
|
|
608
|
+
* });
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
541
611
|
async setupPayment(params) {
|
|
542
612
|
return handleSetupPayment({
|
|
543
613
|
instance: this,
|
|
@@ -545,6 +615,24 @@ var Autumn = class {
|
|
|
545
615
|
});
|
|
546
616
|
}
|
|
547
617
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
618
|
+
/**
|
|
619
|
+
* Cancels a customer's subscription or product attachment.
|
|
620
|
+
*
|
|
621
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
622
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
623
|
+
*
|
|
624
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
625
|
+
* @returns Promise resolving to cancellation result
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```typescript
|
|
629
|
+
* const result = await autumn.cancel({
|
|
630
|
+
* customer_id: "user_123",
|
|
631
|
+
* product_id: "pro",
|
|
632
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
633
|
+
* });
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
548
636
|
async cancel(params) {
|
|
549
637
|
return handleCancel({
|
|
550
638
|
instance: this,
|
|
@@ -552,6 +640,29 @@ var Autumn = class {
|
|
|
552
640
|
});
|
|
553
641
|
}
|
|
554
642
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
643
|
+
/**
|
|
644
|
+
* Checks if a customer has access to a specific feature.
|
|
645
|
+
*
|
|
646
|
+
* This method verifies whether a customer has permission to use a feature
|
|
647
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
648
|
+
* features and determine when to show upgrade prompts.
|
|
649
|
+
*
|
|
650
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
651
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* ```typescript
|
|
655
|
+
* const result = await autumn.check({
|
|
656
|
+
* customer_id: "user_123",
|
|
657
|
+
* feature_id: "messages",
|
|
658
|
+
* required_balance: 1
|
|
659
|
+
* });
|
|
660
|
+
*
|
|
661
|
+
* if (!result.allowed) {
|
|
662
|
+
* console.log("Feature access denied - upgrade required");
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
555
666
|
async check(params) {
|
|
556
667
|
return handleCheck({
|
|
557
668
|
instance: this,
|
|
@@ -559,12 +670,50 @@ var Autumn = class {
|
|
|
559
670
|
});
|
|
560
671
|
}
|
|
561
672
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
673
|
+
/**
|
|
674
|
+
* Tracks usage events for features or analytics.
|
|
675
|
+
*
|
|
676
|
+
* This method records usage events for metered features, updating the customer's
|
|
677
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
678
|
+
* accurate tracking that cannot be manipulated by users.
|
|
679
|
+
*
|
|
680
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
681
|
+
* @returns Promise resolving to tracking result
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```typescript
|
|
685
|
+
* const result = await autumn.track({
|
|
686
|
+
* customer_id: "user_123",
|
|
687
|
+
* feature_id: "messages",
|
|
688
|
+
* value: 1 // Track 1 message sent
|
|
689
|
+
* });
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
562
692
|
async track(params) {
|
|
563
693
|
return handleTrack({
|
|
564
694
|
instance: this,
|
|
565
695
|
params
|
|
566
696
|
});
|
|
567
697
|
}
|
|
698
|
+
/**
|
|
699
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
700
|
+
*
|
|
701
|
+
* This method fetches detailed usage information for a customer's features,
|
|
702
|
+
* including current balances, usage history, and analytics data. Useful
|
|
703
|
+
* for displaying usage dashboards or generating reports.
|
|
704
|
+
*
|
|
705
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
706
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```typescript
|
|
710
|
+
* const result = await autumn.usage({
|
|
711
|
+
* customer_id: "user_123",
|
|
712
|
+
* feature_id: "messages"
|
|
713
|
+
* value: 20 // Usage value
|
|
714
|
+
* });
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
568
717
|
async usage(params) {
|
|
569
718
|
return handleUsage({
|
|
570
719
|
instance: this,
|
|
@@ -572,6 +721,25 @@ var Autumn = class {
|
|
|
572
721
|
});
|
|
573
722
|
}
|
|
574
723
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
724
|
+
/**
|
|
725
|
+
* Performs advanced queries on customer data and analytics.
|
|
726
|
+
*
|
|
727
|
+
* This method allows you to run complex queries against customer data,
|
|
728
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
729
|
+
* analytics, and custom data insights.
|
|
730
|
+
*
|
|
731
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
732
|
+
* @returns Promise resolving to query results with requested data
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```typescript
|
|
736
|
+
* const result = await autumn.query({
|
|
737
|
+
* customer_id: "user_123",
|
|
738
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
739
|
+
* });
|
|
740
|
+
*
|
|
741
|
+
* ```
|
|
742
|
+
*/
|
|
575
743
|
async query(params) {
|
|
576
744
|
return handleQuery({
|
|
577
745
|
instance: this,
|
|
@@ -787,6 +955,8 @@ var CheckoutParamsSchema = import_v47.z.object({
|
|
|
787
955
|
product_id: import_v47.z.string(),
|
|
788
956
|
entity_id: import_v47.z.string().optional(),
|
|
789
957
|
options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
|
|
958
|
+
force_checkout: import_v47.z.boolean().optional(),
|
|
959
|
+
invoice: import_v47.z.boolean().optional(),
|
|
790
960
|
success_url: import_v47.z.string().optional(),
|
|
791
961
|
customer_data: CustomerDataSchema.optional(),
|
|
792
962
|
entity_data: import_v47.z.any().optional(),
|
|
@@ -968,7 +1138,8 @@ var AutumnClient = class {
|
|
|
968
1138
|
await fetch(testEndpoint, {
|
|
969
1139
|
method: "POST",
|
|
970
1140
|
credentials: "include",
|
|
971
|
-
headers: { "Content-Type": "application/json" }
|
|
1141
|
+
headers: { "Content-Type": "application/json" },
|
|
1142
|
+
body: JSON.stringify({})
|
|
972
1143
|
});
|
|
973
1144
|
return { valid: true, includeCredentials: true };
|
|
974
1145
|
} catch (error) {
|
|
@@ -976,7 +1147,8 @@ var AutumnClient = class {
|
|
|
976
1147
|
await fetch(testEndpoint, {
|
|
977
1148
|
method: "POST",
|
|
978
1149
|
credentials: "omit",
|
|
979
|
-
headers: { "Content-Type": "application/json" }
|
|
1150
|
+
headers: { "Content-Type": "application/json" },
|
|
1151
|
+
body: JSON.stringify({})
|
|
980
1152
|
});
|
|
981
1153
|
return { valid: true, includeCredentials: false };
|
|
982
1154
|
} catch (error2) {
|
|
@@ -1486,7 +1658,6 @@ var useAutumnBase = ({
|
|
|
1486
1658
|
};
|
|
1487
1659
|
return {
|
|
1488
1660
|
attach,
|
|
1489
|
-
// check,
|
|
1490
1661
|
track,
|
|
1491
1662
|
cancel,
|
|
1492
1663
|
openBillingPortal,
|
|
@@ -1706,16 +1877,6 @@ var useCustomerBase = ({
|
|
|
1706
1877
|
context
|
|
1707
1878
|
});
|
|
1708
1879
|
return res;
|
|
1709
|
-
},
|
|
1710
|
-
/** @deprecated Use check() instead */
|
|
1711
|
-
allowed: (params2) => {
|
|
1712
|
-
const result = handleCheck2({
|
|
1713
|
-
customer,
|
|
1714
|
-
params: params2,
|
|
1715
|
-
isEntity: false,
|
|
1716
|
-
context
|
|
1717
|
-
});
|
|
1718
|
-
return result.data.allowed;
|
|
1719
1880
|
}
|
|
1720
1881
|
};
|
|
1721
1882
|
};
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
import {
|
|
5
5
|
BaseAutumnProvider
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7JU3XHKL.mjs";
|
|
7
7
|
import "./chunk-RFSQBGLO.mjs";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-BT5OY2CA.mjs";
|
|
9
|
+
import "./chunk-DKOF357C.mjs";
|
|
10
|
+
import "./chunk-P6CAHZVT.mjs";
|
|
11
|
+
import "./chunk-7HRCOEUW.mjs";
|
|
12
|
+
import "./chunk-SWVRRNIW.mjs";
|
|
13
|
+
import "./chunk-TOAZUTY6.mjs";
|
|
14
|
+
import "./chunk-5O3IHYFF.mjs";
|
|
15
|
+
import "./chunk-JVCOY7ZL.mjs";
|
|
15
16
|
import "./chunk-CIBQ4BJU.mjs";
|
|
16
17
|
import "./chunk-V575SGOW.mjs";
|
|
17
18
|
import "./chunk-ZV4RPZTM.mjs";
|
|
18
|
-
import "./chunk-JVCOY7ZL.mjs";
|
|
19
19
|
import "./chunk-VTGR7VVK.mjs";
|
|
20
20
|
import "./chunk-WFFVOEUG.mjs";
|
|
21
21
|
import "./chunk-ZF2HUCN6.mjs";
|