@kizunajs/fetch 2.0.0-beta.2 → 2.0.0-beta.3
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/server.cjs +3 -7
- package/dist/server.mjs +4 -8
- package/package.json +4 -4
package/dist/server.cjs
CHANGED
|
@@ -159,11 +159,7 @@ const typeOf = (schema, collector, hint) => {
|
|
|
159
159
|
const def = (0, kizunajs_generator.readDef)(schema);
|
|
160
160
|
if (def.type === "nullable" && def.innerType) return `${typeOf(def.innerType, collector, hint)} | null`;
|
|
161
161
|
if (def.type === "nullish" && def.innerType) return `${typeOf(def.innerType, collector, hint)} | null`;
|
|
162
|
-
if (def.innerType && def.type !== "object")
|
|
163
|
-
const { inner } = (0, kizunajs_generator.unwrapOptionalWrappers)(schema);
|
|
164
|
-
if (inner !== schema) return typeOf(inner, collector, hint);
|
|
165
|
-
return typeOf(def.innerType, collector, hint);
|
|
166
|
-
}
|
|
162
|
+
if (def.innerType && def.type !== "object") return typeOf(def.innerType, collector, hint);
|
|
167
163
|
if (def.type === "pipe") {
|
|
168
164
|
const side = def.out ?? def.in;
|
|
169
165
|
return side ? typeOf(side, collector, hint) : "unknown";
|
|
@@ -247,7 +243,7 @@ const exampleCall = (routeKey, route) => {
|
|
|
247
243
|
entries.push(`params: {\n${indent(fields.join("\n"))}\n},`);
|
|
248
244
|
}
|
|
249
245
|
if (route.query && requiresArgument(route.query)) entries.push(`query: ${sampleObject(route.query)},`);
|
|
250
|
-
if (route.body && requiresArgument(route.body)) entries.push(`body: ${sampleValue(route.body)},`);
|
|
246
|
+
if (route.body && !(0, kizunajs_generator.isVoidSchema)(route.body) && requiresArgument(route.body)) entries.push(`body: ${sampleValue(route.body)},`);
|
|
251
247
|
return `const result = await client.${routeKey}(${entries.length > 0 ? `{\n${indent(entries.join("\n"))}\n}` : ""});`;
|
|
252
248
|
};
|
|
253
249
|
/**
|
|
@@ -293,7 +289,7 @@ const emitRoute = (routeKey, key, route, collector) => {
|
|
|
293
289
|
members.push(`export type Query = ${typeOf(route.query, collector, `${namespace}Query`)};`);
|
|
294
290
|
args.push(`query?: API.${namespace}.Query`);
|
|
295
291
|
}
|
|
296
|
-
if (route.body) {
|
|
292
|
+
if (route.body && !(0, kizunajs_generator.isVoidSchema)(route.body)) {
|
|
297
293
|
members.push(`export type Body = ${typeOf(route.body, collector, `${namespace}Body`)};`);
|
|
298
294
|
args.push(`body: API.${namespace}.Body`);
|
|
299
295
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationErrorSchema } from "kizunajs/schemas";
|
|
2
|
-
import { isBinarySchema, isFileSchema, isStreamResponse, readDef, readDeprecation, readDiscriminatedUnion, readMetaDescription, readMetaExamples, readMetaId, readObjectShape, resolveResponseBody, resolveResponseHeaders, streamContentType, toPascalCase, unwrapOptionalWrappers } from "kizunajs/generator";
|
|
2
|
+
import { isBinarySchema, isFileSchema, isStreamResponse, isVoidSchema, readDef, readDeprecation, readDiscriminatedUnion, readMetaDescription, readMetaExamples, readMetaId, readObjectShape, resolveResponseBody, resolveResponseHeaders, streamContentType, toPascalCase, unwrapOptionalWrappers } from "kizunajs/generator";
|
|
3
3
|
//#region src/zod-to-typescript.ts
|
|
4
4
|
/**
|
|
5
5
|
* Collects the named types a walk produces, so a model shared by many routes is
|
|
@@ -158,11 +158,7 @@ const typeOf = (schema, collector, hint) => {
|
|
|
158
158
|
const def = readDef(schema);
|
|
159
159
|
if (def.type === "nullable" && def.innerType) return `${typeOf(def.innerType, collector, hint)} | null`;
|
|
160
160
|
if (def.type === "nullish" && def.innerType) return `${typeOf(def.innerType, collector, hint)} | null`;
|
|
161
|
-
if (def.innerType && def.type !== "object")
|
|
162
|
-
const { inner } = unwrapOptionalWrappers(schema);
|
|
163
|
-
if (inner !== schema) return typeOf(inner, collector, hint);
|
|
164
|
-
return typeOf(def.innerType, collector, hint);
|
|
165
|
-
}
|
|
161
|
+
if (def.innerType && def.type !== "object") return typeOf(def.innerType, collector, hint);
|
|
166
162
|
if (def.type === "pipe") {
|
|
167
163
|
const side = def.out ?? def.in;
|
|
168
164
|
return side ? typeOf(side, collector, hint) : "unknown";
|
|
@@ -246,7 +242,7 @@ const exampleCall = (routeKey, route) => {
|
|
|
246
242
|
entries.push(`params: {\n${indent(fields.join("\n"))}\n},`);
|
|
247
243
|
}
|
|
248
244
|
if (route.query && requiresArgument(route.query)) entries.push(`query: ${sampleObject(route.query)},`);
|
|
249
|
-
if (route.body && requiresArgument(route.body)) entries.push(`body: ${sampleValue(route.body)},`);
|
|
245
|
+
if (route.body && !isVoidSchema(route.body) && requiresArgument(route.body)) entries.push(`body: ${sampleValue(route.body)},`);
|
|
250
246
|
return `const result = await client.${routeKey}(${entries.length > 0 ? `{\n${indent(entries.join("\n"))}\n}` : ""});`;
|
|
251
247
|
};
|
|
252
248
|
/**
|
|
@@ -292,7 +288,7 @@ const emitRoute = (routeKey, key, route, collector) => {
|
|
|
292
288
|
members.push(`export type Query = ${typeOf(route.query, collector, `${namespace}Query`)};`);
|
|
293
289
|
args.push(`query?: API.${namespace}.Query`);
|
|
294
290
|
}
|
|
295
|
-
if (route.body) {
|
|
291
|
+
if (route.body && !isVoidSchema(route.body)) {
|
|
296
292
|
members.push(`export type Body = ${typeOf(route.body, collector, `${namespace}Body`)};`);
|
|
297
293
|
args.push(`body: API.${namespace}.Body`);
|
|
298
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizunajs/fetch",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Typed fetch client for Kizuna.js APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kizunajs",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"zod": "^4.0.0",
|
|
71
|
-
"kizunajs": "2.0.0-beta.
|
|
71
|
+
"kizunajs": "2.0.0-beta.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/express": "^5.0.0",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"tsdown": "^0.21.0",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"zod": "^4.0.0",
|
|
79
|
-
"kizunajs": "2.0.0-beta.
|
|
80
|
-
"@kizunajs/express": "2.0.0-beta.
|
|
79
|
+
"kizunajs": "2.0.0-beta.3",
|
|
80
|
+
"@kizunajs/express": "2.0.0-beta.3"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsdown src/index.ts src/server.ts --format esm,cjs --dts --clean --external kizunajs --external zod",
|