prisma-to-zod-v4 0.6.2 → 0.6.4

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 (3) hide show
  1. package/README.md +26 -15
  2. package/dist/index.js +90 -102
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -125,27 +125,38 @@ This project uses pnpm.
125
125
 
126
126
  ```prisma
127
127
  generator zod {
128
- provider = "prisma-to-zod-v4"
129
- output = "./zod" // (default) the directory where generated zod schemas will be saved
128
+ provider = "prisma-to-zod-v4"
130
129
 
131
- relationModel = true // (default) Create and export both plain and related models.
132
- // relationModel = "default" // Do not export model without relations.
133
- // relationModel = false // Do not generate related model
130
+ // Output directory for generated Zod schemas
131
+ output = "./zod" // default
134
132
 
135
- modelCase = "PascalCase" // (default) Output models using pascal case (ex. UserModel, PostModel)
136
- // modelCase = "camelCase" // Output models using camel case (ex. userModel, postModel)
133
+ // Relation model generation
134
+ relationModel = true // default: generate both plain and related models
135
+ // relationModel = "default" // generate only related models (no plain models)
136
+ // relationModel = false // disable related model generation
137
137
 
138
- modelSuffix = "Model" // (default) Suffix to apply to your prisma models when naming Zod schemas
138
+ // Naming conventions
139
+ modelCase = "PascalCase" // default: UserModel, PostModel
140
+ // modelCase = "camelCase" // userModel, postModel
139
141
 
140
- // useDecimalJs = false // (default) represent the prisma Decimal type using as a JS number
141
- useDecimalJs = true // represent the prisma Decimal type using Decimal.js (as Prisma does)
142
+ // Suffix appended to generated Zod schemas
143
+ modelSuffix = "Model" // default
142
144
 
143
- imports = null // (default) will import the referenced file in generated schemas to be used via imports.someExportedVariable
145
+ // Decimal handling
146
+ // useDecimalJs = false // default: represent Prisma Decimal as number
147
+ useDecimalJs = true // represent Prisma Decimal using Decimal.js (matches Prisma behavior)
144
148
 
145
- // https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values
146
- prismaJsonNullability = true // (default) uses prisma's scheme for JSON field nullability
147
- // prismaJsonNullability = false // allows null assignment to optional JSON fields
148
- }
149
+ // Enable coercion for input schemas (e.g. strings → numbers, dates)
150
+ useCoerce = true
151
+
152
+ // Custom imports for generated schemas
153
+ imports = null // default: no additional imports
154
+
155
+ // JSON field nullability behavior
156
+ // See: https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values
157
+ prismaJsonNullability = true // default: follow Prisma's JSON nullability rules
158
+ // prismaJsonNullability = false // allow null assignment to optional JSON fields
159
+ }
149
160
  ```
150
161
 
151
162
  3. Run `npx prisma generate` or `pnpm prisma generate` to generate your zod schemas
package/dist/index.js CHANGED
@@ -213047,7 +213047,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
213047
213047
  });
213048
213048
 
213049
213049
  // package.json
213050
- var version = "0.6.2";
213050
+ var version = "0.6.4";
213051
213051
 
213052
213052
  // src/index.ts
213053
213053
  var import_generator_helper = require("@prisma/generator-helper");
@@ -213063,6 +213063,7 @@ var configSchema = import_zod.z.object({
213063
213063
  modelSuffix: import_zod.z.string().default("Model"),
213064
213064
  modelCase: import_zod.z.enum(["PascalCase", "camelCase"]).default("PascalCase"),
213065
213065
  useDecimalJs: configBoolean,
213066
+ useCoerce: configBoolean.default(false),
213066
213067
  imports: import_zod.z.string().optional(),
213067
213068
  prismaJsonNullability: configBoolean
213068
213069
  });
@@ -213132,25 +213133,26 @@ var computeModifiers = (docString) => {
213132
213133
  };
213133
213134
 
213134
213135
  // src/types.ts
213135
- var getZodConstructor = (field, getRelatedModelName = (name) => name.toString(), nativeType) => {
213136
+ var getZodConstructor = (field, getRelatedModelName = (name) => name.toString(), nativeType, useCoerce) => {
213136
213137
  var _a, _b, _c, _d;
213137
213138
  let zodType = "z.unknown()";
213138
- let extraModifiers = [""];
213139
+ const zodVar = useCoerce ? "z.coerce" : "z";
213140
+ const extraModifiers = [""];
213139
213141
  if (field.kind === "scalar") {
213140
213142
  switch (field.type) {
213141
213143
  case "String":
213142
- zodType = "z.string()";
213144
+ zodType = zodVar + ".string()";
213143
213145
  if (nativeType == null ? void 0 : nativeType.match(/^Uuid/)) zodType = "z.uuid()";
213144
- else if (nativeType == null ? void 0 : nativeType.match(/^Citext/)) zodType = "z.string().toLowerCase()";
213146
+ else if (nativeType == null ? void 0 : nativeType.match(/^Citext/)) zodType = zodVar + ".string().toLowerCase()";
213145
213147
  else if (nativeType == null ? void 0 : nativeType.match(/^VarChar\(\d+\)/)) {
213146
213148
  const length = (_a = nativeType.match(/VarChar\((\d+)\)/)) == null ? void 0 : _a[1];
213147
213149
  if (length) extraModifiers.push(`max(${length})`);
213148
213150
  } else if (nativeType == null ? void 0 : nativeType.match(/^Char\(\d+\)/)) {
213149
213151
  const length = (_b = nativeType.match(/Char\((\d+)\)/)) == null ? void 0 : _b[1];
213150
213152
  if (length) extraModifiers.push(`max(${length})`);
213151
- } else if (nativeType == null ? void 0 : nativeType.match(/^Text/)) zodType = "z.string()";
213152
- else if (nativeType == null ? void 0 : nativeType.match(/^VarBit/)) zodType = "z.string()";
213153
- else if (nativeType == null ? void 0 : nativeType.match(/^Bit/)) zodType = "z.string()";
213153
+ } else if (nativeType == null ? void 0 : nativeType.match(/^Text/)) zodType = zodVar + ".string()";
213154
+ else if (nativeType == null ? void 0 : nativeType.match(/^VarBit/)) zodType = zodVar + ".string()";
213155
+ else if (nativeType == null ? void 0 : nativeType.match(/^Bit/)) zodType = zodVar + ".string()";
213154
213156
  else if (nativeType == null ? void 0 : nativeType.match(/^VarBinary/)) zodType = "z.unknown()";
213155
213157
  else if (nativeType == null ? void 0 : nativeType.match(/^Binary/)) zodType = "z.unknown()";
213156
213158
  else if (nativeType == null ? void 0 : nativeType.match(/^NVarChar\(\d+\)/)) {
@@ -213159,11 +213161,11 @@ var getZodConstructor = (field, getRelatedModelName = (name) => name.toString(),
213159
213161
  } else if (nativeType == null ? void 0 : nativeType.match(/^NChar\(\d+\)/)) {
213160
213162
  const length = (_d = nativeType.match(/NChar\((\d+)\)/)) == null ? void 0 : _d[1];
213161
213163
  if (length) extraModifiers.push(`max(${length})`);
213162
- } else if (nativeType == null ? void 0 : nativeType.match(/^NText/)) zodType = "z.string()";
213164
+ } else if (nativeType == null ? void 0 : nativeType.match(/^NText/)) zodType = zodVar + ".string()";
213163
213165
  else if (nativeType == null ? void 0 : nativeType.match(/^ObjectId/)) extraModifiers.push("regex(/^[0-9a-f]{24}$/i)");
213164
213166
  break;
213165
213167
  case "Int":
213166
- zodType = "z.number()";
213168
+ zodType = zodVar + ".number()";
213167
213169
  extraModifiers.push("int()");
213168
213170
  if (nativeType == null ? void 0 : nativeType.match(/^SmallInt/)) extraModifiers.push("min(-32768)", "max(32767)");
213169
213171
  else if (nativeType == null ? void 0 : nativeType.match(/^UnsignedInt/)) extraModifiers.push("min(0)");
@@ -213172,40 +213174,47 @@ var getZodConstructor = (field, getRelatedModelName = (name) => name.toString(),
213172
213174
  else if (nativeType == null ? void 0 : nativeType.match(/^TinyInt/)) extraModifiers.push("min(-128)", "max(127)");
213173
213175
  break;
213174
213176
  case "BigInt":
213175
- zodType = "z.bigint()";
213177
+ zodType = zodVar + ".bigint()";
213176
213178
  break;
213177
213179
  case "Float":
213178
- zodType = "z.coerce.number()";
213180
+ zodType = zodVar + ".number()";
213179
213181
  break;
213180
213182
  case "Decimal":
213181
- zodType = "z.coerce.number()";
213183
+ zodType = zodVar + ".number()";
213182
213184
  if (nativeType == null ? void 0 : nativeType.match(/^Numeric\(\d+,\d+\)/)) {
213183
213185
  const match = nativeType.match(/Numeric\((\d+),(\d+)\)/);
213184
213186
  if (match) {
213185
213187
  const [, precision, scale] = match;
213186
- extraModifiers.push(`refine(x => /^\\d{1,${Number(precision) - parseInt(scale)}}(\\.\\d{1,${scale}})?$/.test(x.toString()))`);
213188
+ extraModifiers.push(
213189
+ `refine(x => /^\\d{1,${Number(precision) - parseInt(scale)}}(\\.\\d{1,${scale}})?$/.test(x.toString()))`
213190
+ );
213187
213191
  }
213188
213192
  } else if (nativeType == null ? void 0 : nativeType.match(/^Decimal\(\d+,\d+\)/)) {
213189
213193
  const match = nativeType.match(/Decimal\((\d+),(\d+)\)/);
213190
213194
  if (match) {
213191
213195
  const [, precision, scale] = match;
213192
- extraModifiers.push(`refine(x => /^\\d{1,${Number(precision) - parseInt(scale)}}(\\.\\d{1,${scale}})?$/.test(x.toString()))`);
213196
+ extraModifiers.push(
213197
+ `refine(x => /^\\d{1,${Number(precision) - parseInt(scale)}}(\\.\\d{1,${scale}})?$/.test(x.toString()))`
213198
+ );
213193
213199
  }
213194
213200
  }
213195
213201
  break;
213196
213202
  case "DateTime":
213197
- zodType = "z.date()";
213198
- if (nativeType == null ? void 0 : nativeType.match(/^TimestampTz/)) zodType = "z.date()";
213199
- else if (nativeType == null ? void 0 : nativeType.match(/^Timestamp/)) zodType = "z.date()";
213200
- else if (nativeType == null ? void 0 : nativeType.match(/^TimeTz/)) zodType = "z.string().regex(/^\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$/)";
213201
- else if (nativeType == null ? void 0 : nativeType.match(/^Time/)) zodType = "z.string().regex(/^\\d{2}:\\d{2}:\\d{2}$/)";
213202
- else if (nativeType == null ? void 0 : nativeType.match(/^Date/)) zodType = "z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/)";
213203
- else if (nativeType == null ? void 0 : nativeType.match(/^DateTime/)) zodType = "z.date()";
213204
- else if (nativeType == null ? void 0 : nativeType.match(/^DateTimeOffset/)) zodType = "z.date()";
213205
- else if (nativeType == null ? void 0 : nativeType.match(/^DateTime2/)) zodType = "z.date()";
213203
+ zodType = zodVar + ".date()";
213204
+ if (nativeType == null ? void 0 : nativeType.match(/^TimestampTz/)) zodType = zodVar + ".date()";
213205
+ else if (nativeType == null ? void 0 : nativeType.match(/^Timestamp/)) zodType = zodVar + ".date()";
213206
+ else if (nativeType == null ? void 0 : nativeType.match(/^TimeTz/))
213207
+ zodType = zodVar + ".string().regex(/^\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$/)";
213208
+ else if (nativeType == null ? void 0 : nativeType.match(/^Time/))
213209
+ zodType = zodVar + ".string().regex(/^\\d{2}:\\d{2}:\\d{2}$/)";
213210
+ else if (nativeType == null ? void 0 : nativeType.match(/^Date/))
213211
+ zodType = zodVar + ".string().regex(/^\\d{4}-\\d{2}-\\d{2}$/)";
213212
+ else if (nativeType == null ? void 0 : nativeType.match(/^DateTime/)) zodType = zodVar + ".date()";
213213
+ else if (nativeType == null ? void 0 : nativeType.match(/^DateTimeOffset/)) zodType = zodVar + ".date()";
213214
+ else if (nativeType == null ? void 0 : nativeType.match(/^DateTime2/)) zodType = zodVar + ".date()";
213206
213215
  break;
213207
213216
  case "Boolean":
213208
- zodType = "z.boolean()";
213217
+ zodType = zodVar + ".boolean()";
213209
213218
  break;
213210
213219
  case "Bytes":
213211
213220
  zodType = "z.instanceof(Buffer)";
@@ -213233,7 +213242,7 @@ var getZodConstructor = (field, getRelatedModelName = (name) => name.toString(),
213233
213242
  extraModifiers.push(...computeModifiers(field.documentation));
213234
213243
  }
213235
213244
  if (!field.isRequired && field.type !== "Json") extraModifiers.push("nullish()");
213236
- const validModifiers = extraModifiers.filter((m) => m !== "");
213245
+ const validModifiers = extraModifiers.filter((m) => m !== "").filter((m, i, l) => l.indexOf(m) === i);
213237
213246
  return validModifiers.length > 0 ? `${zodType}.${validModifiers.join(".")}` : zodType;
213238
213247
  };
213239
213248
 
@@ -213242,60 +213251,41 @@ var parseNativeTypes = (schemaPath) => {
213242
213251
  var _a;
213243
213252
  let schemaContent = "";
213244
213253
  let resolvedPath = schemaPath;
213245
- try {
213246
- if (!(0, import_fs.existsSync)(resolvedPath)) {
213247
- const withFile = import_path.default.join(schemaPath, "schema.prisma");
213248
- const parentDir = import_path.default.dirname(schemaPath);
213249
- if ((0, import_fs.existsSync)(withFile)) {
213250
- resolvedPath = withFile;
213251
- } else if ((0, import_fs.existsSync)(parentDir)) {
213252
- resolvedPath = parentDir;
213253
- } else {
213254
- console.warn(`Schema path not found: ${schemaPath}`);
213255
- return /* @__PURE__ */ new Map();
213256
- }
213257
- }
213258
- const stat = (0, import_fs.statSync)(resolvedPath);
213259
- if (stat.isFile()) {
213260
- schemaContent = (0, import_fs.readFileSync)(resolvedPath, "utf-8");
213261
- } else if (stat.isDirectory()) {
213262
- const prismaFiles = findPrismaFiles(resolvedPath);
213263
- if (prismaFiles.length === 0) {
213264
- console.warn(`No .prisma files found in ${resolvedPath}`);
213265
- return /* @__PURE__ */ new Map();
213266
- }
213267
- prismaFiles.forEach((filePath) => {
213268
- schemaContent += (0, import_fs.readFileSync)(filePath, "utf-8") + "\n";
213269
- });
213270
- }
213271
- } catch (error) {
213272
- console.error(`Error reading schema path: ${schemaPath}`, error);
213273
- return /* @__PURE__ */ new Map();
213254
+ if (!(0, import_fs.existsSync)(resolvedPath)) {
213255
+ const withFile = import_path.default.join(schemaPath, "schema.prisma");
213256
+ const parentDir = import_path.default.dirname(schemaPath);
213257
+ if ((0, import_fs.existsSync)(withFile)) resolvedPath = withFile;
213258
+ else if ((0, import_fs.existsSync)(parentDir)) resolvedPath = parentDir;
213259
+ else return /* @__PURE__ */ new Map();
213274
213260
  }
213275
- if (!schemaContent) {
213276
- console.warn(`No schema content found at ${schemaPath}`);
213277
- return /* @__PURE__ */ new Map();
213261
+ const stat = (0, import_fs.statSync)(resolvedPath);
213262
+ if (stat.isFile()) schemaContent = (0, import_fs.readFileSync)(resolvedPath, "utf-8");
213263
+ else if (stat.isDirectory()) {
213264
+ const prismaFiles = findPrismaFiles(resolvedPath);
213265
+ if (prismaFiles.length === 0) return /* @__PURE__ */ new Map();
213266
+ prismaFiles.forEach((filePath) => {
213267
+ schemaContent += (0, import_fs.readFileSync)(filePath, "utf-8") + "\n";
213268
+ });
213278
213269
  }
213279
213270
  const nativeTypes = /* @__PURE__ */ new Map();
213280
- const modelRegex = /model\s+(\w+)\s*\{([^}]+)\}/g;
213281
- const fieldRegex = /(\w+)\s+(\w+(?:\[\])?)\s+([^;\n]+)/g;
213271
+ const modelRegex = /model\s+(\w+)\s*\{([\s\S]*?)\}/g;
213282
213272
  let modelMatch;
213283
213273
  while ((modelMatch = modelRegex.exec(schemaContent)) !== null) {
213284
213274
  const modelName = modelMatch[1];
213285
213275
  const modelBody = modelMatch[2];
213286
213276
  const fields = /* @__PURE__ */ new Map();
213287
- let fieldMatch;
213288
- while ((fieldMatch = fieldRegex.exec(modelBody)) !== null) {
213289
- const fieldName = fieldMatch[1];
213290
- const fieldLine = fieldMatch[0];
213291
- const dbMatch = (_a = fieldLine.match(/@db\.(\w+(?:\([^)]*\))?)/)) == null ? void 0 : _a[1];
213292
- if (dbMatch) {
213293
- fields.set(fieldName, dbMatch);
213294
- }
213295
- }
213296
- if (fields.size > 0) {
213297
- nativeTypes.set(modelName, fields);
213277
+ const lines = modelBody.split("\n");
213278
+ for (const line of lines) {
213279
+ const trimmed = line.trim();
213280
+ if (!trimmed || trimmed.startsWith("//")) continue;
213281
+ const parts = trimmed.split(/\s+/);
213282
+ if (parts.length < 2) continue;
213283
+ const fieldName = parts[0];
213284
+ const attributes = parts.slice(2).join(" ");
213285
+ const dbMatch = (_a = attributes.match(/@db\.([A-Za-z0-9_()]+)/)) == null ? void 0 : _a[1];
213286
+ if (dbMatch) fields.set(fieldName, dbMatch);
213298
213287
  }
213288
+ if (fields.size > 0) nativeTypes.set(modelName, fields);
213299
213289
  }
213300
213290
  return nativeTypes;
213301
213291
  };
@@ -213335,9 +213325,7 @@ var writeImportsForModel = (model, sourceFile, config, { schemaPath, outputPath,
213335
213325
  importList.push({
213336
213326
  kind: import_ts_morph.StructureKind.ImportDeclaration,
213337
213327
  namespaceImport: "imports",
213338
- moduleSpecifier: dotSlash(
213339
- import_path.default.relative(outputPath, import_path.default.resolve(baseDir, config.imports))
213340
- )
213328
+ moduleSpecifier: dotSlash(import_path.default.relative(outputPath, import_path.default.resolve(baseDir, config.imports)))
213341
213329
  });
213342
213330
  }
213343
213331
  const hasNonCustomDecimalFieldForImports = model.fields.some(
@@ -213368,12 +213356,7 @@ var writeImportsForModel = (model, sourceFile, config, { schemaPath, outputPath,
213368
213356
  kind: import_ts_morph.StructureKind.ImportDeclaration,
213369
213357
  moduleSpecifier: "./index",
213370
213358
  namedImports: Array.from(
213371
- new Set(
213372
- filteredFields.flatMap((f) => [
213373
- `Complete${f.type}`,
213374
- relatedModelName(f.type)
213375
- ])
213376
- )
213359
+ new Set(filteredFields.flatMap((f) => [`Complete${f.type}`, relatedModelName(f.type)]))
213377
213360
  )
213378
213361
  });
213379
213362
  }
@@ -213383,12 +213366,13 @@ var writeImportsForModel = (model, sourceFile, config, { schemaPath, outputPath,
213383
213366
  var writeTypeSpecificSchemas = (model, sourceFile, config, _prismaOptions) => {
213384
213367
  if (model.fields.some((f) => f.type === "Json")) {
213385
213368
  sourceFile.addStatements((writer) => {
213386
- writer.newLine();
213387
213369
  writeArray(writer, [
213370
+ "",
213388
213371
  "// Helper schema for JSON fields",
213389
- `type Literal = boolean | number | string${config.prismaJsonNullability ? "" : "| null"}`,
213372
+ `type Literal = boolean | number | string${config.prismaJsonNullability ? "" : " | null"}`,
213390
213373
  "type Json = Literal | { [key: string]: Json } | Json[]",
213391
213374
  `const literalSchema = z.union([z.string(), z.number(), z.boolean()${config.prismaJsonNullability ? "" : ", z.null()"}])`,
213375
+ // Keep jsonSchema initializer fully on one line
213392
213376
  "const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(z.string(), jsonSchema)]))"
213393
213377
  ]);
213394
213378
  });
@@ -213401,8 +213385,7 @@ var writeTypeSpecificSchemas = (model, sourceFile, config, _prismaOptions) => {
213401
213385
  writer.newLine();
213402
213386
  writeArray(writer, [
213403
213387
  "// Helper schema for Decimal fields",
213404
- "z",
213405
- ".instanceof(Decimal)",
213388
+ "z.instanceof(Decimal)",
213406
213389
  ".or(z.string())",
213407
213390
  ".or(z.number())",
213408
213391
  ".refine((value) => {",
@@ -213437,7 +213420,8 @@ var generateSchemaForModel = (model, sourceFile, config, { schemaPath }) => {
213437
213420
  `${field.name}: ${getZodConstructor(
213438
213421
  field,
213439
213422
  void 0,
213440
- nativeType
213423
+ nativeType,
213424
+ config.useCoerce
213441
213425
  )}`
213442
213426
  ).write(",").newLine();
213443
213427
  });
@@ -213480,17 +213464,21 @@ var generateRelatedSchemaForModel = (model, sourceFile, config, _prismaOptions)
213480
213464
  name: relatedModelName(model.name),
213481
213465
  type: `z.ZodSchema<Complete${model.name}>`,
213482
213466
  initializer(writer) {
213483
- writer.write(`z.lazy(() => ${modelName(model.name)}.extend(`).inlineBlock(() => {
213484
- relationFields.forEach((field) => {
213485
- writeArray(writer, getJSDocs(field.documentation));
213486
- writer.write(
213487
- `${field.name}: ${getZodConstructor(
213488
- field,
213489
- relatedModelName
213490
- )}`
213491
- ).write(",").newLine();
213492
- });
213493
- }).write("))");
213467
+ writer.write("z.lazy(() =>").newLine().indent(() => {
213468
+ writer.write(`${modelName(model.name)}.extend({`).newLine().indent(() => {
213469
+ relationFields.forEach((field) => {
213470
+ writeArray(writer, getJSDocs(field.documentation));
213471
+ writer.write(
213472
+ `${field.name}: ${getZodConstructor(
213473
+ field,
213474
+ relatedModelName,
213475
+ null,
213476
+ config.useCoerce
213477
+ )},`
213478
+ ).newLine();
213479
+ });
213480
+ }).write("})");
213481
+ }).newLine().write(")");
213494
213482
  }
213495
213483
  }
213496
213484
  ]
@@ -213522,7 +213510,11 @@ var import_ts_morph2 = require("ts-morph");
213522
213510
  };
213523
213511
  },
213524
213512
  onGenerate(options) {
213525
- const project = new import_ts_morph2.Project();
213513
+ const project = new import_ts_morph2.Project({
213514
+ manipulationSettings: {
213515
+ quoteKind: import_ts_morph2.QuoteKind.Single
213516
+ }
213517
+ });
213526
213518
  const models = [...options.dmmf.datamodel.models];
213527
213519
  const schemaPath = options.schemaPath;
213528
213520
  const schemaDir = import_path2.default.dirname(schemaPath);
@@ -213542,11 +213534,7 @@ var import_ts_morph2 = require("ts-morph");
213542
213534
  schemaPath: schemaDir
213543
213535
  // Pass the directory, not the file
213544
213536
  };
213545
- const indexFile = project.createSourceFile(
213546
- `${outputPath}/index.ts`,
213547
- {},
213548
- { overwrite: true }
213549
- );
213537
+ const indexFile = project.createSourceFile(`${outputPath}/index.ts`, {}, { overwrite: true });
213550
213538
  generateBarrelFile(models, indexFile);
213551
213539
  indexFile.formatText({
213552
213540
  indentSize: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-to-zod-v4",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "A Prisma generator that creates Zod schemas for all of your models",
5
5
  "license": "MIT",
6
6
  "author": "yassinrais",
@@ -37,7 +37,7 @@
37
37
  "printWidth": 100,
38
38
  "semi": false,
39
39
  "singleQuote": true,
40
- "tabWidth": 4,
40
+ "tabWidth": 2,
41
41
  "trailingComma": "es5",
42
42
  "useTabs": true
43
43
  },