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
|
@@ -474,22 +474,92 @@ var Autumn = class {
|
|
|
474
474
|
entities = entityMethods(this);
|
|
475
475
|
referrals = referralMethods(this);
|
|
476
476
|
features = featureMethods(this);
|
|
477
|
-
|
|
477
|
+
/**
|
|
478
|
+
* Initiates a checkout flow for a product purchase.
|
|
479
|
+
*
|
|
480
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
481
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
482
|
+
* to Stripe based on the customer's state and product requirements.
|
|
483
|
+
*
|
|
484
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
485
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* const result = await autumn.checkout({
|
|
490
|
+
* customer_id: "user_123",
|
|
491
|
+
* product_id: "pro",
|
|
492
|
+
* success_url: "https://myapp.com/success"
|
|
493
|
+
* });
|
|
494
|
+
*
|
|
495
|
+
* if (result.url) {
|
|
496
|
+
* // Redirect to Stripe checkout
|
|
497
|
+
* window.location.href = result.url;
|
|
498
|
+
* }
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
478
501
|
async checkout(params) {
|
|
479
502
|
return handleCheckout({
|
|
480
503
|
instance: this,
|
|
481
504
|
params
|
|
482
505
|
});
|
|
483
506
|
}
|
|
484
|
-
static
|
|
507
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
485
508
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
509
|
+
/**
|
|
510
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
511
|
+
*
|
|
512
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
513
|
+
* When you attach a product:
|
|
514
|
+
* - The customer gains access to all features in the product
|
|
515
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
516
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
517
|
+
*
|
|
518
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
519
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* const result = await autumn.attach({
|
|
524
|
+
* customer_id: "user_123",
|
|
525
|
+
* product_id: "pro",
|
|
526
|
+
* success_url: "https://myapp.com/success"
|
|
527
|
+
* });
|
|
528
|
+
*
|
|
529
|
+
* if (result.checkout_url) {
|
|
530
|
+
* // Payment required - redirect to checkout
|
|
531
|
+
* window.location.href = result.checkout_url;
|
|
532
|
+
* } else {
|
|
533
|
+
* // Product successfully attached
|
|
534
|
+
* console.log("Access granted:", result.message);
|
|
535
|
+
* }
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
486
538
|
async attach(params) {
|
|
487
539
|
return handleAttach({
|
|
488
540
|
instance: this,
|
|
489
541
|
params
|
|
490
542
|
});
|
|
491
543
|
}
|
|
544
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
492
545
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
546
|
+
/**
|
|
547
|
+
* Sets up a payment method for a customer.
|
|
548
|
+
*
|
|
549
|
+
* This method allows you to set up payment methods for customers without
|
|
550
|
+
* immediately charging them. Useful for collecting payment information
|
|
551
|
+
* before product attachment or for updating existing payment methods.
|
|
552
|
+
*
|
|
553
|
+
* @param params - Setup payment parameters including customer information
|
|
554
|
+
* @returns Promise resolving to setup payment result
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* const result = await autumn.setupPayment({
|
|
559
|
+
* customer_id: "user_123"
|
|
560
|
+
* });
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
493
563
|
async setupPayment(params) {
|
|
494
564
|
return handleSetupPayment({
|
|
495
565
|
instance: this,
|
|
@@ -497,6 +567,24 @@ var Autumn = class {
|
|
|
497
567
|
});
|
|
498
568
|
}
|
|
499
569
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
570
|
+
/**
|
|
571
|
+
* Cancels a customer's subscription or product attachment.
|
|
572
|
+
*
|
|
573
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
574
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
575
|
+
*
|
|
576
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
577
|
+
* @returns Promise resolving to cancellation result
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```typescript
|
|
581
|
+
* const result = await autumn.cancel({
|
|
582
|
+
* customer_id: "user_123",
|
|
583
|
+
* product_id: "pro",
|
|
584
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
585
|
+
* });
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
500
588
|
async cancel(params) {
|
|
501
589
|
return handleCancel({
|
|
502
590
|
instance: this,
|
|
@@ -504,6 +592,29 @@ var Autumn = class {
|
|
|
504
592
|
});
|
|
505
593
|
}
|
|
506
594
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
595
|
+
/**
|
|
596
|
+
* Checks if a customer has access to a specific feature.
|
|
597
|
+
*
|
|
598
|
+
* This method verifies whether a customer has permission to use a feature
|
|
599
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
600
|
+
* features and determine when to show upgrade prompts.
|
|
601
|
+
*
|
|
602
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
603
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```typescript
|
|
607
|
+
* const result = await autumn.check({
|
|
608
|
+
* customer_id: "user_123",
|
|
609
|
+
* feature_id: "messages",
|
|
610
|
+
* required_balance: 1
|
|
611
|
+
* });
|
|
612
|
+
*
|
|
613
|
+
* if (!result.allowed) {
|
|
614
|
+
* console.log("Feature access denied - upgrade required");
|
|
615
|
+
* }
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
507
618
|
async check(params) {
|
|
508
619
|
return handleCheck({
|
|
509
620
|
instance: this,
|
|
@@ -511,12 +622,50 @@ var Autumn = class {
|
|
|
511
622
|
});
|
|
512
623
|
}
|
|
513
624
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
625
|
+
/**
|
|
626
|
+
* Tracks usage events for features or analytics.
|
|
627
|
+
*
|
|
628
|
+
* This method records usage events for metered features, updating the customer's
|
|
629
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
630
|
+
* accurate tracking that cannot be manipulated by users.
|
|
631
|
+
*
|
|
632
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
633
|
+
* @returns Promise resolving to tracking result
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```typescript
|
|
637
|
+
* const result = await autumn.track({
|
|
638
|
+
* customer_id: "user_123",
|
|
639
|
+
* feature_id: "messages",
|
|
640
|
+
* value: 1 // Track 1 message sent
|
|
641
|
+
* });
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
514
644
|
async track(params) {
|
|
515
645
|
return handleTrack({
|
|
516
646
|
instance: this,
|
|
517
647
|
params
|
|
518
648
|
});
|
|
519
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
652
|
+
*
|
|
653
|
+
* This method fetches detailed usage information for a customer's features,
|
|
654
|
+
* including current balances, usage history, and analytics data. Useful
|
|
655
|
+
* for displaying usage dashboards or generating reports.
|
|
656
|
+
*
|
|
657
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
658
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* const result = await autumn.usage({
|
|
663
|
+
* customer_id: "user_123",
|
|
664
|
+
* feature_id: "messages"
|
|
665
|
+
* value: 20 // Usage value
|
|
666
|
+
* });
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
520
669
|
async usage(params) {
|
|
521
670
|
return handleUsage({
|
|
522
671
|
instance: this,
|
|
@@ -524,6 +673,25 @@ var Autumn = class {
|
|
|
524
673
|
});
|
|
525
674
|
}
|
|
526
675
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
676
|
+
/**
|
|
677
|
+
* Performs advanced queries on customer data and analytics.
|
|
678
|
+
*
|
|
679
|
+
* This method allows you to run complex queries against customer data,
|
|
680
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
681
|
+
* analytics, and custom data insights.
|
|
682
|
+
*
|
|
683
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
684
|
+
* @returns Promise resolving to query results with requested data
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* const result = await autumn.query({
|
|
689
|
+
* customer_id: "user_123",
|
|
690
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
691
|
+
* });
|
|
692
|
+
*
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
527
695
|
async query(params) {
|
|
528
696
|
return handleQuery({
|
|
529
697
|
instance: this,
|
|
@@ -763,6 +931,8 @@ var CheckoutParamsSchema = import_v47.z.object({
|
|
|
763
931
|
product_id: import_v47.z.string(),
|
|
764
932
|
entity_id: import_v47.z.string().optional(),
|
|
765
933
|
options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
|
|
934
|
+
force_checkout: import_v47.z.boolean().optional(),
|
|
935
|
+
invoice: import_v47.z.boolean().optional(),
|
|
766
936
|
success_url: import_v47.z.string().optional(),
|
|
767
937
|
customer_data: CustomerDataSchema.optional(),
|
|
768
938
|
entity_data: import_v47.z.any().optional(),
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "./chunk-UNZHJTEY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
createRouterWithOptions
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-NWPFUFXX.mjs";
|
|
7
|
+
import "./chunk-56RGUNOT.mjs";
|
|
8
|
+
import "./chunk-SDL7BFTH.mjs";
|
|
9
|
+
import "./chunk-2DWGCQCF.mjs";
|
|
10
|
+
import "./chunk-6JI6MF4S.mjs";
|
|
11
|
+
import "./chunk-FA5Z2MOT.mjs";
|
|
12
12
|
import {
|
|
13
13
|
Autumn
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Q7SD535L.mjs";
|
|
15
15
|
import "./chunk-2TEL6LR5.mjs";
|
|
16
16
|
import {
|
|
17
17
|
autumnApiUrl
|
|
@@ -474,22 +474,92 @@ var Autumn = class {
|
|
|
474
474
|
entities = entityMethods(this);
|
|
475
475
|
referrals = referralMethods(this);
|
|
476
476
|
features = featureMethods(this);
|
|
477
|
-
|
|
477
|
+
/**
|
|
478
|
+
* Initiates a checkout flow for a product purchase.
|
|
479
|
+
*
|
|
480
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
481
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
482
|
+
* to Stripe based on the customer's state and product requirements.
|
|
483
|
+
*
|
|
484
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
485
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* const result = await autumn.checkout({
|
|
490
|
+
* customer_id: "user_123",
|
|
491
|
+
* product_id: "pro",
|
|
492
|
+
* success_url: "https://myapp.com/success"
|
|
493
|
+
* });
|
|
494
|
+
*
|
|
495
|
+
* if (result.url) {
|
|
496
|
+
* // Redirect to Stripe checkout
|
|
497
|
+
* window.location.href = result.url;
|
|
498
|
+
* }
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
478
501
|
async checkout(params) {
|
|
479
502
|
return handleCheckout({
|
|
480
503
|
instance: this,
|
|
481
504
|
params
|
|
482
505
|
});
|
|
483
506
|
}
|
|
484
|
-
static
|
|
507
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
485
508
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
509
|
+
/**
|
|
510
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
511
|
+
*
|
|
512
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
513
|
+
* When you attach a product:
|
|
514
|
+
* - The customer gains access to all features in the product
|
|
515
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
516
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
517
|
+
*
|
|
518
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
519
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* const result = await autumn.attach({
|
|
524
|
+
* customer_id: "user_123",
|
|
525
|
+
* product_id: "pro",
|
|
526
|
+
* success_url: "https://myapp.com/success"
|
|
527
|
+
* });
|
|
528
|
+
*
|
|
529
|
+
* if (result.checkout_url) {
|
|
530
|
+
* // Payment required - redirect to checkout
|
|
531
|
+
* window.location.href = result.checkout_url;
|
|
532
|
+
* } else {
|
|
533
|
+
* // Product successfully attached
|
|
534
|
+
* console.log("Access granted:", result.message);
|
|
535
|
+
* }
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
486
538
|
async attach(params) {
|
|
487
539
|
return handleAttach({
|
|
488
540
|
instance: this,
|
|
489
541
|
params
|
|
490
542
|
});
|
|
491
543
|
}
|
|
544
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
492
545
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
546
|
+
/**
|
|
547
|
+
* Sets up a payment method for a customer.
|
|
548
|
+
*
|
|
549
|
+
* This method allows you to set up payment methods for customers without
|
|
550
|
+
* immediately charging them. Useful for collecting payment information
|
|
551
|
+
* before product attachment or for updating existing payment methods.
|
|
552
|
+
*
|
|
553
|
+
* @param params - Setup payment parameters including customer information
|
|
554
|
+
* @returns Promise resolving to setup payment result
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* const result = await autumn.setupPayment({
|
|
559
|
+
* customer_id: "user_123"
|
|
560
|
+
* });
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
493
563
|
async setupPayment(params) {
|
|
494
564
|
return handleSetupPayment({
|
|
495
565
|
instance: this,
|
|
@@ -497,6 +567,24 @@ var Autumn = class {
|
|
|
497
567
|
});
|
|
498
568
|
}
|
|
499
569
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
570
|
+
/**
|
|
571
|
+
* Cancels a customer's subscription or product attachment.
|
|
572
|
+
*
|
|
573
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
574
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
575
|
+
*
|
|
576
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
577
|
+
* @returns Promise resolving to cancellation result
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```typescript
|
|
581
|
+
* const result = await autumn.cancel({
|
|
582
|
+
* customer_id: "user_123",
|
|
583
|
+
* product_id: "pro",
|
|
584
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
585
|
+
* });
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
500
588
|
async cancel(params) {
|
|
501
589
|
return handleCancel({
|
|
502
590
|
instance: this,
|
|
@@ -504,6 +592,29 @@ var Autumn = class {
|
|
|
504
592
|
});
|
|
505
593
|
}
|
|
506
594
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
595
|
+
/**
|
|
596
|
+
* Checks if a customer has access to a specific feature.
|
|
597
|
+
*
|
|
598
|
+
* This method verifies whether a customer has permission to use a feature
|
|
599
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
600
|
+
* features and determine when to show upgrade prompts.
|
|
601
|
+
*
|
|
602
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
603
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```typescript
|
|
607
|
+
* const result = await autumn.check({
|
|
608
|
+
* customer_id: "user_123",
|
|
609
|
+
* feature_id: "messages",
|
|
610
|
+
* required_balance: 1
|
|
611
|
+
* });
|
|
612
|
+
*
|
|
613
|
+
* if (!result.allowed) {
|
|
614
|
+
* console.log("Feature access denied - upgrade required");
|
|
615
|
+
* }
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
507
618
|
async check(params) {
|
|
508
619
|
return handleCheck({
|
|
509
620
|
instance: this,
|
|
@@ -511,12 +622,50 @@ var Autumn = class {
|
|
|
511
622
|
});
|
|
512
623
|
}
|
|
513
624
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
625
|
+
/**
|
|
626
|
+
* Tracks usage events for features or analytics.
|
|
627
|
+
*
|
|
628
|
+
* This method records usage events for metered features, updating the customer's
|
|
629
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
630
|
+
* accurate tracking that cannot be manipulated by users.
|
|
631
|
+
*
|
|
632
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
633
|
+
* @returns Promise resolving to tracking result
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```typescript
|
|
637
|
+
* const result = await autumn.track({
|
|
638
|
+
* customer_id: "user_123",
|
|
639
|
+
* feature_id: "messages",
|
|
640
|
+
* value: 1 // Track 1 message sent
|
|
641
|
+
* });
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
514
644
|
async track(params) {
|
|
515
645
|
return handleTrack({
|
|
516
646
|
instance: this,
|
|
517
647
|
params
|
|
518
648
|
});
|
|
519
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
652
|
+
*
|
|
653
|
+
* This method fetches detailed usage information for a customer's features,
|
|
654
|
+
* including current balances, usage history, and analytics data. Useful
|
|
655
|
+
* for displaying usage dashboards or generating reports.
|
|
656
|
+
*
|
|
657
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
658
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* const result = await autumn.usage({
|
|
663
|
+
* customer_id: "user_123",
|
|
664
|
+
* feature_id: "messages"
|
|
665
|
+
* value: 20 // Usage value
|
|
666
|
+
* });
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
520
669
|
async usage(params) {
|
|
521
670
|
return handleUsage({
|
|
522
671
|
instance: this,
|
|
@@ -524,6 +673,25 @@ var Autumn = class {
|
|
|
524
673
|
});
|
|
525
674
|
}
|
|
526
675
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
676
|
+
/**
|
|
677
|
+
* Performs advanced queries on customer data and analytics.
|
|
678
|
+
*
|
|
679
|
+
* This method allows you to run complex queries against customer data,
|
|
680
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
681
|
+
* analytics, and custom data insights.
|
|
682
|
+
*
|
|
683
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
684
|
+
* @returns Promise resolving to query results with requested data
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* const result = await autumn.query({
|
|
689
|
+
* customer_id: "user_123",
|
|
690
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
691
|
+
* });
|
|
692
|
+
*
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
527
695
|
async query(params) {
|
|
528
696
|
return handleQuery({
|
|
529
697
|
instance: this,
|
|
@@ -763,6 +931,8 @@ var CheckoutParamsSchema = import_v47.z.object({
|
|
|
763
931
|
product_id: import_v47.z.string(),
|
|
764
932
|
entity_id: import_v47.z.string().optional(),
|
|
765
933
|
options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
|
|
934
|
+
force_checkout: import_v47.z.boolean().optional(),
|
|
935
|
+
invoice: import_v47.z.boolean().optional(),
|
|
766
936
|
success_url: import_v47.z.string().optional(),
|
|
767
937
|
customer_data: CustomerDataSchema.optional(),
|
|
768
938
|
entity_data: import_v47.z.any().optional(),
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "./chunk-UNZHJTEY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
createRouterWithOptions
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-NWPFUFXX.mjs";
|
|
7
|
+
import "./chunk-56RGUNOT.mjs";
|
|
8
|
+
import "./chunk-SDL7BFTH.mjs";
|
|
9
|
+
import "./chunk-2DWGCQCF.mjs";
|
|
10
|
+
import "./chunk-6JI6MF4S.mjs";
|
|
11
|
+
import "./chunk-FA5Z2MOT.mjs";
|
|
12
12
|
import {
|
|
13
13
|
Autumn
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Q7SD535L.mjs";
|
|
15
15
|
import "./chunk-2TEL6LR5.mjs";
|
|
16
16
|
import {
|
|
17
17
|
autumnApiUrl
|