@contractkit/plugin-typescript 0.33.2 → 0.34.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.
Files changed (39) hide show
  1. package/.turbo/turbo-build$colon$ci.log +4 -4
  2. package/.turbo/turbo-test$colon$ci.log +26 -25
  3. package/CHANGELOG.md +273 -0
  4. package/dist/codegen-contract.d.ts +22 -6
  5. package/dist/codegen-contract.d.ts.map +1 -1
  6. package/dist/codegen-mcp.d.ts.map +1 -1
  7. package/dist/codegen-operation.d.ts.map +1 -1
  8. package/dist/codegen-plain-types.d.ts.map +1 -1
  9. package/dist/codegen-revive.d.ts +38 -4
  10. package/dist/codegen-revive.d.ts.map +1 -1
  11. package/dist/codegen-sdk.d.ts +2 -0
  12. package/dist/codegen-sdk.d.ts.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +413 -202
  16. package/dist/index.js.map +1 -1
  17. package/dist/path-utils.d.ts +9 -0
  18. package/dist/path-utils.d.ts.map +1 -1
  19. package/dist/ts-render.d.ts +14 -0
  20. package/dist/ts-render.d.ts.map +1 -1
  21. package/package.json +3 -2
  22. package/src/codegen-contract.ts +84 -68
  23. package/src/codegen-mcp.ts +12 -11
  24. package/src/codegen-operation.ts +32 -19
  25. package/src/codegen-plain-types.ts +15 -8
  26. package/src/codegen-revive.ts +140 -20
  27. package/src/codegen-sdk.ts +322 -63
  28. package/src/index.ts +46 -4
  29. package/src/path-utils.ts +10 -0
  30. package/src/ts-render.ts +26 -0
  31. package/tests/codegen-contract.test.ts +87 -32
  32. package/tests/codegen-mcp.test.ts +31 -0
  33. package/tests/codegen-operation.test.ts +68 -8
  34. package/tests/codegen-plain-types.test.ts +13 -5
  35. package/tests/codegen-sdk.test.ts +265 -10
  36. package/tests/codegen-server.test.ts +43 -1
  37. package/tests/helpers.ts +7 -2
  38. package/tests/pipeline.test.ts +51 -4
  39. package/tests/ts-render.test.ts +29 -0
@@ -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 220.70 KB
9
+ ESM dist/index.js.map 514.14 KB
10
+ ESM ⚡️ Build success in 310ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 4711ms
12
+ DTS ⚡️ Build success in 3538ms
13
13
  DTS dist/index.d.ts 5.14 KB
@@ -3,36 +3,37 @@ $ 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-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
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
+  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)
19
20
 
20
21
   % Coverage report from v8
21
22
  -------------------|---------|----------|---------|---------|-------------------
22
23
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
23
24
  -------------------|---------|----------|---------|---------|-------------------
24
- All files | 83.01 | 77.14 | 86.06 | 85.64 |
25
- src | 82.87 | 76.85 | 85.8 | 85.49 |
26
- ...n-contract.ts | 89.24 | 83.92 | 90.16 | 90.42 | ...1150,1155-1156
27
- codegen-mcp.ts | 82.33 | 74.84 | 84.21 | 85.77 | ...97,302-303,386
28
- ...-operation.ts | 83.02 | 80.71 | 79.71 | 85.18 | ...1032,1037-1038
29
- ...lain-types.ts | 88.44 | 80.74 | 97.05 | 90.74 | ...71,197,309,315
30
- ...gen-revive.ts | 57.77 | 52.04 | 75 | 62.74 | ...65-196,278-284
31
- codegen-sdk.ts | 88.96 | 82.01 | 90.56 | 91.78 | ...1632,1636-1637
25
+ All files | 83.33 | 77.36 | 86.64 | 85.95 |
26
+ src | 83.14 | 77.04 | 86.23 | 85.78 |
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
29
+ ...-operation.ts | 83.06 | 80.46 | 80.28 | 85.15 | ...1045,1050-1051
30
+ ...lain-types.ts | 91.7 | 83.8 | 96.96 | 94.57 | ...79,204,316,322
31
+ ...gen-revive.ts | 59.23 | 52.54 | 78.37 | 65.28 | ...85-316,398-404
32
+ codegen-sdk.ts | 88.46 | 80.47 | 90.55 | 91.36 | ...1891,1895-1896
32
33
  ...al-runtime.ts | 100 | 100 | 100 | 100 |
33
- index.ts | 67.96 | 54.68 | 75 | 71.09 | ...1079,1095-1114
34
- path-utils.ts | 70.28 | 51.13 | 100 | 73.5 | ...65-168,216-231
35
- ts-render.ts | 85.18 | 87.5 | 79.16 | 89.39 | 83,165,198-206
36
- tests | 91.22 | 92.68 | 90.32 | 94 |
37
- helpers.ts | 91.22 | 92.68 | 90.32 | 94 | 115-123
34
+ index.ts | 68.64 | 55.2 | 75.4 | 71.67 | ...1121,1137-1156
35
+ path-utils.ts | 70.5 | 52.27 | 100 | 73.72 | ...75-178,226-241
36
+ ts-render.ts | 86.04 | 88.23 | 80 | 90.14 | 103,191,224-232
37
+ tests | 94.73 | 95.12 | 93.54 | 96 |
38
+ helpers.ts | 94.73 | 95.12 | 93.54 | 96 | 120,128
38
39
  -------------------|---------|----------|---------|---------|-------------------
package/CHANGELOG.md CHANGED
@@ -1,5 +1,278 @@
1
1
  # @contractkit/contractkit-plugin-typescript
2
2
 
3
+ ## 0.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f453bf5: Honour the optionality an inline `query:` or `headers:` block declares, in the router, the SDK and the OpenAPI document.
8
+
9
+ All three read the same `OpParamNode.optional`, and all three ignored it. The router validated every inline param as required, the SDK typed every one optional, and OpenAPI marked every non-path parameter `required: false`. So for a contract saying
10
+
11
+ ```
12
+ query: { limit?: int = 20, cursor: string }
13
+ headers: { api-key?: string, x-tenant: string }
14
+ ```
15
+
16
+ the SDK let you omit a `cursor` the router would then reject, while typing `limit` as something you had to think about even though it has a default; and the published spec disagreed with both.
17
+
18
+ Now:
19
+ - **Router** — the param schema carries the same modifier chain a model field does, via the shared `applyFieldModifiers`. `limit` becomes `.default(20)`, `api-key` becomes `.optional()`. The hand-rolled query-array preprocess is gone too, delegating to `renderQueryType`, which already had that rule.
20
+ - **SDK** — a field is optional only when the contract says so, either with `?` or by carrying a default. The whole argument is optional only when every field is, since a caller cannot omit an object that must supply something.
21
+ - **OpenAPI** — `required` follows the contract for query and header parameters, matching what the `inlineObject` branch already did. The two `$ref` branches are unchanged: a whole-model param source has no per-field optionality to read.
22
+
23
+ **Python is deliberately excluded.** It hardcodes `optional: true` on query and headers, and has the same ordering constraint as a `SyntaxError` rather than a type error. Permissive is safe; changing it belongs with the work that gives inline query params a `TypedDict`.
24
+
25
+ ### What this breaks
26
+
27
+ **SDK call sites stop compiling when an argument becomes required.** The old signature was wrong in both directions at once, so this surfaces two different latent bugs: calls that omitted a value the router demanded, and required fields typed as optional so nothing made you pass them.
28
+
29
+ **Requests omitting a non-optional inline param now get a 400.** They were already being rejected by the router; what changes is that the SDK and the spec now say so. To find the affected surface, grep your contracts for inline `query:` and `headers:` blocks whose fields lack a `?` — that set is exactly the delta.
30
+
31
+ One case only becomes reachable now: parameter order is path, body, query, then customHeaders, so an all-optional `query:` in front of an all-required `headers:` would emit `async m(query?: Q, customHeaders: H)`, which is `TS1016`. A normalisation pass clears `optional` on every argument before the last required one, which is the only fix that keeps the positional order call sites depend on.
32
+
33
+ - c93b5c4: Return 204 when an operation emits no response, instead of an error status.
34
+
35
+ The generated router picked its status as `emitted ?? first declared ?? 200`. For an operation whose response block is documentation only, the first declared status is an error code, so the router answered a _successful_ request with it:
36
+
37
+ ```
38
+ delete: {
39
+ response: {
40
+ 400:
41
+ }
42
+ }
43
+ ```
44
+
45
+ emitted `ctx.status = 400` on the success path. A bare status means "documented, produced by something else" — middleware, a proxy, the framework — so it is precisely the status the service does not produce, and the worst possible choice of fallback.
46
+
47
+ 204 is the status that aligns the three generators. `observableResponses` excludes a bare `400:` for the same reason `emittedResponses` does, so the SDK already types such a method `Promise<void>` and `thrownResponses` already puts the 400 in `@throws`. A bodyless 204 success is exactly what `Promise<void>` means; the router was the only one disagreeing.
48
+
49
+ ### What this breaks
50
+
51
+ **Operations declaring only non-2xx statuses now return 204 rather than that status.** The old behaviour was an error code returned on success, so any client treating it as an error was correct to and now gets a success it can act on. If you genuinely want that status written, give it a block — `400: { … }` — which makes it service-produced and restores it.
52
+
53
+ An operation with no `response:` block at all also moves from 200 to 204, on the same reasoning: it emits nothing, and 204 says so precisely. Both are 2xx, so nothing that checks for success changes behaviour; a client asserting `status === 200` would need updating.
54
+
55
+ - 0e10409: Apply the bigint JSON reviver only to contracts that actually declare a `bigint`.
56
+
57
+ `parseJson` ran every response through `bigIntReviver`, which tests `/^-?\d+n$/` against every string anywhere in the document. A contract with no `bigint` field still had a legitimate value like `"123n"` — a product code, a hash fragment, a user's own text — silently turned into a `BigInt`, at any depth, in any field.
58
+
59
+ The shared runtime now exports two functions. Clients whose responses carry a `bigint` import `parseJsonWithBigInt` aliased to `parseJson`, so the method bodies are identical either way and the import line is where the choice is legible.
60
+
61
+ The predicate is transitive and cross-file, because a `bigint` reached through a referenced model still arrives on the wire as `123n`. It comes from a `modelsWithBigInt` taint set computed the same way `modelsWithDecimal` is, and sliced into the same per-file fingerprints — so a model gaining a `bigint` in another `.ck` file invalidates the clients that read it, rather than leaving a cached client with the wrong import.
62
+
63
+ A full schema-driven revival was considered and rejected: `bigIntReplacer` serialises bigints at any depth on the way out, so a path-aware reviver would have to cover exactly the same paths to stay symmetric. Gating the whole reviver on a contract-level predicate takes almost all of the benefit for a fraction of the machinery.
64
+
65
+ Renamed `sdkNeedsBigIntReviver` to `sdkParsesJsonResponse` along the way. It tests whether an operation reads a JSON response body at all, which is now the gate for importing `parseJson` in either form — and is a different question from whether the reviver is needed.
66
+
67
+ ### What this breaks
68
+
69
+ A response field holding the string `"123n"` now stays a string, unless the contract declares that field as `bigint`. If you were relying on the conversion, declare the field `bigint` and it comes back.
70
+
71
+ - a3c2598: Reject non-string JSON values for numeric scalars, instead of silently turning them into numbers.
72
+
73
+ `number` and `int` compiled to `z.coerce.number()`, which is `Number(v)`. That accepts far more than a number: `[]` and `""` become `0`, `null` becomes `0`, `true` becomes `1`. So `{"quantity": []}` validated cleanly and the handler ran on a value the client never sent.
74
+
75
+ The coercion is now narrowed to the case that motivates it:
76
+
77
+ ```ts
78
+ z.preprocess(v => (typeof v === 'string' && v.trim() !== '' ? Number(v) : v), z.number());
79
+ ```
80
+
81
+ A non-empty string still converts, because query strings and headers arrive as text and a JSON body carrying `"42"` is common enough that rejecting it would break working callers. Everything else is handed to `z.number()`, which judges it.
82
+
83
+ This is the shape the `boolean` scalar already had: its preprocess maps only the two literal strings and passes everything else through to `z.boolean()`. It needed no change.
84
+
85
+ Constraints move inside the preprocess — `z.preprocess(…, z.number().min(1))` rather than `.min(1)` on the outside — because `z.preprocess` returns a `ZodPipe`, which has no `.min()`. The `bigint` scalar already did it this way.
86
+
87
+ ### What this breaks
88
+
89
+ `{"petId": []}`, `{"n": null}` and `{"n": true}` now get a 400 where they previously validated as `0`, `0` and `1`. Frame this as the fix it is: those requests were being accepted and acted on with a value the caller did not send. String-shaped numbers still coerce, so query parameters and headers are unaffected.
90
+
91
+ Not addressed here: the JSON-versus-string wire split. `XInput` is a single exported `const` reused for both `query: X` and `request: { application/json: X }`, so a truly strict body schema needs a second emitted variant plus import plumbing. `renderInputScalar` remains the documented seam for that, with its docstring corrected — it claimed to coerce from string input while being a pure passthrough.
92
+
93
+ - cb06aec: Derive valid identifiers from path parameter names, so a hyphenated path param generates code that works.
94
+
95
+ `operation /invoices/{invoice-id}` is a legal contract — the grammar's `identPart` admits `-` and `.` — but it is not a valid TypeScript identifier, and every TypeScript generator used the contract's spelling directly:
96
+
97
+ ```ts
98
+ HyphenatedRouter.get('/invoices/{invoice-id}', requirePolicy(), async ctx => {
99
+ const { invoice-id } = await parseAndValidate(ctx.params, ...);
100
+ ```
101
+
102
+ Three separate failures in those two lines. The route pattern kept the braces, so Koa registered a literal path no request could match. The destructuring did not parse. And the SDK emitted `async getInvoice(invoice-id: string)`, which did not parse either.
103
+
104
+ Names the generated code has to _bind_ are now mapped through `toIdentifier`, so `invoice-id` becomes `invoiceId`:
105
+ - **Router** — the Koa pattern becomes `/invoices/:invoiceId`, the params schema is keyed to match (that is what `ctx.params` carries), and the service call passes the bound name.
106
+ - **SDK** — the method parameter and the URL interpolation use the identifier.
107
+ - **MCP** — the tool's input schema and the handler's destructuring use it.
108
+
109
+ **Nothing on the wire changes.** A path placeholder's name never reaches the client: Koa matches by position, so `GET /invoices/abc123` behaves exactly as before. That is what makes the rename safe, and it is the reason query parameters, headers and OpenAPI parameters are deliberately _not_ renamed — those names are what the client actually sends, or must match a path template the same document declares.
110
+
111
+ `toIdentifier` returns its input unchanged whenever it is already an identifier, so no existing generated output moves. It lives in core next to the path-parameter pattern, because the Bruno plugin needs the same mapping for its own `:variable` syntax.
112
+
113
+ - 12040d1: Revive temporal scalars in generated SDK clients, so a `datetime` field really is a Luxon `DateTime`.
114
+
115
+ In `sdk: { zod: true }` mode a `datetime` field's type comes from `z.infer` over `z.custom<DateTime>`, so the SDK has always _claimed_ to return a `DateTime`. The client reads its response with `JSON.parse` and a cast, and never runs the schema — so at runtime the field held a string, and `order.shipDate.toISO()` threw. The same held for `date`, `time` and `duration`.
116
+
117
+ The generated `reviveX` functions now rehydrate those scalars alongside `decimal`, using helpers that mirror what the schema validates against:
118
+ - `datetime` → `DateTime.fromISO`
119
+ - `duration` → `Duration.fromISO`
120
+ - `date` and `time` → `DateTime.fromFormat` with the format from the contract, defaulting to `yyyy-MM-dd` and `HH:mm:ss`
121
+
122
+ Each throws a `TypeError` naming the field path rather than returning something invalid, since a silently wrong `DateTime` surfaces much further from its cause than a throw at the boundary does. A file gets only the helpers its revivers call, decided by scanning the emitted text — the idiom the reviver and type imports already use, for the same reason: a separately computed predicate can drift and leave an unused local behind.
123
+
124
+ `interval` is deliberately excluded. `_ZodInterval` ends in `.transform(v => v.toISO()!)`, so its inferred output type is already `string` and there is nothing to revive it to. Covering it means making that round-trip idempotent first, which the router's `isRevalidatable` also depends on.
125
+
126
+ Two things ride along:
127
+
128
+ **Plain types now say `DateTime` too.** `renderTsScalar` mapped every temporal to `string` for both targets, so `types:` output disagreed with what the router and the SDK actually hand you. It now renders the Luxon classes, and the emitted file imports them.
129
+
130
+ **`_ZodBinary` follows the render target.** It was `z.custom<Buffer>` unconditionally, and SDK type files reach it through the same `generateContract`, so a browser client got `Buffer.isBuffer` with no `@types/node` in its scaffold — the type did not resolve and the check could not run. The SDK's schemas are now client-shaped (`Blob`), matching what `renderTsScalar` has always said for that target; the server and standalone `zod:` outputs are unchanged.
131
+
132
+ No bump to `TYPESCRIPT_CODEGEN_VERSION` is needed; it was already raised to `2` earlier in this batch. Cache invalidation for the wider taint set comes for free: every `hashFingerprint` that slices it already exists, so a model gaining a `datetime` in another `.ck` file invalidates dependent output as it should.
133
+
134
+ ### Patch Changes
135
+
136
+ - 27af3f2: Generalise the decimal taint-set helpers over an arbitrary set of scalars.
137
+
138
+ `typeHasDecimal` and `computeModelsWithDecimal` hardcoded `decimal`, but the question they answer is not specific to it: any scalar whose runtime type differs from what `JSON.parse` produces taints a model the same way, and needs the same transitive answer through referenced models.
139
+
140
+ Core now exports `typeHasScalar(type, scalars)` and `computeModelsWithScalar(models, scalars, external)`. `computeModelsWithDecimal` stays as a thin wrapper over a one-member set, so every existing caller is untouched. The TypeScript plugin's `ReviveCodegenOptions` gains an optional `revivableScalars`, defaulting to the same one-member set.
141
+
142
+ Decimal remains the only member and no generated output changes.
143
+
144
+ One thing settled in passing: core's predicate checks a `record`'s key _and_ value while the reviver's checks only the value, and that divergence is correct rather than an oversight. Core answers "is this scalar mentioned", which decides imports, and a `record(decimal, string)` schema does reference the `Decimal` type. The reviver answers "is there a value to rehydrate", and a JSON object key is always a string, so there is nothing at a key position to convert. Both are now documented in place.
145
+
146
+ - fb39996: Fix `@deprecated` being dropped from generated SDK methods that also have a description.
147
+
148
+ The SDK emitted the deprecation as its own block, immediately above the block carrying `@name`, `@description` and `@throws`:
149
+
150
+ ```ts
151
+ /** @deprecated */
152
+ /** @description look up a refund by its originating payment */
153
+ async getRefund(params: PaymentRef): Promise<Payment> {
154
+ ```
155
+
156
+ TypeScript associates only the JSDoc comment _adjacent_ to a declaration, so the deprecation was invisible to editors and to `tsc` whenever the operation also had a description or an error contract, which is the common case. It survived only on operations that had nothing else to document.
157
+
158
+ `@deprecated` is now a tag inside the one block, in the same position the Koa router already puts it:
159
+
160
+ ```ts
161
+ /**
162
+ * @description look up a refund by its originating payment
163
+ * @deprecated
164
+ */
165
+ ```
166
+
167
+ No bump to `TYPESCRIPT_CODEGEN_VERSION` is needed; it was already raised to `2` earlier in this batch.
168
+
169
+ - 78462d7: Stop emitting the `ModelBase` Zod schema, which nothing has ever read.
170
+
171
+ A model with writeonly fields emitted three schemas: `ModelBase` with every field, `Model` (read, no writeonly) and `ModelInput` (write, no readonly). Only the last two were exported. `ModelBase` was a plain `const`, and the sole place a `XBase` name was ever _referenced_ was inside the block that declares `YBase` for a child model — so `XBase` was read only by `YBase`, and no `YBase` was read by anything reachable. The read schema extends the parent's read schema directly, and the input schema extends the parent's input schema; neither goes through a Base. The construct was a closed island, and under `noUnusedLocals` it is a compile error in the generated file.
172
+
173
+ Nothing is lost with it. Writeonly inheritance was the thing Base was meant to deliver, and it already rides on the Input chain: a child's `ModelInput` extends its parent's `ModelInput`, which carries the parent's writeonly fields. That is why removing Base changes no exported schema, no inferred type, and no runtime validation.
174
+
175
+ This supersedes the narrower change of emitting `XBase` only when some writeonly model extends `X`. That predicate turns out to be unsatisfiable in practice: gating the child's Base on having a reader of its own removes the only reference to the parent's Base, so the correct set is always empty.
176
+
177
+ Visible in diffs but not breaking: an unexported `const` disappears from generated schema files.
178
+
179
+ - 383d26f: Stop importing model types into SDK clients that never mention them.
180
+
181
+ `collectTypes` walks the AST and reports every model a request body names, regardless of its content type. `buildMethodParams` types a `multipart/form-data` body as `FormData`, so that model is never mentioned in the emitted method and its import is left unused, which is a compile error under `noUnusedLocals`. The same happened to a model's read variant when only its `Input` variant was actually referenced.
182
+
183
+ The collected list is now filtered against the emitted text before imports are generated: the method bodies, the error-body aliases and the inline reviver declarations. This is the idiom the reviver imports in the same function already use, and it errs toward keeping — a name appearing only inside a doc string counts as a reference, because a surplus import is untidy while a missing one does not compile.
184
+
185
+ Multipart is deliberately not special-cased inside `collectTypes`. Validating multipart bodies against their declared contract is work still to come, and it would have to undo that special case; with a text-derived filter the model becomes referenced on its own the moment the body is checked, and the import comes back automatically.
186
+
187
+ The aggregator path, which calls `collectTypes` separately when several op files merge into one area client, gets the same filter.
188
+
189
+ Visible in diffs but not breaking: an `import type` shrinks or disappears. Nothing exported changes.
190
+
191
+ - b239519: Coerce SDK response headers to the types the return shape declares.
192
+
193
+ `renderSdkHeadersShape` types the `headers` object from the contract, while `sdkHeaderEntries` assigned `result.headers.get(name) ?? undefined` regardless. That produced `TS2322` in both directions at once: a header declared `int` was typed `number` and given a `string | undefined`, and a _required_ header was typed `T` and given `T | undefined`. Neither compiled.
194
+
195
+ The value expression now follows the resolved scalar, and this table is shared with the Python SDK:
196
+
197
+ | Declared type | Expression |
198
+ | ---------------------------------------------------------------- | ---------------------------------------------------------- |
199
+ | `string`, `email`, `url`, `uuid`, the date/time types, `unknown` | the raw value, asserted or defaulted per optionality |
200
+ | `int`, `number` | `Number(...)`, guarded on `null` when optional |
201
+ | `boolean` | compared against `'true'`, guarded on `null` when optional |
202
+ | `bigint` | `BigInt(...)`, guarded on `null` when optional |
203
+ | anything else | rejected at codegen |
204
+
205
+ Optionality drives the null handling: `Headers.get` returns `null` for an absent header, so an optional header maps that onto `undefined`, which is what its `?` in the shape means, while a required one is asserted because the contract says the service always sends it.
206
+
207
+ A header declared as a `decimal`, a `json`, a `binary`, a model reference, an array or an object is now a build error naming the header and the operation, which the CLI reports scoped to this plugin. Header values arrive as strings and there is no meaningful reading of those types from one; emitting code that does not compile is worse than refusing.
208
+
209
+ The Python SDK reuses this table, with one asymmetry worth stating: temporals _do_ need coercion there, because `renderPyType` maps them to `datetime`/`date`/`time` objects while `renderOutputTsType` maps them to `string`.
210
+
211
+ No bump to `TYPESCRIPT_CODEGEN_VERSION` is needed; it was already raised to `2` earlier in this batch.
212
+
213
+ - 2597e3e: Fix generated SDK methods failing to compile when a route declares its path params as a model.
214
+
215
+ `buildUrlExpression` accepted a `ParamSource` and discarded it, always interpolating the placeholder by bare name. That is right for a `params { … }` block, whose fields `buildMethodParams` spreads across the signature — but for `params: PaymentRef` the signature has a single argument called `params`, so the emitted URL named something that does not exist:
216
+
217
+ ```ts
218
+ async getRefund(params: PaymentRef): Promise<Payment> {
219
+ const result = await this.fetch(`/refunds/${encodeURIComponent(paymentId)}`, { method: 'GET' });
220
+ ```
221
+
222
+ `TS2304`, plus `TS6133` for the now-unread `params`. This is the same root cause as the Python `NameError`: the name in the path and the name in the signature come from different places and were never reconciled.
223
+
224
+ The value is now read off the argument, as `params.paymentId`. A placeholder that is not a valid property accessor uses bracket notation, and the expression is wrapped in `String(...)` because a model's field may be typed something `encodeURIComponent` does not accept.
225
+
226
+ The spread-param branch is deliberately unchanged, including for a placeholder that is not a valid identifier. There the expression has to name a signature parameter, and `buildMethodParams` uses the contract's spelling verbatim — so when that spelling is not an identifier the method is already unsalvageable, and emitting an expression that parses as arithmetic would be no improvement over leaving the placeholder alone.
227
+
228
+ No bump to `TYPESCRIPT_CODEGEN_VERSION` is needed; it was already raised to `2` earlier in this batch.
229
+
230
+ - 1c36107: Fix the source links in generated TypeScript, which were malformed and did not resolve.
231
+
232
+ Every generated schema, router, SDK client and MCP tool carries a markdown link back to the `.ck` declaration it came from. Those links were written as `[User](file://./../contracts/user.ck#L5)`. The `file://` prefix opens a URL authority component, so the `.` that follows parses as the _host_ rather than as a path segment, and the link resolves to nothing in an editor or a rendered doc. The correct form for a path relative to the emitted file is simply `[User](../contracts/user.ck#L5)`, which is what is now emitted.
233
+
234
+ The seven sites that built this link each recomputed `relative(dirname(outPath), sourceFile)` by hand and concatenated the pieces inline. They now share one `sourceLink(label, outPath, sourceFile, line?)` helper in `ts-render.ts`, alongside `quoteKey`, `escapeJsDocLines` and `headerNameToProperty`. The helper returns just the link, since some callers wrap it in a JSDoc block and one emits it in a `//` comment. A path that does not already begin with `.` gains a `./` prefix so it reads unambiguously as relative.
235
+
236
+ `TYPESCRIPT_CODEGEN_VERSION` is bumped to `2`. `runIncrementalCodegen` honours a cached manifest whenever its recorded `codegenVersion` matches, so without the bump anyone with a warm `.contractkit/cache` would keep the old files after upgrading.
237
+
238
+ Visible in diffs but not breaking: the doc links change form. Nothing imports or depends on their text.
239
+
240
+ - fe9ea0b: Coerce temporal response headers to Luxon objects, completing the header table.
241
+
242
+ When response headers first learned to follow their declared types, temporals mapped to `string` and passed the raw value straight through. Reviving temporal scalars later changed `renderOutputTsType` to produce `DateTime` and `Duration` — so the header _shape_ said `DateTime` while the entry still assigned a raw string, and the client file had no `luxon` import at all. A `datetime` response header therefore produced a client that did not compile.
243
+
244
+ Temporal headers now convert, using the same functions the body reviver does and taking `date` and `time` formats from the contract. This also makes the TypeScript and Python SDKs symmetric: Python has coerced these since its own header types landed.
245
+
246
+ Two details:
247
+
248
+ The `luxon` import is decided from the emitted method bodies, like every other import in these files, and is added by both client paths — `generateSdk` for a top-level client and `generateAreaClient` for an area one. Only the first had the reviver's import logic, so an area client needed it separately.
249
+
250
+ Optional headers assert non-null inside the conversion. TypeScript does not carry the narrowing from `get(x) === null` across a _second_ `get(x)` call, so without the assertion the optional form is a `TS2345` even though the ternary has already excluded null. The `bigint` case had the same latent error and is fixed with it — it was invisible because no fixture declared an optional `bigint` header.
251
+
252
+ Found by running the real CLI over the reference contracts rather than the test harness, which is what that acceptance pass exists for: the fixture had no temporal response header, so nothing in the suite covered the interaction. It does now.
253
+
254
+ - e06d2e7: Warn when an output path template variable has no value.
255
+
256
+ `resolveTemplate` leaves an unknown `{key}` in place, and the result joins straight into the output path — so a config using `{area}` against a `.ck` file that declares no `options { keys { area: … } }` quietly wrote its files into a directory literally named `{area}`. `assertWithinBase` did not catch it: the path is inside the base directory, just wrong.
257
+
258
+ The build now says so, naming both the variable and the file it affected, and pointing at the two ways to fix it.
259
+
260
+ The file is still emitted. Throwing would be a worse trade here — the CLI catches a `generateTargets` throw and continues to the next plugin, so refusing over one misconfigured file would cost you that plugin's entire output. This adds visibility, not a new failure mode.
261
+
262
+ The check sits at the plugin's single `emitFile` funnel rather than being threaded down through the five path-computing helpers and their nine call sites. Every output path passes through that one point whichever helper built it, so one check covers all of them, and it catches a case a per-helper callback would miss.
263
+
264
+ - Updated dependencies [27af3f2]
265
+ - Updated dependencies [227c224]
266
+ - Updated dependencies [135947f]
267
+ - Updated dependencies [cb06aec]
268
+ - @contractkit/core@0.29.0
269
+
270
+ ## 0.33.3
271
+
272
+ ### Patch Changes
273
+
274
+ - 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.
275
+
3
276
  ## 0.33.2
4
277
 
5
278
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { ContractRootNode, ModelNode, ContractTypeNode, ObjectMode } from '@contractkit/core';
1
+ import type { ContractRootNode, ModelNode, FieldNode, ContractTypeNode, ObjectMode } from '@contractkit/core';
2
2
  import type { TsRenderTarget } from './ts-render.js';
3
3
  /**
4
4
  * Maps a ContractKit object mode to its Zod constructor name.
@@ -19,9 +19,9 @@ export interface ContractCodegenContext {
19
19
  /** If set, import JsonValue from this path instead of re-declaring it (avoids barrel re-export conflicts) */
20
20
  jsonValueImportPath?: string;
21
21
  /**
22
- * Runtime the emitted plain types describe. Only affects scalars whose TypeScript type differs
23
- * per runtime (`binary` `Buffer` on the server, `Blob` in the client). Ignored by
24
- * `generateContract`, whose Zod schemas are server-shaped by construction. Default `'client'`.
22
+ * Runtime the emitted types describe. Only affects scalars whose TypeScript type differs per
23
+ * runtime: `binary` is a `Buffer` on a Node server and a `Blob` in a fetch client, and
24
+ * `_ZodBinary` is generated to match. Default `'client'`.
25
25
  */
26
26
  target?: TsRenderTarget;
27
27
  /** Model names that carry a `decimal`, directly or transitively. */
@@ -41,14 +41,30 @@ export declare function computeModelsWithInput(models: ModelNode[], externalMode
41
41
  /**
42
42
  * Generate a TypeScript module containing Zod schemas for every model in `root`.
43
43
  *
44
- * Emits up to three schemas per model when visibility modifiers are present:
45
- * `ModelBase` (all fields), `Model` (read — no writeonly), `ModelInput` (write — no readonly).
44
+ * Emits two schemas per model when visibility modifiers are present: `Model` (read — no
45
+ * writeonly fields) and `ModelInput` (write — no readonly fields). Writeonly inheritance rides
46
+ * on the Input chain, since a child's `Input` extends its parent's `Input`, which already carries
47
+ * the parent's writeonly fields.
46
48
  *
47
49
  * @param root - The parsed contract root node.
48
50
  * @param context - Optional cross-file context for import resolution and Input/Output variant tracking.
49
51
  * @returns The full TypeScript source as a string.
50
52
  */
51
53
  export declare function generateContract(root: ContractRootNode, context?: ContractCodegenContext): string;
54
+ /**
55
+ * Append the modifier chain a declared field carries: nullability, then a default or optionality,
56
+ * then the description.
57
+ *
58
+ * Takes a structural subset of `FieldNode` rather than the node itself, so an `OpParamNode` — which
59
+ * is a `FieldNode` minus `visibility`, `deprecated` and `override` — can be rendered through the
60
+ * same path. That is what lets the router, the SDK and OpenAPI agree on what an inline `query:` or
61
+ * `headers:` field means.
62
+ *
63
+ * A default and `optional` are mutually exclusive on purpose: `.default()` already makes the input
64
+ * side optional, and adding `.optional()` on top would widen the *output* type to include
65
+ * `undefined`, which is exactly what a default exists to prevent.
66
+ */
67
+ export declare function applyFieldModifiers(expr: string, field: Pick<FieldNode, 'nullable' | 'default' | 'optional' | 'description'>): string;
52
68
  /**
53
69
  * Render a ContractKit AST type node as a Zod schema expression string.
54
70
  *
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-contract.d.ts","sourceRoot":"","sources":["../src/codegen-contract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,gBAAgB,EAChB,SAAS,EAET,gBAAgB,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H;AAoBD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,eAAe,GAAG,MAAM,CAqBzE;AAkbD;;;;;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-plain-types.d.ts","sourceRoot":"","sources":["../src/codegen-plain-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAgBpE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAkFnG"}
1
+ {"version":3,"file":"codegen-plain-types.d.ts","sourceRoot":"","sources":["../src/codegen-plain-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAgBpE;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CA2FnG"}
@@ -1,4 +1,4 @@
1
- import type { ContractTypeNode, ModelNode } from '@contractkit/core';
1
+ import type { ContractTypeNode, ModelNode, ScalarTypeNode } from '@contractkit/core';
2
2
  /**
3
3
  * Emitters for the `reviveX` functions that rehydrate `decimal` fields in an SDK response.
4
4
  *
@@ -17,18 +17,52 @@ import type { ContractTypeNode, ModelNode } from '@contractkit/core';
17
17
  * Emitted from the AST, so zod mode and plain-types mode produce identical runtime behaviour.
18
18
  */
19
19
  export interface ReviveCodegenOptions {
20
- /** Models that carry a decimal, directly or transitively. Only these get a reviver. */
20
+ /** Models that carry a revivable scalar, directly or transitively. Only these get a reviver. */
21
21
  modelsWithDecimal: Set<string>;
22
+ /**
23
+ * Which scalars need rehydrating from their wire form. Defaults to `decimal`, the only scalar
24
+ * whose runtime type currently differs from what `JSON.parse` produces.
25
+ *
26
+ * A set rather than a boolean because the question a reviver asks is not "does this reach a
27
+ * decimal" but "which conversion does this leaf need" — and the answer becomes plural as soon
28
+ * as a second scalar joins.
29
+ */
30
+ revivableScalars?: ReadonlySet<ScalarTypeNode['name']>;
22
31
  /** Models with an `Output` variant, which need a second reviver keyed by the output casing. */
23
32
  modelsWithOutput?: Set<string>;
24
33
  /** Every model in scope, for resolving discriminated-union members to their literal tag. */
25
34
  modelMap?: Map<string, ModelNode>;
26
35
  }
27
- /** The per-file coercion helper. Emitted once in any file that declares a reviver. */
36
+ /**
37
+ * The per-file coercion helpers, keyed by the call prefix that identifies them in emitted text.
38
+ *
39
+ * A file gets only the helpers its revivers actually call, decided by scanning the emitted lines
40
+ * — the same text-derived idiom the reviver and type imports use, and for the same reason: a
41
+ * predicate computed separately can drift and leave an unused local behind.
42
+ *
43
+ * Each one takes the raw JSON value and throws a `TypeError` naming the path rather than
44
+ * returning something invalid, because a silently wrong `DateTime` surfaces much further from
45
+ * the cause than a throw at the boundary does.
46
+ */
47
+ export declare const COERCE_DECLS: Record<string, string[]>;
48
+ /** Back-compat alias: the decimal helper alone, which several call sites still name directly. */
28
49
  export declare const DECIMAL_COERCE_DECL: string[];
50
+ /** The helper declarations `lines` actually calls, in a stable order. */
51
+ export declare function coerceDeclsFor(lines: string[]): string[];
52
+ /** Luxon classes referenced by the helpers `lines` calls, for the importing file to bring in. */
53
+ export declare function coerceLuxonImports(lines: string[]): string[];
29
54
  /** `reviveInvoice` / `reviveInvoiceOutput`. */
30
55
  export declare function reviveFnName(model: string, variant?: 'base' | 'output'): string;
31
- /** Whether a type reaches a decimal, following refs through `modelsWithDecimal`. */
56
+ /**
57
+ * Scalars whose runtime type differs from what `JSON.parse` produces, and which a reviver
58
+ * therefore has to rehydrate. The default of {@link ReviveCodegenOptions.revivableScalars}.
59
+ *
60
+ * `interval` is excluded: `_ZodInterval` ends in `.transform(v => v.toISO()!)`, so its inferred
61
+ * output type is already `string` and there is nothing to revive it to. Covering it means making
62
+ * that round-trip idempotent first, which the router's `isRevalidatable` also depends on.
63
+ */
64
+ export declare const DEFAULT_REVIVABLE_SCALARS: ReadonlySet<ScalarTypeNode['name']>;
65
+ /** Whether a type reaches a revivable scalar, following refs through `modelsWithDecimal`. */
32
66
  export declare function typeReachesDecimal(type: ContractTypeNode, opts: ReviveCodegenOptions): boolean;
33
67
  /**
34
68
  * A standalone reviver for an arbitrary type node — used for a response body that is not a plain
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-revive.d.ts","sourceRoot":"","sources":["../src/codegen-revive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAa,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEhF;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,oBAAoB;IACjC,uFAAuF;IACvF,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,+FAA+F;IAC/F,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACrC;AAED,sFAAsF;AACtF,eAAO,MAAM,mBAAmB,UAW/B,CAAC;AAEF,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,GAAG,QAAiB,GAAG,MAAM,CAEvF;AAQD,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,IA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,EAAE,CAM5D;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,GAAG,QAAiB,GAAG,MAAM,CAEvF;AAQD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,CAMxE,CAAC;AAEH,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CA2B9F;AAuLD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE,MAAM,GAAG,QAAmB,GACtC,MAAM,EAAE,GAAG,IAAI,CAajB;AAED,sGAAsG;AACtG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAQ5F"}
@@ -15,6 +15,8 @@ export interface SdkCodegenOptions {
15
15
  modelsWithOutput?: Set<string>;
16
16
  /** Model names carrying a `decimal`, whose response bodies need rehydrating client-side. */
17
17
  modelsWithDecimal?: Set<string>;
18
+ /** Model names carrying a `bigint`, directly or transitively. Selects the JSON reviver. */
19
+ modelsWithBigInt?: Set<string>;
18
20
  /** Every model in scope, for resolving discriminated-union members inside an inline reviver. */
19
21
  modelMap?: Map<string, ModelNode>;
20
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-sdk.d.ts","sourceRoot":"","sources":["../src/codegen-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EAQV,SAAS,EAEZ,MAAM,mBAAmB,CAAC;AA6D3B,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAC9B,6GAA6G;IAC7G,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,6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;IACrB,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,kBAAkB;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,mIAAmI;IACnI,cAAc,EAAE,iBAAiB,CAAC;CACrC;AAED,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IAC/B,8FAA8F;IAC9F,eAAe,EAAE,aAAa,EAAE,CAAC;IACjC,iCAAiC;IACjC,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC5B,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,+HAA+H;IAC/H,OAAO,EAAE,MAAM,CAAC;IAChB,0GAA0G;IAC1G,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,2EAA2E;IAC3E,cAAc,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,EAAE,CAAC;IAClE,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAyJjE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAyCvE"}
package/dist/index.d.ts CHANGED
@@ -99,7 +99,7 @@ export interface TypescriptPluginConfig {
99
99
  mcp?: McpConfig;
100
100
  }
101
101
  /** Bumped when the codegen output shape changes in a way that should bust every per-file fingerprint. */
102
- export declare const TYPESCRIPT_CODEGEN_VERSION = "1";
102
+ export declare const TYPESCRIPT_CODEGEN_VERSION = "2";
103
103
  declare const plugin: ContractKitPlugin;
104
104
  export default plugin;
105
105
  /** Build a `@contractkit/plugin-typescript` instance with explicit configuration, for programmatic use. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,iBAAiB,EAQpB,MAAM,mBAAmB,CAAC;AAgD3B,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,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,+EAA+E;QAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,mGAAmG;AACnG,MAAM,WAAW,SAAS;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,sFAAsF;AACtF,MAAM,WAAW,SAAS;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;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