@contractkit/plugin-typescript 0.33.2 → 0.33.3

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.
@@ -5,9 +5,9 @@ $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly
5
5
  CLI tsup v8.5.1
6
6
  CLI Target: esnext
7
7
  ESM Build start
8
- ESM dist/index.js 210.74 KB
9
- ESM dist/index.js.map 480.07 KB
10
- ESM ⚡️ Build success in 537ms
8
+ ESM dist/index.js 210.87 KB
9
+ ESM dist/index.js.map 480.21 KB
10
+ ESM ⚡️ Build success in 497ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 4711ms
12
+ DTS ⚡️ Build success in 6324ms
13
13
  DTS dist/index.d.ts 5.14 KB
@@ -3,19 +3,19 @@ $ vitest run --coverage
3
3
   RUN  v4.1.5 /home/runner/work/ContractKit/ContractKit/packages/plugin-typescript
4
4
  Coverage enabled with v8
5
5
 
6
- ✓ tests/codegen-contract.test.ts (140 tests) 291ms
7
- ✓ tests/codegen-operation.test.ts (155 tests) 339ms
8
- ✓ tests/codegen-sdk.test.ts (159 tests) 336ms
9
- ✓ tests/codegen-server.test.ts (30 tests) 106ms
10
- ✓ tests/codegen-plain-types.test.ts (66 tests) 90ms
11
- ✓ tests/pipeline.test.ts (30 tests) 458ms
12
- ✓ tests/codegen-mcp.test.ts (24 tests) 81ms
13
- ✓ tests/escaping-security.test.ts (18 tests) 35ms
6
+ ✓ tests/codegen-contract.test.ts (140 tests) 233ms
7
+ ✓ tests/codegen-sdk.test.ts (159 tests) 222ms
8
+ ✓ tests/codegen-operation.test.ts (155 tests) 387ms
9
+ ✓ tests/codegen-plain-types.test.ts (66 tests) 71ms
10
+ ✓ tests/codegen-server.test.ts (30 tests) 121ms
11
+ ✓ tests/pipeline.test.ts (30 tests) 412ms
12
+ ✓ tests/codegen-mcp.test.ts (28 tests) 63ms
13
+ ✓ tests/escaping-security.test.ts (18 tests) 26ms
14
14
 
15
15
   Test Files  8 passed (8)
16
-  Tests  622 passed (622)
17
-  Start at  19:19:25
18
-  Duration  10.45s (transform 4.58s, setup 0ms, import 19.71s, tests 1.74s, environment 1ms)
16
+  Tests  626 passed (626)
17
+  Start at  11:22:39
18
+  Duration  10.67s (transform 5.63s, setup 0ms, import 20.55s, tests 1.53s, environment 7ms)
19
19
 
20
20
   % Coverage report from v8
21
21
  -------------------|---------|----------|---------|---------|-------------------
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @contractkit/contractkit-plugin-typescript
2
2
 
3
+ ## 0.33.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 637e13b: Fix four defects in the emitted `mcp.router.ts` that left the generated MCP endpoint non-functional. It now emits `bodyParserMiddleware(['json'])` ahead of `requireSignature`, which is what populates the `ctx.rawBody` the signature HMAC is computed over; answers notifications with `else ctx.status = 202` instead of leaving `ctx.body` unset and 404ing the `notifications/initialized` that follows every handshake; wraps the body as `JSON.parse(String(ctx.rawBody))`, since `ctx.rawBody` is `BinaryLike` and `JSON.parse` takes a `string`; and hands the stateful transport `ctx.parsedBody` rather than `ctx.request.body`, which ServerKit never populates and which the new body parser's stream read would otherwise leave empty.
8
+
3
9
  ## 0.33.2
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-mcp.d.ts","sourceRoot":"","sources":["../src/codegen-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA8E,MAAM,mBAAmB,CAAC;AAUhI,MAAM,WAAW,iBAAiB;IAC9B,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qDAAqD;IACrD,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,GAAG,CAAC,M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AC,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AASD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,UAAQ,GAAG,OAAO,CASnF;AA+VD,0GAA0G;AAC1G,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,sGAAsG;AACtG,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CA2DzF;AAED,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IAC/B,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAe3E;AAED,sGAAsG;AACtG,wBAAgB,iBAAiB,CAAC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAwBzE"}
package/dist/index.js CHANGED
@@ -4332,23 +4332,24 @@ function generateMcpAggregator(entries) {
4332
4332
  __name(generateMcpAggregator, "generateMcpAggregator");
4333
4333
  function generateMcpRouter(options = {}) {
4334
4334
  const path = options.path ?? "/mcp";
4335
- return `import { ServerKitRouter, requireSignature } from '@maroonedsoftware/koa';
4335
+ return `import { ServerKitRouter, bodyParserMiddleware, requireSignature } from '@maroonedsoftware/koa';
4336
4336
  import { McpDispatcher, createMcpRequestContext, MCP_AUTH_POLICY } from '@maroonedsoftware/mcp';
4337
4337
 
4338
4338
  /** Mount the MCP endpoint onto a ServerKit router. Call \`registerMcpTools(container)\` at startup. */
4339
4339
  export function mountMcp(router: ReturnType<typeof ServerKitRouter>): void {
4340
- router.post('${path}', requireSignature('mcp', { policy: MCP_AUTH_POLICY }), async (ctx) => {
4340
+ router.post('${path}', bodyParserMiddleware(['json']), requireSignature('mcp', { policy: MCP_AUTH_POLICY }), async (ctx) => {
4341
4341
  const dispatcher = ctx.container.get(McpDispatcher);
4342
4342
  const context = createMcpRequestContext({ requestId: ctx.requestId, logger: ctx.logger });
4343
4343
  if (dispatcher.sessionMode === 'stateful') {
4344
4344
  ctx.respond = false;
4345
4345
  await dispatcher.dispatchStateful(
4346
- { req: ctx.req, res: ctx.res, body: ctx.request.body, sessionId: ctx.get('mcp-session-id') },
4346
+ { req: ctx.req, res: ctx.res, body: ctx.parsedBody, sessionId: ctx.get('mcp-session-id') },
4347
4347
  context,
4348
4348
  );
4349
4349
  } else {
4350
- const response = await dispatcher.dispatch(JSON.parse(ctx.rawBody), context);
4350
+ const response = await dispatcher.dispatch(JSON.parse(String(ctx.rawBody)), context);
4351
4351
  if (response) ctx.body = response;
4352
+ else ctx.status = 202; // a notification \u2014 nothing to return
4352
4353
  }
4353
4354
  });
4354
4355
  }