@rexeus/typeweaver-core 0.1.1 → 0.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/index.d.ts +2 -1
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ type HttpBodySchema = ZodType;
|
|
|
6
6
|
|
|
7
7
|
type IHttpHeader = Record<string, string | string[]> | undefined;
|
|
8
8
|
type HttpHeaderValue = ZodString | ZodStringFormat | ZodLiteral<string> | ZodEnum<Record<string, string>>;
|
|
9
|
-
type
|
|
9
|
+
type HttpHeaderObject = ZodObject<Record<string, HttpHeaderValue | ZodOptional<HttpHeaderValue> | ZodArray<HttpHeaderValue> | ZodOptional<ZodArray<HttpHeaderValue>>>>;
|
|
10
|
+
type HttpHeaderSchema = HttpHeaderObject | ZodOptional<HttpHeaderObject>;
|
|
10
11
|
|
|
11
12
|
declare enum HttpMethod {
|
|
12
13
|
GET = "GET",
|
package/dist/index.js
CHANGED
|
@@ -170,10 +170,16 @@ class HttpResponseDefinition {
|
|
|
170
170
|
if (!this.header && !definition.header) return void 0;
|
|
171
171
|
if (!this.header) return definition.header;
|
|
172
172
|
if (!definition.header) return this.header;
|
|
173
|
-
|
|
174
|
-
...this.header.shape,
|
|
175
|
-
...definition.header.shape
|
|
173
|
+
const mergedHeader2 = z.object({
|
|
174
|
+
...this.header instanceof z.ZodObject ? this.header.shape : this.header.unwrap().shape,
|
|
175
|
+
...definition.header instanceof z.ZodObject ? definition.header.shape : definition.header.unwrap().shape
|
|
176
176
|
});
|
|
177
|
+
if (Object.values(mergedHeader2.shape).every(
|
|
178
|
+
(schema) => schema instanceof z.ZodOptional
|
|
179
|
+
)) {
|
|
180
|
+
return mergedHeader2.optional();
|
|
181
|
+
}
|
|
182
|
+
return mergedHeader2;
|
|
177
183
|
})();
|
|
178
184
|
const mergedBody = (() => {
|
|
179
185
|
if (!this.body && !definition.body) return void 0;
|