@power-maverick/tool-erd-generator 0.0.11 β†’ 0.0.13

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +13 -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[Nc]=this[Nc]={accessors:{}}).accessors,c=this.prototype;function p(m){const w=Dr(m);f[w]||(km(c,m),f[w]=!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 os(s,o){const u=this||Ir,f=o||u,c=rt.from(f.headers);let p=f.data;return k.forEach(s,function(w){p=w.call(u,p,c.normalize(),o?o.status:void 0)}),c.normalize(),p}function Zc(s){return!!(s&&s.__CANCEL__)}function qn(s,o,u){Y.call(this,s??"canceled",Y.ERR_CANCELED,o,u),this.name="CanceledError"}k.inherits(qn,Y,{__CANCEL__:!0});function bc(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 xm(s){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return o&&o[1]||""}function Nm(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 D=p,H=0;for(;D!==c;)H+=u[D++],D=D%s;if(c=(c+1)%s,c===p&&(p=(p+1)%s),N-m<o)return;const b=x&&N-x;return b?Math.round(H*1e3/b):void 0}}function Cm(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(),D=x-u;D>=f?m(N,x):(c=N,p||(p=setTimeout(()=>{p=null,m(c)},f-D)))},()=>c&&m(c)]}const ei=(s,o,u=3)=>{let f=0;const c=Nm(50,250);return Cm(p=>{const m=p.loaded,w=p.lengthComputable?p.total:void 0,C=m-f,N=c(C),x=m<=w;f=m;const D={loaded:m,total:w,progress:w?m/w:void 0,bytes:C,rate:N||void 0,estimated:N&&w&&x?(w-m)/N:void 0,event:p,lengthComputable:w!=null,[o?"download":"upload"]:!0};s(D)},u)},Cc=(s,o)=>{const u=s!=null;return[f=>o[0]({lengthComputable:u,total:s,loaded:f}),o[1]]},Tc=s=>(...o)=>k.asap(()=>s(...o)),Tm=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,Rm=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 _m(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function Pm(s,o){return o?s.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):s}function ef(s,o,u){let f=!_m(o);return s&&(f||u==!1)?Pm(s,o):o}const Rc=s=>s instanceof rt?{...s}:s;function vn(s,o){o=o||{};const u={};function f(N,x,D,H){return k.isPlainObject(N)&&k.isPlainObject(x)?k.merge.call({caseless:H},N,x):k.isPlainObject(x)?k.merge({},x):k.isArray(x)?x.slice():x}function c(N,x,D,H){if(k.isUndefined(x)){if(!k.isUndefined(N))return f(void 0,N,D,H)}else return f(N,x,D,H)}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 w(N,x,D){if(D in o)return f(N,x);if(D 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:w,headers:(N,x,D)=>c(Rc(N),Rc(x),D,!0)};return k.forEach(Object.keys({...s,...o}),function(x){const D=C[x]||c,H=D(s[x],o[x],x);k.isUndefined(H)&&D!==w||(u[x]=H)}),u}const tf=s=>{const o=vn({},s);let{data:u,withXSRFToken:f,xsrfHeaderName:c,xsrfCookieName:p,headers:m,auth:w}=o;if(o.headers=m=rt.from(m),o.url=Gc(ef(o.baseURL,o.url,o.allowAbsoluteUrls),s.params,s.paramsSerializer),w&&m.set("Authorization","Basic "+btoa((w.username||"")+":"+(w.password?unescape(encodeURIComponent(w.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,D])=>{N.includes(x.toLowerCase())&&m.set(x,D)})}}if(We.hasStandardBrowserEnv&&(f&&k.isFunction(f)&&(f=f(o)),f||f!==!1&&Tm(o.url))){const C=c&&p&&Rm.read(p);C&&m.set(c,C)}return o},Om=typeof XMLHttpRequest<"u",Lm=Om&&function(s){return new Promise(function(u,f){const c=tf(s);let p=c.data;const m=rt.from(c.headers).normalize();let{responseType:w,onUploadProgress:C,onDownloadProgress:N}=c,x,D,H,b,O;function j(){b&&b(),O&&O(),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 se(){if(!L)return;const le=rt.from("getAllResponseHeaders"in L&&L.getAllResponseHeaders()),he={data:!w||w==="text"||w==="json"?L.responseText:L.response,status:L.status,statusText:L.statusText,headers:le,config:s,request:L};bc(function(ue){u(ue),j()},function(ue){f(ue),j()},he),L=null}"onloadend"in L?L.onloadend=se:L.onreadystatechange=function(){!L||L.readyState!==4||L.status===0&&!(L.responseURL&&L.responseURL.indexOf("file:")===0)||setTimeout(se)},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||Jc;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),w&&w!=="json"&&(L.responseType=c.responseType),N&&([H,O]=ei(N,!0),L.addEventListener("progress",H)),C&&L.upload&&([D,b]=ei(C),L.upload.addEventListener("progress",D),L.upload.addEventListener("loadend",b)),(c.cancelToken||c.signal)&&(x=le=>{L&&(f(!le||le.type?new qn(null,s,L):le),L.abort(),L=null)},c.cancelToken&&c.cancelToken.subscribe(x),c.signal&&(c.signal.aborted?x():c.signal.addEventListener("abort",x)));const fe=xm(c.url);if(fe&&We.protocols.indexOf(fe)===-1){f(new Y("Unsupported protocol "+fe+":",Y.ERR_BAD_REQUEST,s));return}L.send(p||null)})},zm=(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,w();const x=N instanceof Error?N:this.reason;f.abort(x instanceof Y?x:new qn(x instanceof Error?x.message:x))}};let m=o&&setTimeout(()=>{m=null,p(new Y(`timeout ${o} of ms exceeded`,Y.ETIMEDOUT))},o);const w=()=>{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(w),C}},Am=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},Dm=async function*(s,o){for await(const u of jm(s))yield*Am(u,o)},jm=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=Dm(s,o);let p=0,m,w=C=>{m||(m=!0,f&&f(C))};return new ReadableStream({async pull(C){try{const{done:N,value:x}=await c.next();if(N){w(),C.close();return}let D=x.byteLength;if(u){let H=p+=D;u(H)}C.enqueue(new Uint8Array(x))}catch(N){throw w(N),N}},cancel(C){return w(C),c.return()}},{highWaterMark:2})},Pc=64*1024,{isFunction:Jl}=k,Fm=(({Request:s,Response:o})=>({Request:s,Response:o}))(k.global),{ReadableStream:Oc,TextEncoder:Lc}=k.global,zc=(s,...o)=>{try{return!!s(...o)}catch{return!1}},Mm=s=>{s=k.merge.call({skipUndefined:!0},Fm,s);const{fetch:o,Request:u,Response:f}=s,c=o?Jl(o):typeof fetch=="function",p=Jl(u),m=Jl(f);if(!c)return!1;const w=c&&Jl(Oc),C=c&&(typeof Lc=="function"?(O=>j=>O.encode(j))(new Lc):async O=>new Uint8Array(await new u(O).arrayBuffer())),N=p&&w&&zc(()=>{let O=!1;const j=new u(We.origin,{body:new Oc,method:"POST",get duplex(){return O=!0,"half"}}).headers.has("Content-Type");return O&&!j}),x=m&&w&&zc(()=>k.isReadableStream(new f("").body)),D={stream:x&&(O=>O.body)};c&&["text","arrayBuffer","blob","formData","stream"].forEach(O=>{!D[O]&&(D[O]=(j,L)=>{let se=j&&j[O];if(se)return se.call(j);throw new Y(`Response type '${O}' is not supported`,Y.ERR_NOT_SUPPORT,L)})});const H=async O=>{if(O==null)return 0;if(k.isBlob(O))return O.size;if(k.isSpecCompliantForm(O))return(await new u(We.origin,{method:"POST",body:O}).arrayBuffer()).byteLength;if(k.isArrayBufferView(O)||k.isArrayBuffer(O))return O.byteLength;if(k.isURLSearchParams(O)&&(O=O+""),k.isString(O))return(await C(O)).byteLength},b=async(O,j)=>{const L=k.toFiniteNumber(O.getContentLength());return L??H(j)};return async O=>{let{url:j,method:L,data:se,signal:fe,cancelToken:le,timeout:te,onDownloadProgress:he,onUploadProgress:de,responseType:ue,headers:Pe,withCredentials:Qe="same-origin",fetchOptions:Ge}=tf(O),Ie=o||fetch;ue=ue?(ue+"").toLowerCase():"text";let je=zm([fe,le&&le.toAbortSignal()],te),xe=null;const Ne=je&&je.unsubscribe&&(()=>{je.unsubscribe()});let qe;try{if(de&&N&&L!=="get"&&L!=="head"&&(qe=await b(Pe,se))!==0){let g=new u(j,{method:"POST",body:se,duplex:"half"}),T;if(k.isFormData(se)&&(T=g.headers.get("content-type"))&&Pe.setContentType(T),g.body){const[G,J]=Cc(qe,ei(Tc(de)));se=_c(g.body,Pc,G,J)}}k.isString(Qe)||(Qe=Qe?"include":"omit");const V=p&&"credentials"in u.prototype,ne={...Ge,signal:je,method:L.toUpperCase(),headers:Pe.normalize().toJSON(),body:se,duplex:"half",credentials:V?Qe:void 0};xe=p&&new u(j,ne);let _=await(p?Ie(xe,Ge):Ie(j,ne));const W=x&&(ue==="stream"||ue==="response");if(x&&(he||W&&Ne)){const g={};["status","statusText","headers"].forEach(ee=>{g[ee]=_[ee]});const T=k.toFiniteNumber(_.headers.get("content-length")),[G,J]=he&&Cc(T,ei(Tc(he),!0))||[];_=new f(_c(_.body,Pc,G,()=>{J&&J(),Ne&&Ne()}),g)}ue=ue||"text";let M=await D[k.findKey(D,ue)||"text"](_,O);return!W&&Ne&&Ne(),await new Promise((g,T)=>{bc(g,T,{data:M,headers:rt.from(_.headers),status:_.status,statusText:_.statusText,config:O,request:xe})})}catch(V){throw Ne&&Ne(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Y("Network Error",Y.ERR_NETWORK,O,xe),{cause:V.cause||V}):Y.from(V,V&&V.code,O,xe)}}},Im=new Map,nf=s=>{let o=s?s.env:{};const{fetch:u,Request:f,Response:c}=o,p=[f,c,u];let m=p.length,w=m,C,N,x=Im;for(;w--;)C=p[w],N=x.get(C),N===void 0&&x.set(C,N=w?new Map:Mm(o)),x=N;return N};nf();const fs={http:tm,xhr:Lm,fetch:{get:nf}};k.forEach(fs,(s,o)=>{if(s){try{Object.defineProperty(s,"name",{value:o})}catch{}Object.defineProperty(s,"adapterName",{value:o})}});const Ac=s=>`- ${s}`,Um=s=>k.isFunction(s)||s===null||s===!1,rf={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 w;if(c=f,!Um(f)&&(c=fs[(w=String(f)).toLowerCase()],c===void 0))throw new Y(`Unknown adapter '${w}'`);if(c&&(k.isFunction(c)||(c=c.get(o))))break;p[w||"#"+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 w=u?m.length>1?`since :
46
46
  `+m.map(Ac).join(`
47
47
  `):" "+Ac(m[0]):"as no adapter specified";throw new Y("There is no suitable adapter to dispatch the request "+w,"ERR_NOT_SUPPORT")}return c},adapters:fs};function ss(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new qn(null,s)}function Dc(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),rf.getAdapter(s.adapter||Ir.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 Zc(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 lf="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 jc={};ii.transitional=function(o,u,f){function c(p,m){return"[Axios v"+lf+"] Transitional option '"+p+"'"+m+(f?". "+f:"")}return(p,m,w)=>{if(o===!1)throw new Y(c(m," has been removed"+(u?" in "+u:"")),Y.ERR_DEPRECATED);return u&&!jc[m]&&(jc[m]=!0,console.warn(c(m," has been deprecated since v"+u+" and will be removed in the near future"))),o?o(p,m,w):!0}};ii.spelling=function(o){return(u,f)=>(console.warn(`${f} is likely a misspelling of ${o}`),!0)};function $m(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 w=s[p],C=w===void 0||m(w,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 bl={assertOptions:$m,validators:ii},_t=bl.validators;let gn=class{constructor(o){this.defaults=o||{},this.interceptors={request:new xc,response:new xc}}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=vn(this.defaults,u);const{transitional:f,paramsSerializer:c,headers:p}=u;f!==void 0&&bl.assertOptions(f,{silentJSONParsing:_t.transitional(_t.boolean),forcedJSONParsing:_t.transitional(_t.boolean),clarifyTimeoutError:_t.transitional(_t.boolean)},!1),c!=null&&(k.isFunction(c)?u.paramsSerializer={serialize:c}:bl.assertOptions(c,{encode:_t.function,serialize:_t.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),bl.assertOptions(u,{baseUrl:_t.spelling("baseURL"),withXsrfToken:_t.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"],O=>{delete p[O]}),u.headers=rt.concat(m,p);const w=[];let C=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||(C=C&&j.synchronous,w.unshift(j.fulfilled,j.rejected))});const N=[];this.interceptors.response.forEach(function(j){N.push(j.fulfilled,j.rejected)});let x,D=0,H;if(!C){const O=[Dc.bind(this),void 0];for(O.unshift(...w),O.push(...N),H=O.length,x=Promise.resolve(u);D<H;)x=x.then(O[D++],O[D++]);return x}H=w.length;let b=u;for(;D<H;){const O=w[D++],j=w[D++];try{b=O(b)}catch(L){j.call(this,L);break}}try{x=Dc.call(this,b)}catch(O){return Promise.reject(O)}for(D=0,H=N.length;D<H;)x=x.then(N[D++],N[D++]);return x}getUri(o){o=vn(this.defaults,o);const u=ef(o.baseURL,o.url,o.allowAbsoluteUrls);return Gc(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(p,m,w){return this.request(vn(w||{},{method:o,headers:f?{"Content-Type":"multipart/form-data"}:{},url:p,data:m}))}}gn.prototype[o]=u(),gn.prototype[o+"Form"]=u(!0)});let Bm=class of{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(w=>{f.subscribe(w),p=w}).then(c);return m.cancel=function(){f.unsubscribe(p)},m},o(function(p,m,w){f.reason||(f.reason=new qn(p,m,w),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 of(function(c){o=c}),cancel:o}}};function Hm(s){return function(u){return s.apply(null,u)}}function Vm(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 sf(s){const o=new gn(s),u=Mc(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 sf(vn(s,c))},u}const Re=sf(Ir);Re.Axios=gn;Re.CanceledError=qn;Re.CancelToken=Bm;Re.isCancel=Zc;Re.VERSION=lf;Re.toFormData=li;Re.AxiosError=Y;Re.Cancel=Re.CanceledError;Re.all=function(o){return Promise.all(o)};Re.spread=Hm;Re.isAxiosError=Vm;Re.mergeConfig=vn;Re.AxiosHeaders=rt;Re.formToJSON=s=>Yc(k.isHTMLForm(s)?new FormData(s):s);Re.getAdapter=rf.getAdapter;Re.HttpStatusCode=ds;Re.default=Re;const{Axios:Xm,AxiosError:Gm,CanceledError:Jm,isCancel:Ym,CancelToken:Zm,VERSION:bm,all:eh,Cancel:th,isAxiosError:nh,spread:rh,toFormData:lh,AxiosHeaders:ih,HttpStatusCode:oh,formToJSON:sh,getAdapter:uh,mergeConfig:ah}=Re;class Fc{constructor(o){zr(this,"axiosInstance");zr(this,"environmentUrl");zr(this,"apiVersion");this.environmentUrl=o.environmentUrl.replace(/\/$/,""),this.apiVersion=o.apiVersion||"9.2",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 p=await this.axiosInstance.get(`/solutions?$filter=uniquename eq '${o}'&$select=friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`);if(!p.data.value||p.data.value.length===0)throw new Error(`Solution '${o}' not found`);const m=p.data.value[0],w=((u=m.publisherid)==null?void 0:u.customizationprefix)??"unknown",N=(await this.axiosInstance.get(`/solutioncomponents?$filter=_solutionid_value eq ${m.solutionid} and componenttype eq 1&$select=objectid`)).data.value.map(D=>D.objectid);console.log("tableIds",N);const x=await this.fetchTables(N);return console.log("tables",x),{uniqueName:m.uniquename,displayName:m.friendlyname,version:m.version,publisherPrefix:w,tables:x}}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 p=(await this.axiosInstance.get(`/EntityDefinitions(${o})?$select=LogicalName,DisplayName,SchemaName,PrimaryIdAttribute,PrimaryNameAttribute,TableType,IsIntersect`)).data,w=(await this.axiosInstance.get(`/EntityDefinitions(${o})/Attributes?$select=LogicalName,DisplayName,AttributeType,IsPrimaryId,IsPrimaryName,RequiredLevel`)).data.value.map(N=>{var x,D,H,b;return{logicalName:N.LogicalName,displayName:((D=(x=N.DisplayName)==null?void 0:x.UserLocalizedLabel)==null?void 0:D.Label)||N.LogicalName,type:this.mapAttributeType(N.AttributeType),isPrimaryId:N.IsPrimaryId||!1,isPrimaryName:N.IsPrimaryName||!1,isRequired:((H=N.RequiredLevel)==null?void 0:H.Value)==="ApplicationRequired"||((b=N.RequiredLevel)==null?void 0:b.Value)==="SystemRequired"}}),C=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:w,relationships:C}}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`);for(const w of c.data.value)w.ReferencedEntity===u&&f.push({schemaName:w.SchemaName,type:"OneToMany",relatedTable:w.ReferencingEntity,lookupAttribute:w.ReferencingAttribute});const p=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToOneRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`);for(const w of p.data.value)w.ReferencingEntity===u&&f.push({schemaName:w.SchemaName,type:"ManyToOne",relatedTable:w.ReferencedEntity,lookupAttribute:w.ReferencingAttribute});const m=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToManyRelationships?$select=SchemaName,Entity1LogicalName,Entity2LogicalName,IntersectEntityName`);for(const w of m.data.value){const C=w.Entity1LogicalName===u;f.push({schemaName:w.SchemaName,type:"ManyToMany",relatedTable:C?w.Entity2LogicalName:w.Entity1LogicalName,intersectTable:w.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{return(await this.axiosInstance.get("/solutions?$select=uniquename,friendlyname,version&$filter=isvisible eq true&$orderby=friendlyname asc")).data.value.map(c=>({uniqueName:c.uniquename,displayName:c.friendlyname,version:c.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 Wm(){const[s,o]=Ve.useState(null),[u,f]=Ve.useState(""),[c,p]=Ve.useState(""),[m,w]=Ve.useState([]),[C,N]=Ve.useState(""),[x,D]=Ve.useState("mermaid"),[H,b]=Ve.useState(!0),[O,j]=Ve.useState(""),[L,se]=Ve.useState(""),[fe,le]=Ve.useState("visual"),[te,he]=Ve.useState(!0),[de,ue]=Ve.useState(!0),[Pe,Qe]=Ve.useState(10);Ve.useEffect(()=>{const V=_=>{_.data&&_.data.type==="TOOLBOX_CONTEXT"&&(window.TOOLBOX_CONTEXT=_.data.data,o(_.data.data),console.log("Received TOOLBOX_CONTEXT:",window.TOOLBOX_CONTEXT))};return window.addEventListener("message",V),(async()=>{try{let _=s||window.TOOLBOX_CONTEXT;_||(_=await window.toolboxAPI.getToolContext()),f((_==null?void 0:_.connectionUrl)||""),p((_==null?void 0:_.accessToken)||""),b(!1)}catch(_){console.error("Failed to initialize tool:",_),j("Failed to load connection context"),b(!1)}})(),()=>{window.removeEventListener("message",V)}},[s]),Ve.useEffect(()=>{u&&c&&Ge()},[u,c]);const Ge=async()=>{try{const ne=await new Fc({environmentUrl:u,accessToken:c}).listSolutions();w(ne)}catch(V){Ie(`Failed to load solutions: ${V.message}`)}},Ie=V=>{j(V),setTimeout(()=>j(""),5e3)},je=async()=>{if(!C){Ie("Please select a solution first");return}try{b(!0);const ne=await new Fc({environmentUrl:u,accessToken:c}).fetchSolution(C),W=new hp({format:x,includeAttributes:te,includeRelationships:de,maxAttributesPerTable:Pe}).generate(ne);se(W),await window.toolboxAPI.showNotification({title:"Success",body:"ERD generated successfully",type:"success"})}catch(V){Ie(`Failed to generate ERD: ${V.message}`)}finally{b(!1)}},xe=async()=>{if(!L)return;const ne=`${C}-erd.${{mermaid:"mmd",plantuml:"puml",graphviz:"dot"}[x]}`;try{await window.toolboxAPI.saveFile(ne,L)&&await window.toolboxAPI.showNotification({title:"Success",body:"File saved successfully",type:"success"})}catch(_){Ie(`Failed to save file: ${_.message}`)}},Ne=async()=>{if(L)try{await window.toolboxAPI.copyToClipboard(L),await window.toolboxAPI.showNotification({title:"Success",body:"Copied to clipboard",type:"success"})}catch(V){Ie(`Failed to copy: ${V.message}`)}},qe=()=>L?fe==="visual"&&x==="mermaid"?Q.jsx("div",{className:"mermaid-container",dangerouslySetInnerHTML:{__html:L},ref:V=>{if(V&&window.mermaid)try{window.mermaid.init(void 0,V)}catch(ne){console.error("Mermaid rendering error:",ne)}}}):Q.jsx("pre",{className:"diagram-text",children:L}):null;return H?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"})]}),O&&Q.jsx("div",{className:"error",children:O}),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:V=>N(V.target.value),disabled:m.length===0,children:[Q.jsx("option",{value:"",children:"-- Select a Solution --"}),m.map(V=>Q.jsxs("option",{value:V.uniqueName,children:[V.displayName," (",V.version,")"]},V.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:()=>D("mermaid"),children:"Mermaid"}),Q.jsx("button",{className:`format-btn ${x==="plantuml"?"active":""}`,onClick:()=>D("plantuml"),children:"PlantUML"}),Q.jsx("button",{className:`format-btn ${x==="graphviz"?"active":""}`,onClick:()=>D("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:V=>he(V.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:V=>ue(V.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:Pe,onChange:V=>Qe(parseInt(V.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||H,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:()=>le(fe==="visual"?"text":"visual"),children:fe==="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:qe()})]})]})}mp.createRoot(document.getElementById("root")).render(Q.jsx(Ve.StrictMode,{children:Q.jsx(Wm,{})}));
48
+ `+p):f.stack=p}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:p}=u;f!==void 0&&bl.assertOptions(f,{silentJSONParsing:_t.transitional(_t.boolean),forcedJSONParsing:_t.transitional(_t.boolean),clarifyTimeoutError:_t.transitional(_t.boolean)},!1),c!=null&&(k.isFunction(c)?u.paramsSerializer={serialize:c}:bl.assertOptions(c,{encode:_t.function,serialize:_t.function},!0)),u.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?u.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:u.allowAbsoluteUrls=!0),bl.assertOptions(u,{baseUrl:_t.spelling("baseURL"),withXsrfToken:_t.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"],O=>{delete p[O]}),u.headers=rt.concat(m,p);const w=[];let C=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(u)===!1||(C=C&&j.synchronous,w.unshift(j.fulfilled,j.rejected))});const N=[];this.interceptors.response.forEach(function(j){N.push(j.fulfilled,j.rejected)});let x,D=0,H;if(!C){const O=[Dc.bind(this),void 0];for(O.unshift(...w),O.push(...N),H=O.length,x=Promise.resolve(u);D<H;)x=x.then(O[D++],O[D++]);return x}H=w.length;let b=u;for(;D<H;){const O=w[D++],j=w[D++];try{b=O(b)}catch(L){j.call(this,L);break}}try{x=Dc.call(this,b)}catch(O){return Promise.reject(O)}for(D=0,H=N.length;D<H;)x=x.then(N[D++],N[D++]);return x}getUri(o){o=vn(this.defaults,o);const u=ef(o.baseURL,o.url,o.allowAbsoluteUrls);return Gc(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(p,m,w){return this.request(vn(w||{},{method:o,headers:f?{"Content-Type":"multipart/form-data"}:{},url:p,data:m}))}}gn.prototype[o]=u(),gn.prototype[o+"Form"]=u(!0)});let Bm=class of{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(w=>{f.subscribe(w),p=w}).then(c);return m.cancel=function(){f.unsubscribe(p)},m},o(function(p,m,w){f.reason||(f.reason=new qn(p,m,w),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 of(function(c){o=c}),cancel:o}}};function Hm(s){return function(u){return s.apply(null,u)}}function Vm(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 sf(s){const o=new gn(s),u=Mc(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 sf(vn(s,c))},u}const Re=sf(Ir);Re.Axios=gn;Re.CanceledError=qn;Re.CancelToken=Bm;Re.isCancel=Zc;Re.VERSION=lf;Re.toFormData=li;Re.AxiosError=Y;Re.Cancel=Re.CanceledError;Re.all=function(o){return Promise.all(o)};Re.spread=Hm;Re.isAxiosError=Vm;Re.mergeConfig=vn;Re.AxiosHeaders=rt;Re.formToJSON=s=>Yc(k.isHTMLForm(s)?new FormData(s):s);Re.getAdapter=rf.getAdapter;Re.HttpStatusCode=ds;Re.default=Re;const{Axios:Xm,AxiosError:Gm,CanceledError:Jm,isCancel:Ym,CancelToken:Zm,VERSION:bm,all:eh,Cancel:th,isAxiosError:nh,spread:rh,toFormData:lh,AxiosHeaders:ih,HttpStatusCode:oh,formToJSON:sh,getAdapter:uh,mergeConfig:ah}=Re;class Fc{constructor(o){zr(this,"axiosInstance");zr(this,"environmentUrl");zr(this,"apiVersion");this.environmentUrl=o.environmentUrl.replace(/\/$/,""),this.apiVersion=o.apiVersion||"9.2",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 p=await this.axiosInstance.get(`/solutions?$filter=uniquename eq '${o}'&$select=friendlyname,uniquename,_publisherid_value,version&$expand=publisherid($select=customizationprefix)`);if(!p.data.value||p.data.value.length===0)throw new Error(`Solution '${o}' not found`);const m=p.data.value[0],w=((u=m.publisherid)==null?void 0:u.customizationprefix)??"unknown",N=(await this.axiosInstance.get(`/solutioncomponents?$filter=_solutionid_value eq ${m.solutionid} and componenttype eq 1&$select=objectid`)).data.value.map(D=>D.objectid);console.log("tableIds",N);const x=await this.fetchTables(N);return console.log("tables",x),{uniqueName:m.uniquename,displayName:m.friendlyname,version:m.version,publisherPrefix:w,tables:x}}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 p=(await this.axiosInstance.get(`/EntityDefinitions(${o})?$select=LogicalName,DisplayName,SchemaName,PrimaryIdAttribute,PrimaryNameAttribute,TableType,IsIntersect`)).data,w=(await this.axiosInstance.get(`/EntityDefinitions(${o})/Attributes?$select=LogicalName,DisplayName,AttributeType,IsPrimaryId,IsPrimaryName,RequiredLevel`)).data.value.map(N=>{var x,D,H,b;return{logicalName:N.LogicalName,displayName:((D=(x=N.DisplayName)==null?void 0:x.UserLocalizedLabel)==null?void 0:D.Label)||N.LogicalName,type:this.mapAttributeType(N.AttributeType),isPrimaryId:N.IsPrimaryId||!1,isPrimaryName:N.IsPrimaryName||!1,isRequired:((H=N.RequiredLevel)==null?void 0:H.Value)==="ApplicationRequired"||((b=N.RequiredLevel)==null?void 0:b.Value)==="SystemRequired"}}),C=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:w,relationships:C}}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`);for(const w of c.data.value)w.ReferencedEntity===u&&f.push({schemaName:w.SchemaName,type:"OneToMany",relatedTable:w.ReferencingEntity,lookupAttribute:w.ReferencingAttribute});const p=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToOneRelationships?$select=SchemaName,ReferencedEntity,ReferencingEntity,ReferencingAttribute`);for(const w of p.data.value)w.ReferencingEntity===u&&f.push({schemaName:w.SchemaName,type:"ManyToOne",relatedTable:w.ReferencedEntity,lookupAttribute:w.ReferencingAttribute});const m=await this.axiosInstance.get(`/EntityDefinitions(${o})/ManyToManyRelationships?$select=SchemaName,Entity1LogicalName,Entity2LogicalName,IntersectEntityName`);for(const w of m.data.value){const C=w.Entity1LogicalName===u;f.push({schemaName:w.SchemaName,type:"ManyToMany",relatedTable:C?w.Entity2LogicalName:w.Entity1LogicalName,intersectTable:w.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{return(await this.axiosInstance.get("/solutions?$select=uniquename,friendlyname,version&$filter=isvisible eq true&$orderby=friendlyname asc")).data.value.map(c=>({uniqueName:c.uniquename,displayName:c.friendlyname,version:c.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 Wm(){const[s,o]=Ve.useState(null),[u,f]=Ve.useState(""),[c,p]=Ve.useState(""),[m,w]=Ve.useState([]),[C,N]=Ve.useState(""),[x,D]=Ve.useState("mermaid"),[H,b]=Ve.useState(!0),[O,j]=Ve.useState(""),[L,se]=Ve.useState(""),[fe,le]=Ve.useState("visual"),[te,he]=Ve.useState(!0),[de,ue]=Ve.useState(!0),[Pe,Qe]=Ve.useState(10);Ve.useEffect(()=>{const V=_=>{if(_.data&&_.data.type==="TOOLBOX_CONTEXT"){debugger;window.TOOLBOX_CONTEXT=_.data.data,o(_.data.data),console.log("Received TOOLBOX_CONTEXT:",window.TOOLBOX_CONTEXT)}};return window.addEventListener("message",V),(async()=>{try{debugger;let _=s||window.TOOLBOX_CONTEXT;_||(_=await window.toolboxAPI.getToolContext());debugger;f((_==null?void 0:_.connectionUrl)||""),p((_==null?void 0:_.accessToken)||""),b(!1)}catch(_){console.error("Failed to initialize tool:",_),j("Failed to load connection context"),b(!1)}})(),()=>{window.removeEventListener("message",V)}},[s]),Ve.useEffect(()=>{u&&c&&Ge()},[u,c]);const Ge=async()=>{try{const ne=await new Fc({environmentUrl:u,accessToken:c}).listSolutions();w(ne)}catch(V){Ie(`Failed to load solutions: ${V.message}`)}},Ie=V=>{j(V),setTimeout(()=>j(""),5e3)},je=async()=>{if(!C){Ie("Please select a solution first");return}try{b(!0);const ne=await new Fc({environmentUrl:u,accessToken:c}).fetchSolution(C),W=new hp({format:x,includeAttributes:te,includeRelationships:de,maxAttributesPerTable:Pe}).generate(ne);se(W),await window.toolboxAPI.showNotification({title:"Success",body:"ERD generated successfully",type:"success"})}catch(V){Ie(`Failed to generate ERD: ${V.message}`)}finally{b(!1)}},xe=async()=>{if(!L)return;const ne=`${C}-erd.${{mermaid:"mmd",plantuml:"puml",graphviz:"dot"}[x]}`;try{await window.toolboxAPI.saveFile(ne,L)&&await window.toolboxAPI.showNotification({title:"Success",body:"File saved successfully",type:"success"})}catch(_){Ie(`Failed to save file: ${_.message}`)}},Ne=async()=>{if(L)try{await window.toolboxAPI.copyToClipboard(L),await window.toolboxAPI.showNotification({title:"Success",body:"Copied to clipboard",type:"success"})}catch(V){Ie(`Failed to copy: ${V.message}`)}},qe=()=>L?fe==="visual"&&x==="mermaid"?Q.jsx("div",{className:"mermaid-container",dangerouslySetInnerHTML:{__html:L},ref:V=>{if(V&&window.mermaid)try{window.mermaid.init(void 0,V)}catch(ne){console.error("Mermaid rendering error:",ne)}}}):Q.jsx("pre",{className:"diagram-text",children:L}):null;return H?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"})]}),O&&Q.jsx("div",{className:"error",children:O}),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:V=>N(V.target.value),disabled:m.length===0,children:[Q.jsx("option",{value:"",children:"-- Select a Solution --"}),m.map(V=>Q.jsxs("option",{value:V.uniqueName,children:[V.displayName," (",V.version,")"]},V.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:()=>D("mermaid"),children:"Mermaid"}),Q.jsx("button",{className:`format-btn ${x==="plantuml"?"active":""}`,onClick:()=>D("plantuml"),children:"PlantUML"}),Q.jsx("button",{className:`format-btn ${x==="graphviz"?"active":""}`,onClick:()=>D("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:V=>he(V.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:V=>ue(V.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:Pe,onChange:V=>Qe(parseInt(V.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||H,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:()=>le(fe==="visual"?"text":"visual"),children:fe==="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:qe()})]})]})}mp.createRoot(document.getElementById("root")).render(Q.jsx(Ve.StrictMode,{children:Q.jsx(Wm,{})}));
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.0.11",
4
+ "version": "0.0.13",
5
5
  "description": "Generate Entity Relationship Diagrams (ERD) for Dataverse solutions - React-based tool for PowerPlatform ToolBox",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -12,6 +12,18 @@
12
12
  "files": [
13
13
  "dist"
14
14
  ],
15
+ "csp": {
16
+ "connect-src": [
17
+ "https://*.dynamics.com",
18
+ "https://*.crm*.dynamics.com"
19
+ ],
20
+ "script-src": [
21
+ "https://cdn.jsdelivr.net"
22
+ ],
23
+ "style-src": [
24
+ "'unsafe-inline'"
25
+ ]
26
+ },
15
27
  "keywords": [
16
28
  "dataverse",
17
29
  "erd",