@contractkit/plugin-typescript 0.34.1 → 0.36.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.
- package/.turbo/turbo-build$colon$ci.log +5 -5
- package/.turbo/turbo-test$colon$ci.log +25 -18
- package/CHANGELOG.md +56 -0
- package/README.md +4 -3
- package/dist/codegen-mcp.d.ts +8 -1
- package/dist/codegen-mcp.d.ts.map +1 -1
- package/dist/codegen-operation.d.ts +13 -5
- package/dist/codegen-operation.d.ts.map +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +370 -91
- package/dist/index.js.map +1 -1
- package/dist/server-framework-fastify.d.ts +8 -0
- package/dist/server-framework-fastify.d.ts.map +1 -0
- package/dist/server-framework-koa.d.ts +7 -0
- package/dist/server-framework-koa.d.ts.map +1 -0
- package/dist/server-framework.d.ts +101 -0
- package/dist/server-framework.d.ts.map +1 -0
- package/llms.txt +1 -1
- package/package.json +2 -2
- package/src/codegen-mcp.ts +11 -25
- package/src/codegen-operation.ts +146 -77
- package/src/index.ts +37 -5
- package/src/server-framework-fastify.ts +128 -0
- package/src/server-framework-koa.ts +114 -0
- package/src/server-framework.ts +129 -0
- package/tests/codegen-mcp.test.ts +12 -0
- package/tests/codegen-operation-framework.test.ts +184 -0
- package/tests/codegen-operation.test.ts +74 -0
- package/tests/codegen-server.test.ts +56 -0
- package/tests/server-framework-fastify.test.ts +148 -0
- package/tests/server-framework-koa.test.ts +115 -0
- package/tests/server-framework.test.ts +25 -0
|
@@ -5,9 +5,9 @@ $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly
|
|
|
5
5
|
[34mCLI[39m tsup v8.5.1
|
|
6
6
|
[34mCLI[39m Target: esnext
|
|
7
7
|
[34mESM[39m Build start
|
|
8
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
9
|
-
[32mESM[39m [1mdist/index.js.map [22m[
|
|
10
|
-
[32mESM[39m ⚡️ Build success in
|
|
8
|
+
[32mESM[39m [1mdist/index.js [22m[32m230.12 KB[39m
|
|
9
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m542.08 KB[39m
|
|
10
|
+
[32mESM[39m ⚡️ Build success in 359ms
|
|
11
11
|
[34mDTS[39m Build start
|
|
12
|
-
[32mDTS[39m ⚡️ Build success in
|
|
13
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
12
|
+
[32mDTS[39m ⚡️ Build success in 3932ms
|
|
13
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m11.34 KB[39m
|
|
@@ -3,36 +3,43 @@ $ vitest run --coverage
|
|
|
3
3
|
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.5 [39m[90m/home/runner/work/ContractKit/ContractKit/packages/plugin-typescript[39m
|
|
4
4
|
[2mCoverage enabled with [22m[33mv8[39m
|
|
5
5
|
|
|
6
|
-
[32m✓[39m tests/codegen-
|
|
7
|
-
[32m✓[39m tests/codegen-
|
|
8
|
-
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m173 tests[22m[2m)[22m[
|
|
9
|
-
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m67 tests[22m[2m)[22m[32m
|
|
10
|
-
[32m✓[39m tests/codegen-server.test.ts [2m([22m[
|
|
11
|
-
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m
|
|
12
|
-
[32m✓[39m tests/
|
|
13
|
-
[32m✓[39m tests/
|
|
14
|
-
[32m✓[39m tests/
|
|
6
|
+
[32m✓[39m tests/codegen-operation.test.ts [2m([22m[2m166 tests[22m[2m)[22m[32m 190[2mms[22m[39m
|
|
7
|
+
[32m✓[39m tests/codegen-contract.test.ts [2m([22m[2m147 tests[22m[2m)[22m[32m 182[2mms[22m[39m
|
|
8
|
+
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m173 tests[22m[2m)[22m[32m 228[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m67 tests[22m[2m)[22m[32m 39[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m39 tests[22m[2m)[22m[32m 129[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m 542[2mms[22m[39m
|
|
12
|
+
[32m✓[39m tests/codegen-mcp.test.ts [2m([22m[2m33 tests[22m[2m)[22m[32m 52[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/server-framework-fastify.test.ts [2m([22m[2m25 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
14
|
+
[32m✓[39m tests/codegen-operation-framework.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
15
|
+
[32m✓[39m tests/server-framework-koa.test.ts [2m([22m[2m19 tests[22m[2m)[22m[32m 22[2mms[22m[39m
|
|
16
|
+
[32m✓[39m tests/ts-render.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
17
|
+
[32m✓[39m tests/server-framework.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
18
|
+
[32m✓[39m tests/escaping-security.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 20[2mms[22m[39m
|
|
15
19
|
|
|
16
|
-
[2m Test Files [22m [1m[
|
|
17
|
-
[2m Tests [22m [1m[
|
|
18
|
-
[2m Start at [22m
|
|
19
|
-
[2m Duration [22m
|
|
20
|
+
[2m Test Files [22m [1m[32m13 passed[39m[22m[90m (13)[39m
|
|
21
|
+
[2m Tests [22m [1m[32m744 passed[39m[22m[90m (744)[39m
|
|
22
|
+
[2m Start at [22m 19:51:10
|
|
23
|
+
[2m Duration [22m 9.04s[2m (transform 3.75s, setup 0ms, import 16.64s, tests 1.45s, environment 3ms)[22m
|
|
20
24
|
|
|
21
25
|
[34m % [39m[2mCoverage report from [22m[33mv8[39m
|
|
22
26
|
-------------------|---------|----------|---------|---------|-------------------
|
|
23
27
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
24
28
|
-------------------|---------|----------|---------|---------|-------------------
|
|
25
|
-
All files |
|
|
26
|
-
src |
|
|
29
|
+
All files | 84.73 | 78.53 | 88.26 | 87.45 |
|
|
30
|
+
src | 84.57 | 78.23 | 87.97 | 87.3 |
|
|
27
31
|
...n-contract.ts | 90.13 | 85.89 | 90.51 | 90.9 | ...1166,1171-1172
|
|
28
|
-
codegen-mcp.ts |
|
|
29
|
-
...-operation.ts | 83.
|
|
32
|
+
codegen-mcp.ts | 83.44 | 75.46 | 84.21 | 86.61 | ...01,306-307,392
|
|
33
|
+
...-operation.ts | 83.68 | 80.85 | 81.08 | 85.74 | ...1114,1119-1120
|
|
30
34
|
...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
|
|
31
35
|
...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
|
|
32
36
|
codegen-sdk.ts | 88.46 | 80.47 | 90.55 | 91.36 | ...1891,1895-1896
|
|
33
37
|
...al-runtime.ts | 100 | 100 | 100 | 100 |
|
|
34
|
-
index.ts |
|
|
38
|
+
index.ts | 77.23 | 65.81 | 83.6 | 81.28 | ...1153,1169-1188
|
|
35
39
|
path-utils.ts | 70.5 | 52.27 | 100 | 73.72 | ...75-178,226-241
|
|
40
|
+
...rk-fastify.ts | 100 | 100 | 100 | 100 |
|
|
41
|
+
...mework-koa.ts | 100 | 100 | 100 | 100 |
|
|
42
|
+
...-framework.ts | 100 | 100 | 100 | 100 |
|
|
36
43
|
ts-render.ts | 86.04 | 88.23 | 80 | 90.14 | 103,191,224-232
|
|
37
44
|
tests | 94.73 | 95.12 | 93.54 | 96 |
|
|
38
45
|
helpers.ts | 94.73 | 95.12 | 93.54 | 96 | 120,128
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @contractkit/contractkit-plugin-typescript
|
|
2
2
|
|
|
3
|
+
## 0.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 18263e2: Generate Fastify routers with `server.framework: "fastify"`.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
"server": { "framework": "fastify", "baseDir": "apps/api/" }
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Output targets `@maroonedsoftware/fastify`, whose exported surface mirrors the Koa one, so a contract compiles to the same handlers either way:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
BillingRouter.post('/payments', requirePolicy(), bodyParserMiddleware(['json']), async (request, reply) => {
|
|
17
|
+
const body = await parseAndValidate(request.parsedBody, PaymentInput);
|
|
18
|
+
|
|
19
|
+
const service = request.container.get(PaymentService);
|
|
20
|
+
const result: Payment = await service.create(body);
|
|
21
|
+
|
|
22
|
+
reply.status(200);
|
|
23
|
+
reply.type('application/json');
|
|
24
|
+
return reply.send(result);
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Three differences are worth knowing before you switch:
|
|
29
|
+
- **The request is the context.** Handlers take `(request, reply)`, and params, query, headers, the DI container and the parsed body all hang off `request`. Fastify's own `request.body` is never populated, because ServerKit parses lazily per route.
|
|
30
|
+
- **Responses are returned, not assigned.** A handler that neither returns a body nor calls `send` leaves the request hanging, so a bodyless 204 emits an explicit `return reply.send();` where Koa emits nothing at all.
|
|
31
|
+
- **Content type comes from `requestMediaType(request)`.** Fastify has no accessor that strips the parameters off the header, and a raw `application/json; charset=utf-8` matches none of the MIME literals an operation declares.
|
|
32
|
+
|
|
33
|
+
`koa` remains the default and its output is unchanged. The generated `mcp.router.ts` follows the setting, using `reply.hijack()` where the Koa mount sets `ctx.respond = false`.
|
|
34
|
+
|
|
35
|
+
Separately, a path parameter whose name collides with an identifier the handler already binds is now renamed. `/threads/{reply}` emitted `const { reply } = ...` inside `async (request, reply) => {`, a redeclaration under `tsc` and a temporal-dead-zone `ReferenceError` at runtime; the same held on Koa for a parameter named `ctx`, and on both for one named after a generator local such as `body` or `query`. Only the local binding moves, so the wire name, the schema key and the route placeholder are untouched.
|
|
36
|
+
|
|
37
|
+
## 0.35.0
|
|
38
|
+
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- 731ab7a: Add `server.framework`, and render the generated router through a framework adapter.
|
|
42
|
+
|
|
43
|
+
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:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
"server": { "framework": "koa", "baseDir": "apps/api/" }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`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:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
plugin-typescript: server.framework 'express' is not supported — expected one of: koa.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The optional `mcp.router.ts` follows the same setting, including when there is no `server` sub-config at all, where it stays Koa.
|
|
56
|
+
|
|
57
|
+
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.
|
|
58
|
+
|
|
3
59
|
## 0.34.1
|
|
4
60
|
|
|
5
61
|
### 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
|
|
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: `"koa"` or `"fastify"`. Also selects the `mcp.router.ts` flavour. |
|
|
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
|
-
###
|
|
133
|
+
### Router shape (from `operation`)
|
|
133
134
|
|
|
134
|
-
Each operation file generates one Koa
|
|
135
|
+
Each operation file generates one router, targeting the framework named by `framework`. On Koa a handler is `async ctx => {}` writing `ctx.status` / `ctx.type` / `ctx.body`; on Fastify it is `async (request, reply) => {}` reading `request.parsedBody` and returning `reply.send(...)`. Validation, service dispatch and the response shape are identical either way. 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
|
|
package/dist/codegen-mcp.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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;
|
|
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;AAOhI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,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,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
|
|
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
|
|
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
|
|
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
|
|
@@ -66,7 +74,7 @@ export declare function inferService(op: OpOperationNode, route: OpRouteNode, fi
|
|
|
66
74
|
*
|
|
67
75
|
* @returns The rendered argument list, or an empty string when the method takes no arguments.
|
|
68
76
|
*/
|
|
69
|
-
export declare function buildArgs(route: OpRouteNode, op: OpOperationNode): string;
|
|
77
|
+
export declare function buildArgs(route: OpRouteNode, op: OpOperationNode, bindings?: Map<string, string>): string;
|
|
70
78
|
/**
|
|
71
79
|
* Derive the PascalCase base name used for router, service, and type names from a contract file path.
|
|
72
80
|
*
|
|
@@ -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;
|
|
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;AAa3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,sGAAsG;AACtG,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAsDvD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CA0E5F;AAID,iFAAiF;AACjF,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,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;AA0TD;;;;;;;;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,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAuBzG;AA2bD;;;;;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,21 @@
|
|
|
1
1
|
import type { ContractKitPlugin } from '@contractkit/core';
|
|
2
|
-
|
|
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
|
+
export { FASTIFY_SERVER_FRAMEWORK } from './server-framework-fastify.js';
|
|
6
|
+
/** Server output: routers, and the type or Zod schema files they import. */
|
|
3
7
|
export interface ServerConfig {
|
|
4
8
|
/** Directory (relative to rootDir) where server files are written. Default: rootDir. */
|
|
5
9
|
baseDir?: string;
|
|
10
|
+
/**
|
|
11
|
+
* HTTP framework the generated routers target. Also selects the flavour of the optional
|
|
12
|
+
* `mcp.router.ts` the `mcp` sub-config emits. Supported: `'koa'`. Default `'koa'`.
|
|
13
|
+
*/
|
|
14
|
+
framework?: ServerFrameworkName;
|
|
6
15
|
/** When true, `output.types` emits Zod schema files (via `generateContract`). When false/omitted, emits plain TypeScript. */
|
|
7
16
|
zod?: boolean;
|
|
8
17
|
output?: {
|
|
9
|
-
/** Path template for
|
|
18
|
+
/** Path template for router files. Supports {filename}, {dir}, {area}. */
|
|
10
19
|
routes?: string;
|
|
11
20
|
/** Path template for type/schema files. Supports {filename}, {dir}, {area}. */
|
|
12
21
|
types?: string;
|
|
@@ -81,7 +90,7 @@ export interface McpConfig {
|
|
|
81
90
|
*/
|
|
82
91
|
types?: string;
|
|
83
92
|
};
|
|
84
|
-
/** Emit the `mcp.router.ts` route boilerplate. Default true. */
|
|
93
|
+
/** Emit the `mcp.router.ts` route boilerplate. Its framework follows `server.framework`. Default true. */
|
|
85
94
|
emitRouter?: boolean;
|
|
86
95
|
/** Mount path used in the emitted router. Default `/mcp`. */
|
|
87
96
|
path?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,iBAAiB,EASpB,MAAM,mBAAmB,CAAC;AAiC3B,OAAO,EAAkD,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjH,OAAO,EACH,sBA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