@unkey/api 2.1.1 → 2.1.2

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 (32) hide show
  1. package/bin/mcp-server.js +233 -176
  2. package/bin/mcp-server.js.map +9 -8
  3. package/dist/commonjs/hooks/custom/vercel-edge-fetcher.d.ts +5 -0
  4. package/dist/commonjs/hooks/custom/vercel-edge-fetcher.d.ts.map +1 -0
  5. package/dist/commonjs/hooks/custom/vercel-edge-fetcher.js +63 -0
  6. package/dist/commonjs/hooks/custom/vercel-edge-fetcher.js.map +1 -0
  7. package/dist/commonjs/hooks/registration.d.ts.map +1 -1
  8. package/dist/commonjs/hooks/registration.js +3 -4
  9. package/dist/commonjs/hooks/registration.js.map +1 -1
  10. package/dist/commonjs/lib/config.d.ts +3 -3
  11. package/dist/commonjs/lib/config.js +3 -3
  12. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  13. package/dist/commonjs/mcp-server/server.js +1 -1
  14. package/dist/esm/hooks/custom/vercel-edge-fetcher.d.ts +5 -0
  15. package/dist/esm/hooks/custom/vercel-edge-fetcher.d.ts.map +1 -0
  16. package/dist/esm/hooks/custom/vercel-edge-fetcher.js +59 -0
  17. package/dist/esm/hooks/custom/vercel-edge-fetcher.js.map +1 -0
  18. package/dist/esm/hooks/registration.d.ts.map +1 -1
  19. package/dist/esm/hooks/registration.js +3 -4
  20. package/dist/esm/hooks/registration.js.map +1 -1
  21. package/dist/esm/lib/config.d.ts +3 -3
  22. package/dist/esm/lib/config.js +3 -3
  23. package/dist/esm/mcp-server/mcp-server.js +1 -1
  24. package/dist/esm/mcp-server/server.js +1 -1
  25. package/examples/package-lock.json +1 -1
  26. package/jsr.json +1 -1
  27. package/package.json +1 -1
  28. package/src/hooks/custom/vercel-edge-fetcher.ts +64 -0
  29. package/src/hooks/registration.ts +3 -4
  30. package/src/lib/config.ts +3 -3
  31. package/src/mcp-server/mcp-server.ts +1 -1
  32. package/src/mcp-server/server.ts +1 -1
@@ -0,0 +1,5 @@
1
+ import type { SDKInitHook, SDKInitOptions } from "../types.js";
2
+ export declare class FetcherOverrideForVercelEdgeHook implements SDKInitHook {
3
+ sdkInit(opts: SDKInitOptions): SDKInitOptions;
4
+ }
5
+ //# sourceMappingURL=vercel-edge-fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-edge-fetcher.d.ts","sourceRoot":"","sources":["../../../../src/hooks/custom/vercel-edge-fetcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA+C/D,qBAAa,gCAAiC,YAAW,WAAW;IAClE,OAAO,CAAC,IAAI,EAAE,cAAc;CAc7B"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FetcherOverrideForVercelEdgeHook = void 0;
4
+ const http_js_1 = require("../../lib/http.js");
5
+ function isVercelEdgeRuntime() {
6
+ // https://vercel.com/docs/functions/runtimes/edge#check-if-you're-running-on-the-edge-runtime
7
+ if ("EdgeRuntime" in globalThis)
8
+ return true;
9
+ if (process.env["NEXT_RUNTIME"] === "edge")
10
+ return true;
11
+ return false;
12
+ }
13
+ const vercelEdgeFetcher = (input, init) => {
14
+ // Edge runtime fix: Request objects may not be recognized by instanceof
15
+ // Check if it's a Request-like object by checking for .url property
16
+ const isRequestLike = typeof input === "object" &&
17
+ input !== null &&
18
+ "url" in input &&
19
+ "method" in input &&
20
+ "headers" in input;
21
+ if (isRequestLike && !init) {
22
+ // For Edge runtime: extract URL and reconstruct request
23
+ const req = input;
24
+ return fetch(req.url, {
25
+ method: req.method,
26
+ headers: req.headers,
27
+ body: req.body,
28
+ mode: req.mode,
29
+ credentials: req.credentials,
30
+ cache: req.cache,
31
+ redirect: req.redirect,
32
+ referrer: req.referrer,
33
+ integrity: req.integrity,
34
+ signal: req.signal,
35
+ });
36
+ }
37
+ // If input is a Request and init is undefined, Bun will discard the method,
38
+ // headers, body and other options that were set on the request object.
39
+ // Node.js and browers would ignore an undefined init value. This check is
40
+ // therefore needed for interop with Bun.
41
+ if (init == null) {
42
+ return fetch(input);
43
+ }
44
+ else {
45
+ return fetch(input, init);
46
+ }
47
+ };
48
+ class FetcherOverrideForVercelEdgeHook {
49
+ sdkInit(opts) {
50
+ if (!isVercelEdgeRuntime()) {
51
+ return opts;
52
+ }
53
+ const client = new http_js_1.HTTPClient({
54
+ fetcher: vercelEdgeFetcher,
55
+ });
56
+ return {
57
+ ...opts,
58
+ client,
59
+ };
60
+ }
61
+ }
62
+ exports.FetcherOverrideForVercelEdgeHook = FetcherOverrideForVercelEdgeHook;
63
+ //# sourceMappingURL=vercel-edge-fetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-edge-fetcher.js","sourceRoot":"","sources":["../../../../src/hooks/custom/vercel-edge-fetcher.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAG7D,SAAS,mBAAmB;IAC1B,8FAA8F;IAC9F,IAAI,aAAa,IAAI,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,iBAAiB,GAAY,CAAC,KAAK,EAAE,IAAK,EAAE,EAAE;IAClD,wEAAwE;IACxE,oEAAoE;IACpE,MAAM,aAAa,GACjB,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,IAAI,KAAK;QACd,QAAQ,IAAI,KAAK;QACjB,SAAS,IAAI,KAAK,CAAC;IAErB,IAAI,aAAa,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3B,wDAAwD;QACxD,MAAM,GAAG,GAAG,KAAgB,CAAC;QAC7B,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YACpB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,uEAAuE;IACvE,0EAA0E;IAC1E,yCAAyC;IACzC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEF,MAAa,gCAAgC;IAC3C,OAAO,CAAC,IAAoB;QAC1B,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,oBAAU,CAAC;YAC5B,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,IAAI;YACP,MAAM;SACP,CAAC;IACJ,CAAC;CACF;AAfD,4EAeC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAIrC"}
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAQnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAGrC"}
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initHooks = initHooks;
4
+ const vercel_edge_fetcher_js_1 = require("./custom/vercel-edge-fetcher.js");
4
5
  /*
5
6
  * This file is only ever generated once on the first generation and then is free to be modified.
6
7
  * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
7
8
  * in this file or in separate files in the hooks folder.
8
9
  */
9
- // @ts-expect-error remove this line when you add your first hook and hooks is used
10
10
  function initHooks(hooks) {
11
- // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
12
- // with an instance of a hook that implements that specific Hook interface
13
- // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
11
+ // Use a fetcher that works in Vercel Edge Runtime environments
12
+ hooks.registerSDKInitHook(new vercel_edge_fetcher_js_1.FetcherOverrideForVercelEdgeHook());
14
13
  }
15
14
  //# sourceMappingURL=registration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":";;AASA,8BAIC;AAXD;;;;GAIG;AAEH,mFAAmF;AACnF,SAAgB,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;AAC9F,CAAC"}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":";;AASA,8BAGC;AAZD,4EAAmF;AAGnF;;;;GAIG;AAEH,SAAgB,SAAS,CAAC,KAAY;IACpC,+DAA+D;IAC/D,KAAK,CAAC,mBAAmB,CAAC,IAAI,yDAAgC,EAAE,CAAC,CAAC;AACpE,CAAC"}
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
31
31
  export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "2.0.0";
34
- readonly sdkVersion: "2.1.1";
35
- readonly genVersion: "2.753.1";
36
- readonly userAgent: "speakeasy-sdk/typescript 2.1.1 2.753.1 2.0.0 @unkey/api";
34
+ readonly sdkVersion: "2.1.2";
35
+ readonly genVersion: "2.753.6";
36
+ readonly userAgent: "speakeasy-sdk/typescript 2.1.2 2.753.6 2.0.0 @unkey/api";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -28,8 +28,8 @@ function serverURLFromOptions(options) {
28
28
  exports.SDK_METADATA = {
29
29
  language: "typescript",
30
30
  openapiDocVersion: "2.0.0",
31
- sdkVersion: "2.1.1",
32
- genVersion: "2.753.1",
33
- userAgent: "speakeasy-sdk/typescript 2.1.1 2.753.1 2.0.0 @unkey/api",
31
+ sdkVersion: "2.1.2",
32
+ genVersion: "2.753.6",
33
+ userAgent: "speakeasy-sdk/typescript 2.1.2 2.753.6 2.0.0 @unkey/api",
34
34
  };
35
35
  //# sourceMappingURL=config.js.map
@@ -22,7 +22,7 @@ const routes = (0, core_1.buildRouteMap)({
22
22
  exports.app = (0, core_1.buildApplication)(routes, {
23
23
  name: "mcp",
24
24
  versionInfo: {
25
- currentVersion: "2.1.1",
25
+ currentVersion: "2.1.2",
26
26
  },
27
27
  });
28
28
  (0, core_1.run)(exports.app, node_process_1.default.argv.slice(2), (0, cli_js_1.buildContext)(node_process_1.default));
@@ -51,7 +51,7 @@ const ratelimitSetOverride_js_1 = require("./tools/ratelimitSetOverride.js");
51
51
  function createMCPServer(deps) {
52
52
  const server = new mcp_js_1.McpServer({
53
53
  name: "Unkey",
54
- version: "2.1.1",
54
+ version: "2.1.2",
55
55
  });
56
56
  const client = new core_js_1.UnkeyCore({
57
57
  rootKey: deps.rootKey,
@@ -0,0 +1,5 @@
1
+ import type { SDKInitHook, SDKInitOptions } from "../types.js";
2
+ export declare class FetcherOverrideForVercelEdgeHook implements SDKInitHook {
3
+ sdkInit(opts: SDKInitOptions): SDKInitOptions;
4
+ }
5
+ //# sourceMappingURL=vercel-edge-fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-edge-fetcher.d.ts","sourceRoot":"","sources":["../../../../src/hooks/custom/vercel-edge-fetcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA+C/D,qBAAa,gCAAiC,YAAW,WAAW;IAClE,OAAO,CAAC,IAAI,EAAE,cAAc;CAc7B"}
@@ -0,0 +1,59 @@
1
+ import { HTTPClient } from "../../lib/http.js";
2
+ function isVercelEdgeRuntime() {
3
+ // https://vercel.com/docs/functions/runtimes/edge#check-if-you're-running-on-the-edge-runtime
4
+ if ("EdgeRuntime" in globalThis)
5
+ return true;
6
+ if (process.env["NEXT_RUNTIME"] === "edge")
7
+ return true;
8
+ return false;
9
+ }
10
+ const vercelEdgeFetcher = (input, init) => {
11
+ // Edge runtime fix: Request objects may not be recognized by instanceof
12
+ // Check if it's a Request-like object by checking for .url property
13
+ const isRequestLike = typeof input === "object" &&
14
+ input !== null &&
15
+ "url" in input &&
16
+ "method" in input &&
17
+ "headers" in input;
18
+ if (isRequestLike && !init) {
19
+ // For Edge runtime: extract URL and reconstruct request
20
+ const req = input;
21
+ return fetch(req.url, {
22
+ method: req.method,
23
+ headers: req.headers,
24
+ body: req.body,
25
+ mode: req.mode,
26
+ credentials: req.credentials,
27
+ cache: req.cache,
28
+ redirect: req.redirect,
29
+ referrer: req.referrer,
30
+ integrity: req.integrity,
31
+ signal: req.signal,
32
+ });
33
+ }
34
+ // If input is a Request and init is undefined, Bun will discard the method,
35
+ // headers, body and other options that were set on the request object.
36
+ // Node.js and browers would ignore an undefined init value. This check is
37
+ // therefore needed for interop with Bun.
38
+ if (init == null) {
39
+ return fetch(input);
40
+ }
41
+ else {
42
+ return fetch(input, init);
43
+ }
44
+ };
45
+ export class FetcherOverrideForVercelEdgeHook {
46
+ sdkInit(opts) {
47
+ if (!isVercelEdgeRuntime()) {
48
+ return opts;
49
+ }
50
+ const client = new HTTPClient({
51
+ fetcher: vercelEdgeFetcher,
52
+ });
53
+ return {
54
+ ...opts,
55
+ client,
56
+ };
57
+ }
58
+ }
59
+ //# sourceMappingURL=vercel-edge-fetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-edge-fetcher.js","sourceRoot":"","sources":["../../../../src/hooks/custom/vercel-edge-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAC;AAG7D,SAAS,mBAAmB;IAC1B,8FAA8F;IAC9F,IAAI,aAAa,IAAI,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,iBAAiB,GAAY,CAAC,KAAK,EAAE,IAAK,EAAE,EAAE;IAClD,wEAAwE;IACxE,oEAAoE;IACpE,MAAM,aAAa,GACjB,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,IAAI,KAAK;QACd,QAAQ,IAAI,KAAK;QACjB,SAAS,IAAI,KAAK,CAAC;IAErB,IAAI,aAAa,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3B,wDAAwD;QACxD,MAAM,GAAG,GAAG,KAAgB,CAAC;QAC7B,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YACpB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,uEAAuE;IACvE,0EAA0E;IAC1E,yCAAyC;IACzC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,OAAO,gCAAgC;IAC3C,OAAO,CAAC,IAAoB;QAC1B,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;YAC5B,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,IAAI;YACP,MAAM;SACP,CAAC;IACJ,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AASnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAIrC"}
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAQnC,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,QAGrC"}
@@ -1,12 +1,11 @@
1
+ import { FetcherOverrideForVercelEdgeHook } from "./custom/vercel-edge-fetcher.js";
1
2
  /*
2
3
  * This file is only ever generated once on the first generation and then is free to be modified.
3
4
  * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
4
5
  * in this file or in separate files in the hooks folder.
5
6
  */
6
- // @ts-expect-error remove this line when you add your first hook and hooks is used
7
7
  export function initHooks(hooks) {
8
- // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
9
- // with an instance of a hook that implements that specific Hook interface
10
- // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
8
+ // Use a fetcher that works in Vercel Edge Runtime environments
9
+ hooks.registerSDKInitHook(new FetcherOverrideForVercelEdgeHook());
11
10
  }
12
11
  //# sourceMappingURL=registration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,KAAY;IACpC,gHAAgH;IAChH,0EAA0E;IAC1E,4FAA4F;AAC9F,CAAC"}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/hooks/registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAGnF;;;;GAIG;AAEH,MAAM,UAAU,SAAS,CAAC,KAAY;IACpC,+DAA+D;IAC/D,KAAK,CAAC,mBAAmB,CAAC,IAAI,gCAAgC,EAAE,CAAC,CAAC;AACpE,CAAC"}
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
31
31
  export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "2.0.0";
34
- readonly sdkVersion: "2.1.1";
35
- readonly genVersion: "2.753.1";
36
- readonly userAgent: "speakeasy-sdk/typescript 2.1.1 2.753.1 2.0.0 @unkey/api";
34
+ readonly sdkVersion: "2.1.2";
35
+ readonly genVersion: "2.753.6";
36
+ readonly userAgent: "speakeasy-sdk/typescript 2.1.2 2.753.6 2.0.0 @unkey/api";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -24,8 +24,8 @@ export function serverURLFromOptions(options) {
24
24
  export const SDK_METADATA = {
25
25
  language: "typescript",
26
26
  openapiDocVersion: "2.0.0",
27
- sdkVersion: "2.1.1",
28
- genVersion: "2.753.1",
29
- userAgent: "speakeasy-sdk/typescript 2.1.1 2.753.1 2.0.0 @unkey/api",
27
+ sdkVersion: "2.1.2",
28
+ genVersion: "2.753.6",
29
+ userAgent: "speakeasy-sdk/typescript 2.1.2 2.753.6 2.0.0 @unkey/api",
30
30
  };
31
31
  //# sourceMappingURL=config.js.map
@@ -16,7 +16,7 @@ const routes = buildRouteMap({
16
16
  export const app = buildApplication(routes, {
17
17
  name: "mcp",
18
18
  versionInfo: {
19
- currentVersion: "2.1.1",
19
+ currentVersion: "2.1.2",
20
20
  },
21
21
  });
22
22
  run(app, process.argv.slice(2), buildContext(process));
@@ -48,7 +48,7 @@ import { tool$ratelimitSetOverride } from "./tools/ratelimitSetOverride.js";
48
48
  export function createMCPServer(deps) {
49
49
  const server = new McpServer({
50
50
  name: "Unkey",
51
- version: "2.1.1",
51
+ version: "2.1.2",
52
52
  });
53
53
  const client = new UnkeyCore({
54
54
  rootKey: deps.rootKey,
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "..": {
20
20
  "name": "@unkey/api",
21
- "version": "2.1.1",
21
+ "version": "2.1.2",
22
22
  "dependencies": {
23
23
  "zod": "^3.25.0 || ^4.0.0"
24
24
  },
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@unkey/api",
5
- "version": "2.1.1",
5
+ "version": "2.1.2",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unkey/api",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "author": "Speakeasy",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,64 @@
1
+ import { HTTPClient, type Fetcher } from "../../lib/http.js";
2
+ import type { SDKInitHook, SDKInitOptions } from "../types.js";
3
+
4
+ function isVercelEdgeRuntime(): boolean {
5
+ // https://vercel.com/docs/functions/runtimes/edge#check-if-you're-running-on-the-edge-runtime
6
+ if ("EdgeRuntime" in globalThis) return true;
7
+ if (process.env["NEXT_RUNTIME"] === "edge") return true;
8
+ return false;
9
+ }
10
+
11
+ const vercelEdgeFetcher: Fetcher = (input, init?) => {
12
+ // Edge runtime fix: Request objects may not be recognized by instanceof
13
+ // Check if it's a Request-like object by checking for .url property
14
+ const isRequestLike =
15
+ typeof input === "object" &&
16
+ input !== null &&
17
+ "url" in input &&
18
+ "method" in input &&
19
+ "headers" in input;
20
+
21
+ if (isRequestLike && !init) {
22
+ // For Edge runtime: extract URL and reconstruct request
23
+ const req = input as Request;
24
+ return fetch(req.url, {
25
+ method: req.method,
26
+ headers: req.headers,
27
+ body: req.body,
28
+ mode: req.mode,
29
+ credentials: req.credentials,
30
+ cache: req.cache,
31
+ redirect: req.redirect,
32
+ referrer: req.referrer,
33
+ integrity: req.integrity,
34
+ signal: req.signal,
35
+ });
36
+ }
37
+
38
+ // If input is a Request and init is undefined, Bun will discard the method,
39
+ // headers, body and other options that were set on the request object.
40
+ // Node.js and browers would ignore an undefined init value. This check is
41
+ // therefore needed for interop with Bun.
42
+ if (init == null) {
43
+ return fetch(input);
44
+ } else {
45
+ return fetch(input, init);
46
+ }
47
+ };
48
+
49
+ export class FetcherOverrideForVercelEdgeHook implements SDKInitHook {
50
+ sdkInit(opts: SDKInitOptions) {
51
+ if (!isVercelEdgeRuntime()) {
52
+ return opts;
53
+ }
54
+
55
+ const client = new HTTPClient({
56
+ fetcher: vercelEdgeFetcher,
57
+ });
58
+
59
+ return {
60
+ ...opts,
61
+ client,
62
+ };
63
+ }
64
+ }
@@ -1,3 +1,4 @@
1
+ import { FetcherOverrideForVercelEdgeHook } from "./custom/vercel-edge-fetcher.js";
1
2
  import { Hooks } from "./types.js";
2
3
 
3
4
  /*
@@ -6,9 +7,7 @@ import { Hooks } from "./types.js";
6
7
  * in this file or in separate files in the hooks folder.
7
8
  */
8
9
 
9
- // @ts-expect-error remove this line when you add your first hook and hooks is used
10
10
  export function initHooks(hooks: Hooks) {
11
- // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
12
- // with an instance of a hook that implements that specific Hook interface
13
- // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
11
+ // Use a fetcher that works in Vercel Edge Runtime environments
12
+ hooks.registerSDKInitHook(new FetcherOverrideForVercelEdgeHook());
14
13
  }
package/src/lib/config.ts CHANGED
@@ -58,7 +58,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
58
58
  export const SDK_METADATA = {
59
59
  language: "typescript",
60
60
  openapiDocVersion: "2.0.0",
61
- sdkVersion: "2.1.1",
62
- genVersion: "2.753.1",
63
- userAgent: "speakeasy-sdk/typescript 2.1.1 2.753.1 2.0.0 @unkey/api",
61
+ sdkVersion: "2.1.2",
62
+ genVersion: "2.753.6",
63
+ userAgent: "speakeasy-sdk/typescript 2.1.2 2.753.6 2.0.0 @unkey/api",
64
64
  } as const;
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "2.1.1",
22
+ currentVersion: "2.1.2",
23
23
  },
24
24
  });
25
25
 
@@ -63,7 +63,7 @@ export function createMCPServer(deps: {
63
63
  }) {
64
64
  const server = new McpServer({
65
65
  name: "Unkey",
66
- version: "2.1.1",
66
+ version: "2.1.2",
67
67
  });
68
68
 
69
69
  const client = new UnkeyCore({