@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractkit/plugin-typescript",
3
- "version": "0.22.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-eslint": "0.3.1",
33
- "@repo/config-typescript": "0.1.0"
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",
@@ -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('throw new SdkError(');
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())');