autumn-js 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/backend/better-auth.d.mts +30 -26
- package/dist/libraries/backend/better-auth.d.ts +30 -26
- package/dist/libraries/backend/better-auth.js +172 -2
- package/dist/libraries/backend/better-auth.mjs +7 -7
- package/dist/libraries/backend/{chunk-EW2R7722.mjs → chunk-2DWGCQCF.mjs} +1 -1
- package/dist/libraries/backend/{chunk-VNJ3MFJE.mjs → chunk-56RGUNOT.mjs} +1 -1
- package/dist/libraries/backend/{chunk-P3ARLB2M.mjs → chunk-6JI6MF4S.mjs} +1 -1
- package/dist/libraries/backend/{chunk-5DDCZMDB.mjs → chunk-FA5Z2MOT.mjs} +1 -1
- package/dist/libraries/backend/{chunk-RAHKKJED.mjs → chunk-NWPFUFXX.mjs} +6 -6
- package/dist/libraries/backend/{chunk-NAP2URIW.mjs → chunk-Q7SD535L.mjs} +172 -2
- package/dist/libraries/backend/{chunk-7K3RATTK.mjs → chunk-SDL7BFTH.mjs} +1 -1
- package/dist/libraries/backend/convex.js +172 -2
- package/dist/libraries/backend/convex.mjs +7 -7
- package/dist/libraries/backend/elysia.js +172 -2
- package/dist/libraries/backend/elysia.mjs +7 -7
- package/dist/libraries/backend/express.d.mts +1 -1
- package/dist/libraries/backend/express.d.ts +1 -1
- package/dist/libraries/backend/express.js +172 -2
- package/dist/libraries/backend/express.mjs +7 -7
- package/dist/libraries/backend/fastify.js +172 -2
- package/dist/libraries/backend/fastify.mjs +7 -7
- package/dist/libraries/backend/hono.js +172 -2
- package/dist/libraries/backend/hono.mjs +7 -7
- package/dist/libraries/backend/index.d.mts +1 -1
- package/dist/libraries/backend/index.d.ts +1 -1
- package/dist/libraries/backend/index.js +172 -2
- package/dist/libraries/backend/index.mjs +7 -7
- package/dist/libraries/backend/next.js +172 -2
- package/dist/libraries/backend/next.mjs +7 -7
- package/dist/libraries/backend/react-router.js +172 -2
- package/dist/libraries/backend/react-router.mjs +7 -7
- package/dist/libraries/backend/{referralTypes-C1eZ8cjO.d.mts → referralTypes-BOsjdpOb.d.mts} +176 -6
- package/dist/libraries/backend/{referralTypes-FlI0fYwz.d.ts → referralTypes-DcfU8B6R.d.ts} +176 -6
- package/dist/libraries/backend/remix_dep.js +172 -2
- package/dist/libraries/backend/remix_dep.mjs +7 -7
- package/dist/libraries/backend/routes/backendRouter.js +172 -2
- package/dist/libraries/backend/routes/backendRouter.mjs +7 -7
- package/dist/libraries/backend/routes/entityRoutes.js +172 -2
- package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/genRoutes.js +172 -2
- package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/productRoutes.js +172 -2
- package/dist/libraries/backend/routes/productRoutes.mjs +3 -3
- package/dist/libraries/backend/routes/referralRoutes.js +172 -2
- package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
- package/dist/libraries/backend/supabase.js +172 -2
- package/dist/libraries/backend/supabase.mjs +7 -7
- package/dist/libraries/backend/tanstack.js +172 -2
- package/dist/libraries/backend/tanstack.mjs +7 -7
- package/dist/libraries/backend/utils/backendRes.js +172 -2
- package/dist/libraries/backend/utils/backendRes.mjs +1 -1
- package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
- package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
- package/dist/libraries/backend/utils/withAuth.js +172 -2
- package/dist/libraries/backend/utils/withAuth.mjs +2 -2
- package/dist/libraries/react/AutumnContext.d.mts +6 -6
- package/dist/libraries/react/AutumnContext.d.ts +6 -6
- package/dist/libraries/react/AutumnContext.js +172 -2
- package/dist/libraries/react/AutumnContext.mjs +4 -4
- package/dist/libraries/react/BaseAutumnProvider.d.mts +6 -6
- package/dist/libraries/react/BaseAutumnProvider.d.ts +6 -6
- package/dist/libraries/react/BaseAutumnProvider.js +172 -13
- package/dist/libraries/react/BaseAutumnProvider.mjs +9 -9
- package/dist/libraries/react/{ReactAutumnClient-CfDtucnL.d.ts → ReactAutumnClient-CIAkiqwV.d.ts} +5 -5
- package/dist/libraries/react/{ReactAutumnClient-IFdMWiu5.d.mts → ReactAutumnClient-zBxnpPLM.d.mts} +5 -5
- package/dist/libraries/react/ReactAutumnProvider.d.mts +2 -2
- package/dist/libraries/react/ReactAutumnProvider.d.ts +2 -2
- package/dist/libraries/react/ReactAutumnProvider.js +172 -13
- package/dist/libraries/react/ReactAutumnProvider.mjs +10 -10
- package/dist/libraries/react/{attachTypes-CLK4jfuj.d.ts → attachTypes-BQaZHr5e.d.ts} +1 -1
- package/dist/libraries/react/{attachTypes-C5gcbNrS.d.mts → attachTypes-Cuxn1ThG.d.mts} +1 -1
- package/dist/libraries/react/{chunk-4NZ7ML7V.mjs → chunk-26K62U62.mjs} +2 -2
- package/dist/libraries/react/{chunk-WYQMHQUE.mjs → chunk-5O3IHYFF.mjs} +172 -2
- package/dist/libraries/react/{chunk-3MF54MDU.mjs → chunk-5RTUQSYZ.mjs} +1 -1
- package/dist/libraries/react/{chunk-XK3AXQED.mjs → chunk-6X76WFOV.mjs} +3 -13
- package/dist/libraries/react/{chunk-JHFJKAXG.mjs → chunk-7A2PZDUO.mjs} +25 -25
- package/dist/libraries/react/{chunk-YHT2JUXO.mjs → chunk-7HRCOEUW.mjs} +1 -1
- package/dist/libraries/react/{chunk-KP2Q65Y3.mjs → chunk-CMUWZZWV.mjs} +2 -2
- package/dist/libraries/react/{chunk-KMYL54B4.mjs → chunk-DKOF357C.mjs} +1 -1
- package/dist/libraries/react/{chunk-67RWFVWN.mjs → chunk-HNIU2WNT.mjs} +2 -2
- package/dist/libraries/react/{chunk-U3OQJXCW.mjs → chunk-JTYEHM27.mjs} +4 -4
- package/dist/libraries/react/{chunk-6D6TYTTO.mjs → chunk-P6CAHZVT.mjs} +1 -2
- package/dist/libraries/react/{chunk-TTLL63A4.mjs → chunk-QNMB7QR6.mjs} +3 -3
- package/dist/libraries/react/{chunk-2ENHPIYQ.mjs → chunk-RK4NRHHQ.mjs} +3 -3
- package/dist/libraries/react/{chunk-VZY225C6.mjs → chunk-ROKCGZ77.mjs} +2 -2
- package/dist/libraries/react/{chunk-FDNQ6GRK.mjs → chunk-TE2MOBO7.mjs} +1 -1
- package/dist/libraries/react/{chunk-OMJJLT2Q.mjs → chunk-VGNA76RG.mjs} +1 -1
- package/dist/libraries/react/client/ReactAutumnClient.d.mts +6 -6
- package/dist/libraries/react/client/ReactAutumnClient.d.ts +6 -6
- package/dist/libraries/react/client/ReactAutumnClient.js +172 -2
- package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
- package/dist/libraries/react/client/clientCompMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientCompMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientCusMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientCusMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientEntityMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientEntityMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientGenMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientGenMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientProdMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientProdMethods.d.ts +6 -6
- package/dist/libraries/react/client/clientReferralMethods.d.mts +6 -6
- package/dist/libraries/react/client/clientReferralMethods.d.ts +6 -6
- package/dist/libraries/react/client/types/clientGenTypes.js +172 -2
- package/dist/libraries/react/client/types/clientGenTypes.mjs +1 -1
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.mts +2 -2
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.ts +2 -2
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +172 -13
- package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.mts +2 -2
- package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.ts +2 -2
- package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.mts +1 -1
- package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.ts +1 -1
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +172 -2
- package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +26 -26
- package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.mts +1 -1
- package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.ts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +172 -13
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +26 -26
- package/dist/libraries/react/components/ui/button.d.mts +2 -2
- package/dist/libraries/react/components/ui/button.d.ts +2 -2
- package/dist/libraries/react/components/ui/dialog.mjs +2 -2
- package/dist/libraries/react/components/ui/popover.mjs +2 -2
- package/dist/libraries/react/{cusTypes-CBapqjzm.d.mts → cusTypes-B2m4-oz4.d.mts} +1 -1
- package/dist/libraries/react/{cusTypes-D13MXEN7.d.ts → cusTypes-lMnznWYJ.d.ts} +1 -1
- package/dist/libraries/react/{entTypes-C1bM1Zpv.d.mts → entTypes-D-gn1jj2.d.mts} +1 -1
- package/dist/libraries/react/{entTypes-DbIrfEpl.d.ts → entTypes-WMQRyYAv.d.ts} +1 -1
- package/dist/libraries/react/{genTypes-C_ilxndU.d.mts → genTypes-DdYlVEah.d.mts} +1 -1
- package/dist/libraries/react/{genTypes-DjcQWIOM.d.ts → genTypes-aPPwPimh.d.ts} +1 -1
- package/dist/libraries/react/hooks/helpers/handleCheck.d.mts +6 -6
- package/dist/libraries/react/hooks/helpers/handleCheck.d.ts +6 -6
- package/dist/libraries/react/hooks/helpers/handleCheck.js +172 -2
- package/dist/libraries/react/hooks/helpers/handleCheck.mjs +2 -2
- package/dist/libraries/react/hooks/helpers/useAutumnBase.d.mts +6 -6
- package/dist/libraries/react/hooks/helpers/useAutumnBase.d.ts +6 -6
- package/dist/libraries/react/hooks/helpers/useAutumnBase.js +172 -3
- package/dist/libraries/react/hooks/helpers/useAutumnBase.mjs +3 -3
- package/dist/libraries/react/hooks/useAnalytics.d.mts +2 -2
- package/dist/libraries/react/hooks/useAnalytics.d.ts +2 -2
- package/dist/libraries/react/hooks/useAnalytics.js +172 -2
- package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
- package/dist/libraries/react/hooks/useCustomer.d.mts +66 -8
- package/dist/libraries/react/hooks/useCustomer.d.ts +66 -8
- package/dist/libraries/react/hooks/useCustomer.js +172 -13
- package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
- package/dist/libraries/react/hooks/useCustomerBase.d.mts +50 -9
- package/dist/libraries/react/hooks/useCustomerBase.d.ts +50 -9
- package/dist/libraries/react/hooks/useCustomerBase.js +172 -13
- package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
- package/dist/libraries/react/hooks/useEntity.d.mts +4 -4
- package/dist/libraries/react/hooks/useEntity.d.ts +4 -4
- package/dist/libraries/react/hooks/useEntity.js +172 -3
- package/dist/libraries/react/hooks/useEntity.mjs +9 -9
- package/dist/libraries/react/hooks/useEntityBase.d.mts +6 -6
- package/dist/libraries/react/hooks/useEntityBase.d.ts +6 -6
- package/dist/libraries/react/hooks/useEntityBase.js +172 -3
- package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
- package/dist/libraries/react/hooks/usePaywall.d.mts +1 -1
- package/dist/libraries/react/hooks/usePaywall.d.ts +1 -1
- package/dist/libraries/react/hooks/usePaywall.js +172 -2
- package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
- package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
- package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
- package/dist/libraries/react/hooks/usePricingTable.js +172 -2
- package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.d.mts +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.d.ts +6 -6
- package/dist/libraries/react/hooks/usePricingTableBase.js +172 -2
- package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
- package/dist/libraries/react/hooks/useProductsBase.d.mts +6 -6
- package/dist/libraries/react/hooks/useProductsBase.d.ts +6 -6
- package/dist/libraries/react/index.d.mts +104 -7
- package/dist/libraries/react/index.d.ts +104 -7
- package/dist/libraries/react/index.js +172 -13
- package/dist/libraries/react/index.mjs +172 -13
- package/dist/libraries/react/{prodTypes-B8NdKyKo.d.ts → prodTypes-C8xRoBP7.d.mts} +1 -1
- package/dist/libraries/react/{prodTypes-B8NdKyKo.d.mts → prodTypes-C8xRoBP7.d.ts} +1 -1
- package/dist/next/client/hooks/useCustomer.d.mts +44 -7
- package/dist/next/client/hooks/useCustomer.d.ts +44 -7
- package/dist/next/server/cusActions.d.mts +176 -6
- package/dist/next/server/cusActions.d.ts +176 -6
- package/dist/sdk/index.d.mts +174 -4
- package/dist/sdk/index.d.ts +174 -4
- package/dist/sdk/index.js +171 -1
- package/dist/sdk/index.mjs +171 -1
- package/dist/utils/encryptUtils.js +172 -2
- package/dist/utils/encryptUtils.mjs +172 -2
- package/package.json +1 -1
- package/dist/libraries/react/{chunk-7JNU5ABT.mjs → chunk-FJWZPMWU.mjs} +3 -3
- package/dist/libraries/react/{chunk-LCWL3TIT.mjs → chunk-OTZ65PCT.mjs} +3 -3
|
@@ -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
|
package/dist/libraries/backend/{referralTypes-C1eZ8cjO.d.mts → referralTypes-BOsjdpOb.d.mts}
RENAMED
|
@@ -414,6 +414,8 @@ declare const CheckoutParamsSchema: z.ZodObject<{
|
|
|
414
414
|
feature_id: z.ZodString;
|
|
415
415
|
quantity: z.ZodNumber;
|
|
416
416
|
}, z.core.$strip>>>;
|
|
417
|
+
force_checkout: z.ZodOptional<z.ZodBoolean>;
|
|
418
|
+
invoice: z.ZodOptional<z.ZodBoolean>;
|
|
417
419
|
success_url: z.ZodOptional<z.ZodString>;
|
|
418
420
|
customer_data: z.ZodOptional<z.ZodObject<{
|
|
419
421
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -478,11 +480,11 @@ declare const FeatureSchema: z$1.ZodObject<{
|
|
|
478
480
|
}, "strip", z$1.ZodTypeAny, {
|
|
479
481
|
id: string;
|
|
480
482
|
type: FeatureType;
|
|
483
|
+
name?: string | null | undefined;
|
|
481
484
|
credit_schema?: {
|
|
482
485
|
metered_feature_id: string;
|
|
483
486
|
credit_cost: number;
|
|
484
487
|
}[] | null | undefined;
|
|
485
|
-
name?: string | null | undefined;
|
|
486
488
|
display?: {
|
|
487
489
|
singular: string;
|
|
488
490
|
plural: string;
|
|
@@ -490,11 +492,11 @@ declare const FeatureSchema: z$1.ZodObject<{
|
|
|
490
492
|
}, {
|
|
491
493
|
id: string;
|
|
492
494
|
type: FeatureType;
|
|
495
|
+
name?: string | null | undefined;
|
|
493
496
|
credit_schema?: {
|
|
494
497
|
metered_feature_id: string;
|
|
495
498
|
credit_cost: number;
|
|
496
499
|
}[] | null | undefined;
|
|
497
|
-
name?: string | null | undefined;
|
|
498
500
|
display?: {
|
|
499
501
|
singular: string;
|
|
500
502
|
plural: string;
|
|
@@ -579,9 +581,63 @@ declare class Autumn {
|
|
|
579
581
|
list: Feature[];
|
|
580
582
|
}, AutumnError>>;
|
|
581
583
|
};
|
|
582
|
-
|
|
584
|
+
/**
|
|
585
|
+
* Initiates a checkout flow for a product purchase.
|
|
586
|
+
*
|
|
587
|
+
* The checkout function handles the purchase process for products with pricing.
|
|
588
|
+
* It determines whether to show a dialog for user input or redirect directly
|
|
589
|
+
* to Stripe based on the customer's state and product requirements.
|
|
590
|
+
*
|
|
591
|
+
* @param params - Checkout parameters including product ID, customer data, and options
|
|
592
|
+
* @returns Promise resolving to checkout details including pricing, prorations, and URLs
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* const result = await autumn.checkout({
|
|
597
|
+
* customer_id: "user_123",
|
|
598
|
+
* product_id: "pro",
|
|
599
|
+
* success_url: "https://myapp.com/success"
|
|
600
|
+
* });
|
|
601
|
+
*
|
|
602
|
+
* if (result.url) {
|
|
603
|
+
* // Redirect to Stripe checkout
|
|
604
|
+
* window.location.href = result.url;
|
|
605
|
+
* }
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
583
608
|
checkout(params: CheckoutParams): Promise<Result<CheckoutResult, AutumnError>>;
|
|
584
|
-
static
|
|
609
|
+
static checkout: (params: CheckoutParams) => Promise<Result<CheckoutResult, AutumnError>>;
|
|
610
|
+
static usage: (params: UsageParams) => Promise<Result<UsageResult, AutumnError>>;
|
|
611
|
+
/**
|
|
612
|
+
* Attaches a product to a customer, enabling access and handling billing.
|
|
613
|
+
*
|
|
614
|
+
* The attach function activates a product for a customer and applies all product items.
|
|
615
|
+
* When you attach a product:
|
|
616
|
+
* - The customer gains access to all features in the product
|
|
617
|
+
* - If the product has prices, the customer will be billed accordingly
|
|
618
|
+
* - If there's no existing payment method, a checkout URL will be generated
|
|
619
|
+
*
|
|
620
|
+
* @param params - Attach parameters including customer ID, product ID, and options
|
|
621
|
+
* @returns Promise resolving to attachment result with checkout URL if needed
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```typescript
|
|
625
|
+
* const result = await autumn.attach({
|
|
626
|
+
* customer_id: "user_123",
|
|
627
|
+
* product_id: "pro",
|
|
628
|
+
* success_url: "https://myapp.com/success"
|
|
629
|
+
* });
|
|
630
|
+
*
|
|
631
|
+
* if (result.checkout_url) {
|
|
632
|
+
* // Payment required - redirect to checkout
|
|
633
|
+
* window.location.href = result.checkout_url;
|
|
634
|
+
* } else {
|
|
635
|
+
* // Product successfully attached
|
|
636
|
+
* console.log("Access granted:", result.message);
|
|
637
|
+
* }
|
|
638
|
+
* ```
|
|
639
|
+
*/
|
|
640
|
+
attach(params: AttachParams): Promise<Result<{
|
|
585
641
|
customer_id: string;
|
|
586
642
|
product_ids: string[];
|
|
587
643
|
code: string;
|
|
@@ -596,8 +652,7 @@ declare class Autumn {
|
|
|
596
652
|
currency: string;
|
|
597
653
|
} | undefined;
|
|
598
654
|
}, AutumnError>>;
|
|
599
|
-
static
|
|
600
|
-
attach(params: AttachParams): Promise<Result<{
|
|
655
|
+
static attach: (params: AttachParams) => Promise<Result<{
|
|
601
656
|
customer_id: string;
|
|
602
657
|
product_ids: string[];
|
|
603
658
|
code: string;
|
|
@@ -613,18 +668,76 @@ declare class Autumn {
|
|
|
613
668
|
} | undefined;
|
|
614
669
|
}, AutumnError>>;
|
|
615
670
|
static setupPayment: (params: SetupPaymentParams) => Promise<Result<SetupPaymentResult, AutumnError>>;
|
|
671
|
+
/**
|
|
672
|
+
* Sets up a payment method for a customer.
|
|
673
|
+
*
|
|
674
|
+
* This method allows you to set up payment methods for customers without
|
|
675
|
+
* immediately charging them. Useful for collecting payment information
|
|
676
|
+
* before product attachment or for updating existing payment methods.
|
|
677
|
+
*
|
|
678
|
+
* @param params - Setup payment parameters including customer information
|
|
679
|
+
* @returns Promise resolving to setup payment result
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* ```typescript
|
|
683
|
+
* const result = await autumn.setupPayment({
|
|
684
|
+
* customer_id: "user_123"
|
|
685
|
+
* });
|
|
686
|
+
* ```
|
|
687
|
+
*/
|
|
616
688
|
setupPayment(params: SetupPaymentParams): Promise<Result<SetupPaymentResult, AutumnError>>;
|
|
617
689
|
static cancel: (params: CancelParams) => Promise<Result<{
|
|
618
690
|
success: boolean;
|
|
619
691
|
customer_id: string;
|
|
620
692
|
product_id: string;
|
|
621
693
|
}, AutumnError>>;
|
|
694
|
+
/**
|
|
695
|
+
* Cancels a customer's subscription or product attachment.
|
|
696
|
+
*
|
|
697
|
+
* This method allows you to cancel a customer's subscription to a specific product.
|
|
698
|
+
* You can choose to cancel immediately or at the end of the billing cycle.
|
|
699
|
+
*
|
|
700
|
+
* @param params - Cancel parameters including customer ID and product ID
|
|
701
|
+
* @returns Promise resolving to cancellation result
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* const result = await autumn.cancel({
|
|
706
|
+
* customer_id: "user_123",
|
|
707
|
+
* product_id: "pro",
|
|
708
|
+
* cancel_immediately: false // Cancel at end of billing cycle
|
|
709
|
+
* });
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
622
712
|
cancel(params: CancelParams): Promise<Result<{
|
|
623
713
|
success: boolean;
|
|
624
714
|
customer_id: string;
|
|
625
715
|
product_id: string;
|
|
626
716
|
}, AutumnError>>;
|
|
627
717
|
static check: (params: CheckParams) => Promise<Result<CheckResult, AutumnError>>;
|
|
718
|
+
/**
|
|
719
|
+
* Checks if a customer has access to a specific feature.
|
|
720
|
+
*
|
|
721
|
+
* This method verifies whether a customer has permission to use a feature
|
|
722
|
+
* and checks their remaining balance/usage limits. It can be used to gate
|
|
723
|
+
* features and determine when to show upgrade prompts.
|
|
724
|
+
*
|
|
725
|
+
* @param params - Check parameters including customer ID and feature ID
|
|
726
|
+
* @returns Promise resolving to access check result with allowed status and balance info
|
|
727
|
+
*
|
|
728
|
+
* @example
|
|
729
|
+
* ```typescript
|
|
730
|
+
* const result = await autumn.check({
|
|
731
|
+
* customer_id: "user_123",
|
|
732
|
+
* feature_id: "messages",
|
|
733
|
+
* required_balance: 1
|
|
734
|
+
* });
|
|
735
|
+
*
|
|
736
|
+
* if (!result.allowed) {
|
|
737
|
+
* console.log("Feature access denied - upgrade required");
|
|
738
|
+
* }
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
628
741
|
check(params: CheckParams): Promise<Result<CheckResult, AutumnError>>;
|
|
629
742
|
static track: (params: TrackParams) => Promise<Result<{
|
|
630
743
|
id: string;
|
|
@@ -633,6 +746,25 @@ declare class Autumn {
|
|
|
633
746
|
feature_id?: string | undefined;
|
|
634
747
|
event_name?: string | undefined;
|
|
635
748
|
}, AutumnError>>;
|
|
749
|
+
/**
|
|
750
|
+
* Tracks usage events for features or analytics.
|
|
751
|
+
*
|
|
752
|
+
* This method records usage events for metered features, updating the customer's
|
|
753
|
+
* balance and usage statistics. It's typically used server-side to ensure
|
|
754
|
+
* accurate tracking that cannot be manipulated by users.
|
|
755
|
+
*
|
|
756
|
+
* @param params - Track parameters including customer ID, feature ID, and usage value
|
|
757
|
+
* @returns Promise resolving to tracking result
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const result = await autumn.track({
|
|
762
|
+
* customer_id: "user_123",
|
|
763
|
+
* feature_id: "messages",
|
|
764
|
+
* value: 1 // Track 1 message sent
|
|
765
|
+
* });
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
636
768
|
track(params: TrackParams): Promise<Result<{
|
|
637
769
|
id: string;
|
|
638
770
|
code: string;
|
|
@@ -640,8 +772,46 @@ declare class Autumn {
|
|
|
640
772
|
feature_id?: string | undefined;
|
|
641
773
|
event_name?: string | undefined;
|
|
642
774
|
}, AutumnError>>;
|
|
775
|
+
/**
|
|
776
|
+
* Retrieves usage statistics and analytics for a customer.
|
|
777
|
+
*
|
|
778
|
+
* This method fetches detailed usage information for a customer's features,
|
|
779
|
+
* including current balances, usage history, and analytics data. Useful
|
|
780
|
+
* for displaying usage dashboards or generating reports.
|
|
781
|
+
*
|
|
782
|
+
* @param params - Usage parameters including customer ID and optional filters
|
|
783
|
+
* @returns Promise resolving to usage statistics and analytics data
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```typescript
|
|
787
|
+
* const result = await autumn.usage({
|
|
788
|
+
* customer_id: "user_123",
|
|
789
|
+
* feature_id: "messages"
|
|
790
|
+
* value: 20 // Usage value
|
|
791
|
+
* });
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
643
794
|
usage(params: UsageParams): Promise<Result<UsageResult, AutumnError>>;
|
|
644
795
|
static query: (params: QueryParams) => Promise<Result<QueryResult, AutumnError>>;
|
|
796
|
+
/**
|
|
797
|
+
* Performs advanced queries on customer data and analytics.
|
|
798
|
+
*
|
|
799
|
+
* This method allows you to run complex queries against customer data,
|
|
800
|
+
* usage patterns, and billing information. Useful for generating reports,
|
|
801
|
+
* analytics, and custom data insights.
|
|
802
|
+
*
|
|
803
|
+
* @param params - Query parameters including customer ID and query specifications
|
|
804
|
+
* @returns Promise resolving to query results with requested data
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* ```typescript
|
|
808
|
+
* const result = await autumn.query({
|
|
809
|
+
* customer_id: "user_123",
|
|
810
|
+
* feature_id: "messages" // feature id to fetch for query, can also be an array
|
|
811
|
+
* });
|
|
812
|
+
*
|
|
813
|
+
* ```
|
|
814
|
+
*/
|
|
645
815
|
query(params: QueryParams): Promise<Result<QueryResult, AutumnError>>;
|
|
646
816
|
}
|
|
647
817
|
|