mutano 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/main.js +9 -6
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -95,7 +95,7 @@ function getType(op, desc, config) {
95
95
  const field = typeOverride ? [typeOverride] : dateField;
96
96
  if (isNull && !typeOverride)
97
97
  field.push(nullable);
98
- else if (hasDefaultValue)
98
+ else if (hasDefaultValue || !hasDefaultValue && isGenerated)
99
99
  field.push(optional);
100
100
  if (hasDefaultValue && !isGenerated)
101
101
  field.push(`default('${Default}')`);
@@ -107,7 +107,7 @@ function getType(op, desc, config) {
107
107
  const field = typeOverride ? [typeOverride] : string;
108
108
  if (isNull && !typeOverride)
109
109
  field.push(nullable);
110
- else if (hasDefaultValue)
110
+ else if (hasDefaultValue || !hasDefaultValue && isGenerated)
111
111
  field.push(optional);
112
112
  else if (isRequiredString && !typeOverride)
113
113
  field.push(min1);
@@ -121,7 +121,7 @@ function getType(op, desc, config) {
121
121
  const field = typeOverride ? [typeOverride] : boolean;
122
122
  if (isNull && !typeOverride)
123
123
  field.push(nullable);
124
- else if (hasDefaultValue)
124
+ else if (hasDefaultValue || !hasDefaultValue && isGenerated)
125
125
  field.push(optional);
126
126
  if (hasDefaultValue && !isGenerated)
127
127
  field.push(`default(${Boolean(+Default)})`);
@@ -136,7 +136,7 @@ function getType(op, desc, config) {
136
136
  field.push(nonnegative);
137
137
  if (isNull && !typeOverride)
138
138
  field.push(nullable);
139
- else if (hasDefaultValue)
139
+ else if (hasDefaultValue || !hasDefaultValue && isGenerated)
140
140
  field.push(optional);
141
141
  if (hasDefaultValue && !isGenerated)
142
142
  field.push(`default(${Default})`);
@@ -149,7 +149,7 @@ function getType(op, desc, config) {
149
149
  const field = [`z.enum([${value}])`];
150
150
  if (isNull)
151
151
  field.push(nullable);
152
- else if (hasDefaultValue)
152
+ else if (hasDefaultValue || !hasDefaultValue && isGenerated)
153
153
  field.push(optional);
154
154
  if (hasDefaultValue && !isGenerated)
155
155
  field.push(`default('${Default}')`);
@@ -246,7 +246,10 @@ async function generate(config) {
246
246
  name: fieldType
247
247
  })[0]?.enumerators.filter(
248
248
  (e) => e.type === "enumerator"
249
- ).map((e) => e.name);
249
+ ).map((e) => {
250
+ const attrs = e.attributes?.find((a) => a.name === "map");
251
+ return attrs?.args ? attrs.args[0].value.toString().replace(/"/g, "") : e.name;
252
+ });
250
253
  fieldType = "Enum";
251
254
  }
252
255
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mutano",
3
3
  "type": "module",
4
- "version": "1.0.6",
4
+ "version": "1.0.8",
5
5
  "description": "Converts Prisma/MySQL schemas to Zod interfaces",
6
6
  "author": "Alisson Cavalcante Agiani <thelinuxlich@gmail.com>",
7
7
  "license": "MIT",