autumn-js 0.0.63 → 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 (100) hide show
  1. package/dist/libraries/backend/{chunk-IWZ4KYSH.mjs → chunk-C2YFOJYP.mjs} +1 -1
  2. package/dist/libraries/backend/{chunk-MCSTMHRF.mjs → chunk-FRL4IWBU.mjs} +6 -6
  3. package/dist/libraries/backend/{chunk-R27FUM7G.mjs → chunk-NDN25XDG.mjs} +3 -2
  4. package/dist/libraries/backend/{chunk-NXXTBCPD.mjs → chunk-NDS3EHT3.mjs} +1 -1
  5. package/dist/libraries/backend/{chunk-J6BWOIM2.mjs → chunk-QXJ7YDTB.mjs} +1 -1
  6. package/dist/libraries/backend/{chunk-52ERHSRF.mjs → chunk-W63TY2DI.mjs} +12 -7
  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 +21 -18
  10. package/dist/libraries/backend/express.mjs +12 -15
  11. package/dist/libraries/backend/fastify.js +16 -12
  12. package/dist/libraries/backend/fastify.mjs +7 -9
  13. package/dist/libraries/backend/hono.js +16 -12
  14. package/dist/libraries/backend/hono.mjs +7 -9
  15. package/dist/libraries/backend/next.js +16 -12
  16. package/dist/libraries/backend/next.mjs +7 -9
  17. package/dist/libraries/backend/react-router.js +16 -12
  18. package/dist/libraries/backend/react-router.mjs +7 -9
  19. package/dist/libraries/backend/{referralTypes-D6dBIcVj.d.ts → referralTypes-CJPslVLJ.d.ts} +1 -0
  20. package/dist/libraries/backend/{referralTypes-CIEzOYwT.d.mts → referralTypes-DmqKXhXe.d.mts} +1 -0
  21. package/dist/libraries/backend/remix_dep.js +16 -12
  22. package/dist/libraries/backend/remix_dep.mjs +7 -9
  23. package/dist/libraries/backend/routes/backendRouter.d.mts +1 -5
  24. package/dist/libraries/backend/routes/backendRouter.d.ts +1 -5
  25. package/dist/libraries/backend/routes/backendRouter.js +15 -9
  26. package/dist/libraries/backend/routes/backendRouter.mjs +6 -6
  27. package/dist/libraries/backend/routes/entityRoutes.js +12 -7
  28. package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
  29. package/dist/libraries/backend/routes/genRoutes.js +14 -8
  30. package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
  31. package/dist/libraries/backend/routes/referralRoutes.js +12 -7
  32. package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
  33. package/dist/libraries/backend/supabase.js +16 -12
  34. package/dist/libraries/backend/supabase.mjs +7 -9
  35. package/dist/libraries/backend/tanstack.js +16 -12
  36. package/dist/libraries/backend/tanstack.mjs +7 -9
  37. package/dist/libraries/backend/utils/backendRes.js +12 -7
  38. package/dist/libraries/backend/utils/backendRes.mjs +1 -1
  39. package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
  40. package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
  41. package/dist/libraries/backend/utils/withAuth.js +12 -7
  42. package/dist/libraries/backend/utils/withAuth.mjs +2 -2
  43. package/dist/libraries/react/AutumnContext.js +12 -7
  44. package/dist/libraries/react/AutumnContext.mjs +3 -3
  45. package/dist/libraries/react/BaseAutumnProvider.js +12 -7
  46. package/dist/libraries/react/BaseAutumnProvider.mjs +7 -7
  47. package/dist/libraries/react/ReactAutumnProvider.js +12 -7
  48. package/dist/libraries/react/ReactAutumnProvider.mjs +8 -8
  49. package/dist/libraries/react/{chunk-2Q72AFTY.mjs → chunk-4TTWSWW7.mjs} +8 -8
  50. package/dist/libraries/react/{chunk-ODYKGMMO.mjs → chunk-5CBWPVSP.mjs} +1 -1
  51. package/dist/libraries/react/{chunk-ENHBWPHN.mjs → chunk-CZAUMPWK.mjs} +2 -2
  52. package/dist/libraries/react/{chunk-UP5NZZNP.mjs → chunk-DFXUEQ6D.mjs} +1 -1
  53. package/dist/libraries/react/{chunk-H2V37JOA.mjs → chunk-OCZFV7OX.mjs} +12 -7
  54. package/dist/libraries/react/{chunk-544EFZUX.mjs → chunk-Q5SSQSDP.mjs} +1 -1
  55. package/dist/libraries/react/{chunk-3PIWTU6F.mjs → chunk-RIXRUJDK.mjs} +1 -1
  56. package/dist/libraries/react/{chunk-HU6NIBMZ.mjs → chunk-URAFNMTH.mjs} +1 -1
  57. package/dist/libraries/react/{chunk-KKQ43XGE.mjs → chunk-WPXLFYWT.mjs} +3 -9
  58. package/dist/libraries/react/{chunk-TRNJQQVR.mjs → chunk-XTEUMENO.mjs} +1 -1
  59. package/dist/libraries/react/{chunk-NIZX6KAM.mjs → chunk-XXOQMNM6.mjs} +3 -3
  60. package/dist/libraries/react/client/ReactAutumnClient.js +12 -7
  61. package/dist/libraries/react/client/ReactAutumnClient.mjs +2 -2
  62. package/dist/libraries/react/client/types/clientGenTypes.d.mts +1 -0
  63. package/dist/libraries/react/client/types/clientGenTypes.d.ts +1 -0
  64. package/dist/libraries/react/hooks/useAutumn.d.mts +2 -5
  65. package/dist/libraries/react/hooks/useAutumn.d.ts +2 -5
  66. package/dist/libraries/react/hooks/useAutumn.js +14 -15
  67. package/dist/libraries/react/hooks/useAutumn.mjs +4 -4
  68. package/dist/libraries/react/hooks/useCustomer.js +12 -7
  69. package/dist/libraries/react/hooks/useCustomer.mjs +4 -4
  70. package/dist/libraries/react/hooks/useEntity.js +12 -7
  71. package/dist/libraries/react/hooks/useEntity.mjs +4 -4
  72. package/dist/libraries/react/hooks/useEntityProvider.js +12 -7
  73. package/dist/libraries/react/hooks/useEntityProvider.mjs +2 -2
  74. package/dist/libraries/react/hooks/usePricingTable.js +12 -7
  75. package/dist/libraries/react/hooks/usePricingTable.mjs +4 -4
  76. package/dist/libraries/react/hooks/usePricingTableProvider.js +12 -7
  77. package/dist/libraries/react/hooks/usePricingTableProvider.mjs +2 -2
  78. package/dist/libraries/react/index.js +14 -15
  79. package/dist/libraries/react/index.mjs +15 -15
  80. package/dist/next/client/hooks/useAutumn.d.mts +6 -4
  81. package/dist/next/client/hooks/useAutumn.d.ts +6 -4
  82. package/dist/next/client/hooks/useAutumn.js +2 -6
  83. package/dist/next/client/hooks/useAutumn.mjs +2 -6
  84. package/dist/next/index.d.mts +6 -4
  85. package/dist/next/index.d.ts +6 -4
  86. package/dist/next/server/{clientEntTypes-C_HhGHvK.d.mts → clientEntTypes-CPVfO1bd.d.mts} +1 -0
  87. package/dist/next/server/{clientEntTypes-ZZHurPcy.d.ts → clientEntTypes-JLwH7X3l.d.ts} +1 -0
  88. package/dist/next/server/cusActions.d.mts +1 -1
  89. package/dist/next/server/cusActions.d.ts +1 -1
  90. package/dist/next/server/genActions.d.mts +8 -4
  91. package/dist/next/server/genActions.d.ts +8 -4
  92. package/dist/next/server/genActions.js +3 -10
  93. package/dist/next/server/genActions.mjs +3 -10
  94. package/dist/sdk/general.d.mts +1 -0
  95. package/dist/sdk/general.d.ts +1 -0
  96. package/dist/sdk/index.js +12 -7
  97. package/dist/sdk/index.mjs +12 -7
  98. package/dist/utils/encryptUtils.js +12 -7
  99. package/dist/utils/encryptUtils.mjs +12 -7
  100. package/package.json +1 -1
@@ -256,6 +256,7 @@ interface CancelParams {
256
256
  customer_id: string;
257
257
  product_id: string;
258
258
  entity_id?: string;
259
+ cancel_immediately?: boolean;
259
260
  }
260
261
  interface CancelResult {
261
262
  success: boolean;
@@ -318,7 +318,7 @@ var Autumn = class {
318
318
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
319
319
  } catch (error) {
320
320
  }
321
- if (!this.secretKey && !this.publishableKey) {
321
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
322
322
  throw new Error("Autumn secret key or publishable key is required");
323
323
  }
324
324
  this.headers = options?.headers || {
@@ -340,12 +340,17 @@ var Autumn = class {
340
340
  return toContainerResult(response);
341
341
  }
342
342
  async post(path, body) {
343
- const response = await fetch(`${this.url}${path}`, {
344
- method: "POST",
345
- headers: this.headers,
346
- body: JSON.stringify(body)
347
- });
348
- return toContainerResult(response);
343
+ try {
344
+ const response = await fetch(`${this.url}${path}`, {
345
+ method: "POST",
346
+ headers: this.headers,
347
+ body: JSON.stringify(body)
348
+ });
349
+ return toContainerResult(response);
350
+ } catch (error) {
351
+ console.error("Error sending request:", error);
352
+ throw error;
353
+ }
349
354
  }
350
355
  async delete(path) {
351
356
  const response = await fetch(`${this.url}${path}`, {
@@ -579,11 +584,12 @@ var checkHandler = withAuth({
579
584
  customer_data,
580
585
  body
581
586
  }) => {
582
- return await autumn.check({
587
+ const result = await autumn.check({
583
588
  ...sanitizeBody(body),
584
589
  customer_id,
585
590
  customer_data
586
591
  });
592
+ return result;
587
593
  }
588
594
  });
589
595
  var trackHandler = withAuth({
@@ -770,7 +776,7 @@ var getPricingTableHandler = withAuth({
770
776
  },
771
777
  requireCustomer: false
772
778
  });
773
- var createRouterWithOptions = ({ autumn }) => {
779
+ var createRouterWithOptions = () => {
774
780
  const router = (0, import_rou34.createRouter)();
775
781
  (0, import_rou34.addRoute)(router, "POST", `${BASE_PATH}/customers`, {
776
782
  handler: createCustomerHandler
@@ -792,9 +798,7 @@ function autumnHandler(options) {
792
798
  url: autumnApiUrl,
793
799
  version: options.version
794
800
  });
795
- const router = createRouterWithOptions({
796
- autumn
797
- });
801
+ const router = createRouterWithOptions();
798
802
  async function handleAutumnRequest(args) {
799
803
  let path = args.params["*"] || "";
800
804
  const url = new URL(args.request.url);
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createRouterWithOptions
3
- } from "./chunk-MCSTMHRF.mjs";
4
- import "./chunk-J6BWOIM2.mjs";
5
- import "./chunk-R27FUM7G.mjs";
6
- import "./chunk-NXXTBCPD.mjs";
7
- import "./chunk-IWZ4KYSH.mjs";
3
+ } from "./chunk-FRL4IWBU.mjs";
4
+ import "./chunk-QXJ7YDTB.mjs";
5
+ import "./chunk-NDN25XDG.mjs";
6
+ import "./chunk-NDS3EHT3.mjs";
7
+ import "./chunk-C2YFOJYP.mjs";
8
8
  import {
9
9
  Autumn
10
- } from "./chunk-52ERHSRF.mjs";
10
+ } from "./chunk-W63TY2DI.mjs";
11
11
  import {
12
12
  autumnApiUrl
13
13
  } from "./chunk-KSG3E4Q2.mjs";
@@ -20,9 +20,7 @@ function autumnHandler(options) {
20
20
  url: autumnApiUrl,
21
21
  version: options.version
22
22
  });
23
- const router = createRouterWithOptions({
24
- autumn
25
- });
23
+ const router = createRouterWithOptions();
26
24
  async function handleAutumnRequest(args) {
27
25
  let path = args.params["*"] || "";
28
26
  const url = new URL(args.request.url);
@@ -1,13 +1,9 @@
1
1
  import * as rou3 from 'rou3';
2
- import { A as Autumn } from '../referralTypes-CIEzOYwT.mjs';
3
- import '../response-ByHPEnHs.mjs';
4
2
 
5
3
  type RouteData = {
6
4
  handler: any;
7
5
  requireCustomer?: boolean;
8
6
  };
9
- declare const createRouterWithOptions: ({ autumn }: {
10
- autumn: Autumn;
11
- }) => rou3.RouterContext<RouteData>;
7
+ declare const createRouterWithOptions: () => rou3.RouterContext<RouteData>;
12
8
 
13
9
  export { createRouterWithOptions };
@@ -1,13 +1,9 @@
1
1
  import * as rou3 from 'rou3';
2
- import { A as Autumn } from '../referralTypes-D6dBIcVj.js';
3
- import '../response-ByHPEnHs.js';
4
2
 
5
3
  type RouteData = {
6
4
  handler: any;
7
5
  requireCustomer?: boolean;
8
6
  };
9
- declare const createRouterWithOptions: ({ autumn }: {
10
- autumn: Autumn;
11
- }) => rou3.RouterContext<RouteData>;
7
+ declare const createRouterWithOptions: () => rou3.RouterContext<RouteData>;
12
8
 
13
9
  export { createRouterWithOptions };
@@ -318,7 +318,7 @@ var Autumn = class {
318
318
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
319
319
  } catch (error) {
320
320
  }
321
- if (!this.secretKey && !this.publishableKey) {
321
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
322
322
  throw new Error("Autumn secret key or publishable key is required");
323
323
  }
324
324
  this.headers = options?.headers || {
@@ -340,12 +340,17 @@ var Autumn = class {
340
340
  return toContainerResult(response);
341
341
  }
342
342
  async post(path, body) {
343
- const response = await fetch(`${this.url}${path}`, {
344
- method: "POST",
345
- headers: this.headers,
346
- body: JSON.stringify(body)
347
- });
348
- return toContainerResult(response);
343
+ try {
344
+ const response = await fetch(`${this.url}${path}`, {
345
+ method: "POST",
346
+ headers: this.headers,
347
+ body: JSON.stringify(body)
348
+ });
349
+ return toContainerResult(response);
350
+ } catch (error) {
351
+ console.error("Error sending request:", error);
352
+ throw error;
353
+ }
349
354
  }
350
355
  async delete(path) {
351
356
  const response = await fetch(`${this.url}${path}`, {
@@ -578,11 +583,12 @@ var checkHandler = withAuth({
578
583
  customer_data,
579
584
  body
580
585
  }) => {
581
- return await autumn.check({
586
+ const result = await autumn.check({
582
587
  ...sanitizeBody(body),
583
588
  customer_id,
584
589
  customer_data
585
590
  });
591
+ return result;
586
592
  }
587
593
  });
588
594
  var trackHandler = withAuth({
@@ -769,7 +775,7 @@ var getPricingTableHandler = withAuth({
769
775
  },
770
776
  requireCustomer: false
771
777
  });
772
- var createRouterWithOptions = ({ autumn }) => {
778
+ var createRouterWithOptions = () => {
773
779
  const router = (0, import_rou34.createRouter)();
774
780
  (0, import_rou34.addRoute)(router, "POST", `${BASE_PATH}/customers`, {
775
781
  handler: createCustomerHandler
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createRouterWithOptions
3
- } from "../chunk-MCSTMHRF.mjs";
4
- import "../chunk-J6BWOIM2.mjs";
5
- import "../chunk-R27FUM7G.mjs";
6
- import "../chunk-NXXTBCPD.mjs";
7
- import "../chunk-IWZ4KYSH.mjs";
8
- import "../chunk-52ERHSRF.mjs";
3
+ } from "../chunk-FRL4IWBU.mjs";
4
+ import "../chunk-QXJ7YDTB.mjs";
5
+ import "../chunk-NDN25XDG.mjs";
6
+ import "../chunk-NDS3EHT3.mjs";
7
+ import "../chunk-C2YFOJYP.mjs";
8
+ import "../chunk-W63TY2DI.mjs";
9
9
  import "../chunk-KSG3E4Q2.mjs";
10
10
  import "../chunk-6DZX6EAA.mjs";
11
11
  export {
@@ -319,7 +319,7 @@ var Autumn = class {
319
319
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
320
320
  } catch (error) {
321
321
  }
322
- if (!this.secretKey && !this.publishableKey) {
322
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
323
323
  throw new Error("Autumn secret key or publishable key is required");
324
324
  }
325
325
  this.headers = options?.headers || {
@@ -341,12 +341,17 @@ var Autumn = class {
341
341
  return toContainerResult(response);
342
342
  }
343
343
  async post(path, body) {
344
- const response = await fetch(`${this.url}${path}`, {
345
- method: "POST",
346
- headers: this.headers,
347
- body: JSON.stringify(body)
348
- });
349
- return toContainerResult(response);
344
+ try {
345
+ const response = await fetch(`${this.url}${path}`, {
346
+ method: "POST",
347
+ headers: this.headers,
348
+ body: JSON.stringify(body)
349
+ });
350
+ return toContainerResult(response);
351
+ } catch (error) {
352
+ console.error("Error sending request:", error);
353
+ throw error;
354
+ }
350
355
  }
351
356
  async delete(path) {
352
357
  const response = await fetch(`${this.url}${path}`, {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  addEntityRoutes
3
- } from "../chunk-J6BWOIM2.mjs";
4
- import "../chunk-IWZ4KYSH.mjs";
5
- import "../chunk-52ERHSRF.mjs";
3
+ } from "../chunk-QXJ7YDTB.mjs";
4
+ import "../chunk-C2YFOJYP.mjs";
5
+ import "../chunk-W63TY2DI.mjs";
6
6
  import "../chunk-6DZX6EAA.mjs";
7
7
  export {
8
8
  addEntityRoutes
@@ -318,7 +318,7 @@ var Autumn = class {
318
318
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
319
319
  } catch (error) {
320
320
  }
321
- if (!this.secretKey && !this.publishableKey) {
321
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
322
322
  throw new Error("Autumn secret key or publishable key is required");
323
323
  }
324
324
  this.headers = options?.headers || {
@@ -340,12 +340,17 @@ var Autumn = class {
340
340
  return toContainerResult(response);
341
341
  }
342
342
  async post(path, body) {
343
- const response = await fetch(`${this.url}${path}`, {
344
- method: "POST",
345
- headers: this.headers,
346
- body: JSON.stringify(body)
347
- });
348
- return toContainerResult(response);
343
+ try {
344
+ const response = await fetch(`${this.url}${path}`, {
345
+ method: "POST",
346
+ headers: this.headers,
347
+ body: JSON.stringify(body)
348
+ });
349
+ return toContainerResult(response);
350
+ } catch (error) {
351
+ console.error("Error sending request:", error);
352
+ throw error;
353
+ }
349
354
  }
350
355
  async delete(path) {
351
356
  const response = await fetch(`${this.url}${path}`, {
@@ -554,11 +559,12 @@ var checkHandler = withAuth({
554
559
  customer_data,
555
560
  body
556
561
  }) => {
557
- return await autumn.check({
562
+ const result = await autumn.check({
558
563
  ...sanitizeBody(body),
559
564
  customer_id,
560
565
  customer_data
561
566
  });
567
+ return result;
562
568
  }
563
569
  });
564
570
  var trackHandler = withAuth({
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  addGenRoutes
3
- } from "../chunk-R27FUM7G.mjs";
4
- import "../chunk-IWZ4KYSH.mjs";
5
- import "../chunk-52ERHSRF.mjs";
3
+ } from "../chunk-NDN25XDG.mjs";
4
+ import "../chunk-C2YFOJYP.mjs";
5
+ import "../chunk-W63TY2DI.mjs";
6
6
  import "../chunk-KSG3E4Q2.mjs";
7
7
  import "../chunk-6DZX6EAA.mjs";
8
8
  export {
@@ -319,7 +319,7 @@ var Autumn = class {
319
319
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
320
320
  } catch (error) {
321
321
  }
322
- if (!this.secretKey && !this.publishableKey) {
322
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
323
323
  throw new Error("Autumn secret key or publishable key is required");
324
324
  }
325
325
  this.headers = options?.headers || {
@@ -341,12 +341,17 @@ var Autumn = class {
341
341
  return toContainerResult(response);
342
342
  }
343
343
  async post(path, body) {
344
- const response = await fetch(`${this.url}${path}`, {
345
- method: "POST",
346
- headers: this.headers,
347
- body: JSON.stringify(body)
348
- });
349
- return toContainerResult(response);
344
+ try {
345
+ const response = await fetch(`${this.url}${path}`, {
346
+ method: "POST",
347
+ headers: this.headers,
348
+ body: JSON.stringify(body)
349
+ });
350
+ return toContainerResult(response);
351
+ } catch (error) {
352
+ console.error("Error sending request:", error);
353
+ throw error;
354
+ }
350
355
  }
351
356
  async delete(path) {
352
357
  const response = await fetch(`${this.url}${path}`, {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  addReferralRoutes
3
- } from "../chunk-NXXTBCPD.mjs";
4
- import "../chunk-IWZ4KYSH.mjs";
5
- import "../chunk-52ERHSRF.mjs";
3
+ } from "../chunk-NDS3EHT3.mjs";
4
+ import "../chunk-C2YFOJYP.mjs";
5
+ import "../chunk-W63TY2DI.mjs";
6
6
  import "../chunk-KSG3E4Q2.mjs";
7
7
  import "../chunk-6DZX6EAA.mjs";
8
8
  export {
@@ -319,7 +319,7 @@ var Autumn = class {
319
319
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
320
320
  } catch (error) {
321
321
  }
322
- if (!this.secretKey && !this.publishableKey) {
322
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
323
323
  throw new Error("Autumn secret key or publishable key is required");
324
324
  }
325
325
  this.headers = options?.headers || {
@@ -341,12 +341,17 @@ var Autumn = class {
341
341
  return toContainerResult(response);
342
342
  }
343
343
  async post(path, body) {
344
- const response = await fetch(`${this.url}${path}`, {
345
- method: "POST",
346
- headers: this.headers,
347
- body: JSON.stringify(body)
348
- });
349
- return toContainerResult(response);
344
+ try {
345
+ const response = await fetch(`${this.url}${path}`, {
346
+ method: "POST",
347
+ headers: this.headers,
348
+ body: JSON.stringify(body)
349
+ });
350
+ return toContainerResult(response);
351
+ } catch (error) {
352
+ console.error("Error sending request:", error);
353
+ throw error;
354
+ }
350
355
  }
351
356
  async delete(path) {
352
357
  const response = await fetch(`${this.url}${path}`, {
@@ -580,11 +585,12 @@ var checkHandler = withAuth({
580
585
  customer_data,
581
586
  body
582
587
  }) => {
583
- return await autumn.check({
588
+ const result = await autumn.check({
584
589
  ...sanitizeBody(body),
585
590
  customer_id,
586
591
  customer_data
587
592
  });
593
+ return result;
588
594
  }
589
595
  });
590
596
  var trackHandler = withAuth({
@@ -771,7 +777,7 @@ var getPricingTableHandler = withAuth({
771
777
  },
772
778
  requireCustomer: false
773
779
  });
774
- var createRouterWithOptions = ({ autumn }) => {
780
+ var createRouterWithOptions = () => {
775
781
  const router = (0, import_rou34.createRouter)();
776
782
  (0, import_rou34.addRoute)(router, "POST", `${BASE_PATH}/customers`, {
777
783
  handler: createCustomerHandler
@@ -798,9 +804,7 @@ function autumnHandler(options) {
798
804
  url: autumnApiUrl,
799
805
  secretKey
800
806
  });
801
- const router = createRouterWithOptions({
802
- autumn
803
- });
807
+ const router = createRouterWithOptions();
804
808
  return async function handler(request) {
805
809
  const method = request.method;
806
810
  const url = new URL(request.url);
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createRouterWithOptions
3
- } from "./chunk-MCSTMHRF.mjs";
4
- import "./chunk-J6BWOIM2.mjs";
5
- import "./chunk-R27FUM7G.mjs";
6
- import "./chunk-NXXTBCPD.mjs";
7
- import "./chunk-IWZ4KYSH.mjs";
3
+ } from "./chunk-FRL4IWBU.mjs";
4
+ import "./chunk-QXJ7YDTB.mjs";
5
+ import "./chunk-NDN25XDG.mjs";
6
+ import "./chunk-NDS3EHT3.mjs";
7
+ import "./chunk-C2YFOJYP.mjs";
8
8
  import {
9
9
  Autumn
10
- } from "./chunk-52ERHSRF.mjs";
10
+ } from "./chunk-W63TY2DI.mjs";
11
11
  import {
12
12
  autumnApiUrl
13
13
  } from "./chunk-KSG3E4Q2.mjs";
@@ -26,9 +26,7 @@ function autumnHandler(options) {
26
26
  url: autumnApiUrl,
27
27
  secretKey
28
28
  });
29
- const router = createRouterWithOptions({
30
- autumn
31
- });
29
+ const router = createRouterWithOptions();
32
30
  return async function handler(request) {
33
31
  const method = request.method;
34
32
  const url = new URL(request.url);
@@ -319,7 +319,7 @@ var Autumn = class {
319
319
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
320
320
  } catch (error) {
321
321
  }
322
- if (!this.secretKey && !this.publishableKey) {
322
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
323
323
  throw new Error("Autumn secret key or publishable key is required");
324
324
  }
325
325
  this.headers = options?.headers || {
@@ -341,12 +341,17 @@ var Autumn = class {
341
341
  return toContainerResult(response);
342
342
  }
343
343
  async post(path, body) {
344
- const response = await fetch(`${this.url}${path}`, {
345
- method: "POST",
346
- headers: this.headers,
347
- body: JSON.stringify(body)
348
- });
349
- return toContainerResult(response);
344
+ try {
345
+ const response = await fetch(`${this.url}${path}`, {
346
+ method: "POST",
347
+ headers: this.headers,
348
+ body: JSON.stringify(body)
349
+ });
350
+ return toContainerResult(response);
351
+ } catch (error) {
352
+ console.error("Error sending request:", error);
353
+ throw error;
354
+ }
350
355
  }
351
356
  async delete(path) {
352
357
  const response = await fetch(`${this.url}${path}`, {
@@ -578,11 +583,12 @@ var checkHandler = withAuth({
578
583
  customer_data,
579
584
  body
580
585
  }) => {
581
- return await autumn.check({
586
+ const result = await autumn.check({
582
587
  ...sanitizeBody(body),
583
588
  customer_id,
584
589
  customer_data
585
590
  });
591
+ return result;
586
592
  }
587
593
  });
588
594
  var trackHandler = withAuth({
@@ -769,7 +775,7 @@ var getPricingTableHandler = withAuth({
769
775
  },
770
776
  requireCustomer: false
771
777
  });
772
- var createRouterWithOptions = ({ autumn }) => {
778
+ var createRouterWithOptions = () => {
773
779
  const router = (0, import_rou34.createRouter)();
774
780
  (0, import_rou34.addRoute)(router, "POST", `${BASE_PATH}/customers`, {
775
781
  handler: createCustomerHandler
@@ -885,9 +891,7 @@ var autumnHandler = (options) => {
885
891
  url: autumnApiUrl,
886
892
  version: options.version
887
893
  });
888
- const router = createRouterWithOptions({
889
- autumn
890
- });
894
+ const router = createRouterWithOptions();
891
895
  const handleRequest = async (ctx) => {
892
896
  const { request } = ctx;
893
897
  const url = new URL(request.url);
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createRouterWithOptions
3
- } from "./chunk-MCSTMHRF.mjs";
4
- import "./chunk-J6BWOIM2.mjs";
5
- import "./chunk-R27FUM7G.mjs";
6
- import "./chunk-NXXTBCPD.mjs";
7
- import "./chunk-IWZ4KYSH.mjs";
3
+ } from "./chunk-FRL4IWBU.mjs";
4
+ import "./chunk-QXJ7YDTB.mjs";
5
+ import "./chunk-NDN25XDG.mjs";
6
+ import "./chunk-NDS3EHT3.mjs";
7
+ import "./chunk-C2YFOJYP.mjs";
8
8
  import {
9
9
  Autumn
10
- } from "./chunk-52ERHSRF.mjs";
10
+ } from "./chunk-W63TY2DI.mjs";
11
11
  import {
12
12
  autumnApiUrl
13
13
  } from "./chunk-KSG3E4Q2.mjs";
@@ -117,9 +117,7 @@ var autumnHandler = (options) => {
117
117
  url: autumnApiUrl,
118
118
  version: options.version
119
119
  });
120
- const router = createRouterWithOptions({
121
- autumn
122
- });
120
+ const router = createRouterWithOptions();
123
121
  const handleRequest = async (ctx) => {
124
122
  const { request } = ctx;
125
123
  const url = new URL(request.url);
@@ -319,7 +319,7 @@ var Autumn = class {
319
319
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
320
320
  } catch (error) {
321
321
  }
322
- if (!this.secretKey && !this.publishableKey) {
322
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
323
323
  throw new Error("Autumn secret key or publishable key is required");
324
324
  }
325
325
  this.headers = options?.headers || {
@@ -341,12 +341,17 @@ var Autumn = class {
341
341
  return toContainerResult(response);
342
342
  }
343
343
  async post(path, body) {
344
- const response = await fetch(`${this.url}${path}`, {
345
- method: "POST",
346
- headers: this.headers,
347
- body: JSON.stringify(body)
348
- });
349
- return toContainerResult(response);
344
+ try {
345
+ const response = await fetch(`${this.url}${path}`, {
346
+ method: "POST",
347
+ headers: this.headers,
348
+ body: JSON.stringify(body)
349
+ });
350
+ return toContainerResult(response);
351
+ } catch (error) {
352
+ console.error("Error sending request:", error);
353
+ throw error;
354
+ }
350
355
  }
351
356
  async delete(path) {
352
357
  const response = await fetch(`${this.url}${path}`, {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  toBackendError,
3
3
  toBackendRes
4
- } from "../chunk-52ERHSRF.mjs";
4
+ } from "../chunk-W63TY2DI.mjs";
5
5
  import "../chunk-6DZX6EAA.mjs";
6
6
  export {
7
7
  toBackendError,
@@ -1,4 +1,4 @@
1
- import { A as Autumn, C as CustomerData } from '../referralTypes-CIEzOYwT.mjs';
1
+ import { A as Autumn, C as CustomerData } from '../referralTypes-DmqKXhXe.mjs';
2
2
  import { AuthResult } from './AuthFunction.mjs';
3
3
  import '../response-ByHPEnHs.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as Autumn, C as CustomerData } from '../referralTypes-D6dBIcVj.js';
1
+ import { A as Autumn, C as CustomerData } from '../referralTypes-CJPslVLJ.js';
2
2
  import { AuthResult } from './AuthFunction.js';
3
3
  import '../response-ByHPEnHs.js';
4
4
 
@@ -318,7 +318,7 @@ var Autumn = class {
318
318
  this.publishableKey = options?.publishableKey || process.env.AUTUMN_PUBLISHABLE_KEY;
319
319
  } catch (error) {
320
320
  }
321
- if (!this.secretKey && !this.publishableKey) {
321
+ if (!this.secretKey && !this.publishableKey && !options?.headers) {
322
322
  throw new Error("Autumn secret key or publishable key is required");
323
323
  }
324
324
  this.headers = options?.headers || {
@@ -340,12 +340,17 @@ var Autumn = class {
340
340
  return toContainerResult(response);
341
341
  }
342
342
  async post(path, body) {
343
- const response = await fetch(`${this.url}${path}`, {
344
- method: "POST",
345
- headers: this.headers,
346
- body: JSON.stringify(body)
347
- });
348
- return toContainerResult(response);
343
+ try {
344
+ const response = await fetch(`${this.url}${path}`, {
345
+ method: "POST",
346
+ headers: this.headers,
347
+ body: JSON.stringify(body)
348
+ });
349
+ return toContainerResult(response);
350
+ } catch (error) {
351
+ console.error("Error sending request:", error);
352
+ throw error;
353
+ }
349
354
  }
350
355
  async delete(path) {
351
356
  const response = await fetch(`${this.url}${path}`, {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  withAuth
3
- } from "../chunk-IWZ4KYSH.mjs";
4
- import "../chunk-52ERHSRF.mjs";
3
+ } from "../chunk-C2YFOJYP.mjs";
4
+ import "../chunk-W63TY2DI.mjs";
5
5
  import "../chunk-6DZX6EAA.mjs";
6
6
  export {
7
7
  withAuth