@contractkit/plugin-typescript 0.34.0 → 0.34.1

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 220.70 KB
9
- ESM dist/index.js.map 514.14 KB
10
- ESM ⚡️ Build success in 310ms
8
+ ESM dist/index.js 221.06 KB
9
+ ESM dist/index.js.map 514.96 KB
10
+ ESM ⚡️ Build success in 514ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 3538ms
12
+ DTS ⚡️ Build success in 5728ms
13
13
  DTS dist/index.d.ts 5.14 KB
@@ -3,29 +3,29 @@ $ 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-sdk.test.ts (173 tests) 434ms
7
- ✓ tests/codegen-contract.test.ts (147 tests) 165ms
8
- ✓ tests/codegen-operation.test.ts (159 tests) 297ms
9
- ✓ tests/pipeline.test.ts (34 tests) 276ms
10
- ✓ tests/codegen-server.test.ts (33 tests) 59ms
11
- ✓ tests/codegen-plain-types.test.ts (67 tests) 78ms
12
- ✓ tests/ts-render.test.ts (5 tests) 20ms
13
- ✓ tests/codegen-mcp.test.ts (28 tests) 53ms
14
- ✓ tests/escaping-security.test.ts (18 tests) 18ms
6
+ ✓ tests/codegen-contract.test.ts (147 tests) 222ms
7
+ ✓ tests/codegen-operation.test.ts (159 tests) 241ms
8
+ ✓ tests/codegen-sdk.test.ts (173 tests) 405ms
9
+ ✓ tests/codegen-plain-types.test.ts (67 tests) 63ms
10
+ ✓ tests/codegen-server.test.ts (33 tests) 149ms
11
+ ✓ tests/pipeline.test.ts (34 tests) 413ms
12
+ ✓ tests/ts-render.test.ts (5 tests) 8ms
13
+ ✓ tests/codegen-mcp.test.ts (31 tests) 49ms
14
+ ✓ tests/escaping-security.test.ts (18 tests) 30ms
15
15
 
16
16
   Test Files  9 passed (9)
17
-  Tests  664 passed (664)
18
-  Start at  14:41:57
19
-  Duration  7.07s (transform 3.29s, setup 0ms, import 12.86s, tests 1.40s, environment 1ms)
17
+  Tests  667 passed (667)
18
+  Start at  17:41:52
19
+  Duration  10.27s (transform 6.12s, setup 0ms, import 20.30s, tests 1.58s, environment 24ms)
20
20
 
21
21
   % Coverage report from v8
22
22
  -------------------|---------|----------|---------|---------|-------------------
23
23
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
24
24
  -------------------|---------|----------|---------|---------|-------------------
25
- All files | 83.33 | 77.36 | 86.64 | 85.95 |
26
- src | 83.14 | 77.04 | 86.23 | 85.78 |
25
+ All files | 83.37 | 77.38 | 86.64 | 86 |
26
+ src | 83.19 | 77.06 | 86.23 | 85.83 |
27
27
  ...n-contract.ts | 90.13 | 85.89 | 90.51 | 90.9 | ...1166,1171-1172
28
- codegen-mcp.ts | 82.2 | 74.21 | 84.21 | 85.65 | ...99,304-305,387
28
+ codegen-mcp.ts | 82.75 | 74.53 | 84.21 | 86.19 | ...99,304-305,390
29
29
  ...-operation.ts | 83.06 | 80.46 | 80.28 | 85.15 | ...1045,1050-1051
30
30
  ...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
31
31
  ...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @contractkit/contractkit-plugin-typescript
2
2
 
3
+ ## 0.34.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3e90488: Stop the MCP aggregator from calling `container.register`, and underscore the unused `args` parameter on no-argument tools.
8
+
9
+ `generateMcpAggregator` emitted `container.register(McpToolHandlerMap, { useValue: map })`. InjectKit's `Container` has no `register`; it exposes only `get`, `createScopedContainer`, `hasRegistration`, `disposeAsync`, and `[Symbol.asyncDispose]`. Registration belongs to `Registry`, the composition-phase object, while `Container` is the resolution-phase one. Every generated `mcp.tools.ts` therefore failed to compile with `TS2339`, and would have thrown at startup if it had.
10
+
11
+ `registerMcpTools` now only builds the map and returns it. Its doc comment shows the binding that supplies the `Container` in the first place:
12
+
13
+ ```ts
14
+ registry.register(McpToolHandlerMap).useFactory(registerMcpTools).asSingleton();
15
+ ```
16
+
17
+ `generateMcpRouter`'s doc line told consumers to _call_ the aggregator at startup, which is the same mistake. It now points at the binding.
18
+
19
+ Separately, `renderToolClass` always named the handler's first parameter `args`. An operation with no path parameters and no request body destructures nothing, so the parameter went unread and tripped `@typescript-eslint/no-unused-vars` in consumers that lint generated output. It is now emitted as `_args` when there is nothing to destructure.
20
+
3
21
  ## 0.34.0
4
22
 
5
23
  ### Minor 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,MAAM,CAAC,CAAC;IAC/B,yFAAyF;IACzF,mBAAmB,CAAC,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;AAgWD,0GAA0G;AAC1G,wBAAgB,uBAAuB,CAAC,IAAI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G,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CA0DzF;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,CAuB3E;AAED,sGAAsG;AACtG,wBAAgB,iBAAiB,CAAC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAwBzE"}
package/dist/index.js CHANGED
@@ -4415,7 +4415,8 @@ function renderToolClass(plan, file, options) {
4415
4415
  const callArgs = buildArgs(route, op);
4416
4416
  const isVoid = !primaryResponseBody(op);
4417
4417
  const structured = !!outExpr;
4418
- lines.push(" async handle(args: Record<string, unknown>, _context: McpToolContext): Promise<CallToolResult> {");
4418
+ const argsParam = destructure.length > 0 ? "args" : "_args";
4419
+ lines.push(` async handle(${argsParam}: Record<string, unknown>, _context: McpToolContext): Promise<CallToolResult> {`);
4419
4420
  if (destructure.length > 0) {
4420
4421
  lines.push(` const { ${destructure.join(", ")} } = await parseAndValidate(args, ${argsConstName});`);
4421
4422
  }
@@ -4503,11 +4504,19 @@ function generateMcpAggregator(entries) {
4503
4504
  lines.push(`import { McpToolHandlerMap } from '@maroonedsoftware/mcp';`);
4504
4505
  for (const e of sorted) lines.push(`import { ${e.registerFn} } from '${e.importPath}';`);
4505
4506
  lines.push("");
4506
- lines.push("/** Build + register the MCP tool catalog. Call once at startup. */");
4507
+ lines.push("/**");
4508
+ lines.push(" * Build the MCP tool catalog.");
4509
+ lines.push(" *");
4510
+ lines.push(" * Bind it to the `McpToolHandlerMap` token from a factory, which is what supplies the");
4511
+ lines.push(" * `Container` needed to resolve each handler:");
4512
+ lines.push(" *");
4513
+ lines.push(" * ```ts");
4514
+ lines.push(" * registry.register(McpToolHandlerMap).useFactory(registerMcpTools).asSingleton();");
4515
+ lines.push(" * ```");
4516
+ lines.push(" */");
4507
4517
  lines.push("export function registerMcpTools(container: Container): McpToolHandlerMap {");
4508
4518
  lines.push(" const map = new McpToolHandlerMap();");
4509
4519
  for (const e of sorted) lines.push(` ${e.registerFn}(map, container);`);
4510
- lines.push(" container.register(McpToolHandlerMap, { useValue: map });");
4511
4520
  lines.push(" return map;");
4512
4521
  lines.push("}");
4513
4522
  return lines.join("\n") + "\n";
@@ -4518,7 +4527,7 @@ function generateMcpRouter(options = {}) {
4518
4527
  return `import { ServerKitRouter, bodyParserMiddleware, requireSignature } from '@maroonedsoftware/koa';
4519
4528
  import { McpDispatcher, createMcpRequestContext, MCP_AUTH_POLICY } from '@maroonedsoftware/mcp';
4520
4529
 
4521
- /** Mount the MCP endpoint onto a ServerKit router. Call \`registerMcpTools(container)\` at startup. */
4530
+ /** Mount the MCP endpoint onto a ServerKit router. Bind \`registerMcpTools\` to the \`McpToolHandlerMap\` token. */
4522
4531
  export function mountMcp(router: ReturnType<typeof ServerKitRouter>): void {
4523
4532
  router.post('${path}', bodyParserMiddleware(['json']), requireSignature('mcp', { policy: MCP_AUTH_POLICY }), async (ctx) => {
4524
4533
  const dispatcher = ctx.container.get(McpDispatcher);