@contractkit/plugin-typescript 0.34.1 → 0.35.0

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 221.06 KB
9
- ESM dist/index.js.map 514.96 KB
10
- ESM ⚡️ Build success in 514ms
8
+ ESM dist/index.js 225.18 KB
9
+ ESM dist/index.js.map 531.21 KB
10
+ ESM ⚡️ Build success in 386ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 5728ms
13
- DTS dist/index.d.ts 5.14 KB
12
+ DTS ⚡️ Build success in 3500ms
13
+ DTS dist/index.d.ts 10.53 KB
@@ -3,36 +3,41 @@ $ 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 (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
6
+ ✓ tests/codegen-operation.test.ts (161 tests) 207ms
7
+ ✓ tests/codegen-contract.test.ts (147 tests) 155ms
8
+ ✓ tests/codegen-sdk.test.ts (173 tests) 256ms
9
+ ✓ tests/codegen-plain-types.test.ts (67 tests) 54ms
10
+ ✓ tests/codegen-server.test.ts (39 tests) 147ms
11
+ ✓ tests/pipeline.test.ts (34 tests) 433ms
12
+ ✓ tests/codegen-mcp.test.ts (33 tests) 29ms
13
+ ✓ tests/codegen-operation-framework.test.ts (8 tests) 6ms
14
+ ✓ tests/server-framework-koa.test.ts (19 tests) 18ms
15
+ ✓ tests/ts-render.test.ts (5 tests) 10ms
16
+ ✓ tests/escaping-security.test.ts (18 tests) 22ms
17
+ ✓ tests/server-framework.test.ts (4 tests) 7ms
15
18
 
16
-  Test Files  9 passed (9)
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)
19
+  Test Files  12 passed (12)
20
+  Tests  708 passed (708)
21
+  Start at  18:00:17
22
+  Duration  7.85s (transform 4.21s, setup 0ms, import 14.10s, tests 1.34s, environment 1ms)
20
23
 
21
24
   % Coverage report from v8
22
25
  -------------------|---------|----------|---------|---------|-------------------
23
26
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
24
27
  -------------------|---------|----------|---------|---------|-------------------
25
- All files | 83.37 | 77.38 | 86.64 | 86 |
26
- src | 83.19 | 77.06 | 86.23 | 85.83 |
28
+ All files | 84.59 | 78.42 | 87.93 | 87.3 |
29
+ src | 84.42 | 78.12 | 87.61 | 87.16 |
27
30
  ...n-contract.ts | 90.13 | 85.89 | 90.51 | 90.9 | ...1166,1171-1172
28
- codegen-mcp.ts | 82.75 | 74.53 | 84.21 | 86.19 | ...99,304-305,390
29
- ...-operation.ts | 83.06 | 80.46 | 80.28 | 85.15 | ...1045,1050-1051
31
+ codegen-mcp.ts | 83.44 | 75.46 | 84.21 | 86.61 | ...01,306-307,392
32
+ ...-operation.ts | 83.27 | 80.62 | 80.82 | 85.33 | ...1070,1075-1076
30
33
  ...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
31
34
  ...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
32
35
  codegen-sdk.ts | 88.46 | 80.47 | 90.55 | 91.36 | ...1891,1895-1896
33
36
  ...al-runtime.ts | 100 | 100 | 100 | 100 |
34
- index.ts | 68.64 | 55.2 | 75.4 | 71.67 | ...1121,1137-1156
37
+ index.ts | 77.23 | 65.81 | 83.6 | 81.28 | ...1152,1168-1187
35
38
  path-utils.ts | 70.5 | 52.27 | 100 | 73.72 | ...75-178,226-241
39
+ ...mework-koa.ts | 100 | 100 | 100 | 100 |
40
+ ...-framework.ts | 100 | 100 | 100 | 100 |
36
41
  ts-render.ts | 86.04 | 88.23 | 80 | 90.14 | 103,191,224-232
37
42
  tests | 94.73 | 95.12 | 93.54 | 96 |
38
43
  helpers.ts | 94.73 | 95.12 | 93.54 | 96 | 120,128
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @contractkit/contractkit-plugin-typescript
2
2
 
3
+ ## 0.35.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 731ab7a: Add `server.framework`, and render the generated router through a framework adapter.
8
+
9
+ The server sub-generator emitted the Koa flavour of ServerKit inline: `ServerKitRouter()`, `async ctx => {`, `ctx.params`, `ctx.parsedBody`, `ctx.container.get`, `ctx.status`, `ctx.set`, `ctx.type`, `ctx.body`, and a wholly Koa-specific `mcp.router.ts`. Every one of those strings now comes from a `ServerFramework` adapter, and `server.framework` selects it:
10
+
11
+ ```json
12
+ "server": { "framework": "koa", "baseDir": "apps/api/" }
13
+ ```
14
+
15
+ `koa` is the only supported value and the default, so **generated output is unchanged, byte for byte** — the option exists so a later release can target another framework without touching the generator. A name with no adapter fails config validation rather than emitting code that cannot run:
16
+
17
+ ```
18
+ plugin-typescript: server.framework 'express' is not supported — expected one of: koa.
19
+ ```
20
+
21
+ The optional `mcp.router.ts` follows the same setting, including when there is no `server` sub-config at all, where it stays Koa.
22
+
23
+ Two internal changes came with it. `generateParamValidation` decided whether it was rendering query params or path params by comparing its accessor argument against the literals `'ctx.query'` and `'ctx.params'`, so the query-string array coercion and the destructuring of path params both hung on the exact spelling of a Koa accessor; it now takes the kind explicitly. And the response seam is shaped for a framework that ends a response by returning rather than by assigning: the adapter supplies the terminal statement for bodyless responses too, and supplies whatever closes a status case, since a `return` followed by a `break` is unreachable code.
24
+
3
25
  ## 0.34.1
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -52,11 +52,12 @@ Add the plugin to `contractkit.config.json`. Each sub-config is independent —
52
52
 
53
53
  ### `server`
54
54
 
55
- Generates Koa router files from `operation` declarations and optionally type files from `contract` declarations.
55
+ Generates server router files from `operation` declarations and optionally type files from `contract` declarations.
56
56
 
57
57
  | Option | Type | Default | Description |
58
58
  |---|---|---|---|
59
59
  | `baseDir` | `string` | `rootDir` | Base directory for output files |
60
+ | `framework` | `string` | `"koa"` | HTTP framework the routers target. Only `koa` is supported today. |
60
61
  | `zod` | `boolean` | `false` | Emit Zod schemas in `output.types` instead of plain interfaces |
61
62
  | `output.routes` | `string` | — | Path template for router files |
62
63
  | `output.types` | `string` | — | Path template for type/schema files |
@@ -129,9 +130,9 @@ Contracts with `readonly` or `writeonly` fields generate up to three schemas:
129
130
 
130
131
  Contracts without visibility modifiers generate a single `Model` schema.
131
132
 
132
- ### Koa router shape (from `operation`)
133
+ ### Router shape (from `operation`)
133
134
 
134
- Each operation file generates one Koa router. Request bodies and path/query params are validated against the Zod schemas (when `zod: true`) or plain types. Handlers are expected to be exported from the service module specified by `servicePathTemplate`.
135
+ Each operation file generates one router, targeting the framework named by `framework` (`koa` today). Request bodies and path/query params are validated against the Zod schemas (when `zod: true`) or plain types. Handlers are expected to be exported from the service module specified by `servicePathTemplate`.
135
136
 
136
137
  Responses are only type-annotated by default. With `validateResponses: true` (which requires `zod: true`) the service's return value is re-parsed against its declared response schema and the parsed value is written to `ctx.body`, so a service returning a shape the contract does not allow fails with a 500 instead of shipping it. See [docs/config.md](../../docs/config.md#validateresponses) for the caveats — notably that models using `format(input=…)`/`format(output=…)` are skipped.
137
138
 
@@ -1,4 +1,5 @@
1
1
  import type { OpRootNode } from '@contractkit/core';
2
+ import type { ServerFramework } from './server-framework.js';
2
3
  export interface McpCodegenOptions {
3
4
  /** Absolute path of the file being generated. Used to compute relative imports. */
4
5
  outPath?: string;
@@ -31,8 +32,14 @@ export interface McpAggregatorEntry {
31
32
  }
32
33
  /** Generate the aggregator `mcp.tools.ts` that assembles the single McpToolHandlerMap. */
33
34
  export declare function generateMcpAggregator(entries: McpAggregatorEntry[]): string;
34
- /** Generate the optional `mcp.router.ts` — the standard ServerKit route wiring for the dispatcher. */
35
+ /**
36
+ * Generate the optional `mcp.router.ts` — the standard ServerKit route wiring for the dispatcher.
37
+ *
38
+ * The whole file is framework-specific boilerplate rather than a per-operation render, so the
39
+ * adapter owns the template. Defaults to Koa, matching the router generator.
40
+ */
35
41
  export declare function generateMcpRouter(options?: {
36
42
  path?: string;
43
+ framework?: ServerFramework;
37
44
  }): string;
38
45
  //# sourceMappingURL=codegen-mcp.d.ts.map
@@ -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;AAmWD,0GAA0G;AAC1G,wBAAgB,uBAAuB,C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uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,sGAAsG;AACtG,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;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,eAAe,CAAA;CAAO,GAAG,MAAM,CAGtG"}
@@ -1,10 +1,13 @@
1
1
  import type { OpRootNode, OpRouteNode, OpOperationNode, ContractTypeNode } from '@contractkit/core';
2
+ import type { ServerFramework } from './server-framework.js';
3
+ /** Which request-side object a validation block reads from. Names the variable the block declares. */
4
+ export type ParamKind = 'params' | 'query' | 'headers';
2
5
  /**
3
6
  * Deep structural equality on ContractTypeNode, ignoring source locations on inline fields.
4
7
  * Used to decide whether multiple declared request MIMEs can share a single validate path.
5
8
  */
6
9
  export declare function bodyTypesStructurallyEqual(a: ContractTypeNode, b: ContractTypeNode): boolean;
7
- /** Options controlling how {@link generateOp} renders a Koa router module. */
10
+ /** Options controlling how {@link generateOp} renders a server router module. */
8
11
  export interface OpCodegenOptions {
9
12
  servicePathTemplate?: string;
10
13
  typeImportPathTemplate?: string;
@@ -22,8 +25,8 @@ export interface OpCodegenOptions {
22
25
  */
23
26
  includeInternal?: boolean;
24
27
  /**
25
- * Re-parse the service result through its declared response schema before writing `ctx.body`,
26
- * and write the parsed value. Requires the type file to hold Zod schemas (`server.zod`) —
28
+ * Re-parse the service result through its declared response schema before writing the response
29
+ * body, and write the parsed value. Requires the type file to hold Zod schemas (`server.zod`) —
27
30
  * plain interfaces are types, with no runtime schema value to validate against. Default false.
28
31
  */
29
32
  validateResponses?: boolean;
@@ -33,9 +36,14 @@ export interface OpCodegenOptions {
33
36
  * post-transform shape, which the schema itself cannot re-parse.
34
37
  */
35
38
  modelsWithTransform?: Set<string>;
39
+ /**
40
+ * Which HTTP framework the emitted router targets. Every framework-specific string in the output
41
+ * comes from here. Defaults to Koa, the only framework shipped today.
42
+ */
43
+ framework?: ServerFramework;
36
44
  }
37
45
  /**
38
- * Generate a Koa router module for every operation in `root`, including the imports, type
46
+ * Generate a server router module for every operation in `root`, including the imports, type
39
47
  * aliases, and handler list.
40
48
  *
41
49
  * Imports are derived from the generated body — each candidate symbol is emitted only if it
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-operation.d.ts","sourceRoot":"","sources":["../src/codegen-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,WAAW,EACX,eAAe,EAGf,gBAAgB,EAInB,MAAM,mBAAmB,CAAC;AAmC3B;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CA0E5F;AAID,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qFAAqF;IACrF,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,O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AM,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,qFAAqF;IACrF,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;CAC/B;AAKD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAgHnF;AAuTD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAY7H;AAoBD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,eAAe,GAAG,MAAM,CAqBzE;AAgbD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWnD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ/E"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,20 @@
1
1
  import type { ContractKitPlugin } from '@contractkit/core';
2
- /** Koa server output: routers, and the type or Zod schema files they import. */
2
+ import { type ServerFrameworkName } from './server-framework.js';
3
+ export { SERVER_FRAMEWORK_NAMES, DEFAULT_SERVER_FRAMEWORK_NAME, resolveServerFramework, SERVER_FRAMEWORKS, type ServerFramework, type ServerFrameworkName, } from './server-framework.js';
4
+ export { KOA_SERVER_FRAMEWORK } from './server-framework-koa.js';
5
+ /** Server output: routers, and the type or Zod schema files they import. */
3
6
  export interface ServerConfig {
4
7
  /** Directory (relative to rootDir) where server files are written. Default: rootDir. */
5
8
  baseDir?: string;
9
+ /**
10
+ * HTTP framework the generated routers target. Also selects the flavour of the optional
11
+ * `mcp.router.ts` the `mcp` sub-config emits. Supported: `'koa'`. Default `'koa'`.
12
+ */
13
+ framework?: ServerFrameworkName;
6
14
  /** When true, `output.types` emits Zod schema files (via `generateContract`). When false/omitted, emits plain TypeScript. */
7
15
  zod?: boolean;
8
16
  output?: {
9
- /** Path template for Koa router files. Supports {filename}, {dir}, {area}. */
17
+ /** Path template for router files. Supports {filename}, {dir}, {area}. */
10
18
  routes?: string;
11
19
  /** Path template for type/schema files. Supports {filename}, {dir}, {area}. */
12
20
  types?: string;
@@ -81,7 +89,7 @@ export interface McpConfig {
81
89
  */
82
90
  types?: string;
83
91
  };
84
- /** Emit the `mcp.router.ts` route boilerplate. Default true. */
92
+ /** Emit the `mcp.router.ts` route boilerplate. Its framework follows `server.framework`. Default true. */
85
93
  emitRouter?: boolean;
86
94
  /** Mount path used in the emitted router. Default `/mcp`. */
87
95
  path?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,iBAAiB,EASpB,MAAM,mBAAmB,CAAC;AAqD3B,gFAAgF;AAChF,MAAM,WAAW,YAAY;IACzB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6HAA6H;IAC7H,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE;QACL,8EAA8E;QAC9E,MA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