autumn-js 0.0.62 → 0.0.65

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 (174) hide show
  1. package/dist/libraries/backend/{chunk-3OKYXLTN.mjs → chunk-C2YFOJYP.mjs} +1 -1
  2. package/dist/libraries/backend/{chunk-EJQ2IWD7.mjs → chunk-FRL4IWBU.mjs} +6 -6
  3. package/dist/libraries/backend/{chunk-I45FNCR5.mjs → chunk-NDN25XDG.mjs} +3 -2
  4. package/dist/libraries/backend/{chunk-ONFOZVN3.mjs → chunk-NDS3EHT3.mjs} +1 -1
  5. package/dist/libraries/backend/{chunk-EWE7GADM.mjs → chunk-QXJ7YDTB.mjs} +1 -1
  6. package/dist/libraries/backend/{chunk-YQVUFNOA.mjs → chunk-W63TY2DI.mjs} +13 -8
  7. package/dist/libraries/backend/express.d.mts +1 -1
  8. package/dist/libraries/backend/express.d.ts +1 -1
  9. package/dist/libraries/backend/express.js +22 -19
  10. package/dist/libraries/backend/express.mjs +12 -15
  11. package/dist/libraries/backend/fastify.js +17 -13
  12. package/dist/libraries/backend/fastify.mjs +7 -9
  13. package/dist/libraries/backend/hono.js +17 -13
  14. package/dist/libraries/backend/hono.mjs +7 -9
  15. package/dist/libraries/backend/next.d.mts +2 -1
  16. package/dist/libraries/backend/next.d.ts +2 -1
  17. package/dist/libraries/backend/next.js +18 -14
  18. package/dist/libraries/backend/next.mjs +8 -10
  19. package/dist/libraries/backend/react-router.js +17 -13
  20. package/dist/libraries/backend/react-router.mjs +7 -9
  21. package/dist/libraries/backend/{referralTypes-CGt7XaEI.d.ts → referralTypes-CJPslVLJ.d.ts} +4 -0
  22. package/dist/libraries/backend/{referralTypes-B7FSGa5b.d.mts → referralTypes-DmqKXhXe.d.mts} +4 -0
  23. package/dist/libraries/backend/remix_dep.js +17 -13
  24. package/dist/libraries/backend/remix_dep.mjs +7 -9
  25. package/dist/libraries/backend/routes/backendRouter.d.mts +1 -5
  26. package/dist/libraries/backend/routes/backendRouter.d.ts +1 -5
  27. package/dist/libraries/backend/routes/backendRouter.js +16 -10
  28. package/dist/libraries/backend/routes/backendRouter.mjs +6 -6
  29. package/dist/libraries/backend/routes/entityRoutes.js +13 -8
  30. package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
  31. package/dist/libraries/backend/routes/genRoutes.js +15 -9
  32. package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
  33. package/dist/libraries/backend/routes/referralRoutes.js +13 -8
  34. package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
  35. package/dist/libraries/backend/supabase.js +17 -13
  36. package/dist/libraries/backend/supabase.mjs +7 -9
  37. package/dist/libraries/backend/tanstack.js +17 -13
  38. package/dist/libraries/backend/tanstack.mjs +7 -9
  39. package/dist/libraries/backend/utils/backendRes.js +13 -8
  40. package/dist/libraries/backend/utils/backendRes.mjs +1 -1
  41. package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
  42. package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
  43. package/dist/libraries/backend/utils/withAuth.js +13 -8
  44. package/dist/libraries/backend/utils/withAuth.mjs +2 -2
  45. package/dist/libraries/react/AutumnContext.d.mts +4 -4
  46. package/dist/libraries/react/AutumnContext.d.ts +4 -4
  47. package/dist/libraries/react/AutumnContext.js +13 -8
  48. package/dist/libraries/react/AutumnContext.mjs +3 -3
  49. package/dist/libraries/react/BaseAutumnProvider.d.mts +4 -4
  50. package/dist/libraries/react/BaseAutumnProvider.d.ts +4 -4
  51. package/dist/libraries/react/BaseAutumnProvider.js +13 -8
  52. package/dist/libraries/react/BaseAutumnProvider.mjs +6 -6
  53. package/dist/libraries/react/{ReactAutumnClient-DoXXU_vr.d.mts → ReactAutumnClient-BQtmw21U.d.mts} +3 -3
  54. package/dist/libraries/react/{ReactAutumnClient-BgrRcTEM.d.ts → ReactAutumnClient-DNcV0gAT.d.ts} +3 -3
  55. package/dist/libraries/react/ReactAutumnProvider.d.mts +1 -1
  56. package/dist/libraries/react/ReactAutumnProvider.d.ts +1 -1
  57. package/dist/libraries/react/ReactAutumnProvider.js +13 -8
  58. package/dist/libraries/react/ReactAutumnProvider.mjs +7 -7
  59. package/dist/libraries/react/{chunk-BG33A3TN.mjs → chunk-4TTWSWW7.mjs} +3 -3
  60. package/dist/libraries/react/{chunk-6FF2Q2VD.mjs → chunk-5CBWPVSP.mjs} +1 -1
  61. package/dist/libraries/react/{chunk-GKHSPJB6.mjs → chunk-CZAUMPWK.mjs} +2 -2
  62. package/dist/libraries/react/{chunk-MRIPC6HX.mjs → chunk-DFXUEQ6D.mjs} +1 -1
  63. package/dist/libraries/react/{chunk-VIXAYSBW.mjs → chunk-OCZFV7OX.mjs} +13 -8
  64. package/dist/libraries/react/{chunk-LRYO52RU.mjs → chunk-Q5SSQSDP.mjs} +1 -1
  65. package/dist/libraries/react/{chunk-7PEQTAP7.mjs → chunk-RIXRUJDK.mjs} +1 -1
  66. package/dist/libraries/react/{chunk-PC4OCHJB.mjs → chunk-URAFNMTH.mjs} +1 -1
  67. package/dist/libraries/react/{chunk-E6UE2PPO.mjs → chunk-WPXLFYWT.mjs} +3 -9
  68. package/dist/libraries/react/{chunk-GVWF4C3N.mjs → chunk-XTEUMENO.mjs} +1 -1
  69. package/dist/libraries/react/{chunk-3BJR6YBL.mjs → chunk-XXOQMNM6.mjs} +1 -1
  70. package/dist/libraries/react/client/ReactAutumnClient.d.mts +4 -4
  71. package/dist/libraries/react/client/ReactAutumnClient.d.ts +4 -4
  72. package/dist/libraries/react/client/ReactAutumnClient.js +13 -8
  73. package/dist/libraries/react/client/ReactAutumnClient.mjs +2 -2
  74. package/dist/libraries/react/client/clientCompMethods.d.mts +4 -4
  75. package/dist/libraries/react/client/clientCompMethods.d.ts +4 -4
  76. package/dist/libraries/react/client/clientCusMethods.d.mts +4 -4
  77. package/dist/libraries/react/client/clientCusMethods.d.ts +4 -4
  78. package/dist/libraries/react/client/clientEntityMethods.d.mts +4 -4
  79. package/dist/libraries/react/client/clientEntityMethods.d.ts +4 -4
  80. package/dist/libraries/react/client/clientGenMethods.d.mts +4 -4
  81. package/dist/libraries/react/client/clientGenMethods.d.ts +4 -4
  82. package/dist/libraries/react/client/clientReferralMethods.d.mts +4 -4
  83. package/dist/libraries/react/client/clientReferralMethods.d.ts +4 -4
  84. package/dist/libraries/react/client/types/clientGenTypes.d.mts +1 -0
  85. package/dist/libraries/react/client/types/clientGenTypes.d.ts +1 -0
  86. package/dist/libraries/react/{cusTypes-BTcZvjbB.d.ts → cusTypes-Cf-s9PYP.d.mts} +2 -0
  87. package/dist/libraries/react/{cusTypes-BTcZvjbB.d.mts → cusTypes-Cf-s9PYP.d.ts} +2 -0
  88. package/dist/libraries/react/{entTypes-CIjIxPas.d.ts → entTypes-BbIk0Toa.d.ts} +1 -1
  89. package/dist/libraries/react/{entTypes-_9_C-00R.d.mts → entTypes-CV-165S-.d.mts} +1 -1
  90. package/dist/libraries/react/hooks/useAutumn.d.mts +4 -7
  91. package/dist/libraries/react/hooks/useAutumn.d.ts +4 -7
  92. package/dist/libraries/react/hooks/useAutumn.js +15 -16
  93. package/dist/libraries/react/hooks/useAutumn.mjs +4 -4
  94. package/dist/libraries/react/hooks/useCustomer.d.mts +4 -4
  95. package/dist/libraries/react/hooks/useCustomer.d.ts +4 -4
  96. package/dist/libraries/react/hooks/useCustomer.js +13 -8
  97. package/dist/libraries/react/hooks/useCustomer.mjs +4 -4
  98. package/dist/libraries/react/hooks/useCustomerProvider.d.mts +4 -4
  99. package/dist/libraries/react/hooks/useCustomerProvider.d.ts +4 -4
  100. package/dist/libraries/react/hooks/useEntity.d.mts +2 -2
  101. package/dist/libraries/react/hooks/useEntity.d.ts +2 -2
  102. package/dist/libraries/react/hooks/useEntity.js +13 -8
  103. package/dist/libraries/react/hooks/useEntity.mjs +4 -4
  104. package/dist/libraries/react/hooks/useEntityProvider.d.mts +4 -4
  105. package/dist/libraries/react/hooks/useEntityProvider.d.ts +4 -4
  106. package/dist/libraries/react/hooks/useEntityProvider.js +13 -8
  107. package/dist/libraries/react/hooks/useEntityProvider.mjs +2 -2
  108. package/dist/libraries/react/hooks/usePricingTable.js +13 -8
  109. package/dist/libraries/react/hooks/usePricingTable.mjs +4 -4
  110. package/dist/libraries/react/hooks/usePricingTableProvider.d.mts +4 -4
  111. package/dist/libraries/react/hooks/usePricingTableProvider.d.ts +4 -4
  112. package/dist/libraries/react/hooks/usePricingTableProvider.js +13 -8
  113. package/dist/libraries/react/hooks/usePricingTableProvider.mjs +2 -2
  114. package/dist/libraries/react/index.d.mts +4 -4
  115. package/dist/libraries/react/index.d.ts +4 -4
  116. package/dist/libraries/react/index.js +15 -16
  117. package/dist/libraries/react/index.mjs +11 -11
  118. package/dist/libraries/react/{response-CuJBOgCX.d.ts → response-B1KyqUB9.d.ts} +1 -1
  119. package/dist/libraries/react/{response-BqFGIMug.d.mts → response-B5dHU3I9.d.mts} +1 -1
  120. package/dist/next/client/AutumnContext.d.mts +2 -2
  121. package/dist/next/client/AutumnContext.d.ts +2 -2
  122. package/dist/next/client/AutumnProvider.d.mts +1 -1
  123. package/dist/next/client/AutumnProvider.d.ts +1 -1
  124. package/dist/next/client/clientUtils.d.mts +2 -2
  125. package/dist/next/client/clientUtils.d.ts +2 -2
  126. package/dist/next/client/{cusTypes-BGfMicAw.d.ts → cusTypes-sh5_cN7N.d.mts} +2 -0
  127. package/dist/next/client/{cusTypes-BGfMicAw.d.mts → cusTypes-sh5_cN7N.d.ts} +2 -0
  128. package/dist/next/client/{entTypes-C81tVu3a.d.ts → entTypes-BDqnMLZ4.d.ts} +1 -1
  129. package/dist/next/client/{entTypes-Dmm2Us0w.d.mts → entTypes-C9TNWMk6.d.mts} +1 -1
  130. package/dist/next/client/hooks/useAutumn.d.mts +6 -4
  131. package/dist/next/client/hooks/useAutumn.d.ts +6 -4
  132. package/dist/next/client/hooks/useAutumn.js +2 -6
  133. package/dist/next/client/hooks/useAutumn.mjs +2 -6
  134. package/dist/next/client/hooks/useCustomer.d.mts +2 -2
  135. package/dist/next/client/hooks/useCustomer.d.ts +2 -2
  136. package/dist/next/client/hooks/useEntity.d.mts +2 -2
  137. package/dist/next/client/hooks/useEntity.d.ts +2 -2
  138. package/dist/next/client/hooks/usePricingTable.d.mts +2 -2
  139. package/dist/next/client/hooks/usePricingTable.d.ts +2 -2
  140. package/dist/next/client/types.d.mts +2 -2
  141. package/dist/next/client/types.d.ts +2 -2
  142. package/dist/next/index.d.mts +10 -5
  143. package/dist/next/index.d.ts +10 -5
  144. package/dist/next/server/auth/withAuth.d.mts +1 -1
  145. package/dist/next/server/auth/withAuth.d.ts +1 -1
  146. package/dist/next/server/{clientEntTypes-DX4iApM4.d.ts → clientEntTypes-CPVfO1bd.d.mts} +2 -1
  147. package/dist/next/server/{clientEntTypes-DCLnLdr2.d.mts → clientEntTypes-JLwH7X3l.d.ts} +2 -1
  148. package/dist/next/server/componentActions.d.mts +1 -1
  149. package/dist/next/server/componentActions.d.ts +1 -1
  150. package/dist/next/server/cusActions.d.mts +3 -2
  151. package/dist/next/server/cusActions.d.ts +3 -2
  152. package/dist/next/server/{cusTypes-VlsM-bzW.d.mts → cusTypes-BD42O-7Z.d.mts} +2 -0
  153. package/dist/next/server/{cusTypes-VlsM-bzW.d.ts → cusTypes-BD42O-7Z.d.ts} +2 -0
  154. package/dist/next/server/genActions.d.mts +9 -5
  155. package/dist/next/server/genActions.d.ts +9 -5
  156. package/dist/next/server/genActions.js +3 -10
  157. package/dist/next/server/genActions.mjs +3 -10
  158. package/dist/sdk/{cusTypes-D6sQTXPy.d.ts → cusTypes-BTV6ui4e.d.ts} +2 -0
  159. package/dist/sdk/{cusTypes-T1IdN-ez.d.mts → cusTypes-wBxbodEe.d.mts} +2 -0
  160. package/dist/sdk/customers.d.mts +1 -1
  161. package/dist/sdk/customers.d.ts +1 -1
  162. package/dist/sdk/{entTypes-BCt_cXXf.d.ts → entTypes-BwLV9Jn4.d.ts} +1 -1
  163. package/dist/sdk/{entTypes-BDv4ErLm.d.mts → entTypes-CJjjWn54.d.mts} +1 -1
  164. package/dist/sdk/entities.d.mts +2 -2
  165. package/dist/sdk/entities.d.ts +2 -2
  166. package/dist/sdk/general.d.mts +3 -2
  167. package/dist/sdk/general.d.ts +3 -2
  168. package/dist/sdk/index.d.mts +5 -4
  169. package/dist/sdk/index.d.ts +5 -4
  170. package/dist/sdk/index.js +13 -8
  171. package/dist/sdk/index.mjs +13 -8
  172. package/dist/utils/encryptUtils.js +13 -8
  173. package/dist/utils/encryptUtils.mjs +13 -8
  174. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import * as swr from 'swr';
2
- import { G as GetEntityParams } from '../entTypes-C81tVu3a.js';
3
- import '../cusTypes-BGfMicAw.js';
2
+ import { G as GetEntityParams } from '../entTypes-BDqnMLZ4.js';
3
+ import '../cusTypes-sh5_cN7N.js';
4
4
 
5
5
  declare const useEntity: (entityId?: string, params?: GetEntityParams) => {
6
6
  entity: any;
@@ -1,6 +1,6 @@
1
1
  import { PricingTableProduct } from '../types.mjs';
2
- import '../cusTypes-BGfMicAw.mjs';
3
- import '../entTypes-Dmm2Us0w.mjs';
2
+ import '../cusTypes-sh5_cN7N.mjs';
3
+ import '../entTypes-C9TNWMk6.mjs';
4
4
 
5
5
  declare const usePricingTable: (options?: {
6
6
  productDetails: {
@@ -1,6 +1,6 @@
1
1
  import { PricingTableProduct } from '../types.js';
2
- import '../cusTypes-BGfMicAw.js';
3
- import '../entTypes-C81tVu3a.js';
2
+ import '../cusTypes-sh5_cN7N.js';
3
+ import '../entTypes-BDqnMLZ4.js';
4
4
 
5
5
  declare const usePricingTable: (options?: {
6
6
  productDetails: {
@@ -1,5 +1,5 @@
1
- import { C as CustomerData, b as Customer } from './cusTypes-BGfMicAw.mjs';
2
- import { E as Entity } from './entTypes-Dmm2Us0w.mjs';
1
+ import { C as CustomerData, b as Customer } from './cusTypes-sh5_cN7N.mjs';
2
+ import { E as Entity } from './entTypes-C9TNWMk6.mjs';
3
3
 
4
4
  interface ProductDetails {
5
5
  id: string;
@@ -1,5 +1,5 @@
1
- import { C as CustomerData, b as Customer } from './cusTypes-BGfMicAw.js';
2
- import { E as Entity } from './entTypes-C81tVu3a.js';
1
+ import { C as CustomerData, b as Customer } from './cusTypes-sh5_cN7N.js';
2
+ import { E as Entity } from './entTypes-BDqnMLZ4.js';
3
3
 
4
4
  interface ProductDetails {
5
5
  id: string;
@@ -31,6 +31,11 @@ interface CreateEntityParams {
31
31
  featureId: string;
32
32
  }
33
33
 
34
+ interface CancelParams {
35
+ productId: string;
36
+ entityId?: string;
37
+ cancelImmediately?: boolean;
38
+ }
34
39
  interface TrackParams {
35
40
  featureId?: string;
36
41
  eventName?: string;
@@ -53,10 +58,7 @@ declare const useAutumn: () => {
53
58
  entityData?: EntityDataParams;
54
59
  }) => Promise<any>;
55
60
  track: (params: TrackParams) => Promise<any>;
56
- cancel: ({ productId, entityId, }: {
57
- productId: string;
58
- entityId?: string;
59
- }) => Promise<any>;
61
+ cancel: (params: CancelParams) => Promise<any>;
60
62
  openBillingPortal: (options?: {
61
63
  returnUrl?: string;
62
64
  }) => Promise<any>;
@@ -117,6 +119,8 @@ interface CustomerProduct {
117
119
  current_period_end?: number | null;
118
120
  trial_ends_at?: number;
119
121
  entity_id?: string;
122
+ is_add_on: boolean;
123
+ is_default: boolean;
120
124
  }
121
125
  interface Customer {
122
126
  id: string | null;
@@ -291,8 +295,9 @@ type AuthResult = Promise<{
291
295
  } | null>;
292
296
 
293
297
  declare function autumnHandler(options: {
294
- secretKey?: string;
295
298
  identify: (request: NextRequest) => AuthResult;
299
+ url?: string;
300
+ secretKey?: string;
296
301
  }): {
297
302
  GET: (request: NextRequest) => Promise<NextResponse<any>>;
298
303
  POST: (request: NextRequest) => Promise<NextResponse<any>>;
@@ -31,6 +31,11 @@ interface CreateEntityParams {
31
31
  featureId: string;
32
32
  }
33
33
 
34
+ interface CancelParams {
35
+ productId: string;
36
+ entityId?: string;
37
+ cancelImmediately?: boolean;
38
+ }
34
39
  interface TrackParams {
35
40
  featureId?: string;
36
41
  eventName?: string;
@@ -53,10 +58,7 @@ declare const useAutumn: () => {
53
58
  entityData?: EntityDataParams;
54
59
  }) => Promise<any>;
55
60
  track: (params: TrackParams) => Promise<any>;
56
- cancel: ({ productId, entityId, }: {
57
- productId: string;
58
- entityId?: string;
59
- }) => Promise<any>;
61
+ cancel: (params: CancelParams) => Promise<any>;
60
62
  openBillingPortal: (options?: {
61
63
  returnUrl?: string;
62
64
  }) => Promise<any>;
@@ -117,6 +119,8 @@ interface CustomerProduct {
117
119
  current_period_end?: number | null;
118
120
  trial_ends_at?: number;
119
121
  entity_id?: string;
122
+ is_add_on: boolean;
123
+ is_default: boolean;
120
124
  }
121
125
  interface Customer {
122
126
  id: string | null;
@@ -291,8 +295,9 @@ type AuthResult = Promise<{
291
295
  } | null>;
292
296
 
293
297
  declare function autumnHandler(options: {
294
- secretKey?: string;
295
298
  identify: (request: NextRequest) => AuthResult;
299
+ url?: string;
300
+ secretKey?: string;
296
301
  }): {
297
302
  GET: (request: NextRequest) => Promise<NextResponse<any>>;
298
303
  POST: (request: NextRequest) => Promise<NextResponse<any>>;
@@ -1,4 +1,4 @@
1
- import { C as CustomerData } from '../cusTypes-VlsM-bzW.mjs';
1
+ import { C as CustomerData } from '../cusTypes-BD42O-7Z.mjs';
2
2
 
3
3
  declare const withAuth: <T extends {
4
4
  customerId?: string;
@@ -1,4 +1,4 @@
1
- import { C as CustomerData } from '../cusTypes-VlsM-bzW.js';
1
+ import { C as CustomerData } from '../cusTypes-BD42O-7Z.js';
2
2
 
3
3
  declare const withAuth: <T extends {
4
4
  customerId?: string;
@@ -1,4 +1,4 @@
1
- import { d as CustomerProduct, e as CustomerFeature, f as CustomerInvoice, C as CustomerData, A as AppEnv, I as Infinite, P as ProductItemIntervalType, g as UsageModel, F as FreeTrialDuration, h as UsageModelType } from './cusTypes-VlsM-bzW.js';
1
+ import { d as CustomerProduct, e as CustomerFeature, f as CustomerInvoice, C as CustomerData, A as AppEnv, I as Infinite, P as ProductItemIntervalType, g as UsageModel, F as FreeTrialDuration, h as UsageModelType } from './cusTypes-BD42O-7Z.mjs';
2
2
 
3
3
  type EntityExpandOption = "invoices";
4
4
 
@@ -137,6 +137,7 @@ interface CancelParams {
137
137
  customer_id: string;
138
138
  product_id: string;
139
139
  entity_id?: string;
140
+ cancel_immediately?: boolean;
140
141
  }
141
142
  interface CancelResult {
142
143
  success: boolean;
@@ -1,4 +1,4 @@
1
- import { d as CustomerProduct, e as CustomerFeature, f as CustomerInvoice, C as CustomerData, A as AppEnv, I as Infinite, P as ProductItemIntervalType, g as UsageModel, F as FreeTrialDuration, h as UsageModelType } from './cusTypes-VlsM-bzW.mjs';
1
+ import { d as CustomerProduct, e as CustomerFeature, f as CustomerInvoice, C as CustomerData, A as AppEnv, I as Infinite, P as ProductItemIntervalType, g as UsageModel, F as FreeTrialDuration, h as UsageModelType } from './cusTypes-BD42O-7Z.js';
2
2
 
3
3
  type EntityExpandOption = "invoices";
4
4
 
@@ -137,6 +137,7 @@ interface CancelParams {
137
137
  customer_id: string;
138
138
  product_id: string;
139
139
  entity_id?: string;
140
+ cancel_immediately?: boolean;
140
141
  }
141
142
  interface CancelResult {
142
143
  success: boolean;
@@ -1,4 +1,4 @@
1
- import { C as CustomerData } from './cusTypes-VlsM-bzW.mjs';
1
+ import { C as CustomerData } from './cusTypes-BD42O-7Z.mjs';
2
2
 
3
3
  declare const getPricingTableAction: (args: Omit<{
4
4
  customerId?: string;
@@ -1,4 +1,4 @@
1
- import { C as CustomerData } from './cusTypes-VlsM-bzW.js';
1
+ import { C as CustomerData } from './cusTypes-BD42O-7Z.js';
2
2
 
3
3
  declare const getPricingTableAction: (args: Omit<{
4
4
  customerId?: string;
@@ -1,6 +1,6 @@
1
- import { P as Product, C as CreateProductParams, L as ListProductsParams, G as GetEntityParams, E as Entity, a as CreateEntityParams, b as CreateEntityResult, D as DeleteEntityResult, A as AttachParams, c as AttachResult, U as UsageParams, d as UsageResult, e as CancelParams, f as CancelResult, g as CheckParams, h as CheckResult, T as TrackParams, i as TrackResult, j as GetEntityParams$1 } from './clientEntTypes-DCLnLdr2.mjs';
1
+ import { P as Product, C as CreateProductParams, L as ListProductsParams, G as GetEntityParams, E as Entity, a as CreateEntityParams, b as CreateEntityResult, D as DeleteEntityResult, A as AttachParams, c as AttachResult, U as UsageParams, d as UsageResult, e as CancelParams, f as CancelResult, g as CheckParams, h as CheckResult, T as TrackParams, i as TrackResult, j as GetEntityParams$1 } from './clientEntTypes-CPVfO1bd.mjs';
2
2
  import { R as Result, A as AutumnError } from './response-BCg7kiiN.mjs';
3
- import { G as GetCustomerParams, a as Customer, b as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, c as BillingPortalResponse, C as CustomerData } from './cusTypes-VlsM-bzW.mjs';
3
+ import { G as GetCustomerParams, a as Customer, b as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, c as BillingPortalResponse, C as CustomerData } from './cusTypes-BD42O-7Z.mjs';
4
4
 
5
5
  declare class Autumn {
6
6
  private readonly secretKey;
@@ -13,6 +13,7 @@ declare class Autumn {
13
13
  publishableKey?: string;
14
14
  url?: string;
15
15
  version?: string;
16
+ headers?: Record<string, string>;
16
17
  });
17
18
  getLevel(): "secret" | "publishable";
18
19
  get(path: string): Promise<Result<any, AutumnError>>;
@@ -1,6 +1,6 @@
1
- import { P as Product, C as CreateProductParams, L as ListProductsParams, G as GetEntityParams, E as Entity, a as CreateEntityParams, b as CreateEntityResult, D as DeleteEntityResult, A as AttachParams, c as AttachResult, U as UsageParams, d as UsageResult, e as CancelParams, f as CancelResult, g as CheckParams, h as CheckResult, T as TrackParams, i as TrackResult, j as GetEntityParams$1 } from './clientEntTypes-DX4iApM4.js';
1
+ import { P as Product, C as CreateProductParams, L as ListProductsParams, G as GetEntityParams, E as Entity, a as CreateEntityParams, b as CreateEntityResult, D as DeleteEntityResult, A as AttachParams, c as AttachResult, U as UsageParams, d as UsageResult, e as CancelParams, f as CancelResult, g as CheckParams, h as CheckResult, T as TrackParams, i as TrackResult, j as GetEntityParams$1 } from './clientEntTypes-JLwH7X3l.js';
2
2
  import { R as Result, A as AutumnError } from './response-BCg7kiiN.js';
3
- import { G as GetCustomerParams, a as Customer, b as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, c as BillingPortalResponse, C as CustomerData } from './cusTypes-VlsM-bzW.js';
3
+ import { G as GetCustomerParams, a as Customer, b as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, c as BillingPortalResponse, C as CustomerData } from './cusTypes-BD42O-7Z.js';
4
4
 
5
5
  declare class Autumn {
6
6
  private readonly secretKey;
@@ -13,6 +13,7 @@ declare class Autumn {
13
13
  publishableKey?: string;
14
14
  url?: string;
15
15
  version?: string;
16
+ headers?: Record<string, string>;
16
17
  });
17
18
  getLevel(): "secret" | "publishable";
18
19
  get(path: string): Promise<Result<any, AutumnError>>;
@@ -63,6 +63,8 @@ interface CustomerProduct {
63
63
  current_period_end?: number | null;
64
64
  trial_ends_at?: number;
65
65
  entity_id?: string;
66
+ is_add_on: boolean;
67
+ is_default: boolean;
66
68
  }
67
69
  interface Customer {
68
70
  id: string | null;
@@ -63,6 +63,8 @@ interface CustomerProduct {
63
63
  current_period_end?: number | null;
64
64
  trial_ends_at?: number;
65
65
  entity_id?: string;
66
+ is_add_on: boolean;
67
+ is_default: boolean;
66
68
  }
67
69
  interface Customer {
68
70
  id: string | null;
@@ -1,5 +1,11 @@
1
- import { k as AttachFeatureOptions, l as EntityDataParams } from './clientEntTypes-DCLnLdr2.mjs';
2
- import { C as CustomerData, B as BillingPortalParams } from './cusTypes-VlsM-bzW.mjs';
1
+ import { k as AttachFeatureOptions, l as EntityDataParams } from './clientEntTypes-CPVfO1bd.mjs';
2
+ import { C as CustomerData, B as BillingPortalParams } from './cusTypes-BD42O-7Z.mjs';
3
+
4
+ interface CancelParams {
5
+ productId: string;
6
+ entityId?: string;
7
+ cancelImmediately?: boolean;
8
+ }
3
9
 
4
10
  declare const attachAction: (args: Omit<{
5
11
  customerId: string;
@@ -14,10 +20,8 @@ declare const attachAction: (args: Omit<{
14
20
  }, "customerId"> & {
15
21
  encryptedCustomerId?: string;
16
22
  }, request?: Request) => Promise<any>;
17
- declare const cancelAction: (args: Omit<{
23
+ declare const cancelAction: (args: Omit<CancelParams & {
18
24
  customerId: string;
19
- productId: string;
20
- entityId?: string;
21
25
  }, "customerId"> & {
22
26
  encryptedCustomerId?: string;
23
27
  }, request?: Request) => Promise<any>;
@@ -1,5 +1,11 @@
1
- import { k as AttachFeatureOptions, l as EntityDataParams } from './clientEntTypes-DX4iApM4.js';
2
- import { C as CustomerData, B as BillingPortalParams } from './cusTypes-VlsM-bzW.js';
1
+ import { k as AttachFeatureOptions, l as EntityDataParams } from './clientEntTypes-JLwH7X3l.js';
2
+ import { C as CustomerData, B as BillingPortalParams } from './cusTypes-BD42O-7Z.js';
3
+
4
+ interface CancelParams {
5
+ productId: string;
6
+ entityId?: string;
7
+ cancelImmediately?: boolean;
8
+ }
3
9
 
4
10
  declare const attachAction: (args: Omit<{
5
11
  customerId: string;
@@ -14,10 +20,8 @@ declare const attachAction: (args: Omit<{
14
20
  }, "customerId"> & {
15
21
  encryptedCustomerId?: string;
16
22
  }, request?: Request) => Promise<any>;
17
- declare const cancelAction: (args: Omit<{
23
+ declare const cancelAction: (args: Omit<CancelParams & {
18
24
  customerId: string;
19
- productId: string;
20
- entityId?: string;
21
25
  }, "customerId"> & {
22
26
  encryptedCustomerId?: string;
23
27
  }, request?: Request) => Promise<any>;
@@ -2,6 +2,7 @@
2
2
  import { createAutumnClient } from "../server/cusActions";
3
3
  import { withAuth } from "./auth/withAuth";
4
4
  import { toServerResponse } from "./utils";
5
+ import { toSnakeCase } from "../../libraries/react/utils/toSnakeCase";
5
6
  const attachAction = withAuth({
6
7
  fn: async ({
7
8
  customerId,
@@ -31,17 +32,9 @@ const attachAction = withAuth({
31
32
  withCustomerData: true
32
33
  });
33
34
  const cancelAction = withAuth({
34
- fn: async ({
35
- customerId,
36
- productId,
37
- entityId
38
- }) => {
35
+ fn: async (params) => {
39
36
  const autumn = createAutumnClient();
40
- let res = await autumn.cancel({
41
- customer_id: customerId,
42
- product_id: productId,
43
- entity_id: entityId
44
- });
37
+ let res = await autumn.cancel(toSnakeCase(params));
45
38
  return toServerResponse(res);
46
39
  }
47
40
  });
@@ -2,6 +2,7 @@
2
2
  import { createAutumnClient } from "../server/cusActions";
3
3
  import { withAuth } from "./auth/withAuth";
4
4
  import { toServerResponse } from "./utils";
5
+ import { toSnakeCase } from "../../libraries/react/utils/toSnakeCase";
5
6
  const attachAction = withAuth({
6
7
  fn: async ({
7
8
  customerId,
@@ -31,17 +32,9 @@ const attachAction = withAuth({
31
32
  withCustomerData: true
32
33
  });
33
34
  const cancelAction = withAuth({
34
- fn: async ({
35
- customerId,
36
- productId,
37
- entityId
38
- }) => {
35
+ fn: async (params) => {
39
36
  const autumn = createAutumnClient();
40
- let res = await autumn.cancel({
41
- customer_id: customerId,
42
- product_id: productId,
43
- entity_id: entityId
44
- });
37
+ let res = await autumn.cancel(toSnakeCase(params));
45
38
  return toServerResponse(res);
46
39
  }
47
40
  });
@@ -38,6 +38,8 @@ interface CustomerProduct {
38
38
  current_period_end?: number | null;
39
39
  trial_ends_at?: number;
40
40
  entity_id?: string;
41
+ is_add_on: boolean;
42
+ is_default: boolean;
41
43
  }
42
44
  interface Customer {
43
45
  id: string | null;
@@ -38,6 +38,8 @@ interface CustomerProduct {
38
38
  current_period_end?: number | null;
39
39
  trial_ends_at?: number;
40
40
  entity_id?: string;
41
+ is_add_on: boolean;
42
+ is_default: boolean;
41
43
  }
42
44
  interface Customer {
43
45
  id: string | null;
@@ -1,2 +1,2 @@
1
1
  import './prodEnums-C1lccCWI.mjs';
2
- export { B as BillingPortalParams, b as BillingPortalResponse, a as CreateCustomerParams, C as Customer, e as CustomerData, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, G as GetCustomerParams, U as UpdateCustomerParams } from './cusTypes-T1IdN-ez.mjs';
2
+ export { B as BillingPortalParams, b as BillingPortalResponse, a as CreateCustomerParams, C as Customer, e as CustomerData, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, G as GetCustomerParams, U as UpdateCustomerParams } from './cusTypes-wBxbodEe.mjs';
@@ -1,2 +1,2 @@
1
1
  import './prodEnums-C1lccCWI.js';
2
- export { B as BillingPortalParams, b as BillingPortalResponse, a as CreateCustomerParams, C as Customer, e as CustomerData, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, G as GetCustomerParams, U as UpdateCustomerParams } from './cusTypes-D6sQTXPy.js';
2
+ export { B as BillingPortalParams, b as BillingPortalResponse, a as CreateCustomerParams, C as Customer, e as CustomerData, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, G as GetCustomerParams, U as UpdateCustomerParams } from './cusTypes-BTV6ui4e.js';
@@ -1,4 +1,4 @@
1
- import { e as CustomerData, d as CustomerProduct, c as CustomerFeature, f as CustomerInvoice } from './cusTypes-D6sQTXPy.js';
1
+ import { e as CustomerData, d as CustomerProduct, c as CustomerFeature, f as CustomerInvoice } from './cusTypes-BTV6ui4e.js';
2
2
 
3
3
  type EntityExpandOption = "invoices";
4
4
 
@@ -1,4 +1,4 @@
1
- import { e as CustomerData, d as CustomerProduct, c as CustomerFeature, f as CustomerInvoice } from './cusTypes-T1IdN-ez.mjs';
1
+ import { e as CustomerData, d as CustomerProduct, c as CustomerFeature, f as CustomerInvoice } from './cusTypes-wBxbodEe.mjs';
2
2
 
3
3
  type EntityExpandOption = "invoices";
4
4
 
@@ -1,3 +1,3 @@
1
- import './cusTypes-T1IdN-ez.mjs';
2
- export { C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult, E as Entity, b as EntityData, G as GetEntityParams } from './entTypes-BDv4ErLm.mjs';
1
+ import './cusTypes-wBxbodEe.mjs';
2
+ export { C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult, E as Entity, b as EntityData, G as GetEntityParams } from './entTypes-CJjjWn54.mjs';
3
3
  import './prodEnums-C1lccCWI.mjs';
@@ -1,3 +1,3 @@
1
- import './cusTypes-D6sQTXPy.js';
2
- export { C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult, E as Entity, b as EntityData, G as GetEntityParams } from './entTypes-BCt_cXXf.js';
1
+ import './cusTypes-BTV6ui4e.js';
2
+ export { C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult, E as Entity, b as EntityData, G as GetEntityParams } from './entTypes-BwLV9Jn4.js';
3
3
  import './prodEnums-C1lccCWI.js';
@@ -1,5 +1,5 @@
1
- import { e as CustomerData } from './cusTypes-T1IdN-ez.mjs';
2
- import { b as EntityData } from './entTypes-BDv4ErLm.mjs';
1
+ import { e as CustomerData } from './cusTypes-wBxbodEe.mjs';
2
+ import { b as EntityData } from './entTypes-CJjjWn54.mjs';
3
3
  import { CheckProductFormattedPreview, CheckFeatureFormattedPreview } from './check.mjs';
4
4
  import './prodEnums-C1lccCWI.mjs';
5
5
  import './products.mjs';
@@ -26,6 +26,7 @@ interface CancelParams {
26
26
  customer_id: string;
27
27
  product_id: string;
28
28
  entity_id?: string;
29
+ cancel_immediately?: boolean;
29
30
  }
30
31
  interface CancelResult {
31
32
  success: boolean;
@@ -1,5 +1,5 @@
1
- import { e as CustomerData } from './cusTypes-D6sQTXPy.js';
2
- import { b as EntityData } from './entTypes-BCt_cXXf.js';
1
+ import { e as CustomerData } from './cusTypes-BTV6ui4e.js';
2
+ import { b as EntityData } from './entTypes-BwLV9Jn4.js';
3
3
  import { CheckProductFormattedPreview, CheckFeatureFormattedPreview } from './check.js';
4
4
  import './prodEnums-C1lccCWI.js';
5
5
  import './products.js';
@@ -26,6 +26,7 @@ interface CancelParams {
26
26
  customer_id: string;
27
27
  product_id: string;
28
28
  entity_id?: string;
29
+ cancel_immediately?: boolean;
29
30
  }
30
31
  interface CancelResult {
31
32
  success: boolean;
@@ -2,10 +2,10 @@ import { AttachParams, AttachResult, UsageParams, UsageResult, CancelParams, Can
2
2
  export { AttachFeatureOptions, EntitledBalance } from './general.mjs';
3
3
  import { Product, CreateProductParams, ListProductsParams } from './products.mjs';
4
4
  export { FreeTrial, PriceTier, ProductItem } from './products.mjs';
5
- import { G as GetCustomerParams, C as Customer, a as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, b as BillingPortalResponse } from './cusTypes-T1IdN-ez.mjs';
6
- export { e as CustomerData, g as CustomerExpandOption, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, P as ProductStatus } from './cusTypes-T1IdN-ez.mjs';
7
- import { G as GetEntityParams, E as Entity, C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult } from './entTypes-BDv4ErLm.mjs';
8
- export { b as EntityData, c as EntityExpandOption } from './entTypes-BDv4ErLm.mjs';
5
+ import { G as GetCustomerParams, C as Customer, a as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, b as BillingPortalResponse } from './cusTypes-wBxbodEe.mjs';
6
+ export { e as CustomerData, g as CustomerExpandOption, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, P as ProductStatus } from './cusTypes-wBxbodEe.mjs';
7
+ import { G as GetEntityParams, E as Entity, C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult } from './entTypes-CJjjWn54.mjs';
8
+ export { b as EntityData, c as EntityExpandOption } from './entTypes-CJjjWn54.mjs';
9
9
  import { CreateReferralCodeParams, RedeemReferralCodeParams } from './referrals.mjs';
10
10
  export { CreateReferralCodeResult, RedeemReferralCodeResult } from './referrals.mjs';
11
11
  export { CheckFeatureFormattedPreview, CheckFeatureScenario, CheckProductFormattedPreview, CheckProductScenario } from './check.mjs';
@@ -51,6 +51,7 @@ declare class Autumn {
51
51
  publishableKey?: string;
52
52
  url?: string;
53
53
  version?: string;
54
+ headers?: Record<string, string>;
54
55
  });
55
56
  getLevel(): "secret" | "publishable";
56
57
  get(path: string): Promise<Result<any, AutumnError>>;
@@ -2,10 +2,10 @@ import { AttachParams, AttachResult, UsageParams, UsageResult, CancelParams, Can
2
2
  export { AttachFeatureOptions, EntitledBalance } from './general.js';
3
3
  import { Product, CreateProductParams, ListProductsParams } from './products.js';
4
4
  export { FreeTrial, PriceTier, ProductItem } from './products.js';
5
- import { G as GetCustomerParams, C as Customer, a as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, b as BillingPortalResponse } from './cusTypes-D6sQTXPy.js';
6
- export { e as CustomerData, g as CustomerExpandOption, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, P as ProductStatus } from './cusTypes-D6sQTXPy.js';
7
- import { G as GetEntityParams, E as Entity, C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult } from './entTypes-BCt_cXXf.js';
8
- export { b as EntityData, c as EntityExpandOption } from './entTypes-BCt_cXXf.js';
5
+ import { G as GetCustomerParams, C as Customer, a as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, b as BillingPortalResponse } from './cusTypes-BTV6ui4e.js';
6
+ export { e as CustomerData, g as CustomerExpandOption, c as CustomerFeature, f as CustomerInvoice, d as CustomerProduct, P as ProductStatus } from './cusTypes-BTV6ui4e.js';
7
+ import { G as GetEntityParams, E as Entity, C as CreateEntityParams, a as CreateEntityResult, D as DeleteEntityResult } from './entTypes-BwLV9Jn4.js';
8
+ export { b as EntityData, c as EntityExpandOption } from './entTypes-BwLV9Jn4.js';
9
9
  import { CreateReferralCodeParams, RedeemReferralCodeParams } from './referrals.js';
10
10
  export { CreateReferralCodeResult, RedeemReferralCodeResult } from './referrals.js';
11
11
  export { CheckFeatureFormattedPreview, CheckFeatureScenario, CheckProductFormattedPreview, CheckProductScenario } from './check.js';
@@ -51,6 +51,7 @@ declare class Autumn {
51
51
  publishableKey?: string;
52
52
  url?: string;
53
53
  version?: string;
54
+ headers?: Record<string, string>;
54
55
  });
55
56
  getLevel(): "secret" | "publishable";
56
57
  get(path: string): Promise<Result<any, AutumnError>>;
package/dist/sdk/index.js CHANGED
@@ -302,10 +302,10 @@ var Autumn = class {
302
302
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
303
303
  } catch (error) {
304
304
  }
305
- if (!this.secretKey && !this.publishableKey) {
305
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
306
306
  throw new Error("Autumn secret key or publishable key is required");
307
307
  }
308
- this.headers = {
308
+ this.headers = options?.headers || {
309
309
  Authorization: `Bearer ${this.secretKey || this.publishableKey}`,
310
310
  "Content-Type": "application/json"
311
311
  };
@@ -324,12 +324,17 @@ var Autumn = class {
324
324
  return toContainerResult(response);
325
325
  }
326
326
  async post(path, body) {
327
- const response = await fetch(`${this.url}${path}`, {
328
- method: "POST",
329
- headers: this.headers,
330
- body: JSON.stringify(body)
331
- });
332
- return toContainerResult(response);
327
+ try {
328
+ const response = await fetch(`${this.url}${path}`, {
329
+ method: "POST",
330
+ headers: this.headers,
331
+ body: JSON.stringify(body)
332
+ });
333
+ return toContainerResult(response);
334
+ } catch (error) {
335
+ console.error("Error sending request:", error);
336
+ throw error;
337
+ }
333
338
  }
334
339
  async delete(path) {
335
340
  const response = await fetch(`${this.url}${path}`, {
@@ -300,10 +300,10 @@ var Autumn = class {
300
300
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
301
301
  } catch (error) {
302
302
  }
303
- if (!this.secretKey && !this.publishableKey) {
303
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
304
304
  throw new Error("Autumn secret key or publishable key is required");
305
305
  }
306
- this.headers = {
306
+ this.headers = options?.headers || {
307
307
  Authorization: `Bearer ${this.secretKey || this.publishableKey}`,
308
308
  "Content-Type": "application/json"
309
309
  };
@@ -322,12 +322,17 @@ var Autumn = class {
322
322
  return toContainerResult(response);
323
323
  }
324
324
  async post(path, body) {
325
- const response = await fetch(`${this.url}${path}`, {
326
- method: "POST",
327
- headers: this.headers,
328
- body: JSON.stringify(body)
329
- });
330
- return toContainerResult(response);
325
+ try {
326
+ const response = await fetch(`${this.url}${path}`, {
327
+ method: "POST",
328
+ headers: this.headers,
329
+ body: JSON.stringify(body)
330
+ });
331
+ return toContainerResult(response);
332
+ } catch (error) {
333
+ console.error("Error sending request:", error);
334
+ throw error;
335
+ }
331
336
  }
332
337
  async delete(path) {
333
338
  const response = await fetch(`${this.url}${path}`, {
@@ -330,10 +330,10 @@ var Autumn = class {
330
330
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
331
331
  } catch (error) {
332
332
  }
333
- if (!this.secretKey && !this.publishableKey) {
333
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
334
334
  throw new Error("Autumn secret key or publishable key is required");
335
335
  }
336
- this.headers = {
336
+ this.headers = options?.headers || {
337
337
  Authorization: `Bearer ${this.secretKey || this.publishableKey}`,
338
338
  "Content-Type": "application/json"
339
339
  };
@@ -352,12 +352,17 @@ var Autumn = class {
352
352
  return toContainerResult(response);
353
353
  }
354
354
  async post(path, body) {
355
- const response = await fetch(`${this.url}${path}`, {
356
- method: "POST",
357
- headers: this.headers,
358
- body: JSON.stringify(body)
359
- });
360
- return toContainerResult(response);
355
+ try {
356
+ const response = await fetch(`${this.url}${path}`, {
357
+ method: "POST",
358
+ headers: this.headers,
359
+ body: JSON.stringify(body)
360
+ });
361
+ return toContainerResult(response);
362
+ } catch (error) {
363
+ console.error("Error sending request:", error);
364
+ throw error;
365
+ }
361
366
  }
362
367
  async delete(path) {
363
368
  const response = await fetch(`${this.url}${path}`, {