prisma-to-zod-v4 0.5.6 → 0.5.7
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.js +5 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -413677,7 +413677,7 @@ var require_parenthesis = __commonJS((exports2, module2) => {
|
|
|
413677
413677
|
module2.exports = parenthesis;
|
|
413678
413678
|
});
|
|
413679
413679
|
// package.json
|
|
413680
|
-
var version = "0.5.
|
|
413680
|
+
var version = "0.5.7";
|
|
413681
413681
|
|
|
413682
413682
|
// src/index.ts
|
|
413683
413683
|
var import_generator_helper = __toESM(require_dist2(), 1);
|
|
@@ -427329,7 +427329,8 @@ var getZodConstructor = (field, getRelatedModelName = (name) => name.toString(),
|
|
|
427329
427329
|
|
|
427330
427330
|
// src/generator.ts
|
|
427331
427331
|
var parseNativeTypes = (schemaPath) => {
|
|
427332
|
-
const
|
|
427332
|
+
const fullSchemaPath = schemaPath.endsWith("schema.prisma") ? schemaPath : import_path.default.join(schemaPath, "schema.prisma");
|
|
427333
|
+
const schemaContent = import_fs.readFileSync(fullSchemaPath, "utf-8");
|
|
427333
427334
|
const nativeTypes = new Map;
|
|
427334
427335
|
const modelRegex = /model\s+(\w+)\s*\{([^}]+)\}/g;
|
|
427335
427336
|
const fieldRegex = /(\w+)\s+(\w+(?:\[\])?)\s+([^;\n]+)/g;
|
|
@@ -427437,7 +427438,8 @@ var writeTypeSpecificSchemas = (model, sourceFile, config2, _prismaOptions) => {
|
|
|
427437
427438
|
};
|
|
427438
427439
|
var generateSchemaForModel = (model, sourceFile, config2, { schemaPath }) => {
|
|
427439
427440
|
const { modelName } = useModelNames(config2);
|
|
427440
|
-
const
|
|
427441
|
+
const actualSchemaPath = schemaPath.includes("schema.prisma") ? schemaPath : import_path.default.join(schemaPath, "schema.prisma");
|
|
427442
|
+
const nativeTypes = parseNativeTypes(actualSchemaPath);
|
|
427441
427443
|
const modelNativeTypes = nativeTypes.get(model.name) || new Map;
|
|
427442
427444
|
sourceFile.addVariableStatement({
|
|
427443
427445
|
declarationKind: import_ts_morph.VariableDeclarationKind.Const,
|