autumn-js 1.2.2 → 1.2.4

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 (151) hide show
  1. package/dist/backend/adapters/express.d.mts +1 -1
  2. package/dist/backend/adapters/express.d.ts +1 -1
  3. package/dist/backend/adapters/express.js +361 -43
  4. package/dist/backend/adapters/express.mjs +5 -5
  5. package/dist/backend/adapters/fetch.d.mts +1 -1
  6. package/dist/backend/adapters/fetch.d.ts +1 -1
  7. package/dist/backend/adapters/fetch.js +361 -43
  8. package/dist/backend/adapters/fetch.mjs +5 -5
  9. package/dist/backend/adapters/hono.d.mts +1 -1
  10. package/dist/backend/adapters/hono.d.ts +1 -1
  11. package/dist/backend/adapters/hono.js +361 -43
  12. package/dist/backend/adapters/hono.mjs +5 -5
  13. package/dist/backend/adapters/index.d.mts +1 -1
  14. package/dist/backend/adapters/index.d.ts +1 -1
  15. package/dist/backend/adapters/index.js +361 -43
  16. package/dist/backend/adapters/index.mjs +8 -8
  17. package/dist/backend/adapters/next.d.mts +1 -1
  18. package/dist/backend/adapters/next.d.ts +1 -1
  19. package/dist/backend/adapters/next.js +361 -43
  20. package/dist/backend/adapters/next.mjs +5 -5
  21. package/dist/backend/{authTypes-BCoyMOAj.d.mts → authTypes-Bdpu8A6G.d.mts} +18 -0
  22. package/dist/backend/{authTypes-BCoyMOAj.d.ts → authTypes-Bdpu8A6G.d.ts} +18 -0
  23. package/dist/backend/{chunk-XU4OGYDV.mjs → chunk-3RN6TO3T.mjs} +60 -7
  24. package/dist/backend/{chunk-3QNAZFQH.mjs → chunk-AA2HLIP7.mjs} +2 -2
  25. package/dist/backend/{chunk-SX3CNUF5.mjs → chunk-AIKOHUUL.mjs} +1 -1
  26. package/dist/backend/{chunk-6BVI5XZX.mjs → chunk-BGGTI77T.mjs} +301 -36
  27. package/dist/backend/{chunk-OB47KG2H.mjs → chunk-MHFVVQCC.mjs} +1 -1
  28. package/dist/backend/{chunk-GLPHS5KF.mjs → chunk-OZRCCZTP.mjs} +2 -2
  29. package/dist/backend/{chunk-GENKYO6B.mjs → chunk-SCDE7Y52.mjs} +1 -1
  30. package/dist/backend/{chunk-C5ZDQJPP.mjs → chunk-UUMOHEAD.mjs} +1 -1
  31. package/dist/backend/core/handlers/coreHandler.d.mts +2 -2
  32. package/dist/backend/core/handlers/coreHandler.d.ts +2 -2
  33. package/dist/backend/core/handlers/coreHandler.js +361 -43
  34. package/dist/backend/core/handlers/coreHandler.mjs +3 -3
  35. package/dist/backend/core/handlers/executeRoute.d.mts +2 -2
  36. package/dist/backend/core/handlers/executeRoute.d.ts +2 -2
  37. package/dist/backend/core/handlers/handleRouteByName.d.mts +1 -1
  38. package/dist/backend/core/handlers/handleRouteByName.d.ts +1 -1
  39. package/dist/backend/core/handlers/handleRouteByName.js +361 -43
  40. package/dist/backend/core/handlers/handleRouteByName.mjs +3 -3
  41. package/dist/backend/core/handlers/index.d.mts +2 -2
  42. package/dist/backend/core/handlers/index.d.ts +2 -2
  43. package/dist/backend/core/handlers/index.js +361 -43
  44. package/dist/backend/core/handlers/index.mjs +4 -4
  45. package/dist/backend/core/handlers/resolveIdentity.d.mts +1 -1
  46. package/dist/backend/core/handlers/resolveIdentity.d.ts +1 -1
  47. package/dist/backend/core/index.d.mts +2 -2
  48. package/dist/backend/core/index.d.ts +2 -2
  49. package/dist/backend/core/index.js +361 -43
  50. package/dist/backend/core/index.mjs +4 -4
  51. package/dist/backend/core/routes/index.d.mts +2 -2
  52. package/dist/backend/core/routes/index.d.ts +2 -2
  53. package/dist/backend/core/routes/index.js +60 -7
  54. package/dist/backend/core/routes/index.mjs +1 -1
  55. package/dist/backend/core/routes/routeBuilder.d.mts +2 -2
  56. package/dist/backend/core/routes/routeBuilder.d.ts +2 -2
  57. package/dist/backend/core/routes/routeConfigs.d.mts +2 -2
  58. package/dist/backend/core/routes/routeConfigs.d.ts +2 -2
  59. package/dist/backend/core/routes/routeConfigs.js +60 -7
  60. package/dist/backend/core/routes/routeConfigs.mjs +1 -1
  61. package/dist/backend/core/types/authTypes.d.mts +1 -1
  62. package/dist/backend/core/types/authTypes.d.ts +1 -1
  63. package/dist/backend/core/types/handlerTypes.d.mts +2 -2
  64. package/dist/backend/core/types/handlerTypes.d.ts +2 -2
  65. package/dist/backend/core/types/index.d.mts +2 -2
  66. package/dist/backend/core/types/index.d.ts +2 -2
  67. package/dist/backend/core/types/routeTypes.d.mts +2 -2
  68. package/dist/backend/core/types/routeTypes.d.ts +2 -2
  69. package/dist/backend/index.d.mts +4 -4
  70. package/dist/backend/index.d.ts +4 -4
  71. package/dist/backend/index.js +361 -43
  72. package/dist/backend/index.mjs +4 -4
  73. package/dist/backend/{routeTypes-Che2nkqv.d.ts → routeTypes-DpH9YHyt.d.ts} +247 -2
  74. package/dist/backend/{routeTypes-RMeyKg5T.d.mts → routeTypes-mIP4rSxp.d.mts} +247 -2
  75. package/dist/better-auth/{chunk-5F3J4ZQQ.mjs → chunk-3C2VGNW3.mjs} +302 -37
  76. package/dist/better-auth/{chunk-6TAYCQUD.mjs → chunk-CG3LL2TQ.mjs} +60 -7
  77. package/dist/better-auth/{chunk-IODRHT4E.mjs → chunk-UCMJFTKD.mjs} +1 -1
  78. package/dist/better-auth/index.js +361 -43
  79. package/dist/better-auth/index.mjs +3 -3
  80. package/dist/better-auth/types.d.mts +18 -0
  81. package/dist/better-auth/types.d.ts +18 -0
  82. package/dist/better-auth/utils/createAutumnEndpoint.js +60 -7
  83. package/dist/better-auth/utils/createAutumnEndpoint.mjs +2 -2
  84. package/dist/better-auth/utils/handleBetterAuthRoute.js +361 -43
  85. package/dist/better-auth/utils/handleBetterAuthRoute.mjs +2 -2
  86. package/dist/better-auth/utils/index.js +361 -43
  87. package/dist/better-auth/utils/index.mjs +3 -3
  88. package/dist/react/AutumnContext.d.mts +3 -3
  89. package/dist/react/AutumnContext.d.ts +3 -3
  90. package/dist/react/AutumnProvider.d.mts +2 -1
  91. package/dist/react/AutumnProvider.d.ts +2 -1
  92. package/dist/react/AutumnProvider.js +18 -8
  93. package/dist/react/AutumnProvider.mjs +3 -3
  94. package/dist/react/{chunk-R7I3UPL4.mjs → chunk-26CKSAPZ.mjs} +6 -4
  95. package/dist/react/{chunk-QEJLIFBC.mjs → chunk-QOFGTXEX.mjs} +3 -2
  96. package/dist/react/{chunk-M34U5F2H.mjs → chunk-SCDO26YC.mjs} +11 -4
  97. package/dist/react/client/AutumnClient.d.mts +4 -3
  98. package/dist/react/client/AutumnClient.d.ts +4 -3
  99. package/dist/react/client/AutumnClient.js +13 -5
  100. package/dist/react/client/AutumnClient.mjs +2 -2
  101. package/dist/react/client/IAutumnClient.d.mts +7 -3
  102. package/dist/react/client/IAutumnClient.d.ts +7 -3
  103. package/dist/react/client/index.d.mts +3 -3
  104. package/dist/react/client/index.d.ts +3 -3
  105. package/dist/react/client/index.js +13 -5
  106. package/dist/react/client/index.mjs +2 -2
  107. package/dist/react/client/internal/httpClient.d.mts +1 -0
  108. package/dist/react/client/internal/httpClient.d.ts +1 -0
  109. package/dist/react/client/internal/httpClient.js +11 -4
  110. package/dist/react/client/internal/httpClient.mjs +1 -1
  111. package/dist/react/{customer-CMAtwbJl.d.ts → customer-BPHnUS4N.d.ts} +19 -1
  112. package/dist/react/{customer-CNvpHhpS.d.mts → customer-DDRi84Zq.d.mts} +19 -1
  113. package/dist/react/hooks/index.d.mts +3 -3
  114. package/dist/react/hooks/index.d.ts +3 -3
  115. package/dist/react/hooks/internal/check/balanceToAllowed.d.mts +2 -2
  116. package/dist/react/hooks/internal/check/balanceToAllowed.d.ts +2 -2
  117. package/dist/react/hooks/internal/check/customerToFeatures.d.mts +2 -2
  118. package/dist/react/hooks/internal/check/customerToFeatures.d.ts +2 -2
  119. package/dist/react/hooks/internal/check/findCreditSystemsByFeature.d.mts +2 -2
  120. package/dist/react/hooks/internal/check/findCreditSystemsByFeature.d.ts +2 -2
  121. package/dist/react/hooks/internal/check/getCreditCost.d.mts +2 -2
  122. package/dist/react/hooks/internal/check/getCreditCost.d.ts +2 -2
  123. package/dist/react/hooks/internal/getLocalCheckResponse.d.mts +3 -3
  124. package/dist/react/hooks/internal/getLocalCheckResponse.d.ts +3 -3
  125. package/dist/react/hooks/internal/useCustomerActions.d.mts +3 -3
  126. package/dist/react/hooks/internal/useCustomerActions.d.ts +3 -3
  127. package/dist/react/hooks/useAggregateEvents.d.mts +2 -2
  128. package/dist/react/hooks/useAggregateEvents.d.ts +2 -2
  129. package/dist/react/hooks/useCustomer.d.mts +3 -3
  130. package/dist/react/hooks/useCustomer.d.ts +3 -3
  131. package/dist/react/hooks/useEntity.d.mts +2 -2
  132. package/dist/react/hooks/useEntity.d.ts +2 -2
  133. package/dist/react/hooks/useListEvents.d.mts +2 -2
  134. package/dist/react/hooks/useListEvents.d.ts +2 -2
  135. package/dist/react/hooks/useListPlans.d.mts +2 -2
  136. package/dist/react/hooks/useListPlans.d.ts +2 -2
  137. package/dist/react/hooks/useReferrals.d.mts +2 -2
  138. package/dist/react/hooks/useReferrals.d.ts +2 -2
  139. package/dist/react/index.d.mts +3 -3
  140. package/dist/react/index.d.ts +3 -3
  141. package/dist/react/index.js +18 -8
  142. package/dist/react/index.mjs +3 -3
  143. package/dist/react/{params-Cdkj83CV.d.mts → params-Bj6uyOX1.d.mts} +91 -2
  144. package/dist/react/{params-CnOvYjqJ.d.ts → params-DAVIR4YX.d.ts} +91 -2
  145. package/dist/react/{plan-BoMslu_O.d.mts → plan-CqxFGNk2.d.mts} +4 -0
  146. package/dist/react/{plan-BoMslu_O.d.ts → plan-CqxFGNk2.d.ts} +4 -0
  147. package/dist/sdk/index.d.mts +360 -4
  148. package/dist/sdk/index.d.ts +360 -4
  149. package/dist/sdk/index.js +406 -36
  150. package/dist/sdk/index.mjs +381 -37
  151. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  import "../chunk-HIWOK3G6.mjs";
2
2
  import {
3
3
  createAutumnEndpoint
4
- } from "../chunk-IODRHT4E.mjs";
4
+ } from "../chunk-UCMJFTKD.mjs";
5
5
  import {
6
6
  createHandleBetterAuthRoute
7
- } from "../chunk-5F3J4ZQQ.mjs";
7
+ } from "../chunk-3C2VGNW3.mjs";
8
8
  import {
9
9
  resolveIdentityFromScope
10
10
  } from "../chunk-J2WYVGHS.mjs";
11
- import "../chunk-6TAYCQUD.mjs";
11
+ import "../chunk-CG3LL2TQ.mjs";
12
12
  import {
13
13
  getActiveOrganization
14
14
  } from "../chunk-BT3EAYVW.mjs";
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { IAutumnClient } from './client/IAutumnClient.mjs';
3
- import './params-Cdkj83CV.mjs';
4
- import './plan-BoMslu_O.mjs';
5
- import './customer-CNvpHhpS.mjs';
3
+ import './params-Bj6uyOX1.mjs';
4
+ import './plan-CqxFGNk2.mjs';
5
+ import './customer-DDRi84Zq.mjs';
6
6
 
7
7
  type AutumnContextValue = {
8
8
  client: IAutumnClient;
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { IAutumnClient } from './client/IAutumnClient.js';
3
- import './params-CnOvYjqJ.js';
4
- import './plan-BoMslu_O.js';
5
- import './customer-CMAtwbJl.js';
3
+ import './params-DAVIR4YX.js';
4
+ import './plan-CqxFGNk2.js';
5
+ import './customer-BPHnUS4N.js';
6
6
 
7
7
  type AutumnContextValue = {
8
8
  client: IAutumnClient;
@@ -7,6 +7,7 @@ type AutumnProviderProps = {
7
7
  pathPrefix?: string;
8
8
  useBetterAuth?: boolean;
9
9
  includeCredentials?: boolean;
10
+ headers?: Record<string, string>;
10
11
  };
11
12
  /**
12
13
  * Provider component for Autumn billing SDK.
@@ -16,6 +17,6 @@ type AutumnProviderProps = {
16
17
  * @param useBetterAuth - Use better-auth integration. Sets pathPrefix to "/api/auth/autumn" and includeCredentials to true by default.
17
18
  * @param includeCredentials - Include credentials (cookies) in cross-origin requests. Defaults to true if useBetterAuth is true.
18
19
  */
19
- declare const AutumnProvider: ({ children, backendUrl, pathPrefix, useBetterAuth, includeCredentials, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
20
+ declare const AutumnProvider: ({ children, backendUrl, pathPrefix, useBetterAuth, includeCredentials, headers, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
20
21
 
21
22
  export { AutumnProvider, type AutumnProviderProps };
@@ -7,6 +7,7 @@ type AutumnProviderProps = {
7
7
  pathPrefix?: string;
8
8
  useBetterAuth?: boolean;
9
9
  includeCredentials?: boolean;
10
+ headers?: Record<string, string>;
10
11
  };
11
12
  /**
12
13
  * Provider component for Autumn billing SDK.
@@ -16,6 +17,6 @@ type AutumnProviderProps = {
16
17
  * @param useBetterAuth - Use better-auth integration. Sets pathPrefix to "/api/auth/autumn" and includeCredentials to true by default.
17
18
  * @param includeCredentials - Include credentials (cookies) in cross-origin requests. Defaults to true if useBetterAuth is true.
18
19
  */
19
- declare const AutumnProvider: ({ children, backendUrl, pathPrefix, useBetterAuth, includeCredentials, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
20
+ declare const AutumnProvider: ({ children, backendUrl, pathPrefix, useBetterAuth, includeCredentials, headers, }: AutumnProviderProps) => react_jsx_runtime.JSX.Element;
20
21
 
21
22
  export { AutumnProvider, type AutumnProviderProps };
@@ -1926,7 +1926,12 @@ var isErrorBody = (body) => {
1926
1926
  return !!body && typeof body === "object" && "message" in body && "code" in body && "statusCode" in body;
1927
1927
  };
1928
1928
  var createHttpClient = (config) => {
1929
- const { backendUrl, pathPrefix, includeCredentials } = config;
1929
+ const {
1930
+ backendUrl,
1931
+ pathPrefix,
1932
+ includeCredentials,
1933
+ headers: customHeaders
1934
+ } = config;
1930
1935
  const baseUrl = backendUrl ? `${backendUrl}${pathPrefix}` : pathPrefix;
1931
1936
  const request = async ({
1932
1937
  route,
@@ -1934,12 +1939,14 @@ var createHttpClient = (config) => {
1934
1939
  method = "POST"
1935
1940
  }) => {
1936
1941
  const url = `${baseUrl}/${route}`;
1942
+ const headers = {
1943
+ "Content-Type": "application/json",
1944
+ ...customHeaders
1945
+ };
1937
1946
  try {
1938
1947
  const response = await fetch(url, {
1939
1948
  method,
1940
- headers: {
1941
- "Content-Type": "application/json"
1942
- },
1949
+ headers,
1943
1950
  ...includeCredentials && { credentials: "include" },
1944
1951
  ...body !== void 0 && { body: JSON.stringify(body) }
1945
1952
  });
@@ -1980,7 +1987,8 @@ var createAutumnClient = (config) => {
1980
1987
  const http = createHttpClient({
1981
1988
  backendUrl: config.backendUrl,
1982
1989
  pathPrefix: config.pathPrefix,
1983
- includeCredentials: config.includeCredentials
1990
+ includeCredentials: config.includeCredentials,
1991
+ headers: config.headers
1984
1992
  });
1985
1993
  return {
1986
1994
  getOrCreateCustomer: (params) => http.request({
@@ -2055,7 +2063,8 @@ var AutumnProvider = ({
2055
2063
  backendUrl,
2056
2064
  pathPrefix,
2057
2065
  useBetterAuth,
2058
- includeCredentials
2066
+ includeCredentials,
2067
+ headers
2059
2068
  }) => {
2060
2069
  const queryClientRef = (0, import_react2.useRef)(null);
2061
2070
  if (!queryClientRef.current) {
@@ -2076,10 +2085,11 @@ var AutumnProvider = ({
2076
2085
  const client = createAutumnClient({
2077
2086
  backendUrl,
2078
2087
  pathPrefix: resolvedPathPrefix,
2079
- includeCredentials: resolvedIncludeCredentials
2088
+ includeCredentials: resolvedIncludeCredentials,
2089
+ headers
2080
2090
  });
2081
2091
  return { client };
2082
- }, [backendUrl, pathPrefix, useBetterAuth, includeCredentials]);
2092
+ }, [backendUrl, pathPrefix, useBetterAuth, includeCredentials, JSON.stringify(headers)]);
2083
2093
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(QueryClientProvider, { client: queryClientRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AutumnContext.Provider, { value: contextValue, children }) });
2084
2094
  };
2085
2095
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,9 +2,9 @@
2
2
  "use client";
3
3
  import {
4
4
  AutumnProvider
5
- } from "./chunk-R7I3UPL4.mjs";
6
- import "./chunk-QEJLIFBC.mjs";
7
- import "./chunk-M34U5F2H.mjs";
5
+ } from "./chunk-26CKSAPZ.mjs";
6
+ import "./chunk-QOFGTXEX.mjs";
7
+ import "./chunk-SCDO26YC.mjs";
8
8
  import "./chunk-IC3QHWR6.mjs";
9
9
  import "./chunk-XJZH5NMZ.mjs";
10
10
  import "./chunk-SOA7GEAN.mjs";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createAutumnClient
4
- } from "./chunk-QEJLIFBC.mjs";
4
+ } from "./chunk-QOFGTXEX.mjs";
5
5
  import {
6
6
  QueryClient,
7
7
  QueryClientProvider
@@ -20,7 +20,8 @@ var AutumnProvider = ({
20
20
  backendUrl,
21
21
  pathPrefix,
22
22
  useBetterAuth,
23
- includeCredentials
23
+ includeCredentials,
24
+ headers
24
25
  }) => {
25
26
  const queryClientRef = useRef(null);
26
27
  if (!queryClientRef.current) {
@@ -41,10 +42,11 @@ var AutumnProvider = ({
41
42
  const client = createAutumnClient({
42
43
  backendUrl,
43
44
  pathPrefix: resolvedPathPrefix,
44
- includeCredentials: resolvedIncludeCredentials
45
+ includeCredentials: resolvedIncludeCredentials,
46
+ headers
45
47
  });
46
48
  return { client };
47
- }, [backendUrl, pathPrefix, useBetterAuth, includeCredentials]);
49
+ }, [backendUrl, pathPrefix, useBetterAuth, includeCredentials, JSON.stringify(headers)]);
48
50
  return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClientRef.current, children: /* @__PURE__ */ jsx(AutumnContext.Provider, { value: contextValue, children }) });
49
51
  };
50
52
 
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import {
3
3
  createHttpClient
4
- } from "./chunk-M34U5F2H.mjs";
4
+ } from "./chunk-SCDO26YC.mjs";
5
5
 
6
6
  // src/react/client/AutumnClient.ts
7
7
  var createAutumnClient = (config) => {
8
8
  const http = createHttpClient({
9
9
  backendUrl: config.backendUrl,
10
10
  pathPrefix: config.pathPrefix,
11
- includeCredentials: config.includeCredentials
11
+ includeCredentials: config.includeCredentials,
12
+ headers: config.headers
12
13
  });
13
14
  return {
14
15
  getOrCreateCustomer: (params) => http.request({
@@ -8,7 +8,12 @@ var isErrorBody = (body) => {
8
8
  return !!body && typeof body === "object" && "message" in body && "code" in body && "statusCode" in body;
9
9
  };
10
10
  var createHttpClient = (config) => {
11
- const { backendUrl, pathPrefix, includeCredentials } = config;
11
+ const {
12
+ backendUrl,
13
+ pathPrefix,
14
+ includeCredentials,
15
+ headers: customHeaders
16
+ } = config;
12
17
  const baseUrl = backendUrl ? `${backendUrl}${pathPrefix}` : pathPrefix;
13
18
  const request = async ({
14
19
  route,
@@ -16,12 +21,14 @@ var createHttpClient = (config) => {
16
21
  method = "POST"
17
22
  }) => {
18
23
  const url = `${baseUrl}/${route}`;
24
+ const headers = {
25
+ "Content-Type": "application/json",
26
+ ...customHeaders
27
+ };
19
28
  try {
20
29
  const response = await fetch(url, {
21
30
  method,
22
- headers: {
23
- "Content-Type": "application/json"
24
- },
31
+ headers,
25
32
  ...includeCredentials && { credentials: "include" },
26
33
  ...body !== void 0 && { body: JSON.stringify(body) }
27
34
  });
@@ -1,13 +1,14 @@
1
1
  import { IAutumnClient } from './IAutumnClient.mjs';
2
- import '../params-Cdkj83CV.mjs';
3
- import '../plan-BoMslu_O.mjs';
4
- import '../customer-CNvpHhpS.mjs';
2
+ import '../params-Bj6uyOX1.mjs';
3
+ import '../plan-CqxFGNk2.mjs';
4
+ import '../customer-DDRi84Zq.mjs';
5
5
 
6
6
  /** Configuration for Autumn client */
7
7
  type AutumnClientConfig = {
8
8
  backendUrl?: string;
9
9
  pathPrefix: string;
10
10
  includeCredentials?: boolean;
11
+ headers?: Record<string, string>;
11
12
  };
12
13
  declare const createAutumnClient: (config: AutumnClientConfig) => IAutumnClient;
13
14
 
@@ -1,13 +1,14 @@
1
1
  import { IAutumnClient } from './IAutumnClient.js';
2
- import '../params-CnOvYjqJ.js';
3
- import '../plan-BoMslu_O.js';
4
- import '../customer-CMAtwbJl.js';
2
+ import '../params-DAVIR4YX.js';
3
+ import '../plan-CqxFGNk2.js';
4
+ import '../customer-BPHnUS4N.js';
5
5
 
6
6
  /** Configuration for Autumn client */
7
7
  type AutumnClientConfig = {
8
8
  backendUrl?: string;
9
9
  pathPrefix: string;
10
10
  includeCredentials?: boolean;
11
+ headers?: Record<string, string>;
11
12
  };
12
13
  declare const createAutumnClient: (config: AutumnClientConfig) => IAutumnClient;
13
14
 
@@ -49,7 +49,12 @@ var isErrorBody = (body) => {
49
49
  return !!body && typeof body === "object" && "message" in body && "code" in body && "statusCode" in body;
50
50
  };
51
51
  var createHttpClient = (config) => {
52
- const { backendUrl, pathPrefix, includeCredentials } = config;
52
+ const {
53
+ backendUrl,
54
+ pathPrefix,
55
+ includeCredentials,
56
+ headers: customHeaders
57
+ } = config;
53
58
  const baseUrl = backendUrl ? `${backendUrl}${pathPrefix}` : pathPrefix;
54
59
  const request = async ({
55
60
  route,
@@ -57,12 +62,14 @@ var createHttpClient = (config) => {
57
62
  method = "POST"
58
63
  }) => {
59
64
  const url = `${baseUrl}/${route}`;
65
+ const headers = {
66
+ "Content-Type": "application/json",
67
+ ...customHeaders
68
+ };
60
69
  try {
61
70
  const response = await fetch(url, {
62
71
  method,
63
- headers: {
64
- "Content-Type": "application/json"
65
- },
72
+ headers,
66
73
  ...includeCredentials && { credentials: "include" },
67
74
  ...body !== void 0 && { body: JSON.stringify(body) }
68
75
  });
@@ -103,7 +110,8 @@ var createAutumnClient = (config) => {
103
110
  const http = createHttpClient({
104
111
  backendUrl: config.backendUrl,
105
112
  pathPrefix: config.pathPrefix,
106
- includeCredentials: config.includeCredentials
113
+ includeCredentials: config.includeCredentials,
114
+ headers: config.headers
107
115
  });
108
116
  return {
109
117
  getOrCreateCustomer: (params) => http.request({
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  createAutumnClient
4
- } from "../chunk-QEJLIFBC.mjs";
5
- import "../chunk-M34U5F2H.mjs";
4
+ } from "../chunk-QOFGTXEX.mjs";
5
+ import "../chunk-SCDO26YC.mjs";
6
6
  import "../chunk-IC3QHWR6.mjs";
7
7
  export {
8
8
  createAutumnClient
@@ -1,6 +1,6 @@
1
- import { d as ClientGetOrCreateCustomerParams, a as ClientAttachParams, p as AttachResponse, h as ClientPreviewAttachParams, q as PreviewAttachResponse, m as ClientUpdateSubscriptionParams, B as BillingUpdateResponse, j as ClientPreviewUpdateSubscriptionParams, r as PreviewUpdateResponse, f as ClientMultiAttachParams, M as MultiAttachResponse, i as ClientPreviewMultiAttachParams, t as PreviewMultiAttachResponse, l as ClientSetupPaymentParams, S as SetupPaymentResponse, g as ClientOpenCustomerPortalParams, O as OpenCustomerPortalResponse, b as ClientCreateReferralCodeParams, w as CreateReferralCodeResponse, k as ClientRedeemReferralCodeParams, R as RedeemReferralCodeResponse, v as ClientListPlansParams, e as ClientListEventsParams, L as ListEventsResponse, C as ClientAggregateEventsParams, A as AggregateEventsResponse, c as ClientGetEntityParams, G as GetEntityResponse } from '../params-Cdkj83CV.mjs';
2
- import { C as Customer } from '../customer-CNvpHhpS.mjs';
3
- import { O as OpenEnum } from '../plan-BoMslu_O.mjs';
1
+ import { d as ClientGetOrCreateCustomerParams, a as ClientAttachParams, p as AttachResponse, h as ClientPreviewAttachParams, q as PreviewAttachResponse, m as ClientUpdateSubscriptionParams, B as BillingUpdateResponse, j as ClientPreviewUpdateSubscriptionParams, r as PreviewUpdateResponse, f as ClientMultiAttachParams, M as MultiAttachResponse, i as ClientPreviewMultiAttachParams, t as PreviewMultiAttachResponse, l as ClientSetupPaymentParams, S as SetupPaymentResponse, g as ClientOpenCustomerPortalParams, O as OpenCustomerPortalResponse, b as ClientCreateReferralCodeParams, w as CreateReferralCodeResponse, k as ClientRedeemReferralCodeParams, R as RedeemReferralCodeResponse, v as ClientListPlansParams, e as ClientListEventsParams, L as ListEventsResponse, C as ClientAggregateEventsParams, A as AggregateEventsResponse, c as ClientGetEntityParams, G as GetEntityResponse } from '../params-Bj6uyOX1.mjs';
2
+ import { C as Customer } from '../customer-DDRi84Zq.mjs';
3
+ import { O as OpenEnum } from '../plan-CqxFGNk2.mjs';
4
4
 
5
5
  /**
6
6
  * Billing interval (e.g. 'month', 'year').
@@ -233,6 +233,10 @@ type ListPlansRollover = {
233
233
  * Maximum rollover units. Null for unlimited rollover.
234
234
  */
235
235
  max: number | null;
236
+ /**
237
+ * Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max.
238
+ */
239
+ maxPercentage?: number | null | undefined;
236
240
  /**
237
241
  * When rolled over units expire.
238
242
  */
@@ -1,6 +1,6 @@
1
- import { d as ClientGetOrCreateCustomerParams, a as ClientAttachParams, p as AttachResponse, h as ClientPreviewAttachParams, q as PreviewAttachResponse, m as ClientUpdateSubscriptionParams, B as BillingUpdateResponse, j as ClientPreviewUpdateSubscriptionParams, r as PreviewUpdateResponse, f as ClientMultiAttachParams, M as MultiAttachResponse, i as ClientPreviewMultiAttachParams, t as PreviewMultiAttachResponse, l as ClientSetupPaymentParams, S as SetupPaymentResponse, g as ClientOpenCustomerPortalParams, O as OpenCustomerPortalResponse, b as ClientCreateReferralCodeParams, w as CreateReferralCodeResponse, k as ClientRedeemReferralCodeParams, R as RedeemReferralCodeResponse, v as ClientListPlansParams, e as ClientListEventsParams, L as ListEventsResponse, C as ClientAggregateEventsParams, A as AggregateEventsResponse, c as ClientGetEntityParams, G as GetEntityResponse } from '../params-CnOvYjqJ.js';
2
- import { C as Customer } from '../customer-CMAtwbJl.js';
3
- import { O as OpenEnum } from '../plan-BoMslu_O.js';
1
+ import { d as ClientGetOrCreateCustomerParams, a as ClientAttachParams, p as AttachResponse, h as ClientPreviewAttachParams, q as PreviewAttachResponse, m as ClientUpdateSubscriptionParams, B as BillingUpdateResponse, j as ClientPreviewUpdateSubscriptionParams, r as PreviewUpdateResponse, f as ClientMultiAttachParams, M as MultiAttachResponse, i as ClientPreviewMultiAttachParams, t as PreviewMultiAttachResponse, l as ClientSetupPaymentParams, S as SetupPaymentResponse, g as ClientOpenCustomerPortalParams, O as OpenCustomerPortalResponse, b as ClientCreateReferralCodeParams, w as CreateReferralCodeResponse, k as ClientRedeemReferralCodeParams, R as RedeemReferralCodeResponse, v as ClientListPlansParams, e as ClientListEventsParams, L as ListEventsResponse, C as ClientAggregateEventsParams, A as AggregateEventsResponse, c as ClientGetEntityParams, G as GetEntityResponse } from '../params-DAVIR4YX.js';
2
+ import { C as Customer } from '../customer-BPHnUS4N.js';
3
+ import { O as OpenEnum } from '../plan-CqxFGNk2.js';
4
4
 
5
5
  /**
6
6
  * Billing interval (e.g. 'month', 'year').
@@ -233,6 +233,10 @@ type ListPlansRollover = {
233
233
  * Maximum rollover units. Null for unlimited rollover.
234
234
  */
235
235
  max: number | null;
236
+ /**
237
+ * Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max.
238
+ */
239
+ maxPercentage?: number | null | undefined;
236
240
  /**
237
241
  * When rolled over units expire.
238
242
  */
@@ -1,6 +1,6 @@
1
1
  export { AutumnClientConfig, createAutumnClient } from './AutumnClient.mjs';
2
2
  export { AutumnClientError } from './AutumnClientError.mjs';
3
3
  export { IAutumnClient } from './IAutumnClient.mjs';
4
- import '../params-Cdkj83CV.mjs';
5
- import '../plan-BoMslu_O.mjs';
6
- import '../customer-CNvpHhpS.mjs';
4
+ import '../params-Bj6uyOX1.mjs';
5
+ import '../plan-CqxFGNk2.mjs';
6
+ import '../customer-DDRi84Zq.mjs';
@@ -1,6 +1,6 @@
1
1
  export { AutumnClientConfig, createAutumnClient } from './AutumnClient.js';
2
2
  export { AutumnClientError } from './AutumnClientError.js';
3
3
  export { IAutumnClient } from './IAutumnClient.js';
4
- import '../params-CnOvYjqJ.js';
5
- import '../plan-BoMslu_O.js';
6
- import '../customer-CMAtwbJl.js';
4
+ import '../params-DAVIR4YX.js';
5
+ import '../plan-CqxFGNk2.js';
6
+ import '../customer-BPHnUS4N.js';
@@ -50,7 +50,12 @@ var isErrorBody = (body) => {
50
50
  return !!body && typeof body === "object" && "message" in body && "code" in body && "statusCode" in body;
51
51
  };
52
52
  var createHttpClient = (config) => {
53
- const { backendUrl, pathPrefix, includeCredentials } = config;
53
+ const {
54
+ backendUrl,
55
+ pathPrefix,
56
+ includeCredentials,
57
+ headers: customHeaders
58
+ } = config;
54
59
  const baseUrl = backendUrl ? `${backendUrl}${pathPrefix}` : pathPrefix;
55
60
  const request = async ({
56
61
  route,
@@ -58,12 +63,14 @@ var createHttpClient = (config) => {
58
63
  method = "POST"
59
64
  }) => {
60
65
  const url = `${baseUrl}/${route}`;
66
+ const headers = {
67
+ "Content-Type": "application/json",
68
+ ...customHeaders
69
+ };
61
70
  try {
62
71
  const response = await fetch(url, {
63
72
  method,
64
- headers: {
65
- "Content-Type": "application/json"
66
- },
73
+ headers,
67
74
  ...includeCredentials && { credentials: "include" },
68
75
  ...body !== void 0 && { body: JSON.stringify(body) }
69
76
  });
@@ -104,7 +111,8 @@ var createAutumnClient = (config) => {
104
111
  const http = createHttpClient({
105
112
  backendUrl: config.backendUrl,
106
113
  pathPrefix: config.pathPrefix,
107
- includeCredentials: config.includeCredentials
114
+ includeCredentials: config.includeCredentials,
115
+ headers: config.headers
108
116
  });
109
117
  return {
110
118
  getOrCreateCustomer: (params) => http.request({
@@ -2,8 +2,8 @@
2
2
  import "../chunk-7KBQVCNO.mjs";
3
3
  import {
4
4
  createAutumnClient
5
- } from "../chunk-QEJLIFBC.mjs";
6
- import "../chunk-M34U5F2H.mjs";
5
+ } from "../chunk-QOFGTXEX.mjs";
6
+ import "../chunk-SCDO26YC.mjs";
7
7
  import {
8
8
  AutumnClientError
9
9
  } from "../chunk-IC3QHWR6.mjs";
@@ -2,6 +2,7 @@ type HttpClientConfig = {
2
2
  backendUrl?: string;
3
3
  pathPrefix: string;
4
4
  includeCredentials?: boolean;
5
+ headers?: Record<string, string>;
5
6
  };
6
7
  declare const createHttpClient: (config: HttpClientConfig) => {
7
8
  request: <T>({ route, body, method, }: {
@@ -2,6 +2,7 @@ type HttpClientConfig = {
2
2
  backendUrl?: string;
3
3
  pathPrefix: string;
4
4
  includeCredentials?: boolean;
5
+ headers?: Record<string, string>;
5
6
  };
6
7
  declare const createHttpClient: (config: HttpClientConfig) => {
7
8
  request: <T>({ route, body, method, }: {
@@ -49,7 +49,12 @@ var isErrorBody = (body) => {
49
49
  return !!body && typeof body === "object" && "message" in body && "code" in body && "statusCode" in body;
50
50
  };
51
51
  var createHttpClient = (config) => {
52
- const { backendUrl, pathPrefix, includeCredentials } = config;
52
+ const {
53
+ backendUrl,
54
+ pathPrefix,
55
+ includeCredentials,
56
+ headers: customHeaders
57
+ } = config;
53
58
  const baseUrl = backendUrl ? `${backendUrl}${pathPrefix}` : pathPrefix;
54
59
  const request = async ({
55
60
  route,
@@ -57,12 +62,14 @@ var createHttpClient = (config) => {
57
62
  method = "POST"
58
63
  }) => {
59
64
  const url = `${baseUrl}/${route}`;
65
+ const headers = {
66
+ "Content-Type": "application/json",
67
+ ...customHeaders
68
+ };
60
69
  try {
61
70
  const response = await fetch(url, {
62
71
  method,
63
- headers: {
64
- "Content-Type": "application/json"
65
- },
72
+ headers,
66
73
  ...includeCredentials && { credentials: "include" },
67
74
  ...body !== void 0 && { body: JSON.stringify(body) }
68
75
  });
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createHttpClient
4
- } from "../../chunk-M34U5F2H.mjs";
4
+ } from "../../chunk-SCDO26YC.mjs";
5
5
  import "../../chunk-IC3QHWR6.mjs";
6
6
  export {
7
7
  createHttpClient
@@ -1,4 +1,4 @@
1
- import { O as OpenEnum, P as Plan, a as Balance } from './plan-BoMslu_O.js';
1
+ import { O as OpenEnum, P as Plan, a as Balance } from './plan-CqxFGNk2.js';
2
2
 
3
3
  /**
4
4
  * The environment this customer was created in.
@@ -62,6 +62,10 @@ type CustomerAutoTopup = {
62
62
  * Optional rate limit to cap how often auto top-ups occur.
63
63
  */
64
64
  purchaseLimit?: CustomerPurchaseLimit | undefined;
65
+ /**
66
+ * When true, auto top-up creates a send_invoice invoice instead of auto-charging.
67
+ */
68
+ invoiceMode?: boolean | undefined;
65
69
  };
66
70
  type CustomerSpendLimit = {
67
71
  /**
@@ -110,6 +114,16 @@ type CustomerUsageAlert = {
110
114
  */
111
115
  name?: string | undefined;
112
116
  };
117
+ type CustomerOverageAllowed = {
118
+ /**
119
+ * The feature ID this overage allowed control applies to.
120
+ */
121
+ featureId: string;
122
+ /**
123
+ * Whether overage is allowed for this feature.
124
+ */
125
+ enabled: boolean;
126
+ };
113
127
  /**
114
128
  * Billing controls for the customer (auto top-ups, etc.)
115
129
  */
@@ -126,6 +140,10 @@ type CustomerBillingControls = {
126
140
  * List of usage alert configurations per feature.
127
141
  */
128
142
  usageAlerts?: Array<CustomerUsageAlert> | undefined;
143
+ /**
144
+ * List of overage allowed controls per feature. When enabled, usage can exceed balance.
145
+ */
146
+ overageAllowed?: Array<CustomerOverageAllowed> | undefined;
129
147
  };
130
148
  /**
131
149
  * Current status of the subscription.
@@ -1,4 +1,4 @@
1
- import { O as OpenEnum, P as Plan, a as Balance } from './plan-BoMslu_O.mjs';
1
+ import { O as OpenEnum, P as Plan, a as Balance } from './plan-CqxFGNk2.mjs';
2
2
 
3
3
  /**
4
4
  * The environment this customer was created in.
@@ -62,6 +62,10 @@ type CustomerAutoTopup = {
62
62
  * Optional rate limit to cap how often auto top-ups occur.
63
63
  */
64
64
  purchaseLimit?: CustomerPurchaseLimit | undefined;
65
+ /**
66
+ * When true, auto top-up creates a send_invoice invoice instead of auto-charging.
67
+ */
68
+ invoiceMode?: boolean | undefined;
65
69
  };
66
70
  type CustomerSpendLimit = {
67
71
  /**
@@ -110,6 +114,16 @@ type CustomerUsageAlert = {
110
114
  */
111
115
  name?: string | undefined;
112
116
  };
117
+ type CustomerOverageAllowed = {
118
+ /**
119
+ * The feature ID this overage allowed control applies to.
120
+ */
121
+ featureId: string;
122
+ /**
123
+ * Whether overage is allowed for this feature.
124
+ */
125
+ enabled: boolean;
126
+ };
113
127
  /**
114
128
  * Billing controls for the customer (auto top-ups, etc.)
115
129
  */
@@ -126,6 +140,10 @@ type CustomerBillingControls = {
126
140
  * List of usage alert configurations per feature.
127
141
  */
128
142
  usageAlerts?: Array<CustomerUsageAlert> | undefined;
143
+ /**
144
+ * List of overage allowed controls per feature. When enabled, usage can exceed balance.
145
+ */
146
+ overageAllowed?: Array<CustomerOverageAllowed> | undefined;
129
147
  };
130
148
  /**
131
149
  * Current status of the subscription.
@@ -7,6 +7,6 @@ export { UseListPlansParams, useListPlans } from './useListPlans.mjs';
7
7
  export { UseReferralsParams, UseReferralsResult, useReferrals } from './useReferrals.mjs';
8
8
  import '@tanstack/react-query';
9
9
  import '../client/AutumnClientError.mjs';
10
- import '../params-Cdkj83CV.mjs';
11
- import '../plan-BoMslu_O.mjs';
12
- import '../customer-CNvpHhpS.mjs';
10
+ import '../params-Bj6uyOX1.mjs';
11
+ import '../plan-CqxFGNk2.mjs';
12
+ import '../customer-DDRi84Zq.mjs';
@@ -7,6 +7,6 @@ export { UseListPlansParams, useListPlans } from './useListPlans.js';
7
7
  export { UseReferralsParams, UseReferralsResult, useReferrals } from './useReferrals.js';
8
8
  import '@tanstack/react-query';
9
9
  import '../client/AutumnClientError.js';
10
- import '../params-CnOvYjqJ.js';
11
- import '../plan-BoMslu_O.js';
12
- import '../customer-CMAtwbJl.js';
10
+ import '../params-DAVIR4YX.js';
11
+ import '../plan-CqxFGNk2.js';
12
+ import '../customer-BPHnUS4N.js';
@@ -1,5 +1,5 @@
1
- import { C as Customer } from '../../../customer-CNvpHhpS.mjs';
2
- import '../../../plan-BoMslu_O.mjs';
1
+ import { C as Customer } from '../../../customer-DDRi84Zq.mjs';
2
+ import '../../../plan-CqxFGNk2.mjs';
3
3
 
4
4
  type CustomerBalance = Customer["balances"][string];
5
5
  type CustomerFeature = NonNullable<Customer["balances"][string]["feature"]>;
@@ -1,5 +1,5 @@
1
- import { C as Customer } from '../../../customer-CMAtwbJl.js';
2
- import '../../../plan-BoMslu_O.js';
1
+ import { C as Customer } from '../../../customer-BPHnUS4N.js';
2
+ import '../../../plan-CqxFGNk2.js';
3
3
 
4
4
  type CustomerBalance = Customer["balances"][string];
5
5
  type CustomerFeature = NonNullable<Customer["balances"][string]["feature"]>;