@contractkit/plugin-typescript 0.27.0 → 0.28.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 152.62 KB
9
- ESM dist/index.js.map 335.05 KB
10
- ESM ⚡️ Build success in 416ms
8
+ ESM dist/index.js 152.65 KB
9
+ ESM dist/index.js.map 335.08 KB
10
+ ESM ⚡️ Build success in 388ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 5954ms
12
+ DTS ⚡️ Build success in 5659ms
13
13
  DTS dist/index.d.ts 2.35 KB
@@ -3,17 +3,17 @@ $ 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 (127 tests) 150ms
7
- ✓ tests/codegen-operation.test.ts (89 tests) 151ms
8
- ✓ tests/codegen-sdk.test.ts (138 tests) 206ms
9
- ✓ tests/codegen-plain-types.test.ts (61 tests) 34ms
10
- ✓ tests/codegen-server.test.ts (22 tests) 103ms
11
- ✓ tests/pipeline.test.ts (25 tests) 171ms
6
+ ✓ tests/codegen-contract.test.ts (127 tests) 87ms
7
+ ✓ tests/codegen-sdk.test.ts (138 tests) 167ms
8
+ ✓ tests/codegen-operation.test.ts (89 tests) 224ms
9
+ ✓ tests/codegen-plain-types.test.ts (61 tests) 69ms
10
+ ✓ tests/codegen-server.test.ts (22 tests) 60ms
11
+ ✓ tests/pipeline.test.ts (25 tests) 153ms
12
12
 
13
13
   Test Files  6 passed (6)
14
14
   Tests  462 passed (462)
15
-  Start at  15:55:38
16
-  Duration  7.14s (transform 4.98s, setup 0ms, import 13.67s, tests 815ms, environment 1ms)
15
+  Start at  16:24:02
16
+  Duration  8.54s (transform 5.16s, setup 0ms, import 16.94s, tests 760ms, environment 16ms)
17
17
 
18
18
   % Coverage report from v8
19
19
  -------------------|---------|----------|---------|---------|-------------------
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @contractkit/contractkit-plugin-typescript
2
2
 
3
+ ## 0.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8ac8343: Generated Koa routers now read the incoming request body from `ctx.parsedBody` instead of `ctx.body`, matching serverkit's refactor. The response body is still assigned via `ctx.body`.
8
+
3
9
  ## 0.27.0
4
10
 
5
11
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1781625346029" clover="3.2.0">
3
- <project timestamp="1781625346029" name="All files">
2
+ <coverage generated="1783441451213" clover="3.2.0">
3
+ <project timestamp="1783441451213" name="All files">
4
4
  <metrics statements="2177" coveredstatements="1861" conditionals="1663" coveredconditionals="1286" methods="408" coveredmethods="350" elements="4248" coveredelements="3497" complexity="0" loc="2177" ncloc="2177" packages="2" files="8" classes="8"/>
5
5
  <package name="src">
6
6
  <metrics statements="2131" coveredstatements="1818" conditionals="1630" coveredconditionals="1256" methods="380" coveredmethods="325"/>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2026-06-16T15:55:46.002Z
119
+ at 2026-07-07T16:24:11.130Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -3646,7 +3646,7 @@ export function pascalToDotCase(name: string): string {
3646
3646
  <div class='footer quiet pad2 space-top1 center small'>
3647
3647
  Code coverage generated by
3648
3648
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
3649
- at 2026-06-16T15:55:46.002Z
3649
+ at 2026-07-07T16:24:11.130Z
3650
3650
  </div>
3651
3651
  <script src="../prettify.js"></script>
3652
3652
  <script>
@@ -2008,14 +2008,14 @@ function generateHandler(route: OpRouteNode, op: OpOperationNode, root: OpRootNo
2008
2008
  // Body validation (request-side — use Input variants)
2009
2009
  if (hasBody &amp;&amp; op.request) {
2010
2010
  if (isSingleMultipart) {
2011
- lines.push(` const multipartBody = ctx.body as MultipartBody;`);
2011
+ lines.push(` const multipartBody = ctx.parsedBody as MultipartBody;`);
2012
2012
  lines.push('');
2013
2013
  } else if (bodies.length === 1) {
2014
- lines.push(` const body = await parseAndValidate(ctx.body, ${renderInputType(bodies[0]!.bodyType, modelsWithInput)});`);
2014
+ lines.push(` const body = await parseAndValidate(ctx.parsedBody, ${renderInputType(bodies[0]!.bodyType, modelsWithInput)});`);
2015
2015
  lines.push('');
2016
2016
  } else if (bodies.every(b =&gt; bodyTypesStructurallyEqual(b.bodyType, bodies[0]!.bodyType))) {
2017
2017
  // All declared MIMEs share the same body shape — single validation suffices
2018
- lines.push(` const body = await parseAndValidate(ctx.body, ${renderInputType(bodies[0]!.bodyType, modelsWithInput)});`);
2018
+ lines.push(` const body = await parseAndValidate(ctx.parsedBody, ${renderInputType(bodies[0]!.bodyType, modelsWithInput)});`);
2019
2019
  lines.push('');
2020
2020
  } else {
2021
2021
  // Different body types per MIME — dispatch on Content-Type
@@ -2029,9 +2029,9 @@ function generateHandler(route: OpRouteNode, op: OpOperationNode, root: OpRootNo
2029
2029
  for (const b of bodies) {
2030
2030
  lines.push(` case '${b.contentType}':`);
2031
2031
  if (b.contentType === 'multipart/form-data') {
2032
- lines.push(` body = ctx.body as MultipartBody;`);
2032
+ lines.push(` body = ctx.parsedBody as MultipartBody;`);
2033
2033
  } else {
2034
- lines.push(` body = await parseAndValidate(ctx.body, ${renderInputType(b.bodyType, modelsWithInput)});`);
2034
+ lines.push(` body = await parseAndValidate(ctx.parsedBody, ${renderInputType(b.bodyType, modelsWithInput)});`);
2035
2035
  }
2036
2036
  lines.push(` break;`);
2037
2037
  }
@@ -2569,7 +2569,7 @@ function deriveTypeImportPath(file: string, template?: string): string {
2569
2569
  <div class='footer quiet pad2 space-top1 center small'>
2570
2570
  Code coverage generated by
2571
2571
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2572
- at 2026-06-16T15:55:46.002Z
2572
+ at 2026-07-07T16:24:11.130Z
2573
2573
  </div>
2574
2574
  <script src="../prettify.js"></script>
2575
2575
  <script>
@@ -982,7 +982,7 @@ function renderOutputField(field: FieldNode, outputCase: 'camel' | 'snake' | 'pa
982
982
  <div class='footer quiet pad2 space-top1 center small'>
983
983
  Code coverage generated by
984
984
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
985
- at 2026-06-16T15:55:46.002Z
985
+ at 2026-07-07T16:24:11.130Z
986
986
  </div>
987
987
  <script src="../prettify.js"></script>
988
988
  <script>
@@ -3886,7 +3886,7 @@ export function generateSdkAggregator(input: SdkAggregatorInput): string {
3886
3886
  <div class='footer quiet pad2 space-top1 center small'>
3887
3887
  Code coverage generated by
3888
3888
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
3889
- at 2026-06-16T15:55:46.002Z
3889
+ at 2026-07-07T16:24:11.130Z
3890
3890
  </div>
3891
3891
  <script src="../prettify.js"></script>
3892
3892
  <script>
@@ -191,7 +191,7 @@
191
191
  <div class='footer quiet pad2 space-top1 center small'>
192
192
  Code coverage generated by
193
193
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
194
- at 2026-06-16T15:55:46.002Z
194
+ at 2026-07-07T16:24:11.130Z
195
195
  </div>
196
196
  <script src="../prettify.js"></script>
197
197
  <script>
@@ -2746,7 +2746,7 @@ function stableSubConfig(config: unknown): string {
2746
2746
  <div class='footer quiet pad2 space-top1 center small'>
2747
2747
  Code coverage generated by
2748
2748
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2749
- at 2026-06-16T15:55:46.002Z
2749
+ at 2026-07-07T16:24:11.130Z
2750
2750
  </div>
2751
2751
  <script src="../prettify.js"></script>
2752
2752
  <script>
@@ -730,7 +730,7 @@ export function computePubliclyReachableTypes(
730
730
  <div class='footer quiet pad2 space-top1 center small'>
731
731
  Code coverage generated by
732
732
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
733
- at 2026-06-16T15:55:46.002Z
733
+ at 2026-07-07T16:24:11.130Z
734
734
  </div>
735
735
  <script src="../prettify.js"></script>
736
736
  <script>
@@ -577,7 +577,7 @@ export function renderOutputTsType(type: ContractTypeNode, modelsWithOutput?: Se
577
577
  <div class='footer quiet pad2 space-top1 center small'>
578
578
  Code coverage generated by
579
579
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
580
- at 2026-06-16T15:55:46.002Z
580
+ at 2026-07-07T16:24:11.130Z
581
581
  </div>
582
582
  <script src="../prettify.js"></script>
583
583
  <script>
@@ -811,7 +811,7 @@ operation /users/{id}: {
811
811
  <div class='footer quiet pad2 space-top1 center small'>
812
812
  Code coverage generated by
813
813
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
814
- at 2026-06-16T15:55:46.002Z
814
+ at 2026-07-07T16:24:11.130Z
815
815
  </div>
816
816
  <script src="../prettify.js"></script>
817
817
  <script>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2026-06-16T15:55:46.002Z
104
+ at 2026-07-07T16:24:11.130Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
package/dist/index.js CHANGED
@@ -1283,13 +1283,13 @@ function generateHandler(route, op, root, options) {
1283
1283
  lines.push(...generateParamValidation(op.headers, "ctx.headers", "headers", op.headersMode ?? "strip", "", modelsWithInput));
1284
1284
  if (hasBody && op.request) {
1285
1285
  if (isSingleMultipart) {
1286
- lines.push(` const multipartBody = ctx.body as MultipartBody;`);
1286
+ lines.push(` const multipartBody = ctx.parsedBody as MultipartBody;`);
1287
1287
  lines.push("");
1288
1288
  } else if (bodies.length === 1) {
1289
- lines.push(` const body = await parseAndValidate(ctx.body, ${renderInputType(bodies[0].bodyType, modelsWithInput)});`);
1289
+ lines.push(` const body = await parseAndValidate(ctx.parsedBody, ${renderInputType(bodies[0].bodyType, modelsWithInput)});`);
1290
1290
  lines.push("");
1291
1291
  } else if (bodies.every((b) => bodyTypesStructurallyEqual(b.bodyType, bodies[0].bodyType))) {
1292
- lines.push(` const body = await parseAndValidate(ctx.body, ${renderInputType(bodies[0].bodyType, modelsWithInput)});`);
1292
+ lines.push(` const body = await parseAndValidate(ctx.parsedBody, ${renderInputType(bodies[0].bodyType, modelsWithInput)});`);
1293
1293
  lines.push("");
1294
1294
  } else {
1295
1295
  const annotation = bodies.map((b) => b.contentType === "multipart/form-data" ? "MultipartBody" : `z.infer<typeof ${renderInputType(b.bodyType, modelsWithInput)}>`).join(" | ");
@@ -1298,9 +1298,9 @@ function generateHandler(route, op, root, options) {
1298
1298
  for (const b of bodies) {
1299
1299
  lines.push(` case '${b.contentType}':`);
1300
1300
  if (b.contentType === "multipart/form-data") {
1301
- lines.push(` body = ctx.body as MultipartBody;`);
1301
+ lines.push(` body = ctx.parsedBody as MultipartBody;`);
1302
1302
  } else {
1303
- lines.push(` body = await parseAndValidate(ctx.body, ${renderInputType(b.bodyType, modelsWithInput)});`);
1303
+ lines.push(` body = await parseAndValidate(ctx.parsedBody, ${renderInputType(b.bodyType, modelsWithInput)});`);
1304
1304
  }
1305
1305
  lines.push(` break;`);
1306
1306
  }