@power-maverick/tool-erd-generator 0.1.11 β 0.1.12
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 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45,4 +45,4 @@ Error generating stack: `+i.message+`
|
|
|
45
45
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(o){return o instanceof this?o:new this(o)}static concat(o,...u){const f=new this(o);return u.forEach(c=>f.set(c)),f}static accessor(o){const f=(this[Tc]=this[Tc]={accessors:{}}).accessors,c=this.prototype;function p(m){const v=Dr(m);f[v]||(Pm(c,m),f[v]=!0)}return k.isArray(o)?o.forEach(p):p(o),this}};rt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);k.reduceDescriptors(rt.prototype,({value:s},o)=>{let u=o[0].toUpperCase()+o.slice(1);return{get:()=>s,set(f){this[u]=f}}});k.freezeMethods(rt);function ss(s,o){const u=this||Ir,f=o||u,c=rt.from(f.headers);let p=f.data;return k.forEach(s,function(v){p=v.call(u,p,c.normalize(),o?o.status:void 0)}),c.normalize(),p}function ef(s){return!!(s&&s.__CANCEL__)}function Kn(s,o,u){Y.call(this,s??"canceled",Y.ERR_CANCELED,o,u),this.name="CanceledError"}k.inherits(Kn,Y,{__CANCEL__:!0});function tf(s,o,u){const f=u.config.validateStatus;!u.status||!f||f(u.status)?s(u):o(new Y("Request failed with status code "+u.status,[Y.ERR_BAD_REQUEST,Y.ERR_BAD_RESPONSE][Math.floor(u.status/100)-4],u.config,u.request,u))}function Rm(s){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return o&&o[1]||""}function _m(s,o){s=s||10;const u=new Array(s),f=new Array(s);let c=0,p=0,m;return o=o!==void 0?o:1e3,function(C){const N=Date.now(),x=f[p];m||(m=N),u[c]=C,f[c]=N;let z=p,I=0;for(;z!==c;)I+=u[z++],z=z%s;if(c=(c+1)%s,c===p&&(p=(p+1)%s),N-m<o)return;const Z=x&&N-x;return Z?Math.round(I*1e3/Z):void 0}}function Om(s,o){let u=0,f=1e3/o,c,p;const m=(N,x=Date.now())=>{u=x,c=null,p&&(clearTimeout(p),p=null),s(...N)};return[(...N)=>{const x=Date.now(),z=x-u;z>=f?m(N,x):(c=N,p||(p=setTimeout(()=>{p=null,m(c)},f-z)))},()=>c&&m(c)]}const ti=(s,o,u=3)=>{let f=0;const c=_m(50,250);return Om(p=>{const m=p.loaded,v=p.lengthComputable?p.total:void 0,C=m-f,N=c(C),x=m<=v;f=m;const z={loaded:m,total:v,progress:v?m/v:void 0,bytes:C,rate:N||void 0,estimated:N&&v&&x?(v-m)/N:void 0,event:p,lengthComputable:v!=null,[o?"download":"upload"]:!0};s(z)},u)},Pc=(s,o)=>{const u=s!=null;return[f=>o[0]({lengthComputable:u,total:s,loaded:f}),o[1]]},Rc=s=>(...o)=>k.asap(()=>s(...o)),Lm=We.hasStandardBrowserEnv?((s,o)=>u=>(u=new URL(u,We.origin),s.protocol===u.protocol&&s.host===u.host&&(o||s.port===u.port)))(new URL(We.origin),We.navigator&&/(msie|trident)/i.test(We.navigator.userAgent)):()=>!0,Am=We.hasStandardBrowserEnv?{write(s,o,u,f,c,p){const m=[s+"="+encodeURIComponent(o)];k.isNumber(u)&&m.push("expires="+new Date(u).toGMTString()),k.isString(f)&&m.push("path="+f),k.isString(c)&&m.push("domain="+c),p===!0&&m.push("secure"),document.cookie=m.join("; ")},read(s){const o=document.cookie.match(new RegExp("(^|;\\s*)("+s+")=([^;]*)"));return o?decodeURIComponent(o[3]):null},remove(s){this.write(s,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function zm(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function Dm(s,o){return o?s.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):s}function nf(s,o,u){let f=!zm(o);return s&&(f||u==!1)?Dm(s,o):o}const _c=s=>s instanceof rt?{...s}:s;function wn(s,o){o=o||{};const u={};function f(N,x,z,I){return k.isPlainObject(N)&&k.isPlainObject(x)?k.merge.call({caseless:I},N,x):k.isPlainObject(x)?k.merge({},x):k.isArray(x)?x.slice():x}function c(N,x,z,I){if(k.isUndefined(x)){if(!k.isUndefined(N))return f(void 0,N,z,I)}else return f(N,x,z,I)}function p(N,x){if(!k.isUndefined(x))return f(void 0,x)}function m(N,x){if(k.isUndefined(x)){if(!k.isUndefined(N))return f(void 0,N)}else return f(void 0,x)}function v(N,x,z){if(z in o)return f(N,x);if(z in s)return f(void 0,N)}const C={url:p,method:p,data:p,baseURL:m,transformRequest:m,transformResponse:m,paramsSerializer:m,timeout:m,timeoutMessage:m,withCredentials:m,withXSRFToken:m,adapter:m,responseType:m,xsrfCookieName:m,xsrfHeaderName:m,onUploadProgress:m,onDownloadProgress:m,decompress:m,maxContentLength:m,maxBodyLength:m,beforeRedirect:m,transport:m,httpAgent:m,httpsAgent:m,cancelToken:m,socketPath:m,responseEncoding:m,validateStatus:v,headers:(N,x,z)=>c(_c(N),_c(x),z,!0)};return k.forEach(Object.keys({...s,...o}),function(x){const z=C[x]||c,I=z(s[x],o[x],x);k.isUndefined(I)&&z!==v||(u[x]=I)}),u}const rf=s=>{const o=wn({},s);let{data:u,withXSRFToken:f,xsrfHeaderName:c,xsrfCookieName:p,headers:m,auth:v}=o;if(o.headers=m=rt.from(m),o.url=Yc(nf(o.baseURL,o.url,o.allowAbsoluteUrls),s.params,s.paramsSerializer),v&&m.set("Authorization","Basic "+btoa((v.username||"")+":"+(v.password?unescape(encodeURIComponent(v.password)):""))),k.isFormData(u)){if(We.hasStandardBrowserEnv||We.hasStandardBrowserWebWorkerEnv)m.setContentType(void 0);else if(k.isFunction(u.getHeaders)){const C=u.getHeaders(),N=["content-type","content-length"];Object.entries(C).forEach(([x,z])=>{N.includes(x.toLowerCase())&&m.set(x,z)})}}if(We.hasStandardBrowserEnv&&(f&&k.isFunction(f)&&(f=f(o)),f||f!==!1&&Lm(o.url))){const C=c&&p&&Am.read(p);C&&m.set(c,C)}return o},jm=typeof XMLHttpRequest<"u",Fm=jm&&function(s){return new Promise(function(u,f){const c=rf(s);let p=c.data;const m=rt.from(c.headers).normalize();let{responseType:v,onUploadProgress:C,onDownloadProgress:N}=c,x,z,I,Z,P;function j(){Z&&Z(),P&&P(),c.cancelToken&&c.cancelToken.unsubscribe(x),c.signal&&c.signal.removeEventListener("abort",x)}let L=new XMLHttpRequest;L.open(c.method.toUpperCase(),c.url,!0),L.timeout=c.timeout;function oe(){if(!L)return;const re=rt.from("getAllResponseHeaders"in L&&L.getAllResponseHeaders()),he={data:!v||v==="text"||v==="json"?L.responseText:L.response,status:L.status,statusText:L.statusText,headers:re,config:s,request:L};tf(function(se){u(se),j()},function(se){f(se),j()},he),L=null}"onloadend"in L?L.onloadend=oe:L.onreadystatechange=function(){!L||L.readyState!==4||L.status===0&&!(L.responseURL&&L.responseURL.indexOf("file:")===0)||setTimeout(oe)},L.onabort=function(){L&&(f(new Y("Request aborted",Y.ECONNABORTED,s,L)),L=null)},L.onerror=function(te){const he=te&&te.message?te.message:"Network Error",de=new Y(he,Y.ERR_NETWORK,s,L);de.event=te||null,f(de),L=null},L.ontimeout=function(){let te=c.timeout?"timeout of "+c.timeout+"ms exceeded":"timeout exceeded";const he=c.transitional||Zc;c.timeoutErrorMessage&&(te=c.timeoutErrorMessage),f(new Y(te,he.clarifyTimeoutError?Y.ETIMEDOUT:Y.ECONNABORTED,s,L)),L=null},p===void 0&&m.setContentType(null),"setRequestHeader"in L&&k.forEach(m.toJSON(),function(te,he){L.setRequestHeader(he,te)}),k.isUndefined(c.withCredentials)||(L.withCredentials=!!c.withCredentials),v&&v!=="json"&&(L.responseType=c.responseType),N&&([I,P]=ti(N,!0),L.addEventListener("progress",I)),C&&L.upload&&([z,Z]=ti(C),L.upload.addEventListener("progress",z),L.upload.addEventListener("loadend",Z)),(c.cancelToken||c.signal)&&(x=re=>{L&&(f(!re||re.type?new Kn(null,s,L):re),L.abort(),L=null)},c.cancelToken&&c.cancelToken.subscribe(x),c.signal&&(c.signal.aborted?x():c.signal.addEventListener("abort",x)));const ce=Rm(c.url);if(ce&&We.protocols.indexOf(ce)===-1){f(new Y("Unsupported protocol "+ce+":",Y.ERR_BAD_REQUEST,s));return}L.send(p||null)})},Mm=(s,o)=>{const{length:u}=s=s?s.filter(Boolean):[];if(o||u){let f=new AbortController,c;const p=function(N){if(!c){c=!0,v();const x=N instanceof Error?N:this.reason;f.abort(x instanceof Y?x:new Kn(x instanceof Error?x.message:x))}};let m=o&&setTimeout(()=>{m=null,p(new Y(`timeout ${o} of ms exceeded`,Y.ETIMEDOUT))},o);const v=()=>{s&&(m&&clearTimeout(m),m=null,s.forEach(N=>{N.unsubscribe?N.unsubscribe(p):N.removeEventListener("abort",p)}),s=null)};s.forEach(N=>N.addEventListener("abort",p));const{signal:C}=f;return C.unsubscribe=()=>k.asap(v),C}},Im=function*(s,o){let u=s.byteLength;if(u<o){yield s;return}let f=0,c;for(;f<u;)c=f+o,yield s.slice(f,c),f=c},Um=async function*(s,o){for await(const u of $m(s))yield*Im(u,o)},$m=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const o=s.getReader();try{for(;;){const{done:u,value:f}=await o.read();if(u)break;yield f}}finally{await o.cancel()}},Oc=(s,o,u,f)=>{const c=Um(s,o);let p=0,m,v=C=>{m||(m=!0,f&&f(C))};return new ReadableStream({async pull(C){try{const{done:N,value:x}=await c.next();if(N){v(),C.close();return}let z=x.byteLength;if(u){let I=p+=z;u(I)}C.enqueue(new Uint8Array(x))}catch(N){throw v(N),N}},cancel(C){return v(C),c.return()}},{highWaterMark:2})},Lc=64*1024,{isFunction:Xl}=k,Bm=(({Request:s,Response:o})=>({Request:s,Response:o}))(k.global),{ReadableStream:Ac,TextEncoder:zc}=k.global,Dc=(s,...o)=>{try{return!!s(...o)}catch{return!1}},Hm=s=>{s=k.merge.call({skipUndefined:!0},Bm,s);const{fetch:o,Request:u,Response:f}=s,c=o?Xl(o):typeof fetch=="function",p=Xl(u),m=Xl(f);if(!c)return!1;const v=c&&Xl(Ac),C=c&&(typeof zc=="function"?(P=>j=>P.encode(j))(new zc):async P=>new Uint8Array(await new u(P).arrayBuffer())),N=p&&v&&Dc(()=>{let P=!1;const j=new u(We.origin,{body:new Ac,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!j}),x=m&&v&&Dc(()=>k.isReadableStream(new f("").body)),z={stream:x&&(P=>P.body)};c&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!z[P]&&(z[P]=(j,L)=>{let oe=j&&j[P];if(oe)return oe.call(j);throw new Y(`Response type '${P}' is not supported`,Y.ERR_NOT_SUPPORT,L)})});const I=async P=>{if(P==null)return 0;if(k.isBlob(P))return P.size;if(k.isSpecCompliantForm(P))return(await new u(We.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(k.isArrayBufferView(P)||k.isArrayBuffer(P))return P.byteLength;if(k.isURLSearchParams(P)&&(P=P+""),k.isString(P))return(await C(P)).byteLength},Z=async(P,j)=>{const L=k.toFiniteNumber(P.getContentLength());return L??I(j)};return async P=>{let{url:j,method:L,data:oe,signal:ce,cancelToken:re,timeout:te,onDownloadProgress:he,onUploadProgress:de,responseType:se,headers:_e,withCredentials:Qe="same-origin",fetchOptions:Je}=rf(P),Ie=o||fetch;se=se?(se+"").toLowerCase():"text";let je=Mm([ce,re&&re.toAbortSignal()],te),xe=null;const Ce=je&&je.unsubscribe&&(()=>{je.unsubscribe()});let qe;try{if(de&&N&&L!=="get"&&L!=="head"&&(qe=await Z(_e,oe))!==0){let g=new u(j,{method:"POST",body:oe,duplex:"half"}),T;if(k.isFormData(oe)&&(T=g.headers.get("content-type"))&&_e.setContentType(T),g.body){const[J,X]=Pc(qe,ti(Rc(de)));oe=Oc(g.body,Lc,J,X)}}k.isString(Qe)||(Qe=Qe?"include":"omit");const fe=p&&"credentials"in u.prototype,W={...Je,signal:je,method:L.toUpperCase(),headers:_e.normalize().toJSON(),body:oe,duplex:"half",credentials:fe?Qe:void 0};xe=p&&new u(j,W);let _=await(p?Ie(xe,Je):Ie(j,W));const H=x&&(se==="stream"||se==="response");if(x&&(he||H&&Ce)){const g={};["status","statusText","headers"].forEach(ee=>{g[ee]=_[ee]});const T=k.toFiniteNumber(_.headers.get("content-length")),[J,X]=he&&Pc(T,ti(Rc(he),!0))||[];_=new f(Oc(_.body,Lc,J,()=>{X&&X(),Ce&&Ce()}),g)}se=se||"text";let F=await z[k.findKey(z,se)||"text"](_,P);return!H&&Ce&&Ce(),await new Promise((g,T)=>{tf(g,T,{data:F,headers:rt.from(_.headers),status:_.status,statusText:_.statusText,config:P,request:xe})})}catch(fe){throw Ce&&Ce(),fe&&fe.name==="TypeError"&&/Load failed|fetch/i.test(fe.message)?Object.assign(new Y("Network Error",Y.ERR_NETWORK,P,xe),{cause:fe.cause||fe}):Y.from(fe,fe&&fe.code,P,xe)}}},Vm=new Map,lf=s=>{let o=s?s.env:{};const{fetch:u,Request:f,Response:c}=o,p=[f,c,u];let m=p.length,v=m,C,N,x=Vm;for(;v--;)C=p[v],N=x.get(C),N===void 0&&x.set(C,N=v?new Map:Hm(o)),x=N;return N};lf();const ds={http:om,xhr:Fm,fetch:{get:lf}};k.forEach(ds,(s,o)=>{if(s){try{Object.defineProperty(s,"name",{value:o})}catch{}Object.defineProperty(s,"adapterName",{value:o})}});const jc=s=>`- ${s}`,Wm=s=>k.isFunction(s)||s===null||s===!1,of={getAdapter:(s,o)=>{s=k.isArray(s)?s:[s];const{length:u}=s;let f,c;const p={};for(let m=0;m<u;m++){f=s[m];let v;if(c=f,!Wm(f)&&(c=ds[(v=String(f)).toLowerCase()],c===void 0))throw new Y(`Unknown adapter '${v}'`);if(c&&(k.isFunction(c)||(c=c.get(o))))break;p[v||"#"+m]=c}if(!c){const m=Object.entries(p).map(([C,N])=>`adapter ${C} `+(N===!1?"is not supported by the environment":"is not available in the build"));let v=u?m.length>1?`since :
|
|
46
46
|
`+m.map(jc).join(`
|
|
47
47
|
`):" "+jc(m[0]):"as no adapter specified";throw new Y("There is no suitable adapter to dispatch the request "+v,"ERR_NOT_SUPPORT")}return c},adapters:ds};function us(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Kn(null,s)}function Fc(s){return us(s),s.headers=rt.from(s.headers),s.data=ss.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),of.getAdapter(s.adapter||Ir.adapter,s)(s).then(function(f){return us(s),f.data=ss.call(s,s.transformResponse,f),f.headers=rt.from(f.headers),f},function(f){return ef(f)||(us(s),f&&f.response&&(f.response.data=ss.call(s,s.transformResponse,f.response),f.response.headers=rt.from(f.response.headers))),Promise.reject(f)})}const sf="1.12.2",oi={};["object","boolean","number","function","string","symbol"].forEach((s,o)=>{oi[s]=function(f){return typeof f===s||"a"+(o<1?"n ":" ")+s}});const Mc={};oi.transitional=function(o,u,f){function c(p,m){return"[Axios v"+sf+"] Transitional option '"+p+"'"+m+(f?". "+f:"")}return(p,m,v)=>{if(o===!1)throw new Y(c(m," has been removed"+(u?" in "+u:"")),Y.ERR_DEPRECATED);return u&&!Mc[m]&&(Mc[m]=!0,console.warn(c(m," has been deprecated since v"+u+" and will be removed in the near future"))),o?o(p,m,v):!0}};oi.spelling=function(o){return(u,f)=>(console.warn(`${f} is likely a misspelling of ${o}`),!0)};function Qm(s,o,u){if(typeof s!="object")throw new Y("options must be an object",Y.ERR_BAD_OPTION_VALUE);const f=Object.keys(s);let c=f.length;for(;c-- >0;){const p=f[c],m=o[p];if(m){const v=s[p],C=v===void 0||m(v,p,s);if(C!==!0)throw new Y("option "+p+" must be "+C,Y.ERR_BAD_OPTION_VALUE);continue}if(u!==!0)throw new Y("Unknown option "+p,Y.ERR_BAD_OPTION)}}const ei={assertOptions:Qm,validators:oi},Rt=ei.validators;let vn=class{constructor(o){this.defaults=o||{},this.interceptors={request:new Nc,response:new Nc}}async request(o,u){try{return await this._request(o,u)}catch(f){if(f instanceof Error){let c={};Error.captureStackTrace?Error.captureStackTrace(c):c=new Error;const p=c.stack?c.stack.replace(/^.+\n/,""):"";try{f.stack?p&&!String(f.stack).endsWith(p.replace(/^.+\n.+\n/,""))&&(f.stack+=`
|
|
48
|
-
`+p):f.stack=p}catch{}}throw f}}_request(o,u){typeof o=="string"?(u=u||{},u.url=o):u=o||{},u=wn(this.defaults,u);const{transitional:f,paramsSerializer:c,headers:p}=u;f!==void 0&&ei.assertOptions(f,{silentJSONParsing:Rt.transitional(Rt.boolean),forcedJSONParsing:Rt.transitional(Rt.boolean),clarifyTimeoutError:Rt.transitional(Rt.boolean)},!1),c!=null&&(k.isFunction(c)?u.paramsSerializer={serialize:c}:ei.assertOptions(c,{encode:Rt.function,serialize:Rt.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),ei.assertOptions(u,{baseUrl:Rt.spelling("baseURL"),withXsrfToken:Rt.spelling("withXSRFToken")},!0),u.method=(u.method||this.defaults.method||"get").toLowerCase();let m=p&&k.merge(p.common,p[u.method]);p&&k.forEach(["delete","get","head","post","put","patch","common"],P=>{delete p[P]}),u.headers=rt.concat(m,p);const v=[];let C=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||(C=C&&j.synchronous,v.unshift(j.fulfilled,j.rejected))});const N=[];this.interceptors.response.forEach(function(j){N.push(j.fulfilled,j.rejected)});let x,z=0,I;if(!C){const P=[Fc.bind(this),void 0];for(P.unshift(...v),P.push(...N),I=P.length,x=Promise.resolve(u);z<I;)x=x.then(P[z++],P[z++]);return x}I=v.length;let Z=u;for(;z<I;){const P=v[z++],j=v[z++];try{Z=P(Z)}catch(L){j.call(this,L);break}}try{x=Fc.call(this,Z)}catch(P){return Promise.reject(P)}for(z=0,I=N.length;z<I;)x=x.then(N[z++],N[z++]);return x}getUri(o){o=wn(this.defaults,o);const u=nf(o.baseURL,o.url,o.allowAbsoluteUrls);return Yc(u,o.params,o.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(o){vn.prototype[o]=function(u,f){return this.request(wn(f||{},{method:o,url:u,data:(f||{}).data}))}});k.forEach(["post","put","patch"],function(o){function u(f){return function(p,m,v){return this.request(wn(v||{},{method:o,headers:f?{"Content-Type":"multipart/form-data"}:{},url:p,data:m}))}}vn.prototype[o]=u(),vn.prototype[o+"Form"]=u(!0)});let qm=class uf{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let u;this.promise=new Promise(function(p){u=p});const f=this;this.promise.then(c=>{if(!f._listeners)return;let p=f._listeners.length;for(;p-- >0;)f._listeners[p](c);f._listeners=null}),this.promise.then=c=>{let p;const m=new Promise(v=>{f.subscribe(v),p=v}).then(c);return m.cancel=function(){f.unsubscribe(p)},m},o(function(p,m,v){f.reason||(f.reason=new Kn(p,m,v),u(f.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const u=this._listeners.indexOf(o);u!==-1&&this._listeners.splice(u,1)}toAbortSignal(){const o=new AbortController,u=f=>{o.abort(f)};return this.subscribe(u),o.signal.unsubscribe=()=>this.unsubscribe(u),o.signal}static source(){let o;return{token:new uf(function(c){o=c}),cancel:o}}};function Km(s){return function(u){return s.apply(null,u)}}function Gm(s){return k.isObject(s)&&s.isAxiosError===!0}const ps={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ps).forEach(([s,o])=>{ps[o]=s});function af(s){const o=new vn(s),u=Uc(vn.prototype.request,o);return k.extend(u,vn.prototype,o,{allOwnKeys:!0}),k.extend(u,o,null,{allOwnKeys:!0}),u.create=function(c){return af(wn(s,c))},u}const Pe=af(Ir);Pe.Axios=vn;Pe.CanceledError=Kn;Pe.CancelToken=qm;Pe.isCancel=ef;Pe.VERSION=sf;Pe.toFormData=ii;Pe.AxiosError=Y;Pe.Cancel=Pe.CanceledError;Pe.all=function(o){return Promise.all(o)};Pe.spread=Km;Pe.isAxiosError=Gm;Pe.mergeConfig=wn;Pe.AxiosHeaders=rt;Pe.formToJSON=s=>bc(k.isHTMLForm(s)?new FormData(s):s);Pe.getAdapter=of.getAdapter;Pe.HttpStatusCode=ps;Pe.default=Pe;const{Axios:bm,AxiosError:eh,CanceledError:th,isCancel:nh,CancelToken:rh,VERSION:lh,all:ih,Cancel:oh,isAxiosError:sh,spread:uh,toFormData:ah,AxiosHeaders:ch,HttpStatusCode:fh,formToJSON:dh,getAdapter:ph,mergeConfig:mh}=Pe;class Yl{constructor(o){yn(this,"axiosInstance");this.axiosInstance=o}async getOData(o,u){try{return u?(await window.dataverseAPI.queryData(o)).value:(await this.axiosInstance.get("/"+o)).data.value}catch(f){throw console.error("Error fetching OData:",f),f}}}class Ic{constructor(o,u){yn(this,"axiosInstance");yn(this,"environmentUrl");yn(this,"apiVersion");yn(this,"isPPTB");this.environmentUrl=o.environmentUrl.replace(/\/$/,""),this.apiVersion=o.apiVersion||"9.2",this.isPPTB=u,this.axiosInstance=Pe.create({baseURL:`${this.environmentUrl}/api/data/v${this.apiVersion}`,headers:{Authorization:`Bearer ${o.accessToken}`,Accept:"application/json","Content-Type":"application/json","OData-MaxVersion":"4.0","OData-Version":"4.0"}})}async fetchSolution(o){var u,f,c;try{const p=new Yl(this.axiosInstance),m=await p.getOData(`solutions?$filter=uniquename eq '${o}'&$select=solutionid,friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`,this.isPPTB);if(console.log(m),!m||m.length===0)throw new Error(`Solution '${o}' not found`);const v=m[0];console.log(v);const C=((u=v.publisherid)==null?void 0:u.customizationprefix)??"unknown",N=await p.getOData(`solutioncomponents?$filter=_solutionid_value eq ${v.solutionid} and componenttype eq 1&$select=objectid`,this.isPPTB);console.log(N);const x=N.map(I=>I.objectid);console.log("tableIds",x);const z=await this.fetchTables(x);return console.log("tables",z),{uniqueName:v.uniquename,displayName:v.friendlyname,version:v.version,publisherPrefix:C,tables:z}}catch(p){throw p.response?new Error(`Dataverse API error: ${p.response.status} - ${((c=(f=p.response.data)==null?void 0:f.error)==null?void 0:c.message)||p.message}`):p}}async fetchTables(o){const u=[];for(const f of o)try{const c=await this.fetchTable(f);c&&u.push(c)}catch(c){console.warn(`Failed to fetch table ${f}:`,c)}return u}async fetchTable(o){var u,f;try{const c=new Yl(this.axiosInstance),p=await c.getOData(`EntityDefinitions(${o})?$select=LogicalName,DisplayName,SchemaName,PrimaryIdAttribute,PrimaryNameAttribute,TableType,IsIntersect`,this.isPPTB);console.log(p);const m=p,v=await c.getOData(`EntityDefinitions(${o})/Attributes?$select=LogicalName,DisplayName,AttributeType,IsPrimaryId,IsPrimaryName,RequiredLevel`,this.isPPTB);console.log(v);const C=v.map(x=>{var z,I,Z,P;return{logicalName:x.LogicalName,displayName:((I=(z=x.DisplayName)==null?void 0:z.UserLocalizedLabel)==null?void 0:I.Label)||x.LogicalName,type:this.mapAttributeType(x.AttributeType),isPrimaryId:x.IsPrimaryId||!1,isPrimaryName:x.IsPrimaryName||!1,isRequired:((Z=x.RequiredLevel)==null?void 0:Z.Value)==="ApplicationRequired"||((P=x.RequiredLevel)==null?void 0:P.Value)==="SystemRequired"}}),N=await this.fetchRelationships(o,m.LogicalName);return{logicalName:m.LogicalName,displayName:((f=(u=m.DisplayName)==null?void 0:u.UserLocalizedLabel)==null?void 0:f.Label)||m.LogicalName,schemaName:m.SchemaName,primaryIdAttribute:m.PrimaryIdAttribute,primaryNameAttribute:m.PrimaryNameAttribute,isIntersect:m.IsIntersect||!1,tableType:m.TableType,attributes:C,relationships:N}}catch(c){return console.warn(`Failed to fetch table metadata for ${o}:`,c),null}}async fetchRelationships(o,u){const f=[],c=new Yl(this.axiosInstance);try{const p=await c.getOData(`EntityDefinitions(${o})/OneToManyRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`,this.isPPTB);console.log(p);for(const C of p)C.ReferencedEntity===u&&f.push({schemaName:C.SchemaName,type:"OneToMany",relatedTable:C.ReferencingEntity,lookupAttribute:C.ReferencingAttribute});const m=await c.getOData(`EntityDefinitions(${o})/ManyToOneRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`,this.isPPTB);console.log(m);for(const C of m)C.ReferencingEntity===u&&f.push({schemaName:C.SchemaName,type:"ManyToOne",relatedTable:C.ReferencedEntity,lookupAttribute:C.ReferencingAttribute});const v=await c.getOData(`EntityDefinitions(${o})/ManyToManyRelationships?$select=SchemaName,Entity1LogicalName,Entity2LogicalName,IntersectEntityName`,this.isPPTB);console.log(v);for(const C of v){const N=C.Entity1LogicalName===u;f.push({schemaName:C.SchemaName,type:"ManyToMany",relatedTable:N?C.Entity2LogicalName:C.Entity1LogicalName,intersectTable:C.IntersectEntityName})}}catch(p){console.warn(`Failed to fetch relationships for ${u}:`,p)}return f}mapAttributeType(o){return{String:"string",Memo:"string",Integer:"int",BigInt:"int",Decimal:"decimal",Double:"decimal",Money:"money",DateTime:"datetime",Boolean:"boolean",Lookup:"lookup",Customer:"lookup",Owner:"lookup",Picklist:"picklist",State:"picklist",Status:"picklist",Uniqueidentifier:"guid"}[o]||"string"}async listSolutions(){var o,u;try{const c=await new Yl(this.axiosInstance).getOData("solutions?$select=uniquename,friendlyname,version&$filter=isvisible eq true&$orderby=friendlyname asc",this.isPPTB);return console.log(c),c.map(p=>({uniqueName:p.uniquename,displayName:p.friendlyname,version:p.version}))}catch(f){throw f.response?new Error(`Dataverse API error: ${f.response.status} - ${((u=(o=f.response.data)==null?void 0:o.error)==null?void 0:u.message)||f.message}`):f}}}function Jm(){const[s,o]=Ve.useState(!1),[u,f]=Ve.useState(""),[c,p]=Ve.useState(""),[m,v]=Ve.useState([]),[C,N]=Ve.useState(""),[x,z]=Ve.useState("mermaid"),[I,Z]=Ve.useState(!0),[P,j]=Ve.useState(""),[L,oe]=Ve.useState(""),[ce,re]=Ve.useState("visual"),[te,he]=Ve.useState(!0),[de,se]=Ve.useState(!0),[_e,Qe]=Ve.useState(10);Ve.useEffect(()=>{(async()=>{if(typeof window.acquireVsCodeApi<"u"){o(!1),Z(!0);const _=H=>{const F=H.data;F.command==="setCredentials"&&(f(F.environmentUrl),p(F.accessToken),Z(!1))};return window.addEventListener("message",_),()=>{window.removeEventListener("message",_)}}else if(window.toolboxAPI){o(!0);try{const _=await window.toolboxAPI.connections.getActiveConnection();f((_==null?void 0:_.url)||"")}catch(_){console.error("Failed to get tool context:",_)}Z(!1)}else j("Not running in supported environment (DVDT or PPTB)"),Z(!1)})()},[]),Ve.useEffect(()=>{u&&Je()},[u]);const Je=async()=>{try{const _=await new Ic({environmentUrl:u,accessToken:c},s).listSolutions();v(_)}catch(W){Ie(`Failed to load solutions: ${W.message}`)}},Ie=W=>{j(W),setTimeout(()=>j(""),5e3)},je=async()=>{if(!C){Ie("Please select a solution first");return}try{Z(!0);const _=await new Ic({environmentUrl:u,accessToken:c},s).fetchSolution(C),F=new Sp({format:x,includeAttributes:te,includeRelationships:de,maxAttributesPerTable:_e}).generate(_);oe(F),s&&await window.toolboxAPI.utils.showNotification({title:"Success",body:"ERD generated successfully",type:"success"})}catch(W){Ie(`Failed to generate ERD: ${W.message}`)}finally{Z(!1)}},xe=async()=>{if(!L)return;const _=`${C}-erd.${{mermaid:"mmd",plantuml:"puml",graphviz:"dot"}[x]}`;try{s||await window.toolboxAPI.utils.saveFile(_,L)&&await window.toolboxAPI.utils.showNotification({title:"Success",body:"File saved successfully",type:"success"})}catch(H){Ie(`Failed to save file: ${H.message}`)}},Ce=async()=>{if(L)try{s||(await window.toolboxAPI.utils.copyToClipboard(L),await window.toolboxAPI.utils.showNotification({title:"Success",body:"Copied to clipboard",type:"success"}))}catch(W){Ie(`Failed to copy: ${W.message}`)}},qe=async()=>{if(window.mermaid)return;const W=await wp(()=>import("./mermaid.core.js").then(H=>H.b8),[]),_=W.default??W;_.initialize({startOnLoad:!1,theme:"default",themeVariables:{primaryColor:"#0e639c",primaryTextColor:"#fff",primaryBorderColor:"#0a4f7c",lineColor:"#0e639c",secondaryColor:"#f3f4f6",tertiaryColor:"#e5e7eb"}}),window.mermaid=_},fe=()=>L?ce==="visual"&&x==="mermaid"?Q.jsx("div",{className:"mermaid",ref:W=>{(async()=>{if(W)try{W.textContent=L,await qe(),window.mermaid&&window.mermaid.init(void 0,W)}catch(_){console.error("Mermaid rendering error:",_)}})()}}):Q.jsx("pre",{className:"diagram-text",children:L}):null;return I?Q.jsx("div",{className:"container",children:Q.jsx("div",{className:"loading",children:"Loading..."})}):Q.jsxs("div",{className:"container",children:[Q.jsxs("header",{className:"header",children:[Q.jsx("h1",{children:"πΊοΈ Dataverse ERD Generator"}),Q.jsx("p",{children:"Generate Entity Relationship Diagrams from your Dataverse solutions"})]}),P&&Q.jsx("div",{className:"error",children:P}),Q.jsxs("div",{className:"card",children:[Q.jsxs("div",{className:"info-message",children:[Q.jsx("strong",{children:"β Connected to Dataverse"}),Q.jsx("br",{}),"Environment: ",Q.jsx("span",{children:u||"Not connected"})]}),Q.jsxs("div",{className:"form-group",children:[Q.jsx("label",{htmlFor:"solutionSelect",children:"Select a Solution"}),Q.jsxs("select",{id:"solutionSelect",value:C,onChange:W=>N(W.target.value),disabled:m.length===0,children:[Q.jsx("option",{value:"",children:"-- Select a Solution --"}),m.map(W=>Q.jsxs("option",{value:W.uniqueName,children:[W.displayName," (",W.version,")"]},W.uniqueName))]})]}),Q.jsxs("div",{className:"generate-section",children:[Q.jsx("h2",{children:"Generate ERD"}),Q.jsxs("div",{className:"format-selector",children:[Q.jsx("label",{style:{fontWeight:600,marginRight:"10px"},children:"Output Format:"}),Q.jsx("button",{className:`format-btn ${x==="mermaid"?"active":""}`,onClick:()=>z("mermaid"),children:"Mermaid"}),Q.jsx("button",{className:`format-btn ${x==="plantuml"?"active":""}`,onClick:()=>z("plantuml"),children:"PlantUML"}),Q.jsx("button",{className:`format-btn ${x==="graphviz"?"active":""}`,onClick:()=>z("graphviz"),children:"Graphviz"})]}),Q.jsxs("div",{className:"config-section",children:[Q.jsx("h3",{children:"Configuration"}),Q.jsxs("div",{className:"config-group",children:[Q.jsxs("label",{children:[Q.jsx("input",{type:"checkbox",checked:te,onChange:W=>he(W.target.checked)}),Q.jsx("span",{children:"Include Attributes"})]}),Q.jsx("div",{className:"config-help",children:"Show table columns/fields in the diagram"})]}),Q.jsxs("div",{className:"config-group",children:[Q.jsxs("label",{children:[Q.jsx("input",{type:"checkbox",checked:de,onChange:W=>se(W.target.checked)}),Q.jsx("span",{children:"Include Relationships"})]}),Q.jsx("div",{className:"config-help",children:"Show relationships between tables"})]}),Q.jsxs("div",{className:"config-group",children:[Q.jsxs("div",{className:"config-label-group",children:[Q.jsx("label",{htmlFor:"maxAttributesInput",children:"Max Attributes per Table:"}),Q.jsx("input",{type:"number",id:"maxAttributesInput",value:_e,onChange:W=>Qe(parseInt(W.target.value)||0),min:"0",max:"100"})]}),Q.jsx("div",{className:"config-help",children:"Maximum number of attributes to display per table (0 = show all)"})]})]}),Q.jsx("button",{className:"btn btn-primary",onClick:je,disabled:!C||I,children:"Generate ERD"})]})]}),L&&Q.jsxs("div",{className:"card",children:[Q.jsx("h2",{children:"Generated ERD"}),Q.jsxs("div",{className:"diagram-controls",children:[x==="mermaid"&&Q.jsx("button",{className:"btn btn-secondary",onClick:()=>re(ce==="visual"?"text":"visual"),children:ce==="visual"?"π Show Text":"π¨ Show Visual"}),Q.jsx("button",{className:"btn btn-secondary",onClick:xe,children:"π₯ Download Source"}),Q.jsx("button",{className:"btn btn-secondary",onClick:Ce,children:"π Copy to Clipboard"})]}),Q.jsx("div",{className:"diagram-container",children:fe()})]})]})}yp.createRoot(document.getElementById("root")).render(Q.jsx(Ve.StrictMode,{children:Q.jsx(Jm,{})}));export{wp as _};
|
|
48
|
+
`+p):f.stack=p}catch{}}throw f}}_request(o,u){typeof o=="string"?(u=u||{},u.url=o):u=o||{},u=wn(this.defaults,u);const{transitional:f,paramsSerializer:c,headers:p}=u;f!==void 0&&ei.assertOptions(f,{silentJSONParsing:Rt.transitional(Rt.boolean),forcedJSONParsing:Rt.transitional(Rt.boolean),clarifyTimeoutError:Rt.transitional(Rt.boolean)},!1),c!=null&&(k.isFunction(c)?u.paramsSerializer={serialize:c}:ei.assertOptions(c,{encode:Rt.function,serialize:Rt.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),ei.assertOptions(u,{baseUrl:Rt.spelling("baseURL"),withXsrfToken:Rt.spelling("withXSRFToken")},!0),u.method=(u.method||this.defaults.method||"get").toLowerCase();let m=p&&k.merge(p.common,p[u.method]);p&&k.forEach(["delete","get","head","post","put","patch","common"],P=>{delete p[P]}),u.headers=rt.concat(m,p);const v=[];let C=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||(C=C&&j.synchronous,v.unshift(j.fulfilled,j.rejected))});const N=[];this.interceptors.response.forEach(function(j){N.push(j.fulfilled,j.rejected)});let x,z=0,I;if(!C){const P=[Fc.bind(this),void 0];for(P.unshift(...v),P.push(...N),I=P.length,x=Promise.resolve(u);z<I;)x=x.then(P[z++],P[z++]);return x}I=v.length;let Z=u;for(;z<I;){const P=v[z++],j=v[z++];try{Z=P(Z)}catch(L){j.call(this,L);break}}try{x=Fc.call(this,Z)}catch(P){return Promise.reject(P)}for(z=0,I=N.length;z<I;)x=x.then(N[z++],N[z++]);return x}getUri(o){o=wn(this.defaults,o);const u=nf(o.baseURL,o.url,o.allowAbsoluteUrls);return Yc(u,o.params,o.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(o){vn.prototype[o]=function(u,f){return this.request(wn(f||{},{method:o,url:u,data:(f||{}).data}))}});k.forEach(["post","put","patch"],function(o){function u(f){return function(p,m,v){return this.request(wn(v||{},{method:o,headers:f?{"Content-Type":"multipart/form-data"}:{},url:p,data:m}))}}vn.prototype[o]=u(),vn.prototype[o+"Form"]=u(!0)});let qm=class uf{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let u;this.promise=new Promise(function(p){u=p});const f=this;this.promise.then(c=>{if(!f._listeners)return;let p=f._listeners.length;for(;p-- >0;)f._listeners[p](c);f._listeners=null}),this.promise.then=c=>{let p;const m=new Promise(v=>{f.subscribe(v),p=v}).then(c);return m.cancel=function(){f.unsubscribe(p)},m},o(function(p,m,v){f.reason||(f.reason=new Kn(p,m,v),u(f.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const u=this._listeners.indexOf(o);u!==-1&&this._listeners.splice(u,1)}toAbortSignal(){const o=new AbortController,u=f=>{o.abort(f)};return this.subscribe(u),o.signal.unsubscribe=()=>this.unsubscribe(u),o.signal}static source(){let o;return{token:new uf(function(c){o=c}),cancel:o}}};function Km(s){return function(u){return s.apply(null,u)}}function Gm(s){return k.isObject(s)&&s.isAxiosError===!0}const ps={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ps).forEach(([s,o])=>{ps[o]=s});function af(s){const o=new vn(s),u=Uc(vn.prototype.request,o);return k.extend(u,vn.prototype,o,{allOwnKeys:!0}),k.extend(u,o,null,{allOwnKeys:!0}),u.create=function(c){return af(wn(s,c))},u}const Pe=af(Ir);Pe.Axios=vn;Pe.CanceledError=Kn;Pe.CancelToken=qm;Pe.isCancel=ef;Pe.VERSION=sf;Pe.toFormData=ii;Pe.AxiosError=Y;Pe.Cancel=Pe.CanceledError;Pe.all=function(o){return Promise.all(o)};Pe.spread=Km;Pe.isAxiosError=Gm;Pe.mergeConfig=wn;Pe.AxiosHeaders=rt;Pe.formToJSON=s=>bc(k.isHTMLForm(s)?new FormData(s):s);Pe.getAdapter=of.getAdapter;Pe.HttpStatusCode=ps;Pe.default=Pe;const{Axios:bm,AxiosError:eh,CanceledError:th,isCancel:nh,CancelToken:rh,VERSION:lh,all:ih,Cancel:oh,isAxiosError:sh,spread:uh,toFormData:ah,AxiosHeaders:ch,HttpStatusCode:fh,formToJSON:dh,getAdapter:ph,mergeConfig:mh}=Pe;class Yl{constructor(o){yn(this,"axiosInstance");this.axiosInstance=o}async getOData(o,u){try{return u?(await window.dataverseAPI.queryData(o)).value:(await this.axiosInstance.get("/"+o)).data.value}catch(f){throw console.error("Error fetching OData:",f),f}}}class Ic{constructor(o,u){yn(this,"axiosInstance");yn(this,"environmentUrl");yn(this,"apiVersion");yn(this,"isPPTB");this.environmentUrl=o.environmentUrl.replace(/\/$/,""),this.apiVersion=o.apiVersion||"9.2",this.isPPTB=u,this.axiosInstance=Pe.create({baseURL:`${this.environmentUrl}/api/data/v${this.apiVersion}`,headers:{Authorization:`Bearer ${o.accessToken}`,Accept:"application/json","Content-Type":"application/json","OData-MaxVersion":"4.0","OData-Version":"4.0"}})}async fetchSolution(o){var u,f,c;try{const p=new Yl(this.axiosInstance),m=await p.getOData(`solutions?$filter=uniquename eq '${o}'&$select=solutionid,friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`,this.isPPTB);if(console.log("Solution Metadata",m),!m||m.length===0)throw new Error(`Solution '${o}' not found`);const v=m[0];console.log("Solution Data",v);const C=((u=v.publisherid)==null?void 0:u.customizationprefix)??"unknown",N=await p.getOData(`solutioncomponents?$filter=_solutionid_value eq ${v.solutionid} and componenttype eq 1&$select=objectid`,this.isPPTB);console.log("Component List",N);const x=N.map(I=>I.objectid);console.log("Table IDs",x);const z=await this.fetchTables(x);return console.log("Tables",z),{uniqueName:v.uniquename,displayName:v.friendlyname,version:v.version,publisherPrefix:C,tables:z}}catch(p){throw p.response?new Error(`Dataverse API error: ${p.response.status} - ${((c=(f=p.response.data)==null?void 0:f.error)==null?void 0:c.message)||p.message}`):p}}async fetchTables(o){const u=[];for(const f of o)try{const c=await this.fetchTable(f);c&&u.push(c)}catch(c){console.warn(`Failed to fetch table ${f}:`,c)}return u}async fetchTable(o){var u,f;try{const c=new Yl(this.axiosInstance),p=await c.getOData(`EntityDefinitions(${o})?$select=LogicalName,DisplayName,SchemaName,PrimaryIdAttribute,PrimaryNameAttribute,TableType,IsIntersect`,this.isPPTB);console.log("Entity Metadata",p);const m=p,v=await c.getOData(`EntityDefinitions(${o})/Attributes?$select=LogicalName,DisplayName,AttributeType,IsPrimaryId,IsPrimaryName,RequiredLevel`,this.isPPTB);console.log("Entity Attributes",v);const C=v.map(x=>{var z,I,Z,P;return{logicalName:x.LogicalName,displayName:((I=(z=x.DisplayName)==null?void 0:z.UserLocalizedLabel)==null?void 0:I.Label)||x.LogicalName,type:this.mapAttributeType(x.AttributeType),isPrimaryId:x.IsPrimaryId||!1,isPrimaryName:x.IsPrimaryName||!1,isRequired:((Z=x.RequiredLevel)==null?void 0:Z.Value)==="ApplicationRequired"||((P=x.RequiredLevel)==null?void 0:P.Value)==="SystemRequired"}}),N=await this.fetchRelationships(o,m.LogicalName);return{logicalName:m.LogicalName,displayName:((f=(u=m.DisplayName)==null?void 0:u.UserLocalizedLabel)==null?void 0:f.Label)||m.LogicalName,schemaName:m.SchemaName,primaryIdAttribute:m.PrimaryIdAttribute,primaryNameAttribute:m.PrimaryNameAttribute,isIntersect:m.IsIntersect||!1,tableType:m.TableType,attributes:C,relationships:N}}catch(c){return console.warn(`Failed to fetch table metadata for ${o}:`,c),null}}async fetchRelationships(o,u){const f=[],c=new Yl(this.axiosInstance);try{const p=await c.getOData(`EntityDefinitions(${o})/OneToManyRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`,this.isPPTB);console.log("One-to-Many Relationships",p);for(const C of p)C.ReferencedEntity===u&&f.push({schemaName:C.SchemaName,type:"OneToMany",relatedTable:C.ReferencingEntity,lookupAttribute:C.ReferencingAttribute});const m=await c.getOData(`EntityDefinitions(${o})/ManyToOneRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`,this.isPPTB);console.log("Many-to-One Relationships",m);for(const C of m)C.ReferencingEntity===u&&f.push({schemaName:C.SchemaName,type:"ManyToOne",relatedTable:C.ReferencedEntity,lookupAttribute:C.ReferencingAttribute});const v=await c.getOData(`EntityDefinitions(${o})/ManyToManyRelationships?$select=SchemaName,Entity1LogicalName,Entity2LogicalName,IntersectEntityName`,this.isPPTB);console.log("Many-to-Many Relationships",v);for(const C of v){const N=C.Entity1LogicalName===u;f.push({schemaName:C.SchemaName,type:"ManyToMany",relatedTable:N?C.Entity2LogicalName:C.Entity1LogicalName,intersectTable:C.IntersectEntityName})}}catch(p){console.warn(`Failed to fetch relationships for ${u}:`,p)}return f}mapAttributeType(o){return{String:"string",Memo:"string",Integer:"int",BigInt:"int",Decimal:"decimal",Double:"decimal",Money:"money",DateTime:"datetime",Boolean:"boolean",Lookup:"lookup",Customer:"lookup",Owner:"lookup",Picklist:"picklist",State:"picklist",Status:"picklist",Uniqueidentifier:"guid"}[o]||"string"}async listSolutions(){var o,u;try{const c=await new Yl(this.axiosInstance).getOData("solutions?$select=uniquename,friendlyname,version&$filter=isvisible eq true&$orderby=friendlyname asc",this.isPPTB);return console.log("Solutions",c),c.map(p=>({uniqueName:p.uniquename,displayName:p.friendlyname,version:p.version}))}catch(f){throw f.response?new Error(`Dataverse API error: ${f.response.status} - ${((u=(o=f.response.data)==null?void 0:o.error)==null?void 0:u.message)||f.message}`):f}}}function Jm(){const[s,o]=Ve.useState(!1),[u,f]=Ve.useState(""),[c,p]=Ve.useState(""),[m,v]=Ve.useState([]),[C,N]=Ve.useState(""),[x,z]=Ve.useState("mermaid"),[I,Z]=Ve.useState(!0),[P,j]=Ve.useState(""),[L,oe]=Ve.useState(""),[ce,re]=Ve.useState("visual"),[te,he]=Ve.useState(!0),[de,se]=Ve.useState(!0),[_e,Qe]=Ve.useState(10);Ve.useEffect(()=>{(async()=>{if(typeof window.acquireVsCodeApi<"u"){o(!1),Z(!0);const _=H=>{const F=H.data;F.command==="setCredentials"&&(f(F.environmentUrl),p(F.accessToken),Z(!1))};return window.addEventListener("message",_),()=>{window.removeEventListener("message",_)}}else if(window.toolboxAPI){o(!0);try{const _=await window.toolboxAPI.connections.getActiveConnection();f((_==null?void 0:_.url)||"")}catch(_){console.error("Failed to get tool context:",_)}Z(!1)}else j("Not running in supported environment (DVDT or PPTB)"),Z(!1)})()},[]),Ve.useEffect(()=>{u&&Je()},[u]);const Je=async()=>{try{const _=await new Ic({environmentUrl:u,accessToken:c},s).listSolutions();v(_)}catch(W){Ie(`Failed to load solutions: ${W.message}`)}},Ie=W=>{j(W),setTimeout(()=>j(""),5e3)},je=async()=>{if(!C){Ie("Please select a solution first");return}try{Z(!0);const _=await new Ic({environmentUrl:u,accessToken:c},s).fetchSolution(C),F=new Sp({format:x,includeAttributes:te,includeRelationships:de,maxAttributesPerTable:_e}).generate(_);oe(F),s&&await window.toolboxAPI.utils.showNotification({title:"Success",body:"ERD generated successfully",type:"success"})}catch(W){Ie(`Failed to generate ERD: ${W.message}`)}finally{Z(!1)}},xe=async()=>{if(!L)return;const _=`${C}-erd.${{mermaid:"mmd",plantuml:"puml",graphviz:"dot"}[x]}`;try{s||await window.toolboxAPI.utils.saveFile(_,L)&&await window.toolboxAPI.utils.showNotification({title:"Success",body:"File saved successfully",type:"success"})}catch(H){Ie(`Failed to save file: ${H.message}`)}},Ce=async()=>{if(L)try{s||(await window.toolboxAPI.utils.copyToClipboard(L),await window.toolboxAPI.utils.showNotification({title:"Success",body:"Copied to clipboard",type:"success"}))}catch(W){Ie(`Failed to copy: ${W.message}`)}},qe=async()=>{if(window.mermaid)return;const W=await wp(()=>import("./mermaid.core.js").then(H=>H.b8),[]),_=W.default??W;_.initialize({startOnLoad:!1,theme:"default",themeVariables:{primaryColor:"#0e639c",primaryTextColor:"#fff",primaryBorderColor:"#0a4f7c",lineColor:"#0e639c",secondaryColor:"#f3f4f6",tertiaryColor:"#e5e7eb"}}),window.mermaid=_},fe=()=>L?ce==="visual"&&x==="mermaid"?Q.jsx("div",{className:"mermaid",ref:W=>{(async()=>{if(W)try{W.textContent=L,await qe(),window.mermaid&&window.mermaid.init(void 0,W)}catch(_){console.error("Mermaid rendering error:",_)}})()}}):Q.jsx("pre",{className:"diagram-text",children:L}):null;return I?Q.jsx("div",{className:"container",children:Q.jsx("div",{className:"loading",children:"Loading..."})}):Q.jsxs("div",{className:"container",children:[Q.jsxs("header",{className:"header",children:[Q.jsx("h1",{children:"πΊοΈ Dataverse ERD Generator"}),Q.jsx("p",{children:"Generate Entity Relationship Diagrams from your Dataverse solutions"})]}),P&&Q.jsx("div",{className:"error",children:P}),Q.jsxs("div",{className:"card",children:[Q.jsxs("div",{className:"info-message",children:[Q.jsx("strong",{children:"β Connected to Dataverse"}),Q.jsx("br",{}),"Environment: ",Q.jsx("span",{children:u||"Not connected"})]}),Q.jsxs("div",{className:"form-group",children:[Q.jsx("label",{htmlFor:"solutionSelect",children:"Select a Solution"}),Q.jsxs("select",{id:"solutionSelect",value:C,onChange:W=>N(W.target.value),disabled:m.length===0,children:[Q.jsx("option",{value:"",children:"-- Select a Solution --"}),m.map(W=>Q.jsxs("option",{value:W.uniqueName,children:[W.displayName," (",W.version,")"]},W.uniqueName))]})]}),Q.jsxs("div",{className:"generate-section",children:[Q.jsx("h2",{children:"Generate ERD"}),Q.jsxs("div",{className:"format-selector",children:[Q.jsx("label",{style:{fontWeight:600,marginRight:"10px"},children:"Output Format:"}),Q.jsx("button",{className:`format-btn ${x==="mermaid"?"active":""}`,onClick:()=>z("mermaid"),children:"Mermaid"}),Q.jsx("button",{className:`format-btn ${x==="plantuml"?"active":""}`,onClick:()=>z("plantuml"),children:"PlantUML"}),Q.jsx("button",{className:`format-btn ${x==="graphviz"?"active":""}`,onClick:()=>z("graphviz"),children:"Graphviz"})]}),Q.jsxs("div",{className:"config-section",children:[Q.jsx("h3",{children:"Configuration"}),Q.jsxs("div",{className:"config-group",children:[Q.jsxs("label",{children:[Q.jsx("input",{type:"checkbox",checked:te,onChange:W=>he(W.target.checked)}),Q.jsx("span",{children:"Include Attributes"})]}),Q.jsx("div",{className:"config-help",children:"Show table columns/fields in the diagram"})]}),Q.jsxs("div",{className:"config-group",children:[Q.jsxs("label",{children:[Q.jsx("input",{type:"checkbox",checked:de,onChange:W=>se(W.target.checked)}),Q.jsx("span",{children:"Include Relationships"})]}),Q.jsx("div",{className:"config-help",children:"Show relationships between tables"})]}),Q.jsxs("div",{className:"config-group",children:[Q.jsxs("div",{className:"config-label-group",children:[Q.jsx("label",{htmlFor:"maxAttributesInput",children:"Max Attributes per Table:"}),Q.jsx("input",{type:"number",id:"maxAttributesInput",value:_e,onChange:W=>Qe(parseInt(W.target.value)||0),min:"0",max:"100"})]}),Q.jsx("div",{className:"config-help",children:"Maximum number of attributes to display per table (0 = show all)"})]})]}),Q.jsx("button",{className:"btn btn-primary",onClick:je,disabled:!C||I,children:"Generate ERD"})]})]}),L&&Q.jsxs("div",{className:"card",children:[Q.jsx("h2",{children:"Generated ERD"}),Q.jsxs("div",{className:"diagram-controls",children:[x==="mermaid"&&Q.jsx("button",{className:"btn btn-secondary",onClick:()=>re(ce==="visual"?"text":"visual"),children:ce==="visual"?"π Show Text":"π¨ Show Visual"}),Q.jsx("button",{className:"btn btn-secondary",onClick:xe,children:"π₯ Download Source"}),Q.jsx("button",{className:"btn btn-secondary",onClick:Ce,children:"π Copy to Clipboard"})]}),Q.jsx("div",{className:"diagram-container",children:fe()})]})]})}yp.createRoot(document.getElementById("root")).render(Q.jsx(Ve.StrictMode,{children:Q.jsx(Jm,{})}));export{wp as _};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@power-maverick/tool-erd-generator",
|
|
3
3
|
"displayName": "ERD Generator",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"description": "Generate Entity Relationship Diagrams (ERD) for Dataverse solutions - React-based tool for PowerPlatform ToolBox",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|