diff --git a/dist/main.cjs b/dist/main.cjs index c77de7b..44c052c 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -42,7 +42,7 @@ __p += '`),ne&&(C+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+C+`return __p -}`;var z=Tu(function(){return oe(p,B+"return "+C).apply(s,$)});if(z.source=C,ao(z))throw z;return z}function eb(e){return ie(e).toLowerCase()}function sb(e){return ie(e).toUpperCase()}function nb(e,n,r){if(e=ie(e),e&&(r||n===s))return Ri(e);if(!e||!(n=ke(n)))return e;var i=ps(e),u=ps(n),p=hi(i,u),$=Ni(i,u)+1;return Gs(i,p,$).join("")}function tb(e,n,r){if(e=ie(e),e&&(r||n===s))return e.slice(0,yi(e)+1);if(!e||!(n=ke(n)))return e;var i=ps(e),u=Ni(i,ps(n))+1;return Gs(i,0,u).join("")}function rb(e,n,r){if(e=ie(e),e&&(r||n===s))return e.replace(a_,"");if(!e||!(n=ke(n)))return e;var i=ps(e),u=hi(i,ps(n));return Gs(i,u).join("")}function _b(e,n){var r=R,i=x;if(be(n)){var u="separator"in n?n.separator:u;r="length"in n?k(n.length):r,i="omission"in n?ke(n.omission):i}e=ie(e);var p=e.length;if(cn(e)){var $=ps(e);p=$.length}if(r>=p)return e;var l=r-mn(i);if(l<1)return i;var b=$?Gs($,0,l).join(""):e.slice(0,l);if(u===s)return b+i;if($&&(l+=b.length-l),po(u)){if(e.slice(l).search(u)){var S,y=b;for(u.global||(u=L_(u.source,ie(Ho.exec(u))+"g")),u.lastIndex=0;S=u.exec(y);)var C=S.index;b=b.slice(0,C===s?l:C)}}else if(e.indexOf(ke(u),l)!=l){var D=b.lastIndexOf(u);D>-1&&(b=b.slice(0,D))}return b+i}function ob(e){return e=ie(e),e&&Aa.test(e)?e.replace(Yo,Bp):e}var ib=Sn(function(e,n,r){return e+(r?" ":"")+n.toUpperCase()}),lo=lE("toUpperCase");function $u(e,n,r){return e=ie(e),n=r?s:n,n===s?xp(e)?Mp(e):Ip(e):e.match(n)||[]}var Tu=Z(function(e,n){try{return Qe(e,s,n)}catch(r){return ao(r)?r:new H(r)}}),Eb=Ls(function(e,n){return je(n,function(r){r=Is(r),Ss(e,r,Eo(e[r],e))}),e});function ub(e){var n=e==null?0:e.length,r=g();return e=n?fe(e,function(i){if(typeof i[1]!="function")throw new es(T);return[r(i[0]),i[1]]}):[],Z(function(i){for(var u=-1;++uue)return[];var r=Be,i=ge(e,Be);n=g(n),e-=Be;for(var u=N_(i,n);++r0||n<0)?new ee(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),n!==s&&(n=k(n),r=n<0?r.dropRight(-n):r.take(n-e)),r)},ee.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ee.prototype.toArray=function(){return this.take(Be)},cs(ee.prototype,function(e,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),i=/^(?:head|last)$/.test(n),u=a[i?"take"+(n=="last"?"Right":""):n],p=i||/^find/.test(n);!u||(a.prototype[n]=function(){var $=this.__wrapped__,l=i?[1]:arguments,b=$ instanceof ee,S=l[0],y=b||W($),C=function(j){var ne=u.apply(a,gs([j],l));return i&&D?ne[0]:ne};y&&r&&typeof S=="function"&&S.length!=1&&(b=y=!1);var D=this.__chain__,B=!!this.__actions__.length,M=p&&!D,z=b&&!B;if(!p&&y){$=z?$:new ee(this);var F=e.apply($,l);return F.__actions__.push({func:er,args:[C],thisArg:s}),new ss(F,D)}return M&&z?e.apply(this,l):(F=this.thru(C),M?i?F.value()[0]:F.value():F)})}),je(["pop","push","shift","sort","splice","unshift"],function(e){var n=yt[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var p=this.value();return n.apply(W(p)?p:[],u)}return this[r](function($){return n.apply(W($)?$:[],u)})}}),cs(ee.prototype,function(e,n){var r=a[n];if(r){var i=r.name+"";ae.call(Rn,i)||(Rn[i]=[]),Rn[i].push({name:n,func:r})}}),Rn[qt(s,_e).name]=[{name:"wrapper",func:s}],ee.prototype.clone=_$,ee.prototype.reverse=o$,ee.prototype.value=i$,a.prototype.at=gl,a.prototype.chain=Ml,a.prototype.commit=Fl,a.prototype.next=Ul,a.prototype.plant=Yl,a.prototype.reverse=Xl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Gl,a.prototype.first=a.prototype.head,kn&&(a.prototype[kn]=wl),a},Fs=Fp();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(De._=Fs,define(function(){return Fs})):js?((js.exports=Fs)._=Fs,A_._=Fs):De._=Fs}).call(Yn)});var Km={};Zb(Km,{schemaToErd:()=>Ea});module.exports=jb(Km);var zr=require("fs"),Zr=ur(require("path"),1);var ra=ur(na(),1),Jr=ur(require("assert"),1),_a=ur(ta(),1);var Fo={"inter-token":["BINARY","national","STORED"],"match-token":["VIRTUAL","type = innodb","default 0000-00-00 00:00:00","default 0000-00-00","CONSTRANT check_active"],function:["GENERATED","CHECK","PARTITION BY LIST (transaction_type)"]};var Nm=new ra.Parser("mysql");function Sm(s,t){let o=s,E,T,c;for(;T=o.indexOf(t),T!==-1;){E=0,c=void 0;for(let O=T+t.length;OSm(o,E),s)}function Lm(s){return Object.keys(Fo).reduce((t,o)=>{let E=Fo[o];if(_a.default.isEmpty(E))return t;switch(o){case"inter-token":let T=new RegExp(`\\s+(${E.join("|")})\\s+`,"gmi");return t.replace(T," ");case"match-token":let c=new RegExp(`(${E.join("|")})`,"gm");return t.replace(c,"");case"function":return ym(t,E);default:(0,Jr.default)(!1,`Not supported token type: ${o}`);break}},s)}function Cm(s){let t=[],o=/(CREATE|ALTER|DROP|RENAME|TRUNCATE)\sTABLE/i,E=0;for(;E=p)return e;var l=r-mn(i);if(l<1)return i;var b=$?Gs($,0,l).join(""):e.slice(0,l);if(u===s)return b+i;if($&&(l+=b.length-l),po(u)){if(e.slice(l).search(u)){var S,y=b;for(u.global||(u=L_(u.source,ie(Ho.exec(u))+"g")),u.lastIndex=0;S=u.exec(y);)var C=S.index;b=b.slice(0,C===s?l:C)}}else if(e.indexOf(ke(u),l)!=l){var D=b.lastIndexOf(u);D>-1&&(b=b.slice(0,D))}return b+i}function ob(e){return e=ie(e),e&&Aa.test(e)?e.replace(Yo,Bp):e}var ib=Sn(function(e,n,r){return e+(r?" ":"")+n.toUpperCase()}),lo=lE("toUpperCase");function $u(e,n,r){return e=ie(e),n=r?s:n,n===s?xp(e)?Mp(e):Ip(e):e.match(n)||[]}var Tu=Z(function(e,n){try{return Qe(e,s,n)}catch(r){return ao(r)?r:new H(r)}}),Eb=Ls(function(e,n){return je(n,function(r){r=Is(r),Ss(e,r,Eo(e[r],e))}),e});function ub(e){var n=e==null?0:e.length,r=g();return e=n?fe(e,function(i){if(typeof i[1]!="function")throw new es(T);return[r(i[0]),i[1]]}):[],Z(function(i){for(var u=-1;++uue)return[];var r=Be,i=ge(e,Be);n=g(n),e-=Be;for(var u=N_(i,n);++r0||n<0)?new ee(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),n!==s&&(n=k(n),r=n<0?r.dropRight(-n):r.take(n-e)),r)},ee.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ee.prototype.toArray=function(){return this.take(Be)},cs(ee.prototype,function(e,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),i=/^(?:head|last)$/.test(n),u=a[i?"take"+(n=="last"?"Right":""):n],p=i||/^find/.test(n);!u||(a.prototype[n]=function(){var $=this.__wrapped__,l=i?[1]:arguments,b=$ instanceof ee,S=l[0],y=b||W($),C=function(j){var ne=u.apply(a,gs([j],l));return i&&D?ne[0]:ne};y&&r&&typeof S=="function"&&S.length!=1&&(b=y=!1);var D=this.__chain__,B=!!this.__actions__.length,M=p&&!D,z=b&&!B;if(!p&&y){$=z?$:new ee(this);var F=e.apply($,l);return F.__actions__.push({func:er,args:[C],thisArg:s}),new ss(F,D)}return M&&z?e.apply(this,l):(F=this.thru(C),M?i?F.value()[0]:F.value():F)})}),je(["pop","push","shift","sort","splice","unshift"],function(e){var n=yt[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var p=this.value();return n.apply(W(p)?p:[],u)}return this[r](function($){return n.apply(W($)?$:[],u)})}}),cs(ee.prototype,function(e,n){var r=a[n];if(r){var i=r.name+"";ae.call(Rn,i)||(Rn[i]=[]),Rn[i].push({name:n,func:r})}}),Rn[qt(s,_e).name]=[{name:"wrapper",func:s}],ee.prototype.clone=_$,ee.prototype.reverse=o$,ee.prototype.value=i$,a.prototype.at=gl,a.prototype.chain=Ml,a.prototype.commit=Fl,a.prototype.next=Ul,a.prototype.plant=Yl,a.prototype.reverse=Xl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Gl,a.prototype.first=a.prototype.head,kn&&(a.prototype[kn]=wl),a},Fs=Fp();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(De._=Fs,define(function(){return Fs})):js?((js.exports=Fs)._=Fs,A_._=Fs):De._=Fs}).call(Yn)});var Km={};Zb(Km,{schemaToErd:()=>Ea});module.exports=jb(Km);var zr=require("fs"),Zr=ur(require("path"),1);var ra=ur(na(),1),Jr=ur(require("assert"),1),_a=ur(ta(),1);var Fo={"inter-token":["BINARY","national","STORED"],"match-token":["VIRTUAL","type = innodb","default 0000-00-00 00:00:00","default 0000-00-00","CONSTRAINT check_active"],function:["GENERATED","CHECK","PARTITION BY LIST (transaction_type)"]};var Nm=new ra.Parser("mysql");function Sm(s,t){let o=s,E,T,c;for(;T=o.indexOf(t),T!==-1;){E=0,c=void 0;for(let O=T+t.length;OSm(o,E),s)}function Lm(s){return Object.keys(Fo).reduce((t,o)=>{let E=Fo[o];if(_a.default.isEmpty(E))return t;switch(o){case"inter-token":let T=new RegExp(`\\s+(${E.join("|")})\\s+`,"gmi");return t.replace(T," ");case"match-token":let c=new RegExp(`(${E.join("|")})`,"gm");return t.replace(c,"");case"function":return ym(t,E);default:(0,Jr.default)(!1,`Not supported token type: ${o}`);break}},s)}function Cm(s){let t=[],o=/(CREATE|ALTER|DROP|RENAME|TRUNCATE)\sTABLE/i,E=0;for(;EO.$comment==="primary key"?[...T,c]:T,[]);return{tableName:t,columnNames:o,primaryKeys:E}}var oa=s=>Cm(s.replace(/\/\*.*?\*\/|--.*?\n/gs,"")).reduce((t,o)=>{try{let E={useRef:!0},T=Nm.feed(o).toJsonSchemaArray(E);if(T.length===0)return t;(0,Jr.default)(T.length===1,"Parse only one DDL at a time.");let{tableName:c,columnNames:O,primaryKeys:U}=xm(T[0]);return{...t,[c]:{columnNames:O,primaryKeys:U}}}catch(E){return console.error(`Can not parse "${o}"`,E),t}},{});function Pm(s,t,o){let T=t.map(c=>o.includes(c)?`*${c}`:c).join(` `);return`entity ${s} { ${T} diff --git a/dist/main.mjs b/dist/main.mjs index e98849a..97eb2f1 100644 --- a/dist/main.mjs +++ b/dist/main.mjs @@ -42,7 +42,7 @@ __p += '`),ne&&(C+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+C+`return __p -}`;var z=pu(function(){return oe(p,B+"return "+C).apply(s,$)});if(z.source=C,_o(z))throw z;return z}function ZA(e){return ie(e).toLowerCase()}function jA(e){return ie(e).toUpperCase()}function eb(e,n,r){if(e=ie(e),e&&(r||n===s))return Ii(e);if(!e||!(n=ke(n)))return e;var i=ps(e),u=ps(n),p=Oi(i,u),$=Ri(i,u)+1;return Gs(i,p,$).join("")}function sb(e,n,r){if(e=ie(e),e&&(r||n===s))return e.slice(0,Ni(e)+1);if(!e||!(n=ke(n)))return e;var i=ps(e),u=Ri(i,ps(n))+1;return Gs(i,0,u).join("")}function nb(e,n,r){if(e=ie(e),e&&(r||n===s))return e.replace(__,"");if(!e||!(n=ke(n)))return e;var i=ps(e),u=Oi(i,ps(n));return Gs(i,u).join("")}function tb(e,n){var r=R,i=x;if(be(n)){var u="separator"in n?n.separator:u;r="length"in n?k(n.length):r,i="omission"in n?ke(n.omission):i}e=ie(e);var p=e.length;if(cn(e)){var $=ps(e);p=$.length}if(r>=p)return e;var l=r-mn(i);if(l<1)return i;var b=$?Gs($,0,l).join(""):e.slice(0,l);if(u===s)return b+i;if($&&(l+=b.length-l),oo(u)){if(e.slice(l).search(u)){var S,y=b;for(u.global||(u=R_(u.source,ie(Xo.exec(u))+"g")),u.lastIndex=0;S=u.exec(y);)var C=S.index;b=b.slice(0,C===s?l:C)}}else if(e.indexOf(ke(u),l)!=l){var D=b.lastIndexOf(u);D>-1&&(b=b.slice(0,D))}return b+i}function rb(e){return e=ie(e),e&&la.test(e)?e.replace(Uo,Kp):e}var _b=Sn(function(e,n,r){return e+(r?" ":"")+n.toUpperCase()}),uo=$E("toUpperCase");function au(e,n,r){return e=ie(e),n=r?s:n,n===s?Lp(e)?vp(e):cp(e):e.match(n)||[]}var pu=Z(function(e,n){try{return Qe(e,s,n)}catch(r){return _o(r)?r:new H(r)}}),ob=Ls(function(e,n){return je(n,function(r){r=Is(r),Ss(e,r,to(e[r],e))}),e});function ib(e){var n=e==null?0:e.length,r=g();return e=n?fe(e,function(i){if(typeof i[1]!="function")throw new es(T);return[r(i[0]),i[1]]}):[],Z(function(i){for(var u=-1;++uue)return[];var r=Be,i=ge(e,Be);n=g(n),e-=Be;for(var u=m_(i,n);++r0||n<0)?new ee(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),n!==s&&(n=k(n),r=n<0?r.dropRight(-n):r.take(n-e)),r)},ee.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ee.prototype.toArray=function(){return this.take(Be)},cs(ee.prototype,function(e,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),i=/^(?:head|last)$/.test(n),u=a[i?"take"+(n=="last"?"Right":""):n],p=i||/^find/.test(n);!u||(a.prototype[n]=function(){var $=this.__wrapped__,l=i?[1]:arguments,b=$ instanceof ee,S=l[0],y=b||W($),C=function(j){var ne=u.apply(a,gs([j],l));return i&&D?ne[0]:ne};y&&r&&typeof S=="function"&&S.length!=1&&(b=y=!1);var D=this.__chain__,B=!!this.__actions__.length,M=p&&!D,z=b&&!B;if(!p&&y){$=z?$:new ee(this);var F=e.apply($,l);return F.__actions__.push({func:er,args:[C],thisArg:s}),new ss(F,D)}return M&&z?e.apply(this,l):(F=this.thru(C),M?i?F.value()[0]:F.value():F)})}),je(["pop","push","shift","sort","splice","unshift"],function(e){var n=yt[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var p=this.value();return n.apply(W(p)?p:[],u)}return this[r](function($){return n.apply(W($)?$:[],u)})}}),cs(ee.prototype,function(e,n){var r=a[n];if(r){var i=r.name+"";ae.call(Rn,i)||(Rn[i]=[]),Rn[i].push({name:n,func:r})}}),Rn[qt(s,_e).name]=[{name:"wrapper",func:s}],ee.prototype.clone=t$,ee.prototype.reverse=r$,ee.prototype.value=_$,a.prototype.at=Bl,a.prototype.chain=vl,a.prototype.commit=gl,a.prototype.next=Ml,a.prototype.plant=Ul,a.prototype.reverse=wl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Yl,a.prototype.first=a.prototype.head,kn&&(a.prototype[kn]=Fl),a},Fs=gp();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(De._=Fs,define(function(){return Fs})):js?((js.exports=Fs)._=Fs,p_._=Fs):De._=Fs}).call(Yn)});import{promises as vo}from"fs";import go from"path";var ta=fu(sa(),1),ra=fu(na(),1);import Bo from"assert";var Ko={"inter-token":["BINARY","national","STORED"],"match-token":["VIRTUAL","type = innodb","default 0000-00-00 00:00:00","default 0000-00-00","CONSTRANT check_active"],function:["GENERATED","CHECK","PARTITION BY LIST (transaction_type)"]};var Om=new ta.Parser("mysql");function Rm(s,t){let o=s,E,T,c;for(;T=o.indexOf(t),T!==-1;){E=0,c=void 0;for(let O=T+t.length;ORm(o,E),s)}function Nm(s){return Object.keys(Ko).reduce((t,o)=>{let E=Ko[o];if(ra.default.isEmpty(E))return t;switch(o){case"inter-token":let T=new RegExp(`\\s+(${E.join("|")})\\s+`,"gmi");return t.replace(T," ");case"match-token":let c=new RegExp(`(${E.join("|")})`,"gm");return t.replace(c,"");case"function":return hm(t,E);default:Bo(!1,`Not supported token type: ${o}`);break}},s)}function Sm(s){let t=[],o=/(CREATE|ALTER|DROP|RENAME|TRUNCATE)\sTABLE/i,E=0;for(;E=p)return e;var l=r-mn(i);if(l<1)return i;var b=$?Gs($,0,l).join(""):e.slice(0,l);if(u===s)return b+i;if($&&(l+=b.length-l),oo(u)){if(e.slice(l).search(u)){var S,y=b;for(u.global||(u=R_(u.source,ie(Xo.exec(u))+"g")),u.lastIndex=0;S=u.exec(y);)var C=S.index;b=b.slice(0,C===s?l:C)}}else if(e.indexOf(ke(u),l)!=l){var D=b.lastIndexOf(u);D>-1&&(b=b.slice(0,D))}return b+i}function rb(e){return e=ie(e),e&&la.test(e)?e.replace(Uo,Kp):e}var _b=Sn(function(e,n,r){return e+(r?" ":"")+n.toUpperCase()}),uo=$E("toUpperCase");function au(e,n,r){return e=ie(e),n=r?s:n,n===s?Lp(e)?vp(e):cp(e):e.match(n)||[]}var pu=Z(function(e,n){try{return Qe(e,s,n)}catch(r){return _o(r)?r:new H(r)}}),ob=Ls(function(e,n){return je(n,function(r){r=Is(r),Ss(e,r,to(e[r],e))}),e});function ib(e){var n=e==null?0:e.length,r=g();return e=n?fe(e,function(i){if(typeof i[1]!="function")throw new es(T);return[r(i[0]),i[1]]}):[],Z(function(i){for(var u=-1;++uue)return[];var r=Be,i=ge(e,Be);n=g(n),e-=Be;for(var u=m_(i,n);++r0||n<0)?new ee(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),n!==s&&(n=k(n),r=n<0?r.dropRight(-n):r.take(n-e)),r)},ee.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ee.prototype.toArray=function(){return this.take(Be)},cs(ee.prototype,function(e,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),i=/^(?:head|last)$/.test(n),u=a[i?"take"+(n=="last"?"Right":""):n],p=i||/^find/.test(n);!u||(a.prototype[n]=function(){var $=this.__wrapped__,l=i?[1]:arguments,b=$ instanceof ee,S=l[0],y=b||W($),C=function(j){var ne=u.apply(a,gs([j],l));return i&&D?ne[0]:ne};y&&r&&typeof S=="function"&&S.length!=1&&(b=y=!1);var D=this.__chain__,B=!!this.__actions__.length,M=p&&!D,z=b&&!B;if(!p&&y){$=z?$:new ee(this);var F=e.apply($,l);return F.__actions__.push({func:er,args:[C],thisArg:s}),new ss(F,D)}return M&&z?e.apply(this,l):(F=this.thru(C),M?i?F.value()[0]:F.value():F)})}),je(["pop","push","shift","sort","splice","unshift"],function(e){var n=yt[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var u=arguments;if(i&&!this.__chain__){var p=this.value();return n.apply(W(p)?p:[],u)}return this[r](function($){return n.apply(W($)?$:[],u)})}}),cs(ee.prototype,function(e,n){var r=a[n];if(r){var i=r.name+"";ae.call(Rn,i)||(Rn[i]=[]),Rn[i].push({name:n,func:r})}}),Rn[qt(s,_e).name]=[{name:"wrapper",func:s}],ee.prototype.clone=t$,ee.prototype.reverse=r$,ee.prototype.value=_$,a.prototype.at=Bl,a.prototype.chain=vl,a.prototype.commit=gl,a.prototype.next=Ml,a.prototype.plant=Ul,a.prototype.reverse=wl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Yl,a.prototype.first=a.prototype.head,kn&&(a.prototype[kn]=Fl),a},Fs=gp();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(De._=Fs,define(function(){return Fs})):js?((js.exports=Fs)._=Fs,p_._=Fs):De._=Fs}).call(Yn)});import{promises as vo}from"fs";import go from"path";var ta=fu(sa(),1),ra=fu(na(),1);import Bo from"assert";var Ko={"inter-token":["BINARY","national","STORED"],"match-token":["VIRTUAL","type = innodb","default 0000-00-00 00:00:00","default 0000-00-00","CONSTRAINT check_active"],function:["GENERATED","CHECK","PARTITION BY LIST (transaction_type)"]};var Om=new ta.Parser("mysql");function Rm(s,t){let o=s,E,T,c;for(;T=o.indexOf(t),T!==-1;){E=0,c=void 0;for(let O=T+t.length;ORm(o,E),s)}function Nm(s){return Object.keys(Ko).reduce((t,o)=>{let E=Ko[o];if(ra.default.isEmpty(E))return t;switch(o){case"inter-token":let T=new RegExp(`\\s+(${E.join("|")})\\s+`,"gmi");return t.replace(T," ");case"match-token":let c=new RegExp(`(${E.join("|")})`,"gm");return t.replace(c,"");case"function":return hm(t,E);default:Bo(!1,`Not supported token type: ${o}`);break}},s)}function Sm(s){let t=[],o=/(CREATE|ALTER|DROP|RENAME|TRUNCATE)\sTABLE/i,E=0;for(;EO.$comment==="primary key"?[...T,c]:T,[]);return{tableName:t,columnNames:o,primaryKeys:E}}var _a=s=>Sm(s.replace(/\/\*.*?\*\/|--.*?\n/gs,"")).reduce((t,o)=>{try{let E={useRef:!0},T=Om.feed(o).toJsonSchemaArray(E);if(T.length===0)return t;Bo(T.length===1,"Parse only one DDL at a time.");let{tableName:c,columnNames:O,primaryKeys:U}=ym(T[0]);return{...t,[c]:{columnNames:O,primaryKeys:U}}}catch(E){return console.error(`Can not parse "${o}"`,E),t}},{});function Lm(s,t,o){let T=t.map(c=>o.includes(c)?`*${c}`:c).join(` `);return`entity ${s} { ${T} diff --git a/package.json b/package.json index 559f30a..273ca90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "schema-to-erd", - "version": "1.2.8", + "version": "1.2.9", "description": "Generate ERD UML file from Schema DDL file", "type": "module", "main": "dist/main.cjs", diff --git a/src/unparsable_token.json b/src/unparsable_token.json index 83cd8a2..f8e8b87 100644 --- a/src/unparsable_token.json +++ b/src/unparsable_token.json @@ -1,5 +1,5 @@ { "inter-token": ["BINARY", "national", "STORED"], - "match-token": ["VIRTUAL", "type = innodb", "default 0000-00-00 00:00:00", "default 0000-00-00", "CONSTRANT check_active"], + "match-token": ["VIRTUAL", "type = innodb", "default 0000-00-00 00:00:00", "default 0000-00-00", "CONSTRAINT check_active"], "function": ["GENERATED", "CHECK", "PARTITION BY LIST (transaction_type)"] }