@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.
- package/.turbo/turbo-build$colon$ci.log +4 -4
- package/.turbo/turbo-test$colon$ci.log +8 -8
- package/CHANGELOG.md +6 -0
- package/coverage/clover.xml +2 -2
- package/coverage/index.html +1 -1
- package/coverage/src/codegen-contract.ts.html +1 -1
- package/coverage/src/codegen-operation.ts.html +6 -6
- package/coverage/src/codegen-plain-types.ts.html +1 -1
- package/coverage/src/codegen-sdk.ts.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/index.ts.html +1 -1
- package/coverage/src/path-utils.ts.html +1 -1
- package/coverage/src/ts-render.ts.html +1 -1
- package/coverage/tests/helpers.ts.html +1 -1
- package/coverage/tests/index.html +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/codegen-operation.ts +5 -5
- package/tests/codegen-operation.test.ts +5 -5
|
@@ -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[32m152.
|
|
9
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m335.
|
|
10
|
-
[32mESM[39m ⚡️ Build success in
|
|
8
|
+
[32mESM[39m [1mdist/index.js [22m[32m152.65 KB[39m
|
|
9
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m335.08 KB[39m
|
|
10
|
+
[32mESM[39m ⚡️ Build success in 388ms
|
|
11
11
|
[34mDTS[39m Build start
|
|
12
|
-
[32mDTS[39m ⚡️ Build success in
|
|
12
|
+
[32mDTS[39m ⚡️ Build success in 5659ms
|
|
13
13
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.35 KB[39m
|
|
@@ -3,17 +3,17 @@ $ 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-contract.test.ts [2m([22m[2m127 tests[22m[2m)[22m[32m
|
|
7
|
-
[32m✓[39m tests/codegen-
|
|
8
|
-
[32m✓[39m tests/codegen-
|
|
9
|
-
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m61 tests[22m[2m)[22m[32m
|
|
10
|
-
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m22 tests[22m[2m)[22m[32m
|
|
11
|
-
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m25 tests[22m[2m)[22m[32m
|
|
6
|
+
[32m✓[39m tests/codegen-contract.test.ts [2m([22m[2m127 tests[22m[2m)[22m[32m 87[2mms[22m[39m
|
|
7
|
+
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m138 tests[22m[2m)[22m[32m 167[2mms[22m[39m
|
|
8
|
+
[32m✓[39m tests/codegen-operation.test.ts [2m([22m[2m89 tests[22m[2m)[22m[32m 224[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m61 tests[22m[2m)[22m[32m 69[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m22 tests[22m[2m)[22m[32m 60[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m25 tests[22m[2m)[22m[32m 153[2mms[22m[39m
|
|
12
12
|
|
|
13
13
|
[2m Test Files [22m [1m[32m6 passed[39m[22m[90m (6)[39m
|
|
14
14
|
[2m Tests [22m [1m[32m462 passed[39m[22m[90m (462)[39m
|
|
15
|
-
[2m Start at [22m
|
|
16
|
-
[2m Duration [22m
|
|
15
|
+
[2m Start at [22m 16:24:02
|
|
16
|
+
[2m Duration [22m 8.54s[2m (transform 5.16s, setup 0ms, import 16.94s, tests 760ms, environment 16ms)[22m
|
|
17
17
|
|
|
18
18
|
[34m % [39m[2mCoverage report from [22m[33mv8[39m
|
|
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
|
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
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"/>
|
package/coverage/index.html
CHANGED
|
@@ -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-
|
|
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-
|
|
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 && op.request) {
|
|
2010
2010
|
if (isSingleMultipart) {
|
|
2011
|
-
lines.push(` const multipartBody = ctx.
|
|
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.
|
|
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 => 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.
|
|
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.
|
|
2032
|
+
lines.push(` body = ctx.parsedBody as MultipartBody;`);
|
|
2033
2033
|
} else {
|
|
2034
|
-
lines.push(` body = await parseAndValidate(ctx.
|
|
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-
|
|
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-
|
|
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-
|
|
3889
|
+
at 2026-07-07T16:24:11.130Z
|
|
3890
3890
|
</div>
|
|
3891
3891
|
<script src="../prettify.js"></script>
|
|
3892
3892
|
<script>
|
package/coverage/src/index.html
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
1301
|
+
lines.push(` body = ctx.parsedBody as MultipartBody;`);
|
|
1302
1302
|
} else {
|
|
1303
|
-
lines.push(` body = await parseAndValidate(ctx.
|
|
1303
|
+
lines.push(` body = await parseAndValidate(ctx.parsedBody, ${renderInputType(b.bodyType, modelsWithInput)});`);
|
|
1304
1304
|
}
|
|
1305
1305
|
lines.push(` break;`);
|
|
1306
1306
|
}
|