@kubb/plugin-zod 5.2.1 → 5.2.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.cjs +8 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1228,10 +1228,12 @@ function collectDirectionalRefNames({ node, printerOptions }) {
|
|
|
1228
1228
|
* Handlers that never recurse into children, so {@link variesByDirection} can call one directly
|
|
1229
1229
|
* to probe both directions without building a printer.
|
|
1230
1230
|
*
|
|
1231
|
-
* `date`
|
|
1232
|
-
* back on requests
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1231
|
+
* `date` and `time` are the built-in two-way conversions, decoding `string → Date` on responses
|
|
1232
|
+
* and encoding back on requests. `date` keeps `date` and `date-time` precision apart. `time` has
|
|
1233
|
+
* no date component, so it decodes onto `1970-01-01` UTC and encodes back to `HH:mm:ss`, dropping
|
|
1234
|
+
* fractional seconds. Only `representation: 'date'` fields convert; ISO-string fields print the
|
|
1235
|
+
* matching `z.iso.*()` either way. A `printer.nodes.date` or `printer.nodes.time` override
|
|
1236
|
+
* replaces the whole handler, direction branch included.
|
|
1235
1237
|
*/
|
|
1236
1238
|
const scalarNodes = {
|
|
1237
1239
|
any: () => "z.any()",
|
|
@@ -1303,7 +1305,8 @@ const scalarNodes = {
|
|
|
1303
1305
|
},
|
|
1304
1306
|
time(node) {
|
|
1305
1307
|
if (node.representation === "string") return "z.iso.time()";
|
|
1306
|
-
|
|
1308
|
+
if (this.options.direction === "encode") return "z.date().transform((value) => value.toISOString().slice(11, 19))";
|
|
1309
|
+
return "z.iso.time().transform((value) => new Date(`1970-01-01T${value}Z`))";
|
|
1307
1310
|
},
|
|
1308
1311
|
uuid(node) {
|
|
1309
1312
|
return `${this.options.guidType === "guid" ? "z.guid()" : "z.uuid()"}${lengthConstraints({
|