UNPKG

prisma-erd-generator

Version:

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> [![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#contributors-) <!-- ALL-CONTRIBUTORS-BADGE:END -->

46 lines (41 loc) 34.9 kB
#!/usr/bin/env node "use strict";(()=>{var lr=Object.create;var pe=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,fr=Object.prototype.hasOwnProperty;var S=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var k=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var mr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of pr(r))!fr.call(e,n)&&n!==t&&pe(e,n,{get:()=>r[n],enumerable:!(o=ur(r,n))||o.enumerable});return e};var I=(e,r,t)=>(t=e!=null?lr(dr(e)):{},mr(r||!e||!e.__esModule?pe(t,"default",{value:e,enumerable:!0}):t,e));var J=k((qn,ve)=>{"use strict";var hr=Object.create,G=Object.defineProperty,gr=Object.getOwnPropertyDescriptor,vr=Object.getOwnPropertyNames,_r=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty,br=(e,r)=>{for(var t in r)G(e,t,{get:r[t],enumerable:!0})},de=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of vr(r))!yr.call(e,n)&&n!==t&&G(e,n,{get:()=>r[n],enumerable:!(o=gr(r,n))||o.enumerable});return e},fe=(e,r,t)=>(t=e!=null?hr(_r(e)):{},de(r||!e||!e.__esModule?G(t,"default",{value:e,enumerable:!0}):t,e)),wr=e=>de(G({},"__esModule",{value:!0}),e),me={};br(me,{LineStream:()=>L,byline:()=>Or,createLineStream:()=>ge,createStream:()=>he});ve.exports=wr(me);var W=fe(S("stream")),Er=fe(S("util"));function Or(e,r){return he(e,r)}function he(e,r){return e?ge(e,r):new L(r)}function ge(e,r){if(!e)throw new Error("expected readStream");if(!e.readable)throw new Error("readStream must be readable");let t=new L(r);return e.pipe(t),t}function L(e){W.default.Transform.call(this,e),e=e||{},this._readableState.objectMode=!0,this._lineBuffer=[],this._keepEmptyLines=e.keepEmptyLines||!1,this._lastChunkEndedWithCR=!1,this.on("pipe",function(r){this.encoding||r instanceof W.default.Readable&&(this.encoding=r._readableState.encoding)})}Er.default.inherits(L,W.default.Transform);L.prototype._transform=function(e,r,t){r=r||"utf8",Buffer.isBuffer(e)&&(r=="buffer"?(e=e.toString(),r="utf8"):e=e.toString(r)),this._chunkEncoding=r;let o=e.split(/\r\n|\r|\n/g);this._lastChunkEndedWithCR&&e[0]==` `&&o.shift(),this._lineBuffer.length>0&&(this._lineBuffer[this._lineBuffer.length-1]+=o[0],o.shift()),this._lastChunkEndedWithCR=e[e.length-1]=="\r",this._lineBuffer=this._lineBuffer.concat(o),this._pushBuffer(r,1,t)};L.prototype._pushBuffer=function(e,r,t){for(;this._lineBuffer.length>r;){let o=this._lineBuffer.shift();if((this._keepEmptyLines||o.length>0)&&!this.push(this._reencode(o,e))){let n=this;setImmediate(function(){n._pushBuffer(e,r,t)});return}}t()};L.prototype._flush=function(e){this._pushBuffer(this._chunkEncoding,0,e)};L.prototype._reencode=function(e,r){return this.encoding&&this.encoding!=r?Buffer.from(e,r).toString(this.encoding):this.encoding?e:Buffer.from(e,r)}});var z=k((Fn,ye)=>{"use strict";var H=Object.defineProperty,xr=Object.getOwnPropertyDescriptor,Sr=Object.getOwnPropertyNames,Pr=Object.prototype.hasOwnProperty,Nr=(e,r)=>{for(var t in r)H(e,t,{get:r[t],enumerable:!0})},Dr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Sr(r))!Pr.call(e,n)&&n!==t&&H(e,n,{get:()=>r[n],enumerable:!(o=xr(r,n))||o.enumerable});return e},jr=e=>Dr(H({},"__esModule",{value:!0}),e),_e={};Nr(_e,{isErrorResponse:()=>$r});ye.exports=jr(_e);function $r(e){return e.error!==void 0}});var Q=k((Bn,Oe)=>{"use strict";var X=Object.defineProperty,Cr=Object.getOwnPropertyDescriptor,Mr=Object.getOwnPropertyNames,Tr=Object.prototype.hasOwnProperty,kr=(e,r)=>{for(var t in r)X(e,t,{get:r[t],enumerable:!0})},Rr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Mr(r))!Tr.call(e,n)&&n!==t&&X(e,n,{get:()=>r[n],enumerable:!(o=Cr(r,n))||o.enumerable});return e},Lr=e=>Rr(X({},"__esModule",{value:!0}),e),be={};kr(be,{__commonJS:()=>Vr,__require:()=>Br,__toESM:()=>Jr});Oe.exports=Lr(be);var Ir=Object.create,we=Object.defineProperty,Ar=Object.getOwnPropertyDescriptor,Ee=Object.getOwnPropertyNames,qr=Object.getPrototypeOf,Fr=Object.prototype.hasOwnProperty,Br=(e=>typeof S<"u"?S:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof S<"u"?S:r)[t]}):e)(function(e){if(typeof S<"u")return S.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),Vr=(e,r)=>function(){return r||(0,e[Ee(e)[0]])((r={exports:{}}).exports,r),r.exports},Gr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Ee(r))!Fr.call(e,n)&&n!==t&&we(e,n,{get:()=>r[n],enumerable:!(o=Ar(r,n))||o.enumerable});return e},Jr=(e,r,t)=>(t=e!=null?Ir(qr(e)):{},Gr(r||!e||!e.__esModule?we(t,"default",{value:e,enumerable:!0}):t,e))});var Le=k((Gn,Re)=>{"use strict";var te=Object.defineProperty,Yr=Object.getOwnPropertyDescriptor,Kr=Object.getOwnPropertyNames,Ur=Object.prototype.hasOwnProperty,Pe=(e,r)=>{for(var t in r)te(e,t,{get:r[t],enumerable:!0})},Wr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Kr(r))!Ur.call(e,n)&&n!==t&&te(e,n,{get:()=>r[n],enumerable:!(o=Yr(r,n))||o.enumerable});return e},Hr=e=>Wr(te({},"__esModule",{value:!0}),e),Ne={};Pe(Ne,{Debug:()=>ke,clearLogs:()=>Pt,default:()=>Nt,getLogs:()=>St});Re.exports=Hr(Ne);var Z={};Pe(Z,{$:()=>Me,bgBlack:()=>ft,bgBlue:()=>vt,bgCyan:()=>yt,bgGreen:()=>ht,bgMagenta:()=>_t,bgRed:()=>mt,bgWhite:()=>bt,bgYellow:()=>gt,black:()=>nt,blue:()=>at,bold:()=>Te,cyan:()=>lt,dim:()=>Xr,gray:()=>pt,green:()=>st,grey:()=>dt,hidden:()=>rt,inverse:()=>et,italic:()=>Qr,magenta:()=>ct,red:()=>ot,reset:()=>zr,strikethrough:()=>tt,underline:()=>Zr,white:()=>ut,yellow:()=>it});var ee,De,je,$e,Ce=!0;typeof process<"u"&&({FORCE_COLOR:ee,NODE_DISABLE_COLORS:De,NO_COLOR:je,TERM:$e}=process.env||{},Ce=process.stdout&&process.stdout.isTTY);var Me={enabled:!De&&je==null&&$e!=="dumb"&&(ee!=null&&ee!=="0"||Ce)};function y(e,r){let t=new RegExp(`\\x1b\\[${r}m`,"g"),o=`\x1B[${e}m`,n=`\x1B[${r}m`;return function(s){return!Me.enabled||s==null?s:o+(~(""+s).indexOf(n)?s.replace(t,n+o):s)+n}}var zr=y(0,0),Te=y(1,22),Xr=y(2,22),Qr=y(3,23),Zr=y(4,24),et=y(7,27),rt=y(8,28),tt=y(9,29),nt=y(30,39),ot=y(31,39),st=y(32,39),it=y(33,39),at=y(34,39),ct=y(35,39),lt=y(36,39),ut=y(37,39),pt=y(90,39),dt=y(90,39),ft=y(40,49),mt=y(41,49),ht=y(42,49),gt=y(43,49),vt=y(44,49),_t=y(45,49),yt=y(46,49),bt=y(47,49),wt=100,xe=["green","yellow","blue","magenta","cyan","red"],A=[],Se=Date.now(),Et=0,re=typeof process<"u"?process.env:{};globalThis.DEBUG??=re.DEBUG??"";globalThis.DEBUG_COLORS??=re.DEBUG_COLORS?re.DEBUG_COLORS==="true":!0;var q={enable(e){typeof e=="string"&&(globalThis.DEBUG=e)},disable(){let e=globalThis.DEBUG;return globalThis.DEBUG="",e},enabled(e){let r=globalThis.DEBUG.split(",").map(n=>n.replace(/[.+?^${}()|[\]\\]/g,"\\$&")),t=r.some(n=>n===""||n[0]==="-"?!1:e.match(RegExp(n.split("*").join(".*")+"$"))),o=r.some(n=>n===""||n[0]!=="-"?!1:e.match(RegExp(n.slice(1).split("*").join(".*")+"$")));return t&&!o},log:(...e)=>{let[r,t,...o]=e;(console.warn??console.log)(`${r} ${t}`,...o)},formatters:{}};function Ot(e){let r={color:xe[Et++%xe.length],enabled:q.enabled(e),namespace:e,log:q.log,extend:()=>{}},t=(...o)=>{let{enabled:n,namespace:s,color:l,log:i}=r;if(o.length!==0&&A.push([s,...o]),A.length>wt&&A.shift(),q.enabled(s)||n){let c=o.map(a=>typeof a=="string"?a:xt(a)),p=`+${Date.now()-Se}ms`;Se=Date.now(),globalThis.DEBUG_COLORS?i(Z[l](Te(s)),...c,Z[l](p)):i(s,...c,p)}};return new Proxy(t,{get:(o,n)=>r[n],set:(o,n,s)=>r[n]=s})}var ke=new Proxy(Ot,{get:(e,r)=>q[r],set:(e,r,t)=>q[r]=t});function xt(e,r=2){let t=new Set;return JSON.stringify(e,(o,n)=>{if(typeof n=="object"&&n!==null){if(t.has(n))return"[Circular *]";t.add(n)}else if(typeof n=="bigint")return n.toString();return n},r)}function St(e=7500){let r=A.map(([t,...o])=>`${t} ${o.map(n=>typeof n=="string"?n:JSON.stringify(n)).join(" ")}`).join(` `);return r.length<e?r:r.slice(-e)}function Pt(){A.length=0}var Nt=ke});var Ge=k((go,Ve)=>{"use strict";var se=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,jt=Object.getOwnPropertyNames,$t=Object.prototype.hasOwnProperty,Ct=(e,r)=>{for(var t in r)se(e,t,{get:r[t],enumerable:!0})},Mt=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of jt(r))!$t.call(e,n)&&n!==t&&se(e,n,{get:()=>r[n],enumerable:!(o=Dt(r,n))||o.enumerable});return e},Tt=e=>Mt(se({},"__esModule",{value:!0}),e),Ie={};Ct(Ie,{GeneratorError:()=>F,GeneratorProcess:()=>rn});Ve.exports=Tt(Ie);var kt=J(),Rt=z(),O=Q(),Lt=S("child_process"),It=Le(),At=(0,O.__commonJS)({"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(e,r){"use strict";r.exports=s,s.sync=l;var t=(0,O.__require)("fs");function o(i,c){var p=c.pathExt!==void 0?c.pathExt:process.env.PATHEXT;if(!p||(p=p.split(";"),p.indexOf("")!==-1))return!0;for(var a=0;a<p.length;a++){var d=p[a].toLowerCase();if(d&&i.substr(-d.length).toLowerCase()===d)return!0}return!1}function n(i,c,p){return!i.isSymbolicLink()&&!i.isFile()?!1:o(c,p)}function s(i,c,p){t.stat(i,function(a,d){p(a,a?!1:n(d,i,c))})}function l(i,c){return n(t.statSync(i),i,c)}}}),qt=(0,O.__commonJS)({"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(e,r){"use strict";r.exports=o,o.sync=n;var t=(0,O.__require)("fs");function o(i,c,p){t.stat(i,function(a,d){p(a,a?!1:s(d,c))})}function n(i,c){return s(t.statSync(i),c)}function s(i,c){return i.isFile()&&l(i,c)}function l(i,c){var p=i.mode,a=i.uid,d=i.gid,u=c.uid!==void 0?c.uid:process.getuid&&process.getuid(),h=c.gid!==void 0?c.gid:process.getgid&&process.getgid(),v=parseInt("100",8),w=parseInt("010",8),g=parseInt("001",8),f=v|w,M=p&g||p&w&&d===h||p&v&&a===u||p&f&&u===0;return M}}}),Ft=(0,O.__commonJS)({"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(e,r){"use strict";var t=(0,O.__require)("fs"),o;process.platform==="win32"||global.TESTING_WINDOWS?o=At():o=qt(),r.exports=n,n.sync=s;function n(l,i,c){if(typeof i=="function"&&(c=i,i={}),!c){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(p,a){n(l,i||{},function(d,u){d?a(d):p(u)})})}o(l,i||{},function(p,a){p&&(p.code==="EACCES"||i&&i.ignoreErrors)&&(p=null,a=!1),c(p,a)})}function s(l,i){try{return o.sync(l,i||{})}catch(c){if(i&&i.ignoreErrors||c.code==="EACCES")return!1;throw c}}}}),Bt=(0,O.__commonJS)({"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(e,r){"use strict";var t=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",o=(0,O.__require)("path"),n=t?";":":",s=Ft(),l=a=>Object.assign(new Error(`not found: ${a}`),{code:"ENOENT"}),i=(a,d)=>{let u=d.colon||n,h=a.match(/\//)||t&&a.match(/\\/)?[""]:[...t?[process.cwd()]:[],...(d.path||process.env.PATH||"").split(u)],v=t?d.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",w=t?v.split(u):[""];return t&&a.indexOf(".")!==-1&&w[0]!==""&&w.unshift(""),{pathEnv:h,pathExt:w,pathExtExe:v}},c=(a,d,u)=>{typeof d=="function"&&(u=d,d={}),d||(d={});let{pathEnv:h,pathExt:v,pathExtExe:w}=i(a,d),g=[],f=P=>new Promise((T,x)=>{if(P===h.length)return d.all&&g.length?T(g):x(l(a));let _=h[P],m=/^".*"$/.test(_)?_.slice(1,-1):_,E=o.join(m,a),j=!m&&/^\.[\\\/]/.test(a)?a.slice(0,2)+E:E;T(M(j,P,0))}),M=(P,T,x)=>new Promise((_,m)=>{if(x===v.length)return _(f(T+1));let E=v[x];s(P+E,{pathExt:w},(j,$)=>{if(!j&&$)if(d.all)g.push(P+E);else return _(P+E);return _(M(P,T,x+1))})});return u?f(0).then(P=>u(null,P),u):f(0)},p=(a,d)=>{d=d||{};let{pathEnv:u,pathExt:h,pathExtExe:v}=i(a,d),w=[];for(let g=0;g<u.length;g++){let f=u[g],M=/^".*"$/.test(f)?f.slice(1,-1):f,P=o.join(M,a),T=!M&&/^\.[\\\/]/.test(a)?a.slice(0,2)+P:P;for(let x=0;x<h.length;x++){let _=T+h[x];try{if(s.sync(_,{pathExt:v}))if(d.all)w.push(_);else return _}catch{}}}if(d.all&&w.length)return w;if(d.nothrow)return null;throw l(a)};r.exports=c,c.sync=p}}),Vt=(0,O.__commonJS)({"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(e,r){"use strict";var t=(o={})=>{let n=o.env||process.env;return(o.platform||process.platform)!=="win32"?"PATH":Object.keys(n).reverse().find(l=>l.toUpperCase()==="PATH")||"Path"};r.exports=t,r.exports.default=t}}),Gt=(0,O.__commonJS)({"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(e,r){"use strict";var t=(0,O.__require)("path"),o=Bt(),n=Vt();function s(i,c){let p=i.options.env||process.env,a=process.cwd(),d=i.options.cwd!=null,u=d&&process.chdir!==void 0&&!process.chdir.disabled;if(u)try{process.chdir(i.options.cwd)}catch{}let h;try{h=o.sync(i.command,{path:p[n({env:p})],pathExt:c?t.delimiter:void 0})}catch{}finally{u&&process.chdir(a)}return h&&(h=t.resolve(d?i.options.cwd:"",h)),h}function l(i){return s(i)||s(i,!0)}r.exports=l}}),Jt=(0,O.__commonJS)({"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(e,r){"use strict";var t=/([()\][%!^"`<>&|;, *?])/g;function o(s){return s=s.replace(t,"^$1"),s}function n(s,l){return s=`${s}`,s=s.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),s=s.replace(/(?=(\\+?)?)\1$/,"$1$1"),s=`"${s}"`,s=s.replace(t,"^$1"),l&&(s=s.replace(t,"^$1")),s}r.exports.command=o,r.exports.argument=n}}),Yt=(0,O.__commonJS)({"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(e,r){"use strict";r.exports=/^#!(.*)/}}),Kt=(0,O.__commonJS)({"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(e,r){"use strict";var t=Yt();r.exports=(o="")=>{let n=o.match(t);if(!n)return null;let[s,l]=n[0].replace(/#! ?/,"").split(" "),i=s.split("/").pop();return i==="env"?l:l?`${i} ${l}`:i}}}),Ut=(0,O.__commonJS)({"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(e,r){"use strict";var t=(0,O.__require)("fs"),o=Kt();function n(s){let i=Buffer.alloc(150),c;try{c=t.openSync(s,"r"),t.readSync(c,i,0,150,0),t.closeSync(c)}catch{}return o(i.toString())}r.exports=n}}),Wt=(0,O.__commonJS)({"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(e,r){"use strict";var t=(0,O.__require)("path"),o=Gt(),n=Jt(),s=Ut(),l=process.platform==="win32",i=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function p(u){u.file=o(u);let h=u.file&&s(u.file);return h?(u.args.unshift(u.file),u.command=h,o(u)):u.file}function a(u){if(!l)return u;let h=p(u),v=!i.test(h);if(u.options.forceShell||v){let w=c.test(h);u.command=t.normalize(u.command),u.command=n.command(u.command),u.args=u.args.map(f=>n.argument(f,w));let g=[u.command].concat(u.args).join(" ");u.args=["/d","/s","/c",`"${g}"`],u.command=process.env.comspec||"cmd.exe",u.options.windowsVerbatimArguments=!0}return u}function d(u,h,v){h&&!Array.isArray(h)&&(v=h,h=null),h=h?h.slice(0):[],v=Object.assign({},v);let w={command:u,args:h,options:v,file:void 0,original:{command:u,args:h}};return v.shell?w:a(w)}r.exports=d}}),Ht=(0,O.__commonJS)({"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(e,r){"use strict";var t=process.platform==="win32";function o(i,c){return Object.assign(new Error(`${c} ${i.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${c} ${i.command}`,path:i.command,spawnargs:i.args})}function n(i,c){if(!t)return;let p=i.emit;i.emit=function(a,d){if(a==="exit"){let u=s(d,c);if(u)return p.call(i,"error",u)}return p.apply(i,arguments)}}function s(i,c){return t&&i===1&&!c.file?o(c.original,"spawn"):null}function l(i,c){return t&&i===1&&!c.file?o(c.original,"spawnSync"):null}r.exports={hookChildProcess:n,verifyENOENT:s,verifyENOENTSync:l,notFoundError:o}}}),zt=(0,O.__commonJS)({"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(e,r){"use strict";var t=(0,O.__require)("child_process"),o=Wt(),n=Ht();function s(i,c,p){let a=o(i,c,p),d=t.spawn(a.command,a.args,a.options);return n.hookChildProcess(d,a),d}function l(i,c,p){let a=o(i,c,p),d=t.spawnSync(a.command,a.args,a.options);return d.error=d.error||n.verifyENOENTSync(d.status,a),d}r.exports=s,r.exports.spawn=s,r.exports.sync=l,r.exports._parse=o,r.exports._enoent=n}}),Xt=(0,O.__toESM)(zt()),oe,Ae,qe,Fe,Be=!0;typeof process<"u"&&({FORCE_COLOR:oe,NODE_DISABLE_COLORS:Ae,NO_COLOR:qe,TERM:Fe}=process.env||{},Be=process.stdout&&process.stdout.isTTY);var Qt={enabled:!Ae&&qe==null&&Fe!=="dumb"&&(oe!=null&&oe!=="0"||Be)};function b(e,r){let t=new RegExp(`\\x1b\\[${r}m`,"g"),o=`\x1B[${e}m`,n=`\x1B[${r}m`;return function(s){return!Qt.enabled||s==null?s:o+(~(""+s).indexOf(n)?s.replace(t,n+o):s)+n}}var Jn=b(0,0),Zt=b(1,22),Yn=b(2,22),Kn=b(3,23),Un=b(4,24),Wn=b(7,27),Hn=b(8,28),zn=b(9,29),Xn=b(30,39),Qn=b(31,39),Zn=b(32,39),eo=b(33,39),ro=b(34,39),to=b(35,39),no=b(36,39),oo=b(37,39),so=b(90,39),io=b(90,39),ao=b(40,49),co=b(41,49),lo=b(42,49),uo=b(43,49),po=b(44,49),fo=b(45,49),mo=b(46,49),ho=b(47,49),ne=(0,It.Debug)("prisma:GeneratorProcess"),en=1,F=class extends Error{constructor(e,r,t){super(e),this.code=r,this.data=t,t?.stack&&(this.stack=t.stack)}name="GeneratorError"},rn=class{constructor(e,{isNode:r=!1}={}){this.pathOrCommand=e,this.isNode=r}child;handlers={};initPromise;isNode;errorLogs="";pendingError;exited=!1;async init(){return this.initPromise||(this.initPromise=this.initSingleton()),this.initPromise}initSingleton(){return new Promise((e,r)=>{this.isNode?this.child=(0,Lt.fork)(this.pathOrCommand,[],{stdio:["pipe","inherit","pipe","ipc"],env:{...process.env,PRISMA_GENERATOR_INVOCATION:"true"},execArgv:["--max-old-space-size=8096"]}):this.child=(0,Xt.spawn)(this.pathOrCommand,{stdio:["pipe","inherit","pipe"],env:{...process.env,PRISMA_GENERATOR_INVOCATION:"true"},shell:!0}),this.child.on("exit",(t,o)=>{if(ne(`child exited with code ${t} on signal ${o}`),this.exited=!0,t){let n=new F(`Generator ${JSON.stringify(this.pathOrCommand)} failed: ${this.errorLogs}`);this.pendingError=n,this.rejectAllHandlers(n)}}),this.child.stdin.on("error",()=>{}),this.child.on("error",t=>{ne(t),this.pendingError=t,t.code==="EACCES"?r(new Error(`The executable at ${this.pathOrCommand} lacks the right permissions. Please use ${Zt(`chmod +x ${this.pathOrCommand}`)}`)):r(t),this.rejectAllHandlers(t)}),(0,kt.byline)(this.child.stderr).on("data",t=>{let o=String(t),n;try{n=JSON.parse(o)}catch{this.errorLogs+=o+` `,ne(o)}n&&this.handleResponse(n)}),this.child.on("spawn",e)})}rejectAllHandlers(e){for(let r of Object.keys(this.handlers))this.handlers[r].reject(e),delete this.handlers[r]}handleResponse(e){if(e.jsonrpc&&e.id){if(typeof e.id!="number")throw new Error(`message.id has to be a number. Found value ${e.id}`);if(this.handlers[e.id]){if((0,Rt.isErrorResponse)(e)){let r=new F(e.error.message,e.error.code,e.error.data);this.handlers[e.id].reject(r)}else this.handlers[e.id].resolve(e.result);delete this.handlers[e.id]}}}sendMessage(e,r){if(!this.child){r(new F("Generator process has not started yet"));return}if(!this.child.stdin.writable){r(new F("Cannot send data to the generator process, process already exited"));return}this.child.stdin.write(JSON.stringify(e)+` `,t=>{if(!t||t.code==="EPIPE")return r();r(t)})}getMessageId(){return en++}stop(){if(this.child&&!this.child?.killed){this.child.kill("SIGTERM");let e=2e3,r=200,t,o;Promise.race([new Promise(n=>{o=setTimeout(n,e)}),new Promise(n=>{t=setInterval(()=>{if(this.exited)return n("exited")},r)})]).then(n=>{n!=="exited"&&this.child?.kill("SIGKILL")}).finally(()=>{clearInterval(t),clearTimeout(o)})}}rpcMethod(e,r=t=>t){return t=>new Promise((o,n)=>{if(this.pendingError){n(this.pendingError);return}let s=this.getMessageId();this.handlers[s]={resolve:l=>o(r(l)),reject:n},this.sendMessage({jsonrpc:"2.0",method:e,params:t,id:s},l=>{l&&n(l)})})}getManifest=this.rpcMethod("getManifest",e=>e.manifest??null);generate=this.rpcMethod("generate")}});var Ke=k((yo,Ye)=>{"use strict";var ie=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=Object.getOwnPropertyNames,on=Object.prototype.hasOwnProperty,sn=(e,r)=>{for(var t in r)ie(e,t,{get:r[t],enumerable:!0})},an=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of nn(r))!on.call(e,n)&&n!==t&&ie(e,n,{get:()=>r[n],enumerable:!(o=tn(r,n))||o.enumerable});return e},cn=e=>an(ie({},"__esModule",{value:!0}),e),Je={};sn(Je,{generatorHandler:()=>un});Ye.exports=cn(Je);var ln=J();function un(e){(0,ln.byline)(process.stdin).on("data",async r=>{let t=JSON.parse(String(r));if(t.method==="generate"&&t.params)try{let o=await e.onGenerate(t.params);B({jsonrpc:"2.0",result:o,id:t.id})}catch(o){let n=o;B({jsonrpc:"2.0",error:{code:-32e3,message:n.message,data:{stack:n.stack}},id:t.id})}if(t.method==="getManifest")if(e.onManifest)try{let o=await e.onManifest(t.params);B({jsonrpc:"2.0",result:{manifest:o},id:t.id})}catch(o){let n=o;B({jsonrpc:"2.0",error:{code:-32e3,message:n.message,data:{stack:n.stack}},id:t.id})}else B({jsonrpc:"2.0",result:{manifest:null},id:t.id})}),process.stdin.resume()}function B(e){process.stderr.write(JSON.stringify(e)+` `)}});var ze=k((Oo,He)=>{"use strict";var ae=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,dn=Object.getOwnPropertyNames,fn=Object.prototype.hasOwnProperty,mn=(e,r)=>{for(var t in r)ae(e,t,{get:r[t],enumerable:!0})},hn=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of dn(r))!fn.call(e,n)&&n!==t&&ae(e,n,{get:()=>r[n],enumerable:!(o=pn(r,n))||o.enumerable});return e},gn=e=>hn(ae({},"__esModule",{value:!0}),e),We={};mn(We,{GeneratorError:()=>Ue.GeneratorError,GeneratorProcess:()=>Ue.GeneratorProcess,generatorHandler:()=>vn.generatorHandler});He.exports=gn(We);var Ue=Ge(),vn=Ke(),bo=J(),wo=z(),Eo=Q()});var Xe=k((xo,_n)=>{_n.exports={name:"dotenv",version:"16.6.1",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var tr=k((So,R)=>{"use strict";var ce=S("fs"),Y=S("path"),yn=S("os"),bn=S("crypto"),wn=Xe(),le=wn.version,En=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function On(e){let r={},t=e.toString();t=t.replace(/\r\n?/mg,` `);let o;for(;(o=En.exec(t))!=null;){let n=o[1],s=o[2]||"";s=s.trim();let l=s[0];s=s.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),l==='"'&&(s=s.replace(/\\n/g,` `),s=s.replace(/\\r/g,"\r")),r[n]=s}return r}function xn(e){e=e||{};let r=rr(e);e.path=r;let t=N.configDotenv(e);if(!t.parsed){let l=new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);throw l.code="MISSING_DATA",l}let o=er(e).split(","),n=o.length,s;for(let l=0;l<n;l++)try{let i=o[l].trim(),c=Pn(t,i);s=N.decrypt(c.ciphertext,c.key);break}catch(i){if(l+1>=n)throw i}return N.parse(s)}function Sn(e){console.log(`[dotenv@${le}][WARN] ${e}`)}function V(e){console.log(`[dotenv@${le}][DEBUG] ${e}`)}function Ze(e){console.log(`[dotenv@${le}] ${e}`)}function er(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Pn(e,r){let t;try{t=new URL(r)}catch(i){if(i.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw i}let o=t.password;if(!o){let i=new Error("INVALID_DOTENV_KEY: Missing key part");throw i.code="INVALID_DOTENV_KEY",i}let n=t.searchParams.get("environment");if(!n){let i=new Error("INVALID_DOTENV_KEY: Missing environment part");throw i.code="INVALID_DOTENV_KEY",i}let s=`DOTENV_VAULT_${n.toUpperCase()}`,l=e.parsed[s];if(!l){let i=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw i.code="NOT_FOUND_DOTENV_ENVIRONMENT",i}return{ciphertext:l,key:o}}function rr(e){let r=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let t of e.path)ce.existsSync(t)&&(r=t.endsWith(".vault")?t:`${t}.vault`);else r=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else r=Y.resolve(process.cwd(),".env.vault");return ce.existsSync(r)?r:null}function Qe(e){return e[0]==="~"?Y.join(yn.homedir(),e.slice(1)):e}function Nn(e){let r=!!(e&&e.debug),t=e&&"quiet"in e?e.quiet:!0;(r||!t)&&Ze("Loading env from encrypted .env.vault");let o=N._parseVault(e),n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),N.populate(n,o,e),{parsed:o}}function Dn(e){let r=Y.resolve(process.cwd(),".env"),t="utf8",o=!!(e&&e.debug),n=e&&"quiet"in e?e.quiet:!0;e&&e.encoding?t=e.encoding:o&&V("No encoding is specified. UTF-8 is used by default");let s=[r];if(e&&e.path)if(!Array.isArray(e.path))s=[Qe(e.path)];else{s=[];for(let p of e.path)s.push(Qe(p))}let l,i={};for(let p of s)try{let a=N.parse(ce.readFileSync(p,{encoding:t}));N.populate(i,a,e)}catch(a){o&&V(`Failed to load ${p} ${a.message}`),l=a}let c=process.env;if(e&&e.processEnv!=null&&(c=e.processEnv),N.populate(c,i,e),o||!n){let p=Object.keys(i).length,a=[];for(let d of s)try{let u=Y.relative(process.cwd(),d);a.push(u)}catch(u){o&&V(`Failed to load ${d} ${u.message}`),l=u}Ze(`injecting env (${p}) from ${a.join(",")}`)}return l?{parsed:i,error:l}:{parsed:i}}function jn(e){if(er(e).length===0)return N.configDotenv(e);let r=rr(e);return r?N._configVault(e):(Sn(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`),N.configDotenv(e))}function $n(e,r){let t=Buffer.from(r.slice(-64),"hex"),o=Buffer.from(e,"base64"),n=o.subarray(0,12),s=o.subarray(-16);o=o.subarray(12,-16);try{let l=bn.createDecipheriv("aes-256-gcm",t,n);return l.setAuthTag(s),`${l.update(o)}${l.final()}`}catch(l){let i=l instanceof RangeError,c=l.message==="Invalid key length",p=l.message==="Unsupported state or unable to authenticate data";if(i||c){let a=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw a.code="INVALID_DOTENV_KEY",a}else if(p){let a=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw a.code="DECRYPTION_FAILED",a}else throw l}}function Cn(e,r,t={}){let o=!!(t&&t.debug),n=!!(t&&t.override);if(typeof r!="object"){let s=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw s.code="OBJECT_REQUIRED",s}for(let s of Object.keys(r))Object.prototype.hasOwnProperty.call(e,s)?(n===!0&&(e[s]=r[s]),o&&V(n===!0?`"${s}" is already defined and WAS overwritten`:`"${s}" is already defined and was NOT overwritten`)):e[s]=r[s]}var N={configDotenv:Dn,_configVault:Nn,_parseVault:xn,config:jn,decrypt:$n,parse:On,populate:Cn};R.exports.configDotenv=N.configDotenv;R.exports._configVault=N._configVault;R.exports._parseVault=N._parseVault;R.exports.config=N.config;R.exports.decrypt=N.decrypt;R.exports.parse=N.parse;R.exports.populate=N.populate;R.exports=N});var ar=I(ze());var D=I(S("path")),K=I(S("child_process")),C=I(S("fs")),U=I(S("os")),nr=S("url"),or=I(tr());or.config();function Mn(e,r){let{tableOnly:t=!1,ignoreEnums:o=!1,ignoreViews:n=!1,ignorePattern:s=[],includeRelationFromFields:l=!1,disableEmoji:i=!1}=r??{},c="erDiagram",p=e.models;if(n&&e.views){let g=new Set(e.views.map(f=>f.name));p=p.filter(f=>!g.has(f.name))}s.length>0&&(p=p.filter(g=>!Ln(g.name,s)));let a=p.concat(e.types),d=t||o?"":e.enums.map(g=>` ${g.dbName||g.name} { ${g.values.map(f=>`${f.name||f.dbName} ${f.dbName||f.name}`).join(` `)} } `).join(` `),u=i?'"PK"':'"\u{1F5DD}\uFE0F"',h=i?'"nullable"':'"\u2753"',v=a.map(g=>` "${g.dbName||g.name}" { ${t?"":g.fields.filter(Tn(g,l)).map(f=>` ${f.type.trimStart()} ${f.name.replace(/^_/,"z_")} ${f.isId||g.primaryKey?.fields?.includes(f.name)?u:""}${f.isRequired?"":h}`).join(` `)} } `).join(` `),w="";for(let g of a)for(let f of g.fields){let M=f.kind==="enum";if(M&&(t||o))continue;let P=`${M?"enum:":""}${f.name}`,T=`"${g.dbName||g.name}"`,x=`"${a.find(_=>_.name===f.type)?.dbName||f.type}"`;if(f.relationFromFields&&f.relationFromFields.length>0||M){let _=a.find($=>$.name===f.type||$.dbName===f.type),m=_?.fields.find(({relationName:$})=>$===f.relationName),E="||";m?.isList?E="}o":m?.isRequired||(E="|o");let j="||";f.isList?j="}o":f.isRequired||(j="|o"),w+=` ${T} ${E}--${j} ${_?.dbName||x} : "${P}" `}else if(a.find(_=>_.name===f.type||_.dbName===f.type)&&f.relationFromFields?.length===0){let _=a.find(m=>m.name===f.type||m.dbName===f.type);if(_){let m=_.fields.find(({relationName:j})=>j===f.relationName);if(!(m?.relationFromFields&&m.relationFromFields.length>0)){let j=a.indexOf(g),$=a.indexOf(_);j<$&&(w+=` ${T} o{--}o ${x} : "" `)}}}else if(f.kind==="object"){let _=e.types.find(m=>m.name.replace(/^_/,"z_").replace(/\s/g,"")===f.type);if(_){let m="||";f.isList?m="}o":f.isRequired||(m="|o");let E=_?.fields.find(({relationName:$})=>$===f.relationName),j=m;E?.isList?m="o{":E?.isRequired||(m="o|"),w+=` ${T} ${m}--${j} ${_.dbName||x} : "${P}" `}}}return`${c} ${d} ${v} ${w}`}var Tn=(e,r)=>t=>r?t.kind!=="object":t.kind!=="object"&&!e.fields.find(({relationFromFields:o})=>o?.includes(t.name)),kn=e=>{let r=[],t=e?.split(` `)||[];for(let o=0;o<t.length;o++){let n=t[o]?.trim();if(!n)continue;let s=n.match(/^view\s+(\w+)\s*{/);s&&s[1]&&r.push(s[1])}return r},Rn=e=>{let r=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${r}$`)},Ln=(e,r)=>r.some(t=>Rn(t).test(e)),In=(e,r)=>{let t=r?.split(` `).filter(o=>o.includes("@map")||o.includes("model ")).map(o=>o.trim());return e.map(o=>({...o,fields:o.fields.map(n=>{let s="None",l=t.filter(i=>(s==="Match"&&i.includes("model ")&&(s="End"),s==="None"&&i.includes(`model ${o.name} `)&&(s="Match"),s==="Match")).find(i=>i.includes(`${n.name} `)&&i.includes("@map"));if(l){let c=new RegExp(/@map\(\"(.*?)\"\)/,"g").exec(l);if(c?.[1]){let p=c[1].replace(/^_/,"z_").replace(/\s/g,"");n.name=p}}return n})}))},sr=async e=>{try{let r=e.generator.output?.value||"./prisma/ERD.svg",t=e.generator.config,o=t.theme??"forest",n=D.resolve(D.join(t.mmdcPath||"node_modules/.bin","mmdc")),s=t.tableOnly==="true",l=t.disableEmoji==="true",i=t.ignoreEnums==="true",c=t.ignoreViews==="true",p=t.ignorePattern?t.ignorePattern.split(",").map(m=>m.trim()):[],a=t.includeRelationFromFields==="true",d=process.env.DISABLE_ERD==="true"||t.disabled==="true",u=t.erdDebug==="true"||!!process.env.ERD_DEBUG;if(u&&(console.log("debug mode enabled"),console.log("config",t)),d)return console.log("ERD generator is disabled");let h=C.default.mkdtempSync(`${U.default.tmpdir()+D.sep}prisma-erd-`);if(!e.dmmf?.datamodel)throw new Error("Datamodel is missing from generator options");let v=JSON.parse(JSON.stringify(e.dmmf.datamodel));if(u&&v){C.default.mkdirSync(D.resolve("prisma/debug"),{recursive:!0});let m=D.resolve("prisma/debug/1-datamodel.json");C.default.writeFileSync(m,JSON.stringify(v,null,2)),console.log(`data model written to ${m}`)}v.models=In(v.models,e.datamodel),v.types||(v.types=[]);let w=kn(e.datamodel);if(v.views=v.models.filter(m=>w.includes(m.name)),u&&v.models){let m=D.resolve("prisma/debug/2-datamodel-map-applied.json");C.default.writeFileSync(m,JSON.stringify(v,null,2)),console.log(`applied @map to fields written to ${m}`)}let g=Mn(v,{tableOnly:s,ignoreEnums:i,ignoreViews:c,ignorePattern:p,includeRelationFromFields:a,disableEmoji:l});if(u&&g){let m=D.resolve("prisma/debug/3-mermaid.mmd");C.default.writeFileSync(m,g),console.log(`mermaid written to ${m}`)}if(!g)throw new Error("failed to construct mermaid instance from dml");if(r.endsWith(".md"))return C.default.writeFileSync(r,`\`\`\`mermaid ${g}\`\`\` `);let f=D.resolve(D.join(h,"prisma.mmd"));C.default.writeFileSync(f,g);let M={deterministicIds:!0,maxTextSize:9e4,er:{useMaxWidth:!0},theme:o},P=M;if(t?.mermaidConfig){let m=D.resolve(t.mermaidConfig),E=await import((0,nr.pathToFileURL)(m).href);u&&console.log("imported mermaid config: ",E),P={...M,...E}}let T=D.resolve(D.join(h,"config.json"));C.default.writeFileSync(T,JSON.stringify(P));let x=t.puppeteerConfig;if(x&&!C.default.existsSync(x))throw new Error(`Puppeteer config file "${x}" does not exist`);if(!x){let m=D.resolve(D.join(h,"puppeteerConfig.json")),E,j={logLevel:u?"warn":"error",executablePath:E};if(U.default.platform()==="darwin"&&U.default.arch()==="arm64")try{let $=K.execSync("which chromium").toString().replace(` `,"");if(!$)throw new Error("Could not find chromium executable. Refer to https://github.com/keonik/prisma-erd-generator#issues for next steps.");j.executablePath=$,j.args=["--no-sandbox"]}catch($){console.error($),console.log(` Prisma ERD Generator: Unable to find chromium path for you MacOS arm64 machine. Attempting to use the default at ${E}. To learn more visit https://github.com/keonik/prisma-erd-generator#-arm64-users- `),E="/usr/bin/chromium-browser"}C.default.writeFileSync(m,JSON.stringify(j)),x=m}if(t.mmdcPath){if(!C.default.existsSync(n))throw new Error(` Mermaid CLI provided path does not exist. ${n}`)}else if(!C.default.existsSync(n)){let m=K.execSync("find ../.. -name mmdc").toString().split(` `).filter(E=>E).pop();if(!m||!C.default.existsSync(m))throw new Error(`Expected mermaid CLI at ${n} or ${m} but this package was not found.`);n=D.resolve(m)}let _=`"${n}" -i "${f}" -o "${r}" -c "${T}" -p "${x}"`;if(u&&_&&console.log("mermaid command: ",_),K.execSync(_),!C.default.existsSync(r))throw new Error(`Issue generating ER Diagram. Expected ${r} to be created`)}catch(r){throw console.error(r),r}};var cr=S("fs"),ir=process.env.DISABLE_ERD==="true",ue;try{ue=JSON.parse((0,cr.readFileSync)("package.json","utf-8"))}catch(e){console.error(e),ue={version:"1.0.0"}}(0,ar.generatorHandler)({onManifest:()=>({defaultOutput:ir?"N/A":"ERD.svg",prettyName:ir?"No ERD":"Entity-relationship-diagram",version:ue?.version}),onGenerate:sr});})();