autumn-js 1.1.7 → 1.1.8
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.
- package/dist/backend/adapters/express.js +114 -2
- package/dist/backend/adapters/express.mjs +4 -4
- package/dist/backend/adapters/fetch.js +114 -2
- package/dist/backend/adapters/fetch.mjs +4 -4
- package/dist/backend/adapters/hono.js +114 -2
- package/dist/backend/adapters/hono.mjs +4 -4
- package/dist/backend/adapters/index.js +114 -2
- package/dist/backend/adapters/index.mjs +7 -7
- package/dist/backend/adapters/next.js +114 -2
- package/dist/backend/adapters/next.mjs +4 -4
- package/dist/backend/{chunk-PP6UQYJS.mjs → chunk-4CAIFRHS.mjs} +1 -1
- package/dist/backend/{chunk-PX3QACWR.mjs → chunk-FN75G3TE.mjs} +1 -1
- package/dist/backend/{chunk-BNTQ4ECE.mjs → chunk-OQXZXMNQ.mjs} +1 -1
- package/dist/backend/{chunk-NYHWQDP6.mjs → chunk-UANWRTQO.mjs} +1 -1
- package/dist/backend/{chunk-JUZDG66W.mjs → chunk-UUYPN27R.mjs} +1 -1
- package/dist/backend/{chunk-X2ZQ7KI7.mjs → chunk-WVXLG3HD.mjs} +1 -1
- package/dist/backend/{chunk-ZPZ7FFHT.mjs → chunk-XK7RZSEV.mjs} +114 -2
- package/dist/backend/core/handlers/coreHandler.js +114 -2
- package/dist/backend/core/handlers/coreHandler.mjs +2 -2
- package/dist/backend/core/handlers/handleRouteByName.js +114 -2
- package/dist/backend/core/handlers/handleRouteByName.mjs +2 -2
- package/dist/backend/core/handlers/index.js +114 -2
- package/dist/backend/core/handlers/index.mjs +3 -3
- package/dist/backend/core/index.js +114 -2
- package/dist/backend/core/index.mjs +3 -3
- package/dist/backend/index.js +114 -2
- package/dist/backend/index.mjs +3 -3
- package/dist/better-auth/{chunk-WVO7XICO.mjs → chunk-7MR76UL4.mjs} +114 -2
- package/dist/better-auth/index.js +114 -2
- package/dist/better-auth/index.mjs +1 -1
- package/dist/better-auth/utils/handleBetterAuthRoute.js +114 -2
- package/dist/better-auth/utils/handleBetterAuthRoute.mjs +1 -1
- package/dist/better-auth/utils/index.js +114 -2
- package/dist/better-auth/utils/index.mjs +1 -1
- package/dist/react/hooks/index.mjs +9 -9
- package/dist/react/index.mjs +10 -10
- package/dist/sdk/index.d.mts +2 -2
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +116 -2
- package/dist/sdk/index.mjs +116 -2
- package/package.json +142 -142
|
@@ -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.
|
|
82
|
-
userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.
|
|
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
|
|
@@ -9724,6 +9724,117 @@ async function $do2(client, request, options) {
|
|
|
9724
9724
|
return [result, { status: "complete", request: req, response }];
|
|
9725
9725
|
}
|
|
9726
9726
|
|
|
9727
|
+
// ../sdk/src/hooks/failOpenHook.ts
|
|
9728
|
+
var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
9729
|
+
"check",
|
|
9730
|
+
"track",
|
|
9731
|
+
"getOrCreateCustomer"
|
|
9732
|
+
]);
|
|
9733
|
+
var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
|
|
9734
|
+
var FAIL_OPEN_BODIES = {
|
|
9735
|
+
check: {
|
|
9736
|
+
allowed: true,
|
|
9737
|
+
customer_id: null,
|
|
9738
|
+
balance: null,
|
|
9739
|
+
flag: null
|
|
9740
|
+
},
|
|
9741
|
+
track: {
|
|
9742
|
+
customer_id: null,
|
|
9743
|
+
value: 0,
|
|
9744
|
+
balance: null
|
|
9745
|
+
},
|
|
9746
|
+
getOrCreateCustomer: {
|
|
9747
|
+
id: null,
|
|
9748
|
+
name: null,
|
|
9749
|
+
email: null,
|
|
9750
|
+
created_at: 0,
|
|
9751
|
+
fingerprint: null,
|
|
9752
|
+
stripe_id: null,
|
|
9753
|
+
env: "live",
|
|
9754
|
+
metadata: {},
|
|
9755
|
+
send_email_receipts: false,
|
|
9756
|
+
billing_controls: {},
|
|
9757
|
+
subscriptions: [],
|
|
9758
|
+
purchases: [],
|
|
9759
|
+
balances: {},
|
|
9760
|
+
flags: {}
|
|
9761
|
+
}
|
|
9762
|
+
};
|
|
9763
|
+
var FailOpenHook = class {
|
|
9764
|
+
enabled = true;
|
|
9765
|
+
sdkInit(opts) {
|
|
9766
|
+
if (opts.failOpen === false) {
|
|
9767
|
+
this.enabled = false;
|
|
9768
|
+
return opts;
|
|
9769
|
+
}
|
|
9770
|
+
this.enabled = true;
|
|
9771
|
+
opts.httpClient = new HTTPClient({
|
|
9772
|
+
fetcher: async (input, init) => {
|
|
9773
|
+
try {
|
|
9774
|
+
return init == null ? await fetch(input) : await fetch(input, init);
|
|
9775
|
+
} catch {
|
|
9776
|
+
return new Response(null, {
|
|
9777
|
+
status: 503,
|
|
9778
|
+
statusText: "Autumn Unreachable"
|
|
9779
|
+
});
|
|
9780
|
+
}
|
|
9781
|
+
}
|
|
9782
|
+
});
|
|
9783
|
+
return opts;
|
|
9784
|
+
}
|
|
9785
|
+
afterError(hookCtx, response, error) {
|
|
9786
|
+
if (!this.enabled) {
|
|
9787
|
+
return { response, error };
|
|
9788
|
+
}
|
|
9789
|
+
if (!response || response.status < 500) {
|
|
9790
|
+
return { response, error };
|
|
9791
|
+
}
|
|
9792
|
+
if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
|
|
9793
|
+
return { response, error };
|
|
9794
|
+
}
|
|
9795
|
+
const body = FAIL_OPEN_BODIES[hookCtx.operationID];
|
|
9796
|
+
if (!body) {
|
|
9797
|
+
return { response, error };
|
|
9798
|
+
}
|
|
9799
|
+
console.error(FAIL_OPEN_LOG_MESSAGE);
|
|
9800
|
+
console.error(
|
|
9801
|
+
` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
|
|
9802
|
+
);
|
|
9803
|
+
return {
|
|
9804
|
+
response: new Response(JSON.stringify(body), {
|
|
9805
|
+
status: 200,
|
|
9806
|
+
headers: { "Content-Type": "application/json" }
|
|
9807
|
+
}),
|
|
9808
|
+
error: null
|
|
9809
|
+
};
|
|
9810
|
+
}
|
|
9811
|
+
};
|
|
9812
|
+
|
|
9813
|
+
// ../sdk/src/hooks/timeoutFixHook.ts
|
|
9814
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
9815
|
+
var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
|
|
9816
|
+
var TimeoutFixHook = class {
|
|
9817
|
+
beforeRequest(hookCtx, request) {
|
|
9818
|
+
let timeoutMs = hookCtx.options.timeoutMs;
|
|
9819
|
+
if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
|
|
9820
|
+
timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
9821
|
+
if (!timeoutMs || timeoutMs <= 0) return request;
|
|
9822
|
+
const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
|
|
9823
|
+
return new Request(request, {
|
|
9824
|
+
signal
|
|
9825
|
+
});
|
|
9826
|
+
}
|
|
9827
|
+
};
|
|
9828
|
+
|
|
9829
|
+
// ../sdk/src/hooks/registration.ts
|
|
9830
|
+
function initHooks(hooks) {
|
|
9831
|
+
const failOpenHook = new FailOpenHook();
|
|
9832
|
+
const timeoutFixHook = new TimeoutFixHook();
|
|
9833
|
+
hooks.registerSDKInitHook(failOpenHook);
|
|
9834
|
+
hooks.registerBeforeRequestHook(timeoutFixHook);
|
|
9835
|
+
hooks.registerAfterErrorHook(failOpenHook);
|
|
9836
|
+
}
|
|
9837
|
+
|
|
9727
9838
|
// ../sdk/src/hooks/hooks.ts
|
|
9728
9839
|
var SDKHooks = class {
|
|
9729
9840
|
sdkInitHooks = [];
|
|
@@ -9732,6 +9843,7 @@ var SDKHooks = class {
|
|
|
9732
9843
|
afterSuccessHooks = [];
|
|
9733
9844
|
afterErrorHooks = [];
|
|
9734
9845
|
constructor() {
|
|
9846
|
+
initHooks(this);
|
|
9735
9847
|
const presetHooks = [];
|
|
9736
9848
|
for (const hook of presetHooks) {
|
|
9737
9849
|
if ("sdkInit" in hook) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
autumnHandler
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-WVXLG3HD.mjs";
|
|
4
4
|
import "../chunk-WYDGEDEU.mjs";
|
|
5
5
|
import "../chunk-VXND2UDT.mjs";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-UUYPN27R.mjs";
|
|
7
|
+
import "../chunk-UANWRTQO.mjs";
|
|
8
|
+
import "../chunk-XK7RZSEV.mjs";
|
|
9
9
|
import "../chunk-55C2WWXQ.mjs";
|
|
10
10
|
import "../chunk-TBQ27LIK.mjs";
|
|
11
11
|
import "../chunk-J44WR3QZ.mjs";
|
|
@@ -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.
|
|
82
|
-
userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.
|
|
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
|
|
@@ -9724,6 +9724,117 @@ async function $do2(client, request, options) {
|
|
|
9724
9724
|
return [result, { status: "complete", request: req, response }];
|
|
9725
9725
|
}
|
|
9726
9726
|
|
|
9727
|
+
// ../sdk/src/hooks/failOpenHook.ts
|
|
9728
|
+
var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
9729
|
+
"check",
|
|
9730
|
+
"track",
|
|
9731
|
+
"getOrCreateCustomer"
|
|
9732
|
+
]);
|
|
9733
|
+
var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
|
|
9734
|
+
var FAIL_OPEN_BODIES = {
|
|
9735
|
+
check: {
|
|
9736
|
+
allowed: true,
|
|
9737
|
+
customer_id: null,
|
|
9738
|
+
balance: null,
|
|
9739
|
+
flag: null
|
|
9740
|
+
},
|
|
9741
|
+
track: {
|
|
9742
|
+
customer_id: null,
|
|
9743
|
+
value: 0,
|
|
9744
|
+
balance: null
|
|
9745
|
+
},
|
|
9746
|
+
getOrCreateCustomer: {
|
|
9747
|
+
id: null,
|
|
9748
|
+
name: null,
|
|
9749
|
+
email: null,
|
|
9750
|
+
created_at: 0,
|
|
9751
|
+
fingerprint: null,
|
|
9752
|
+
stripe_id: null,
|
|
9753
|
+
env: "live",
|
|
9754
|
+
metadata: {},
|
|
9755
|
+
send_email_receipts: false,
|
|
9756
|
+
billing_controls: {},
|
|
9757
|
+
subscriptions: [],
|
|
9758
|
+
purchases: [],
|
|
9759
|
+
balances: {},
|
|
9760
|
+
flags: {}
|
|
9761
|
+
}
|
|
9762
|
+
};
|
|
9763
|
+
var FailOpenHook = class {
|
|
9764
|
+
enabled = true;
|
|
9765
|
+
sdkInit(opts) {
|
|
9766
|
+
if (opts.failOpen === false) {
|
|
9767
|
+
this.enabled = false;
|
|
9768
|
+
return opts;
|
|
9769
|
+
}
|
|
9770
|
+
this.enabled = true;
|
|
9771
|
+
opts.httpClient = new HTTPClient({
|
|
9772
|
+
fetcher: async (input, init) => {
|
|
9773
|
+
try {
|
|
9774
|
+
return init == null ? await fetch(input) : await fetch(input, init);
|
|
9775
|
+
} catch {
|
|
9776
|
+
return new Response(null, {
|
|
9777
|
+
status: 503,
|
|
9778
|
+
statusText: "Autumn Unreachable"
|
|
9779
|
+
});
|
|
9780
|
+
}
|
|
9781
|
+
}
|
|
9782
|
+
});
|
|
9783
|
+
return opts;
|
|
9784
|
+
}
|
|
9785
|
+
afterError(hookCtx, response, error) {
|
|
9786
|
+
if (!this.enabled) {
|
|
9787
|
+
return { response, error };
|
|
9788
|
+
}
|
|
9789
|
+
if (!response || response.status < 500) {
|
|
9790
|
+
return { response, error };
|
|
9791
|
+
}
|
|
9792
|
+
if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
|
|
9793
|
+
return { response, error };
|
|
9794
|
+
}
|
|
9795
|
+
const body = FAIL_OPEN_BODIES[hookCtx.operationID];
|
|
9796
|
+
if (!body) {
|
|
9797
|
+
return { response, error };
|
|
9798
|
+
}
|
|
9799
|
+
console.error(FAIL_OPEN_LOG_MESSAGE);
|
|
9800
|
+
console.error(
|
|
9801
|
+
` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
|
|
9802
|
+
);
|
|
9803
|
+
return {
|
|
9804
|
+
response: new Response(JSON.stringify(body), {
|
|
9805
|
+
status: 200,
|
|
9806
|
+
headers: { "Content-Type": "application/json" }
|
|
9807
|
+
}),
|
|
9808
|
+
error: null
|
|
9809
|
+
};
|
|
9810
|
+
}
|
|
9811
|
+
};
|
|
9812
|
+
|
|
9813
|
+
// ../sdk/src/hooks/timeoutFixHook.ts
|
|
9814
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
9815
|
+
var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
|
|
9816
|
+
var TimeoutFixHook = class {
|
|
9817
|
+
beforeRequest(hookCtx, request) {
|
|
9818
|
+
let timeoutMs = hookCtx.options.timeoutMs;
|
|
9819
|
+
if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
|
|
9820
|
+
timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
9821
|
+
if (!timeoutMs || timeoutMs <= 0) return request;
|
|
9822
|
+
const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
|
|
9823
|
+
return new Request(request, {
|
|
9824
|
+
signal
|
|
9825
|
+
});
|
|
9826
|
+
}
|
|
9827
|
+
};
|
|
9828
|
+
|
|
9829
|
+
// ../sdk/src/hooks/registration.ts
|
|
9830
|
+
function initHooks(hooks) {
|
|
9831
|
+
const failOpenHook = new FailOpenHook();
|
|
9832
|
+
const timeoutFixHook = new TimeoutFixHook();
|
|
9833
|
+
hooks.registerSDKInitHook(failOpenHook);
|
|
9834
|
+
hooks.registerBeforeRequestHook(timeoutFixHook);
|
|
9835
|
+
hooks.registerAfterErrorHook(failOpenHook);
|
|
9836
|
+
}
|
|
9837
|
+
|
|
9727
9838
|
// ../sdk/src/hooks/hooks.ts
|
|
9728
9839
|
var SDKHooks = class {
|
|
9729
9840
|
sdkInitHooks = [];
|
|
@@ -9732,6 +9843,7 @@ var SDKHooks = class {
|
|
|
9732
9843
|
afterSuccessHooks = [];
|
|
9733
9844
|
afterErrorHooks = [];
|
|
9734
9845
|
constructor() {
|
|
9846
|
+
initHooks(this);
|
|
9735
9847
|
const presetHooks = [];
|
|
9736
9848
|
for (const hook of presetHooks) {
|
|
9737
9849
|
if ("sdkInit" in hook) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
autumnHandler
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-4CAIFRHS.mjs";
|
|
4
4
|
import "../chunk-WYDGEDEU.mjs";
|
|
5
5
|
import "../chunk-VXND2UDT.mjs";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-UUYPN27R.mjs";
|
|
7
|
+
import "../chunk-UANWRTQO.mjs";
|
|
8
|
+
import "../chunk-XK7RZSEV.mjs";
|
|
9
9
|
import "../chunk-55C2WWXQ.mjs";
|
|
10
10
|
import "../chunk-TBQ27LIK.mjs";
|
|
11
11
|
import "../chunk-J44WR3QZ.mjs";
|
|
@@ -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.
|
|
82
|
-
userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.
|
|
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
|
|
@@ -9724,6 +9724,117 @@ async function $do2(client, request, options) {
|
|
|
9724
9724
|
return [result, { status: "complete", request: req, response }];
|
|
9725
9725
|
}
|
|
9726
9726
|
|
|
9727
|
+
// ../sdk/src/hooks/failOpenHook.ts
|
|
9728
|
+
var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
9729
|
+
"check",
|
|
9730
|
+
"track",
|
|
9731
|
+
"getOrCreateCustomer"
|
|
9732
|
+
]);
|
|
9733
|
+
var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
|
|
9734
|
+
var FAIL_OPEN_BODIES = {
|
|
9735
|
+
check: {
|
|
9736
|
+
allowed: true,
|
|
9737
|
+
customer_id: null,
|
|
9738
|
+
balance: null,
|
|
9739
|
+
flag: null
|
|
9740
|
+
},
|
|
9741
|
+
track: {
|
|
9742
|
+
customer_id: null,
|
|
9743
|
+
value: 0,
|
|
9744
|
+
balance: null
|
|
9745
|
+
},
|
|
9746
|
+
getOrCreateCustomer: {
|
|
9747
|
+
id: null,
|
|
9748
|
+
name: null,
|
|
9749
|
+
email: null,
|
|
9750
|
+
created_at: 0,
|
|
9751
|
+
fingerprint: null,
|
|
9752
|
+
stripe_id: null,
|
|
9753
|
+
env: "live",
|
|
9754
|
+
metadata: {},
|
|
9755
|
+
send_email_receipts: false,
|
|
9756
|
+
billing_controls: {},
|
|
9757
|
+
subscriptions: [],
|
|
9758
|
+
purchases: [],
|
|
9759
|
+
balances: {},
|
|
9760
|
+
flags: {}
|
|
9761
|
+
}
|
|
9762
|
+
};
|
|
9763
|
+
var FailOpenHook = class {
|
|
9764
|
+
enabled = true;
|
|
9765
|
+
sdkInit(opts) {
|
|
9766
|
+
if (opts.failOpen === false) {
|
|
9767
|
+
this.enabled = false;
|
|
9768
|
+
return opts;
|
|
9769
|
+
}
|
|
9770
|
+
this.enabled = true;
|
|
9771
|
+
opts.httpClient = new HTTPClient({
|
|
9772
|
+
fetcher: async (input, init) => {
|
|
9773
|
+
try {
|
|
9774
|
+
return init == null ? await fetch(input) : await fetch(input, init);
|
|
9775
|
+
} catch {
|
|
9776
|
+
return new Response(null, {
|
|
9777
|
+
status: 503,
|
|
9778
|
+
statusText: "Autumn Unreachable"
|
|
9779
|
+
});
|
|
9780
|
+
}
|
|
9781
|
+
}
|
|
9782
|
+
});
|
|
9783
|
+
return opts;
|
|
9784
|
+
}
|
|
9785
|
+
afterError(hookCtx, response, error) {
|
|
9786
|
+
if (!this.enabled) {
|
|
9787
|
+
return { response, error };
|
|
9788
|
+
}
|
|
9789
|
+
if (!response || response.status < 500) {
|
|
9790
|
+
return { response, error };
|
|
9791
|
+
}
|
|
9792
|
+
if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
|
|
9793
|
+
return { response, error };
|
|
9794
|
+
}
|
|
9795
|
+
const body = FAIL_OPEN_BODIES[hookCtx.operationID];
|
|
9796
|
+
if (!body) {
|
|
9797
|
+
return { response, error };
|
|
9798
|
+
}
|
|
9799
|
+
console.error(FAIL_OPEN_LOG_MESSAGE);
|
|
9800
|
+
console.error(
|
|
9801
|
+
` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
|
|
9802
|
+
);
|
|
9803
|
+
return {
|
|
9804
|
+
response: new Response(JSON.stringify(body), {
|
|
9805
|
+
status: 200,
|
|
9806
|
+
headers: { "Content-Type": "application/json" }
|
|
9807
|
+
}),
|
|
9808
|
+
error: null
|
|
9809
|
+
};
|
|
9810
|
+
}
|
|
9811
|
+
};
|
|
9812
|
+
|
|
9813
|
+
// ../sdk/src/hooks/timeoutFixHook.ts
|
|
9814
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
9815
|
+
var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
|
|
9816
|
+
var TimeoutFixHook = class {
|
|
9817
|
+
beforeRequest(hookCtx, request) {
|
|
9818
|
+
let timeoutMs = hookCtx.options.timeoutMs;
|
|
9819
|
+
if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
|
|
9820
|
+
timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
9821
|
+
if (!timeoutMs || timeoutMs <= 0) return request;
|
|
9822
|
+
const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
|
|
9823
|
+
return new Request(request, {
|
|
9824
|
+
signal
|
|
9825
|
+
});
|
|
9826
|
+
}
|
|
9827
|
+
};
|
|
9828
|
+
|
|
9829
|
+
// ../sdk/src/hooks/registration.ts
|
|
9830
|
+
function initHooks(hooks) {
|
|
9831
|
+
const failOpenHook = new FailOpenHook();
|
|
9832
|
+
const timeoutFixHook = new TimeoutFixHook();
|
|
9833
|
+
hooks.registerSDKInitHook(failOpenHook);
|
|
9834
|
+
hooks.registerBeforeRequestHook(timeoutFixHook);
|
|
9835
|
+
hooks.registerAfterErrorHook(failOpenHook);
|
|
9836
|
+
}
|
|
9837
|
+
|
|
9727
9838
|
// ../sdk/src/hooks/hooks.ts
|
|
9728
9839
|
var SDKHooks = class {
|
|
9729
9840
|
sdkInitHooks = [];
|
|
@@ -9732,6 +9843,7 @@ var SDKHooks = class {
|
|
|
9732
9843
|
afterSuccessHooks = [];
|
|
9733
9844
|
afterErrorHooks = [];
|
|
9734
9845
|
constructor() {
|
|
9846
|
+
initHooks(this);
|
|
9735
9847
|
const presetHooks = [];
|
|
9736
9848
|
for (const hook of presetHooks) {
|
|
9737
9849
|
if ("sdkInit" in hook) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
autumnHandler
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-OQXZXMNQ.mjs";
|
|
4
4
|
import "../chunk-WYDGEDEU.mjs";
|
|
5
5
|
import "../chunk-VXND2UDT.mjs";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-UUYPN27R.mjs";
|
|
7
|
+
import "../chunk-UANWRTQO.mjs";
|
|
8
|
+
import "../chunk-XK7RZSEV.mjs";
|
|
9
9
|
import "../chunk-55C2WWXQ.mjs";
|
|
10
10
|
import "../chunk-TBQ27LIK.mjs";
|
|
11
11
|
import "../chunk-J44WR3QZ.mjs";
|
|
@@ -81,8 +81,8 @@ var SDK_METADATA = {
|
|
|
81
81
|
language: "typescript",
|
|
82
82
|
openapiDocVersion: "2.2.0",
|
|
83
83
|
sdkVersion: "0.10.17",
|
|
84
|
-
genVersion: "2.869.
|
|
85
|
-
userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.
|
|
84
|
+
genVersion: "2.869.25",
|
|
85
|
+
userAgent: "speakeasy-sdk/typescript 0.10.17 2.869.25 2.2.0 @useautumn/sdk"
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
// ../sdk/src/lib/http.ts
|
|
@@ -9727,6 +9727,117 @@ async function $do2(client, request, options) {
|
|
|
9727
9727
|
return [result, { status: "complete", request: req, response }];
|
|
9728
9728
|
}
|
|
9729
9729
|
|
|
9730
|
+
// ../sdk/src/hooks/failOpenHook.ts
|
|
9731
|
+
var FAIL_OPEN_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
9732
|
+
"check",
|
|
9733
|
+
"track",
|
|
9734
|
+
"getOrCreateCustomer"
|
|
9735
|
+
]);
|
|
9736
|
+
var FAIL_OPEN_LOG_MESSAGE = "[Autumn] Request failed \u2014 failing open. Learn more: https://docs.useautumn.com/documentation/fail-open";
|
|
9737
|
+
var FAIL_OPEN_BODIES = {
|
|
9738
|
+
check: {
|
|
9739
|
+
allowed: true,
|
|
9740
|
+
customer_id: null,
|
|
9741
|
+
balance: null,
|
|
9742
|
+
flag: null
|
|
9743
|
+
},
|
|
9744
|
+
track: {
|
|
9745
|
+
customer_id: null,
|
|
9746
|
+
value: 0,
|
|
9747
|
+
balance: null
|
|
9748
|
+
},
|
|
9749
|
+
getOrCreateCustomer: {
|
|
9750
|
+
id: null,
|
|
9751
|
+
name: null,
|
|
9752
|
+
email: null,
|
|
9753
|
+
created_at: 0,
|
|
9754
|
+
fingerprint: null,
|
|
9755
|
+
stripe_id: null,
|
|
9756
|
+
env: "live",
|
|
9757
|
+
metadata: {},
|
|
9758
|
+
send_email_receipts: false,
|
|
9759
|
+
billing_controls: {},
|
|
9760
|
+
subscriptions: [],
|
|
9761
|
+
purchases: [],
|
|
9762
|
+
balances: {},
|
|
9763
|
+
flags: {}
|
|
9764
|
+
}
|
|
9765
|
+
};
|
|
9766
|
+
var FailOpenHook = class {
|
|
9767
|
+
enabled = true;
|
|
9768
|
+
sdkInit(opts) {
|
|
9769
|
+
if (opts.failOpen === false) {
|
|
9770
|
+
this.enabled = false;
|
|
9771
|
+
return opts;
|
|
9772
|
+
}
|
|
9773
|
+
this.enabled = true;
|
|
9774
|
+
opts.httpClient = new HTTPClient({
|
|
9775
|
+
fetcher: async (input, init) => {
|
|
9776
|
+
try {
|
|
9777
|
+
return init == null ? await fetch(input) : await fetch(input, init);
|
|
9778
|
+
} catch {
|
|
9779
|
+
return new Response(null, {
|
|
9780
|
+
status: 503,
|
|
9781
|
+
statusText: "Autumn Unreachable"
|
|
9782
|
+
});
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
9785
|
+
});
|
|
9786
|
+
return opts;
|
|
9787
|
+
}
|
|
9788
|
+
afterError(hookCtx, response, error) {
|
|
9789
|
+
if (!this.enabled) {
|
|
9790
|
+
return { response, error };
|
|
9791
|
+
}
|
|
9792
|
+
if (!response || response.status < 500) {
|
|
9793
|
+
return { response, error };
|
|
9794
|
+
}
|
|
9795
|
+
if (!FAIL_OPEN_OPERATION_IDS.has(hookCtx.operationID)) {
|
|
9796
|
+
return { response, error };
|
|
9797
|
+
}
|
|
9798
|
+
const body = FAIL_OPEN_BODIES[hookCtx.operationID];
|
|
9799
|
+
if (!body) {
|
|
9800
|
+
return { response, error };
|
|
9801
|
+
}
|
|
9802
|
+
console.error(FAIL_OPEN_LOG_MESSAGE);
|
|
9803
|
+
console.error(
|
|
9804
|
+
` Operation: ${hookCtx.operationID} | Status: ${response.status} | Error: ${error ?? "Server error"}`
|
|
9805
|
+
);
|
|
9806
|
+
return {
|
|
9807
|
+
response: new Response(JSON.stringify(body), {
|
|
9808
|
+
status: 200,
|
|
9809
|
+
headers: { "Content-Type": "application/json" }
|
|
9810
|
+
}),
|
|
9811
|
+
error: null
|
|
9812
|
+
};
|
|
9813
|
+
}
|
|
9814
|
+
};
|
|
9815
|
+
|
|
9816
|
+
// ../sdk/src/hooks/timeoutFixHook.ts
|
|
9817
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
9818
|
+
var AUTO_TIMEOUT_OPERATION_IDS = /* @__PURE__ */ new Set(["check", "track"]);
|
|
9819
|
+
var TimeoutFixHook = class {
|
|
9820
|
+
beforeRequest(hookCtx, request) {
|
|
9821
|
+
let timeoutMs = hookCtx.options.timeoutMs;
|
|
9822
|
+
if ((!timeoutMs || timeoutMs <= 0) && AUTO_TIMEOUT_OPERATION_IDS.has(hookCtx.operationID))
|
|
9823
|
+
timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
9824
|
+
if (!timeoutMs || timeoutMs <= 0) return request;
|
|
9825
|
+
const signal = typeof AbortSignal.any === "function" ? AbortSignal.any([request.signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
|
|
9826
|
+
return new Request(request, {
|
|
9827
|
+
signal
|
|
9828
|
+
});
|
|
9829
|
+
}
|
|
9830
|
+
};
|
|
9831
|
+
|
|
9832
|
+
// ../sdk/src/hooks/registration.ts
|
|
9833
|
+
function initHooks(hooks) {
|
|
9834
|
+
const failOpenHook = new FailOpenHook();
|
|
9835
|
+
const timeoutFixHook = new TimeoutFixHook();
|
|
9836
|
+
hooks.registerSDKInitHook(failOpenHook);
|
|
9837
|
+
hooks.registerBeforeRequestHook(timeoutFixHook);
|
|
9838
|
+
hooks.registerAfterErrorHook(failOpenHook);
|
|
9839
|
+
}
|
|
9840
|
+
|
|
9730
9841
|
// ../sdk/src/hooks/hooks.ts
|
|
9731
9842
|
var SDKHooks = class {
|
|
9732
9843
|
sdkInitHooks = [];
|
|
@@ -9735,6 +9846,7 @@ var SDKHooks = class {
|
|
|
9735
9846
|
afterSuccessHooks = [];
|
|
9736
9847
|
afterErrorHooks = [];
|
|
9737
9848
|
constructor() {
|
|
9849
|
+
initHooks(this);
|
|
9738
9850
|
const presetHooks = [];
|
|
9739
9851
|
for (const hook of presetHooks) {
|
|
9740
9852
|
if ("sdkInit" in hook) {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
autumnHandler
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-WVXLG3HD.mjs";
|
|
4
4
|
import {
|
|
5
5
|
autumnHandler as autumnHandler2
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-4CAIFRHS.mjs";
|
|
7
7
|
import {
|
|
8
8
|
autumnHandler as autumnHandler3
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-OQXZXMNQ.mjs";
|
|
10
10
|
import {
|
|
11
11
|
autumnHandler as autumnHandler4
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-FN75G3TE.mjs";
|
|
13
13
|
import "../chunk-WYDGEDEU.mjs";
|
|
14
14
|
import "../chunk-VXND2UDT.mjs";
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-UUYPN27R.mjs";
|
|
16
|
+
import "../chunk-UANWRTQO.mjs";
|
|
17
|
+
import "../chunk-XK7RZSEV.mjs";
|
|
18
18
|
import "../chunk-55C2WWXQ.mjs";
|
|
19
19
|
import "../chunk-TBQ27LIK.mjs";
|
|
20
20
|
import "../chunk-J44WR3QZ.mjs";
|