autumn-js 1.1.7 → 1.1.10

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 (107) hide show
  1. package/dist/backend/adapters/express.js +122 -6
  2. package/dist/backend/adapters/express.mjs +9 -9
  3. package/dist/backend/adapters/fetch.js +122 -6
  4. package/dist/backend/adapters/fetch.mjs +9 -9
  5. package/dist/backend/adapters/hono.js +122 -6
  6. package/dist/backend/adapters/hono.mjs +9 -9
  7. package/dist/backend/adapters/index.js +122 -6
  8. package/dist/backend/adapters/index.mjs +12 -12
  9. package/dist/backend/adapters/next.js +122 -6
  10. package/dist/backend/adapters/next.mjs +9 -9
  11. package/dist/backend/{chunk-PP6UQYJS.mjs → chunk-3N5JKLZU.mjs} +1 -1
  12. package/dist/backend/{chunk-JUZDG66W.mjs → chunk-CS4R7BU4.mjs} +5 -5
  13. package/dist/backend/{chunk-X2ZQ7KI7.mjs → chunk-HG52KOLU.mjs} +1 -1
  14. package/dist/backend/{chunk-BNTQ4ECE.mjs → chunk-NKLPJAWS.mjs} +1 -1
  15. package/dist/backend/{chunk-VDKSZFDB.mjs → chunk-NSXJQETG.mjs} +4 -2
  16. package/dist/backend/{chunk-ZPZ7FFHT.mjs → chunk-RGUUMXFG.mjs} +118 -4
  17. package/dist/backend/{chunk-PX3QACWR.mjs → chunk-SBTEC637.mjs} +1 -1
  18. package/dist/backend/{chunk-NYHWQDP6.mjs → chunk-TC6BT3QN.mjs} +7 -7
  19. package/dist/backend/core/handlers/coreHandler.d.mts +1 -1
  20. package/dist/backend/core/handlers/coreHandler.d.ts +1 -1
  21. package/dist/backend/core/handlers/coreHandler.js +122 -6
  22. package/dist/backend/core/handlers/coreHandler.mjs +7 -7
  23. package/dist/backend/core/handlers/executeRoute.d.mts +1 -1
  24. package/dist/backend/core/handlers/executeRoute.d.ts +1 -1
  25. package/dist/backend/core/handlers/executeRoute.mjs +4 -4
  26. package/dist/backend/core/handlers/handleRouteByName.js +122 -6
  27. package/dist/backend/core/handlers/handleRouteByName.mjs +7 -7
  28. package/dist/backend/core/handlers/index.d.mts +1 -1
  29. package/dist/backend/core/handlers/index.d.ts +1 -1
  30. package/dist/backend/core/handlers/index.js +122 -6
  31. package/dist/backend/core/handlers/index.mjs +10 -10
  32. package/dist/backend/core/index.d.mts +1 -1
  33. package/dist/backend/core/index.d.ts +1 -1
  34. package/dist/backend/core/index.js +122 -6
  35. package/dist/backend/core/index.mjs +10 -10
  36. package/dist/backend/core/routes/index.d.mts +1 -1
  37. package/dist/backend/core/routes/index.d.ts +1 -1
  38. package/dist/backend/core/routes/index.js +4 -2
  39. package/dist/backend/core/routes/index.mjs +2 -2
  40. package/dist/backend/core/routes/routeBuilder.d.mts +1 -1
  41. package/dist/backend/core/routes/routeBuilder.d.ts +1 -1
  42. package/dist/backend/core/routes/routeConfigs.d.mts +1 -1
  43. package/dist/backend/core/routes/routeConfigs.d.ts +1 -1
  44. package/dist/backend/core/routes/routeConfigs.js +4 -2
  45. package/dist/backend/core/routes/routeConfigs.mjs +2 -2
  46. package/dist/backend/core/types/handlerTypes.d.mts +1 -1
  47. package/dist/backend/core/types/handlerTypes.d.ts +1 -1
  48. package/dist/backend/core/types/index.d.mts +1 -1
  49. package/dist/backend/core/types/index.d.ts +1 -1
  50. package/dist/backend/core/types/routeTypes.d.mts +1 -1
  51. package/dist/backend/core/types/routeTypes.d.ts +1 -1
  52. package/dist/backend/core/utils/index.mjs +3 -3
  53. package/dist/backend/index.d.mts +2 -2
  54. package/dist/backend/index.d.ts +2 -2
  55. package/dist/backend/index.js +122 -6
  56. package/dist/backend/index.mjs +10 -10
  57. package/dist/backend/{routeTypes-COJtRKM-.d.ts → routeTypes-CpYmkN-b.d.ts} +4 -0
  58. package/dist/backend/{routeTypes-BTLwfLzU.d.mts → routeTypes-mZBR-uVw.d.mts} +4 -0
  59. package/dist/better-auth/{chunk-GVZ475U2.mjs → chunk-6YDKA7Z5.mjs} +1 -1
  60. package/dist/better-auth/{chunk-KVCXG6IW.mjs → chunk-AHCYYKBC.mjs} +4 -2
  61. package/dist/better-auth/{chunk-WVO7XICO.mjs → chunk-SASLAUVA.mjs} +119 -5
  62. package/dist/better-auth/index.js +122 -6
  63. package/dist/better-auth/index.mjs +3 -3
  64. package/dist/better-auth/utils/createAutumnEndpoint.js +4 -2
  65. package/dist/better-auth/utils/createAutumnEndpoint.mjs +2 -2
  66. package/dist/better-auth/utils/handleBetterAuthRoute.js +122 -6
  67. package/dist/better-auth/utils/handleBetterAuthRoute.mjs +2 -2
  68. package/dist/better-auth/utils/index.js +122 -6
  69. package/dist/better-auth/utils/index.mjs +3 -3
  70. package/dist/react/AutumnContext.d.mts +1 -1
  71. package/dist/react/AutumnContext.d.ts +1 -1
  72. package/dist/react/client/AutumnClient.d.mts +1 -1
  73. package/dist/react/client/AutumnClient.d.ts +1 -1
  74. package/dist/react/client/IAutumnClient.d.mts +1 -1
  75. package/dist/react/client/IAutumnClient.d.ts +1 -1
  76. package/dist/react/client/index.d.mts +1 -1
  77. package/dist/react/client/index.d.ts +1 -1
  78. package/dist/react/hooks/index.d.mts +1 -1
  79. package/dist/react/hooks/index.d.ts +1 -1
  80. package/dist/react/hooks/index.mjs +9 -9
  81. package/dist/react/hooks/internal/getLocalCheckResponse.d.mts +1 -1
  82. package/dist/react/hooks/internal/getLocalCheckResponse.d.ts +1 -1
  83. package/dist/react/hooks/internal/useCustomerActions.d.mts +1 -1
  84. package/dist/react/hooks/internal/useCustomerActions.d.ts +1 -1
  85. package/dist/react/hooks/useAggregateEvents.d.mts +1 -1
  86. package/dist/react/hooks/useAggregateEvents.d.ts +1 -1
  87. package/dist/react/hooks/useCustomer.d.mts +1 -1
  88. package/dist/react/hooks/useCustomer.d.ts +1 -1
  89. package/dist/react/hooks/useEntity.d.mts +1 -1
  90. package/dist/react/hooks/useEntity.d.ts +1 -1
  91. package/dist/react/hooks/useListEvents.d.mts +1 -1
  92. package/dist/react/hooks/useListEvents.d.ts +1 -1
  93. package/dist/react/hooks/useListPlans.d.mts +1 -1
  94. package/dist/react/hooks/useListPlans.d.ts +1 -1
  95. package/dist/react/hooks/useReferrals.d.mts +1 -1
  96. package/dist/react/hooks/useReferrals.d.ts +1 -1
  97. package/dist/react/index.d.mts +1 -1
  98. package/dist/react/index.d.ts +1 -1
  99. package/dist/react/index.mjs +10 -10
  100. package/dist/react/{params-CULG2g_G.d.ts → params-BJe02wWl.d.ts} +4 -0
  101. package/dist/react/{params-D0knGGE_.d.mts → params-DQdWUztN.d.mts} +4 -0
  102. package/dist/sdk/index.d.mts +7 -2
  103. package/dist/sdk/index.d.ts +7 -2
  104. package/dist/sdk/index.js +120 -4
  105. package/dist/sdk/index.mjs +120 -4
  106. package/package.json +142 -142
  107. package/dist/backend/{chunk-55C2WWXQ.mjs → chunk-S5HPMJ4U.mjs} +3 -3
@@ -78,8 +78,8 @@ var SDK_METADATA = {
78
78
  language: "typescript",
79
79
  openapiDocVersion: "2.2.0",
80
80
  sdkVersion: "0.10.17",
81
- genVersion: "2.869.23",
82
- userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.23 2.2.0 @useautumn/sdk"
81
+ genVersion: "2.869.25",
82
+ userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.25 2.2.0 @useautumn/sdk"
83
83
  };
84
84
 
85
85
  // ../sdk/src/lib/http.ts
@@ -1336,7 +1336,8 @@ var EventsAggregateParams$outboundSchema = z8.pipe(
1336
1336
  binSize: z8._default(BinSize$outboundSchema, "day"),
1337
1337
  customRange: z8.optional(
1338
1338
  z8.lazy(() => AggregateEventsCustomRange$outboundSchema)
1339
- )
1339
+ ),
1340
+ maxGroups: z8.optional(z8.int())
1340
1341
  }),
1341
1342
  z8.transform((v) => {
1342
1343
  return remap(v, {
@@ -1345,7 +1346,8 @@ var EventsAggregateParams$outboundSchema = z8.pipe(
1345
1346
  featureId: "feature_id",
1346
1347
  groupBy: "group_by",
1347
1348
  binSize: "bin_size",
1348
- customRange: "custom_range"
1349
+ customRange: "custom_range",
1350
+ maxGroups: "max_groups"
1349
1351
  });
1350
1352
  })
1351
1353
  );
@@ -9724,6 +9726,117 @@ async function $do2(client, request, options) {
9724
9726
  return [result, { status: "complete", request: req, response }];
9725
9727
  }
9726
9728
 
9729
+ // ../sdk/src/hooks/failOpenHook.ts
9730
+ var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
9731
+ "check",
9732
+ "track",
9733
+ "getOrCreateCustomer"
9734
+ ]);
9735
+ var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
9736
+ var FAIL_OPEN_BODIES = {
9737
+ check: {
9738
+ allowed: true,
9739
+ customer_id: null,
9740
+ balance: null,
9741
+ flag: null
9742
+ },
9743
+ track: {
9744
+ customer_id: null,
9745
+ value: 0,
9746
+ balance: null
9747
+ },
9748
+ getOrCreateCustomer: {
9749
+ id: null,
9750
+ name: null,
9751
+ email: null,
9752
+ created_at: 0,
9753
+ fingerprint: null,
9754
+ stripe_id: null,
9755
+ env: "live",
9756
+ metadata: {},
9757
+ send_email_receipts: false,
9758
+ billing_controls: {},
9759
+ subscriptions: [],
9760
+ purchases: [],
9761
+ balances: {},
9762
+ flags: {}
9763
+ }
9764
+ };
9765
+ var FailOpenHook = class {
9766
+ enabled = true;
9767
+ sdkInit(opts) {
9768
+ if (opts.failOpen === false) {
9769
+ this.enabled = false;
9770
+ return opts;
9771
+ }
9772
+ this.enabled = true;
9773
+ opts.httpClient = new HTTPClient({
9774
+ fetcher: async (input, init) => {
9775
+ try {
9776
+ return init == null ? await fetch(input) : await fetch(input, init);
9777
+ } catch {
9778
+ return new Response(null, {
9779
+ status: 503,
9780
+ statusText: "Autumn Unreachable"
9781
+ });
9782
+ }
9783
+ }
9784
+ });
9785
+ return opts;
9786
+ }
9787
+ afterError(hookCtx, response, error) {
9788
+ if (!this.enabled) {
9789
+ return { response, error };
9790
+ }
9791
+ if (!response || response.status < 500) {
9792
+ return { response, error };
9793
+ }
9794
+ if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
9795
+ return { response, error };
9796
+ }
9797
+ const body = FAIL_OPEN_BODIES[hookCtx.operationID];
9798
+ if (!body) {
9799
+ return { response, error };
9800
+ }
9801
+ console.error(FAIL_OPEN_LOG_MESSAGE);
9802
+ console.error(
9803
+ ` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
9804
+ );
9805
+ return {
9806
+ response: new Response(JSON.stringify(body), {
9807
+ status: 200,
9808
+ headers: { "Content-Type": "application/json" }
9809
+ }),
9810
+ error: null
9811
+ };
9812
+ }
9813
+ };
9814
+
9815
+ // ../sdk/src/hooks/timeoutFixHook.ts
9816
+ var DEFAULT_TIMEOUT_MS = 5e3;
9817
+ var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
9818
+ var TimeoutFixHook = class {
9819
+ beforeRequest(hookCtx, request) {
9820
+ let timeoutMs = hookCtx.options.timeoutMs;
9821
+ if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
9822
+ timeoutMs = DEFAULT_TIMEOUT_MS;
9823
+ if (!timeoutMs || timeoutMs <= 0) return request;
9824
+ const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
9825
+ return new Request(request, {
9826
+ signal
9827
+ });
9828
+ }
9829
+ };
9830
+
9831
+ // ../sdk/src/hooks/registration.ts
9832
+ function initHooks(hooks) {
9833
+ const failOpenHook = new FailOpenHook();
9834
+ const timeoutFixHook = new TimeoutFixHook();
9835
+ hooks.registerSDKInitHook(failOpenHook);
9836
+ hooks.registerBeforeRequestHook(timeoutFixHook);
9837
+ hooks.registerAfterErrorHook(failOpenHook);
9838
+ }
9839
+
9727
9840
  // ../sdk/src/hooks/hooks.ts
9728
9841
  var SDKHooks = class {
9729
9842
  sdkInitHooks = [];
@@ -9732,6 +9845,7 @@ var SDKHooks = class {
9732
9845
  afterSuccessHooks = [];
9733
9846
  afterErrorHooks = [];
9734
9847
  constructor() {
9848
+ initHooks(this);
9735
9849
  const presetHooks = [];
9736
9850
  for (const hook of presetHooks) {
9737
9851
  if ("sdkInit" in hook) {
@@ -13920,7 +14034,8 @@ var eventsAggregateParamsOutboundSchema = import_v4.z.object({
13920
14034
  group_by: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13921
14035
  range: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13922
14036
  bin_size: import_v4.z.string(),
13923
- custom_range: import_v4.z.union([aggregateEventsCustomRangeOutboundSchema, import_v4.z.undefined()]).optional()
14037
+ custom_range: import_v4.z.union([aggregateEventsCustomRangeOutboundSchema, import_v4.z.undefined()]).optional(),
14038
+ max_groups: import_v4.z.union([import_v4.z.number(), import_v4.z.undefined()]).optional()
13924
14039
  });
13925
14040
  var closedEnumSchema = import_v4.z.any();
13926
14041
  var rangeSchema = closedEnumSchema;
@@ -13932,7 +14047,8 @@ var eventsAggregateParamsSchema = import_v4.z.object({
13932
14047
  groupBy: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13933
14048
  range: import_v4.z.union([rangeSchema, import_v4.z.undefined()]).optional(),
13934
14049
  binSize: import_v4.z.union([binSizeSchema, import_v4.z.undefined()]).optional(),
13935
- customRange: import_v4.z.union([aggregateEventsCustomRangeSchema, import_v4.z.undefined()]).optional()
14050
+ customRange: import_v4.z.union([aggregateEventsCustomRangeSchema, import_v4.z.undefined()]).optional(),
14051
+ maxGroups: import_v4.z.union([import_v4.z.number(), import_v4.z.undefined()]).optional()
13936
14052
  });
13937
14053
 
13938
14054
  // src/generated/attachSchemas.ts
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  autumnHandler
3
- } from "../chunk-X2ZQ7KI7.mjs";
3
+ } from "../chunk-HG52KOLU.mjs";
4
4
  import "../chunk-WYDGEDEU.mjs";
5
5
  import "../chunk-VXND2UDT.mjs";
6
- import "../chunk-JUZDG66W.mjs";
7
- import "../chunk-NYHWQDP6.mjs";
8
- import "../chunk-ZPZ7FFHT.mjs";
9
- import "../chunk-55C2WWXQ.mjs";
10
- import "../chunk-TBQ27LIK.mjs";
11
- import "../chunk-J44WR3QZ.mjs";
6
+ import "../chunk-CS4R7BU4.mjs";
7
+ import "../chunk-TC6BT3QN.mjs";
12
8
  import "../chunk-TSF4YCUO.mjs";
13
9
  import "../chunk-UAR3TMWI.mjs";
14
- import "../chunk-VDKSZFDB.mjs";
10
+ import "../chunk-RGUUMXFG.mjs";
11
+ import "../chunk-NSXJQETG.mjs";
12
+ import "../chunk-S5HPMJ4U.mjs";
15
13
  import "../chunk-OTXV5FY7.mjs";
16
- import "../chunk-VZIMT7AO.mjs";
17
14
  import "../chunk-Z6QP3YEA.mjs";
15
+ import "../chunk-VZIMT7AO.mjs";
16
+ import "../chunk-TBQ27LIK.mjs";
17
+ import "../chunk-J44WR3QZ.mjs";
18
18
  import "../chunk-N7NFYY54.mjs";
19
19
  export {
20
20
  autumnHandler
@@ -78,8 +78,8 @@ var SDK_METADATA = {
78
78
  language: "typescript",
79
79
  openapiDocVersion: "2.2.0",
80
80
  sdkVersion: "0.10.17",
81
- genVersion: "2.869.23",
82
- userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.23 2.2.0 @useautumn/sdk"
81
+ genVersion: "2.869.25",
82
+ userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.25 2.2.0 @useautumn/sdk"
83
83
  };
84
84
 
85
85
  // ../sdk/src/lib/http.ts
@@ -1336,7 +1336,8 @@ var EventsAggregateParams$outboundSchema = z8.pipe(
1336
1336
  binSize: z8._default(BinSize$outboundSchema, "day"),
1337
1337
  customRange: z8.optional(
1338
1338
  z8.lazy(() => AggregateEventsCustomRange$outboundSchema)
1339
- )
1339
+ ),
1340
+ maxGroups: z8.optional(z8.int())
1340
1341
  }),
1341
1342
  z8.transform((v) => {
1342
1343
  return remap(v, {
@@ -1345,7 +1346,8 @@ var EventsAggregateParams$outboundSchema = z8.pipe(
1345
1346
  featureId: "feature_id",
1346
1347
  groupBy: "group_by",
1347
1348
  binSize: "bin_size",
1348
- customRange: "custom_range"
1349
+ customRange: "custom_range",
1350
+ maxGroups: "max_groups"
1349
1351
  });
1350
1352
  })
1351
1353
  );
@@ -9724,6 +9726,117 @@ async function $do2(client, request, options) {
9724
9726
  return [result, { status: "complete", request: req, response }];
9725
9727
  }
9726
9728
 
9729
+ // ../sdk/src/hooks/failOpenHook.ts
9730
+ var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
9731
+ "check",
9732
+ "track",
9733
+ "getOrCreateCustomer"
9734
+ ]);
9735
+ var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
9736
+ var FAIL_OPEN_BODIES = {
9737
+ check: {
9738
+ allowed: true,
9739
+ customer_id: null,
9740
+ balance: null,
9741
+ flag: null
9742
+ },
9743
+ track: {
9744
+ customer_id: null,
9745
+ value: 0,
9746
+ balance: null
9747
+ },
9748
+ getOrCreateCustomer: {
9749
+ id: null,
9750
+ name: null,
9751
+ email: null,
9752
+ created_at: 0,
9753
+ fingerprint: null,
9754
+ stripe_id: null,
9755
+ env: "live",
9756
+ metadata: {},
9757
+ send_email_receipts: false,
9758
+ billing_controls: {},
9759
+ subscriptions: [],
9760
+ purchases: [],
9761
+ balances: {},
9762
+ flags: {}
9763
+ }
9764
+ };
9765
+ var FailOpenHook = class {
9766
+ enabled = true;
9767
+ sdkInit(opts) {
9768
+ if (opts.failOpen === false) {
9769
+ this.enabled = false;
9770
+ return opts;
9771
+ }
9772
+ this.enabled = true;
9773
+ opts.httpClient = new HTTPClient({
9774
+ fetcher: async (input, init) => {
9775
+ try {
9776
+ return init == null ? await fetch(input) : await fetch(input, init);
9777
+ } catch {
9778
+ return new Response(null, {
9779
+ status: 503,
9780
+ statusText: "Autumn Unreachable"
9781
+ });
9782
+ }
9783
+ }
9784
+ });
9785
+ return opts;
9786
+ }
9787
+ afterError(hookCtx, response, error) {
9788
+ if (!this.enabled) {
9789
+ return { response, error };
9790
+ }
9791
+ if (!response || response.status < 500) {
9792
+ return { response, error };
9793
+ }
9794
+ if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
9795
+ return { response, error };
9796
+ }
9797
+ const body = FAIL_OPEN_BODIES[hookCtx.operationID];
9798
+ if (!body) {
9799
+ return { response, error };
9800
+ }
9801
+ console.error(FAIL_OPEN_LOG_MESSAGE);
9802
+ console.error(
9803
+ ` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
9804
+ );
9805
+ return {
9806
+ response: new Response(JSON.stringify(body), {
9807
+ status: 200,
9808
+ headers: { "Content-Type": "application/json" }
9809
+ }),
9810
+ error: null
9811
+ };
9812
+ }
9813
+ };
9814
+
9815
+ // ../sdk/src/hooks/timeoutFixHook.ts
9816
+ var DEFAULT_TIMEOUT_MS = 5e3;
9817
+ var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
9818
+ var TimeoutFixHook = class {
9819
+ beforeRequest(hookCtx, request) {
9820
+ let timeoutMs = hookCtx.options.timeoutMs;
9821
+ if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
9822
+ timeoutMs = DEFAULT_TIMEOUT_MS;
9823
+ if (!timeoutMs || timeoutMs <= 0) return request;
9824
+ const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
9825
+ return new Request(request, {
9826
+ signal
9827
+ });
9828
+ }
9829
+ };
9830
+
9831
+ // ../sdk/src/hooks/registration.ts
9832
+ function initHooks(hooks) {
9833
+ const failOpenHook = new FailOpenHook();
9834
+ const timeoutFixHook = new TimeoutFixHook();
9835
+ hooks.registerSDKInitHook(failOpenHook);
9836
+ hooks.registerBeforeRequestHook(timeoutFixHook);
9837
+ hooks.registerAfterErrorHook(failOpenHook);
9838
+ }
9839
+
9727
9840
  // ../sdk/src/hooks/hooks.ts
9728
9841
  var SDKHooks = class {
9729
9842
  sdkInitHooks = [];
@@ -9732,6 +9845,7 @@ var SDKHooks = class {
9732
9845
  afterSuccessHooks = [];
9733
9846
  afterErrorHooks = [];
9734
9847
  constructor() {
9848
+ initHooks(this);
9735
9849
  const presetHooks = [];
9736
9850
  for (const hook of presetHooks) {
9737
9851
  if ("sdkInit" in hook) {
@@ -13920,7 +14034,8 @@ var eventsAggregateParamsOutboundSchema = import_v4.z.object({
13920
14034
  group_by: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13921
14035
  range: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13922
14036
  bin_size: import_v4.z.string(),
13923
- custom_range: import_v4.z.union([aggregateEventsCustomRangeOutboundSchema, import_v4.z.undefined()]).optional()
14037
+ custom_range: import_v4.z.union([aggregateEventsCustomRangeOutboundSchema, import_v4.z.undefined()]).optional(),
14038
+ max_groups: import_v4.z.union([import_v4.z.number(), import_v4.z.undefined()]).optional()
13924
14039
  });
13925
14040
  var closedEnumSchema = import_v4.z.any();
13926
14041
  var rangeSchema = closedEnumSchema;
@@ -13932,7 +14047,8 @@ var eventsAggregateParamsSchema = import_v4.z.object({
13932
14047
  groupBy: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13933
14048
  range: import_v4.z.union([rangeSchema, import_v4.z.undefined()]).optional(),
13934
14049
  binSize: import_v4.z.union([binSizeSchema, import_v4.z.undefined()]).optional(),
13935
- customRange: import_v4.z.union([aggregateEventsCustomRangeSchema, import_v4.z.undefined()]).optional()
14050
+ customRange: import_v4.z.union([aggregateEventsCustomRangeSchema, import_v4.z.undefined()]).optional(),
14051
+ maxGroups: import_v4.z.union([import_v4.z.number(), import_v4.z.undefined()]).optional()
13936
14052
  });
13937
14053
 
13938
14054
  // src/generated/attachSchemas.ts
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  autumnHandler
3
- } from "../chunk-PP6UQYJS.mjs";
3
+ } from "../chunk-3N5JKLZU.mjs";
4
4
  import "../chunk-WYDGEDEU.mjs";
5
5
  import "../chunk-VXND2UDT.mjs";
6
- import "../chunk-JUZDG66W.mjs";
7
- import "../chunk-NYHWQDP6.mjs";
8
- import "../chunk-ZPZ7FFHT.mjs";
9
- import "../chunk-55C2WWXQ.mjs";
10
- import "../chunk-TBQ27LIK.mjs";
11
- import "../chunk-J44WR3QZ.mjs";
6
+ import "../chunk-CS4R7BU4.mjs";
7
+ import "../chunk-TC6BT3QN.mjs";
12
8
  import "../chunk-TSF4YCUO.mjs";
13
9
  import "../chunk-UAR3TMWI.mjs";
14
- import "../chunk-VDKSZFDB.mjs";
10
+ import "../chunk-RGUUMXFG.mjs";
11
+ import "../chunk-NSXJQETG.mjs";
12
+ import "../chunk-S5HPMJ4U.mjs";
15
13
  import "../chunk-OTXV5FY7.mjs";
16
- import "../chunk-VZIMT7AO.mjs";
17
14
  import "../chunk-Z6QP3YEA.mjs";
15
+ import "../chunk-VZIMT7AO.mjs";
16
+ import "../chunk-TBQ27LIK.mjs";
17
+ import "../chunk-J44WR3QZ.mjs";
18
18
  import "../chunk-N7NFYY54.mjs";
19
19
  export {
20
20
  autumnHandler
@@ -78,8 +78,8 @@ var SDK_METADATA = {
78
78
  language: "typescript",
79
79
  openapiDocVersion: "2.2.0",
80
80
  sdkVersion: "0.10.17",
81
- genVersion: "2.869.23",
82
- userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.23 2.2.0 @useautumn/sdk"
81
+ genVersion: "2.869.25",
82
+ userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.25 2.2.0 @useautumn/sdk"
83
83
  };
84
84
 
85
85
  // ../sdk/src/lib/http.ts
@@ -1336,7 +1336,8 @@ var EventsAggregateParams$outboundSchema = z8.pipe(
1336
1336
  binSize: z8._default(BinSize$outboundSchema, "day"),
1337
1337
  customRange: z8.optional(
1338
1338
  z8.lazy(() => AggregateEventsCustomRange$outboundSchema)
1339
- )
1339
+ ),
1340
+ maxGroups: z8.optional(z8.int())
1340
1341
  }),
1341
1342
  z8.transform((v) => {
1342
1343
  return remap(v, {
@@ -1345,7 +1346,8 @@ var EventsAggregateParams$outboundSchema = z8.pipe(
1345
1346
  featureId: "feature_id",
1346
1347
  groupBy: "group_by",
1347
1348
  binSize: "bin_size",
1348
- customRange: "custom_range"
1349
+ customRange: "custom_range",
1350
+ maxGroups: "max_groups"
1349
1351
  });
1350
1352
  })
1351
1353
  );
@@ -9724,6 +9726,117 @@ async function $do2(client, request, options) {
9724
9726
  return [result, { status: "complete", request: req, response }];
9725
9727
  }
9726
9728
 
9729
+ // ../sdk/src/hooks/failOpenHook.ts
9730
+ var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
9731
+ "check",
9732
+ "track",
9733
+ "getOrCreateCustomer"
9734
+ ]);
9735
+ var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
9736
+ var FAIL_OPEN_BODIES = {
9737
+ check: {
9738
+ allowed: true,
9739
+ customer_id: null,
9740
+ balance: null,
9741
+ flag: null
9742
+ },
9743
+ track: {
9744
+ customer_id: null,
9745
+ value: 0,
9746
+ balance: null
9747
+ },
9748
+ getOrCreateCustomer: {
9749
+ id: null,
9750
+ name: null,
9751
+ email: null,
9752
+ created_at: 0,
9753
+ fingerprint: null,
9754
+ stripe_id: null,
9755
+ env: "live",
9756
+ metadata: {},
9757
+ send_email_receipts: false,
9758
+ billing_controls: {},
9759
+ subscriptions: [],
9760
+ purchases: [],
9761
+ balances: {},
9762
+ flags: {}
9763
+ }
9764
+ };
9765
+ var FailOpenHook = class {
9766
+ enabled = true;
9767
+ sdkInit(opts) {
9768
+ if (opts.failOpen === false) {
9769
+ this.enabled = false;
9770
+ return opts;
9771
+ }
9772
+ this.enabled = true;
9773
+ opts.httpClient = new HTTPClient({
9774
+ fetcher: async (input, init) => {
9775
+ try {
9776
+ return init == null ? await fetch(input) : await fetch(input, init);
9777
+ } catch {
9778
+ return new Response(null, {
9779
+ status: 503,
9780
+ statusText: "Autumn Unreachable"
9781
+ });
9782
+ }
9783
+ }
9784
+ });
9785
+ return opts;
9786
+ }
9787
+ afterError(hookCtx, response, error) {
9788
+ if (!this.enabled) {
9789
+ return { response, error };
9790
+ }
9791
+ if (!response || response.status < 500) {
9792
+ return { response, error };
9793
+ }
9794
+ if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
9795
+ return { response, error };
9796
+ }
9797
+ const body = FAIL_OPEN_BODIES[hookCtx.operationID];
9798
+ if (!body) {
9799
+ return { response, error };
9800
+ }
9801
+ console.error(FAIL_OPEN_LOG_MESSAGE);
9802
+ console.error(
9803
+ ` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
9804
+ );
9805
+ return {
9806
+ response: new Response(JSON.stringify(body), {
9807
+ status: 200,
9808
+ headers: { "Content-Type": "application/json" }
9809
+ }),
9810
+ error: null
9811
+ };
9812
+ }
9813
+ };
9814
+
9815
+ // ../sdk/src/hooks/timeoutFixHook.ts
9816
+ var DEFAULT_TIMEOUT_MS = 5e3;
9817
+ var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
9818
+ var TimeoutFixHook = class {
9819
+ beforeRequest(hookCtx, request) {
9820
+ let timeoutMs = hookCtx.options.timeoutMs;
9821
+ if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
9822
+ timeoutMs = DEFAULT_TIMEOUT_MS;
9823
+ if (!timeoutMs || timeoutMs <= 0) return request;
9824
+ const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
9825
+ return new Request(request, {
9826
+ signal
9827
+ });
9828
+ }
9829
+ };
9830
+
9831
+ // ../sdk/src/hooks/registration.ts
9832
+ function initHooks(hooks) {
9833
+ const failOpenHook = new FailOpenHook();
9834
+ const timeoutFixHook = new TimeoutFixHook();
9835
+ hooks.registerSDKInitHook(failOpenHook);
9836
+ hooks.registerBeforeRequestHook(timeoutFixHook);
9837
+ hooks.registerAfterErrorHook(failOpenHook);
9838
+ }
9839
+
9727
9840
  // ../sdk/src/hooks/hooks.ts
9728
9841
  var SDKHooks = class {
9729
9842
  sdkInitHooks = [];
@@ -9732,6 +9845,7 @@ var SDKHooks = class {
9732
9845
  afterSuccessHooks = [];
9733
9846
  afterErrorHooks = [];
9734
9847
  constructor() {
9848
+ initHooks(this);
9735
9849
  const presetHooks = [];
9736
9850
  for (const hook of presetHooks) {
9737
9851
  if ("sdkInit" in hook) {
@@ -13920,7 +14034,8 @@ var eventsAggregateParamsOutboundSchema = import_v4.z.object({
13920
14034
  group_by: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13921
14035
  range: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13922
14036
  bin_size: import_v4.z.string(),
13923
- custom_range: import_v4.z.union([aggregateEventsCustomRangeOutboundSchema, import_v4.z.undefined()]).optional()
14037
+ custom_range: import_v4.z.union([aggregateEventsCustomRangeOutboundSchema, import_v4.z.undefined()]).optional(),
14038
+ max_groups: import_v4.z.union([import_v4.z.number(), import_v4.z.undefined()]).optional()
13924
14039
  });
13925
14040
  var closedEnumSchema = import_v4.z.any();
13926
14041
  var rangeSchema = closedEnumSchema;
@@ -13932,7 +14047,8 @@ var eventsAggregateParamsSchema = import_v4.z.object({
13932
14047
  groupBy: import_v4.z.union([import_v4.z.string(), import_v4.z.undefined()]).optional(),
13933
14048
  range: import_v4.z.union([rangeSchema, import_v4.z.undefined()]).optional(),
13934
14049
  binSize: import_v4.z.union([binSizeSchema, import_v4.z.undefined()]).optional(),
13935
- customRange: import_v4.z.union([aggregateEventsCustomRangeSchema, import_v4.z.undefined()]).optional()
14050
+ customRange: import_v4.z.union([aggregateEventsCustomRangeSchema, import_v4.z.undefined()]).optional(),
14051
+ maxGroups: import_v4.z.union([import_v4.z.number(), import_v4.z.undefined()]).optional()
13936
14052
  });
13937
14053
 
13938
14054
  // src/generated/attachSchemas.ts
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  autumnHandler
3
- } from "../chunk-BNTQ4ECE.mjs";
3
+ } from "../chunk-NKLPJAWS.mjs";
4
4
  import "../chunk-WYDGEDEU.mjs";
5
5
  import "../chunk-VXND2UDT.mjs";
6
- import "../chunk-JUZDG66W.mjs";
7
- import "../chunk-NYHWQDP6.mjs";
8
- import "../chunk-ZPZ7FFHT.mjs";
9
- import "../chunk-55C2WWXQ.mjs";
10
- import "../chunk-TBQ27LIK.mjs";
11
- import "../chunk-J44WR3QZ.mjs";
6
+ import "../chunk-CS4R7BU4.mjs";
7
+ import "../chunk-TC6BT3QN.mjs";
12
8
  import "../chunk-TSF4YCUO.mjs";
13
9
  import "../chunk-UAR3TMWI.mjs";
14
- import "../chunk-VDKSZFDB.mjs";
10
+ import "../chunk-RGUUMXFG.mjs";
11
+ import "../chunk-NSXJQETG.mjs";
12
+ import "../chunk-S5HPMJ4U.mjs";
15
13
  import "../chunk-OTXV5FY7.mjs";
16
- import "../chunk-VZIMT7AO.mjs";
17
14
  import "../chunk-Z6QP3YEA.mjs";
15
+ import "../chunk-VZIMT7AO.mjs";
16
+ import "../chunk-TBQ27LIK.mjs";
17
+ import "../chunk-J44WR3QZ.mjs";
18
18
  import "../chunk-N7NFYY54.mjs";
19
19
  export {
20
20
  autumnHandler