@contractkit/plugin-typescript 0.21.0 → 0.22.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.
@@ -25,7 +25,7 @@
25
25
  <div class='fl pad1y space-right2'>
26
26
  <span class="strong">79.96% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>2028/2536</span>
28
+ <span class='fraction'>2027/2535</span>
29
29
  </div>
30
30
 
31
31
 
@@ -37,9 +37,9 @@
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">83.54% </span>
40
+ <span class="strong">83.5% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>335/401</span>
42
+ <span class='fraction'>334/400</span>
43
43
  </div>
44
44
 
45
45
 
@@ -80,15 +80,15 @@
80
80
  </thead>
81
81
  <tbody><tr>
82
82
  <td class="file medium" data-value="src"><a href="src/index.html">src</a></td>
83
- <td data-value="79.75" class="pic medium">
83
+ <td data-value="79.74" class="pic medium">
84
84
  <div class="chart"><div class="cover-fill" style="width: 79%"></div><div class="cover-empty" style="width: 21%"></div></div>
85
85
  </td>
86
- <td data-value="79.75" class="pct medium">79.75%</td>
87
- <td data-value="2484" class="abs medium">1981/2484</td>
86
+ <td data-value="79.74" class="pct medium">79.74%</td>
87
+ <td data-value="2483" class="abs medium">1980/2483</td>
88
88
  <td data-value="74.78" class="pct medium">74.78%</td>
89
89
  <td data-value="1602" class="abs medium">1198/1602</td>
90
- <td data-value="83.1" class="pct high">83.1%</td>
91
- <td data-value="373" class="abs high">310/373</td>
90
+ <td data-value="83.06" class="pct high">83.06%</td>
91
+ <td data-value="372" class="abs high">309/372</td>
92
92
  <td data-value="82.32" class="pct high">82.32%</td>
93
93
  <td data-value="2105" class="abs high">1733/2105</td>
94
94
  </tr>
@@ -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-05-07T11:53:53.335Z
119
+ at 2026-05-08T13:03:00.695Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -3598,7 +3598,7 @@ export function pascalToDotCase(name: string): string {
3598
3598
  <div class='footer quiet pad2 space-top1 center small'>
3599
3599
  Code coverage generated by
3600
3600
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
3601
- at 2026-05-07T11:53:53.335Z
3601
+ at 2026-05-08T13:03:00.695Z
3602
3602
  </div>
3603
3603
  <script src="../prettify.js"></script>
3604
3604
  <script>
@@ -23,9 +23,9 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">78.18% </span>
26
+ <span class="strong">78.13% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>362/463</span>
28
+ <span class='fraction'>361/462</span>
29
29
  </div>
30
30
 
31
31
 
@@ -37,9 +37,9 @@
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">78.08% </span>
40
+ <span class="strong">77.77% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>57/73</span>
42
+ <span class='fraction'>56/72</span>
43
43
  </div>
44
44
 
45
45
 
@@ -878,7 +878,8 @@
878
878
  <a name='L813'></a><a href='#L813'>813</a>
879
879
  <a name='L814'></a><a href='#L814'>814</a>
880
880
  <a name='L815'></a><a href='#L815'>815</a>
881
- <a name='L816'></a><a href='#L816'>816</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
881
+ <a name='L816'></a><a href='#L816'>816</a>
882
+ <a name='L817'></a><a href='#L817'>817</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
882
883
  <span class="cline-any cline-neutral">&nbsp;</span>
883
884
  <span class="cline-any cline-neutral">&nbsp;</span>
884
885
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -1007,6 +1008,7 @@
1007
1008
  <span class="cline-any cline-neutral">&nbsp;</span>
1008
1009
  <span class="cline-any cline-neutral">&nbsp;</span>
1009
1010
  <span class="cline-any cline-neutral">&nbsp;</span>
1011
+ <span class="cline-any cline-neutral">&nbsp;</span>
1010
1012
  <span class="cline-any cline-yes">110x</span>
1011
1013
  <span class="cline-any cline-yes">110x</span>
1012
1014
  <span class="cline-any cline-yes">110x</span>
@@ -1820,6 +1822,7 @@ export interface OpCodegenOptions {
1820
1822
  includeInternal?: boolean;
1821
1823
  }
1822
1824
  &nbsp;
1825
+ /** Generate a Koa router module for every operation in `root`, including the imports, type aliases, and handler list. */
1823
1826
  export function generateOp(root: OpRootNode, options: OpCodegenOptions = {}): string {
1824
1827
  // Collect all referenced types across all routes
1825
1828
  const types = collectTypes(root, options.modelsWithInput, options.modelsWithOutput);
@@ -1935,8 +1938,8 @@ function generateHandler(route: OpRouteNode, op: OpOperationNode, root: OpRootNo
1935
1938
  // Middleware list
1936
1939
  const middlewares: string[] = [];
1937
1940
  if (effectiveSecurity !== SECURITY_NONE) {
1938
- const roles = effectiveSecurity &amp;&amp; effectiveSecurity.roles?.length ? `roles: [${effectiveSecurity.roles.map(r =&gt; `'${r}'`).join(', ')}]` : '';
1939
- middlewares.push(`requireSecurity({ ${roles} })`);
1941
+ const args = effectiveSecurity &amp;&amp; effectiveSecurity.requireMfa !== undefined ? `{ requireMfa: ${effectiveSecurity.requireMfa} }` : '';
1942
+ middlewares.push(`requireSecurity(${args})`);
1940
1943
  }
1941
1944
  if (hasBody) {
1942
1945
  const parserTokens = Array.from(new Set(bodies.map(b =&gt; bodyParserToken(b.contentType))));
@@ -2515,7 +2518,7 @@ function deriveTypeImportPath(file: string, template?: string): string {
2515
2518
  <div class='footer quiet pad2 space-top1 center small'>
2516
2519
  Code coverage generated by
2517
2520
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2518
- at 2026-05-07T11:53:53.335Z
2521
+ at 2026-05-08T13:03:00.695Z
2519
2522
  </div>
2520
2523
  <script src="../prettify.js"></script>
2521
2524
  <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-05-07T11:53:53.335Z
985
+ at 2026-05-08T13:03:00.695Z
986
986
  </div>
987
987
  <script src="../prettify.js"></script>
988
988
  <script>
@@ -3646,7 +3646,7 @@ export function generateSdkAggregator(input: SdkAggregatorInput): 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-05-07T11:53:53.335Z
3649
+ at 2026-05-08T13:03:00.695Z
3650
3650
  </div>
3651
3651
  <script src="../prettify.js"></script>
3652
3652
  <script>
@@ -23,9 +23,9 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">79.75% </span>
26
+ <span class="strong">79.74% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>1981/2484</span>
28
+ <span class='fraction'>1980/2483</span>
29
29
  </div>
30
30
 
31
31
 
@@ -37,9 +37,9 @@
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">83.1% </span>
40
+ <span class="strong">83.06% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>310/373</span>
42
+ <span class='fraction'>309/372</span>
43
43
  </div>
44
44
 
45
45
 
@@ -95,15 +95,15 @@
95
95
 
96
96
  <tr>
97
97
  <td class="file medium" data-value="codegen-operation.ts"><a href="codegen-operation.ts.html">codegen-operation.ts</a></td>
98
- <td data-value="78.18" class="pic medium">
98
+ <td data-value="78.13" class="pic medium">
99
99
  <div class="chart"><div class="cover-fill" style="width: 78%"></div><div class="cover-empty" style="width: 22%"></div></div>
100
100
  </td>
101
- <td data-value="78.18" class="pct medium">78.18%</td>
102
- <td data-value="463" class="abs medium">362/463</td>
101
+ <td data-value="78.13" class="pct medium">78.13%</td>
102
+ <td data-value="462" class="abs medium">361/462</td>
103
103
  <td data-value="74.26" class="pct medium">74.26%</td>
104
104
  <td data-value="338" class="abs medium">251/338</td>
105
- <td data-value="78.08" class="pct medium">78.08%</td>
106
- <td data-value="73" class="abs medium">57/73</td>
105
+ <td data-value="77.77" class="pct medium">77.77%</td>
106
+ <td data-value="72" class="abs medium">56/72</td>
107
107
  <td data-value="79.69" class="pct medium">79.69%</td>
108
108
  <td data-value="399" class="abs medium">318/399</td>
109
109
  </tr>
@@ -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-05-07T11:53:53.335Z
194
+ at 2026-05-08T13:03:00.695Z
195
195
  </div>
196
196
  <script src="../prettify.js"></script>
197
197
  <script>
@@ -2635,7 +2635,7 @@ function stableSubConfig(config: unknown): string {
2635
2635
  <div class='footer quiet pad2 space-top1 center small'>
2636
2636
  Code coverage generated by
2637
2637
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
2638
- at 2026-05-07T11:53:53.335Z
2638
+ at 2026-05-08T13:03:00.695Z
2639
2639
  </div>
2640
2640
  <script src="../prettify.js"></script>
2641
2641
  <script>
@@ -730,7 +730,7 @@ export function <span class="fstat-no" title="function not covered" >computePubl
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-05-07T11:53:53.335Z
733
+ at 2026-05-08T13:03:00.695Z
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-05-07T11:53:53.335Z
580
+ at 2026-05-08T13:03:00.695Z
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-05-07T11:53:53.335Z
814
+ at 2026-05-08T13:03:00.695Z
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-05-07T11:53:53.335Z
104
+ at 2026-05-08T13:03:00.695Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
@@ -21,5 +21,6 @@ export interface OpCodegenOptions {
21
21
  */
22
22
  includeInternal?: boolean;
23
23
  }
24
+ /** Generate a Koa router module for every operation in `root`, including the imports, type aliases, and handler list. */
24
25
  export declare function generateOp(root: OpRootNode, options?: OpCodegenOptions): string;
25
26
  //# sourceMappingURL=codegen-operation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-operation.d.ts","sourceRoot":"","sources":["../src/codegen-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgC,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAmC7H;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAkE5F;AAID,MAAM,WAAW,gBAAgB;IAC7B,mBAAmB,CAAC,EAAE,MAAM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AM,CAwEnF"}
package/dist/index.js CHANGED
@@ -1251,8 +1251,8 @@ function generateHandler(route, op, root, options) {
1251
1251
  const isSingleMultipart = bodies.length === 1 && bodies[0].contentType === "multipart/form-data";
1252
1252
  const middlewares = [];
1253
1253
  if (effectiveSecurity !== SECURITY_NONE) {
1254
- const roles = effectiveSecurity && effectiveSecurity.roles?.length ? `roles: [${effectiveSecurity.roles.map((r) => `'${r}'`).join(", ")}]` : "";
1255
- middlewares.push(`requireSecurity({ ${roles} })`);
1254
+ const args = effectiveSecurity && effectiveSecurity.requireMfa !== void 0 ? `{ requireMfa: ${effectiveSecurity.requireMfa} }` : "";
1255
+ middlewares.push(`requireSecurity(${args})`);
1256
1256
  }
1257
1257
  if (hasBody) {
1258
1258
  const parserTokens = Array.from(new Set(bodies.map((b) => bodyParserToken(b.contentType))));