@power-maverick/tool-erd-generator 0.1.2 β 0.1.3
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 m(p){const v=Dr(p);f[v]||(Pm(c,p),f[v]=!0)}return k.isArray(o)?o.forEach(m):m(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 os(s,o){const u=this||Fr,f=o||u,c=rt.from(f.headers);let m=f.data;return k.forEach(s,function(v){m=v.call(u,m,c.normalize(),o?o.status:void 0)}),c.normalize(),m}function bc(s){return!!(s&&s.__CANCEL__)}function Kn(s,o,u){Z.call(this,s??"canceled",Z.ERR_CANCELED,o,u),this.name="CanceledError"}k.inherits(Kn,Z,{__CANCEL__:!0});function ef(s,o,u){const f=u.config.validateStatus;!u.status||!f||f(u.status)?s(u):o(new Z("Request failed with status code "+u.status,[Z.ERR_BAD_REQUEST,Z.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 Cm(s,o){s=s||10;const u=new Array(s),f=new Array(s);let c=0,m=0,p;return o=o!==void 0?o:1e3,function(T){const N=Date.now(),x=f[m];p||(p=N),u[c]=T,f[c]=N;let A=m,M=0;for(;A!==c;)M+=u[A++],A=A%s;if(c=(c+1)%s,c===m&&(m=(m+1)%s),N-p<o)return;const V=x&&N-x;return V?Math.round(M*1e3/V):void 0}}function _m(s,o){let u=0,f=1e3/o,c,m;const p=(N,x=Date.now())=>{u=x,c=null,m&&(clearTimeout(m),m=null),s(...N)};return[(...N)=>{const x=Date.now(),A=x-u;A>=f?p(N,x):(c=N,m||(m=setTimeout(()=>{m=null,p(c)},f-A)))},()=>c&&p(c)]}const ei=(s,o,u=3)=>{let f=0;const c=Cm(50,250);return _m(m=>{const p=m.loaded,v=m.lengthComputable?m.total:void 0,T=p-f,N=c(T),x=p<=v;f=p;const A={loaded:p,total:v,progress:v?p/v:void 0,bytes:T,rate:N||void 0,estimated:N&&v&&x?(v-p)/N:void 0,event:m,lengthComputable:v!=null,[o?"download":"upload"]:!0};s(A)},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)),Om=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,Lm=We.hasStandardBrowserEnv?{write(s,o,u,f,c,m){const p=[s+"="+encodeURIComponent(o)];k.isNumber(u)&&p.push("expires="+new Date(u).toGMTString()),k.isString(f)&&p.push("path="+f),k.isString(c)&&p.push("domain="+c),m===!0&&p.push("secure"),document.cookie=p.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 Am(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function zm(s,o){return o?s.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):s}function tf(s,o,u){let f=!Am(o);return s&&(f||u==!1)?zm(s,o):o}const Cc=s=>s instanceof rt?{...s}:s;function vn(s,o){o=o||{};const u={};function f(N,x,A,M){return k.isPlainObject(N)&&k.isPlainObject(x)?k.merge.call({caseless:M},N,x):k.isPlainObject(x)?k.merge({},x):k.isArray(x)?x.slice():x}function c(N,x,A,M){if(k.isUndefined(x)){if(!k.isUndefined(N))return f(void 0,N,A,M)}else return f(N,x,A,M)}function m(N,x){if(!k.isUndefined(x))return f(void 0,x)}function p(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,A){if(A in o)return f(N,x);if(A in s)return f(void 0,N)}const T={url:m,method:m,data:m,baseURL:p,transformRequest:p,transformResponse:p,paramsSerializer:p,timeout:p,timeoutMessage:p,withCredentials:p,withXSRFToken:p,adapter:p,responseType:p,xsrfCookieName:p,xsrfHeaderName:p,onUploadProgress:p,onDownloadProgress:p,decompress:p,maxContentLength:p,maxBodyLength:p,beforeRedirect:p,transport:p,httpAgent:p,httpsAgent:p,cancelToken:p,socketPath:p,responseEncoding:p,validateStatus:v,headers:(N,x,A)=>c(Cc(N),Cc(x),A,!0)};return k.forEach(Object.keys({...s,...o}),function(x){const A=T[x]||c,M=A(s[x],o[x],x);k.isUndefined(M)&&A!==v||(u[x]=M)}),u}const nf=s=>{const o=vn({},s);let{data:u,withXSRFToken:f,xsrfHeaderName:c,xsrfCookieName:m,headers:p,auth:v}=o;if(o.headers=p=rt.from(p),o.url=Xc(tf(o.baseURL,o.url,o.allowAbsoluteUrls),s.params,s.paramsSerializer),v&&p.set("Authorization","Basic "+btoa((v.username||"")+":"+(v.password?unescape(encodeURIComponent(v.password)):""))),k.isFormData(u)){if(We.hasStandardBrowserEnv||We.hasStandardBrowserWebWorkerEnv)p.setContentType(void 0);else if(k.isFunction(u.getHeaders)){const T=u.getHeaders(),N=["content-type","content-length"];Object.entries(T).forEach(([x,A])=>{N.includes(x.toLowerCase())&&p.set(x,A)})}}if(We.hasStandardBrowserEnv&&(f&&k.isFunction(f)&&(f=f(o)),f||f!==!1&&Om(o.url))){const T=c&&m&&Lm.read(m);T&&p.set(c,T)}return o},Dm=typeof XMLHttpRequest<"u",jm=Dm&&function(s){return new Promise(function(u,f){const c=nf(s);let m=c.data;const p=rt.from(c.headers).normalize();let{responseType:v,onUploadProgress:T,onDownloadProgress:N}=c,x,A,M,V,R;function j(){V&&V(),R&&R(),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};ef(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 Z("Request aborted",Z.ECONNABORTED,s,L)),L=null)},L.onerror=function(te){const he=te&&te.message?te.message:"Network Error",de=new Z(he,Z.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||Yc;c.timeoutErrorMessage&&(te=c.timeoutErrorMessage),f(new Z(te,he.clarifyTimeoutError?Z.ETIMEDOUT:Z.ECONNABORTED,s,L)),L=null},m===void 0&&p.setContentType(null),"setRequestHeader"in L&&k.forEach(p.toJSON(),function(te,he){L.setRequestHeader(he,te)}),k.isUndefined(c.withCredentials)||(L.withCredentials=!!c.withCredentials),v&&v!=="json"&&(L.responseType=c.responseType),N&&([M,R]=ei(N,!0),L.addEventListener("progress",M)),T&&L.upload&&([A,V]=ei(T),L.upload.addEventListener("progress",A),L.upload.addEventListener("loadend",V)),(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 Z("Unsupported protocol "+ce+":",Z.ERR_BAD_REQUEST,s));return}L.send(m||null)})},Mm=(s,o)=>{const{length:u}=s=s?s.filter(Boolean):[];if(o||u){let f=new AbortController,c;const m=function(N){if(!c){c=!0,v();const x=N instanceof Error?N:this.reason;f.abort(x instanceof Z?x:new Kn(x instanceof Error?x.message:x))}};let p=o&&setTimeout(()=>{p=null,m(new Z(`timeout ${o} of ms exceeded`,Z.ETIMEDOUT))},o);const v=()=>{s&&(p&&clearTimeout(p),p=null,s.forEach(N=>{N.unsubscribe?N.unsubscribe(m):N.removeEventListener("abort",m)}),s=null)};s.forEach(N=>N.addEventListener("abort",m));const{signal:T}=f;return T.unsubscribe=()=>k.asap(v),T}},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},Fm=async function*(s,o){for await(const u of Um(s))yield*Im(u,o)},Um=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()}},_c=(s,o,u,f)=>{const c=Fm(s,o);let m=0,p,v=T=>{p||(p=!0,f&&f(T))};return new ReadableStream({async pull(T){try{const{done:N,value:x}=await c.next();if(N){v(),T.close();return}let A=x.byteLength;if(u){let M=m+=A;u(M)}T.enqueue(new Uint8Array(x))}catch(N){throw v(N),N}},cancel(T){return v(T),c.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:Xl}=k,$m=(({Request:s,Response:o})=>({Request:s,Response:o}))(k.global),{ReadableStream:Lc,TextEncoder:Ac}=k.global,zc=(s,...o)=>{try{return!!s(...o)}catch{return!1}},Bm=s=>{s=k.merge.call({skipUndefined:!0},$m,s);const{fetch:o,Request:u,Response:f}=s,c=o?Xl(o):typeof fetch=="function",m=Xl(u),p=Xl(f);if(!c)return!1;const v=c&&Xl(Lc),T=c&&(typeof Ac=="function"?(R=>j=>R.encode(j))(new Ac):async R=>new Uint8Array(await new u(R).arrayBuffer())),N=m&&v&&zc(()=>{let R=!1;const j=new u(We.origin,{body:new Lc,method:"POST",get duplex(){return R=!0,"half"}}).headers.has("Content-Type");return R&&!j}),x=p&&v&&zc(()=>k.isReadableStream(new f("").body)),A={stream:x&&(R=>R.body)};c&&["text","arrayBuffer","blob","formData","stream"].forEach(R=>{!A[R]&&(A[R]=(j,L)=>{let oe=j&&j[R];if(oe)return oe.call(j);throw new Z(`Response type '${R}' is not supported`,Z.ERR_NOT_SUPPORT,L)})});const M=async R=>{if(R==null)return 0;if(k.isBlob(R))return R.size;if(k.isSpecCompliantForm(R))return(await new u(We.origin,{method:"POST",body:R}).arrayBuffer()).byteLength;if(k.isArrayBufferView(R)||k.isArrayBuffer(R))return R.byteLength;if(k.isURLSearchParams(R)&&(R=R+""),k.isString(R))return(await T(R)).byteLength},V=async(R,j)=>{const L=k.toFiniteNumber(R.getContentLength());return L??M(j)};return async R=>{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}=nf(R),Fe=o||fetch;se=se?(se+"").toLowerCase():"text";let je=Mm([ce,re&&re.toAbortSignal()],te),xe=null;const Ne=je&&je.unsubscribe&&(()=>{je.unsubscribe()});let Qe;try{if(de&&N&&L!=="get"&&L!=="head"&&(Qe=await V(_e,oe))!==0){let g=new u(j,{method:"POST",body:oe,duplex:"half"}),P;if(k.isFormData(oe)&&(P=g.headers.get("content-type"))&&_e.setContentType(P),g.body){const[X,Y]=Pc(Qe,ei(Rc(de)));oe=_c(g.body,Oc,X,Y)}}k.isString(qe)||(qe=qe?"include":"omit");const fe=m&&"credentials"in u.prototype,q={...Je,signal:je,method:L.toUpperCase(),headers:_e.normalize().toJSON(),body:oe,duplex:"half",credentials:fe?qe:void 0};xe=m&&new u(j,q);let _=await(m?Fe(xe,Je):Fe(j,q));const H=x&&(se==="stream"||se==="response");if(x&&(he||H&&Ne)){const g={};["status","statusText","headers"].forEach(ee=>{g[ee]=_[ee]});const P=k.toFiniteNumber(_.headers.get("content-length")),[X,Y]=he&&Pc(P,ei(Rc(he),!0))||[];_=new f(_c(_.body,Oc,X,()=>{Y&&Y(),Ne&&Ne()}),g)}se=se||"text";let I=await A[k.findKey(A,se)||"text"](_,R);return!H&&Ne&&Ne(),await new Promise((g,P)=>{ef(g,P,{data:I,headers:rt.from(_.headers),status:_.status,statusText:_.statusText,config:R,request:xe})})}catch(fe){throw Ne&&Ne(),fe&&fe.name==="TypeError"&&/Load failed|fetch/i.test(fe.message)?Object.assign(new Z("Network Error",Z.ERR_NETWORK,R,xe),{cause:fe.cause||fe}):Z.from(fe,fe&&fe.code,R,xe)}}},Vm=new Map,rf=s=>{let o=s?s.env:{};const{fetch:u,Request:f,Response:c}=o,m=[f,c,u];let p=m.length,v=p,T,N,x=Vm;for(;v--;)T=m[v],N=x.get(T),N===void 0&&x.set(T,N=v?new Map:Bm(o)),x=N;return N};rf();const fs={http:im,xhr:jm,fetch:{get:rf}};k.forEach(fs,(s,o)=>{if(s){try{Object.defineProperty(s,"name",{value:o})}catch{}Object.defineProperty(s,"adapterName",{value:o})}});const Dc=s=>`- ${s}`,Hm=s=>k.isFunction(s)||s===null||s===!1,lf={getAdapter:(s,o)=>{s=k.isArray(s)?s:[s];const{length:u}=s;let f,c;const m={};for(let p=0;p<u;p++){f=s[p];let v;if(c=f,!Hm(f)&&(c=fs[(v=String(f)).toLowerCase()],c===void 0))throw new Z(`Unknown adapter '${v}'`);if(c&&(k.isFunction(c)||(c=c.get(o))))break;m[v||"#"+p]=c}if(!c){const p=Object.entries(m).map(([T,N])=>`adapter ${T} `+(N===!1?"is not supported by the environment":"is not available in the build"));let v=u?p.length>1?`since :
|
|
46
46
|
`+p.map(Dc).join(`
|
|
47
47
|
`):" "+Dc(p[0]):"as no adapter specified";throw new Z("There is no suitable adapter to dispatch the request "+v,"ERR_NOT_SUPPORT")}return c},adapters:fs};function ss(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Kn(null,s)}function jc(s){return ss(s),s.headers=rt.from(s.headers),s.data=os.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),lf.getAdapter(s.adapter||Fr.adapter,s)(s).then(function(f){return ss(s),f.data=os.call(s,s.transformResponse,f),f.headers=rt.from(f.headers),f},function(f){return bc(f)||(ss(s),f&&f.response&&(f.response.data=os.call(s,s.transformResponse,f.response),f.response.headers=rt.from(f.response.headers))),Promise.reject(f)})}const of="1.12.2",ii={};["object","boolean","number","function","string","symbol"].forEach((s,o)=>{ii[s]=function(f){return typeof f===s||"a"+(o<1?"n ":" ")+s}});const Mc={};ii.transitional=function(o,u,f){function c(m,p){return"[Axios v"+of+"] Transitional option '"+m+"'"+p+(f?". "+f:"")}return(m,p,v)=>{if(o===!1)throw new Z(c(p," has been removed"+(u?" in "+u:"")),Z.ERR_DEPRECATED);return u&&!Mc[p]&&(Mc[p]=!0,console.warn(c(p," has been deprecated since v"+u+" and will be removed in the near future"))),o?o(m,p,v):!0}};ii.spelling=function(o){return(u,f)=>(console.warn(`${f} is likely a misspelling of ${o}`),!0)};function Wm(s,o,u){if(typeof s!="object")throw new Z("options must be an object",Z.ERR_BAD_OPTION_VALUE);const f=Object.keys(s);let c=f.length;for(;c-- >0;){const m=f[c],p=o[m];if(p){const v=s[m],T=v===void 0||p(v,m,s);if(T!==!0)throw new Z("option "+m+" must be "+T,Z.ERR_BAD_OPTION_VALUE);continue}if(u!==!0)throw new Z("Unknown option "+m,Z.ERR_BAD_OPTION)}}const bl={assertOptions:Wm,validators:ii},Ct=bl.validators;let gn=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 m=c.stack?c.stack.replace(/^.+\n/,""):"";try{f.stack?m&&!String(f.stack).endsWith(m.replace(/^.+\n.+\n/,""))&&(f.stack+=`
|
|
48
|
-
`+m):f.stack=m}catch{}}throw f}}_request(o,u){typeof o=="string"?(u=u||{},u.url=o):u=o||{},u=vn(this.defaults,u);const{transitional:f,paramsSerializer:c,headers:m}=u;f!==void 0&&bl.assertOptions(f,{silentJSONParsing:Ct.transitional(Ct.boolean),forcedJSONParsing:Ct.transitional(Ct.boolean),clarifyTimeoutError:Ct.transitional(Ct.boolean)},!1),c!=null&&(k.isFunction(c)?u.paramsSerializer={serialize:c}:bl.assertOptions(c,{encode:Ct.function,serialize:Ct.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),bl.assertOptions(u,{baseUrl:Ct.spelling("baseURL"),withXsrfToken:Ct.spelling("withXSRFToken")},!0),u.method=(u.method||this.defaults.method||"get").toLowerCase();let p=m&&k.merge(m.common,m[u.method]);m&&k.forEach(["delete","get","head","post","put","patch","common"],R=>{delete m[R]}),u.headers=rt.concat(p,m);const v=[];let T=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||(T=T&&j.synchronous,v.unshift(j.fulfilled,j.rejected))});const N=[];this.interceptors.response.forEach(function(j){N.push(j.fulfilled,j.rejected)});let x,A=0,M;if(!T){const R=[jc.bind(this),void 0];for(R.unshift(...v),R.push(...N),M=R.length,x=Promise.resolve(u);A<M;)x=x.then(R[A++],R[A++]);return x}M=v.length;let V=u;for(;A<M;){const R=v[A++],j=v[A++];try{V=R(V)}catch(L){j.call(this,L);break}}try{x=jc.call(this,V)}catch(R){return Promise.reject(R)}for(A=0,M=N.length;A<M;)x=x.then(N[A++],N[A++]);return x}getUri(o){o=vn(this.defaults,o);const u=tf(o.baseURL,o.url,o.allowAbsoluteUrls);return Xc(u,o.params,o.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(o){gn.prototype[o]=function(u,f){return this.request(vn(f||{},{method:o,url:u,data:(f||{}).data}))}});k.forEach(["post","put","patch"],function(o){function u(f){return function(m,p,v){return this.request(vn(v||{},{method:o,headers:f?{"Content-Type":"multipart/form-data"}:{},url:m,data:p}))}}gn.prototype[o]=u(),gn.prototype[o+"Form"]=u(!0)});let qm=class sf{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let u;this.promise=new Promise(function(m){u=m});const f=this;this.promise.then(c=>{if(!f._listeners)return;let m=f._listeners.length;for(;m-- >0;)f._listeners[m](c);f._listeners=null}),this.promise.then=c=>{let m;const p=new Promise(v=>{f.subscribe(v),m=v}).then(c);return p.cancel=function(){f.unsubscribe(m)},p},o(function(m,p,v){f.reason||(f.reason=new Kn(m,p,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 sf(function(c){o=c}),cancel:o}}};function Qm(s){return function(u){return s.apply(null,u)}}function Km(s){return k.isObject(s)&&s.isAxiosError===!0}const ds={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(ds).forEach(([s,o])=>{ds[o]=s});function uf(s){const o=new gn(s),u=Fc(gn.prototype.request,o);return k.extend(u,gn.prototype,o,{allOwnKeys:!0}),k.extend(u,o,null,{allOwnKeys:!0}),u.create=function(c){return uf(vn(s,c))},u}const Re=uf(Fr);Re.Axios=gn;Re.CanceledError=Kn;Re.CancelToken=qm;Re.isCancel=bc;Re.VERSION=of;Re.toFormData=li;Re.AxiosError=Z;Re.Cancel=Re.CanceledError;Re.all=function(o){return Promise.all(o)};Re.spread=Qm;Re.isAxiosError=Km;Re.mergeConfig=vn;Re.AxiosHeaders=rt;Re.formToJSON=s=>Zc(k.isHTMLForm(s)?new FormData(s):s);Re.getAdapter=lf.getAdapter;Re.HttpStatusCode=ds;Re.default=Re;const{Axios:Zm,AxiosError:bm,CanceledError:eh,isCancel:th,CancelToken:nh,VERSION:rh,all:lh,Cancel:ih,isAxiosError:oh,spread:sh,toFormData:uh,AxiosHeaders:ah,HttpStatusCode:ch,formToJSON:fh,getAdapter:dh,mergeConfig:ph}=Re;class Ic{constructor(o,u=!1){Wn(this,"axiosInstance");Wn(this,"environmentUrl");Wn(this,"apiVersion");Wn(this,"isPPTB");this.environmentUrl=o.environmentUrl.replace(/\/$/,""),this.apiVersion=o.apiVersion||"9.2",this.isPPTB=u,this.axiosInstance=Re.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 m=await this.axiosInstance.get(`/solutions?$filter=uniquename eq '${o}'&$select=solutionid,friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`),p=await window.dataverseAPI.queryData("solution",`$filter=uniquename eq '${o}'&$select=solutionid,friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`);if((!m.data.value||m.data.value.length===0)&&(!p||p.value.length===0))throw new Error(`Solution '${o}' not found`);const v=this.isPPTB?p.value[0]:m.data.value[0],T=((u=v.publisherid)==null?void 0:u.customizationprefix)??"unknown",N=await this.axiosInstance.get(`/solutioncomponents?$filter=_solutionid_value eq ${v.solutionid} and componenttype eq 1&$select=objectid`),x=await window.dataverseAPI.queryData("solutioncomponent",`$filter=_solutionid_value eq ${v.solutionid} and componenttype eq 1&$select=objectid`),A=this.isPPTB?x.value.map(V=>V.objectid):N.data.value.map(V=>V.objectid);console.log("tableIds",A);const M=await this.fetchTables(A);return console.log("tables",M),{uniqueName:v.uniquename,displayName:v.friendlyname,version:v.version,publisherPrefix:T,tables:M}}catch(m){throw m.response?new Error(`Dataverse API error: ${m.response.status} - ${((c=(f=m.response.data)==null?void 0:f.error)==null?void 0:c.message)||m.message}`):m}}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=await this.axiosInstance.get(`/EntityDefinitions(${o})?$select=LogicalName,DisplayName,SchemaName,PrimaryIdAttribute,PrimaryNameAttribute,TableType,IsIntersect`),m=await window.dataverseAPI.getEntityMetadata(o,["LogicalName","DisplayName","SchemaName","PrimaryIdAttribute","PrimaryNameAttribute","TableType","IsIntersect"]),p=this.isPPTB?m:c.data,v=await this.axiosInstance.get(`/EntityDefinitions(${o})/Attributes?$select=LogicalName,DisplayName,AttributeType,IsPrimaryId,IsPrimaryName,RequiredLevel`),T=await window.dataverseAPI.getEntityRelatedMetadata(o,"Attributes",["LogicalName","DisplayName","AttributeType","IsPrimaryId","IsPrimaryName","RequiredLevel"]),x=(this.isPPTB?T.value:v.data.value).map(M=>{var V,R,j,L;return{logicalName:M.LogicalName,displayName:((R=(V=M.DisplayName)==null?void 0:V.UserLocalizedLabel)==null?void 0:R.Label)||M.LogicalName,type:this.mapAttributeType(M.AttributeType),isPrimaryId:M.IsPrimaryId||!1,isPrimaryName:M.IsPrimaryName||!1,isRequired:((j=M.RequiredLevel)==null?void 0:j.Value)==="ApplicationRequired"||((L=M.RequiredLevel)==null?void 0:L.Value)==="SystemRequired"}}),A=await this.fetchRelationships(o,p.LogicalName);return{logicalName:p.LogicalName,displayName:((f=(u=p.DisplayName)==null?void 0:u.UserLocalizedLabel)==null?void 0:f.Label)||p.LogicalName,schemaName:p.SchemaName,primaryIdAttribute:p.PrimaryIdAttribute,primaryNameAttribute:p.PrimaryNameAttribute,isIntersect:p.IsIntersect||!1,tableType:p.TableType,attributes:x,relationships:A}}catch(c){return console.warn(`Failed to fetch table metadata for ${o}:`,c),null}}async fetchRelationships(o,u){const f=[];try{const c=await this.axiosInstance.get(`/EntityDefinitions(${o})/OneToManyRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`),m=await window.dataverseAPI.getEntityRelatedMetadata(o,"OneToManyRelationships",["SchemaName","ReferencedEntity","ReferencingEntity","ReferencingAttribute"]),p=this.isPPTB?m.value:c.data.value;for(const V of p)V.ReferencedEntity===u&&f.push({schemaName:V.SchemaName,type:"OneToMany",relatedTable:V.ReferencingEntity,lookupAttribute:V.ReferencingAttribute});const v=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToOneRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`),T=await window.dataverseAPI.getEntityRelatedMetadata(o,"ManyToOneRelationships",["SchemaName","ReferencedEntity","ReferencingEntity","ReferencingAttribute"]),N=this.isPPTB?T.value:v.data.value;for(const V of N)V.ReferencingEntity===u&&f.push({schemaName:V.SchemaName,type:"ManyToOne",relatedTable:V.ReferencedEntity,lookupAttribute:V.ReferencingAttribute});const x=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToManyRelationships?$select=SchemaName,Entity1LogicalName,Entity2LogicalName,IntersectEntityName`),A=await window.dataverseAPI.getEntityRelatedMetadata(o,"ManyToManyRelationships",["SchemaName","Entity1LogicalName","Entity2LogicalName","IntersectEntityName"]),M=this.isPPTB?A.value:x.data.value;for(const V of M){const R=V.Entity1LogicalName===u;f.push({schemaName:V.SchemaName,type:"ManyToMany",relatedTable:R?V.Entity2LogicalName:V.Entity1LogicalName,intersectTable:V.IntersectEntityName})}}catch(c){console.warn(`Failed to fetch relationships for ${u}:`,c)}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 f=await this.axiosInstance.get("/solutions?$select=uniquename,friendlyname,version&$filter=isvisible eq true&$orderby=friendlyname asc"),c=await window.dataverseAPI.getSolutions(["friendlyname","uniquename","version"]);return(this.isPPTB?c.value:f.data.value).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 Gm(){const[s,o]=He.useState(!1),[u,f]=He.useState(""),[c,m]=He.useState(""),[p,v]=He.useState([]),[T,N]=He.useState(""),[x,A]=He.useState("mermaid"),[M,V]=He.useState(!0),[R,j]=He.useState(""),[L,oe]=He.useState(""),[ce,re]=He.useState("visual"),[te,he]=He.useState(!0),[de,se]=He.useState(!0),[_e,qe]=He.useState(10);He.useEffect(()=>{(async()=>{if(typeof window.acquireVsCodeApi<"u"){o(!1),V(!0);const _=H=>{const I=H.data;I.command==="setCredentials"&&(f(I.environmentUrl),m(I.accessToken),V(!1))};return window.addEventListener("message",_),()=>{window.removeEventListener("message",_)}}else if(window.toolboxAPI){console.log("Is PPTB"),o(!0);try{const _=await window.toolboxAPI.connections.getActiveConnection();f((_==null?void 0:_.url)||"")}catch(_){console.error("Failed to get tool context:",_)}V(!1)}else j("Not running in supported environment (DVDT or PPTB)"),V(!1)})()},[]),He.useEffect(()=>{u&&c&&Je()},[u,c]);const Je=async()=>{try{const _=await new Ic({environmentUrl:u,accessToken:c},s).listSolutions();v(_)}catch(q){Fe(`Failed to load solutions: ${q.message}`)}},Fe=q=>{j(q),setTimeout(()=>j(""),5e3)},je=async()=>{if(!T){Fe("Please select a solution first");return}try{V(!0);const _=await new Ic({environmentUrl:u,accessToken:c},s).fetchSolution(T),I=new wp({format:x,includeAttributes:te,includeRelationships:de,maxAttributesPerTable:_e}).generate(_);oe(I),s&&await window.toolboxAPI.utils.showNotification({title:"Success",body:"ERD generated successfully",type:"success"})}catch(q){Fe(`Failed to generate ERD: ${q.message}`)}finally{V(!1)}},xe=async()=>{if(!L)return;const _=`${T}-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){Fe(`Failed to save file: ${H.message}`)}},Ne=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(q){Fe(`Failed to copy: ${q.message}`)}},Qe=async()=>{if(window.mermaid)return;const q=await vp(()=>import("./mermaid.core.js").then(H=>H.b8),[]),_=q.default??q;_.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:q=>{(async()=>{if(q)try{q.textContent=L,await Qe(),window.mermaid&&window.mermaid.init(void 0,q)}catch(_){console.error("Mermaid rendering error:",_)}})()}}):Q.jsx("pre",{className:"diagram-text",children:L}):null;return M?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"})]}),R&&Q.jsx("div",{className:"error",children:R}),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:T,onChange:q=>N(q.target.value),disabled:p.length===0,children:[Q.jsx("option",{value:"",children:"-- Select a Solution --"}),p.map(q=>Q.jsxs("option",{value:q.uniqueName,children:[q.displayName," (",q.version,")"]},q.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:()=>A("mermaid"),children:"Mermaid"}),Q.jsx("button",{className:`format-btn ${x==="plantuml"?"active":""}`,onClick:()=>A("plantuml"),children:"PlantUML"}),Q.jsx("button",{className:`format-btn ${x==="graphviz"?"active":""}`,onClick:()=>A("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:q=>he(q.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:q=>se(q.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:q=>qe(parseInt(q.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:!T||M,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:Ne,children:"π Copy to Clipboard"})]}),Q.jsx("div",{className:"diagram-container",children:fe()})]})]})}hp.createRoot(document.getElementById("root")).render(Q.jsx(He.StrictMode,{children:Q.jsx(Gm,{})}));export{vp as _};
|
|
48
|
+
`+m):f.stack=m}catch{}}throw f}}_request(o,u){typeof o=="string"?(u=u||{},u.url=o):u=o||{},u=vn(this.defaults,u);const{transitional:f,paramsSerializer:c,headers:m}=u;f!==void 0&&bl.assertOptions(f,{silentJSONParsing:Ct.transitional(Ct.boolean),forcedJSONParsing:Ct.transitional(Ct.boolean),clarifyTimeoutError:Ct.transitional(Ct.boolean)},!1),c!=null&&(k.isFunction(c)?u.paramsSerializer={serialize:c}:bl.assertOptions(c,{encode:Ct.function,serialize:Ct.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),bl.assertOptions(u,{baseUrl:Ct.spelling("baseURL"),withXsrfToken:Ct.spelling("withXSRFToken")},!0),u.method=(u.method||this.defaults.method||"get").toLowerCase();let p=m&&k.merge(m.common,m[u.method]);m&&k.forEach(["delete","get","head","post","put","patch","common"],R=>{delete m[R]}),u.headers=rt.concat(p,m);const v=[];let T=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||(T=T&&j.synchronous,v.unshift(j.fulfilled,j.rejected))});const N=[];this.interceptors.response.forEach(function(j){N.push(j.fulfilled,j.rejected)});let x,A=0,M;if(!T){const R=[jc.bind(this),void 0];for(R.unshift(...v),R.push(...N),M=R.length,x=Promise.resolve(u);A<M;)x=x.then(R[A++],R[A++]);return x}M=v.length;let V=u;for(;A<M;){const R=v[A++],j=v[A++];try{V=R(V)}catch(L){j.call(this,L);break}}try{x=jc.call(this,V)}catch(R){return Promise.reject(R)}for(A=0,M=N.length;A<M;)x=x.then(N[A++],N[A++]);return x}getUri(o){o=vn(this.defaults,o);const u=tf(o.baseURL,o.url,o.allowAbsoluteUrls);return Xc(u,o.params,o.paramsSerializer)}};k.forEach(["delete","get","head","options"],function(o){gn.prototype[o]=function(u,f){return this.request(vn(f||{},{method:o,url:u,data:(f||{}).data}))}});k.forEach(["post","put","patch"],function(o){function u(f){return function(m,p,v){return this.request(vn(v||{},{method:o,headers:f?{"Content-Type":"multipart/form-data"}:{},url:m,data:p}))}}gn.prototype[o]=u(),gn.prototype[o+"Form"]=u(!0)});let qm=class sf{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let u;this.promise=new Promise(function(m){u=m});const f=this;this.promise.then(c=>{if(!f._listeners)return;let m=f._listeners.length;for(;m-- >0;)f._listeners[m](c);f._listeners=null}),this.promise.then=c=>{let m;const p=new Promise(v=>{f.subscribe(v),m=v}).then(c);return p.cancel=function(){f.unsubscribe(m)},p},o(function(m,p,v){f.reason||(f.reason=new Kn(m,p,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 sf(function(c){o=c}),cancel:o}}};function Qm(s){return function(u){return s.apply(null,u)}}function Km(s){return k.isObject(s)&&s.isAxiosError===!0}const ds={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(ds).forEach(([s,o])=>{ds[o]=s});function uf(s){const o=new gn(s),u=Fc(gn.prototype.request,o);return k.extend(u,gn.prototype,o,{allOwnKeys:!0}),k.extend(u,o,null,{allOwnKeys:!0}),u.create=function(c){return uf(vn(s,c))},u}const Re=uf(Fr);Re.Axios=gn;Re.CanceledError=Kn;Re.CancelToken=qm;Re.isCancel=bc;Re.VERSION=of;Re.toFormData=li;Re.AxiosError=Z;Re.Cancel=Re.CanceledError;Re.all=function(o){return Promise.all(o)};Re.spread=Qm;Re.isAxiosError=Km;Re.mergeConfig=vn;Re.AxiosHeaders=rt;Re.formToJSON=s=>Zc(k.isHTMLForm(s)?new FormData(s):s);Re.getAdapter=lf.getAdapter;Re.HttpStatusCode=ds;Re.default=Re;const{Axios:Zm,AxiosError:bm,CanceledError:eh,isCancel:th,CancelToken:nh,VERSION:rh,all:lh,Cancel:ih,isAxiosError:oh,spread:sh,toFormData:uh,AxiosHeaders:ah,HttpStatusCode:ch,formToJSON:fh,getAdapter:dh,mergeConfig:ph}=Re;class Ic{constructor(o,u=!1){Wn(this,"axiosInstance");Wn(this,"environmentUrl");Wn(this,"apiVersion");Wn(this,"isPPTB");this.environmentUrl=o.environmentUrl.replace(/\/$/,""),this.apiVersion=o.apiVersion||"9.2",this.isPPTB=u,this.axiosInstance=Re.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 m=await this.axiosInstance.get(`/solutions?$filter=uniquename eq '${o}'&$select=solutionid,friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`),p=await window.dataverseAPI.queryData("solution",`$filter=uniquename eq '${o}'&$select=solutionid,friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`);if((!m.data.value||m.data.value.length===0)&&(!p||p.value.length===0))throw new Error(`Solution '${o}' not found`);const v=this.isPPTB?p.value[0]:m.data.value[0],T=((u=v.publisherid)==null?void 0:u.customizationprefix)??"unknown",N=await this.axiosInstance.get(`/solutioncomponents?$filter=_solutionid_value eq ${v.solutionid} and componenttype eq 1&$select=objectid`),x=await window.dataverseAPI.queryData("solutioncomponent",`$filter=_solutionid_value eq ${v.solutionid} and componenttype eq 1&$select=objectid`),A=this.isPPTB?x.value.map(V=>V.objectid):N.data.value.map(V=>V.objectid);console.log("tableIds",A);const M=await this.fetchTables(A);return console.log("tables",M),{uniqueName:v.uniquename,displayName:v.friendlyname,version:v.version,publisherPrefix:T,tables:M}}catch(m){throw m.response?new Error(`Dataverse API error: ${m.response.status} - ${((c=(f=m.response.data)==null?void 0:f.error)==null?void 0:c.message)||m.message}`):m}}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=await this.axiosInstance.get(`/EntityDefinitions(${o})?$select=LogicalName,DisplayName,SchemaName,PrimaryIdAttribute,PrimaryNameAttribute,TableType,IsIntersect`),m=await window.dataverseAPI.getEntityMetadata(o,["LogicalName","DisplayName","SchemaName","PrimaryIdAttribute","PrimaryNameAttribute","TableType","IsIntersect"]),p=this.isPPTB?m:c.data,v=await this.axiosInstance.get(`/EntityDefinitions(${o})/Attributes?$select=LogicalName,DisplayName,AttributeType,IsPrimaryId,IsPrimaryName,RequiredLevel`),T=await window.dataverseAPI.getEntityRelatedMetadata(o,"Attributes",["LogicalName","DisplayName","AttributeType","IsPrimaryId","IsPrimaryName","RequiredLevel"]),x=(this.isPPTB?T.value:v.data.value).map(M=>{var V,R,j,L;return{logicalName:M.LogicalName,displayName:((R=(V=M.DisplayName)==null?void 0:V.UserLocalizedLabel)==null?void 0:R.Label)||M.LogicalName,type:this.mapAttributeType(M.AttributeType),isPrimaryId:M.IsPrimaryId||!1,isPrimaryName:M.IsPrimaryName||!1,isRequired:((j=M.RequiredLevel)==null?void 0:j.Value)==="ApplicationRequired"||((L=M.RequiredLevel)==null?void 0:L.Value)==="SystemRequired"}}),A=await this.fetchRelationships(o,p.LogicalName);return{logicalName:p.LogicalName,displayName:((f=(u=p.DisplayName)==null?void 0:u.UserLocalizedLabel)==null?void 0:f.Label)||p.LogicalName,schemaName:p.SchemaName,primaryIdAttribute:p.PrimaryIdAttribute,primaryNameAttribute:p.PrimaryNameAttribute,isIntersect:p.IsIntersect||!1,tableType:p.TableType,attributes:x,relationships:A}}catch(c){return console.warn(`Failed to fetch table metadata for ${o}:`,c),null}}async fetchRelationships(o,u){const f=[];try{const c=await this.axiosInstance.get(`/EntityDefinitions(${o})/OneToManyRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`),m=await window.dataverseAPI.getEntityRelatedMetadata(o,"OneToManyRelationships",["SchemaName","ReferencedEntity","ReferencingEntity","ReferencingAttribute"]),p=this.isPPTB?m.value:c.data.value;for(const V of p)V.ReferencedEntity===u&&f.push({schemaName:V.SchemaName,type:"OneToMany",relatedTable:V.ReferencingEntity,lookupAttribute:V.ReferencingAttribute});const v=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToOneRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`),T=await window.dataverseAPI.getEntityRelatedMetadata(o,"ManyToOneRelationships",["SchemaName","ReferencedEntity","ReferencingEntity","ReferencingAttribute"]),N=this.isPPTB?T.value:v.data.value;for(const V of N)V.ReferencingEntity===u&&f.push({schemaName:V.SchemaName,type:"ManyToOne",relatedTable:V.ReferencedEntity,lookupAttribute:V.ReferencingAttribute});const x=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToManyRelationships?$select=SchemaName,Entity1LogicalName,Entity2LogicalName,IntersectEntityName`),A=await window.dataverseAPI.getEntityRelatedMetadata(o,"ManyToManyRelationships",["SchemaName","Entity1LogicalName","Entity2LogicalName","IntersectEntityName"]),M=this.isPPTB?A.value:x.data.value;for(const V of M){const R=V.Entity1LogicalName===u;f.push({schemaName:V.SchemaName,type:"ManyToMany",relatedTable:R?V.Entity2LogicalName:V.Entity1LogicalName,intersectTable:V.IntersectEntityName})}}catch(c){console.warn(`Failed to fetch relationships for ${u}:`,c)}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 f=await this.axiosInstance.get("/solutions?$select=uniquename,friendlyname,version&$filter=isvisible eq true&$orderby=friendlyname asc"),c=await window.dataverseAPI.getSolutions(["friendlyname","uniquename","version"]);return(this.isPPTB?c.value:f.data.value).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 Gm(){const[s,o]=He.useState(!1),[u,f]=He.useState(""),[c,m]=He.useState(""),[p,v]=He.useState([]),[T,N]=He.useState(""),[x,A]=He.useState("mermaid"),[M,V]=He.useState(!0),[R,j]=He.useState(""),[L,oe]=He.useState(""),[ce,re]=He.useState("visual"),[te,he]=He.useState(!0),[de,se]=He.useState(!0),[_e,qe]=He.useState(10);He.useEffect(()=>{(async()=>{if(typeof window.acquireVsCodeApi<"u"){o(!1),V(!0);const _=H=>{const I=H.data;I.command==="setCredentials"&&(f(I.environmentUrl),m(I.accessToken),V(!1))};return window.addEventListener("message",_),()=>{window.removeEventListener("message",_)}}else if(window.toolboxAPI){console.log("In PPTB"),o(!0);try{const _=await window.toolboxAPI.connections.getActiveConnection();f((_==null?void 0:_.url)||"")}catch(_){console.error("Failed to get tool context:",_)}V(!1)}else j("Not running in supported environment (DVDT or PPTB)"),V(!1)})()},[]),He.useEffect(()=>{u&&Je()},[u]);const Je=async()=>{try{const _=await new Ic({environmentUrl:u,accessToken:c},s).listSolutions();v(_)}catch(q){Fe(`Failed to load solutions: ${q.message}`)}},Fe=q=>{j(q),setTimeout(()=>j(""),5e3)},je=async()=>{if(!T){Fe("Please select a solution first");return}try{V(!0);const _=await new Ic({environmentUrl:u,accessToken:c},s).fetchSolution(T),I=new wp({format:x,includeAttributes:te,includeRelationships:de,maxAttributesPerTable:_e}).generate(_);oe(I),s&&await window.toolboxAPI.utils.showNotification({title:"Success",body:"ERD generated successfully",type:"success"})}catch(q){Fe(`Failed to generate ERD: ${q.message}`)}finally{V(!1)}},xe=async()=>{if(!L)return;const _=`${T}-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){Fe(`Failed to save file: ${H.message}`)}},Ne=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(q){Fe(`Failed to copy: ${q.message}`)}},Qe=async()=>{if(window.mermaid)return;const q=await vp(()=>import("./mermaid.core.js").then(H=>H.b8),[]),_=q.default??q;_.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:q=>{(async()=>{if(q)try{q.textContent=L,await Qe(),window.mermaid&&window.mermaid.init(void 0,q)}catch(_){console.error("Mermaid rendering error:",_)}})()}}):Q.jsx("pre",{className:"diagram-text",children:L}):null;return M?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"})]}),R&&Q.jsx("div",{className:"error",children:R}),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:T,onChange:q=>N(q.target.value),disabled:p.length===0,children:[Q.jsx("option",{value:"",children:"-- Select a Solution --"}),p.map(q=>Q.jsxs("option",{value:q.uniqueName,children:[q.displayName," (",q.version,")"]},q.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:()=>A("mermaid"),children:"Mermaid"}),Q.jsx("button",{className:`format-btn ${x==="plantuml"?"active":""}`,onClick:()=>A("plantuml"),children:"PlantUML"}),Q.jsx("button",{className:`format-btn ${x==="graphviz"?"active":""}`,onClick:()=>A("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:q=>he(q.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:q=>se(q.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:q=>qe(parseInt(q.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:!T||M,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:Ne,children:"π Copy to Clipboard"})]}),Q.jsx("div",{className:"diagram-container",children:fe()})]})]})}hp.createRoot(document.getElementById("root")).render(Q.jsx(He.StrictMode,{children:Q.jsx(Gm,{})}));export{vp 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.3",
|
|
5
5
|
"description": "Generate Entity Relationship Diagrams (ERD) for Dataverse solutions - React-based tool for PowerPlatform ToolBox",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|