@contractkit/plugin-typescript 0.22.0 → 0.23.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 +6 -6
- package/.turbo/turbo-test$colon$ci.log +11 -11
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/coverage/clover.xml +354 -353
- package/coverage/coverage-final.json +1 -1
- package/coverage/index.html +9 -9
- package/coverage/src/codegen-contract.ts.html +1 -1
- package/coverage/src/codegen-operation.ts.html +1 -1
- package/coverage/src/codegen-plain-types.ts.html +1 -1
- package/coverage/src/codegen-sdk.ts.html +14 -8
- package/coverage/src/index.html +10 -10
- 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/codegen-sdk.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/codegen-sdk.ts +4 -2
- package/tests/codegen-sdk.test.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractkit/plugin-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "ContractKit built-in plugin: TypeScript codegen (SDK clients, Koa routers, Zod schemas, plain types)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marooned Software",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@contractkit/core": "0.17.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@repo/config-
|
|
33
|
-
"@repo/config-
|
|
32
|
+
"@repo/config-typescript": "0.1.0",
|
|
33
|
+
"@repo/config-eslint": "0.3.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
|
package/src/codegen-sdk.ts
CHANGED
|
@@ -138,6 +138,7 @@ export function generateSdk(root: OpRootNode, options: SdkCodegenOptions = {}):
|
|
|
138
138
|
lines.push(' public readonly status: number,');
|
|
139
139
|
lines.push(' public readonly statusText: string,');
|
|
140
140
|
lines.push(' public readonly body: unknown,');
|
|
141
|
+
lines.push(' public readonly headers: Headers,');
|
|
141
142
|
lines.push(' ) {');
|
|
142
143
|
lines.push(' super(`${status} ${statusText}`);');
|
|
143
144
|
lines.push(" this.name = 'SdkError';");
|
|
@@ -168,7 +169,7 @@ export function generateSdk(root: OpRootNode, options: SdkCodegenOptions = {}):
|
|
|
168
169
|
lines.push(' const text = await res.text();');
|
|
169
170
|
lines.push(' let body: unknown;');
|
|
170
171
|
lines.push(' try { body = JSON.parse(text); } catch { body = text; }');
|
|
171
|
-
lines.push(' throw new SdkError(res.status, res.statusText, body);');
|
|
172
|
+
lines.push(' throw new SdkError(res.status, res.statusText, body, res.headers);');
|
|
172
173
|
lines.push(' }');
|
|
173
174
|
lines.push(' return res;');
|
|
174
175
|
lines.push(' };');
|
|
@@ -885,6 +886,7 @@ export function generateSdkOptions(): string {
|
|
|
885
886
|
' public readonly status: number,',
|
|
886
887
|
' public readonly statusText: string,',
|
|
887
888
|
' public readonly body: unknown,',
|
|
889
|
+
' public readonly headers: Headers,',
|
|
888
890
|
' ) {',
|
|
889
891
|
' super(`${status} ${statusText}`);',
|
|
890
892
|
" this.name = 'SdkError';",
|
|
@@ -931,7 +933,7 @@ export function generateSdkOptions(): string {
|
|
|
931
933
|
' const text = await res.text();',
|
|
932
934
|
' let body: unknown;',
|
|
933
935
|
' try { body = JSON.parse(text); } catch { body = text; }',
|
|
934
|
-
' throw new SdkError(res.status, res.statusText, body);',
|
|
936
|
+
' throw new SdkError(res.status, res.statusText, body, res.headers);',
|
|
935
937
|
' }',
|
|
936
938
|
' return res;',
|
|
937
939
|
' };',
|
|
@@ -648,6 +648,8 @@ describe('generateSdk', () => {
|
|
|
648
648
|
expect(out).toContain('headers?:');
|
|
649
649
|
expect(out).toContain('fetch?: SdkFetch');
|
|
650
650
|
expect(out).toContain('export class SdkError extends Error');
|
|
651
|
+
expect(out).toContain('public readonly headers: Headers');
|
|
652
|
+
expect(out).toContain('throw new SdkError(res.status, res.statusText, body, res.headers)');
|
|
651
653
|
});
|
|
652
654
|
});
|
|
653
655
|
|
|
@@ -756,7 +758,8 @@ describe('generateSdkOptions', () => {
|
|
|
756
758
|
expect(out).toContain('export class SdkError extends Error');
|
|
757
759
|
expect(out).toContain('public readonly status: number');
|
|
758
760
|
expect(out).toContain('public readonly body: unknown');
|
|
759
|
-
expect(out).toContain('
|
|
761
|
+
expect(out).toContain('public readonly headers: Headers');
|
|
762
|
+
expect(out).toContain('throw new SdkError(res.status, res.statusText, body, res.headers)');
|
|
760
763
|
expect(out).toContain('export type SdkFetch');
|
|
761
764
|
expect(out).toContain('export function createSdkFetch(options: SdkOptions): SdkFetch');
|
|
762
765
|
expect(out).toContain('requestIdFactory ?? (() => crypto.randomUUID())');
|