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.
Files changed (136) hide show
  1. package/dist/libraries/backend/better-auth.d.mts +4 -0
  2. package/dist/libraries/backend/better-auth.d.ts +4 -0
  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-DSv2hpmP.d.mts} +178 -44
  33. package/dist/libraries/backend/{referralTypes-FlI0fYwz.d.ts → referralTypes-DdKvvqSK.d.ts} +178 -44
  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.js +176 -4
  57. package/dist/libraries/react/AutumnContext.mjs +4 -4
  58. package/dist/libraries/react/BaseAutumnProvider.js +176 -15
  59. package/dist/libraries/react/BaseAutumnProvider.mjs +9 -9
  60. package/dist/libraries/react/ReactAutumnProvider.js +176 -15
  61. package/dist/libraries/react/ReactAutumnProvider.mjs +10 -10
  62. package/dist/libraries/react/{chunk-2ENHPIYQ.mjs → chunk-52HVA7E4.mjs} +3 -3
  63. package/dist/libraries/react/{chunk-WYQMHQUE.mjs → chunk-5O3IHYFF.mjs} +172 -2
  64. package/dist/libraries/react/{chunk-JHFJKAXG.mjs → chunk-5YM6QT7V.mjs} +33 -33
  65. package/dist/libraries/react/{chunk-KP2Q65Y3.mjs → chunk-643J45JV.mjs} +2 -2
  66. package/dist/libraries/react/{chunk-YHT2JUXO.mjs → chunk-7HRCOEUW.mjs} +1 -1
  67. package/dist/libraries/react/{chunk-OMJJLT2Q.mjs → chunk-7JU3XHKL.mjs} +1 -1
  68. package/dist/libraries/react/{chunk-XK3AXQED.mjs → chunk-BT5OY2CA.mjs} +3 -13
  69. package/dist/libraries/react/{chunk-KMYL54B4.mjs → chunk-DKOF357C.mjs} +1 -1
  70. package/dist/libraries/react/{chunk-4NZ7ML7V.mjs → chunk-M3SON3SH.mjs} +2 -2
  71. package/dist/libraries/react/{chunk-67RWFVWN.mjs → chunk-OSYZMMQC.mjs} +2 -2
  72. package/dist/libraries/react/{chunk-6D6TYTTO.mjs → chunk-P6CAHZVT.mjs} +1 -2
  73. package/dist/libraries/react/{chunk-VZY225C6.mjs → chunk-RP56DI4O.mjs} +2 -2
  74. package/dist/libraries/react/{chunk-FDNQ6GRK.mjs → chunk-SWVRRNIW.mjs} +1 -1
  75. package/dist/libraries/react/{chunk-U3OQJXCW.mjs → chunk-TOAZUTY6.mjs} +8 -6
  76. package/dist/libraries/react/{chunk-3MF54MDU.mjs → chunk-WBBWID5F.mjs} +1 -1
  77. package/dist/libraries/react/{chunk-TTLL63A4.mjs → chunk-Z7REFVM4.mjs} +3 -3
  78. package/dist/libraries/react/client/ReactAutumnClient.js +176 -4
  79. package/dist/libraries/react/client/ReactAutumnClient.mjs +3 -3
  80. package/dist/libraries/react/client/types/clientGenTypes.js +172 -2
  81. package/dist/libraries/react/client/types/clientGenTypes.mjs +1 -1
  82. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.css +3 -0
  83. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +181 -20
  84. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +26 -26
  85. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.css +3 -0
  86. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +176 -4
  87. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +26 -26
  88. package/dist/libraries/react/components/pricing-table/pricing-table-synced.css +3 -0
  89. package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +181 -20
  90. package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +26 -26
  91. package/dist/libraries/react/components/ui/button.d.mts +2 -2
  92. package/dist/libraries/react/components/ui/button.d.ts +2 -2
  93. package/dist/libraries/react/components/ui/dialog.mjs +2 -2
  94. package/dist/libraries/react/components/ui/popover.mjs +2 -2
  95. package/dist/libraries/react/hooks/helpers/handleCheck.js +172 -2
  96. package/dist/libraries/react/hooks/helpers/handleCheck.mjs +2 -2
  97. package/dist/libraries/react/hooks/helpers/useAutumnBase.js +172 -3
  98. package/dist/libraries/react/hooks/helpers/useAutumnBase.mjs +3 -3
  99. package/dist/libraries/react/hooks/useAnalytics.js +176 -4
  100. package/dist/libraries/react/hooks/useAnalytics.mjs +5 -5
  101. package/dist/libraries/react/hooks/useCustomer.d.mts +60 -2
  102. package/dist/libraries/react/hooks/useCustomer.d.ts +60 -2
  103. package/dist/libraries/react/hooks/useCustomer.js +176 -15
  104. package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
  105. package/dist/libraries/react/hooks/useCustomerBase.d.mts +44 -3
  106. package/dist/libraries/react/hooks/useCustomerBase.d.ts +44 -3
  107. package/dist/libraries/react/hooks/useCustomerBase.js +176 -15
  108. package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
  109. package/dist/libraries/react/hooks/useEntity.js +176 -5
  110. package/dist/libraries/react/hooks/useEntity.mjs +9 -9
  111. package/dist/libraries/react/hooks/useEntityBase.js +176 -5
  112. package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
  113. package/dist/libraries/react/hooks/usePaywall.js +176 -4
  114. package/dist/libraries/react/hooks/usePaywall.mjs +5 -5
  115. package/dist/libraries/react/hooks/usePricingTable.js +176 -4
  116. package/dist/libraries/react/hooks/usePricingTable.mjs +6 -6
  117. package/dist/libraries/react/hooks/usePricingTableBase.js +172 -2
  118. package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
  119. package/dist/libraries/react/index.d.mts +104 -7
  120. package/dist/libraries/react/index.d.ts +104 -7
  121. package/dist/libraries/react/index.js +182 -21
  122. package/dist/libraries/react/index.mjs +182 -21
  123. package/dist/next/client/hooks/useCustomer.d.mts +44 -7
  124. package/dist/next/client/hooks/useCustomer.d.ts +44 -7
  125. package/dist/next/server/cusActions.d.mts +178 -44
  126. package/dist/next/server/cusActions.d.ts +178 -44
  127. package/dist/sdk/index.d.mts +178 -44
  128. package/dist/sdk/index.d.ts +178 -44
  129. package/dist/sdk/index.js +171 -1
  130. package/dist/sdk/index.mjs +171 -1
  131. package/dist/styles/global.css +3 -0
  132. package/dist/utils/encryptUtils.js +172 -2
  133. package/dist/utils/encryptUtils.mjs +172 -2
  134. package/package.json +1 -1
  135. package/dist/libraries/react/{chunk-7JNU5ABT.mjs → chunk-FJWZPMWU.mjs} +3 -3
  136. 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
- static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
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 attach = (params) => staticWrapper(handleAttach, void 0, { params });
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,
@@ -739,6 +907,8 @@ var CheckoutParamsSchema = import_v47.z.object({
739
907
  product_id: import_v47.z.string(),
740
908
  entity_id: import_v47.z.string().optional(),
741
909
  options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
910
+ force_checkout: import_v47.z.boolean().optional(),
911
+ invoice: import_v47.z.boolean().optional(),
742
912
  success_url: import_v47.z.string().optional(),
743
913
  customer_data: CustomerDataSchema.optional(),
744
914
  entity_data: import_v47.z.any().optional(),
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  addProductRoutes
3
- } from "../chunk-7K3RATTK.mjs";
4
- import "../chunk-5DDCZMDB.mjs";
5
- import "../chunk-NAP2URIW.mjs";
3
+ } from "../chunk-SDL7BFTH.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 {
@@ -474,22 +474,92 @@ var Autumn = class {
474
474
  entities = entityMethods(this);
475
475
  referrals = referralMethods(this);
476
476
  features = featureMethods(this);
477
- static checkout = (params) => staticWrapper(handleCheckout, void 0, { params });
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 attach = (params) => staticWrapper(handleAttach, void 0, { params });
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,
@@ -739,6 +907,8 @@ var CheckoutParamsSchema = import_v47.z.object({
739
907
  product_id: import_v47.z.string(),
740
908
  entity_id: import_v47.z.string().optional(),
741
909
  options: import_v47.z.array(AttachFeatureOptionsSchema).optional(),
910
+ force_checkout: import_v47.z.boolean().optional(),
911
+ invoice: import_v47.z.boolean().optional(),
742
912
  success_url: import_v47.z.string().optional(),
743
913
  customer_data: CustomerDataSchema.optional(),
744
914
  entity_data: import_v47.z.any().optional(),
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  addReferralRoutes
3
- } from "../chunk-EW2R7722.mjs";
4
- import "../chunk-5DDCZMDB.mjs";
5
- import "../chunk-NAP2URIW.mjs";
3
+ } from "../chunk-2DWGCQCF.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 {