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
|
@@ -98,6 +98,7 @@ declare const autumn: (options?: {
|
|
|
98
98
|
quantity: number;
|
|
99
99
|
}[] | undefined;
|
|
100
100
|
success_url?: string | undefined;
|
|
101
|
+
force_checkout?: boolean | undefined;
|
|
101
102
|
customer_data?: {
|
|
102
103
|
name?: string | null | undefined;
|
|
103
104
|
email?: string | null | undefined;
|
|
@@ -106,6 +107,7 @@ declare const autumn: (options?: {
|
|
|
106
107
|
entity_data?: any;
|
|
107
108
|
checkout_session_params?: Record<string, any> | undefined;
|
|
108
109
|
reward?: string | undefined;
|
|
110
|
+
invoice?: boolean | undefined;
|
|
109
111
|
};
|
|
110
112
|
} & {
|
|
111
113
|
method?: "POST" | undefined;
|
|
@@ -139,6 +141,7 @@ declare const autumn: (options?: {
|
|
|
139
141
|
quantity: z.ZodNumber;
|
|
140
142
|
}, z.core.$strip>>>;
|
|
141
143
|
success_url: z.ZodOptional<z.ZodString>;
|
|
144
|
+
force_checkout: z.ZodOptional<z.ZodBoolean>;
|
|
142
145
|
customer_data: z.ZodOptional<z.ZodObject<{
|
|
143
146
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
144
147
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -147,6 +150,7 @@ declare const autumn: (options?: {
|
|
|
147
150
|
entity_data: z.ZodOptional<z.ZodAny>;
|
|
148
151
|
checkout_session_params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
149
152
|
reward: z.ZodOptional<z.ZodString>;
|
|
153
|
+
invoice: z.ZodOptional<z.ZodBoolean>;
|
|
150
154
|
}, z.core.$strip>;
|
|
151
155
|
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
152
156
|
session: {
|
|
@@ -98,6 +98,7 @@ declare const autumn: (options?: {
|
|
|
98
98
|
quantity: number;
|
|
99
99
|
}[] | undefined;
|
|
100
100
|
success_url?: string | undefined;
|
|
101
|
+
force_checkout?: boolean | undefined;
|
|
101
102
|
customer_data?: {
|
|
102
103
|
name?: string | null | undefined;
|
|
103
104
|
email?: string | null | undefined;
|
|
@@ -106,6 +107,7 @@ declare const autumn: (options?: {
|
|
|
106
107
|
entity_data?: any;
|
|
107
108
|
checkout_session_params?: Record<string, any> | undefined;
|
|
108
109
|
reward?: string | undefined;
|
|
110
|
+
invoice?: boolean | undefined;
|
|
109
111
|
};
|
|
110
112
|
} & {
|
|
111
113
|
method?: "POST" | undefined;
|
|
@@ -139,6 +141,7 @@ declare const autumn: (options?: {
|
|
|
139
141
|
quantity: z.ZodNumber;
|
|
140
142
|
}, z.core.$strip>>>;
|
|
141
143
|
success_url: z.ZodOptional<z.ZodString>;
|
|
144
|
+
force_checkout: z.ZodOptional<z.ZodBoolean>;
|
|
142
145
|
customer_data: z.ZodOptional<z.ZodObject<{
|
|
143
146
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
144
147
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -147,6 +150,7 @@ declare const autumn: (options?: {
|
|
|
147
150
|
entity_data: z.ZodOptional<z.ZodAny>;
|
|
148
151
|
checkout_session_params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
149
152
|
reward: z.ZodOptional<z.ZodString>;
|
|
153
|
+
invoice: z.ZodOptional<z.ZodBoolean>;
|
|
150
154
|
}, z.core.$strip>;
|
|
151
155
|
use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
152
156
|
session: {
|
|
@@ -476,22 +476,92 @@ var Autumn = class {
|
|
|
476
476
|
entities = entityMethods(this);
|
|
477
477
|
referrals = referralMethods(this);
|
|
478
478
|
features = featureMethods(this);
|
|
479
|
-
|
|
479
|
+
/**
|
|
480
|
+
* Initiates a checkout flow for a product purchase.
|
|
481
|
+
*
|
|
482
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
483
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
484
|
+
* to Stripe based on the customer's state and product requirements.
|
|
485
|
+
*
|
|
486
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
487
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* const result = await autumn.checkout({
|
|
492
|
+
* customer_id: "user_123",
|
|
493
|
+
* product_id: "pro",
|
|
494
|
+
* success_url: "https://myapp.com/success"
|
|
495
|
+
* });
|
|
496
|
+
*
|
|
497
|
+
* if (result.url) {
|
|
498
|
+
* // Redirect to Stripe checkout
|
|
499
|
+
* window.location.href = result.url;
|
|
500
|
+
* }
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
480
503
|
async checkout(params) {
|
|
481
504
|
return handleCheckout({
|
|
482
505
|
instance: this,
|
|
483
506
|
params
|
|
484
507
|
});
|
|
485
508
|
}
|
|
486
|
-
static
|
|
509
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
487
510
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
511
|
+
/**
|
|
512
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
513
|
+
*
|
|
514
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
515
|
+
* When you attach a product:
|
|
516
|
+
* - The customer gains access to all features in the product
|
|
517
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
518
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
519
|
+
*
|
|
520
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
521
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* const result = await autumn.attach({
|
|
526
|
+
* customer_id: "user_123",
|
|
527
|
+
* product_id: "pro",
|
|
528
|
+
* success_url: "https://myapp.com/success"
|
|
529
|
+
* });
|
|
530
|
+
*
|
|
531
|
+
* if (result.checkout_url) {
|
|
532
|
+
* // Payment required - redirect to checkout
|
|
533
|
+
* window.location.href = result.checkout_url;
|
|
534
|
+
* } else {
|
|
535
|
+
* // Product successfully attached
|
|
536
|
+
* console.log("Access granted:", result.message);
|
|
537
|
+
* }
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
488
540
|
async attach(params) {
|
|
489
541
|
return handleAttach({
|
|
490
542
|
instance: this,
|
|
491
543
|
params
|
|
492
544
|
});
|
|
493
545
|
}
|
|
546
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
494
547
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
548
|
+
/**
|
|
549
|
+
* Sets up a payment method for a customer.
|
|
550
|
+
*
|
|
551
|
+
* This method allows you to set up payment methods for customers without
|
|
552
|
+
* immediately charging them. Useful for collecting payment information
|
|
553
|
+
* before product attachment or for updating existing payment methods.
|
|
554
|
+
*
|
|
555
|
+
* @param params - Setup payment parameters including customer information
|
|
556
|
+
* @returns Promise resolving to setup payment result
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```typescript
|
|
560
|
+
* const result = await autumn.setupPayment({
|
|
561
|
+
* customer_id: "user_123"
|
|
562
|
+
* });
|
|
563
|
+
* ```
|
|
564
|
+
*/
|
|
495
565
|
async setupPayment(params) {
|
|
496
566
|
return handleSetupPayment({
|
|
497
567
|
instance: this,
|
|
@@ -499,6 +569,24 @@ var Autumn = class {
|
|
|
499
569
|
});
|
|
500
570
|
}
|
|
501
571
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
572
|
+
/**
|
|
573
|
+
* Cancels a customer's subscription or product attachment.
|
|
574
|
+
*
|
|
575
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
576
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
577
|
+
*
|
|
578
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
579
|
+
* @returns Promise resolving to cancellation result
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```typescript
|
|
583
|
+
* const result = await autumn.cancel({
|
|
584
|
+
* customer_id: "user_123",
|
|
585
|
+
* product_id: "pro",
|
|
586
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
587
|
+
* });
|
|
588
|
+
* ```
|
|
589
|
+
*/
|
|
502
590
|
async cancel(params) {
|
|
503
591
|
return handleCancel({
|
|
504
592
|
instance: this,
|
|
@@ -506,6 +594,29 @@ var Autumn = class {
|
|
|
506
594
|
});
|
|
507
595
|
}
|
|
508
596
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
597
|
+
/**
|
|
598
|
+
* Checks if a customer has access to a specific feature.
|
|
599
|
+
*
|
|
600
|
+
* This method verifies whether a customer has permission to use a feature
|
|
601
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
602
|
+
* features and determine when to show upgrade prompts.
|
|
603
|
+
*
|
|
604
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
605
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```typescript
|
|
609
|
+
* const result = await autumn.check({
|
|
610
|
+
* customer_id: "user_123",
|
|
611
|
+
* feature_id: "messages",
|
|
612
|
+
* required_balance: 1
|
|
613
|
+
* });
|
|
614
|
+
*
|
|
615
|
+
* if (!result.allowed) {
|
|
616
|
+
* console.log("Feature access denied - upgrade required");
|
|
617
|
+
* }
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
509
620
|
async check(params) {
|
|
510
621
|
return handleCheck({
|
|
511
622
|
instance: this,
|
|
@@ -513,12 +624,50 @@ var Autumn = class {
|
|
|
513
624
|
});
|
|
514
625
|
}
|
|
515
626
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
627
|
+
/**
|
|
628
|
+
* Tracks usage events for features or analytics.
|
|
629
|
+
*
|
|
630
|
+
* This method records usage events for metered features, updating the customer's
|
|
631
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
632
|
+
* accurate tracking that cannot be manipulated by users.
|
|
633
|
+
*
|
|
634
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
635
|
+
* @returns Promise resolving to tracking result
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```typescript
|
|
639
|
+
* const result = await autumn.track({
|
|
640
|
+
* customer_id: "user_123",
|
|
641
|
+
* feature_id: "messages",
|
|
642
|
+
* value: 1 // Track 1 message sent
|
|
643
|
+
* });
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
516
646
|
async track(params) {
|
|
517
647
|
return handleTrack({
|
|
518
648
|
instance: this,
|
|
519
649
|
params
|
|
520
650
|
});
|
|
521
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
654
|
+
*
|
|
655
|
+
* This method fetches detailed usage information for a customer's features,
|
|
656
|
+
* including current balances, usage history, and analytics data. Useful
|
|
657
|
+
* for displaying usage dashboards or generating reports.
|
|
658
|
+
*
|
|
659
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
660
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```typescript
|
|
664
|
+
* const result = await autumn.usage({
|
|
665
|
+
* customer_id: "user_123",
|
|
666
|
+
* feature_id: "messages"
|
|
667
|
+
* value: 20 // Usage value
|
|
668
|
+
* });
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
522
671
|
async usage(params) {
|
|
523
672
|
return handleUsage({
|
|
524
673
|
instance: this,
|
|
@@ -526,6 +675,25 @@ var Autumn = class {
|
|
|
526
675
|
});
|
|
527
676
|
}
|
|
528
677
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
678
|
+
/**
|
|
679
|
+
* Performs advanced queries on customer data and analytics.
|
|
680
|
+
*
|
|
681
|
+
* This method allows you to run complex queries against customer data,
|
|
682
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
683
|
+
* analytics, and custom data insights.
|
|
684
|
+
*
|
|
685
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
686
|
+
* @returns Promise resolving to query results with requested data
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```typescript
|
|
690
|
+
* const result = await autumn.query({
|
|
691
|
+
* customer_id: "user_123",
|
|
692
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
693
|
+
* });
|
|
694
|
+
*
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
529
697
|
async query(params) {
|
|
530
698
|
return handleQuery({
|
|
531
699
|
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(),
|
|
@@ -3,12 +3,12 @@ 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
|
AttachParamsSchema,
|
|
14
14
|
Autumn,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
CustomerExpandEnum,
|
|
21
21
|
RedeemReferralCodeParamsSchema,
|
|
22
22
|
TrackParamsSchema
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-Q7SD535L.mjs";
|
|
24
24
|
import "./chunk-2TEL6LR5.mjs";
|
|
25
25
|
import "./chunk-KSG3E4Q2.mjs";
|
|
26
26
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addGenRoutes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-56RGUNOT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
addProductRoutes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SDL7BFTH.mjs";
|
|
7
7
|
import {
|
|
8
8
|
addReferralRoutes
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2DWGCQCF.mjs";
|
|
10
10
|
import {
|
|
11
11
|
addEntityRoutes
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6JI6MF4S.mjs";
|
|
13
13
|
import {
|
|
14
14
|
withAuth
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-FA5Z2MOT.mjs";
|
|
16
16
|
import {
|
|
17
17
|
fetchPricingTable
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-Q7SD535L.mjs";
|
|
19
19
|
import {
|
|
20
20
|
BASE_PATH
|
|
21
21
|
} from "./chunk-KSG3E4Q2.mjs";
|
|
@@ -413,22 +413,92 @@ var Autumn = class {
|
|
|
413
413
|
entities = entityMethods(this);
|
|
414
414
|
referrals = referralMethods(this);
|
|
415
415
|
features = featureMethods(this);
|
|
416
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Initiates a checkout flow for a product purchase.
|
|
418
|
+
*
|
|
419
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
420
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
421
|
+
* to Stripe based on the customer's state and product requirements.
|
|
422
|
+
*
|
|
423
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
424
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const result = await autumn.checkout({
|
|
429
|
+
* customer_id: "user_123",
|
|
430
|
+
* product_id: "pro",
|
|
431
|
+
* success_url: "https://myapp.com/success"
|
|
432
|
+
* });
|
|
433
|
+
*
|
|
434
|
+
* if (result.url) {
|
|
435
|
+
* // Redirect to Stripe checkout
|
|
436
|
+
* window.location.href = result.url;
|
|
437
|
+
* }
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
417
440
|
async checkout(params) {
|
|
418
441
|
return handleCheckout({
|
|
419
442
|
instance: this,
|
|
420
443
|
params
|
|
421
444
|
});
|
|
422
445
|
}
|
|
423
|
-
static
|
|
446
|
+
static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
|
|
424
447
|
static usage = (params) => staticWrapper(handleUsage, void 0, { params });
|
|
448
|
+
/**
|
|
449
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
450
|
+
*
|
|
451
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
452
|
+
* When you attach a product:
|
|
453
|
+
* - The customer gains access to all features in the product
|
|
454
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
455
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
456
|
+
*
|
|
457
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
458
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```typescript
|
|
462
|
+
* const result = await autumn.attach({
|
|
463
|
+
* customer_id: "user_123",
|
|
464
|
+
* product_id: "pro",
|
|
465
|
+
* success_url: "https://myapp.com/success"
|
|
466
|
+
* });
|
|
467
|
+
*
|
|
468
|
+
* if (result.checkout_url) {
|
|
469
|
+
* // Payment required - redirect to checkout
|
|
470
|
+
* window.location.href = result.checkout_url;
|
|
471
|
+
* } else {
|
|
472
|
+
* // Product successfully attached
|
|
473
|
+
* console.log("Access granted:", result.message);
|
|
474
|
+
* }
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
425
477
|
async attach(params) {
|
|
426
478
|
return handleAttach({
|
|
427
479
|
instance: this,
|
|
428
480
|
params
|
|
429
481
|
});
|
|
430
482
|
}
|
|
483
|
+
static attach = (params) => staticWrapper(handleAttach, void 0, { params });
|
|
431
484
|
static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
|
|
485
|
+
/**
|
|
486
|
+
* Sets up a payment method for a customer.
|
|
487
|
+
*
|
|
488
|
+
* This method allows you to set up payment methods for customers without
|
|
489
|
+
* immediately charging them. Useful for collecting payment information
|
|
490
|
+
* before product attachment or for updating existing payment methods.
|
|
491
|
+
*
|
|
492
|
+
* @param params - Setup payment parameters including customer information
|
|
493
|
+
* @returns Promise resolving to setup payment result
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```typescript
|
|
497
|
+
* const result = await autumn.setupPayment({
|
|
498
|
+
* customer_id: "user_123"
|
|
499
|
+
* });
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
432
502
|
async setupPayment(params) {
|
|
433
503
|
return handleSetupPayment({
|
|
434
504
|
instance: this,
|
|
@@ -436,6 +506,24 @@ var Autumn = class {
|
|
|
436
506
|
});
|
|
437
507
|
}
|
|
438
508
|
static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
|
|
509
|
+
/**
|
|
510
|
+
* Cancels a customer's subscription or product attachment.
|
|
511
|
+
*
|
|
512
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
513
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
514
|
+
*
|
|
515
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
516
|
+
* @returns Promise resolving to cancellation result
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```typescript
|
|
520
|
+
* const result = await autumn.cancel({
|
|
521
|
+
* customer_id: "user_123",
|
|
522
|
+
* product_id: "pro",
|
|
523
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
524
|
+
* });
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
439
527
|
async cancel(params) {
|
|
440
528
|
return handleCancel({
|
|
441
529
|
instance: this,
|
|
@@ -443,6 +531,29 @@ var Autumn = class {
|
|
|
443
531
|
});
|
|
444
532
|
}
|
|
445
533
|
static check = (params) => staticWrapper(handleCheck, void 0, { params });
|
|
534
|
+
/**
|
|
535
|
+
* Checks if a customer has access to a specific feature.
|
|
536
|
+
*
|
|
537
|
+
* This method verifies whether a customer has permission to use a feature
|
|
538
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
539
|
+
* features and determine when to show upgrade prompts.
|
|
540
|
+
*
|
|
541
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
542
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* const result = await autumn.check({
|
|
547
|
+
* customer_id: "user_123",
|
|
548
|
+
* feature_id: "messages",
|
|
549
|
+
* required_balance: 1
|
|
550
|
+
* });
|
|
551
|
+
*
|
|
552
|
+
* if (!result.allowed) {
|
|
553
|
+
* console.log("Feature access denied - upgrade required");
|
|
554
|
+
* }
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
446
557
|
async check(params) {
|
|
447
558
|
return handleCheck({
|
|
448
559
|
instance: this,
|
|
@@ -450,12 +561,50 @@ var Autumn = class {
|
|
|
450
561
|
});
|
|
451
562
|
}
|
|
452
563
|
static track = (params) => staticWrapper(handleTrack, void 0, { params });
|
|
564
|
+
/**
|
|
565
|
+
* Tracks usage events for features or analytics.
|
|
566
|
+
*
|
|
567
|
+
* This method records usage events for metered features, updating the customer's
|
|
568
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
569
|
+
* accurate tracking that cannot be manipulated by users.
|
|
570
|
+
*
|
|
571
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
572
|
+
* @returns Promise resolving to tracking result
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* const result = await autumn.track({
|
|
577
|
+
* customer_id: "user_123",
|
|
578
|
+
* feature_id: "messages",
|
|
579
|
+
* value: 1 // Track 1 message sent
|
|
580
|
+
* });
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
453
583
|
async track(params) {
|
|
454
584
|
return handleTrack({
|
|
455
585
|
instance: this,
|
|
456
586
|
params
|
|
457
587
|
});
|
|
458
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
591
|
+
*
|
|
592
|
+
* This method fetches detailed usage information for a customer's features,
|
|
593
|
+
* including current balances, usage history, and analytics data. Useful
|
|
594
|
+
* for displaying usage dashboards or generating reports.
|
|
595
|
+
*
|
|
596
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
597
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```typescript
|
|
601
|
+
* const result = await autumn.usage({
|
|
602
|
+
* customer_id: "user_123",
|
|
603
|
+
* feature_id: "messages"
|
|
604
|
+
* value: 20 // Usage value
|
|
605
|
+
* });
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
459
608
|
async usage(params) {
|
|
460
609
|
return handleUsage({
|
|
461
610
|
instance: this,
|
|
@@ -463,6 +612,25 @@ var Autumn = class {
|
|
|
463
612
|
});
|
|
464
613
|
}
|
|
465
614
|
static query = (params) => staticWrapper(handleQuery, void 0, { params });
|
|
615
|
+
/**
|
|
616
|
+
* Performs advanced queries on customer data and analytics.
|
|
617
|
+
*
|
|
618
|
+
* This method allows you to run complex queries against customer data,
|
|
619
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
620
|
+
* analytics, and custom data insights.
|
|
621
|
+
*
|
|
622
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
623
|
+
* @returns Promise resolving to query results with requested data
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```typescript
|
|
627
|
+
* const result = await autumn.query({
|
|
628
|
+
* customer_id: "user_123",
|
|
629
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
630
|
+
* });
|
|
631
|
+
*
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
466
634
|
async query(params) {
|
|
467
635
|
return handleQuery({
|
|
468
636
|
instance: this,
|
|
@@ -702,6 +870,8 @@ var CheckoutParamsSchema = z7.object({
|
|
|
702
870
|
product_id: z7.string(),
|
|
703
871
|
entity_id: z7.string().optional(),
|
|
704
872
|
options: z7.array(AttachFeatureOptionsSchema).optional(),
|
|
873
|
+
force_checkout: z7.boolean().optional(),
|
|
874
|
+
invoice: z7.boolean().optional(),
|
|
705
875
|
success_url: z7.string().optional(),
|
|
706
876
|
customer_data: CustomerDataSchema.optional(),
|
|
707
877
|
entity_data: z7.any().optional(),
|