@contractkit/plugin-typescript 0.16.1
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 +35 -0
- package/.turbo/turbo-build.log +15 -0
- package/.turbo/turbo-test$colon$ci.log +81 -0
- package/.turbo/turbo-test.log +19 -0
- package/CHANGELOG.md +151 -0
- package/README.md +153 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +1882 -0
- package/coverage/coverage-final.json +9 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/src/codegen-contract.ts.html +3331 -0
- package/coverage/src/codegen-operation.ts.html +2530 -0
- package/coverage/src/codegen-plain-types.ts.html +901 -0
- package/coverage/src/codegen-sdk.ts.html +2797 -0
- package/coverage/src/index.html +206 -0
- package/coverage/src/index.ts.html +1360 -0
- package/coverage/src/path-utils.ts.html +649 -0
- package/coverage/src/ts-render.ts.html +592 -0
- package/coverage/tests/helpers.ts.html +826 -0
- package/coverage/tests/index.html +116 -0
- package/dist/codegen-contract.d.ts +56 -0
- package/dist/codegen-contract.d.ts.map +1 -0
- package/dist/codegen-operation.d.ts +25 -0
- package/dist/codegen-operation.d.ts.map +1 -0
- package/dist/codegen-plain-types.d.ts +10 -0
- package/dist/codegen-plain-types.d.ts.map +1 -0
- package/dist/codegen-sdk.d.ts +38 -0
- package/dist/codegen-sdk.d.ts.map +1 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3162 -0
- package/dist/index.js.map +1 -0
- package/dist/path-utils.d.ts +15 -0
- package/dist/path-utils.d.ts.map +1 -0
- package/dist/ts-render.d.ts +20 -0
- package/dist/ts-render.d.ts.map +1 -0
- package/eslint.config.js +6 -0
- package/package.json +43 -0
- package/src/codegen-contract.ts +1082 -0
- package/src/codegen-operation.ts +815 -0
- package/src/codegen-plain-types.ts +272 -0
- package/src/codegen-sdk.ts +904 -0
- package/src/index.ts +425 -0
- package/src/path-utils.ts +188 -0
- package/src/ts-render.ts +169 -0
- package/tests/codegen-contract.test.ts +1004 -0
- package/tests/codegen-operation.test.ts +939 -0
- package/tests/codegen-plain-types.test.ts +636 -0
- package/tests/codegen-sdk.test.ts +1500 -0
- package/tests/codegen-server.test.ts +192 -0
- package/tests/helpers.ts +247 -0
- package/tests/pipeline.test.ts +372 -0
- package/tsconfig.json +9 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @contractkit/plugin-typescript@0.16.0 build:ci /Users/robert/projects/contractkit/packages/plugin-typescript
|
|
4
|
+
> eslint --max-warnings=0 && pnpm run build
|
|
5
|
+
|
|
6
|
+
=============
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* @typescript-eslint/typescript-estree version: 8.57.2
|
|
13
|
+
* Supported TypeScript versions: >=4.8.4 <6.0.0
|
|
14
|
+
* Your TypeScript version: 6.0.2
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Please only submit bug reports when using the officially supported version.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
=============
|
|
21
|
+
|
|
22
|
+
> @contractkit/plugin-typescript@0.16.0 build /Users/robert/projects/contractkit/packages/plugin-typescript
|
|
23
|
+
> tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
|
|
24
|
+
|
|
25
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
26
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
27
|
+
[34mCLI[39m tsup v8.5.1
|
|
28
|
+
[34mCLI[39m Target: esnext
|
|
29
|
+
[34mESM[39m Build start
|
|
30
|
+
[32mESM[39m [1mdist/index.js [22m[32m123.76 KB[39m
|
|
31
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m267.25 KB[39m
|
|
32
|
+
[32mESM[39m ⚡️ Build success in 156ms
|
|
33
|
+
DTS Build start
|
|
34
|
+
DTS ⚡️ Build success in 702ms
|
|
35
|
+
DTS dist/index.d.ts 3.44 KB
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
> @contractkit/plugin-typescript@0.16.0 build /Users/robert/projects/contractkit/packages/plugin-typescript
|
|
3
|
+
> tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Target: esnext
|
|
9
|
+
ESM Build start
|
|
10
|
+
ESM dist/index.js 123.76 KB
|
|
11
|
+
ESM dist/index.js.map 267.25 KB
|
|
12
|
+
ESM ⚡️ Build success in 95ms
|
|
13
|
+
DTS Build start
|
|
14
|
+
DTS ⚡️ Build success in 744ms
|
|
15
|
+
DTS dist/index.d.ts 3.44 KB
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @contractkit/plugin-typescript@0.16.0 test:ci /Users/robert/projects/contractkit/packages/plugin-typescript
|
|
4
|
+
> vitest run --coverage
|
|
5
|
+
|
|
6
|
+
[?25l
|
|
7
|
+
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.5 [39m[90m/Users/robert/projects/contractkit/packages/plugin-typescript[39m
|
|
8
|
+
[2mCoverage enabled with [22m[33mv8[39m
|
|
9
|
+
|
|
10
|
+
[?2026h
|
|
11
|
+
[1m[33m ❯ [39m[22mtests/codegen-operation.test.ts[2m [queued][22m
|
|
12
|
+
|
|
13
|
+
[2m Test Files [22m[1m[32m0 passed[39m[22m[90m (6)[39m
|
|
14
|
+
[2m Tests [22m[1m[32m0 passed[39m[22m[90m (0)[39m
|
|
15
|
+
[2m Start at [22m08:51:09
|
|
16
|
+
[2m Duration [22m206ms
|
|
17
|
+
[?2026l[?2026h[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K
|
|
18
|
+
[1m[33m ❯ [39m[22mtests/codegen-contract.test.ts[2m [queued][22m
|
|
19
|
+
[1m[33m ❯ [39m[22mtests/codegen-operation.test.ts[2m [queued][22m
|
|
20
|
+
[1m[33m ❯ [39m[22mtests/codegen-plain-types.test.ts[2m [queued][22m
|
|
21
|
+
[1m[33m ❯ [39m[22mtests/codegen-sdk.test.ts[2m [queued][22m
|
|
22
|
+
[1m[33m ❯ [39m[22mtests/codegen-server.test.ts[2m [queued][22m
|
|
23
|
+
[1m[33m ❯ [39m[22mtests/pipeline.test.ts[2m [queued][22m
|
|
24
|
+
|
|
25
|
+
[2m Test Files [22m[1m[32m0 passed[39m[22m[90m (6)[39m
|
|
26
|
+
[2m Tests [22m[1m[32m0 passed[39m[22m[90m (0)[39m
|
|
27
|
+
[2m Start at [22m08:51:09
|
|
28
|
+
[2m Duration [22m481ms
|
|
29
|
+
[?2026l[?2026h[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K
|
|
30
|
+
[1m[33m ❯ [39m[22mtests/codegen-contract.test.ts[2m [queued][22m
|
|
31
|
+
[1m[33m ❯ [39m[22mtests/codegen-operation.test.ts[2m [queued][22m
|
|
32
|
+
[1m[33m ❯ [39m[22mtests/codegen-plain-types.test.ts[2m [queued][22m
|
|
33
|
+
[1m[33m ❯ [39m[22mtests/codegen-sdk.test.ts[2m [queued][22m
|
|
34
|
+
[1m[33m ❯ [39m[22mtests/codegen-server.test.ts[2m [queued][22m
|
|
35
|
+
[1m[33m ❯ [39m[22mtests/pipeline.test.ts[2m [queued][22m
|
|
36
|
+
|
|
37
|
+
[2m Test Files [22m[1m[32m0 passed[39m[22m[90m (6)[39m
|
|
38
|
+
[2m Tests [22m[1m[32m0 passed[39m[22m[90m (0)[39m
|
|
39
|
+
[2m Start at [22m08:51:09
|
|
40
|
+
[2m Duration [22m928ms
|
|
41
|
+
[?2026l[?2026h[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K
|
|
42
|
+
[1m[33m ❯ [39m[22mtests/codegen-contract.test.ts[2m [queued][22m
|
|
43
|
+
[1m[33m ❯ [39m[22mtests/codegen-operation.test.ts[2m [queued][22m
|
|
44
|
+
[1m[33m ❯ [39m[22mtests/codegen-plain-types.test.ts[2m [queued][22m
|
|
45
|
+
[1m[33m ❯ [39m[22mtests/codegen-sdk.test.ts[2m [queued][22m
|
|
46
|
+
[1m[33m ❯ [39m[22mtests/codegen-server.test.ts[2m [queued][22m
|
|
47
|
+
[1m[33m ❯ [39m[22mtests/pipeline.test.ts[2m 0/25[22m
|
|
48
|
+
|
|
49
|
+
[2m Test Files [22m[1m[32m0 passed[39m[22m[90m (6)[39m
|
|
50
|
+
[2m Tests [22m[1m[32m0 passed[39m[22m[90m (25)[39m
|
|
51
|
+
[2m Start at [22m08:51:09
|
|
52
|
+
[2m Duration [22m1.13s
|
|
53
|
+
[?2026l[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K[1A[K [32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m58 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
54
|
+
[32m✓[39m tests/codegen-contract.test.ts [2m([22m[2m120 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
55
|
+
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m15 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
56
|
+
[32m✓[39m tests/codegen-operation.test.ts [2m([22m[2m86 tests[22m[2m)[22m[32m 28[2mms[22m[39m
|
|
57
|
+
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m25 tests[22m[2m)[22m[32m 47[2mms[22m[39m
|
|
58
|
+
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m123 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
59
|
+
|
|
60
|
+
[2m Test Files [22m [1m[32m6 passed[39m[22m[90m (6)[39m
|
|
61
|
+
[2m Tests [22m [1m[32m427 passed[39m[22m[90m (427)[39m
|
|
62
|
+
[2m Start at [22m 08:51:09
|
|
63
|
+
[2m Duration [22m 1.31s[2m (transform 1.99s, setup 0ms, import 4.86s, tests 118ms, environment 0ms)[22m
|
|
64
|
+
|
|
65
|
+
[34m % [39m[2mCoverage report from [22m[33mv8[39m
|
|
66
|
+
-------------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------
|
|
67
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
68
|
+
-------------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------
|
|
69
|
+
[33;1mAll files [0m | [33;1m 77.37[0m | [33;1m 73.85[0m | [32;1m 82.17[0m | [33;1m 79.25[0m | [31;1m [0m
|
|
70
|
+
[33;1m src [0m | [33;1m 77.05[0m | [33;1m 73.45[0m | [32;1m 81.57[0m | [33;1m 78.88[0m | [31;1m [0m
|
|
71
|
+
[32;1m codegen-contract.ts [0m | [32;1m 87.38[0m | [32;1m 81.19[0m | [32;1m 90.16[0m | [32;1m 88.24[0m | [31;1m102,259,348-349,414-416,418,420,432-434,439,494,595,642-646,654-658,664-674,724-726,730,739-755,796-797,807-816,830-831,898,964-969,974-975,980-981[0m
|
|
72
|
+
[33;1m codegen-operation.ts [0m | [33;1m 78.18[0m | [33;1m 74.26[0m | [33;1m 78.08[0m | [33;1m 79.69[0m | [31;1m30,44-77,85-94,164,172-173,312,387,423-426,500-502,511-514,577-597,618,632-646,651-652,668-679,684-685 [0m
|
|
73
|
+
[32;1m codegen-plain-types.ts[0m | [32;1m 87.5[0m | [33;1m 76.76[0m | [32;1m 92.85[0m | [32;1m 91.66[0m | [31;1m50-55,91,111,185,199,211,217,269 [0m
|
|
74
|
+
[32;1m codegen-sdk.ts [0m | [32;1m 88.75[0m | [32;1m 83.6[0m | [32;1m 85[0m | [32;1m 91.49[0m | [31;1m23,308-309,578-585,594-599,606-623,678,712-729 [0m
|
|
75
|
+
[31;1m index.ts [0m | [31;1m 23.35[0m | [31;1m 19.51[0m | [31;1m 33.33[0m | [31;1m 25.69[0m | [31;1m136,139,175-375,391,394,397,415,418,421 [0m
|
|
76
|
+
[31;1m path-utils.ts [0m | [31;1m 23.47[0m | [31;1m 18.84[0m | [33;1m 58.33[0m | [31;1m 23.71[0m | [31;1m24-25,51,54-55,80-187 [0m
|
|
77
|
+
[32;1m ts-render.ts [0m | [32;1m 82.19[0m | [32;1m 85.39[0m | [33;1m 72.22[0m | [32;1m 87.09[0m | [31;1m56,90,126,157-165 [0m
|
|
78
|
+
[32;1m tests [0m | [32;1m 90.38[0m | [32;1m 90.9[0m | [32;1m 89.28[0m | [32;1m 93.47[0m | [31;1m [0m
|
|
79
|
+
[32;1m helpers.ts [0m | [32;1m 90.38[0m | [32;1m 90.9[0m | [32;1m 89.28[0m | [32;1m 93.47[0m | [31;1m110-118 [0m
|
|
80
|
+
-------------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------
|
|
81
|
+
[?25h
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
> @contractkit/plugin-typescript@0.16.0 test /Users/robert/projects/contractkit/packages/plugin-typescript
|
|
3
|
+
> vitest run
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.5 [39m[90m/Users/robert/projects/contractkit/packages/plugin-typescript[39m
|
|
7
|
+
|
|
8
|
+
[32m✓[39m tests/codegen-contract.test.ts [2m([22m[2m120 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/codegen-plain-types.test.ts [2m([22m[2m58 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/codegen-sdk.test.ts [2m([22m[2m123 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/codegen-operation.test.ts [2m([22m[2m86 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
12
|
+
[32m✓[39m tests/pipeline.test.ts [2m([22m[2m25 tests[22m[2m)[22m[32m 29[2mms[22m[39m
|
|
13
|
+
[32m✓[39m tests/codegen-server.test.ts [2m([22m[2m15 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
14
|
+
|
|
15
|
+
[2m Test Files [22m [1m[32m6 passed[39m[22m[90m (6)[39m
|
|
16
|
+
[2m Tests [22m [1m[32m427 passed[39m[22m[90m (427)[39m
|
|
17
|
+
[2m Start at [22m 08:51:34
|
|
18
|
+
[2m Duration [22m 472ms[2m (transform 591ms, setup 0ms, import 1.33s, tests 80ms, environment 0ms)[22m
|
|
19
|
+
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# @contractkit/contractkit-plugin-typescript
|
|
2
|
+
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c9f2166]
|
|
8
|
+
- @contractkit/core@0.11.0
|
|
9
|
+
|
|
10
|
+
## 0.16.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- bbee232: prep for public release
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [bbee232]
|
|
19
|
+
- @contractkit/core@0.10.0
|
|
20
|
+
|
|
21
|
+
## 0.15.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- e27b771: Add an `includeInternal: boolean` config option to every plugin so consumers can override whether `internal` operations are emitted. Defaults preserve today's behavior: server router and Bruno default to `true` (include); TS SDK, Python SDK, OpenAPI, and Markdown default to `false` (exclude).
|
|
26
|
+
|
|
27
|
+
## 0.14.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 206120c: Fix double-anchoring in Zod regex codegen: patterns that already contain `^` or an unescaped trailing `$` are now emitted as-written instead of being wrapped a second time. Patterns without anchors continue to be auto-anchored to `^...$` for full-match semantics.
|
|
32
|
+
|
|
33
|
+
## 0.14.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- d13614c: Enhance content type handling in contract DSL. This update introduces support for vendor JSON MIME types and improves the classification of content types, allowing for better handling of text and binary responses. The grammar has been updated to accept a wider range of MIME types, and tests have been added to ensure correct parsing and serialization behavior. Additionally, the code has been refactored to normalize content types for stable comparisons and to support multi-MIME request bodies.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [d13614c]
|
|
42
|
+
- @maroonedsoftware/contractkit@0.9.0
|
|
43
|
+
|
|
44
|
+
## 0.13.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- 353aa10: Implement options-level header globals for request and response in the contract DSL. This update allows headers to be declared at the file level, merging them into every operation's request and response. Added normalization logic to handle header collisions and opt-out scenarios. Updated documentation and tests to reflect these changes, ensuring proper round-trip formatting and validation of headers.
|
|
49
|
+
- 888ded5: Enhance contract DSL with multi-base inheritance support and override modifier. This update introduces the ability to declare multiple base contracts, along with validation rules for field conflicts across bases. The `override` modifier is now required for redeclaring conflicting fields, and the documentation has been updated to reflect these changes. Tests have been added to ensure correct behavior for inheritance and modifier usage.
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [353aa10]
|
|
54
|
+
- Updated dependencies [888ded5]
|
|
55
|
+
- @maroonedsoftware/contractkit@0.8.0
|
|
56
|
+
|
|
57
|
+
## 0.12.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- 16ac3a7: Implement support for typed response headers in API operations. Added functionality to declare headers alongside response bodies, affecting OpenAPI, TypeScript SDK, and Markdown documentation generation. Updated related tests to ensure correct parsing and rendering of response headers, including handling optional headers and duplicate declarations.
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [16ac3a7]
|
|
66
|
+
- @maroonedsoftware/contractkit@0.7.0
|
|
67
|
+
|
|
68
|
+
## 0.11.0
|
|
69
|
+
|
|
70
|
+
### Minor Changes
|
|
71
|
+
|
|
72
|
+
- d3ea773: Enhance model handling by introducing Output variants for response types in code generation. Updated functions to compute and collect models with Output variants, ensuring compatibility with serialization logic. Added tests to verify correct generation of Output types based on model configurations.
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [d3ea773]
|
|
77
|
+
- @maroonedsoftware/contractkit@0.6.0
|
|
78
|
+
|
|
79
|
+
## 0.10.0
|
|
80
|
+
|
|
81
|
+
### Minor Changes
|
|
82
|
+
|
|
83
|
+
- ddb6a28: Refactor type generation in codegen-contract to use z.input for developer-facing types when outputCase is set. Updated tests to reflect this change in type handling for improved clarity in serialization logic.
|
|
84
|
+
|
|
85
|
+
## 0.9.0
|
|
86
|
+
|
|
87
|
+
### Minor Changes
|
|
88
|
+
|
|
89
|
+
- 2c9e9a9: Fix type casting in URLSearchParams serialization for form data in codegen-sdk. Updated tests to reflect changes in body serialization logic.
|
|
90
|
+
|
|
91
|
+
## 0.8.0
|
|
92
|
+
|
|
93
|
+
### Minor Changes
|
|
94
|
+
|
|
95
|
+
- 1b336ec: Enhance contract generation by introducing a flattening mechanism for format chains. This allows child models to inline parent fields and inherit transformations, ensuring compatibility with ZodPipe structures. Updated the model generation logic and added tests to verify the new behavior for child models extending formatted parents.
|
|
96
|
+
|
|
97
|
+
## 0.7.0
|
|
98
|
+
|
|
99
|
+
### Minor Changes
|
|
100
|
+
|
|
101
|
+
- 181dadb: Refactor request handling to support multiple content types in operations. Updated OpRequestNode to accept an array of bodies, modified related functions and tests to accommodate multi-MIME requests, and enhanced validation for nested structures in URL-encoded bodies. Improved code generation across various plugins to handle new request structure.
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Updated dependencies [181dadb]
|
|
106
|
+
- @maroonedsoftware/contractkit@0.5.0
|
|
107
|
+
|
|
108
|
+
## 0.6.0
|
|
109
|
+
|
|
110
|
+
### Minor Changes
|
|
111
|
+
|
|
112
|
+
- ada5f84: Implement discriminated unions in ContractKit with validation and code generation support. Update README and tests to reflect new functionality, including parsing, rendering, and OpenAPI generation for discriminated unions.
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [ada5f84]
|
|
117
|
+
- @maroonedsoftware/contractkit@0.4.0
|
|
118
|
+
|
|
119
|
+
## 0.5.0
|
|
120
|
+
|
|
121
|
+
### Minor Changes
|
|
122
|
+
|
|
123
|
+
- 506af42: Enhance input type reference collection in code generation by adding support for tuple, record, union, intersection, lazy, and inlineObject types. Added corresponding test case for intersection query handling.
|
|
124
|
+
|
|
125
|
+
## 0.4.0
|
|
126
|
+
|
|
127
|
+
### Minor Changes
|
|
128
|
+
|
|
129
|
+
- 3d90443: Update ZodInterval transformation to include ISO string conversion in contract generation and corresponding test case.
|
|
130
|
+
|
|
131
|
+
## 0.3.0
|
|
132
|
+
|
|
133
|
+
### Minor Changes
|
|
134
|
+
|
|
135
|
+
- f396a68: Enhance scalar type support by adding 'interval' to the ContractKit
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [f396a68]
|
|
140
|
+
- @maroonedsoftware/contractkit@0.3.0
|
|
141
|
+
|
|
142
|
+
## 0.2.0
|
|
143
|
+
|
|
144
|
+
### Minor Changes
|
|
145
|
+
|
|
146
|
+
- db7345b: updating to contractkit as the org
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- Updated dependencies [db7345b]
|
|
151
|
+
- @contractkit/core@0.2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @contractkit/contractkit-plugin-typescript
|
|
2
|
+
|
|
3
|
+
ContractKit plugin that generates TypeScript output from `.ck` contract files. Covers all server-side and client-side TypeScript needs: Koa routers, SDK clients, Zod schemas, and plain TypeScript interfaces.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @contractkit/contractkit-plugin-typescript
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
Add the plugin to `contractkit.config.json`. Each sub-config is independent — include only what you need.
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"plugins": {
|
|
18
|
+
"@contractkit/contractkit-plugin-typescript": {
|
|
19
|
+
"server": {
|
|
20
|
+
"baseDir": "apps/api/",
|
|
21
|
+
"zod": true,
|
|
22
|
+
"output": {
|
|
23
|
+
"routes": "src/routes/{filename}.router.ts",
|
|
24
|
+
"types": "src/modules/{area}/types/{filename}.ts"
|
|
25
|
+
},
|
|
26
|
+
"servicePathTemplate": "#modules/{module}/{module}.service.js"
|
|
27
|
+
},
|
|
28
|
+
"sdk": {
|
|
29
|
+
"baseDir": "packages/sdk/",
|
|
30
|
+
"name": "acme",
|
|
31
|
+
"zod": true,
|
|
32
|
+
"output": {
|
|
33
|
+
"sdk": "src/{name}.sdk.ts",
|
|
34
|
+
"types": "src/{area}/types/{filename}.ts",
|
|
35
|
+
"clients": "src/{area}/{filename}.client.ts"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"zod": {
|
|
39
|
+
"baseDir": "packages/schemas/",
|
|
40
|
+
"output": "{filename}.schema.ts"
|
|
41
|
+
},
|
|
42
|
+
"types": {
|
|
43
|
+
"baseDir": "packages/types/",
|
|
44
|
+
"output": "{filename}.types.ts"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Sub-configs
|
|
52
|
+
|
|
53
|
+
### `server`
|
|
54
|
+
|
|
55
|
+
Generates Koa router files from `operation` declarations and optionally type files from `contract` declarations.
|
|
56
|
+
|
|
57
|
+
| Option | Type | Default | Description |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| `baseDir` | `string` | `rootDir` | Base directory for output files |
|
|
60
|
+
| `zod` | `boolean` | `false` | Emit Zod schemas in `output.types` instead of plain interfaces |
|
|
61
|
+
| `output.routes` | `string` | — | Path template for router files |
|
|
62
|
+
| `output.types` | `string` | — | Path template for type/schema files |
|
|
63
|
+
| `servicePathTemplate` | `string` | — | Import path template for service implementations |
|
|
64
|
+
|
|
65
|
+
Each generated router imports handler implementations from a service module. The `servicePathTemplate` controls where that import points. Template variables: `{module}`.
|
|
66
|
+
|
|
67
|
+
### `sdk`
|
|
68
|
+
|
|
69
|
+
Generates a typed TypeScript SDK client from `operation` declarations. Produces individual client files per operation file plus an aggregator SDK class.
|
|
70
|
+
|
|
71
|
+
| Option | Type | Default | Description |
|
|
72
|
+
|---|---|---|---|
|
|
73
|
+
| `baseDir` | `string` | `rootDir` | Base directory for output files |
|
|
74
|
+
| `name` | `string` | `"sdk"` | SDK class name (e.g. `"acme"` → `AcmeSdk`) |
|
|
75
|
+
| `zod` | `boolean` | `false` | Emit Zod schemas in `output.types` instead of plain interfaces |
|
|
76
|
+
| `output.sdk` | `string` | — | Path template for the aggregator SDK file |
|
|
77
|
+
| `output.types` | `string` | — | Path template for type/schema files |
|
|
78
|
+
| `output.clients` | `string` | — | Path template for individual client files |
|
|
79
|
+
|
|
80
|
+
### `zod`
|
|
81
|
+
|
|
82
|
+
Generates standalone Zod schema files from `contract` declarations only. Use this when you want schemas without any router or SDK output.
|
|
83
|
+
|
|
84
|
+
| Option | Type | Default | Description |
|
|
85
|
+
|---|---|---|---|
|
|
86
|
+
| `baseDir` | `string` | `rootDir` | Base directory for output files |
|
|
87
|
+
| `output` | `string` | `"{filename}.schema.ts"` | Path template for schema files |
|
|
88
|
+
|
|
89
|
+
### `types`
|
|
90
|
+
|
|
91
|
+
Generates plain TypeScript interface/type files from `contract` declarations. No Zod runtime dependency.
|
|
92
|
+
|
|
93
|
+
| Option | Type | Default | Description |
|
|
94
|
+
|---|---|---|---|
|
|
95
|
+
| `baseDir` | `string` | `rootDir` | Base directory for output files |
|
|
96
|
+
| `output` | `string` | `"{filename}.types.ts"` | Path template for type files |
|
|
97
|
+
|
|
98
|
+
## Path templates
|
|
99
|
+
|
|
100
|
+
Output paths support the following variables:
|
|
101
|
+
|
|
102
|
+
| Variable | Value |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `{filename}` | Base name of the `.ck` source file (without extension) |
|
|
105
|
+
| `{dir}` | Relative directory of the `.ck` source file |
|
|
106
|
+
| `{area}` | Value of the `area` key from the `options` block |
|
|
107
|
+
| `{name}` | The `name` option from the SDK sub-config |
|
|
108
|
+
|
|
109
|
+
## What gets generated
|
|
110
|
+
|
|
111
|
+
### Zod schema shape (from `contract`)
|
|
112
|
+
|
|
113
|
+
Contracts with `readonly` or `writeonly` fields generate up to three schemas:
|
|
114
|
+
|
|
115
|
+
- **`ModelBase`** — all fields including writeonly (only when writeonly fields exist)
|
|
116
|
+
- **`Model`** — read schema; no writeonly fields; extends `ModelBase` when it exists
|
|
117
|
+
- **`ModelInput`** — input schema; no readonly fields (only when readonly/writeonly fields exist)
|
|
118
|
+
|
|
119
|
+
Contracts without visibility modifiers generate a single `Model` schema.
|
|
120
|
+
|
|
121
|
+
### Koa router shape (from `operation`)
|
|
122
|
+
|
|
123
|
+
Each operation file generates one Koa router. Request bodies and path/query params are validated against the Zod schemas (when `zod: true`) or plain types. Handlers are expected to be exported from the service module specified by `servicePathTemplate`.
|
|
124
|
+
|
|
125
|
+
### SDK client shape (from `operation`)
|
|
126
|
+
|
|
127
|
+
Each operation file generates one client class. The aggregator SDK class (in `output.sdk`) instantiates all clients and exposes them as properties.
|
|
128
|
+
|
|
129
|
+
Method names follow this priority:
|
|
130
|
+
|
|
131
|
+
1. `sdk:` field on the HTTP verb declaration — used as-is (e.g. `sdk: getUser` → `getUser`)
|
|
132
|
+
2. `name:` field — converted to camelCase (e.g. `name: "Get User"` → `getUser`)
|
|
133
|
+
3. Inferred from the HTTP method and path (e.g. `GET /users/{id}` → `getUsersById`)
|
|
134
|
+
|
|
135
|
+
A shared `sdk-options.ts` file is emitted alongside the clients. It exports:
|
|
136
|
+
|
|
137
|
+
- `SdkOptions` / `SdkFetch` / `SdkError` / `createSdkFetch` — base client primitives
|
|
138
|
+
- `buildQueryString(query)` — serialises a query params object to `?key=value` or `''`
|
|
139
|
+
- `parseJson<T>(res)` — deserialises a `Response` body to `T`
|
|
140
|
+
- `bigIntReplacer` / `bigIntReviver` — JSON replacer/reviver for `bigint` values
|
|
141
|
+
|
|
142
|
+
## Programmatic use
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { createTypescriptPlugin } from '@contractkit/contractkit-plugin-typescript';
|
|
146
|
+
|
|
147
|
+
const plugin = createTypescriptPlugin({
|
|
148
|
+
server: {
|
|
149
|
+
output: { routes: 'src/routes/{filename}.router.ts' },
|
|
150
|
+
servicePathTemplate: '#services/{module}.service.js',
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
```
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
body, html {
|
|
2
|
+
margin:0; padding: 0;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
body {
|
|
6
|
+
font-family: Helvetica Neue, Helvetica, Arial;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
color:#333;
|
|
9
|
+
}
|
|
10
|
+
.small { font-size: 12px; }
|
|
11
|
+
*, *:after, *:before {
|
|
12
|
+
-webkit-box-sizing:border-box;
|
|
13
|
+
-moz-box-sizing:border-box;
|
|
14
|
+
box-sizing:border-box;
|
|
15
|
+
}
|
|
16
|
+
h1 { font-size: 20px; margin: 0;}
|
|
17
|
+
h2 { font-size: 14px; }
|
|
18
|
+
pre {
|
|
19
|
+
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
-moz-tab-size: 2;
|
|
23
|
+
-o-tab-size: 2;
|
|
24
|
+
tab-size: 2;
|
|
25
|
+
}
|
|
26
|
+
a { color:#0074D9; text-decoration:none; }
|
|
27
|
+
a:hover { text-decoration:underline; }
|
|
28
|
+
.strong { font-weight: bold; }
|
|
29
|
+
.space-top1 { padding: 10px 0 0 0; }
|
|
30
|
+
.pad2y { padding: 20px 0; }
|
|
31
|
+
.pad1y { padding: 10px 0; }
|
|
32
|
+
.pad2x { padding: 0 20px; }
|
|
33
|
+
.pad2 { padding: 20px; }
|
|
34
|
+
.pad1 { padding: 10px; }
|
|
35
|
+
.space-left2 { padding-left:55px; }
|
|
36
|
+
.space-right2 { padding-right:20px; }
|
|
37
|
+
.center { text-align:center; }
|
|
38
|
+
.clearfix { display:block; }
|
|
39
|
+
.clearfix:after {
|
|
40
|
+
content:'';
|
|
41
|
+
display:block;
|
|
42
|
+
height:0;
|
|
43
|
+
clear:both;
|
|
44
|
+
visibility:hidden;
|
|
45
|
+
}
|
|
46
|
+
.fl { float: left; }
|
|
47
|
+
@media only screen and (max-width:640px) {
|
|
48
|
+
.col3 { width:100%; max-width:100%; }
|
|
49
|
+
.hide-mobile { display:none!important; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.quiet {
|
|
53
|
+
color: #7f7f7f;
|
|
54
|
+
color: rgba(0,0,0,0.5);
|
|
55
|
+
}
|
|
56
|
+
.quiet a { opacity: 0.7; }
|
|
57
|
+
|
|
58
|
+
.fraction {
|
|
59
|
+
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
color: #555;
|
|
62
|
+
background: #E8E8E8;
|
|
63
|
+
padding: 4px 5px;
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
div.path a:link, div.path a:visited { color: #333; }
|
|
69
|
+
table.coverage {
|
|
70
|
+
border-collapse: collapse;
|
|
71
|
+
margin: 10px 0 0 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
table.coverage td {
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
vertical-align: top;
|
|
79
|
+
}
|
|
80
|
+
table.coverage td.line-count {
|
|
81
|
+
text-align: right;
|
|
82
|
+
padding: 0 5px 0 20px;
|
|
83
|
+
}
|
|
84
|
+
table.coverage td.line-coverage {
|
|
85
|
+
text-align: right;
|
|
86
|
+
padding-right: 10px;
|
|
87
|
+
min-width:20px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
table.coverage td span.cline-any {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
padding: 0 5px;
|
|
93
|
+
width: 100%;
|
|
94
|
+
}
|
|
95
|
+
.missing-if-branch {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
margin-right: 5px;
|
|
98
|
+
border-radius: 3px;
|
|
99
|
+
position: relative;
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
background: #333;
|
|
102
|
+
color: yellow;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.skip-if-branch {
|
|
106
|
+
display: none;
|
|
107
|
+
margin-right: 10px;
|
|
108
|
+
position: relative;
|
|
109
|
+
padding: 0 4px;
|
|
110
|
+
background: #ccc;
|
|
111
|
+
color: white;
|
|
112
|
+
}
|
|
113
|
+
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
114
|
+
color: inherit !important;
|
|
115
|
+
}
|
|
116
|
+
.coverage-summary {
|
|
117
|
+
border-collapse: collapse;
|
|
118
|
+
width: 100%;
|
|
119
|
+
}
|
|
120
|
+
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
121
|
+
.keyline-all { border: 1px solid #ddd; }
|
|
122
|
+
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
123
|
+
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
124
|
+
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
125
|
+
.coverage-summary td:last-child { border-right: none; }
|
|
126
|
+
.coverage-summary th {
|
|
127
|
+
text-align: left;
|
|
128
|
+
font-weight: normal;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
.coverage-summary th.file { border-right: none !important; }
|
|
132
|
+
.coverage-summary th.pct { }
|
|
133
|
+
.coverage-summary th.pic,
|
|
134
|
+
.coverage-summary th.abs,
|
|
135
|
+
.coverage-summary td.pct,
|
|
136
|
+
.coverage-summary td.abs { text-align: right; }
|
|
137
|
+
.coverage-summary td.file { white-space: nowrap; }
|
|
138
|
+
.coverage-summary td.pic { min-width: 120px !important; }
|
|
139
|
+
.coverage-summary tfoot td { }
|
|
140
|
+
|
|
141
|
+
.coverage-summary .sorter {
|
|
142
|
+
height: 10px;
|
|
143
|
+
width: 7px;
|
|
144
|
+
display: inline-block;
|
|
145
|
+
margin-left: 0.5em;
|
|
146
|
+
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
147
|
+
}
|
|
148
|
+
.coverage-summary .sorted .sorter {
|
|
149
|
+
background-position: 0 -20px;
|
|
150
|
+
}
|
|
151
|
+
.coverage-summary .sorted-desc .sorter {
|
|
152
|
+
background-position: 0 -10px;
|
|
153
|
+
}
|
|
154
|
+
.status-line { height: 10px; }
|
|
155
|
+
/* yellow */
|
|
156
|
+
.cbranch-no { background: yellow !important; color: #111; }
|
|
157
|
+
/* dark red */
|
|
158
|
+
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
159
|
+
.low .chart { border:1px solid #C21F39 }
|
|
160
|
+
.highlighted,
|
|
161
|
+
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
|
162
|
+
background: #C21F39 !important;
|
|
163
|
+
}
|
|
164
|
+
/* medium red */
|
|
165
|
+
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
166
|
+
/* light red */
|
|
167
|
+
.low, .cline-no { background:#FCE1E5 }
|
|
168
|
+
/* light green */
|
|
169
|
+
.high, .cline-yes { background:rgb(230,245,208) }
|
|
170
|
+
/* medium green */
|
|
171
|
+
.cstat-yes { background:rgb(161,215,106) }
|
|
172
|
+
/* dark green */
|
|
173
|
+
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
174
|
+
.high .chart { border:1px solid rgb(77,146,33) }
|
|
175
|
+
/* dark yellow (gold) */
|
|
176
|
+
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
|
177
|
+
.medium .chart { border:1px solid #f9cd0b; }
|
|
178
|
+
/* light yellow */
|
|
179
|
+
.medium { background: #fff4c2; }
|
|
180
|
+
|
|
181
|
+
.cstat-skip { background: #ddd; color: #111; }
|
|
182
|
+
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
183
|
+
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
184
|
+
|
|
185
|
+
span.cline-neutral { background: #eaeaea; }
|
|
186
|
+
|
|
187
|
+
.coverage-summary td.empty {
|
|
188
|
+
opacity: .5;
|
|
189
|
+
padding-top: 4px;
|
|
190
|
+
padding-bottom: 4px;
|
|
191
|
+
line-height: 1;
|
|
192
|
+
color: #888;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.cover-fill, .cover-empty {
|
|
196
|
+
display:inline-block;
|
|
197
|
+
height: 12px;
|
|
198
|
+
}
|
|
199
|
+
.chart {
|
|
200
|
+
line-height: 0;
|
|
201
|
+
}
|
|
202
|
+
.cover-empty {
|
|
203
|
+
background: white;
|
|
204
|
+
}
|
|
205
|
+
.cover-full {
|
|
206
|
+
border-right: none !important;
|
|
207
|
+
}
|
|
208
|
+
pre.prettyprint {
|
|
209
|
+
border: none !important;
|
|
210
|
+
padding: 0 !important;
|
|
211
|
+
margin: 0 !important;
|
|
212
|
+
}
|
|
213
|
+
.com { color: #999 !important; }
|
|
214
|
+
.ignore-none { color: #999; font-weight: normal; }
|
|
215
|
+
|
|
216
|
+
.wrapper {
|
|
217
|
+
min-height: 100%;
|
|
218
|
+
height: auto !important;
|
|
219
|
+
height: 100%;
|
|
220
|
+
margin: 0 auto -48px;
|
|
221
|
+
}
|
|
222
|
+
.footer, .push {
|
|
223
|
+
height: 48px;
|
|
224
|
+
}
|