@flexkit/studio 0.2.34 → 0.2.35
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/chat-page-IR4RF46H.js +4 -0
- package/dist/chat-page-IR4RF46H.js.map +1 -0
- package/dist/{chunk-CHNQZU2P.js → chunk-7N3LTSVX.js} +2 -2
- package/dist/{chunk-CHNQZU2P.js.map → chunk-7N3LTSVX.js.map} +1 -1
- package/dist/chunk-BTH7HU5Y.js +2 -0
- package/dist/chunk-BTH7HU5Y.js.map +1 -0
- package/dist/chunk-DEG7QP5C.js +30 -0
- package/dist/chunk-DEG7QP5C.js.map +1 -0
- package/dist/{chunk-DFBG7PUJ.js → chunk-FJRDLP7V.js} +4 -4
- package/dist/{chunk-DFBG7PUJ.js.map → chunk-FJRDLP7V.js.map} +1 -1
- package/dist/{chunk-RBGXXVF4.js → chunk-J6EGNRRT.js} +3 -3
- package/dist/{chunk-RBGXXVF4.js.map → chunk-J6EGNRRT.js.map} +1 -1
- package/dist/chunk-KEGJNZLW.js +378 -0
- package/dist/chunk-KEGJNZLW.js.map +1 -0
- package/dist/chunk-PMLDA2FF.js +2 -0
- package/dist/chunk-PMLDA2FF.js.map +1 -0
- package/dist/{chunk-HR4QZ5TD.js → chunk-PWGLA33F.js} +3 -3
- package/dist/chunk-PWGLA33F.js.map +1 -0
- package/dist/chunk-PZWEC6KD.js +2 -0
- package/dist/chunk-PZWEC6KD.js.map +1 -0
- package/dist/{chunk-YC7PBLTK.js → chunk-Q4CWQHBJ.js} +2 -2
- package/dist/{chunk-YC7PBLTK.js.map → chunk-Q4CWQHBJ.js.map} +1 -1
- package/dist/{chunk-PSECMZJC.js → chunk-R6DPAMLC.js} +3 -3
- package/dist/{chunk-PSECMZJC.js.map → chunk-R6DPAMLC.js.map} +1 -1
- package/dist/{chunk-7JA6SI5H.js → chunk-RAUQCO6W.js} +2 -2
- package/dist/{chunk-7JA6SI5H.js.map → chunk-RAUQCO6W.js.map} +1 -1
- package/dist/{chunk-XYFS6X74.js → chunk-RFKMFD2O.js} +2 -2
- package/dist/{chunk-XYFS6X74.js.map → chunk-RFKMFD2O.js.map} +1 -1
- package/dist/{chunk-VRDTHLA3.js → chunk-TI3EHLRE.js} +3 -3
- package/dist/{chunk-VRDTHLA3.js.map → chunk-TI3EHLRE.js.map} +1 -1
- package/dist/chunk-W7JDZHCV.js +2 -0
- package/dist/chunk-W7JDZHCV.js.map +1 -0
- package/dist/chunk-XYE6ZAUB.js +2 -0
- package/dist/{chunk-3OBELKJU.js.map → chunk-XYE6ZAUB.js.map} +1 -1
- package/dist/chunk-ZMONKGWJ.js +4 -0
- package/dist/{chunk-2FCVATRT.js.map → chunk-ZMONKGWJ.js.map} +1 -1
- package/dist/{chunk-6AJRQSFO.js → chunk-ZRTWLY77.js} +3 -3
- package/dist/{chunk-6AJRQSFO.js.map → chunk-ZRTWLY77.js.map} +1 -1
- package/dist/entry-NQRN7SWV.js +2 -0
- package/dist/{entry-APJ4V7PW.js.map → entry-NQRN7SWV.js.map} +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/{list-7IHDJM54.js → list-7SCWJXUE.js} +3 -3
- package/dist/{list-7IHDJM54.js.map → list-7SCWJXUE.js.map} +1 -1
- package/dist/list-RPIG75US.js +2 -0
- package/dist/{list-7WFALOUT.js.map → list-RPIG75US.js.map} +1 -1
- package/dist/{pages-BV3ABSFQ.js → pages-KXERA5Z6.js} +3 -3
- package/dist/{pages-BV3ABSFQ.js.map → pages-KXERA5Z6.js.map} +1 -1
- package/dist/{plugin-pages-OWGJPPWV.js → plugin-pages-NXA4BT7Y.js} +2 -2
- package/dist/{plugin-pages-OWGJPPWV.js.map → plugin-pages-NXA4BT7Y.js.map} +1 -1
- package/dist/{project-selector-V5N2724B.js → project-selector-SA6UUVBK.js} +2 -2
- package/dist/{project-selector-V5N2724B.js.map → project-selector-SA6UUVBK.js.map} +1 -1
- package/dist/record-links-RTMCYEPM.js +2 -0
- package/dist/{record-links-3P3XSW66.js.map → record-links-RTMCYEPM.js.map} +1 -1
- package/dist/{root-GBBZ3DX5.js → root-6H6K3YQF.js} +3 -3
- package/dist/{root-GBBZ3DX5.js.map → root-6H6K3YQF.js.map} +1 -1
- package/dist/root-IBZPU2D4.js +23 -0
- package/dist/{root-RGZZYETM.js.map → root-IBZPU2D4.js.map} +1 -1
- package/dist/{root-F2GTYDJM.js → root-MBFQXX4E.js} +2 -2
- package/dist/{root-F2GTYDJM.js.map → root-MBFQXX4E.js.map} +1 -1
- package/dist/root-TSZ3CSJU.js +14 -0
- package/dist/root-TSZ3CSJU.js.map +1 -0
- package/dist/{root-NIL2UHKS.js → root-TZIXWEZO.js} +2 -2
- package/dist/{root-NIL2UHKS.js.map → root-TZIXWEZO.js.map} +1 -1
- package/dist/{root-J62PBDZ2.js → root-W5ZPSNQ2.js} +2 -2
- package/dist/{root-J62PBDZ2.js.map → root-W5ZPSNQ2.js.map} +1 -1
- package/dist/{search-IIGNCQEZ.js → search-ZLEYFT3T.js} +2 -2
- package/dist/{search-IIGNCQEZ.js.map → search-ZLEYFT3T.js.map} +1 -1
- package/dist/{skills-pages-T52MF4DO.js → skills-pages-RPMWIBLS.js} +2 -2
- package/dist/{skills-pages-T52MF4DO.js.map → skills-pages-RPMWIBLS.js.map} +1 -1
- package/dist/source-VYWE5EB5.js +2 -0
- package/dist/{source-IJAAJDGW.js.map → source-VYWE5EB5.js.map} +1 -1
- package/package.json +3 -3
- package/dist/chat-page-7XT4K75G.js +0 -4
- package/dist/chat-page-7XT4K75G.js.map +0 -1
- package/dist/chunk-2FCVATRT.js +0 -4
- package/dist/chunk-3OBELKJU.js +0 -2
- package/dist/chunk-4PUMSUJL.js +0 -30
- package/dist/chunk-4PUMSUJL.js.map +0 -1
- package/dist/chunk-ERDARDGB.js +0 -2
- package/dist/chunk-ERDARDGB.js.map +0 -1
- package/dist/chunk-HR4QZ5TD.js.map +0 -1
- package/dist/chunk-KO2JLLUJ.js +0 -2
- package/dist/chunk-KO2JLLUJ.js.map +0 -1
- package/dist/chunk-PC5Z37LT.js +0 -378
- package/dist/chunk-PC5Z37LT.js.map +0 -1
- package/dist/chunk-U6NFYYTF.js +0 -2
- package/dist/chunk-U6NFYYTF.js.map +0 -1
- package/dist/chunk-XMOSCJOI.js +0 -2
- package/dist/chunk-XMOSCJOI.js.map +0 -1
- package/dist/chunk-YDVO6XWD.js +0 -2
- package/dist/chunk-YDVO6XWD.js.map +0 -1
- package/dist/entry-APJ4V7PW.js +0 -2
- package/dist/list-7WFALOUT.js +0 -2
- package/dist/record-links-3P3XSW66.js +0 -2
- package/dist/root-LYRL7VPN.js +0 -14
- package/dist/root-LYRL7VPN.js.map +0 -1
- package/dist/root-RGZZYETM.js +0 -23
- package/dist/source-IJAAJDGW.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {c}from'./chunk-2DXR5NJV.js';import {f}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=root-
|
|
1
|
+
import'./index.css';import {c}from'./chunk-2DXR5NJV.js';import {f}from'./chunk-TI3EHLRE.js';import {g}from'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {I,K,X,O}from'./chunk-RULCANNM.js';import'./chunk-A4DPLZZF.js';import'./chunk-G5N6HEPW.js';import'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-N33S7BSG.js';import'./chunk-X3SHNHHM.js';import {Outlet}from'react-router-dom';import {jsxs,jsx}from'react/jsx-runtime';function P(){let[,u]=g(),{currentProject:r}=f(),c$1=r?.schema??[],p=r?.menuGroups??[],d=c(c$1,u.user?.spaces),f$1=I();return jsxs(K,{defaultOpen:f$1,children:[jsx(X,{schema:d,menuGroups:p}),jsx(O,{children:jsx(Outlet,{})})]})}export{P as Root};//# sourceMappingURL=root-MBFQXX4E.js.map
|
|
2
|
+
//# sourceMappingURL=root-MBFQXX4E.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/apps/desk/root.tsx"],"names":["Root","auth","useAuth","currentProject","useConfig","schema","menuGroups","visibleSchema","filterEntitiesForSpaces","defaultOpen","readSidebarCookieState","jsxs","SidebarProvider","jsx","Sidebar","SidebarInset","Outlet"],"mappings":"ydAOO,SAASA,CAAAA,EAAoB,CAClC,GAAM,EAAGC,CAAI,CAAA,CAAIC,CAAAA,EAAQ,CACnB,CAAE,cAAA,CAAAC,CAAe,EAAIC,CAAAA,EAAU,CAC/BC,GAAAA,CAASF,CAAAA,EAAgB,MAAA,EAAU,EAAC,CACpCG,CAAAA,CAAaH,GAAgB,UAAA,EAAc,EAAC,CAG5CI,CAAAA,CAAgBC,CAAAA,CAAwBH,GAAAA,CAAQJ,CAAAA,CAAK,IAAA,EAAM,MAAM,CAAA,CACjEQ,GAAAA,CAAcC,CAAAA,EAAuB,CAE3C,OACEC,IAAAA,CAACC,CAAAA,CAAA,CAAgB,YAAaH,GAAAA,CAC5B,QAAA,CAAA,CAAAI,GAAAA,CAACC,CAAAA,CAAA,CAAQ,MAAA,CAAQP,CAAAA,CAAe,UAAA,CAAYD,EAAY,CAAA,CACxDO,GAAAA,CAACE,CAAAA,CAAA,CACC,SAAAF,GAAAA,CAACG,MAAAA,CAAA,EAAO,CAAA,CACV,GACF,CAEJ","file":"root-
|
|
1
|
+
{"version":3,"sources":["../src/apps/desk/root.tsx"],"names":["Root","auth","useAuth","currentProject","useConfig","schema","menuGroups","visibleSchema","filterEntitiesForSpaces","defaultOpen","readSidebarCookieState","jsxs","SidebarProvider","jsx","Sidebar","SidebarInset","Outlet"],"mappings":"ydAOO,SAASA,CAAAA,EAAoB,CAClC,GAAM,EAAGC,CAAI,CAAA,CAAIC,CAAAA,EAAQ,CACnB,CAAE,cAAA,CAAAC,CAAe,EAAIC,CAAAA,EAAU,CAC/BC,GAAAA,CAASF,CAAAA,EAAgB,MAAA,EAAU,EAAC,CACpCG,CAAAA,CAAaH,GAAgB,UAAA,EAAc,EAAC,CAG5CI,CAAAA,CAAgBC,CAAAA,CAAwBH,GAAAA,CAAQJ,CAAAA,CAAK,IAAA,EAAM,MAAM,CAAA,CACjEQ,GAAAA,CAAcC,CAAAA,EAAuB,CAE3C,OACEC,IAAAA,CAACC,CAAAA,CAAA,CAAgB,YAAaH,GAAAA,CAC5B,QAAA,CAAA,CAAAI,GAAAA,CAACC,CAAAA,CAAA,CAAQ,MAAA,CAAQP,CAAAA,CAAe,UAAA,CAAYD,EAAY,CAAA,CACxDO,GAAAA,CAACE,CAAAA,CAAA,CACC,SAAAF,GAAAA,CAACG,MAAAA,CAAA,EAAO,CAAA,CACV,GACF,CAEJ","file":"root-MBFQXX4E.js","sourcesContent":["import { JSX } from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { filterEntitiesForSpaces } from '../../core/spaces';\nimport { useAuth } from '../../auth/auth-context';\nimport { useConfig } from '../../core/config/config-context';\nimport { readSidebarCookieState, Sidebar, SidebarInset, SidebarProvider } from '../../ui';\n\nexport function Root(): JSX.Element {\n const [, auth] = useAuth();\n const { currentProject } = useConfig();\n const schema = currentProject?.schema ?? [];\n const menuGroups = currentProject?.menuGroups ?? [];\n // Space-bound entities are hidden from non-members; the generated\n // @authorization rules block their data server-side either way.\n const visibleSchema = filterEntitiesForSpaces(schema, auth.user?.spaces);\n const defaultOpen = readSidebarCookieState();\n\n return (\n <SidebarProvider defaultOpen={defaultOpen}>\n <Sidebar schema={visibleSchema} menuGroups={menuGroups} />\n <SidebarInset>\n <Outlet />\n </SidebarInset>\n </SidebarProvider>\n );\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import'./index.css';import {a as a$3,b as b$6}from'./chunk-MLHXPTBT.js';import {b as b$5,c as c$4}from'./chunk-ELOJGLAR.js';import {e}from'./chunk-R6DPAMLC.js';import {a as a$1}from'./chunk-BTH7HU5Y.js';import {f as f$1,i,g as g$1,y,k,b as b$1,e as e$3,l,w,v,d,a,m,h,p,n as n$1,o as o$1,s as s$1,c as c$5,q as q$1,r as r$1,j as j$2,u,t}from'./chunk-DEG7QP5C.js';import {c as c$1}from'./chunk-2DXR5NJV.js';import {j,f as f$3}from'./chunk-ZRTWLY77.js';import {c,e as e$1,f as f$2}from'./chunk-PZWEC6KD.js';import'./chunk-HKN6BX5U.js';import {b as b$4}from'./chunk-KEGJNZLW.js';import {f}from'./chunk-TI3EHLRE.js';import {g}from'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {I,K,O,M,ma,L,P,Q,R,T,U,V,n,N,ea,fa,ga,ha,Y,Z,aa,ba,_,ca}from'./chunk-RULCANNM.js';import {e as e$4,g as g$2,h as h$1,j as j$1,q,r,s,o}from'./chunk-A4DPLZZF.js';import {b as b$3,a as a$2}from'./chunk-G5N6HEPW.js';import {l as l$1}from'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import {b}from'./chunk-U45E5X3H.js';import {b as b$2,c as c$2,e as e$2}from'./chunk-N33S7BSG.js';import {c as c$3}from'./chunk-X3SHNHHM.js';import {useEffect,useMemo,useRef,useState,useCallback,useReducer}from'react';import {useLocation}from'react-router-dom';import Qn from'graphology';import zn from'graphology-layout-forceatlas2';import Hn from'graphology-layout-forceatlas2/worker';import jn,{DEFAULT_STYLES}from'sigma';import {jsxs,jsx}from'react/jsx-runtime';import {gql}from'@apollo/client';import {useApolloClient,useQuery}from'@apollo/client/react';import {formatDistance}from'date-fns';import {SearchIcon,ChevronDownIcon,LoaderCircleIcon,PlayIcon,ScanIcon,ExpandIcon,EyeOffIcon,EraserIcon,XIcon,SquareArrowOutUpRightIcon}from'lucide-react';import {closeBrackets,closeBracketsKeymap}from'@codemirror/autocomplete';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {graphql,updateSchema}from'cm6-graphql';import {getIntrospectionQuery,buildClientSchema}from'graphql';import {useDebounce}from'use-debounce';function Ce(e){return Math.min(2e4,2e3+e*9)}function tn({mean:e,max:t,diagonal:n}){let r=Math.max(.05,n*.0015);return e<r&&t<r*20}var Bn=40,Xn=400,Fn=1200,$n=2;function Jn(e){return 5+Math.min(10,Math.sqrt(e)*2)}function on(e){return Bn*(.8+Math.sqrt(e)*.6)}function sn(e,t,n){let r=Math.random()*Math.PI*2;return Array.from({length:t},(i,a)=>{let o=r+a/t*Math.PI*2+Math.random()*.3,d=n*(.9+Math.random()*.2);return {x:e.x+Math.cos(o)*d,y:e.y+Math.sin(o)*d}})}function an(e,t){return !Number.isNaN(e.getNodeAttribute(t,"x"))}function Yn(e,t){if(t.length===0)return {center:{x:0,y:0},reach:0};let n=t.reduce((i,a)=>({x:i.x+e.getNodeAttribute(a,"x"),y:i.y+e.getNodeAttribute(a,"y")}),{x:0,y:0});n.x/=t.length,n.y/=t.length;let r=t.reduce((i,a)=>Math.max(i,Math.hypot(e.getNodeAttribute(a,"x")-n.x,e.getNodeAttribute(a,"y")-n.y)),0);return {center:n,reach:r}}function Kn(e,t){let n=new Map;t.forEach(r=>{let i=e.neighbors(r).find(a=>!t.has(a)&&an(e,a))??null;n.set(i,[...n.get(i)??[],r]);}),n.forEach((r,i)=>{let a;if(i){let o={x:e.getNodeAttribute(i,"x"),y:e.getNodeAttribute(i,"y")};a=sn(o,r.length,on(r.length));}else {let o=e.nodes().filter(b=>!t.has(b)&&an(e,b)),d=Yn(e,o);a=sn(d.center,r.length,d.reach+on(r.length));}a.forEach((o,d)=>e.mergeNodeAttributes(r[d],o));});}var Ue=class{constructor(t){this.graph=t;this.positions=new Float64Array(t.order*2);let n=0;this.graph.forEachNode((r,i)=>{this.positions[n]=i.x,this.positions[n+1]=i.y,n+=2;});}positions;measure(){let{graph:t,positions:n}=this,r=0,i=0,a=0,o=Number.POSITIVE_INFINITY,d=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY,k=0;return t.forEachNode((l,u)=>{let{x:g,y:f}=u;if(k+1<n.length&&!u.fixed){let E=Math.hypot(g-n[k],f-n[k+1]);r+=E,i=Math.max(i,E),a+=1;}n[k]=g,n[k+1]=f,k+=2,o=Math.min(o,g),d=Math.min(d,f),b=Math.max(b,g),C=Math.max(C,f);}),{mean:a>0?r/a:0,max:i,diagonal:t.order>0?Math.hypot(b-o,C-d):0}}};function Un(e,t,n){let r=false,i=new Set,a=e.order>0;return e.forEachNode(o=>{t.nodes[o]||(e.dropNode(o),r=true);}),Object.values(t.nodes).forEach(o=>{if(e.hasNode(o.key)){e.getNodeAttribute(o.key,"label")!==o.label&&e.setNodeAttribute(o.key,"label",o.label);return}e.addNode(o.key,{entity:o.entity,label:o.label,color:n[o.entity]??"#71717a",size:5,x:Number.NaN,y:Number.NaN}),i.add(o.key),r=true;}),e.forEachEdge(o=>{t.edges[o]||(e.dropEdge(o),r=true);}),Object.values(t.edges).forEach(o=>{e.hasEdge(o.key)||(e.addEdgeWithKey(o.key,o.source,o.target,{size:1}),r=true);}),Kn(e,i),r&&e.forEachNode(o=>{e.setNodeAttribute(o,"size",Jn(e.degree(o)));}),{changed:r,added:i,hadNodes:a}}function ln({scene:e,colors:t,theme:n,apiRef:r,onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b}){let C=useRef(null),k=useRef(null),l=useRef(null),u=useRef(null),g=useRef(null),f=useRef(null),E=useRef(null),p=useRef(null),S=useRef(null),s=useRef(new Set),N=useRef(e.pinned);N.current=e.pinned;let m=useRef({key:null,nodes:[]}),D=useRef({onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b}),[_,$]=useState(0);D.current={onSelect:i,onContextMenu:a,onExpand:o,onPin:d,onLayoutChange:b},k.current||(k.current=new Qn({type:"undirected",multi:true}));let v=useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null),p.current!==null&&(window.clearInterval(p.current),p.current=null),u.current&&(u.current.kill(),u.current=null,S.current=null,D.current.onLayoutChange(false));let c=k.current;s.current.forEach(y=>{c?.hasNode(y)&&c.setNodeAttribute(y,"fixed",N.current[y]===true);}),s.current=new Set;},[]),A=useCallback((c,y=[])=>{let w=k.current;if(v(),!w||w.order===0)return;if(s.current=new Set(y.filter(T=>w.hasNode(T))),s.current.forEach(T=>w.setNodeAttribute(T,"fixed",true)),!w.someNode((T,L)=>!L.fixed)){v();return}let R=zn.inferSettings(w),G=new Hn(w,{settings:{...R,adjustSizes:true,gravity:.2,slowDown:(R.slowDown??1)*2},outputReducer:(T,L)=>{let oe=f.current;return oe&&oe.node===T&&(L.x=oe.x,L.y=oe.y),L}}),Q=performance.now(),Y=new Ue(w),V=false,K=0;u.current=G,S.current=Q+c,G.start(),D.current.onLayoutChange(true);let h=()=>{f.current?(S.current=performance.now()+c,g.current=window.setTimeout(h,c)):v();};g.current=window.setTimeout(h,c),p.current=window.setInterval(()=>{let T=Y.measure();if(f.current){K=0;return}V=V||T.max>0,K=V&&tn(T)?K+1:0,K>=$n&&performance.now()-Q>=Fn&&v();},Xn);},[v]),q=useCallback(c=>{let y=k.current,w=l.current;if(!y||!w)return;let R=m.current;if(w.setNodesState(R.nodes.filter(G=>y.hasNode(G)),{isNeighbour:false}),c&&y.hasNode(c)){let G=y.neighbors(c);w.setNodesState(G,{isNeighbour:true}),m.current={key:c,nodes:G};}else m.current={key:null,nodes:[]};},[]);return useEffect(()=>{let c=C.current,y=k.current;if(!c||!y)return;if(c.clientWidth===0||c.clientHeight===0){let h=new ResizeObserver(()=>{c.clientWidth>0&&c.clientHeight>0&&(h.disconnect(),$(T=>T+1));});return h.observe(c),()=>h.disconnect()}let w=n==="dark",R=new jn(y,c,{customNodeState:{isNeighbour:false},customEdgeState:{},customGraphState:{isDense:y.order>300,isZoomedIn:false},settings:{allowInvalidContainer:true,itemSizesReference:"screen",enableNodeDrag:true,renderEdgeLabels:false,labelRenderedSizeThreshold:7,labelDensity:.1,labelGridCellSize:80},styles:{nodes:[{...DEFAULT_STYLES.nodes,size:{whenState:"isHighlighted",then:h=>h.size+5,else:{whenState:"isHovered",then:h=>h.size+2,else:{attribute:"size"}}},cursor:"pointer",labelColor:w?"#e4e4e7":"#18181b",labelSize:12,labelFont:"ui-sans-serif, system-ui, sans-serif",labelVisibility:(h,T,L)=>T.isHovered||T.isHighlighted?"visible":L.isDense&&!L.isZoomedIn&&!T.isNeighbour?"hidden":"auto",backdropColor:w?"#27272a":"#ffffff",backdropShadowColor:w?"rgba(0, 0, 0, 0.6)":"rgba(0, 0, 0, 0.25)"}],edges:[{...DEFAULT_STYLES.edges,color:w?"#3f3f46":"#d4d4d8",size:1}]}});l.current=R,R.on("clickNode",({node:h})=>{D.current.onSelect(h);}),R.on("clickStage",()=>{D.current.onSelect(null);}),R.on("doubleClickNode",({node:h,event:T})=>{T.preventSigmaDefault(),D.current.onExpand(h);}),R.on("rightClickNode",({node:h,event:T})=>{T.preventSigmaDefault();let L=T.original;L.preventDefault(),D.current.onSelect(h),D.current.onContextMenu(h,{x:L.clientX,y:L.clientY});}),R.on("enterNode",({node:h})=>q(h)),R.on("leaveNode",()=>q(null));let G=h=>{let T=new Set([h,...y.neighbors(h)]);return y.nodes().filter(L=>L===h||!T.has(L))};R.on("nodeDragStart",({node:h})=>{f.current={node:h,x:y.getNodeAttribute(h,"x"),y:y.getNodeAttribute(h,"y")},y.size>0?(A(Ce(y.order),G(h)),E.current=u.current):(v(),y.setNodeAttribute(h,"fixed",true));}),R.on("nodeDrag",({node:h})=>{f.current?.node===h&&(f.current.x=y.getNodeAttribute(h,"x"),f.current.y=y.getNodeAttribute(h,"y"));}),R.on("nodeDragEnd",({node:h})=>{let T=f.current!==null&&u.current!==null&&u.current===E.current;f.current=null,E.current=null,D.current.onPin(h),T&&A(Ce(y.order),G(h));});let Q=R.getCamera(),Y=({ratio:h})=>{let T=h<.45;R.getGraphState().isZoomedIn!==T&&R.setGraphState({isZoomedIn:T});};Q.on("updated",Y);let V=h=>h.preventDefault();c.addEventListener("contextmenu",V);let K=new ResizeObserver(()=>{c.clientWidth>0&&c.clientHeight>0&&(R.resize(),R.scheduleRefresh());});return K.observe(c),r.current={fit:()=>{Q.reset({duration:300});}},()=>{K.disconnect(),Q.off("updated",Y),c.removeEventListener("contextmenu",V),r.current=null,l.current=null,m.current={key:null,nodes:[]},R.kill();}},[n,_,r,A,v,q]),useEffect(()=>{let c=k.current;if(!c)return;v();let{changed:y,added:w,hadNodes:R}=Un(c,e,t);if(!y)return;if(l.current?.setGraphState({isDense:c.order>300}),q(c.hasNode(m.current.key??"")?m.current.key:null),c.size===0){v();return}let G=R&&w.size>0?c.nodes().filter(Q=>!w.has(Q)):[];A(Ce(G.length>0?w.size:c.order),G);},[e.version]),useEffect(()=>{let c=k.current;c&&c.forEachNode((y,w)=>{c.setNodeAttribute(y,"color",t[w.entity]??"#71717a");});},[t]),useEffect(()=>{let c=k.current,y=l.current;if(!c||!y)return;let w=new Set(e.hiddenEntities),R=false;c.forEachNode((G,Q)=>{y.setNodeState(G,{isHidden:w.has(Q.entity),isHighlighted:G===e.selected});let Y=e.pinned[G]===true||s.current.has(G);(Q.fixed??false)!==Y&&(c.setNodeAttribute(G,"fixed",Y),R=true);}),R&&S.current!==null&&A(Math.max(500,S.current-performance.now()),[...s.current]),c.forEachEdge((G,Q,Y,V)=>{y.setEdgeState(G,{isHidden:w.has(c.getNodeAttribute(Y,"entity"))||w.has(c.getNodeAttribute(V,"entity"))});});},[e.hiddenEntities,e.selected,e.pinned,e.version,_,n,A]),useEffect(()=>v,[v]),jsx("div",{className:"fk:h-full fk:w-full fk:min-h-0",ref:C})}function un({menu:e,relationships:t,isPinned:n,onClose:r$1,onExpandAll:i,onExpandAttribute:a,onHide:o$1,onHideOthers:d,onTogglePin:b,onOpenRecord:C}){let k=e?.key??"";return jsxs(e$4,{onOpenChange:l=>{l||r$1();},open:e!==null,children:[jsx(g$2,{asChild:true,children:jsx("span",{"aria-hidden":"true",className:"fk:fixed fk:size-0",style:{left:e?.x??0,top:e?.y??0}})}),jsxs(h$1,{align:"start",className:"fk:w-52","data-testid":"graph-context-menu",side:"bottom",children:[jsx(j$1,{onSelect:()=>i(k),children:"Expand all"}),t.length>0?jsxs(q,{children:[jsx(r,{children:"Expand"}),jsx(s,{className:"fk:max-h-80 fk:overflow-y-auto",children:t.map(l=>jsx(j$1,{onSelect:()=>a(k,l),children:l.label},l.name))})]}):null,jsx(o,{}),jsx(j$1,{onSelect:()=>o$1(k),children:"Hide"}),jsx(j$1,{onSelect:()=>d(k),children:"Hide others"}),jsx(j$1,{onSelect:()=>b(k),children:n?"Unpin position":"Pin position"}),jsx(o,{}),jsx(j$1,{onSelect:()=>C(k),children:"Open record"})]})]})}var We={nodes:{},edges:{},counts:{},fetched:{},hiddenEntities:[],pinned:{},selected:null,notice:null,version:0};function Wn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{n[r]={...n[r],...i};}),n}function Zn(e,t){if(!t)return e;let n={...e};return Object.entries(t).forEach(([r,i])=>{let a={...n[r]};Object.entries(i).forEach(([o,d])=>{a[o]=Math.max(a[o]??0,d);}),n[r]=a;}),n}function cn(e,t){let n=Object.fromEntries(Object.entries(e.nodes).filter(([a])=>!t.has(a))),r=Object.fromEntries(Object.entries(e.edges).filter(([,a])=>!t.has(a.source)&&!t.has(a.target))),i=Object.fromEntries(Object.entries(e.pinned).filter(([a])=>!t.has(a)));return {...e,nodes:n,edges:r,pinned:i,selected:e.selected&&t.has(e.selected)?null:e.selected,version:e.version+1}}function dn(e,t){switch(t.type){case "merge":{let n={...e.nodes},r=Object.keys(n).length,i=0;t.data.nodes.forEach(o=>{let d=n[o.key];if(d){d.label===d.id&&o.label!==o.id&&(n[o.key]={...d,label:o.label});return}if(r>=c$5){i+=1;return}n[o.key]=o,r+=1;});let a={...e.edges};return t.data.edges.forEach(o=>{n[o.source]&&n[o.target]&&(a[o.key]=o);}),{...e,nodes:n,edges:a,counts:Wn(e.counts,t.data.counts),fetched:Zn(e.fetched,t.fetched),notice:i>0?`The canvas holds ${c$5.toLocaleString()} nodes at most; ${i.toLocaleString()} were left out. Hide some nodes to make room.`:e.notice,version:e.version+1}}case "remove":return cn(e,new Set(t.keys));case "keepOnly":{let n=new Set(t.keys);return cn(e,new Set(Object.keys(e.nodes).filter(r=>!n.has(r))))}case "clear":return {...We,hiddenEntities:e.hiddenEntities,version:e.version+1};case "toggleEntity":return {...e,hiddenEntities:e.hiddenEntities.includes(t.entity)?e.hiddenEntities.filter(n=>n!==t.entity):[...e.hiddenEntities,t.entity]};case "select":return e.selected===t.key?e:{...e,selected:t.key};case "togglePin":{let n={...e.pinned};return n[t.key]?delete n[t.key]:n[t.key]=true,{...e,pinned:n}}case "notice":return {...e,notice:t.message};default:return e}}function fn(e){return Object.values(e.nodes).reduce((t,n)=>(t[n.entity]=(t[n.entity]??0)+1,t),{})}function pn(e,t){return Object.values(e.edges).reduce((n,r)=>(r.source===t?n[r.sourceAttribute]=(n[r.sourceAttribute]??0)+1:r.target===t&&(n[r.targetAttribute]=(n[r.targetAttribute]??0)+1),n),{})}function mn(e,t){return Object.values(e.edges).flatMap(n=>n.source===t?[n.target]:n.target===t?[n.source]:[])}function sr(e){let[t,n,r]=[1,3,5].map(a=>{let o=parseInt(e.slice(a,a+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*r>.3?"#0a0a0a":"#ffffff"}function kn({node:e,schema:t,scope:n,scene:r,colors:i,isLoading:a,onClose:o,onOpenRecord:d,onExpandAll:b,onExpandAttribute:C,onHide:k}){let l=g$1(t,e.entity),u=f$2(),g=useMemo(()=>gql(l?p({defaultScope:u,entity:l,scope:n}):"query GraphDetails { __typename }"),[u,l,n]),f=useMemo(()=>gql(l?n$1({entity:l}):"query GraphCounts { __typename }"),[l]),E=useQuery(g,{variables:{id:e.id},skip:!l}),p$1=useQuery(f,{variables:{id:e.id},skip:!l}),S=l?E.data?.[l.plural]?.[0]:void 0,s=l?p$1.data?.[l.plural]?.[0]:void 0,N=useMemo(()=>pn(r,e.key),[r,e.key]),m=l?e$3(l):[],D=l?o$1(l):[],_=S?._updatedAt?new Date(S._updatedAt):null,$=i[e.entity]??"#71717a";return jsxs("aside",{"aria-label":"Selected record",className:"fk:flex fk:w-72 fk:shrink-0 fk:flex-col fk:gap-5 fk:overflow-y-auto fk:border-l fk:bg-background fk:p-4 fk:text-sm","data-testid":"graph-inspector",children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsx("span",{className:"fk:inline-flex fk:items-center fk:rounded-full fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium",style:{backgroundColor:$,color:sr($)},children:l?h(l):e.entity}),jsx(c$3,{"aria-label":"Close",className:"fk:size-7",onClick:o,size:"icon",variant:"ghost",children:jsx(XIcon,{className:"fk:size-4"})})]}),jsx("h2",{className:"fk:text-base fk:font-semibold fk:leading-snug fk:break-words",children:e.label}),jsxs("div",{className:"fk:flex fk:gap-1.5",children:[jsxs(c$3,{onClick:()=>d(e.key),size:"xs",children:[jsx(SquareArrowOutUpRightIcon,{}),"Open record"]}),jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(c$3,{"aria-label":"Expand every relationship",disabled:a,onClick:()=>b(e.key),size:"xs",variant:"outline",children:[a?jsx(LoaderCircleIcon,{className:"fk:animate-spin"}):jsx(ExpandIcon,{}),"Expand"]})}),jsx(e$2,{children:"Load the first related records of every relationship"})]}),jsxs(c$3,{"aria-label":"Hide this node",onClick:()=>k(e.key),size:"xs",variant:"outline",children:[jsx(EyeOffIcon,{}),"Hide"]})]})]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h3",{className:"fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Attributes"}),E.loading&&!S?jsx("span",{className:"fk:text-muted-foreground",children:"Loading\u2026"}):jsxs("dl",{className:"fk:grid fk:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] fk:gap-x-3 fk:gap-y-1.5",children:[D.map(v=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:truncate fk:text-muted-foreground",title:v.label,children:v.label}),jsx("dd",{className:"fk:min-w-0 fk:break-words",children:S&&s$1(S[v.name],n)||"\u2014"})]},v.name)),_?jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:"Updated"}),jsx("dd",{children:formatDistance(_,new Date,{addSuffix:true})})]}):null]})]}),m.length>0?jsxs("section",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("h3",{className:"fk:mb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:"Relationships"}),m.map(v=>{let A=g$1(t,v.relationship?.entity??""),q=s?.[`${v.name}Connection`]?.aggregate?.count?.nodes,c=N[v.name]??0,y=r.fetched[e.key]?.[v.name]??0,w=typeof q=="number"&&y>=q;return jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2 fk:shrink-0 fk:rounded-full",style:{backgroundColor:i[v.relationship?.entity??""]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",title:A?h(A):void 0,children:v.label}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:typeof q=="number"?`${c} of ${q.toLocaleString()}`:c}),q===0||w?null:jsx(c$3,{className:"fk:h-6 fk:px-2 fk:text-xs",disabled:a,onClick:()=>C(e.key,v),size:"xs",variant:"outline",children:y>0?"More":"Expand"})]},v.name)})]}):null]})}var bn=EditorView.theme({"&":{fontSize:"13px",height:"100%",minHeight:"0"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",overflow:"auto"},".cm-content":{fontSize:"13px",padding:"12px 0"},".cm-gutters":{borderRight:"1px solid transparent"}});function xn({ariaLabel:e,schema:t,theme:n,value:r,onChange:i,onRun:a}){let o=useRef(null),d=useRef(null),b=useRef(new Compartment),C=useRef(i),k=useRef(a),l=useRef(r);return C.current=i,k.current=a,l.current=r,useEffect(()=>{let u=o.current;if(!u)return;let g=new EditorView({parent:u,state:EditorState.create({doc:l.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),indentOnInput(),bracketMatching(),closeBrackets(),highlightActiveLine(),Prec.highest(keymap.of([{key:"Mod-Enter",run:()=>(k.current(),true)}])),keymap.of([...closeBracketsKeymap,...defaultKeymap,...historyKeymap,...foldKeymap,indentWithTab]),graphql(void 0,{showErrorOnInvalidSchema:false}),EditorView.updateListener.of(f=>{f.docChanged&&C.current(f.state.doc.toString());}),EditorView.contentAttributes.of({"aria-label":e,"aria-multiline":"true",role:"textbox"}),placeholder(`query {
|
|
2
|
+
\u2026
|
|
3
|
+
}`),b.current.of([n==="dark"?a$3:b$6,bn])]})});return d.current=g,()=>{g.destroy(),d.current=null;}},[]),useEffect(()=>{d.current?.dispatch({effects:b.current.reconfigure([n==="dark"?a$3:b$6,bn])});},[n]),useEffect(()=>{d.current&&updateSchema(d.current,t??void 0);},[t]),useEffect(()=>{let u=d.current;!u||u.state.doc.toString()===r||u.dispatch({changes:{from:0,to:u.state.doc.length,insert:r}});},[r]),jsx("div",{className:"fk:h-full fk:min-h-0 fk:w-full","data-testid":"graph-query-editor",ref:o})}var Ge=200,Mr=5,Gr=3;function Sn(e){return typeof e=="object"&&e!==null&&typeof e._id=="string"}function ge(e){if(Array.isArray(e))return e.flatMap(ge);if(typeof e!="object"||e===null)return [];if(Sn(e))return [e];let{edges:t}=e;return Array.isArray(t)?t.flatMap(n=>ge(n?.node)):[]}function Dr(e,t){let n=e.endsWith("Connection")?e.slice(0,-10):e;return t.find(r=>r.plural===n)}function Lr(e,t){let n=e.endsWith("Connection")?e.slice(0,-10):e;return e$3(t).find(r=>r.name===n)}function Ir(e,t){let n=e$3(e).filter(r=>r.relationship?.entity===t);return n.length===1?n[0]:void 0}function Pr(e,t,n){let r=e.__typename;return typeof r=="string"&&g$1(n,r)||t}function _r(e,t$1,n){let r=t(e,t$1,n);if(r!==e._id)return r;let i=Object.entries(e).find(([a,o])=>!a.startsWith("_")&&typeof o=="string"&&o.trim().length>0);return i?i[1]:e._id}function En({data:e,schema:t,scope:n}){let r=new Map,i=new Map,a=(o,d$1)=>{let b=Pr(o,d$1,t);if(!b)return null;let C=d(b.name,o._id),k=_r(o,b,n),l=r.get(C),u$1=l??{key:C,entity:b.name,id:o._id,label:k};return l?l.label===l.id&&k!==o._id&&(l.label=k):r.set(C,u$1),Object.entries(o).forEach(([g,f])=>{let E=Lr(g,b),p=E?g$1(t,E.relationship?.entity??""):void 0;ge(f).forEach(S=>{let s=a(S,p),N=E??(s?Ir(b,s.entity):void 0);if(s&&N&&s.key!==u$1.key){let m=u(u$1,s,N);i.has(m.key)||i.set(m.key,m);}});}),u$1};return Object.entries(e??{}).forEach(([o,d])=>{let b=Dr(o,t);ge(d).forEach(C=>a(C,b));}),{nodes:[...r.values()],edges:[...i.values()],counts:{}}}function Nn(e,t,n){return f$1(e).map(r=>{let i=e$3(r).slice(0,Gr).map(o=>{let d=g$1(e,o.relationship?.entity??"");return ` ${o.name}(limit: ${Mr}) {
|
|
4
|
+
_id
|
|
5
|
+
${j$2(d,t,n)}
|
|
6
|
+
}`}),a=j$2(r,t,n);return {entity:r.name,title:h(r),query:`query {
|
|
7
|
+
${r.plural}(limit: 25) {
|
|
8
|
+
_id
|
|
9
|
+
${a?` ${a}
|
|
10
|
+
`:""}${i.join(`
|
|
11
|
+
`)}
|
|
12
|
+
}
|
|
13
|
+
}`}})}function Or(e,t){let n=ge(e);return n.length>0?`${n.length} ${n.length===1?"record":"records"}`:Array.isArray(e)&&!(typeof e[0]=="object"&&e[0]!==null)?e.map(r=>s$1(r,t)).join(", "):s$1(e,t)}function et(e){if(Array.isArray(e))return e.flatMap(et);if(typeof e!="object"||e===null)return [];let{edges:t}=e;return !Sn(e)&&Array.isArray(t)?t.flatMap(n=>et(n?.node)):[e]}function vn(e,t){let n=Object.values(e??{}).flatMap(et),r=n.slice(0,Ge),i=[];return r.forEach(a=>{Object.keys(a).forEach(o=>{o!=="__typename"&&!i.includes(o)&&i.push(o);});}),{columns:i,rows:r.map(a=>Object.fromEntries(i.map(o=>[o,Or(a[o],t)]))),total:n.length}}function Me(e){return Array.isArray(e)?e.map(Me):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).filter(([t])=>t!=="__typename").map(([t,n])=>[t,Me(n)])):e}function tt(e){return `flexkit-graph:query:${e}`}var De=new Map;function Xr(e,t,n){let r=De.get(t);if(r&&r.hash===n)return r.schema;let i=e.query({query:gql(getIntrospectionQuery()),fetchPolicy:"no-cache",context:f$3}).then(a=>{if(!a.data)throw new Error("The schema could not be introspected.");return buildClientSchema(a.data)});return i.catch(()=>{De.get(t)?.schema===i&&De.delete(t);}),De.set(t,{hash:n,schema:i}),i}function wn(e,t){let n=useApolloClient(),[r,i]=useState(null);return useEffect(()=>{if(!e)return;let a=false;return Xr(n,e,t??"").then(o=>{a||i(o);}).catch(()=>{}),()=>{a=true;}},[n,e,t]),r}function An({projectId:e,schemaHash:t,schema:n$1,scope:r,theme:i,isRunning:a,hidden:o,onRun:d}){let[b,C]=useState(!o),k=wn(b?e:void 0,t),l=f$2(),u=useMemo(()=>Nn(n$1,r,l),[l,n$1,r]),[g,f]=useState(()=>b$5(tt(e))||u[0]?.query||""),E=useRef(g!==""),[p,S]=useState(false),[s,N]=useState("graph"),[m,D]=useState(null),_$1=useMemo(()=>s==="table"&&m?.data?vn(m.data,r):null,[s,m,r]),$=useMemo(()=>s==="json"&&m?.data?JSON.stringify(Me(m.data),null,2):null,[s,m]);useEffect(()=>{o||C(true);},[o]),useEffect(()=>{let[A]=u;!E.current&&A&&(E.current=true,f(q=>q||A.query));},[u]),useEffect(()=>{c$4(tt(e),g);},[e,g]);let v=async()=>{!g.trim()||a||D(await d(g,{append:p}));};return jsxs("section",{"aria-label":"Query",className:`fk:w-[26rem] fk:shrink-0 fk:flex-col fk:border-r fk:bg-background ${o?"fk:hidden":"fk:flex"}`,"data-testid":"graph-query-pane",hidden:o,children:[jsxs("div",{className:"fk:flex fk:h-12 fk:shrink-0 fk:items-center fk:gap-2 fk:border-b fk:pl-4 fk:pr-3",children:[jsx("span",{className:"fk:text-sm fk:font-semibold",children:"Query"}),jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-1.5",children:[u.length>0?jsxs(e$4,{children:[jsx(g$2,{asChild:true,children:jsxs(c$3,{className:"fk:h-8",size:"sm",variant:"outline",children:["Examples",jsx(ChevronDownIcon,{className:"fk:size-3.5"})]})}),jsx(h$1,{align:"end",className:"fk:max-h-80 fk:overflow-y-auto",children:u.map(A=>jsx(j$1,{onSelect:()=>f(A.query),children:A.title},A.entity))})]}):null,jsxs(c$3,{className:"fk:h-8",disabled:a||!g.trim(),onClick:()=>{v();},size:"sm",children:[a?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(PlayIcon,{className:"fk:size-3.5"}),"Run"]})]})]}),jsx("div",{className:"fk:min-h-0 fk:flex-1",children:jsx(xn,{ariaLabel:"GraphQL query",onChange:f,onRun:()=>{v();},schema:k,theme:i,value:g})}),jsxs(ea,{className:"fk:flex fk:max-h-[45%] fk:shrink-0 fk:flex-col fk:gap-0 fk:border-t",onValueChange:A=>N(A),value:s,children:[jsxs("div",{className:"fk:flex fk:h-11 fk:shrink-0 fk:items-center fk:gap-3 fk:px-3",children:[jsxs(fa,{children:[jsx(ga,{value:"graph",children:"Graph"}),jsx(ga,{value:"table",children:"Table"}),jsx(ga,{value:"json",children:"JSON"})]}),jsx("span",{className:"fk:ml-auto fk:truncate fk:text-xs fk:text-muted-foreground","data-testid":"graph-query-stats",children:m&&!m.error?`${m.nodes.toLocaleString()} ${m.nodes===1?"node":"nodes"} \xB7 ${m.edges.toLocaleString()} ${m.edges===1?"relationship":"relationships"} \xB7 ${m.elapsedMs.toLocaleString()} ms`:null})]}),m?.error?jsx("pre",{className:"fk:m-3 fk:mt-0 fk:max-h-40 fk:shrink-0 fk:overflow-auto fk:whitespace-pre-wrap fk:rounded-md fk:border fk:border-destructive/40 fk:bg-destructive/5 fk:p-2 fk:text-xs fk:text-destructive","data-testid":"graph-query-error",children:m.error}):null,jsxs("div",{className:"fk:min-h-0 fk:overflow-auto",children:[jsxs(ha,{className:"fk:flex fk:flex-col fk:gap-3 fk:px-3 fk:pb-3 fk:text-xs fk:text-muted-foreground",value:"graph",children:[jsxs("span",{children:["Every object with an ",jsx("code",{className:"fk:font-mono",children:"_id"})," under an entity field becomes a node; a nested relationship selection becomes a line between them."]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(n,{checked:p,id:"graph-query-append",onCheckedChange:A=>S(A===true)}),jsx(a$2,{className:"fk:text-xs fk:font-normal",htmlFor:"graph-query-append",children:"Add to the current canvas instead of replacing it"})]})]}),jsx(ha,{className:"fk:px-3 fk:pb-3",value:"table",children:_$1&&_$1.columns.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border",children:jsxs(Y,{children:[jsx(Z,{children:jsx(aa,{children:_$1.columns.map(A=>jsx(ba,{className:"fk:h-8 fk:text-xs",children:A},A))})}),jsx(_,{children:_$1.rows.map((A,q)=>jsx(aa,{children:_$1.columns.map(c=>jsx(ca,{className:"fk:max-w-56 fk:truncate fk:py-1.5 fk:text-xs",title:A[c],children:A[c]},c))},`${A._id??""}-${q}`))})]})}),_$1.total>Ge?jsxs("span",{className:"fk:text-xs fk:text-muted-foreground",children:["First ",Ge.toLocaleString()," of ",_$1.total.toLocaleString()," records."]}):null]}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:m?.data?"The response has no rows to show.":"Run a query to see its records."})}),jsx(ha,{className:"fk:px-3 fk:pb-3",value:"json",children:$?jsx("pre",{className:"fk:overflow-auto fk:rounded-md fk:border fk:bg-muted/40 fk:p-2 fk:font-mono fk:text-xs",children:$}):jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Run a query to see its response."})})]})]})]})}var eo=250,to=5;function no(e,t){let n=t.trim();return !n||e.length===0?null:{searchRequests:{searches:e.map(r=>({collection:r.plural}))},commonParams:{q:n,limit:to}}}function ro(e){let t=useMemo(()=>q$1(e),[e]),n=useMemo(()=>gql(t.length>0?r$1(t):"query GraphTotals { __typename }"),[t]),{data:r}=useQuery(n,{skip:t.length===0});return useMemo(()=>Object.fromEntries(t.map(i=>[i.plural,r?.[`${i.plural}Total`]]).filter(i=>typeof i[1]=="number")),[t,r])}function Cn({projectId:e,entities:t,colors:n$1,onCanvas:r,hiddenEntities:i,onStart:a,onHit:o,onToggleEntity:d}){let[b,C]=useState(""),[k]=useDebounce(b,eo),l=useMemo(()=>t.filter(s=>s.attributes.some(N=>N.searchable)),[t]),u=useMemo(()=>no(l,k),[l,k]),{results:g,isLoading:f}=a$1(e,u),E=ro(t),p=useMemo(()=>new Map(t.map(s=>[s.name,s])),[t]),S=Object.keys(r).sort();return jsxs(L,{collapsible:"icon",variant:"inset",children:[jsxs(P,{children:[jsxs(Q,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(b$3,{"aria-label":"Search records to add to the canvas",className:"fk:h-8 fk:bg-background fk:pl-8 fk:shadow-none",onChange:s=>C(s.target.value),placeholder:l.length>0?"Search records\u2026":"No searchable entity",disabled:l.length===0,value:b})]}),u?jsxs("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-0.5","data-testid":"graph-search-results",children:[g.map(s=>{let N=p.get(s._entityName),m=s[b$4(N)?.name??""];return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-2 fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:text-sm fk:hover:bg-sidebar-accent",onClick:()=>o(s._entityName,s._id),type:"button",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s._entityName]??"#71717a"}}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate",children:String(m??s._id)})]})},`${s._entityName}:${s._id}`)}),!f&&g.length===0?jsx("li",{className:"fk:px-2 fk:py-1.5 fk:text-sm fk:text-muted-foreground",children:"Nothing found"}):null]}):null]}),jsxs(Q,{children:[jsx(R,{children:"Nodes"}),jsx(T,{children:t.map(s=>jsx(U,{children:jsxs(V,{onClick:()=>a(s),tooltip:h(s),children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s.name]??"#71717a"}}),jsx("span",{className:"fk:truncate",children:h(s)}),E[s.plural]!==void 0?jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:E[s.plural]?.toLocaleString()}):null]})},s.name))})]}),S.length>0?jsxs(Q,{className:"fk:group-data-[collapsible=icon]:hidden",children:[jsx(R,{children:"On canvas"}),jsx("ul",{className:"fk:flex fk:flex-col","data-testid":"graph-legend",children:S.map(s=>{let N=p.get(s),m=!i.includes(s),D=`graph-legend-${s}`;return jsxs("li",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2 fk:px-2 fk:text-sm",children:[jsx("span",{"aria-hidden":"true",className:"fk:size-2.5 fk:shrink-0 fk:rounded-full",style:{backgroundColor:n$1[s]??"#71717a",opacity:m?1:.35}}),jsx("label",{className:"fk:min-w-0 fk:flex-1 fk:cursor-pointer fk:truncate",htmlFor:D,children:N?h(N):s}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:r[s]?.toLocaleString()}),jsx(n,{"aria-label":`Show ${N?h(N):s}`,checked:m,id:D,onCheckedChange:()=>d(s)})]},s)})})]}):null]}),jsx(N,{})]})}function Le({label:e,icon:t,disabled:n,onClick:r}){return jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsxs(c$3,{className:"fk:h-8 fk:gap-1.5 fk:px-2.5",disabled:n,onClick:r,size:"sm",variant:"ghost",children:[t,jsx("span",{className:"fk:text-xs",children:e})]})}),jsx(e$2,{children:e})]})}function Rn({hasSelection:e,hasNodes:t,isLoading:n,onFit:r,onExpand:i,onHide:a,onClear:o}){return jsxs("div",{className:"fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-1 fk:shadow-xs","data-testid":"graph-toolbar",children:[jsx(Le,{disabled:!t,icon:jsx(ScanIcon,{className:"fk:size-3.5"}),label:"Fit",onClick:r}),jsx(l$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!e||n,icon:n?jsx(LoaderCircleIcon,{className:"fk:size-3.5 fk:animate-spin"}):jsx(ExpandIcon,{className:"fk:size-3.5"}),label:"Expand",onClick:i}),jsx(Le,{disabled:!e,icon:jsx(EyeOffIcon,{className:"fk:size-3.5"}),label:"Hide",onClick:a}),jsx(l$1,{className:"fk:mx-0.5 fk:h-4",orientation:"vertical"}),jsx(Le,{disabled:!t,icon:jsx(EraserIcon,{className:"fk:size-3.5"}),label:"Clear",onClick:o})]})}function Pe(e,t="The records could not be loaded."){return e instanceof Error?e.message:t}function Tn({schema:e,scope:t}){let n=f$2(),r=useApolloClient(),[i,a$1]=useReducer(dn,We),[o,d$1]=useState(0),b=useRef(0),C=useCallback(async(g,f)=>{let E="ids"in f?f.ids:void 0,p="ids"in f?f.expand:false,S="limit"in f?f.limit:E?.length;d$1(s=>s+1);try{let N=(await r.query({query:gql(l({defaultScope:n,entity:g,schema:e,scope:t,expand:p})),variables:{where:E?{_id:{in:E}}:void 0,limit:S},fetchPolicy:"network-only"})).data?.[g.plural]??[];return b.current+=1,a$1({type:"merge",data:v({records:N,entity:g,schema:e,scope:t}),fetched:w(N,g)}),N.map(m=>d(g.name,m._id))}catch(s){return ma.error(Pe(s)),[]}finally{d$1(s=>s-1);}},[n,r,e,t]),k=useCallback(async g=>{let f=i.nodes[g],E=f?g$1(e,f.entity):void 0;!f||!E||await C(E,{ids:[f.id],expand:true});},[C,e,i.nodes]),l$1=useCallback(async(g,f)=>{let E=i.nodes[g],p=E?g$1(e,E.entity):void 0;if(!E||!p)return;let S=i.fetched[g]?.[f.name]??0;d$1(s=>s+1);try{let N=(await r.query({query:gql(m({defaultScope:n,entity:p,schema:e,scope:t,attribute:f})),variables:{id:E.id,offset:S,limit:a},fetchPolicy:"network-only"})).data?.[p.plural]??[];b.current+=1;let m$1=N.reduce((D,_)=>{let $=_[f.name];return D+(Array.isArray($)?$.length:0)},0);a$1({type:"merge",data:v({records:N,entity:p,schema:e,scope:t}),fetched:{[g]:{[f.name]:S+m$1}}});}catch(s){ma.error(Pe(s));}finally{d$1(s=>s-1);}},[n,r,e,t,i.fetched,i.nodes]),u=useCallback(async(g,{append:f})=>{let E=performance.now(),p;try{p=gql(g);}catch(s){return {data:null,error:Pe(s,"The query could not be parsed."),elapsedMs:0,nodes:0,edges:0}}let S=b.current;d$1(s=>s+1);try{let s=await r.query({query:p,fetchPolicy:"no-cache",errorPolicy:"all",context:f$3}),N=s.data??null,m=En({data:N,schema:e,scope:t});return m.nodes.length>0&&(!f&&!s.error&&b.current===S&&a$1({type:"clear"}),b.current+=1,a$1({type:"merge",data:m})),{data:N,error:s.error?s.error.message:null,elapsedMs:Math.round(performance.now()-E),nodes:m.nodes.length,edges:m.edges.length}}catch(s){return {data:null,error:Pe(s,"The query failed."),elapsedMs:Math.round(performance.now()-E),nodes:0,edges:0}}finally{d$1(s=>s-1);}},[r,e,t]);return {state:i,dispatch:a$1,isLoading:o>0,loadRecords:C,expandAll:k,expandAttribute:l$1,runQuery:u}}function is(){let{currentProjectId:e$4,currentProject:t,currentProjectSchema:n}=f();useEffect(()=>{e$4&&t&&e({event:"graph_opened",projectId:e$4});},[e$4,t]);let[,r]=g(),{scope:i$1}=c(),{resolvedTheme:a}=b(),o=useLocation(),d=j(),b$3=a==="dark"?"dark":"light",C=e$1(t?.scopes),k$1=i$1||C,l=r.user?.spaces,u=useMemo(()=>c$1(n,l),[n,l]),g$2=useMemo(()=>f$1(u),[u]),f$2=useMemo(()=>i(u,b$3),[u,b$3]),E=Tn({schema:u,scope:k$1}),{state:p,dispatch:S,isLoading:s,loadRecords:N,expandAll:m,expandAttribute:D,runQuery:_}=E,$=useRef(null),[v,A]=useState(null),[q,c$4]=useState(false),[y$1,w]=useState("explore"),R=useRef(null),G=useMemo(()=>fn(p),[p]),Q=p.selected?p.nodes[p.selected]:void 0,Y=v?p.nodes[v.key]:void 0,V=Y?g$1(u,Y.entity):void 0,K$1=Object.keys(p.nodes).length,h=Object.keys(p.edges).length,T=I(),L=useCallback(x=>S({type:"select",key:x}),[S]),oe=useCallback(x=>{let O=p.nodes[x],ie=O?g$1(u,O.entity):void 0;O&&ie&&d({type:"EditEntity",payload:{entityId:O.id,entityNamePlural:ie.plural}});},[d,u,p.nodes]),Oe=useCallback(x=>S({type:"remove",keys:[x]}),[S]),Dn=useCallback(x=>S({type:"keepOnly",keys:[x,...mn(p,x)]}),[S,p]),Ln=useCallback(x=>S({type:"togglePin",key:x}),[S]),In=useCallback(x=>{p.pinned[x]||S({type:"togglePin",key:x});},[S,p.pinned]),Pn=useCallback(async(x,O)=>{let ie=g$1(u,x);if(!ie)return;let[fe]=await N(ie,{ids:[O],expand:true});fe&&L(fe);},[N,u,L]),_n=useCallback((x,O)=>{A(null),D(x,O);},[D]);return useEffect(()=>{let x=y(o.search);if(!x||R.current===o.key)return;let O=g$1(u,x.entity);if(!O||u.length===0)return;R.current=o.key;let ie=x.ids.length>0?{ids:x.ids,expand:x.ids.length<=k}:{limit:b$1};N(O,ie).then(fe=>{x.ids.length===1&&fe[0]&&L(fe[0]);});},[o.key,o.search,u,N,L]),e$4?jsxs(K,{className:"fk:h-full",defaultOpen:T,children:[jsx(Cn,{colors:f$2,entities:g$2,hiddenEntities:p.hiddenEntities,onCanvas:G,onHit:(x,O)=>{Pn(x,O);},onStart:x=>{N(x,{limit:b$1});},onToggleEntity:x=>S({type:"toggleEntity",entity:x}),projectId:e$4}),jsx(O,{className:"fk:min-w-0",children:jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0","data-testid":"graph-app",children:[jsx(An,{hidden:y$1!=="query",isRunning:s,onRun:_,projectId:e$4,schema:u,schemaHash:t?.schemaHash??null,scope:k$1,theme:b$3},e$4),jsxs("div",{className:"fk:relative fk:min-w-0 fk:flex-1 fk:overflow-hidden fk:bg-background",children:[jsxs("div",{className:"fk:pointer-events-none fk:absolute fk:left-3 fk:right-3 fk:top-3 fk:z-10 fk:flex fk:flex-wrap fk:items-start fk:justify-between fk:gap-2",children:[jsxs("div",{className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(b$2,{children:[jsx(c$2,{asChild:true,children:jsx(M,{className:"fk:h-8 fk:w-8 fk:rounded-lg fk:hover:bg-transparent fk:dark:hover:bg-transparent"})}),jsx(e$2,{children:"Toggle Sidebar"})]}),jsx(Rn,{hasNodes:K$1>0,hasSelection:Q!==void 0,isLoading:s,onClear:()=>S({type:"clear"}),onExpand:()=>{p.selected&&m(p.selected);},onFit:()=>$.current?.fit(),onHide:()=>{p.selected&&Oe(p.selected);}})]}),jsxs("div",{"aria-label":"View",className:"fk:pointer-events-auto fk:flex fk:items-center fk:gap-0.5 fk:rounded-lg fk:border fk:bg-background fk:p-0.5 fk:shadow-xs","data-testid":"graph-mode",role:"group",children:[jsx(c$3,{"aria-pressed":y$1==="explore",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>w("explore"),size:"sm",variant:y$1==="explore"?"default":"ghost",children:"Explore"}),jsx(c$3,{"aria-pressed":y$1==="query",className:"fk:h-7 fk:px-3 fk:text-xs",onClick:()=>w("query"),size:"sm",variant:y$1==="query"?"default":"ghost",children:"Query"})]})]}),K$1>0?null:jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground",children:s?"Loading records\u2026":y$1==="query"?"Run a query to draw its result.":"Search a record or start from an entity to draw its graph."}),jsx(ln,{apiRef:$,colors:f$2,onContextMenu:(x,O)=>A({key:x,...O}),onExpand:x=>{m(x);},onLayoutChange:c$4,onPin:In,onSelect:L,scene:p,theme:b$3}),jsxs("div",{className:"fk:absolute fk:bottom-3 fk:left-3 fk:flex fk:max-w-[calc(100%-1.5rem)] fk:items-center fk:gap-2 fk:rounded-lg fk:border fk:bg-background fk:px-2.5 fk:py-1.5 fk:text-xs fk:text-muted-foreground fk:shadow-xs","data-testid":"graph-status",children:[jsxs("span",{children:[K$1.toLocaleString()," ",K$1===1?"node":"nodes"," \xB7 ",h.toLocaleString()," ",h===1?"relationship":"relationships"]}),q?jsx("span",{children:"\xB7 laying out\u2026"}):null,p.notice?jsxs("span",{className:"fk:truncate fk:text-foreground",children:["\xB7 ",p.notice]}):null]}),jsx(un,{isPinned:v?p.pinned[v.key]===true:false,menu:v,onClose:()=>A(null),onExpandAll:x=>{m(x);},onExpandAttribute:_n,onHide:Oe,onHideOthers:Dn,onOpenRecord:oe,onTogglePin:Ln,relationships:V?e$3(V):[]})]}),Q?jsx(kn,{colors:f$2,isLoading:s,node:Q,onClose:()=>L(null),onExpandAll:x=>{m(x);},onExpandAttribute:(x,O)=>{D(x,O);},onHide:Oe,onOpenRecord:oe,scene:p,schema:u,scope:k$1}):null]})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to explore its graph."})}export{is as Root};//# sourceMappingURL=root-TSZ3CSJU.js.map
|
|
14
|
+
//# sourceMappingURL=root-TSZ3CSJU.js.map
|