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.
Files changed (192) hide show
  1. package/dist/libraries/backend/better-auth.d.mts +30 -26
  2. package/dist/libraries/backend/better-auth.d.ts +30 -26
  3. package/dist/libraries/backend/better-auth.js +172 -2
  4. package/dist/libraries/backend/better-auth.mjs +7 -7
  5. package/dist/libraries/backend/{chunk-EW2R7722.mjs → chunk-2DWGCQCF.mjs} +1 -1
  6. package/dist/libraries/backend/{chunk-VNJ3MFJE.mjs → chunk-56RGUNOT.mjs} +1 -1
  7. package/dist/libraries/backend/{chunk-P3ARLB2M.mjs → chunk-6JI6MF4S.mjs} +1 -1
  8. package/dist/libraries/backend/{chunk-5DDCZMDB.mjs → chunk-FA5Z2MOT.mjs} +1 -1
  9. package/dist/libraries/backend/{chunk-RAHKKJED.mjs → chunk-NWPFUFXX.mjs} +6 -6
  10. package/dist/libraries/backend/{chunk-NAP2URIW.mjs → chunk-Q7SD535L.mjs} +172 -2
  11. package/dist/libraries/backend/{chunk-7K3RATTK.mjs → chunk-SDL7BFTH.mjs} +1 -1
  12. package/dist/libraries/backend/convex.js +172 -2
  13. package/dist/libraries/backend/convex.mjs +7 -7
  14. package/dist/libraries/backend/elysia.js +172 -2
  15. package/dist/libraries/backend/elysia.mjs +7 -7
  16. package/dist/libraries/backend/express.d.mts +1 -1
  17. package/dist/libraries/backend/express.d.ts +1 -1
  18. package/dist/libraries/backend/express.js +172 -2
  19. package/dist/libraries/backend/express.mjs +7 -7
  20. package/dist/libraries/backend/fastify.js +172 -2
  21. package/dist/libraries/backend/fastify.mjs +7 -7
  22. package/dist/libraries/backend/hono.js +172 -2
  23. package/dist/libraries/backend/hono.mjs +7 -7
  24. package/dist/libraries/backend/index.d.mts +1 -1
  25. package/dist/libraries/backend/index.d.ts +1 -1
  26. package/dist/libraries/backend/index.js +172 -2
  27. package/dist/libraries/backend/index.mjs +7 -7
  28. package/dist/libraries/backend/next.js +172 -2
  29. package/dist/libraries/backend/next.mjs +7 -7
  30. package/dist/libraries/backend/react-router.js +172 -2
  31. package/dist/libraries/backend/react-router.mjs +7 -7
  32. package/dist/libraries/backend/{referralTypes-C1eZ8cjO.d.mts → referralTypes-BOsjdpOb.d.mts} +176 -6
  33. package/dist/libraries/backend/{referralTypes-FlI0fYwz.d.ts → referralTypes-DcfU8B6R.d.ts} +176 -6
  34. package/dist/libraries/backend/remix_dep.js +172 -2
  35. package/dist/libraries/backend/remix_dep.mjs +7 -7
  36. package/dist/libraries/backend/routes/backendRouter.js +172 -2
  37. package/dist/libraries/backend/routes/backendRouter.mjs +7 -7
  38. package/dist/libraries/backend/routes/entityRoutes.js +172 -2
  39. package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
  40. package/dist/libraries/backend/routes/genRoutes.js +172 -2
  41. package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
  42. package/dist/libraries/backend/routes/productRoutes.js +172 -2
  43. package/dist/libraries/backend/routes/productRoutes.mjs +3 -3
  44. package/dist/libraries/backend/routes/referralRoutes.js +172 -2
  45. package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
  46. package/dist/libraries/backend/supabase.js +172 -2
  47. package/dist/libraries/backend/supabase.mjs +7 -7
  48. package/dist/libraries/backend/tanstack.js +172 -2
  49. package/dist/libraries/backend/tanstack.mjs +7 -7
  50. package/dist/libraries/backend/utils/backendRes.js +172 -2
  51. package/dist/libraries/backend/utils/backendRes.mjs +1 -1
  52. package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
  53. package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
  54. package/dist/libraries/backend/utils/withAuth.js +172 -2
  55. package/dist/libraries/backend/utils/withAuth.mjs +2 -2
  56. package/dist/libraries/react/AutumnContext.d.mts +6 -6
  57. package/dist/libraries/react/AutumnContext.d.ts +6 -6
  58. package/dist/libraries/react/AutumnContext.js +172 -2
  59. package/dist/libraries/react/AutumnContext.mjs +4 -4
  60. package/dist/libraries/react/BaseAutumnProvider.d.mts +6 -6
  61. package/dist/libraries/react/BaseAutumnProvider.d.ts +6 -6
  62. package/dist/libraries/react/BaseAutumnProvider.js +172 -13
  63. package/dist/libraries/react/BaseAutumnProvider.mjs +9 -9
  64. package/dist/libraries/react/{ReactAutumnClient-CfDtucnL.d.ts → ReactAutumnClient-CIAkiqwV.d.ts} +5 -5
  65. package/dist/libraries/react/{ReactAutumnClient-IFdMWiu5.d.mts → ReactAutumnClient-zBxnpPLM.d.mts} +5 -5
  66. package/dist/libraries/react/ReactAutumnProvider.d.mts +2 -2
  67. package/dist/libraries/react/ReactAutumnProvider.d.ts +2 -2
  68. package/dist/libraries/react/ReactAutumnProvider.js +172 -13
  69. package/dist/libraries/react/ReactAutumnProvider.mjs +10 -10
  70. package/dist/libraries/react/{attachTypes-CLK4jfuj.d.ts → attachTypes-BQaZHr5e.d.ts} +1 -1
  71. package/dist/libraries/react/{attachTypes-C5gcbNrS.d.mts → attachTypes-Cuxn1ThG.d.mts} +1 -1
  72. package/dist/libraries/react/{chunk-4NZ7ML7V.mjs → chunk-26K62U62.mjs} +2 -2
  73. package/dist/libraries/react/{chunk-WYQMHQUE.mjs → chunk-5O3IHYFF.mjs} +172 -2
  74. package/dist/libraries/react/{chunk-3MF54MDU.mjs → chunk-5RTUQSYZ.mjs} +1 -1
  75. package/dist/libraries/react/{chunk-XK3AXQED.mjs → chunk-6X76WFOV.mjs} +3 -13
  76. package/dist/libraries/react/{chunk-JHFJKAXG.mjs → chunk-7A2PZDUO.mjs} +25 -25
  77. package/dist/libraries/react/{chunk-YHT2JUXO.mjs → chunk-7HRCOEUW.mjs} +1 -1
  78. package/dist/libraries/react/{chunk-KP2Q65Y3.mjs → chunk-CMUWZZWV.mjs} +2 -2
  79. package/dist/libraries/react/{chunk-KMYL54B4.mjs → chunk-DKOF357C.mjs} +1 -1
  80. package/dist/libraries/react/{chunk-67RWFVWN.mjs → chunk-HNIU2WNT.mjs} +2 -2
  81. package/dist/libraries/react/{chunk-U3OQJXCW.mjs → chunk-JTYEHM27.mjs} +4 -4
  82. package/dist/libraries/react/{chunk-6D6TYTTO.mjs → chunk-P6CAHZVT.mjs} +1 -2
  83. package/dist/libraries/react/{chunk-TTLL63A4.mjs → chunk-QNMB7QR6.mjs} +3 -3
  84. package/dist/libraries/react/{chunk-2ENHPIYQ.mjs → chunk-RK4NRHHQ.mjs} +3 -3
  85. package/dist/libraries/react/{chunk-VZY225C6.mjs → chunk-ROKCGZ77.mjs} +2 -2
  86. package/dist/libraries/react/{chunk-FDNQ6GRK.mjs → chunk-TE2MOBO7.mjs} +1 -1
  87. package/dist/libraries/react/{chunk-OMJJLT2Q.mjs → chunk-VGNA76RG.mjs} +1 -1
  88. package/dist/libraries/react/client/ReactAutumnClient.d.mts +6 -6
  89. package/dist/libraries/react/client/ReactAutumnClient.d.ts +6 -6
  90. package/dist/libraries/react/client/ReactAutumnClient.js +172 -2
  91. package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
  92. package/dist/libraries/react/client/clientCompMethods.d.mts +6 -6
  93. package/dist/libraries/react/client/clientCompMethods.d.ts +6 -6
  94. package/dist/libraries/react/client/clientCusMethods.d.mts +6 -6
  95. package/dist/libraries/react/client/clientCusMethods.d.ts +6 -6
  96. package/dist/libraries/react/client/clientEntityMethods.d.mts +6 -6
  97. package/dist/libraries/react/client/clientEntityMethods.d.ts +6 -6
  98. package/dist/libraries/react/client/clientGenMethods.d.mts +6 -6
  99. package/dist/libraries/react/client/clientGenMethods.d.ts +6 -6
  100. package/dist/libraries/react/client/clientProdMethods.d.mts +6 -6
  101. package/dist/libraries/react/client/clientProdMethods.d.ts +6 -6
  102. package/dist/libraries/react/client/clientReferralMethods.d.mts +6 -6
  103. package/dist/libraries/react/client/clientReferralMethods.d.ts +6 -6
  104. package/dist/libraries/react/client/types/clientGenTypes.js +172 -2
  105. package/dist/libraries/react/client/types/clientGenTypes.mjs +1 -1
  106. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.mts +2 -2
  107. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.ts +2 -2
  108. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +172 -13
  109. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +26 -26
  110. package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.mts +2 -2
  111. package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.ts +2 -2
  112. package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.mts +1 -1
  113. package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.ts +1 -1
  114. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +172 -2
  115. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +26 -26
  116. package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.mts +1 -1
  117. package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.ts +1 -1
  118. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
  119. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
  120. package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +172 -13
  121. package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +26 -26
  122. package/dist/libraries/react/components/ui/button.d.mts +2 -2
  123. package/dist/libraries/react/components/ui/button.d.ts +2 -2
  124. package/dist/libraries/react/components/ui/dialog.mjs +2 -2
  125. package/dist/libraries/react/components/ui/popover.mjs +2 -2
  126. package/dist/libraries/react/{cusTypes-CBapqjzm.d.mts → cusTypes-B2m4-oz4.d.mts} +1 -1
  127. package/dist/libraries/react/{cusTypes-D13MXEN7.d.ts → cusTypes-lMnznWYJ.d.ts} +1 -1
  128. package/dist/libraries/react/{entTypes-C1bM1Zpv.d.mts → entTypes-D-gn1jj2.d.mts} +1 -1
  129. package/dist/libraries/react/{entTypes-DbIrfEpl.d.ts → entTypes-WMQRyYAv.d.ts} +1 -1
  130. package/dist/libraries/react/{genTypes-C_ilxndU.d.mts → genTypes-DdYlVEah.d.mts} +1 -1
  131. package/dist/libraries/react/{genTypes-DjcQWIOM.d.ts → genTypes-aPPwPimh.d.ts} +1 -1
  132. package/dist/libraries/react/hooks/helpers/handleCheck.d.mts +6 -6
  133. package/dist/libraries/react/hooks/helpers/handleCheck.d.ts +6 -6
  134. package/dist/libraries/react/hooks/helpers/handleCheck.js +172 -2
  135. package/dist/libraries/react/hooks/helpers/handleCheck.mjs +2 -2
  136. package/dist/libraries/react/hooks/helpers/useAutumnBase.d.mts +6 -6
  137. package/dist/libraries/react/hooks/helpers/useAutumnBase.d.ts +6 -6
  138. package/dist/libraries/react/hooks/helpers/useAutumnBase.js +172 -3
  139. package/dist/libraries/react/hooks/helpers/useAutumnBase.mjs +3 -3
  140. package/dist/libraries/react/hooks/useAnalytics.d.mts +2 -2
  141. package/dist/libraries/react/hooks/useAnalytics.d.ts +2 -2
  142. package/dist/libraries/react/hooks/useAnalytics.js +172 -2
  143. package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
  144. package/dist/libraries/react/hooks/useCustomer.d.mts +66 -8
  145. package/dist/libraries/react/hooks/useCustomer.d.ts +66 -8
  146. package/dist/libraries/react/hooks/useCustomer.js +172 -13
  147. package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
  148. package/dist/libraries/react/hooks/useCustomerBase.d.mts +50 -9
  149. package/dist/libraries/react/hooks/useCustomerBase.d.ts +50 -9
  150. package/dist/libraries/react/hooks/useCustomerBase.js +172 -13
  151. package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
  152. package/dist/libraries/react/hooks/useEntity.d.mts +4 -4
  153. package/dist/libraries/react/hooks/useEntity.d.ts +4 -4
  154. package/dist/libraries/react/hooks/useEntity.js +172 -3
  155. package/dist/libraries/react/hooks/useEntity.mjs +9 -9
  156. package/dist/libraries/react/hooks/useEntityBase.d.mts +6 -6
  157. package/dist/libraries/react/hooks/useEntityBase.d.ts +6 -6
  158. package/dist/libraries/react/hooks/useEntityBase.js +172 -3
  159. package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
  160. package/dist/libraries/react/hooks/usePaywall.d.mts +1 -1
  161. package/dist/libraries/react/hooks/usePaywall.d.ts +1 -1
  162. package/dist/libraries/react/hooks/usePaywall.js +172 -2
  163. package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
  164. package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
  165. package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
  166. package/dist/libraries/react/hooks/usePricingTable.js +172 -2
  167. package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
  168. package/dist/libraries/react/hooks/usePricingTableBase.d.mts +6 -6
  169. package/dist/libraries/react/hooks/usePricingTableBase.d.ts +6 -6
  170. package/dist/libraries/react/hooks/usePricingTableBase.js +172 -2
  171. package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
  172. package/dist/libraries/react/hooks/useProductsBase.d.mts +6 -6
  173. package/dist/libraries/react/hooks/useProductsBase.d.ts +6 -6
  174. package/dist/libraries/react/index.d.mts +104 -7
  175. package/dist/libraries/react/index.d.ts +104 -7
  176. package/dist/libraries/react/index.js +172 -13
  177. package/dist/libraries/react/index.mjs +172 -13
  178. package/dist/libraries/react/{prodTypes-B8NdKyKo.d.ts → prodTypes-C8xRoBP7.d.mts} +1 -1
  179. package/dist/libraries/react/{prodTypes-B8NdKyKo.d.mts → prodTypes-C8xRoBP7.d.ts} +1 -1
  180. package/dist/next/client/hooks/useCustomer.d.mts +44 -7
  181. package/dist/next/client/hooks/useCustomer.d.ts +44 -7
  182. package/dist/next/server/cusActions.d.mts +176 -6
  183. package/dist/next/server/cusActions.d.ts +176 -6
  184. package/dist/sdk/index.d.mts +174 -4
  185. package/dist/sdk/index.d.ts +174 -4
  186. package/dist/sdk/index.js +171 -1
  187. package/dist/sdk/index.mjs +171 -1
  188. package/dist/utils/encryptUtils.js +172 -2
  189. package/dist/utils/encryptUtils.mjs +172 -2
  190. package/package.json +1 -1
  191. package/dist/libraries/react/{chunk-7JNU5ABT.mjs → chunk-FJWZPMWU.mjs} +3 -3
  192. package/dist/libraries/react/{chunk-LCWL3TIT.mjs → chunk-OTZ65PCT.mjs} +3 -3
@@ -473,22 +473,92 @@ var Autumn = class {
473
473
  entities = entityMethods(this);
474
474
  referrals = referralMethods(this);
475
475
  features = featureMethods(this);
476
- static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
476
+ /**
477
+ * Initiates a checkout flow for a product purchase.
478
+ *
479
+ * The checkout function handles the purchase process for products with pricing.
480
+ * It determines whether to show a dialog for user input or redirect directly
481
+ * to Stripe based on the customer's state and product requirements.
482
+ *
483
+ * @param params - Checkout parameters including product ID, customer data, and options
484
+ * @returns Promise resolving to checkout details including pricing, prorations, and URLs
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * const result = await autumn.checkout({
489
+ * customer_id: "user_123",
490
+ * product_id: "pro",
491
+ * success_url: "https://myapp.com/success"
492
+ * });
493
+ *
494
+ * if (result.url) {
495
+ * // Redirect to Stripe checkout
496
+ * window.location.href = result.url;
497
+ * }
498
+ * ```
499
+ */
477
500
  async checkout(params) {
478
501
  return handleCheckout({
479
502
  instance: this,
480
503
  params
481
504
  });
482
505
  }
483
- static attach = (params) => staticWrapper(handleAttach, void 0, { params });
506
+ static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
484
507
  static usage = (params) => staticWrapper(handleUsage, void 0, { params });
508
+ /**
509
+ * Attaches a product to a customer, enabling access and handling billing.
510
+ *
511
+ * The attach function activates a product for a customer and applies all product items.
512
+ * When you attach a product:
513
+ * - The customer gains access to all features in the product
514
+ * - If the product has prices, the customer will be billed accordingly
515
+ * - If there's no existing payment method, a checkout URL will be generated
516
+ *
517
+ * @param params - Attach parameters including customer ID, product ID, and options
518
+ * @returns Promise resolving to attachment result with checkout URL if needed
519
+ *
520
+ * @example
521
+ * ```typescript
522
+ * const result = await autumn.attach({
523
+ * customer_id: "user_123",
524
+ * product_id: "pro",
525
+ * success_url: "https://myapp.com/success"
526
+ * });
527
+ *
528
+ * if (result.checkout_url) {
529
+ * // Payment required - redirect to checkout
530
+ * window.location.href = result.checkout_url;
531
+ * } else {
532
+ * // Product successfully attached
533
+ * console.log("Access granted:", result.message);
534
+ * }
535
+ * ```
536
+ */
485
537
  async attach(params) {
486
538
  return handleAttach({
487
539
  instance: this,
488
540
  params
489
541
  });
490
542
  }
543
+ static attach = (params) => staticWrapper(handleAttach, void 0, { params });
491
544
  static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
545
+ /**
546
+ * Sets up a payment method for a customer.
547
+ *
548
+ * This method allows you to set up payment methods for customers without
549
+ * immediately charging them. Useful for collecting payment information
550
+ * before product attachment or for updating existing payment methods.
551
+ *
552
+ * @param params - Setup payment parameters including customer information
553
+ * @returns Promise resolving to setup payment result
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * const result = await autumn.setupPayment({
558
+ * customer_id: "user_123"
559
+ * });
560
+ * ```
561
+ */
492
562
  async setupPayment(params) {
493
563
  return handleSetupPayment({
494
564
  instance: this,
@@ -496,6 +566,24 @@ var Autumn = class {
496
566
  });
497
567
  }
498
568
  static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
569
+ /**
570
+ * Cancels a customer's subscription or product attachment.
571
+ *
572
+ * This method allows you to cancel a customer's subscription to a specific product.
573
+ * You can choose to cancel immediately or at the end of the billing cycle.
574
+ *
575
+ * @param params - Cancel parameters including customer ID and product ID
576
+ * @returns Promise resolving to cancellation result
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * const result = await autumn.cancel({
581
+ * customer_id: "user_123",
582
+ * product_id: "pro",
583
+ * cancel_immediately: false // Cancel at end of billing cycle
584
+ * });
585
+ * ```
586
+ */
499
587
  async cancel(params) {
500
588
  return handleCancel({
501
589
  instance: this,
@@ -503,6 +591,29 @@ var Autumn = class {
503
591
  });
504
592
  }
505
593
  static check = (params) => staticWrapper(handleCheck, void 0, { params });
594
+ /**
595
+ * Checks if a customer has access to a specific feature.
596
+ *
597
+ * This method verifies whether a customer has permission to use a feature
598
+ * and checks their remaining balance/usage limits. It can be used to gate
599
+ * features and determine when to show upgrade prompts.
600
+ *
601
+ * @param params - Check parameters including customer ID and feature ID
602
+ * @returns Promise resolving to access check result with allowed status and balance info
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * const result = await autumn.check({
607
+ * customer_id: "user_123",
608
+ * feature_id: "messages",
609
+ * required_balance: 1
610
+ * });
611
+ *
612
+ * if (!result.allowed) {
613
+ * console.log("Feature access denied - upgrade required");
614
+ * }
615
+ * ```
616
+ */
506
617
  async check(params) {
507
618
  return handleCheck({
508
619
  instance: this,
@@ -510,12 +621,50 @@ var Autumn = class {
510
621
  });
511
622
  }
512
623
  static track = (params) => staticWrapper(handleTrack, void 0, { params });
624
+ /**
625
+ * Tracks usage events for features or analytics.
626
+ *
627
+ * This method records usage events for metered features, updating the customer's
628
+ * balance and usage statistics. It's typically used server-side to ensure
629
+ * accurate tracking that cannot be manipulated by users.
630
+ *
631
+ * @param params - Track parameters including customer ID, feature ID, and usage value
632
+ * @returns Promise resolving to tracking result
633
+ *
634
+ * @example
635
+ * ```typescript
636
+ * const result = await autumn.track({
637
+ * customer_id: "user_123",
638
+ * feature_id: "messages",
639
+ * value: 1 // Track 1 message sent
640
+ * });
641
+ * ```
642
+ */
513
643
  async track(params) {
514
644
  return handleTrack({
515
645
  instance: this,
516
646
  params
517
647
  });
518
648
  }
649
+ /**
650
+ * Retrieves usage statistics and analytics for a customer.
651
+ *
652
+ * This method fetches detailed usage information for a customer's features,
653
+ * including current balances, usage history, and analytics data. Useful
654
+ * for displaying usage dashboards or generating reports.
655
+ *
656
+ * @param params - Usage parameters including customer ID and optional filters
657
+ * @returns Promise resolving to usage statistics and analytics data
658
+ *
659
+ * @example
660
+ * ```typescript
661
+ * const result = await autumn.usage({
662
+ * customer_id: "user_123",
663
+ * feature_id: "messages"
664
+ * value: 20 // Usage value
665
+ * });
666
+ * ```
667
+ */
519
668
  async usage(params) {
520
669
  return handleUsage({
521
670
  instance: this,
@@ -523,6 +672,25 @@ var Autumn = class {
523
672
  });
524
673
  }
525
674
  static query = (params) => staticWrapper(handleQuery, void 0, { params });
675
+ /**
676
+ * Performs advanced queries on customer data and analytics.
677
+ *
678
+ * This method allows you to run complex queries against customer data,
679
+ * usage patterns, and billing information. Useful for generating reports,
680
+ * analytics, and custom data insights.
681
+ *
682
+ * @param params - Query parameters including customer ID and query specifications
683
+ * @returns Promise resolving to query results with requested data
684
+ *
685
+ * @example
686
+ * ```typescript
687
+ * const result = await autumn.query({
688
+ * customer_id: "user_123",
689
+ * feature_id: "messages" // feature id to fetch for query, can also be an array
690
+ * });
691
+ *
692
+ * ```
693
+ */
526
694
  async query(params) {
527
695
  return handleQuery({
528
696
  instance: this,
@@ -762,6 +930,8 @@ var CheckoutParamsSchema = import_v47.z.object({
762
930
  product_id: import_v47.z.string(),
763
931
  entity_id: import_v47.z.string().optional(),
764
932
  options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
933
+ force_checkout: import_v47.z.boolean().optional(),
934
+ invoice: import_v47.z.boolean().optional(),
765
935
  success_url: import_v47.z.string().optional(),
766
936
  customer_data: CustomerDataSchema.optional(),
767
937
  entity_data: import_v47.z.any().optional(),
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  createRouterWithOptions
3
- } from "../chunk-RAHKKJED.mjs";
4
- import "../chunk-VNJ3MFJE.mjs";
5
- import "../chunk-7K3RATTK.mjs";
6
- import "../chunk-EW2R7722.mjs";
7
- import "../chunk-P3ARLB2M.mjs";
8
- import "../chunk-5DDCZMDB.mjs";
9
- import "../chunk-NAP2URIW.mjs";
3
+ } from "../chunk-NWPFUFXX.mjs";
4
+ import "../chunk-56RGUNOT.mjs";
5
+ import "../chunk-SDL7BFTH.mjs";
6
+ import "../chunk-2DWGCQCF.mjs";
7
+ import "../chunk-6JI6MF4S.mjs";
8
+ import "../chunk-FA5Z2MOT.mjs";
9
+ import "../chunk-Q7SD535L.mjs";
10
10
  import "../chunk-2TEL6LR5.mjs";
11
11
  import "../chunk-KSG3E4Q2.mjs";
12
12
  export {
@@ -473,22 +473,92 @@ var Autumn = class {
473
473
  entities = entityMethods(this);
474
474
  referrals = referralMethods(this);
475
475
  features = featureMethods(this);
476
- static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
476
+ /**
477
+ * Initiates a checkout flow for a product purchase.
478
+ *
479
+ * The checkout function handles the purchase process for products with pricing.
480
+ * It determines whether to show a dialog for user input or redirect directly
481
+ * to Stripe based on the customer's state and product requirements.
482
+ *
483
+ * @param params - Checkout parameters including product ID, customer data, and options
484
+ * @returns Promise resolving to checkout details including pricing, prorations, and URLs
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * const result = await autumn.checkout({
489
+ * customer_id: "user_123",
490
+ * product_id: "pro",
491
+ * success_url: "https://myapp.com/success"
492
+ * });
493
+ *
494
+ * if (result.url) {
495
+ * // Redirect to Stripe checkout
496
+ * window.location.href = result.url;
497
+ * }
498
+ * ```
499
+ */
477
500
  async checkout(params) {
478
501
  return handleCheckout({
479
502
  instance: this,
480
503
  params
481
504
  });
482
505
  }
483
- static attach = (params) => staticWrapper(handleAttach, void 0, { params });
506
+ static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
484
507
  static usage = (params) => staticWrapper(handleUsage, void 0, { params });
508
+ /**
509
+ * Attaches a product to a customer, enabling access and handling billing.
510
+ *
511
+ * The attach function activates a product for a customer and applies all product items.
512
+ * When you attach a product:
513
+ * - The customer gains access to all features in the product
514
+ * - If the product has prices, the customer will be billed accordingly
515
+ * - If there's no existing payment method, a checkout URL will be generated
516
+ *
517
+ * @param params - Attach parameters including customer ID, product ID, and options
518
+ * @returns Promise resolving to attachment result with checkout URL if needed
519
+ *
520
+ * @example
521
+ * ```typescript
522
+ * const result = await autumn.attach({
523
+ * customer_id: "user_123",
524
+ * product_id: "pro",
525
+ * success_url: "https://myapp.com/success"
526
+ * });
527
+ *
528
+ * if (result.checkout_url) {
529
+ * // Payment required - redirect to checkout
530
+ * window.location.href = result.checkout_url;
531
+ * } else {
532
+ * // Product successfully attached
533
+ * console.log("Access granted:", result.message);
534
+ * }
535
+ * ```
536
+ */
485
537
  async attach(params) {
486
538
  return handleAttach({
487
539
  instance: this,
488
540
  params
489
541
  });
490
542
  }
543
+ static attach = (params) => staticWrapper(handleAttach, void 0, { params });
491
544
  static setupPayment = (params) => staticWrapper(handleSetupPayment, void 0, { params });
545
+ /**
546
+ * Sets up a payment method for a customer.
547
+ *
548
+ * This method allows you to set up payment methods for customers without
549
+ * immediately charging them. Useful for collecting payment information
550
+ * before product attachment or for updating existing payment methods.
551
+ *
552
+ * @param params - Setup payment parameters including customer information
553
+ * @returns Promise resolving to setup payment result
554
+ *
555
+ * @example
556
+ * ```typescript
557
+ * const result = await autumn.setupPayment({
558
+ * customer_id: "user_123"
559
+ * });
560
+ * ```
561
+ */
492
562
  async setupPayment(params) {
493
563
  return handleSetupPayment({
494
564
  instance: this,
@@ -496,6 +566,24 @@ var Autumn = class {
496
566
  });
497
567
  }
498
568
  static cancel = (params) => staticWrapper(handleCancel, void 0, { params });
569
+ /**
570
+ * Cancels a customer's subscription or product attachment.
571
+ *
572
+ * This method allows you to cancel a customer's subscription to a specific product.
573
+ * You can choose to cancel immediately or at the end of the billing cycle.
574
+ *
575
+ * @param params - Cancel parameters including customer ID and product ID
576
+ * @returns Promise resolving to cancellation result
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * const result = await autumn.cancel({
581
+ * customer_id: "user_123",
582
+ * product_id: "pro",
583
+ * cancel_immediately: false // Cancel at end of billing cycle
584
+ * });
585
+ * ```
586
+ */
499
587
  async cancel(params) {
500
588
  return handleCancel({
501
589
  instance: this,
@@ -503,6 +591,29 @@ var Autumn = class {
503
591
  });
504
592
  }
505
593
  static check = (params) => staticWrapper(handleCheck, void 0, { params });
594
+ /**
595
+ * Checks if a customer has access to a specific feature.
596
+ *
597
+ * This method verifies whether a customer has permission to use a feature
598
+ * and checks their remaining balance/usage limits. It can be used to gate
599
+ * features and determine when to show upgrade prompts.
600
+ *
601
+ * @param params - Check parameters including customer ID and feature ID
602
+ * @returns Promise resolving to access check result with allowed status and balance info
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * const result = await autumn.check({
607
+ * customer_id: "user_123",
608
+ * feature_id: "messages",
609
+ * required_balance: 1
610
+ * });
611
+ *
612
+ * if (!result.allowed) {
613
+ * console.log("Feature access denied - upgrade required");
614
+ * }
615
+ * ```
616
+ */
506
617
  async check(params) {
507
618
  return handleCheck({
508
619
  instance: this,
@@ -510,12 +621,50 @@ var Autumn = class {
510
621
  });
511
622
  }
512
623
  static track = (params) => staticWrapper(handleTrack, void 0, { params });
624
+ /**
625
+ * Tracks usage events for features or analytics.
626
+ *
627
+ * This method records usage events for metered features, updating the customer's
628
+ * balance and usage statistics. It's typically used server-side to ensure
629
+ * accurate tracking that cannot be manipulated by users.
630
+ *
631
+ * @param params - Track parameters including customer ID, feature ID, and usage value
632
+ * @returns Promise resolving to tracking result
633
+ *
634
+ * @example
635
+ * ```typescript
636
+ * const result = await autumn.track({
637
+ * customer_id: "user_123",
638
+ * feature_id: "messages",
639
+ * value: 1 // Track 1 message sent
640
+ * });
641
+ * ```
642
+ */
513
643
  async track(params) {
514
644
  return handleTrack({
515
645
  instance: this,
516
646
  params
517
647
  });
518
648
  }
649
+ /**
650
+ * Retrieves usage statistics and analytics for a customer.
651
+ *
652
+ * This method fetches detailed usage information for a customer's features,
653
+ * including current balances, usage history, and analytics data. Useful
654
+ * for displaying usage dashboards or generating reports.
655
+ *
656
+ * @param params - Usage parameters including customer ID and optional filters
657
+ * @returns Promise resolving to usage statistics and analytics data
658
+ *
659
+ * @example
660
+ * ```typescript
661
+ * const result = await autumn.usage({
662
+ * customer_id: "user_123",
663
+ * feature_id: "messages"
664
+ * value: 20 // Usage value
665
+ * });
666
+ * ```
667
+ */
519
668
  async usage(params) {
520
669
  return handleUsage({
521
670
  instance: this,
@@ -523,6 +672,25 @@ var Autumn = class {
523
672
  });
524
673
  }
525
674
  static query = (params) => staticWrapper(handleQuery, void 0, { params });
675
+ /**
676
+ * Performs advanced queries on customer data and analytics.
677
+ *
678
+ * This method allows you to run complex queries against customer data,
679
+ * usage patterns, and billing information. Useful for generating reports,
680
+ * analytics, and custom data insights.
681
+ *
682
+ * @param params - Query parameters including customer ID and query specifications
683
+ * @returns Promise resolving to query results with requested data
684
+ *
685
+ * @example
686
+ * ```typescript
687
+ * const result = await autumn.query({
688
+ * customer_id: "user_123",
689
+ * feature_id: "messages" // feature id to fetch for query, can also be an array
690
+ * });
691
+ *
692
+ * ```
693
+ */
526
694
  async query(params) {
527
695
  return handleQuery({
528
696
  instance: this,
@@ -738,6 +906,8 @@ var CheckoutParamsSchema = import_v47.z.object({
738
906
  product_id: import_v47.z.string(),
739
907
  entity_id: import_v47.z.string().optional(),
740
908
  options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
909
+ force_checkout: import_v47.z.boolean().optional(),
910
+ invoice: import_v47.z.boolean().optional(),
741
911
  success_url: import_v47.z.string().optional(),
742
912
  customer_data: CustomerDataSchema.optional(),
743
913
  entity_data: import_v47.z.any().optional(),
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  addEntityRoutes
3
- } from "../chunk-P3ARLB2M.mjs";
4
- import "../chunk-5DDCZMDB.mjs";
5
- import "../chunk-NAP2URIW.mjs";
3
+ } from "../chunk-6JI6MF4S.mjs";
4
+ import "../chunk-FA5Z2MOT.mjs";
5
+ import "../chunk-Q7SD535L.mjs";
6
6
  import "../chunk-2TEL6LR5.mjs";
7
7
  import "../chunk-KSG3E4Q2.mjs";
8
8
  export {