31 lines
14 KiB
Diff
31 lines
14 KiB
Diff
|
diff --git a/dist/zod-prisma.cjs.development.js b/dist/zod-prisma.cjs.development.js
|
||
|
index fb04fd45d6e6d9407ed9ab0b13533b05f3ae4d08..ce51f3065af5dc3e13dcb796293d45cc03e21b7b 100644
|
||
|
--- a/dist/zod-prisma.cjs.development.js
|
||
|
+++ b/dist/zod-prisma.cjs.development.js
|
||
|
@@ -194,7 +194,7 @@ const writeImportsForModel = (model, sourceFile, config, {
|
||
|
if (filteredFields.length > 0) {
|
||
|
importList.push({
|
||
|
kind: tsMorph.StructureKind.ImportDeclaration,
|
||
|
- moduleSpecifier: './index',
|
||
|
+ moduleSpecifier: './index.js',
|
||
|
namedImports: Array.from(new Set(filteredFields.flatMap(f => [`Complete${f.type}`, relatedModelName(f.type)])))
|
||
|
});
|
||
|
}
|
||
|
@@ -284,7 +284,7 @@ const populateModelFile = (model, sourceFile, config, prismaOptions) => {
|
||
|
};
|
||
|
const generateBarrelFile = (models, indexFile) => {
|
||
|
models.forEach(model => indexFile.addExportDeclaration({
|
||
|
- moduleSpecifier: `./${model.name.toLowerCase()}`
|
||
|
+ moduleSpecifier: `./${model.name.toLowerCase()}.js`
|
||
|
}));
|
||
|
};
|
||
|
|
||
|
diff --git a/dist/zod-prisma.cjs.production.min.js b/dist/zod-prisma.cjs.production.min.js
|
||
|
index 9720e85802156e5765b0cc277a5c3dbed9b5a2e8..a4df60874a24897582785ebd61bc86f29f89b7b4 100644
|
||
|
--- a/dist/zod-prisma.cjs.production.min.js
|
||
|
+++ b/dist/zod-prisma.cjs.production.min.js
|
||
|
@@ -1,2 +1,2 @@
|
||
|
-"use strict";var e=require("@prisma/generator-helper"),t=require("typescript"),a=require("zod"),r=require("path"),i=require("ts-morph"),n=require("parenthesis");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(r);const s=a.z.enum(["true","false"]).transform((e=>JSON.parse(e))),c=a.z.object({relationModel:s.default("true").or(a.z.literal("default")),modelSuffix:a.z.string().default("Model"),modelCase:a.z.enum(["PascalCase","camelCase"]).default("PascalCase"),useDecimalJs:s.default("false"),imports:a.z.string().optional(),prismaJsonNullability:s.default("true")}),d=(e,t,a=!0)=>t.forEach((t=>e.write(t).conditionalNewLine(a))),m=({modelCase:e,modelSuffix:t,relationModel:a})=>{const r=(a,r="")=>("camelCase"===e&&(a=a.slice(0,1).toLowerCase()+a.slice(1)),`${r}${a}${t}`);return{modelName:e=>r(e,"default"===a?"_":""),relatedModelName:e=>r("default"===a?e.toString():`Related${e.toString()}`)}},u=e=>{const t=e.replace(/^\\\\\?\\/,"").replace(/\\/g,"/").replace(/\/\/+/g,"/");return t.includes("/node_modules/")?t.split("/node_modules/").slice(-1)[0]:t.startsWith("../")?t:"./"+t},p=e=>{const t=[];if(e){const a=e.split("\n").filter((e=>!e.trimStart().startsWith("@zod")));a.length&&(t.push("/**"),a.forEach((e=>t.push(` * ${e}`))),t.push(" */"))}return t},f=e=>e.split("\n").filter((e=>e.trimStart().startsWith("@zod"))).map((e=>e.trimStart().slice(4))).flatMap((e=>{return(t=n.parse(e),t.reduce(((e,t,a)=>a%2==0?[...e,[t]]:[...e.slice(0,-1),[...e.slice(-1)[0],t]]),[])).slice(0,-1).map((([e,t])=>e.replace(/\)?\./,"")+`${n.stringify(t)})`));var t})),h=(e,t=(e=>e.toString()))=>{let a="z.unknown()",r=[""];if("scalar"===e.kind)switch(e.type){case"String":a="z.string()";break;case"Int":a="z.number()",r.push("int()");break;case"BigInt":a="z.bigint()";break;case"DateTime":a="z.date()";break;case"Float":case"Decimal":a="z.number()";break;case"Json":a="jsonSchema";break;case"Boolean":a="z.boolean()";break;case"Bytes":a="z.unknown()"}else"enum"===e.kind?a=`z.nativeEnum(${e.type})`:"object"===e.kind&&(a=t(e.type));var i,n,o;return e.isList&&r.push("array()"),e.documentation&&(a=null!=(i=null==(n=f(e.documentation).find((e=>e.startsWith("custom("))))?void 0:n.slice(7).slice(0,-1))?i:a,r.push(...(o=e.documentation,f(o).filter((e=>!e.startsWith("custom(")))))),e.isRequired||"Json"===e.type||r.push("nullish()"),`${a}${r.join(".")}`};e.generatorHandler({onManifest:()=>({version:"0.5.4",prettyName:"Zod Schemas",defaultOutput:"zod"}),onGenerate(e){const a=new i.Project,r=e.dmmf.datamodel.models,{schemaPath:n}=e,o=e.generator.output.value,s=e.otherGenerators.find((e=>"prisma-client-js"===e.provider.value)).output.value,f=c.safeParse(e.generator.config);if(!f.success)throw new Error("Incorrect config provided. Please check the values you provided and try again.");const z=f.data,S={clientPath:s,outputPath:o,schemaPath:n},y=a.createSourceFile(`${o}/index.ts`,{},{overwrite:!0});return((e,t)=>{e.forEach((e=>t.addExportDeclaration({moduleSpecifier:`./${e.name.toLowerCase()}`})))})(r,y),y.formatText({indentSize:2,convertTabsToSpaces:!0,semicolons:t.SemicolonPreference.Remove}),r.forEach((e=>{const r=a.createSourceFile(`${o}/${e.name.toLowerCase()}.ts`,{},{overwrite:!0});((e,t,a,r)=>{((e,t,a,{schemaPath:r,outputPath:n,clientPath:o})=>{const{relatedModelName:s}=m(a),c=[{kind:i.StructureKind.ImportDeclaration,namespaceImport:"z",moduleSpecifier:"zod"}];a.imports&&c.push({kind:i.StructureKind.ImportDeclaration,namespaceImport:"imports",moduleSpecifier:u(l.default.relative(n,l.default.resolve(l.default.dirname(r),a.imports)))}),a.useDecimalJs&&e.fields.some((e=>"Decimal"===e.type))&&c.push({kind:i.StructureKind.ImportDeclaration,namedImports:["Decimal"],moduleSpecifier:"decimal.js"});const d=e.fields.filter((e=>"enum"===e.kind)),p=e.fields.filter((e=>"object"===e.kind)),f=l.default.relative(n,o);if(d.length>0&&c.push({kind:i.StructureKind.ImportDeclaration,isTypeOnly:0===d.length,moduleSpecifier:u(f),namedImports:d.map((e=>e.type))}),!1!==a.relationModel&&p.length>0){const t=p.filter((t=>t.type!==e.name));t.length>0&&c.push({kind:i.Struct
|
||
|
+"use strict";var e=require("@prisma/generator-helper"),t=require("typescript"),a=require("zod"),r=require("path"),i=require("ts-morph"),n=require("parenthesis");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(r);const s=a.z.enum(["true","false"]).transform((e=>JSON.parse(e))),c=a.z.object({relationModel:s.default("true").or(a.z.literal("default")),modelSuffix:a.z.string().default("Model"),modelCase:a.z.enum(["PascalCase","camelCase"]).default("PascalCase"),useDecimalJs:s.default("false"),imports:a.z.string().optional(),prismaJsonNullability:s.default("true")}),d=(e,t,a=!0)=>t.forEach((t=>e.write(t).conditionalNewLine(a))),m=({modelCase:e,modelSuffix:t,relationModel:a})=>{const r=(a,r="")=>("camelCase"===e&&(a=a.slice(0,1).toLowerCase()+a.slice(1)),`${r}${a}${t}`);return{modelName:e=>r(e,"default"===a?"_":""),relatedModelName:e=>r("default"===a?e.toString():`Related${e.toString()}`)}},u=e=>{const t=e.replace(/^\\\\\?\\/,"").replace(/\\/g,"/").replace(/\/\/+/g,"/");return t.includes("/node_modules/")?t.split("/node_modules/").slice(-1)[0]:t.startsWith("../")?t:"./"+t},p=e=>{const t=[];if(e){const a=e.split("\n").filter((e=>!e.trimStart().startsWith("@zod")));a.length&&(t.push("/**"),a.forEach((e=>t.push(` * ${e}`))),t.push(" */"))}return t},f=e=>e.split("\n").filter((e=>e.trimStart().startsWith("@zod"))).map((e=>e.trimStart().slice(4))).flatMap((e=>{return(t=n.parse(e),t.reduce(((e,t,a)=>a%2==0?[...e,[t]]:[...e.slice(0,-1),[...e.slice(-1)[0],t]]),[])).slice(0,-1).map((([e,t])=>e.replace(/\)?\./,"")+`${n.stringify(t)})`));var t})),h=(e,t=(e=>e.toString()))=>{let a="z.unknown()",r=[""];if("scalar"===e.kind)switch(e.type){case"String":a="z.string()";break;case"Int":a="z.number()",r.push("int()");break;case"BigInt":a="z.bigint()";break;case"DateTime":a="z.date()";break;case"Float":case"Decimal":a="z.number()";break;case"Json":a="jsonSchema";break;case"Boolean":a="z.boolean()";break;case"Bytes":a="z.unknown()"}else"enum"===e.kind?a=`z.nativeEnum(${e.type})`:"object"===e.kind&&(a=t(e.type));var i,n,o;return e.isList&&r.push("array()"),e.documentation&&(a=null!=(i=null==(n=f(e.documentation).find((e=>e.startsWith("custom("))))?void 0:n.slice(7).slice(0,-1))?i:a,r.push(...(o=e.documentation,f(o).filter((e=>!e.startsWith("custom(")))))),e.isRequired||"Json"===e.type||r.push("nullish()"),`${a}${r.join(".")}`};e.generatorHandler({onManifest:()=>({version:"0.5.4",prettyName:"Zod Schemas",defaultOutput:"zod"}),onGenerate(e){const a=new i.Project,r=e.dmmf.datamodel.models,{schemaPath:n}=e,o=e.generator.output.value,s=e.otherGenerators.find((e=>"prisma-client-js"===e.provider.value)).output.value,f=c.safeParse(e.generator.config);if(!f.success)throw new Error("Incorrect config provided. Please check the values you provided and try again.");const z=f.data,S={clientPath:s,outputPath:o,schemaPath:n},y=a.createSourceFile(`${o}/index.ts`,{},{overwrite:!0});return((e,t)=>{e.forEach((e=>t.addExportDeclaration({moduleSpecifier:`./${e.name.toLowerCase()}.js`})))})(r,y),y.formatText({indentSize:2,convertTabsToSpaces:!0,semicolons:t.SemicolonPreference.Remove}),r.forEach((e=>{const r=a.createSourceFile(`${o}/${e.name.toLowerCase()}.ts`,{},{overwrite:!0});((e,t,a,r)=>{((e,t,a,{schemaPath:r,outputPath:n,clientPath:o})=>{const{relatedModelName:s}=m(a),c=[{kind:i.StructureKind.ImportDeclaration,namespaceImport:"z",moduleSpecifier:"zod"}];a.imports&&c.push({kind:i.StructureKind.ImportDeclaration,namespaceImport:"imports",moduleSpecifier:u(l.default.relative(n,l.default.resolve(l.default.dirname(r),a.imports)))}),a.useDecimalJs&&e.fields.some((e=>"Decimal"===e.type))&&c.push({kind:i.StructureKind.ImportDeclaration,namedImports:["Decimal"],moduleSpecifier:"decimal.js"});const d=e.fields.filter((e=>"enum"===e.kind)),p=e.fields.filter((e=>"object"===e.kind)),f=l.default.relative(n,o);if(d.length>0&&c.push({kind:i.StructureKind.ImportDeclaration,isTypeOnly:0===d.length,moduleSpecifier:u(f),namedImports:d.map((e=>e.type))}),!1!==a.relationModel&&p.length>0){const t=p.filter((t=>t.type!==e.name));t.length>0&&c.push({kind:i.Str
|
||
|
//# sourceMappingURL=zod-prisma.cjs.production.min.js.map
|