@owox/web 0.35.0 → 0.36.0
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/assets/ModelCanvas-BIPDBSA2.js +12 -0
- package/dist/assets/RelationshipCanvas-BoamwL_P.js +1 -0
- package/dist/assets/{erd-fields-section-w0MuCbrx.js → erd-fields-section-BDlFV3FN.js} +7 -7
- package/dist/assets/index-C5zthIAZ.css +1 -0
- package/dist/assets/index-D5dI1sj2.js +46 -0
- package/dist/assets/index-DbpdnvsV.js +1757 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/ModelCanvas-BmvwRtKX.js +0 -2
- package/dist/assets/RelationshipCanvas-BJwnmPDj.js +0 -1
- package/dist/assets/index-BobN8jFh.js +0 -46
- package/dist/assets/index-CHid1y1x.js +0 -1457
- package/dist/assets/index-OJoOSyiH.css +0 -1
package/dist/index.html
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>OWOX</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-DbpdnvsV.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C5zthIAZ.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body translate="no" class="notranslate">
|
|
13
13
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BobN8jFh.js","assets/erd-fields-section-w0MuCbrx.js","assets/index-CHid1y1x.js","assets/index-OJoOSyiH.css","assets/erd-fields-section-BnuhLJ6X.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as a,j as t,k as Ne,S as nt,l as oe,P as st,m as at,D as re,n as it,o as ot,p as rt,L as lt,q as ct,s as dt,T as Re,a as Oe,R as ut,H as ft,b as _e,t as pt,v as ht,w as gt,I as mt,E as xt,x as bt,y as N,z as wt,A as Et,_ as Ct,F as Te,G as le,c as ce}from"./index-CHid1y1x.js";import{I as vt,J as jt,K as St,s as yt,v as Dt,w as Lt,W as It,o as fe,t as Nt,B as Rt,D as Pe,x as Ot,y as _t,z as Tt,A as Pt,u as kt,P as X,n as de,H as we,S as Ee,Q as At,a as Mt,b as $t,N as Ft,R as Ut,c as Ht,d as ue,e as Qt,f as Ce,p as Gt,r as Vt,h as ve,T as Bt,U as qt,i as zt,L as Wt,Z as Kt,j as Jt,C as Yt,k as Zt,M as Xt,l as en,q as tn}from"./erd-fields-section-w0MuCbrx.js";const nn=(n,e)=>[n,e].sort().join("->"),sn=56;function an(n,e=sn){const r=new Map;for(const i of n){if(i.sourceId===i.targetId)continue;const d=nn(i.sourceId,i.targetId),h=r.get(d);h?h.push(i):r.set(d,[i])}const u=new Map;for(const i of n)i.sourceId===i.targetId&&u.set(i.id,0);for(const i of r.values()){const d=[...i].sort((m,b)=>m.id.localeCompare(b.id)),h=d.length;d.forEach((m,b)=>{u.set(m.id,(b-(h-1)/2)*e)})}return u}const on=212,je=116,rn=256,ln=88;function pe(n){return n==="erd"?rn:on}function ke(n,e,r=!1,u=!1){const i=(r?-36:0)+(u?-30:0);if(e!=="erd")return je+i;const d=n.fields??[];if(d.length===0)return je+i;const h=vt(d),m=d.length>h;return ln+i+h*jt+(m?St:0)}function cn(n,e,r,u,i,d){let h,m,b,y;if(d==="vertical"){const g=Math.max(40,Math.abs(u-e)*.3);h=n+i,m=e+g,b=r+i,y=u-g}else{const g=Math.max(40,Math.abs(r-n)*.3);h=n+g,m=e+i,b=r-g,y=u+i}return{path:`M ${n} ${e} C ${h} ${m}, ${b} ${y}, ${r} ${u}`,labelX:(n+3*h+3*b+r)/8,labelY:(e+3*m+3*y+u)/8}}function dn({id:n,sourceX:e,sourceY:r,targetX:u,targetY:i,sourcePosition:d,targetPosition:h,selected:m,data:b}){const{bowOffset:y,warning:g,joinLabel:x,dimmed:E,direction:w,bidirectional:R}=b;let v;if(y!==0)v=cn(e,r,u,i,y,w);else{const[O,I,M]=yt({sourceX:e,sourceY:r,sourcePosition:d,targetX:u,targetY:i,targetPosition:h});v={path:O,labelX:I,labelY:M}}const j=g?It:m?fe:Nt,D=a.useId(),L=Dt("mc-arrow",D);return t.jsxs(t.Fragment,{children:[t.jsx(Lt,{markerId:L,color:j,withStart:R}),t.jsx(Rt,{id:n,path:v.path,markerEnd:`url(#${L}-end)`,markerStart:R?`url(#${L}-start)`:void 0,style:{stroke:j,strokeWidth:m?_t:Tt,strokeDasharray:g?Ot:void 0,opacity:E?Pe:1,transition:"opacity 0.2s, stroke 0.2s"}}),t.jsx(Pt,{x:v.labelX,y:v.labelY,lines:x,selected:m??!1,dimmed:E})]})}const un=100,fn=200;function B(n,e){return`${n} ${e}${n===1?"":"s"}`}function pn({dataMartTitle:n,summary:e,onOpenQuality:r,onRunQuality:u}){const[i,d]=a.useState(!1),[h,m]=a.useState(!1),b=a.useRef(null),y=a.useRef(null),g=a.useRef(null),x=a.useRef(null),E=a.useRef(null),w=a.useRef(!1),R=a.useRef(!1),v=a.useRef(!1),j=Ne(e),D=j.icon,L=[{count:e.errorChecks,singular:"execution error",tone:"error",icon:nt},{count:e.errorFindings,singular:"critical finding",tone:"error",icon:oe},{count:e.warningFindings,singular:"warning finding",tone:"warning",icon:oe},{count:e.noticeFindings,singular:"notice finding",tone:"notice",icon:oe}].filter(l=>l.count>0),O=(e.state==="ISSUES"||e.state==="EXECUTION_FAILED")&&L.length>0,I=L.map(l=>B(l.count,l.singular)).join(", "),M=`Open Data Quality for ${n}: ${j.label}${O?`, ${I}`:""}`,C=j.isActive,te=e.state==="QUEUED"?"Queued":e.state==="RUNNING"?"Started":"Last checked";function H(){x.current!==null&&(clearTimeout(x.current),x.current=null)}function q(){E.current!==null&&(clearTimeout(E.current),E.current=null)}function A(){H(),q()}function K(){q(),!(i||w.current||x.current!==null)&&(x.current=setTimeout(()=>{x.current=null,!w.current&&d(!0)},un))}function _(){H(),!(!i||w.current||E.current!==null)&&(E.current=setTimeout(()=>{E.current=null,!w.current&&d(!1)},fn))}function P(l){if(l.stopPropagation(),l.preventDefault(),A(),w.current&&i){w.current=!1,d(!1);return}w.current=!0,d(!0),l.detail===0&&queueMicrotask(()=>{var S;(S=g.current)==null||S.focus()})}function ne(l){if(A(),l){w.current=!0,d(!0);return}w.current=!1,d(!1)}function se(l){l.stopPropagation(),l.preventDefault(),r()}async function ae(l){if(l.stopPropagation(),l.preventDefault(),!(C||h)){m(!0);try{await u()}finally{m(!1)}}}return a.useEffect(()=>()=>{x.current!==null&&clearTimeout(x.current),E.current!==null&&clearTimeout(E.current)},[]),a.useEffect(()=>{if(!i)return;function l(S){var Q,$;const T=S.target;T instanceof Node&&((Q=b.current)!=null&&Q.contains(T)||($=y.current)!=null&&$.contains(T)||(x.current!==null&&(clearTimeout(x.current),x.current=null),E.current!==null&&(clearTimeout(E.current),E.current=null),w.current=!1,d(!1)))}return document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("pointerdown",l,!0)}},[i]),t.jsxs(st,{open:i,onOpenChange:ne,children:[t.jsx(at,{asChild:!0,children:t.jsx("button",{ref:b,type:"button",className:`${O?"":re[j.tone]} -ml-0.5 inline-flex shrink-0 cursor-pointer items-center rounded p-0.5 transition-colors ${O?"gap-1.5":""}`,"aria-label":M,onPointerDown:l=>{l.stopPropagation()},onPointerEnter:()=>{K()},onPointerLeave:()=>{_()},onFocus:()=>{if(v.current){v.current=!1;return}K()},onBlur:()=>{_()},onClick:P,children:O?L.map(l=>{const S=B(l.count,l.singular),T=l.icon;return t.jsxs("span",{role:"img","aria-label":S,className:`${re[l.tone]} inline-flex items-center gap-0.5`,children:[t.jsx(T,{className:"size-4","aria-hidden":!0}),t.jsx("span",{className:"leading-none font-medium tabular-nums",children:l.count})]},l.singular)}):t.jsx(D,{className:`size-4 ${e.state==="RUNNING"?"animate-spin":""}`,"aria-hidden":!0})})}),t.jsxs(it,{ref:y,side:"top",align:"center",role:"region","aria-label":`Data Quality checks for ${n}`,className:"w-72 max-w-72 p-3 text-xs sm:w-72 sm:max-w-72",onOpenAutoFocus:l=>{l.preventDefault()},onCloseAutoFocus:l=>{var S;l.preventDefault(),R.current&&(R.current=!1,v.current=!0,(S=b.current)==null||S.focus({preventScroll:!0}),queueMicrotask(()=>{v.current=!1}))},onEscapeKeyDown:()=>{R.current=!0},onPointerEnter:()=>{q()},onPointerLeave:()=>{_()},onPointerDown:l=>{l.stopPropagation()},children:[t.jsxs("div",{className:"border-border flex items-center justify-between gap-3 border-b pb-2",children:[t.jsx(ot,{className:"text-sm font-semibold whitespace-nowrap",children:"Data Quality checks"}),t.jsx("span",{className:`${re[j.tone]} shrink-0 font-medium whitespace-nowrap`,children:j.label})]}),t.jsxs("div",{className:"text-muted-foreground space-y-1 py-2",children:[e.enabledChecks>0&&t.jsxs("p",{children:[e.enabledChecks," enabled"]}),C?t.jsx("p",{children:"Terminal results will be available after this run finishes."}):t.jsxs(t.Fragment,{children:[e.passedChecks>0&&t.jsxs("p",{children:[e.passedChecks," passed"]}),e.notApplicableChecks>0&&t.jsxs("p",{children:[e.notApplicableChecks," not applicable"]}),e.errorChecks>0&&t.jsx("p",{children:B(e.errorChecks,"execution error")}),e.errorFindings>0&&t.jsx("p",{children:B(e.errorFindings,"critical finding")}),e.warningFindings>0&&t.jsx("p",{children:B(e.warningFindings,"warning finding")}),e.noticeFindings>0&&t.jsx("p",{children:B(e.noticeFindings,"notice finding")})]}),e.lastRunAt&&t.jsx("p",{className:"text-foreground pt-2 pb-1 font-medium",children:`${te} ${rt(e.lastRunAt)}`})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{ref:g,type:"button",className:"border-input bg-background hover:bg-muted inline-flex cursor-pointer items-center justify-center rounded-md border px-3 py-1.5 font-medium transition-colors","aria-label":`Open Data Quality page for ${n}`,onPointerDown:l=>{l.stopPropagation()},onClick:se,children:"Open"}),t.jsxs("button",{type:"button",className:"bg-primary text-primary-foreground hover:bg-primary/90 inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Run Quality for ${n}`,title:C?"A Data Quality run is already active":void 0,disabled:C||h,onPointerDown:l=>{l.stopPropagation()},onClick:l=>{ae(l)},children:[h?t.jsx(lt,{className:"size-3.5 animate-spin","aria-hidden":"true"}):t.jsx(ct,{className:"size-3.5","aria-hidden":"true"}),h?"Starting…":"Run checks"]})]})]})]})}function hn({dataMartTitle:n,block:e,isChecking:r=!1}){const u=r?"checking…":dt(e);return t.jsxs(Re,{children:[t.jsx(Oe,{asChild:!0,children:t.jsx("button",{type:"button",className:`nodrag inline-flex cursor-default items-center rounded p-0.5 transition-colors ${r||e!=null&&e.dataLastUpdatedAt?"text-muted-foreground hover:text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,"aria-label":`Data Last Updated for ${n}: ${u}`,onPointerDown:i=>{i.stopPropagation()},children:r?t.jsx(ut,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),t.jsx(_e,{side:"top",align:"start",role:"tooltip",className:"max-w-xs",children:r?t.jsx("div",{className:"text-xs",children:"Checking Data Last Updated…"}):e?t.jsx(pt,{block:e}):t.jsx("div",{className:"text-xs",children:"Data Last Updated has not been checked yet. Use Actions → Check Data Last Updated to measure the visible Data Marts."})})]})}function gn({id:n,data:e,selected:r}){const[u,i]=a.useState(!1),d=kt();a.useEffect(()=>{d(n)},[u,n,d]);const h=ht[Ne(e.qualitySummary).tone],m=e.viewMode==="erd",b=e.fields,y=m&&b.length>0,g=e.objectLabels??gt,x=!g.source,E=!g.fields,w=!g.status,R=x&&!!e.definitionType,v=w&&R,j=g.source&&g.fields&&g.status,D=j?"pl-3.5":"pl-[16px]",L=e.direction==="vertical"?X.Top:X.Left,O=e.direction==="vertical"?X.Bottom:X.Right,I=`Open ${e.title} in new tab`;function M(C){C.stopPropagation(),C.preventDefault(),e.onOpenExternal()}return t.jsxs("div",{className:"bg-background relative flex cursor-grab flex-col overflow-hidden rounded-sm border shadow-sm active:cursor-grabbing",style:{width:pe(e.viewMode),borderColor:e.highlighted?de:r?fe:void 0,boxShadow:e.highlighted?`0 0 0 3px ${de}40, 0 0 12px ${de}60`:r?`0 0 0 1px ${fe}`:void 0,opacity:e.dimmed?Pe:1,filter:e.dimmed?"grayscale(0.8)":void 0,animation:e.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s"},children:[!j&&t.jsx("span",{className:`absolute inset-y-0 top-0 bottom-0 left-0 w-1 rounded-tr-full rounded-br-full ${h}`,"aria-hidden":"true"}),e.hasIncoming&&t.jsx(we,{type:"target",position:L,isConnectable:!1,style:Ee}),t.jsxs("div",{className:`flex items-center gap-2 pt-3 pr-3.5 ${D} ${j?"pb-3":"pb-1"}`,children:[t.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.title,children:e.title}),e.description&&t.jsxs(Re,{children:[t.jsx(Oe,{asChild:!0,children:t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${e.title}`,onPointerDown:C=>{C.stopPropagation()},children:t.jsx(mt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),t.jsx(_e,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:e.description})]}),t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:C=>{C.stopPropagation()},onClick:M,title:I,"aria-label":I,children:t.jsx(xt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),(w||x)&&t.jsxs("div",{className:`text-muted-foreground flex items-center ${v?"gap-0":"gap-1"} pt-1 pr-3.5 text-[11px] ${D}`,children:[w&&t.jsx(At,{isDraft:e.isDraft,joined:v}),x&&t.jsx(Mt,{type:e.definitionType,joined:v})]}),!j&&t.jsxs("div",{className:`text-muted-foreground flex items-center gap-1 pt-1.5 pr-3.5 pb-3 text-[11px] ${D}`,children:[t.jsx(pn,{dataMartTitle:e.title,summary:e.qualitySummary,onOpenQuality:e.onOpenQuality,onRunQuality:e.onRunQuality}),t.jsx(hn,{dataMartTitle:e.title,block:e.dataLastUpdated,isChecking:e.isCheckingDataLastUpdated}),E&&t.jsxs("span",{className:"ml-auto shrink-0",children:[e.fieldCount," field",e.fieldCount!==1?"s":""]})]}),y&&t.jsx($t,{fields:b,expanded:u,onToggleExpanded:()=>{i(C=>!C)}}),e.hasOutgoing&&t.jsx(we,{type:"source",position:O,isConnectable:!1,style:Ee})]})}const Se="model-canvas-layout",ye="model-canvas-show-join-fields",De="model-canvas-view-mode",Le="model-canvas-object-labels",mn="model-canvas-positions";function ee(n){return`${mn}:${n}`}function xn(n){if(!n)return{};const e=N.get(ee(n),"json");if(!e)return{};const r={};for(const[u,i]of Object.entries(e)){const d=i;d&&typeof d.x=="number"&&typeof d.y=="number"&&(r[u]={x:d.x,y:d.y})}return r}const W=.2,bn=150,wn={modelCanvasNode:gn},En={modelCanvasEdge:dn};function Cn(n){return JSON.stringify(n.map(({id:e,title:r,status:u,description:i,fieldCount:d,definitionType:h,fields:m})=>({id:e,title:r,status:u,description:i,fieldCount:d,definitionType:h,fields:m})))}function vn(n){return JSON.stringify(n)}function Ie(n,e){const r=e(n),u=a.useRef({signature:r,value:n});return u.current.signature!==r&&(u.current={signature:r,value:n}),u.current.value}function jn(n){const{node:e,highlight:r,viewMode:u,objectLabels:i}=n,d=i.source&&i.status,h=i.source&&i.fields&&i.status;return{id:e.id,type:"modelCanvasNode",position:n.position,width:pe(u),height:ke(e,u,d,h),draggable:!0,selectable:!1,focusable:!1,deletable:!1,style:tn,data:{title:e.title,isDraft:e.status===Te.DRAFT,fieldCount:e.fieldCount,description:e.description,definitionType:e.definitionType??null,fields:e.fields??[],viewMode:u,objectLabels:i,dataLastUpdated:e.dataLastUpdated,isCheckingDataLastUpdated:n.isCheckingDataLastUpdated,hasIncoming:n.hasIncoming,hasOutgoing:n.hasOutgoing,highlighted:r.highlighted,dimmed:r.dimmed,direction:n.direction,onOpenExternal:n.onOpenExternal,qualitySummary:e.qualitySummary,onOpenQuality:n.onOpenQuality,onRunQuality:n.onRunQuality}}}function Sn(n){return n.joinConditions.map(e=>`${e.sourceFieldName} = ${e.targetFieldName}`)}function yn(n){const{edge:e,warning:r}=n;return{id:e.id,type:"modelCanvasEdge",source:e.sourceId,target:e.targetId,focusable:!1,selectable:!0,deletable:!1,data:{bowOffset:n.bowOffset,warning:r,joinLabel:n.joinLabel,dimmed:n.dimmed,direction:n.direction,bidirectional:e.bidirectional}}}function Dn({nodes:n,edges:e,searchQuery:r,onOpenDataMart:u,onOpenQuality:i,onRunQuality:d,isCheckingDataLastUpdated:h=!1,storageId:m,storageTitle:b,exportApiRef:y}){const g=Ht(),x=ue(o=>o.width),E=ue(o=>o.height),w=ue(o=>o.domNode),R=a.useRef(u);R.current=u;const v=a.useRef(i);v.current=i;const j=a.useRef(d);j.current=d;const D=a.useRef(n);D.current=n;const L=a.useRef(r);L.current=r;const O=a.useRef(h);O.current=h;const[I,M]=a.useState(()=>bt(N.get(Se))),[C,te]=a.useState(()=>wt(N.get(De))),[H,q]=a.useState(()=>N.get(ye,"boolean")??!1),[A,K]=a.useState(()=>Et(N.get(Le))),_=a.useRef(null),P=a.useRef(m);(_.current===null||P.current!==m)&&(P.current=m,_.current=xn(m));const[ne,se]=a.useState(0),[ae,l]=a.useState(!1),[S,T]=a.useState([]),[Q,$]=a.useState([]),he=a.useMemo(()=>Qt(S),[S]),G=Ie(n,Cn),F=Ie(e,vn);a.useImperativeHandle(y,()=>({exportCanvas:async o=>{const{exportModelCanvas:p}=await Ct(async()=>{const{exportModelCanvas:c}=await import("./index-BobN8jFh.js");return{exportModelCanvas:c}},__vite__mapDeps([0,1,2,3,4]));return p(o,{viewport:(w==null?void 0:w.querySelector(".react-flow__viewport"))??null,flowNodes:S,nodes:n,edges:e,storageTitle:b})}}),[w,S,n,e,b]),a.useEffect(()=>{const o=new Set(F.map(s=>s.targetId)),p=new Set(F.map(s=>s.sourceId)),c=new Map(G.map(s=>[s.id,s.status===Te.DRAFT])),f=Ce(G,L.current,s=>s.id,s=>s.title),k=A.source&&A.status,V=G.map(s=>({id:s.id,width:pe(C),height:ke(s,C,k)})),z=H?new Map(F.map(s=>[s.id,Sn(s)])):new Map,J=F.map(s=>({id:s.id,sourceId:s.sourceId,targetId:s.targetId,label:Gt(z.get(s.id)??[])})),{positions:Y}=Vt(V,J,I),Ke=an(F),Je=new Set(G.map(s=>s.id)),ge=Object.entries(_.current??{}),Z=Object.fromEntries(ge.filter(([s])=>Je.has(s)));ge.length!==Object.keys(Z).length&&(_.current=Z,P.current&&N.set(ee(P.current),Z));const Ye=new Map(D.current.map(s=>[s.id,s.qualitySummary])),Ze=new Map(D.current.map(s=>[s.id,s.dataLastUpdated]));T(G.map(s=>jn({node:{...s,qualitySummary:Ye.get(s.id)??s.qualitySummary,dataLastUpdated:Ze.get(s.id)??s.dataLastUpdated},position:Z[s.id]??Y.get(s.id)??{x:0,y:0},hasIncoming:o.has(s.id),hasOutgoing:p.has(s.id),highlight:f.get(s.id)??ve,direction:I,viewMode:C,objectLabels:A,onOpenExternal:()=>{R.current(s.id)},onOpenQuality:()=>{v.current(s.id)},onRunQuality:()=>j.current(s.id),isCheckingDataLastUpdated:O.current}))),$(F.map(s=>{var xe,be;const et=((xe=f.get(s.sourceId))==null?void 0:xe.dimmed)??!1,tt=((be=f.get(s.targetId))==null?void 0:be.dimmed)??!1;return yn({edge:s,joinLabel:z.get(s.id)??[],bowOffset:Ke.get(s.id)??0,warning:s.joinNotConfigured||(c.get(s.sourceId)??!1)||(c.get(s.targetId)??!1),dimmed:et&&tt,direction:I})})),l(!0);const me=[...f.entries()].filter(([,s])=>s.highlighted).map(([s])=>s),Xe=requestAnimationFrame(()=>{g.fitView(me.length>0?{nodes:me.map(s=>({id:s})),duration:300,padding:W}:{padding:W,duration:300})});return()=>{cancelAnimationFrame(Xe)}},[G,F,I,ne,C,H,A,g]);const Ae=a.useCallback(o=>{T(p=>Bt(o,p))},[]),Me=a.useCallback(o=>{$(p=>qt(o,p))},[]),[U,ie]=a.useState(null),$e=a.useCallback((o,p)=>{ie(c=>c===p.id?null:p.id),$(c=>c.some(f=>f.selected)?c.map(f=>f.selected?{...f,selected:!1}:f):c)},[]),Fe=a.useCallback(()=>{ie(null)},[]),Ue=a.useCallback(()=>{ie(null)},[]),He=a.useMemo(()=>U?S.map(o=>o.id===U?{...o,selected:!0}:o):S,[S,U]),Qe=a.useMemo(()=>U?Q.map(o=>o.source===U||o.target===U?{...o,selected:!0}:o):Q,[Q,U]),Ge=a.useCallback((o,p)=>{const c=_.current??{};c[p.id]={x:p.position.x,y:p.position.y},_.current=c,P.current&&N.set(ee(P.current),c)},[]);a.useEffect(()=>{const o=new Map(n.map(c=>[c.id,c.qualitySummary])),p=new Map(n.map(c=>[c.id,c.dataLastUpdated]));T(c=>c.map(f=>{const k=o.get(f.id)??f.data.qualitySummary,V=p.has(f.id)?p.get(f.id)??null:f.data.dataLastUpdated;return f.data.qualitySummary!==k||f.data.dataLastUpdated!==V?{...f,data:{...f.data,qualitySummary:k,dataLastUpdated:V}}:f}))},[n]),a.useEffect(()=>{T(o=>o.map(p=>p.data.isCheckingDataLastUpdated===h?p:{...p,data:{...p.data,isCheckingDataLastUpdated:h}}))},[h]),a.useEffect(()=>{const o=Ce(D.current,r,c=>c.id,c=>c.title);T(c=>c.map(f=>{const k=o.get(f.id)??ve;return f.data.highlighted===k.highlighted&&f.data.dimmed===k.dimmed?f:{...f,data:{...f.data,...k}}})),$(c=>c.map(f=>{var J,Y;const k=((J=o.get(f.source))==null?void 0:J.dimmed)??!1,V=((Y=o.get(f.target))==null?void 0:Y.dimmed)??!1,z=k&&V;return f.data.dimmed===z?f:{...f,data:{...f.data,dimmed:z}}}));const p=[...o.entries()].filter(([,c])=>c.highlighted).map(([c])=>c);p.length>0&&g.fitView({nodes:p.map(c=>({id:c})),duration:300,padding:W})},[r,g]);const Ve=a.useCallback(o=>{M(o),N.set(Se,o),_.current={},P.current&&N.remove(ee(P.current)),se(p=>p+1)},[]),Be=a.useCallback(o=>{K(p=>le(p)===le(o)?p:(N.set(Le,le(o)),o))},[]),qe=a.useCallback(o=>{te(o),N.set(De,o)},[]),ze=a.useCallback(o=>{q(o),N.set(ye,o)},[]),We=a.useCallback((o,p)=>{if(x===0||E===0)return;const c=zt(p,he,x,E,bn);c.x===p.x&&c.y===p.y||g.setViewport(c)},[he,E,x,g]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[t.jsx(ce,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{g.fitView({padding:W,duration:300})},"aria-label":"Fit to view",children:t.jsx(Wt,{className:"h-6 w-6"})}),t.jsx(ce,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{g.zoomIn({duration:150})},"aria-label":"Zoom in",children:t.jsx(Kt,{className:"h-6 w-6"})}),t.jsx(ce,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{g.zoomOut({duration:150})},"aria-label":"Zoom out",children:t.jsx(Jt,{className:"h-6 w-6"})}),t.jsx(Yt,{viewMode:C,onViewModeChange:qe,direction:I,onDirectionChange:Ve,showJoinFields:H,onShowJoinFieldsChange:ze,objectLabels:A,onObjectLabelsChange:Be})]}),ae&&t.jsx(Zt,{nodes:He,edges:Qe,nodeTypes:wn,edgeTypes:En,onNodesChange:Ae,onEdgesChange:Me,onNodeDragStop:Ge,onNodeClick:$e,onEdgeClick:Ue,onPaneClick:Fe,deleteKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,edgesFocusable:!1,minZoom:.05,maxZoom:2,onMove:We,fitView:!0,fitViewOptions:{padding:W},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:t.jsx(Xt,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:en})})]})}function Nn({nodes:n,edges:e,searchQuery:r,onOpenDataMart:u,onOpenQuality:i,onRunQuality:d,isCheckingDataLastUpdated:h,storageId:m,storageTitle:b,exportApiRef:y,className:g,style:x}){return n.length===0?null:t.jsxs("div",{className:`relative overflow-hidden ${g??""}`,style:x??{height:480},children:[t.jsx("style",{children:Ft}),t.jsx(Ut,{children:t.jsx(Dn,{nodes:n,edges:e,searchQuery:r,onOpenDataMart:u,onOpenQuality:i,onRunQuality:d,isCheckingDataLastUpdated:h,storageId:m,storageTitle:b,exportApiRef:y})})]})}export{Nn as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as De,r,j as s,C as Se,N as Oe,T as _e,a as ve,I as Ae,b as Me,E as Re,B as ke,c as U,M as Pe,g as Te,d as Le,e as He,h as Fe,i as ue,f as Ge}from"./index-CHid1y1x.js";import{g as We,N as Ke,R as ze,u as Be,P as J,E as ge,H as Q,S as ee,a as $e,b as Ye,c as Ze,d as he,e as Ve,f as Xe,h as Ue,i as Je,L as qe,Z as Qe,j as et,C as tt,k as st,M as it,l as nt,O as at,W as ne,m as ot,D as xe,n as te,o as ie,p as rt,r as lt,q as ct,s as dt,t as ut,v as gt,w as ht,B as ft,x as mt,y as pt,z as xt,A as bt,F as Nt,G as Ct}from"./erd-fields-section-w0MuCbrx.js";const $=3,be=.05,Et=1e-4,fe=1;function yt(i,e,l,p){const c=i.maxX-i.minX,h=i.maxY-i.minY;return c<=0||h<=0||e<=0||l<=0?null:We({x:i.minX,y:i.minY,width:c,height:h},e,l,be,$,p)}function It(i){const e=Number.isFinite(i)&&i>0?Math.min(i,$):fe;return{min:e>=$?fe:e,max:$}}function jt(i,e,l){if(!Number.isFinite(i)||i<=0)return null;const p=i*(1+e),c=Math.min(Math.max(p,l.min),l.max);return!Number.isFinite(c)||Math.abs(c-i)<Et||e>0!=c>i?null:{zoom:c,delta:c/i-1}}const Y=240,Ne=48,q=92,wt=.85,se=1/wt-1,Dt=150,St=ot;function me({data:i}){const e=Te(i);if(!e)return null;const l=e.kind==="attention";return s.jsxs("span",{title:l?Le:void 0,style:{position:"absolute",top:-18,right:4,display:"inline-flex",alignItems:"center",gap:2,fontSize:10,fontWeight:600,color:l?at:ne,lineHeight:1,whiteSpace:"nowrap"},children:[l&&s.jsx(He,{style:{width:12,height:12,color:St}}),e.label]})}function Ce(i){return i==="erd"?Nt:Y}function pe(i,e){return{width:i.isSource?Y:Ce(i.viewMode),borderColor:i.highlighted?te:Fe(i)?ne:e?ie:void 0,boxShadow:i.highlighted?`0 0 0 3px ${te}40, 0 0 12px ${te}60`:e?`0 0 0 1px ${ie}`:void 0,opacity:i.dimmed?xe:1,filter:i.dimmed?"grayscale(0.8)":void 0,animation:i.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s",cursor:"pointer"}}function Ot({id:i,data:e,selected:l}){const[p,c]=r.useState(!1),h=Be();r.useEffect(()=>{h(i)},[p,i,h]);const b=e.objectLabels,N=!b.source,d=!b.fields,S=!b.status,O=e.direction==="vertical"?J.Top:J.Left,C=e.direction==="vertical"?J.Bottom:J.Right;function _(f){f.stopPropagation(),f.preventDefault(),e.onOpenExternal()}if(e.isSource)return s.jsxs("div",{className:"bg-primary/5 relative flex items-center gap-2 rounded-xl border shadow-sm",style:{...pe(e,l),height:Ne,padding:"0 14px"},children:[s.jsx(me,{data:e}),s.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.label,children:e.label}),S&&s.jsx(ge,{isDraft:e.isDraft,decorative:!0}),e.hasOutgoing&&s.jsx(Q,{type:"source",position:C,isConnectable:!1,style:ee})]});const y=`Open ${e.label} in new tab`,I=e.viewMode==="erd"&&e.fields.length>0;return s.jsxs("div",{title:e.isCycleStub?Se:void 0,className:"bg-background relative flex flex-col rounded-xl border shadow-sm",style:pe(e,l),children:[s.jsx(me,{data:e}),s.jsx(Q,{type:"target",position:O,isConnectable:!1,style:ee}),s.jsxs("div",{className:"flex items-center gap-2 px-3.5 pt-3 pb-1",children:[s.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.label,children:e.label}),S&&s.jsx(ge,{isDraft:e.isDraft,decorative:!0}),!e.userHasAccess&&s.jsx(Oe,{}),e.description&&s.jsxs(_e,{children:[s.jsx(ve,{asChild:!0,children:s.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${e.label}`,onPointerDown:f=>{f.stopPropagation()},children:s.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),s.jsx(Me,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:e.description})]}),s.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:f=>{f.stopPropagation()},onClick:_,title:y,"aria-label":y,children:s.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3.5 pt-1 pb-3",children:[N&&s.jsx($e,{type:e.definitionType}),e.targetAlias&&s.jsx(ke,{variant:"secondary",className:"inline-block max-w-[90px] truncate px-1.5 py-0 text-[10px]",title:e.targetAlias,children:e.targetAlias}),d&&s.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0 text-[11px]",children:[e.fieldCount??0," field",e.fieldCount!==1?"s":""]})]}),I&&s.jsx(Ye,{fields:e.fields,expanded:p,onToggleExpanded:()=>{c(f=>!f)}}),e.hasOutgoing&&s.jsx(Q,{type:"source",position:C,isConnectable:!1,style:ee})]})}function _t({id:i,sourceX:e,sourceY:l,targetX:p,targetY:c,sourcePosition:h,targetPosition:b,selected:N,data:d}){const[S,O,C]=dt({sourceX:e,sourceY:l,sourcePosition:h,targetX:p,targetY:c,targetPosition:b}),_=d.warning?ne:N?ie:ut,y=r.useId(),I=gt("rel-arrow",y);return s.jsxs(s.Fragment,{children:[s.jsx(ht,{markerId:I,color:_,withStart:!1}),s.jsx(ft,{id:i,path:S,markerEnd:`url(#${I}-end)`,style:{stroke:_,strokeWidth:N?pt:xt,strokeDasharray:d.warning?mt:void 0,opacity:d.dimmed?xe:1,transition:"opacity 0.2s, stroke 0.2s"}}),s.jsx(bt,{x:O,y:C,lines:d.joinLabel,selected:N??!1,dimmed:d.dimmed})]})}const vt={relationshipNode:Ot},At={relationshipEdge:_t};function Mt(i){return JSON.stringify([i.nodes.map(e=>[e.id,e.data.isSource,e.data.label,e.data.targetAlias,e.data.fieldCount,e.data.description,e.data.isDraft,e.data.isBlocked,e.data.isJoinNotConfigured,e.data.isCycleStub,e.data.isMissingPrimaryKey,e.data.userHasAccess,e.data.hasOutgoing]),i.edges.map(e=>[e.id,e.source,e.target,e.data.warning])])}function Rt(i,e,l){return i?Ne:l!=="erd"?q:q+Ct(e)}function kt({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:p,rootDefinitionType:c,definitionTypes:h,initialRelationships:b,graph:N,fieldCounts:d,showLooped:S,statusFilter:O,viewMode:C,objectLabels:_,direction:y,showJoinFields:I,fieldsByAliasPath:f,onOpenExternal:P}){let F=0;const R=(t,a)=>a&&!S||O!=="all"&&t!==O?(F++,!1):!0,v=new Map,A=[],G=new Set,T=p==="DRAFT";v.set(i,{dmId:i,title:e,description:l,depth:0,isSource:!0,isDraft:T,userHasAccess:!0});const u=new Map;u.set("",i);function E(t,a,w,x,K){const D=`path:${x}`;A.push({sourceId:t,targetId:D,joinLabel:I?K.map(V=>`${V.sourceFieldName} = ${V.targetFieldName}`):[]}),G.add(t),v.set(D,{dmId:a,aliasPath:x,...w}),u.set(x,D)}if(N)for(const t of N.nodes){const a=t.aliasPath.lastIndexOf("."),w=a===-1?"":t.aliasPath.slice(0,a),x=u.get(w);x&&R(t.relationship.targetDataMart.status,t.isCycleStub)&&E(x,t.relationship.targetDataMart.id,{title:t.relationship.targetDataMart.title,description:t.relationship.targetDataMart.description,depth:t.depth,isSource:!1,targetAlias:t.relationship.targetAlias,fieldCount:(d==null?void 0:d.get(t.relationship.id))??0,isDraft:t.relationship.targetDataMart.status==="DRAFT",isBlocked:t.isBlocked,isJoinNotConfigured:t.relationship.joinConditions.length===0,isCycleStub:t.isCycleStub,isMissingPrimaryKey:ue(t.relationship.targetDataMart.hasPrimaryKey,t.relationship.joinConditions.length),userHasAccess:t.relationship.targetDataMart.userHasAccess},t.aliasPath,t.relationship.joinConditions)}else for(const t of b)R(t.targetDataMart.status,t.targetDataMart.id===i)&&E(i,t.targetDataMart.id,{title:t.targetDataMart.title,description:t.targetDataMart.description,depth:1,isSource:!1,targetAlias:t.targetAlias,fieldCount:(d==null?void 0:d.get(t.id))??0,isDraft:t.targetDataMart.status==="DRAFT",isBlocked:T,isJoinNotConfigured:t.joinConditions.length===0,isCycleStub:t.targetDataMart.id===i,isMissingPrimaryKey:ue(t.targetDataMart.hasPrimaryKey,t.joinConditions.length),userHasAccess:t.targetDataMart.userHasAccess},t.targetAlias,t.joinConditions);const j=new Map,k=new Map,L=new Map;for(const[t,a]of v){const w=a.isSource||a.aliasPath===void 0?[]:(f==null?void 0:f.get(a.aliasPath))??[];j.set(t,w),k.set(t,a.isSource?Y:Ce(C)),L.set(t,Rt(a.isSource,w,C))}const g=[...v.keys()].map(t=>({id:t,width:k.get(t)??Y,height:L.get(t)??q})),Z=A.map(t=>({id:`${t.sourceId}->${t.targetId}`,sourceId:t.sourceId,targetId:t.targetId,label:rt(t.joinLabel)})),{positions:W}=lt(g,Z,y),M=[];for(const[t,a]of v)M.push({id:t,type:"relationshipNode",position:W.get(t)??{x:0,y:0},width:k.get(t)??Y,height:L.get(t)??q,draggable:!1,selectable:!1,focusable:!1,style:ct,data:{isSource:a.isSource,label:a.title,targetAlias:a.targetAlias,fieldCount:a.fieldCount,description:a.description,definitionType:a.isSource?c:(h==null?void 0:h.get(a.dmId))??null,isDraft:a.isDraft??!1,isBlocked:a.isBlocked??!1,isJoinNotConfigured:a.isJoinNotConfigured??!1,isCycleStub:a.isCycleStub??!1,isMissingPrimaryKey:a.isMissingPrimaryKey??!1,userHasAccess:a.userHasAccess,hasOutgoing:G.has(t)&&!a.isCycleStub,highlighted:!1,dimmed:!1,fields:j.get(t)??[],viewMode:C,objectLabels:_,direction:y,onOpenExternal:()=>{P(a.dmId)}}});const H=[];for(const t of A){const a=v.get(t.sourceId),w=v.get(t.targetId);if(!a||!w)continue;const x=Ge(a,w);H.push({id:`${t.sourceId}->${t.targetId}`,type:"relationshipEdge",source:t.sourceId,target:t.targetId,focusable:!1,selectable:!1,data:{warning:x,dimmed:!1,joinLabel:t.joinLabel}})}return{nodes:M,edges:H,filteredOutCount:F}}function Pt({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:p,dataMartDefinitionType:c,definitionTypes:h,relationships:b,relationshipGraph:N,connectedFieldCounts:d,searchQuery:S,onRequestFullscreen:O,onOpenExternal:C,showLooped:_,statusFilter:y,viewMode:I,onViewModeChange:f,direction:P,onDirectionChange:F,showJoinFields:R,onShowJoinFieldsChange:v,objectLabels:A,onObjectLabelsChange:G,fieldsByAliasPath:T}){const u=Ze(),E=he(n=>n.width),j=he(n=>n.height),k=r.useRef(!1),L=r.useRef(!1),g=r.useMemo(()=>kt({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:p,rootDefinitionType:c??null,definitionTypes:h,initialRelationships:b,graph:N,fieldCounts:d,showLooped:_,statusFilter:y,viewMode:I,objectLabels:A,direction:P,showJoinFields:R,fieldsByAliasPath:T,onOpenExternal:C}),[i,e,l,p,c,h,b,N,d,_,y,I,A,P,R,T,C]),[Z,W]=r.useState(null),[M,H]=r.useState(null),t=r.useMemo(()=>Mt(g),[g]),a=r.useMemo(()=>Ve(g.nodes),[g.nodes]),w=r.useRef(t),x=r.useMemo(()=>yt(a,E,j,se),[a,E,j]),K=r.useMemo(()=>It((x==null?void 0:x.zoom)??Number.NaN),[x]);r.useEffect(()=>{w.current!==t&&(w.current=t,L.current=!1,H(n=>n!==null&&g.nodes.some(o=>o.id===n)?n:null),W(n=>n!==null&&g.edges.some(o=>o.id===n)?n:null))},[t,g]);const D=r.useMemo(()=>Xe(g.nodes,S,n=>n.id,n=>n.data.label),[g.nodes,S]),V=r.useMemo(()=>g.nodes.map(n=>{const o=D.get(n.id)??Ue,m=n.id===M;return n.data.highlighted===o.highlighted&&n.data.dimmed===o.dimmed&&(n.selected??!1)===m?n:{...n,selected:m,data:{...n.data,...o}}}),[g.nodes,D,M]),Ee=r.useMemo(()=>g.edges.map(n=>{var ce,de;const o=(((ce=D.get(n.source))==null?void 0:ce.dimmed)??!1)&&(((de=D.get(n.target))==null?void 0:de.dimmed)??!1),m=n.id===Z||M!==null&&(n.source===M||n.target===M);return n.data.dimmed===o&&(n.selected??!1)===m?n:{...n,selected:m,data:{...n.data,dimmed:o}}}),[g.edges,D,Z,M]),ye=r.useCallback((n,o)=>{W(m=>m===o.id?null:o.id),H(null)},[]),Ie=r.useCallback((n,o)=>{H(m=>m===o.id?null:o.id),W(null)},[]),je=r.useCallback(()=>{W(null),H(null)},[]),ae=r.useRef(D);ae.current=D;const X=r.useCallback(()=>{const n=[...ae.current.entries()].filter(([,o])=>o.highlighted).map(([o])=>o);n.length!==0&&u.fitView({nodes:n.map(o=>({id:o})),duration:300,padding:se})},[u]),B=r.useCallback(()=>u.fitView({minZoom:be,maxZoom:$,padding:se}),[u]),oe=r.useRef(x);oe.current=x;const re=r.useCallback(()=>{const n=oe.current;return n?u.setViewport(n):B()},[B,u]),z=r.useCallback(()=>{L.current=!0},[]);r.useEffect(()=>{E===0||j===0||L.current||re().then(()=>{k.current=!0,X()})},[E,j,t,re,X]),r.useEffect(()=>{k.current&&X()},[D,X]);const le=r.useCallback(n=>{z();const o=u.getZoom();if(!Number.isFinite(o)||o<=0){B();return}const m=jt(o,n,K);m&&u.zoomTo(m.zoom,{duration:150})},[B,z,u,K]),we=r.useCallback((n,o)=>{if(E===0||j===0||!Number.isFinite(o.zoom))return;const m=Je(o,a,E,j,Dt);m.x===o.x&&m.y===o.y||u.setViewport(m)},[a,j,E,u]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute top-3 right-3 z-10 flex items-start gap-2",children:s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{z(),B()},"aria-label":"Fit to view",children:s.jsx(qe,{className:"h-6 w-6"})}),s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{le(.25)},"aria-label":"Zoom in",children:s.jsx(Qe,{className:"h-6 w-6"})}),s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{le(-.25)},"aria-label":"Zoom out",children:s.jsx(et,{className:"h-6 w-6"})}),O&&s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:O,"aria-label":"Expand diagram",children:s.jsx(Pe,{className:"h-6 w-6"})}),s.jsx(tt,{viewMode:I,onViewModeChange:f,direction:P,onDirectionChange:F,showJoinFields:R,onShowJoinFieldsChange:v,objectLabels:A,onObjectLabelsChange:G})]})}),s.jsxs("div",{className:"h-full w-full",onPointerDownCapture:z,onWheelCapture:z,children:[s.jsx(st,{nodes:V,edges:Ee,nodeTypes:vt,edgeTypes:At,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,zoomOnDoubleClick:!1,minZoom:K.min,maxZoom:K.max,onEdgeClick:ye,onNodeClick:Ie,onPaneClick:je,deleteKeyCode:null,panActivationKeyCode:null,onMove:we,onMoveStart:n=>{n&&z()},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:s.jsx(it,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:nt})}),g.nodes.length===1&&g.filteredOutCount>0&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-6 flex justify-center",children:s.jsx("span",{className:"bg-background text-muted-foreground rounded-md border px-3 py-1.5 text-sm shadow-sm",children:"No related data marts match the current filters"})})]})]})}function Ht({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:p,dataMartDefinitionType:c,definitionTypes:h,relationships:b,relationshipGraph:N,connectedFieldCounts:d,searchQuery:S,onRequestFullscreen:O,showLooped:C,statusFilter:_,viewMode:y,onViewModeChange:I,direction:f,onDirectionChange:P,showJoinFields:F,onShowJoinFieldsChange:R,objectLabels:v,onObjectLabelsChange:A,fieldsByAliasPath:G,className:T,style:u}){const{scope:E}=De(),j=r.useCallback(k=>{window.open(E(`/data-marts/${k}/data-setup`),"_blank","noopener,noreferrer")},[E]);return b.length===0?null:s.jsxs("div",{className:`relative overflow-hidden rounded-lg border ${T??""}`,style:u??{height:480},children:[s.jsx("style",{children:Ke}),s.jsx(ze,{children:s.jsx(Pt,{dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:p,dataMartDefinitionType:c,definitionTypes:h,relationships:b,relationshipGraph:N,connectedFieldCounts:d,searchQuery:S,onRequestFullscreen:O,onOpenExternal:j,showLooped:C,statusFilter:_,viewMode:y,onViewModeChange:I,direction:f,onDirectionChange:P,showJoinFields:F,onShowJoinFieldsChange:R,objectLabels:v,onObjectLabelsChange:A,fieldsByAliasPath:G})})]})}export{Ht as RelationshipCanvas,Ot as RelationshipFlowNode};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import{V as Se}from"./erd-fields-section-w0MuCbrx.js";import{F as Dt,a7 as et}from"./index-CHid1y1x.js";function ot(t,e=""){return(t||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||e}function yt(t,e){const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=e,n.click(),setTimeout(()=>{URL.revokeObjectURL(r)},1e3)}function $e(t){const e=ot(t??"","data-marts-model"),r=new Date().toISOString().slice(0,10);return`${e}-${r}`}function Ce(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),i=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(i),e&&(n.href=e),i.href=t,i.href}const Ee=(()=>{let t=0;const e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${e()}${t}`)})();function q(t){const e=[];for(let r=0,n=t.length;r<n;r++)e.push(t[r]);return e}let Y=null;function Jt(t={}){return Y||(t.includeStyleProperties?(Y=t.includeStyleProperties,Y):(Y=q(window.getComputedStyle(document.documentElement)),Y))}function st(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function xe(t){const e=st(t,"border-left-width"),r=st(t,"border-right-width");return t.clientWidth+e+r}function Re(t){const e=st(t,"border-top-width"),r=st(t,"border-bottom-width");return t.clientHeight+e+r}function Yt(t,e={}){const r=e.width||xe(t),n=e.height||Re(t);return{width:r,height:n}}function Te(){let t,e;try{e=process}catch{}const r=e&&e.env?e.env.devicePixelRatio:null;return r&&(t=parseInt(r,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}const M=16384;function be(t){(t.width>M||t.height>M)&&(t.width>M&&t.height>M?t.width>t.height?(t.height*=M/t.width,t.width=M):(t.width*=M/t.height,t.height=M):t.width>M?(t.height*=M/t.width,t.width=M):(t.width*=M/t.height,t.height=M))}function ct(t){return new Promise((e,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>e(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=t})}async function ke(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function Fe(t,e,r){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),a=document.createElementNS(n,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${r}`),i.setAttribute("viewBox",`0 0 ${e} ${r}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),i.appendChild(a),a.appendChild(t),ke(i)}const b=(t,e)=>{if(t instanceof e)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===e.name||b(r,e)};function Pe(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function Ie(t,e){return Jt(e).map(r=>{const n=t.getPropertyValue(r),i=t.getPropertyPriority(r);return`${r}: ${n}${i?" !important":""};`}).join(" ")}function Le(t,e,r,n){const i=`.${t}:${e}`,a=r.cssText?Pe(r):Ie(r,n);return document.createTextNode(`${i}{${a}}`)}function Ut(t,e,r,n){const i=window.getComputedStyle(t,r),a=i.getPropertyValue("content");if(a===""||a==="none")return;const o=Ee();try{e.className=`${e.className} ${o}`}catch{return}const s=document.createElement("style");s.appendChild(Le(o,r,i,n)),e.appendChild(s)}function Me(t,e,r){Ut(t,e,":before",r),Ut(t,e,":after",r)}const Bt="application/font-woff",_t="image/jpeg",Ae={woff:Bt,woff2:Bt,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:_t,jpeg:_t,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Oe(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function bt(t){const e=Oe(t).toLowerCase();return Ae[e]||""}function De(t){return t.split(/,/)[1]}function St(t){return t.search(/^(data:)/)!==-1}function Ue(t,e){return`data:${e};base64,${t}`}async function Nt(t,e,r){const n=await fetch(t,e);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const i=await n.blob();return new Promise((a,o)=>{const s=new FileReader;s.onerror=o,s.onloadend=()=>{try{a(r({res:n,result:s.result}))}catch(c){o(c)}},s.readAsDataURL(i)})}const pt={};function Be(t,e,r){let n=t.replace(/\?.*/,"");return r&&(n=t),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),e?`[${e}]${n}`:n}async function kt(t,e,r){const n=Be(t,e,r.includeQueryParams);if(pt[n]!=null)return pt[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let i;try{const a=await Nt(t,r.fetchRequestInit,({res:o,result:s})=>(e||(e=o.headers.get("Content-Type")||""),De(s)));i=Ue(a,e)}catch(a){i=r.imagePlaceholder||"";let o=`Failed to fetch resource: ${t}`;a&&(o=typeof a=="string"?a:a.message),o&&console.warn(o)}return pt[n]=i,i}async function _e(t){const e=t.toDataURL();return e==="data:,"?t.cloneNode(!1):ct(e)}async function He(t,e){if(t.currentSrc){const a=document.createElement("canvas"),o=a.getContext("2d");a.width=t.clientWidth,a.height=t.clientHeight,o==null||o.drawImage(t,0,0,a.width,a.height);const s=a.toDataURL();return ct(s)}const r=t.poster,n=bt(r),i=await kt(r,n,e);return ct(i)}async function je(t,e){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await ft(t.contentDocument.body,e,!0)}catch{}return t.cloneNode(!1)}async function Ve(t,e){return b(t,HTMLCanvasElement)?_e(t):b(t,HTMLVideoElement)?He(t,e):b(t,HTMLIFrameElement)?je(t,e):t.cloneNode(te(t))}const We=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",te=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function ze(t,e,r){var n,i;if(te(e))return e;let a=[];return We(t)&&t.assignedNodes?a=q(t.assignedNodes()):b(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?a=q(t.contentDocument.body.childNodes):a=q(((i=t.shadowRoot)!==null&&i!==void 0?i:t).childNodes),a.length===0||b(t,HTMLVideoElement)||await a.reduce((o,s)=>o.then(()=>ft(s,r)).then(c=>{c&&e.appendChild(c)}),Promise.resolve()),e}function Ge(t,e,r){const n=e.style;if(!n)return;const i=window.getComputedStyle(t);i.cssText?(n.cssText=i.cssText,n.transformOrigin=i.transformOrigin):Jt(r).forEach(a=>{let o=i.getPropertyValue(a);a==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),b(t,HTMLIFrameElement)&&a==="display"&&o==="inline"&&(o="block"),a==="d"&&e.getAttribute("d")&&(o=`path(${e.getAttribute("d")})`),n.setProperty(a,o,i.getPropertyPriority(a))})}function qe(t,e){b(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),b(t,HTMLInputElement)&&e.setAttribute("value",t.value)}function Xe(t,e){if(b(t,HTMLSelectElement)){const n=Array.from(e.children).find(i=>t.value===i.getAttribute("value"));n&&n.setAttribute("selected","")}}function Ke(t,e,r){return b(e,Element)&&(Ge(t,e,r),Me(t,e,r),qe(t,e),Xe(t,e)),e}async function Qe(t,e){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let a=0;a<r.length;a++){const s=r[a].getAttribute("xlink:href");if(s){const c=t.querySelector(s),u=document.querySelector(s);!c&&u&&!n[s]&&(n[s]=await ft(u,e,!0))}}const i=Object.values(n);if(i.length){const a="http://www.w3.org/1999/xhtml",o=document.createElementNS(a,"svg");o.setAttribute("xmlns",a),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const s=document.createElementNS(a,"defs");o.appendChild(s);for(let c=0;c<i.length;c++)s.appendChild(i[c]);t.appendChild(o)}return t}async function ft(t,e,r){return!r&&e.filter&&!e.filter(t)?null:Promise.resolve(t).then(n=>Ve(n,e)).then(n=>ze(t,n,e)).then(n=>Ke(t,n,e)).then(n=>Qe(n,e))}const ee=/url\((['"]?)([^'"]+?)\1\)/g,Ze=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Je=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Ye(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function Ne(t){const e=[];return t.replace(ee,(r,n,i)=>(e.push(i),r)),e.filter(r=>!St(r))}async function tr(t,e,r,n,i){try{const a=r?Ce(e,r):e,o=bt(e);let s;return i||(s=await kt(a,o,n)),t.replace(Ye(e),`$1${s}$3`)}catch{}return t}function er(t,{preferredFontFormat:e}){return e?t.replace(Je,r=>{for(;;){const[n,,i]=Ze.exec(r)||[];if(!i)return"";if(i===e)return`src: ${n};`}}):t}function re(t){return t.search(ee)!==-1}async function ne(t,e,r){if(!re(t))return t;const n=er(t,r);return Ne(n).reduce((a,o)=>a.then(s=>tr(s,o,e,r)),Promise.resolve(n))}async function N(t,e,r){var n;const i=(n=e.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(i){const a=await ne(i,null,r);return e.style.setProperty(t,a,e.style.getPropertyPriority(t)),!0}return!1}async function rr(t,e){await N("background",t,e)||await N("background-image",t,e),await N("mask",t,e)||await N("-webkit-mask",t,e)||await N("mask-image",t,e)||await N("-webkit-mask-image",t,e)}async function nr(t,e){const r=b(t,HTMLImageElement);if(!(r&&!St(t.src))&&!(b(t,SVGImageElement)&&!St(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,i=await kt(n,bt(n),e);await new Promise((a,o)=>{t.onload=a,t.onerror=e.onImageErrorHandler?(...c)=>{try{a(e.onImageErrorHandler(...c))}catch(u){o(u)}}:o;const s=t;s.decode&&(s.decode=a),s.loading==="lazy"&&(s.loading="eager"),r?(t.srcset="",t.src=i):t.href.baseVal=i})}async function ar(t,e){const n=q(t.childNodes).map(i=>ae(i,e));await Promise.all(n).then(()=>t)}async function ae(t,e){b(t,Element)&&(await rr(t,e),await nr(t,e),await ar(t,e))}function ir(t,e){const{style:r}=t;e.backgroundColor&&(r.backgroundColor=e.backgroundColor),e.width&&(r.width=`${e.width}px`),e.height&&(r.height=`${e.height}px`);const n=e.style;return n!=null&&Object.keys(n).forEach(i=>{r[i]=n[i]}),t}const Ht={};async function jt(t){let e=Ht[t];if(e!=null)return e;const n=await(await fetch(t)).text();return e={url:t,cssText:n},Ht[t]=e,e}async function Vt(t,e){let r=t.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,a=(r.match(/url\([^)]+\)/g)||[]).map(async o=>{let s=o.replace(n,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),Nt(s,e.fetchRequestInit,({result:c})=>(r=r.replace(o,`url(${c})`),[o,c]))});return Promise.all(a).then(()=>r)}function Wt(t){if(t==null)return[];const e=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=i.exec(n);if(c===null)break;e.push(c[0])}n=n.replace(i,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(o,"gi");for(;;){let c=a.exec(n);if(c===null){if(c=s.exec(n),c===null)break;a.lastIndex=s.lastIndex}else s.lastIndex=a.lastIndex;e.push(c[0])}return e}async function or(t,e){const r=[],n=[];return t.forEach(i=>{if("cssRules"in i)try{q(i.cssRules||[]).forEach((a,o)=>{if(a.type===CSSRule.IMPORT_RULE){let s=o+1;const c=a.href,u=jt(c).then(l=>Vt(l,e)).then(l=>Wt(l).forEach(f=>{try{i.insertRule(f,f.startsWith("@import")?s+=1:i.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:f,error:g})}})).catch(l=>{console.error("Error loading remote css",l.toString())});n.push(u)}})}catch(a){const o=t.find(s=>s.href==null)||document.styleSheets[0];i.href!=null&&n.push(jt(i.href).then(s=>Vt(s,e)).then(s=>Wt(s).forEach(c=>{o.insertRule(c,o.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",a)}}),Promise.all(n).then(()=>(t.forEach(i=>{if("cssRules"in i)try{q(i.cssRules||[]).forEach(a=>{r.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${i.href}`,a)}}),r))}function sr(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>re(e.style.getPropertyValue("src")))}async function cr(t,e){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=q(t.ownerDocument.styleSheets),n=await or(r,e);return sr(n)}function ie(t){return t.trim().replace(/["']/g,"")}function lr(t){const e=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(a=>{e.add(ie(a))}),Array.from(n.children).forEach(a=>{a instanceof HTMLElement&&r(a)})}return r(t),e}async function ur(t,e){const r=await cr(t,e),n=lr(t);return(await Promise.all(r.filter(a=>n.has(ie(a.style.fontFamily))).map(a=>{const o=a.parentStyleSheet?a.parentStyleSheet.href:null;return ne(a.cssText,o,e)}))).join(`
|
|
2
|
-
`)}async function fr(t,e){const r=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await ur(t,e);if(r){const n=document.createElement("style"),i=document.createTextNode(r);n.appendChild(i),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}}async function oe(t,e={}){const{width:r,height:n}=Yt(t,e),i=await ft(t,e,!0);return await fr(i,e),await ae(i,e),ir(i,e),await Fe(i,r,n)}async function hr(t,e={}){const{width:r,height:n}=Yt(t,e),i=await oe(t,e),a=await ct(i),o=document.createElement("canvas"),s=o.getContext("2d"),c=e.pixelRatio||Te(),u=e.canvasWidth||r,l=e.canvasHeight||n;return o.width=u*c,o.height=l*c,e.skipAutoScale||be(o),o.style.width=`${u}`,o.style.height=`${l}`,e.backgroundColor&&(s.fillStyle=e.backgroundColor,s.fillRect(0,0,o.width,o.height)),s.drawImage(a,0,0,o.width,o.height),o}const it=60,gr=2,mr=67108864,G=24,lt=14;function wr(t,e){const r=Math.sqrt(mr/(t*e));return Math.max(1,Math.min(gr,r))}const vr="M421.311 119.85C435.258 133.807 440.996 157.327 440.996 157.327C440.996 157.327 449.53 204.69 449.53 268.995C449.53 177.972 418.65 162.348 311.314 162.348H212.327C157.38 162.348 161.097 217.57 157.38 243.85L152.865 283.556C150.697 325.33 157.951 351.215 200.811 351.215C111.444 351.215 61.806 365.847 61.8062 239.866C61.8061 182.846 70.4043 157.327 70.4043 157.327C70.4043 157.327 76.1419 133.807 90.1183 119.85C104.095 105.877 124.809 104.475 124.809 104.475C124.809 104.475 167.579 98.0374 252.066 98.0374C336.554 98.0374 384.285 104.475 384.285 104.475C384.285 104.475 407.321 105.877 421.311 119.85Z",yr="M449.515 271.888C449.52 273.026 449.523 274.174 449.523 275.333C449.523 329.946 441.393 351.201 441.393 351.201C441.393 351.201 435.03 376.952 424.167 388.075C406.929 405.725 388.495 406.71 388.495 406.71C388.495 406.71 348.836 413.061 263.502 413.061C181.632 413.061 127.111 406.749 127.111 406.749C127.111 406.749 104.091 405.337 90.1144 391.377C76.1379 377.394 70.4004 351.201 70.4004 351.201C70.4004 351.201 61.8062 297.401 61.8062 238.506C61.806 352.055 102.131 351.374 175.525 350.133C183.56 349.998 191.992 349.855 200.811 349.855H299.787C343.122 349.855 352.906 318.315 354.792 282.196L359.32 227.093C360.526 204.443 357.608 188.362 350.507 178.012C342.765 166.722 329.575 160.987 311.314 160.987C424.974 160.987 448.73 176.216 449.515 271.888Z";function se(){const t=G/512;return`<defs><linearGradient id="wmg0" x1="0" y1="0" x2="1" y2="1"><stop stop-color="#05D2FF"/><stop offset=".4" stop-color="#1E88E5"/><stop offset="1" stop-color="#182FFF"/></linearGradient><linearGradient id="wmg1" x1="0" y1="1" x2="1" y2="0"><stop stop-color="#24D8FF"/><stop offset=".4" stop-color="#1E88E5"/><stop offset="1" stop-color="#0046F9"/></linearGradient></defs><g transform="scale(${String(t)})"><path d="${vr}" fill="url(#wmg0)"/><path d="${yr}" fill="url(#wmg1)"/></g>`}function pr(t,e){return`<g transform="translate(${String(t)},${String(e)})" opacity="0.92">${se()}</g>`}function ce(t){const e=Se(t),r=Math.ceil(e.width)+it*2,n=Math.ceil(e.height)+it*2,i=`translate(${String(it-e.x)}px, ${String(it-e.y)}px) scale(1)`;return{width:r,height:n,style:{width:`${String(r)}px`,height:`${String(n)}px`,transform:i}}}function dr(t){let e=t;for(;e;){const r=getComputedStyle(e).backgroundColor;if(r&&r!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(r))return r;e=e.parentElement}return"#ffffff"}async function Sr(t,e,r){const{width:n,height:i,style:a}=ce(e),o=await oe(t,{width:n,height:i,style:a,skipFonts:!0}),c=decodeURIComponent(o.replace(/^data:image\/svg\+xml;charset=utf-8,/,"")).replace(/(<svg[^>]*>)/,`$1<rect width="100%" height="100%" fill="${r}"/>`),u=pr(n-G-lt,i-G-lt),l=c.replace(/<\/svg>\s*$/,`${u}</svg>`);return new Blob([l],{type:"image/svg+xml"})}function $r(t){return new Promise((e,r)=>{const n=new Image;n.onload=()=>{e(n)},n.onerror=()=>{r(new Error("Failed to load watermark image"))},n.src=t})}async function Cr(t,e,r){const{width:n,height:i,style:a}=ce(e),o=wr(n,i),s=await hr(t,{width:n,height:i,style:a,skipFonts:!0,pixelRatio:o}),c=document.createElement("canvas");c.width=Math.round(n*o),c.height=Math.round(i*o);const u=c.getContext("2d");if(!u)throw new Error("Canvas 2D context is unavailable");u.fillStyle=r,u.fillRect(0,0,c.width,c.height),u.drawImage(s,0,0,c.width,c.height);const l=`<svg xmlns="http://www.w3.org/2000/svg" width="${String(G)}" height="${String(G)}" viewBox="0 0 ${String(G)} ${String(G)}" opacity="0.92">${se()}</svg>`,f=await $r(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),g=G*o;u.drawImage(f,c.width-g-lt*o,c.height-g-lt*o,g,g);const h=await new Promise(v=>{c.toBlob(v,"image/png")});if(!h)throw new Error("PNG rasterization produced no data");return h}const Er={[et.SQL]:"SQL",[et.TABLE]:"TABLE",[et.VIEW]:"VIEW",[et.TABLE_PATTERN]:"TABLE",[et.CONNECTOR]:"CONNECTOR"};function xr(t){const e=new Map,r=new Set;for(const a of t.nodes){const o=ot(a.title,a.id);let s=o,c=2;for(;r.has(s);)s=`${o}-${String(c++)}`;r.add(s),e.set(a.id,s)}const n=t.nodes.map(a=>({key:e.get(a.id)??a.id,title:a.title,inputSource:a.definitionType?Er[a.definitionType]:"TABLE",description:a.description??void 0,definition:a.status===Dt.PUBLISHED?a.definition??null:null,schema:(a.fields??[]).map(o=>({name:o.name,type:o.type,pk:o.isPrimaryKey,...o.alias&&o.alias!==o.name?{alias:o.alias}:{},...o.description?{description:o.description}:{}})),position:t.positions.get(a.id)??{x:0,y:0},status:a.status===Dt.PUBLISHED?"created":"pending"})),i=t.edges.flatMap(a=>{const o=e.get(a.sourceId),s=e.get(a.targetId);return!o||!s?[]:[{id:a.id,from:o,to:s,keys:a.joinConditions.map(c=>({left:c.sourceFieldName,right:c.targetFieldName})),bidirectional:a.bidirectional}]});return{storageId:t.storageLabel??null,nodes:n,edges:i}}function Rr(t){return{nodes:t.nodes.map(e=>({key:e.key,title:e.title,inputSource:e.inputSource,description:e.description,schema:e.schema,position:e.position,status:"pending"})),edges:t.edges.map(e=>({id:e.id,from:e.from,to:e.to,keys:e.keys,bidirectional:e.bidirectional}))}}function le(t){const e=[];for(const[r,n]of Object.entries(t))n!=null&&(Array.isArray(n)?e.push(`${r}: [${n.map(zt).join(", ")}]`):e.push(`${r}: ${zt(n)}`));return e.join(`
|
|
3
|
-
`)}function zt(t){return typeof t=="number"||typeof t=="boolean"?String(t):`"${String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g," ")}"`}function $t(t){return t.replace(/\|/g,"|")}function ue(t){return t.replace(/([[\]])/g,"\\$1")}const Tr=`
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
_Generated with [OWOX Data Marts](https://www.owox.com/) · [open source](https://github.com/OWOX/owox-data-marts)_
|
|
8
|
-
`;function br(t,e="Data Marts"){const r=ot(e,"data-marts"),n=new Map,i=new Set;for(const s of t.nodes){const c=ot(s.title,s.key);let u=c,l=2;for(;i.has(u);)u=`${c}-${String(l++)}`;i.add(u),n.set(s.key,u)}const a={};for(const s of t.nodes)a[`${r}/${n.get(s.key)??s.key}.md`]=kr(s,t,n);const o=t.nodes.map(s=>`| [${ue($t(s.title))}](./${n.get(s.key)??s.key}.md) | ${s.inputSource} | ${$t(t.storageId??"—")} |`).join(`
|
|
9
|
-
`);return a[`${r}/index.md`]=`---
|
|
10
|
-
${le({type:"index",title:e,description:"Index of exported OWOX data marts.",tags:["owox","index"]})}
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# ${e}
|
|
14
|
-
|
|
15
|
-
| Data Mart | Type | Storage |
|
|
16
|
-
|-----------|------|---------|
|
|
17
|
-
${o}
|
|
18
|
-
${Tr}`,{files:a}}function kr(t,e,r){var g;const n=le({type:"OWOX Data Mart",title:t.title,description:t.description===""?void 0:t.description,tags:["owox",t.inputSource.toLowerCase()]}),i=["## Overview","",`- **Status:** ${t.status==="created"?"PUBLISHED":"DRAFT"}`,`- **Definition type:** ${t.inputSource}`,`- **Storage:** ${e.storageId??"—"}`,""].join(`
|
|
19
|
-
`),a=t.schema.some(h=>h.alias),o=a?`| Column | Type | Alias | Description |
|
|
20
|
-
|--------|------|-------|-------------|
|
|
21
|
-
`:`| Column | Type | Description |
|
|
22
|
-
|--------|------|-------------|
|
|
23
|
-
`,s=t.schema.length?`# Schema
|
|
24
|
-
|
|
25
|
-
`+o+t.schema.map(h=>{const v=[];return h.pk&&v.push("PK."),h.description&&v.push(h.description.replace(/\s+/g," ").trim()),`| ${(a?[`\`${h.name}\``,h.type,h.alias??"",v.join(" ").trim()]:[`\`${h.name}\``,h.type,v.join(" ").trim()]).map($t).join(" | ")} |`}).join(`
|
|
26
|
-
`)+`
|
|
27
|
-
|
|
28
|
-
`:"",c=(g=t.definition)==null?void 0:g.trim().replace(/^( {0,3})(`{3,})/gm," $1$2"),u=c?`## Definition
|
|
29
|
-
|
|
30
|
-
\`\`\`${t.inputSource==="SQL"?"sql":"text"}
|
|
31
|
-
${c}
|
|
32
|
-
\`\`\`
|
|
33
|
-
|
|
34
|
-
`:"",l=e.edges.filter(h=>h.from===t.key||h.bidirectional&&h.to===t.key),f=l.length?`## Joins
|
|
35
|
-
|
|
36
|
-
`+l.map(h=>{const v=h.from===t.key,y=v?h.to:h.from,$=e.nodes.find(p=>p.key===y),k=r.get(y);if(!$||!k)return null;const O=(v?h.keys:h.keys.map(p=>({left:p.right,right:p.left}))).map(p=>`\`${p.left} = ${p.right}\``).join(", ");return`- [${ue($.title)}](./${k}.md) — ${O}`}).filter(Boolean).join(`
|
|
37
|
-
`)+`
|
|
38
|
-
`:"";return`---
|
|
39
|
-
${n}
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
# ${t.title}
|
|
43
|
-
${t.description?`
|
|
44
|
-
`+t.description+`
|
|
45
|
-
`:""}
|
|
46
|
-
${i}${s}${u}${f}`}var R=Uint8Array,A=Uint16Array,Ft=Int32Array,Pt=new R([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),It=new R([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gt=new R([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fe=function(t,e){for(var r=new A(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];for(var i=new Ft(r[30]),n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)i[a]=a-r[n]<<5|n;return{b:r,r:i}},he=fe(Pt,2),Fr=he.b,Ct=he.r;Fr[28]=258,Ct[258]=28;var Pr=fe(It,0),qt=Pr.r,Et=new A(32768);for(var d=0;d<32768;++d){var z=(d&43690)>>1|(d&21845)<<1;z=(z&52428)>>2|(z&13107)<<2,z=(z&61680)>>4|(z&3855)<<4,Et[d]=((z&65280)>>8|(z&255)<<8)>>1}var at=(function(t,e,r){for(var n=t.length,i=0,a=new A(e);i<n;++i)t[i]&&++a[t[i]-1];var o=new A(e);for(i=1;i<e;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(r){s=new A(1<<e);var c=15-e;for(i=0;i<n;++i)if(t[i])for(var u=i<<4|t[i],l=e-t[i],f=o[t[i]-1]++<<l,g=f|(1<<l)-1;f<=g;++f)s[Et[f]>>c]=u}else for(s=new A(n),i=0;i<n;++i)t[i]&&(s[i]=Et[o[t[i]-1]++]>>15-t[i]);return s}),X=new R(288);for(var d=0;d<144;++d)X[d]=8;for(var d=144;d<256;++d)X[d]=9;for(var d=256;d<280;++d)X[d]=7;for(var d=280;d<288;++d)X[d]=8;var ut=new R(32);for(var d=0;d<32;++d)ut[d]=5;var Ir=at(X,9,0),Lr=at(ut,5,0),ge=function(t){return(t+7)/8|0},me=function(t,e,r){return(r==null||r>t.length)&&(r=t.length),new R(t.subarray(e,r))},Mr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ht=function(t,e,r){var n=new Error(e||Mr[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,ht),!r)throw n;return n},V=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8},rt=function(t,e,r){r<<=e&7;var n=e/8|0;t[n]|=r,t[n+1]|=r>>8,t[n+2]|=r>>16},dt=function(t,e){for(var r=[],n=0;n<t.length;++n)t[n]&&r.push({s:n,f:t[n]});var i=r.length,a=r.slice();if(!i)return{t:ve,l:0};if(i==1){var o=new R(r[0].s+1);return o[r[0].s]=1,{t:o,l:1}}r.sort(function(T,P){return T.f-P.f}),r.push({s:-1,f:25001});var s=r[0],c=r[1],u=0,l=1,f=2;for(r[0]={s:-1,f:s.f+c.f,l:s,r:c};l!=i-1;)s=r[r[u].f<r[f].f?u++:f++],c=r[u!=l&&r[u].f<r[f].f?u++:f++],r[l++]={s:-1,f:s.f+c.f,l:s,r:c};for(var g=a[0].s,n=1;n<i;++n)a[n].s>g&&(g=a[n].s);var h=new A(g+1),v=xt(r[l-1],h,0);if(v>e){var n=0,y=0,$=v-e,k=1<<$;for(a.sort(function(P,S){return h[S.s]-h[P.s]||P.f-S.f});n<i;++n){var F=a[n].s;if(h[F]>e)y+=k-(1<<v-h[F]),h[F]=e;else break}for(y>>=$;y>0;){var O=a[n].s;h[O]<e?y-=1<<e-h[O]++-1:++n}for(;n>=0&&y;--n){var p=a[n].s;h[p]==e&&(--h[p],++y)}v=e}return{t:new R(h),l:v}},xt=function(t,e,r){return t.s==-1?Math.max(xt(t.l,e,r+1),xt(t.r,e,r+1)):e[t.s]=r},Xt=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new A(++e),n=0,i=t[0],a=1,o=function(c){r[n++]=c},s=1;s<=e;++s)if(t[s]==i&&s!=e)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=t[s]}return{c:r.subarray(0,n),n:e}},nt=function(t,e){for(var r=0,n=0;n<e.length;++n)r+=t[n]*e[n];return r},we=function(t,e,r){var n=r.length,i=ge(e+2);t[i]=n&255,t[i+1]=n>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var a=0;a<n;++a)t[i+a+4]=r[a];return(i+4+n)*8},Kt=function(t,e,r,n,i,a,o,s,c,u,l){V(e,l++,r),++i[256];for(var f=dt(i,15),g=f.t,h=f.l,v=dt(a,15),y=v.t,$=v.l,k=Xt(g),F=k.c,O=k.n,p=Xt(y),T=p.c,P=p.n,S=new A(19),w=0;w<F.length;++w)++S[F[w]&31];for(var w=0;w<T.length;++w)++S[T[w]&31];for(var m=dt(S,7),I=m.t,K=m.l,L=19;L>4&&!I[Gt[L-1]];--L);var Q=u+5<<3,D=nt(i,X)+nt(a,ut)+o,U=nt(i,g)+nt(a,y)+o+14+3*L+nt(S,I)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&Q<=D&&Q<=U)return we(e,l,t.subarray(c,c+u));var _,C,B,W;if(V(e,l,1+(U<D)),l+=2,U<D){_=at(g,h,0),C=g,B=at(y,$,0),W=y;var gt=at(I,K,0);V(e,l,O-257),V(e,l+5,P-1),V(e,l+10,L-4),l+=14;for(var w=0;w<L;++w)V(e,l+3*w,I[Gt[w]]);l+=3*L;for(var H=[F,T],tt=0;tt<2;++tt)for(var Z=H[tt],w=0;w<Z.length;++w){var j=Z[w]&31;V(e,l,gt[j]),l+=I[j],j>15&&(V(e,l,Z[w]>>5&127),l+=Z[w]>>12)}}else _=Ir,C=X,B=Lr,W=ut;for(var w=0;w<s;++w){var x=n[w];if(x>255){var j=x>>18&31;rt(e,l,_[j+257]),l+=C[j+257],j>7&&(V(e,l,x>>23&31),l+=Pt[j]);var J=x&31;rt(e,l,B[J]),l+=W[J],J>3&&(rt(e,l,x>>5&8191),l+=It[J])}else rt(e,l,_[x]),l+=C[x]}return rt(e,l,_[256]),l+C[256]},Ar=new Ft([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ve=new R(0),Or=function(t,e,r,n,i,a){var o=a.z||t.length,s=new R(n+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(n,s.length-i),u=a.l,l=(a.r||0)&7;if(e){l&&(c[0]=a.r>>3);for(var f=Ar[e-1],g=f>>13,h=f&8191,v=(1<<r)-1,y=a.p||new A(32768),$=a.h||new A(v+1),k=Math.ceil(r/3),F=2*k,O=function(vt){return(t[vt]^t[vt+1]<<k^t[vt+2]<<F)&v},p=new Ft(25e3),T=new A(288),P=new A(32),S=0,w=0,m=a.i||0,I=0,K=a.w||0,L=0;m+2<o;++m){var Q=O(m),D=m&32767,U=$[Q];if(y[D]=U,$[Q]=D,K<=m){var _=o-m;if((S>7e3||I>24576)&&(_>423||!u)){l=Kt(t,c,0,p,T,P,w,I,L,m-L,l),I=S=w=0,L=m;for(var C=0;C<286;++C)T[C]=0;for(var C=0;C<30;++C)P[C]=0}var B=2,W=0,gt=h,H=D-U&32767;if(_>2&&Q==O(m-H))for(var tt=Math.min(g,_)-1,Z=Math.min(32767,m),j=Math.min(258,_);H<=Z&&--gt&&D!=U;){if(t[m+B]==t[m+B-H]){for(var x=0;x<j&&t[m+x]==t[m+x-H];++x);if(x>B){if(B=x,W=H,x>tt)break;for(var J=Math.min(H,x-2),Lt=0,C=0;C<J;++C){var mt=m-H+C&32767,de=y[mt],Mt=mt-de&32767;Mt>Lt&&(Lt=Mt,U=mt)}}}D=U,U=y[D],H+=D-U&32767}if(W){p[I++]=268435456|Ct[B]<<18|qt[W];var At=Ct[B]&31,Ot=qt[W]&31;w+=Pt[At]+It[Ot],++T[257+At],++P[Ot],K=m+B,++S}else p[I++]=t[m],++T[t[m]]}}for(m=Math.max(m,K);m<o;++m)p[I++]=t[m],++T[t[m]];l=Kt(t,c,u,p,T,P,w,I,L,m-L,l),u||(a.r=l&7|c[l/8|0]<<3,l-=7,a.h=$,a.p=y,a.i=m,a.w=K)}else{for(var m=a.w||0;m<o+u;m+=65535){var wt=m+65535;wt>=o&&(c[l/8|0]=u,wt=o),l=we(c,l+1,t.subarray(m,wt))}a.i=o}return me(s,0,n+ge(l)+i)},Dr=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var r=e,n=9;--n;)r=(r&1&&-306674912)^r>>>1;t[e]=r}return t})(),Ur=function(){var t=-1;return{p:function(e){for(var r=t,n=0;n<e.length;++n)r=Dr[r&255^e[n]]^r>>>8;t=r},d:function(){return~t}}},Br=function(t,e,r,n,i){if(!i&&(i={l:1},e.dictionary)){var a=e.dictionary.subarray(-32768),o=new R(a.length+t.length);o.set(a),o.set(t,a.length),t=o,i.w=a.length}return Or(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,r,n,i)},ye=function(t,e){var r={};for(var n in t)r[n]=t[n];for(var n in e)r[n]=e[n];return r},E=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8};function _r(t,e){return Br(t,e||{},0,0)}var pe=function(t,e,r,n){for(var i in t){var a=t[i],o=e+i,s=n;Array.isArray(a)&&(s=ye(n,a[1]),a=a[0]),ArrayBuffer.isView(a)?r[o]=[a,s]:(r[o+="/"]=[new R(0),s],pe(a,o,r,n))}},Qt=typeof TextEncoder<"u"&&new TextEncoder,Hr=typeof TextDecoder<"u"&&new TextDecoder,jr=0;try{Hr.decode(ve,{stream:!0}),jr=1}catch{}function Rt(t,e){var r;if(Qt)return Qt.encode(t);for(var n=t.length,i=new R(t.length+(t.length>>1)),a=0,o=function(u){i[a++]=u},r=0;r<n;++r){if(a+5>i.length){var s=new R(a+8+(n-r<<1));s.set(i),i=s}var c=t.charCodeAt(r);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|t.charCodeAt(++r)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return me(i,0,a)}var Tt=function(t){var e=0;if(t)for(var r in t){var n=t[r].length;n>65535&&ht(9),e+=n+4}return e},Zt=function(t,e,r,n,i,a,o,s){var c=n.length,u=r.extra,l=s&&s.length,f=Tt(u);E(t,e,o!=null?33639248:67324752),e+=4,o!=null&&(t[e++]=20,t[e++]=r.os),t[e]=20,e+=2,t[e++]=r.flag<<1|(a<0&&8),t[e++]=i&&8,t[e++]=r.compression&255,t[e++]=r.compression>>8;var g=new Date(r.mtime==null?Date.now():r.mtime),h=g.getFullYear()-1980;if((h<0||h>119)&&ht(10),E(t,e,h<<25|g.getMonth()+1<<21|g.getDate()<<16|g.getHours()<<11|g.getMinutes()<<5|g.getSeconds()>>1),e+=4,a!=-1&&(E(t,e,r.crc),E(t,e+4,a<0?-a-2:a),E(t,e+8,r.size)),E(t,e+12,c),E(t,e+14,f),e+=16,o!=null&&(E(t,e,l),E(t,e+6,r.attrs),E(t,e+10,o),e+=14),t.set(n,e),e+=c,f)for(var v in u){var y=u[v],$=y.length;E(t,e,+v),E(t,e+2,$),t.set(y,e+4),e+=4+$}return l&&(t.set(s,e),e+=l),e},Vr=function(t,e,r,n,i){E(t,e,101010256),E(t,e+8,r),E(t,e+10,r),E(t,e+12,n),E(t,e+16,i)};function Wr(t,e){e||(e={});var r={},n=[];pe(t,"",r,e);var i=0,a=0;for(var o in r){var s=r[o],c=s[0],u=s[1],l=u.level==0?0:8,f=Rt(o),g=f.length,h=u.comment,v=h&&Rt(h),y=v&&v.length,$=Tt(u.extra);g>65535&&ht(11);var k=l?_r(c,u):c,F=k.length,O=Ur();O.p(c),n.push(ye(u,{size:c.length,crc:O.d(),c:k,f,m:v,u:g!=o.length||v&&h.length!=y,o:i,compression:l})),i+=30+g+$+F,a+=76+2*(g+$)+(y||0)+F}for(var p=new R(a+22),T=i,P=a-i,S=0;S<n.length;++S){var f=n[S];Zt(p,f.o,f,f.f,f.u,f.c.length);var w=30+f.f.length+Tt(f.extra);p.set(f.c,f.o+w),Zt(p,i,f,f.f,f.u,f.c.length,f.o,f.m),i+=16+w+(f.m?f.m.length:0)}return Vr(p,i,n.length,P,T),p}function zr(t){const e={};for(const[r,n]of Object.entries(t))e[r]=Rt(n);return Wr(e,{level:6})}async function Xr(t,e){if(e.nodes.length===0||e.flowNodes.length===0)return!1;const r=$e(e.storageTitle);if(t==="svg"||t==="png"){if(!e.viewport)return!1;const s=dr(e.viewport),c=t==="svg"?await Sr(e.viewport,e.flowNodes,s):await Cr(e.viewport,e.flowNodes,s);return yt(c,`${r}.${t}`),!0}const n=new Map(e.flowNodes.map(s=>[s.id,{x:s.position.x,y:s.position.y}])),i=xr({nodes:e.nodes,edges:e.edges,positions:n,storageLabel:e.storageTitle});if(t==="json"){const s=JSON.stringify(Rr(i),null,2);return yt(new Blob([s],{type:"application/json"}),`${r}.json`),!0}const a=br(i,e.storageTitle??"Data Marts"),o=zr(a.files);return yt(new Blob([o.slice()],{type:"application/zip"}),`${r}.zip`),!0}export{Xr as exportModelCanvas};
|