@decocms/runtime 1.0.0-alpha.20 → 1.0.0-alpha.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/runtime",
3
- "version": "1.0.0-alpha.20",
3
+ "version": "1.0.0-alpha.21",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@cloudflare/workers-types": "^4.20250617.0",
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /* oxlint-disable no-explicit-any */
2
- import type { ExecutionContext } from "@cloudflare/workers-types";
3
2
  import { decodeJwt } from "jose";
4
3
  import type { z } from "zod";
5
4
  import { createContractBinding, createIntegrationBinding } from "./bindings.ts";
5
+ import { type CORSOptions, handlePreflight, withCORS } from "./cors.ts";
6
6
  import { State } from "./state.ts";
7
7
  import {
8
8
  createMCPServer,
@@ -10,14 +10,13 @@ import {
10
10
  MCPServer,
11
11
  } from "./tools.ts";
12
12
  import type { Binding, ContractBinding, MCPBinding } from "./wrangler.ts";
13
- import { type CORSOptions, handlePreflight, withCORS } from "./cors.ts";
14
13
  export { proxyConnectionForId } from "./bindings.ts";
14
+ export { type CORSOptions, type CORSOrigin } from "./cors.ts";
15
15
  export {
16
16
  createMCPFetchStub,
17
17
  type CreateStubAPIOptions,
18
18
  type ToolBinder,
19
19
  } from "./mcp.ts";
20
- export { type CORSOptions, type CORSOrigin } from "./cors.ts";
21
20
 
22
21
  export interface DefaultEnv<TSchema extends z.ZodTypeAny = any> {
23
22
  MESH_REQUEST_CONTEXT: RequestContext<TSchema>;
@@ -53,11 +52,7 @@ export interface UserDefaultExport<
53
52
  TSchema extends z.ZodTypeAny = never,
54
53
  TEnv = TUserEnv & DefaultEnv<TSchema>,
55
54
  > extends CreateMCPServerOptions<TEnv, TSchema> {
56
- fetch?: (
57
- req: Request,
58
- env: TEnv,
59
- ctx: ExecutionContext,
60
- ) => Promise<Response> | Response;
55
+ fetch?: (req: Request, env: TEnv, ctx: any) => Promise<Response> | Response;
61
56
  /**
62
57
  * CORS configuration options.
63
58
  * Set to `false` to disable CORS handling entirely.
@@ -235,14 +230,14 @@ export const withBindings = <TEnv>({
235
230
 
236
231
  export const withRuntime = <TEnv, TSchema extends z.ZodTypeAny = never>(
237
232
  userFns: UserDefaultExport<TEnv, TSchema>,
238
- ): ExportedHandler<TEnv & DefaultEnv<TSchema>> => {
233
+ ) => {
239
234
  const server = createMCPServer<TEnv, TSchema>(userFns);
240
235
  const corsOptions = userFns.cors;
241
236
 
242
237
  const fetcher = async (
243
238
  req: Request,
244
239
  env: TEnv & DefaultEnv<TSchema>,
245
- ctx: ExecutionContext,
240
+ ctx: any,
246
241
  ) => {
247
242
  const url = new URL(req.url);
248
243
  if (url.pathname === "/mcp") {
@@ -278,11 +273,7 @@ export const withRuntime = <TEnv, TSchema extends z.ZodTypeAny = never>(
278
273
  };
279
274
 
280
275
  return {
281
- fetch: async (
282
- req: Request,
283
- env: TEnv & DefaultEnv<TSchema>,
284
- ctx: ExecutionContext,
285
- ) => {
276
+ fetch: async (req: Request, env: TEnv & DefaultEnv<TSchema>, ctx: any) => {
286
277
  // Handle CORS preflight (OPTIONS) requests
287
278
  if (corsOptions !== false && req.method === "OPTIONS") {
288
279
  const options = corsOptions ?? {};
package/src/tools.ts CHANGED
@@ -335,11 +335,7 @@ export const createMCPServer = <
335
335
  return { server, tools };
336
336
  };
337
337
 
338
- const fetch = async (
339
- req: Request,
340
- env: TEnv & DefaultEnv<TSchema>,
341
- _ctx: ExecutionContext,
342
- ) => {
338
+ const fetch = async (req: Request, env: TEnv & DefaultEnv<TSchema>) => {
343
339
  const { server } = await createServer(env);
344
340
  const transport = new HttpServerTransport();
345
341