mutano 3.0.20 → 3.0.22
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/main.js +11 -2
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -401,8 +401,8 @@ function generateStandardType(op, desc, config, destination, typeMappings) {
|
|
|
401
401
|
const useTrim = destination.useTrim;
|
|
402
402
|
const requiredString = destination.requiredString;
|
|
403
403
|
baseType = "z.string()";
|
|
404
|
-
if (useTrim) baseType += ".trim()";
|
|
405
|
-
if (requiredString && !shouldBeNullable) baseType += ".min(1)";
|
|
404
|
+
if (useTrim && op !== "selectable") baseType += ".trim()";
|
|
405
|
+
if (requiredString && !shouldBeNullable && op !== "selectable") baseType += ".min(1)";
|
|
406
406
|
} else {
|
|
407
407
|
baseType = "string";
|
|
408
408
|
}
|
|
@@ -429,12 +429,21 @@ function generateStandardType(op, desc, config, destination, typeMappings) {
|
|
|
429
429
|
return `${baseType}.default(${defaultValueFormatted})`;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
+
const isDateField = typeMappings.dateTypes.includes(type);
|
|
433
|
+
const shouldDateBeOptional = isDateField && (hasDefaultValue || isGenerated) && (op === "table" || op === "selectable");
|
|
434
|
+
const isIdField = typeMappings.numberTypes.includes(type) || typeMappings.bigIntTypes.includes(type) || typeMappings.stringTypes.includes(type);
|
|
435
|
+
const shouldIdBeOptional = isIdField && isGenerated && (op === "table" || op === "selectable");
|
|
432
436
|
if (shouldBeNullable && shouldBeOptional) {
|
|
433
437
|
return `${baseType}.${nullableMethod}()`;
|
|
434
438
|
} else if (shouldBeNullable) {
|
|
439
|
+
if (shouldDateBeOptional || shouldIdBeOptional) {
|
|
440
|
+
return `${baseType}.${nullableMethod}().optional()`;
|
|
441
|
+
}
|
|
435
442
|
return `${baseType}.${nullableMethod}()`;
|
|
436
443
|
} else if (shouldBeOptional) {
|
|
437
444
|
return `${baseType}.optional()`;
|
|
445
|
+
} else if (shouldDateBeOptional || shouldIdBeOptional) {
|
|
446
|
+
return `${baseType}.optional()`;
|
|
438
447
|
} else {
|
|
439
448
|
return baseType;
|
|
440
449
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mutano",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.22",
|
|
5
5
|
"description": "Converts Prisma/MySQL/PostgreSQL/SQLite schemas to Zod/TS/Kysely interfaces",
|
|
6
6
|
"author": "Alisson Cavalcante Agiani <thelinuxlich@gmail.com>",
|
|
7
7
|
"license": "MIT",
|