typed-openapi 2.1.1 → 2.1.2

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.
@@ -5,7 +5,7 @@ import {
5
5
  generateFile,
6
6
  generateTanstackQueryFile,
7
7
  mapOpenApiEndpoints
8
- } from "./chunk-KAZF7BK3.js";
8
+ } from "./chunk-X4A4YQN7.js";
9
9
  import {
10
10
  prettify
11
11
  } from "./chunk-KAEXXJ7X.js";
@@ -697,7 +697,7 @@ export class ApiClient {
697
697
  "typebox",
698
698
  "valibot",
699
699
  () => `InferResponseByStatus<${infer(`TEndpoint`)}, SuccessStatusCode>["data"]`
700
- ).otherwise(() => `InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"]`)}>;
700
+ ).otherwise(() => `Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]`)}>;
701
701
 
702
702
  ${method}<Path extends keyof ${capitalizedMethod}Endpoints, TEndpoint extends ${capitalizedMethod}Endpoints[Path]>(
703
703
  path: Path,
@@ -733,7 +733,7 @@ export class ApiClient {
733
733
  "typebox",
734
734
  "valibot",
735
735
  () => `as Promise<InferResponseByStatus<${infer(`TEndpoint`)}, SuccessStatusCode>["data"]>`
736
- ).otherwise(() => `as Promise<InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"]>`)}
736
+ ).otherwise(() => `as Promise<Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]>`)}
737
737
  }
738
738
  // </ApiClient.${method}>
739
739
  ` : "";
@@ -1333,7 +1333,7 @@ var generateTanstackQueryFile = async (ctx) => {
1333
1333
  withResponse: false as const
1334
1334
  };
1335
1335
  const res = await this.client.${method}(path, requestParams);
1336
- return res as InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"];
1336
+ return res as Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"];
1337
1337
  },
1338
1338
  queryKey: queryKey
1339
1339
  }),
@@ -1348,7 +1348,7 @@ var generateTanstackQueryFile = async (ctx) => {
1348
1348
  withResponse: false as const
1349
1349
  };
1350
1350
  const res = await this.client.${method}(path, requestParams);
1351
- return res as InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"];
1351
+ return res as Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"];
1352
1352
  }
1353
1353
  }
1354
1354
  };
@@ -1371,7 +1371,7 @@ var generateTanstackQueryFile = async (ctx) => {
1371
1371
  TWithResponse extends boolean = false,
1372
1372
  TSelection = TWithResponse extends true
1373
1373
  ? InferResponseByStatus<TEndpoint, SuccessStatusCode>
1374
- : TEndpoint extends { response: infer Res } ? Res : never,
1374
+ : Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"],
1375
1375
  TError = TEndpoint extends { responses: infer TResponses }
1376
1376
  ? TResponses extends Record<string | number, unknown>
1377
1377
  ? InferResponseByStatus<TEndpoint, ErrorStatusCode>
@@ -1381,7 +1381,7 @@ var generateTanstackQueryFile = async (ctx) => {
1381
1381
  withResponse?: TWithResponse;
1382
1382
  selectFn?: (res: TWithResponse extends true
1383
1383
  ? InferResponseByStatus<TEndpoint, SuccessStatusCode>
1384
- : TEndpoint extends { response: infer Res } ? Res : never
1384
+ : Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]
1385
1385
  ) => TSelection;
1386
1386
  throwOnStatusError?: boolean
1387
1387
  }) {
@@ -1395,9 +1395,7 @@ var generateTanstackQueryFile = async (ctx) => {
1395
1395
  mutationKey: mutationKey,
1396
1396
  mutationFn: async <TLocalWithResponse extends boolean = TWithResponse, TLocalSelection = TLocalWithResponse extends true
1397
1397
  ? InferResponseByStatus<TEndpoint, SuccessStatusCode>
1398
- : TEndpoint extends { response: infer Res }
1399
- ? Res
1400
- : never>
1398
+ : Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]>
1401
1399
  (params: (TEndpoint extends { parameters: infer Parameters } ? Parameters : {}) & {
1402
1400
  withResponse?: TLocalWithResponse;
1403
1401
  throwOnStatusError?: boolean;
package/dist/cli.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  generateClientFiles
3
- } from "./chunk-CO4NONVX.js";
3
+ } from "./chunk-UNKLDND3.js";
4
4
  import {
5
5
  allowedRuntimes
6
- } from "./chunk-KAZF7BK3.js";
6
+ } from "./chunk-X4A4YQN7.js";
7
7
  import "./chunk-KAEXXJ7X.js";
8
8
 
9
9
  // src/cli.ts
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  openApiSchemaToTs,
9
9
  tsFactory,
10
10
  unwrap
11
- } from "./chunk-KAZF7BK3.js";
11
+ } from "./chunk-X4A4YQN7.js";
12
12
  import "./chunk-KAEXXJ7X.js";
13
13
  export {
14
14
  createBoxFactory,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generateClientFiles
3
- } from "./chunk-CO4NONVX.js";
4
- import "./chunk-KAZF7BK3.js";
3
+ } from "./chunk-UNKLDND3.js";
4
+ import "./chunk-X4A4YQN7.js";
5
5
  import "./chunk-KAEXXJ7X.js";
6
6
  export {
7
7
  generateClientFiles
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typed-openapi",
3
3
  "type": "module",
4
- "version": "2.1.1",
4
+ "version": "2.1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {
package/src/generator.ts CHANGED
@@ -462,7 +462,7 @@ export class ApiClient {
462
462
  "valibot",
463
463
  () => `InferResponseByStatus<${infer(`TEndpoint`)}, SuccessStatusCode>["data"]`,
464
464
  )
465
- .otherwise(() => `InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"]`)}>;
465
+ .otherwise(() => `Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]`)}>;
466
466
 
467
467
  ${method}<Path extends keyof ${capitalizedMethod}Endpoints, TEndpoint extends ${capitalizedMethod}Endpoints[Path]>(
468
468
  path: Path,
@@ -504,7 +504,7 @@ export class ApiClient {
504
504
  "valibot",
505
505
  () => `as Promise<InferResponseByStatus<${infer(`TEndpoint`)}, SuccessStatusCode>["data"]>`,
506
506
  )
507
- .otherwise(() => `as Promise<InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"]>`)}
507
+ .otherwise(() => `as Promise<Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]>`)}
508
508
  }
509
509
  // </ApiClient.${method}>
510
510
  `
@@ -95,7 +95,7 @@ export const generateTanstackQueryFile = async (ctx: GeneratorContext & { relati
95
95
  withResponse: false as const
96
96
  };
97
97
  const res = await this.client.${method}(path, requestParams);
98
- return res as InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"];
98
+ return res as Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"];
99
99
  },
100
100
  queryKey: queryKey
101
101
  }),
@@ -110,7 +110,7 @@ export const generateTanstackQueryFile = async (ctx: GeneratorContext & { relati
110
110
  withResponse: false as const
111
111
  };
112
112
  const res = await this.client.${method}(path, requestParams);
113
- return res as InferResponseByStatus<TEndpoint, SuccessStatusCode>["data"];
113
+ return res as Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"];
114
114
  }
115
115
  }
116
116
  };
@@ -134,7 +134,7 @@ export const generateTanstackQueryFile = async (ctx: GeneratorContext & { relati
134
134
  TWithResponse extends boolean = false,
135
135
  TSelection = TWithResponse extends true
136
136
  ? InferResponseByStatus<TEndpoint, SuccessStatusCode>
137
- : TEndpoint extends { response: infer Res } ? Res : never,
137
+ : Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"],
138
138
  TError = TEndpoint extends { responses: infer TResponses }
139
139
  ? TResponses extends Record<string | number, unknown>
140
140
  ? InferResponseByStatus<TEndpoint, ErrorStatusCode>
@@ -144,7 +144,7 @@ export const generateTanstackQueryFile = async (ctx: GeneratorContext & { relati
144
144
  withResponse?: TWithResponse;
145
145
  selectFn?: (res: TWithResponse extends true
146
146
  ? InferResponseByStatus<TEndpoint, SuccessStatusCode>
147
- : TEndpoint extends { response: infer Res } ? Res : never
147
+ : Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]
148
148
  ) => TSelection;
149
149
  throwOnStatusError?: boolean
150
150
  }) {
@@ -158,9 +158,7 @@ export const generateTanstackQueryFile = async (ctx: GeneratorContext & { relati
158
158
  mutationKey: mutationKey,
159
159
  mutationFn: async <TLocalWithResponse extends boolean = TWithResponse, TLocalSelection = TLocalWithResponse extends true
160
160
  ? InferResponseByStatus<TEndpoint, SuccessStatusCode>
161
- : TEndpoint extends { response: infer Res }
162
- ? Res
163
- : never>
161
+ : Extract<InferResponseByStatus<TEndpoint, SuccessStatusCode>, { data: {} }>["data"]>
164
162
  (params: (TEndpoint extends { parameters: infer Parameters } ? Parameters : {}) & {
165
163
  withResponse?: TLocalWithResponse;
166
164
  throwOnStatusError?: boolean;