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.
- package/dist/{chunk-CO4NONVX.js → chunk-UNKLDND3.js} +1 -1
- package/dist/{chunk-KAZF7BK3.js → chunk-X4A4YQN7.js} +7 -9
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/node.export.js +2 -2
- package/package.json +1 -1
- package/src/generator.ts +2 -2
- package/src/tanstack-query.generator.ts +5 -7
|
@@ -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
|
|
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
|
|
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
|
|
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
package/dist/index.js
CHANGED
package/dist/node.export.js
CHANGED
package/package.json
CHANGED
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
|
|
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
|
|
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
|
|
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;
|