@flexkit/studio 0.2.22 → 0.2.23
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/astro.js +1 -1
- package/dist/{chat-page-WLKJ3QNZ.js → chat-page-ASH67R6B.js} +3 -3
- package/dist/{chat-page-WLKJ3QNZ.js.map → chat-page-ASH67R6B.js.map} +1 -1
- package/dist/{chunk-SE4HJCGA.js → chunk-7HBT6L4U.js} +2 -2
- package/dist/{chunk-SE4HJCGA.js.map → chunk-7HBT6L4U.js.map} +1 -1
- package/dist/{chunk-QTFFVG7C.js → chunk-7HEARTFH.js} +2 -2
- package/dist/{chunk-QTFFVG7C.js.map → chunk-7HEARTFH.js.map} +1 -1
- package/dist/{chunk-UCHWUGRT.js → chunk-AMUTDCI7.js} +3 -3
- package/dist/{chunk-UCHWUGRT.js.map → chunk-AMUTDCI7.js.map} +1 -1
- package/dist/{chunk-GGC75EMC.js → chunk-C4XLDODU.js} +2 -0
- package/dist/{chunk-YXUEPR7K.js → chunk-CAMLITJT.js} +3 -3
- package/dist/{chunk-YXUEPR7K.js.map → chunk-CAMLITJT.js.map} +1 -1
- package/dist/{chunk-K2KW6UYG.js → chunk-CJHMUEOB.js} +2 -2
- package/dist/{chunk-K2KW6UYG.js.map → chunk-CJHMUEOB.js.map} +1 -1
- package/dist/{chunk-MHVZXDVL.js → chunk-DAM7JM5J.js} +2 -2
- package/dist/{chunk-MHVZXDVL.js.map → chunk-DAM7JM5J.js.map} +1 -1
- package/dist/{chunk-BM7INZL3.js → chunk-E2NDJLAI.js} +3 -3
- package/dist/{chunk-BM7INZL3.js.map → chunk-E2NDJLAI.js.map} +1 -1
- package/dist/{chunk-6AI7322C.js → chunk-EYIV4KVY.js} +3 -3
- package/dist/{chunk-6AI7322C.js.map → chunk-EYIV4KVY.js.map} +1 -1
- package/dist/{chunk-HGXYSP47.js → chunk-FUX7UG36.js} +3 -3
- package/dist/{chunk-HGXYSP47.js.map → chunk-FUX7UG36.js.map} +1 -1
- package/dist/{chunk-4LVMCUHR.js → chunk-KN7OJFEX.js} +2 -2
- package/dist/{chunk-4LVMCUHR.js.map → chunk-KN7OJFEX.js.map} +1 -1
- package/dist/{chunk-HBTMGDOM.js → chunk-KQVLLOWJ.js} +2 -2
- package/dist/{chunk-HBTMGDOM.js.map → chunk-KQVLLOWJ.js.map} +1 -1
- package/dist/{chunk-LIMXKPEK.js → chunk-V7C4EHK3.js} +2 -2
- package/dist/{chunk-LIMXKPEK.js.map → chunk-V7C4EHK3.js.map} +1 -1
- package/dist/chunk-WPCPL2TQ.js +3 -0
- package/dist/chunk-WPCPL2TQ.js.map +1 -0
- package/dist/{chunk-UJEDL3IZ.js → chunk-YEWTJHKW.js} +2 -2
- package/dist/{chunk-UJEDL3IZ.js.map → chunk-YEWTJHKW.js.map} +1 -1
- package/dist/{chunk-RPLKJVDQ.js → chunk-YRPFCYLR.js} +3 -3
- package/dist/{chunk-RPLKJVDQ.js.map → chunk-YRPFCYLR.js.map} +1 -1
- package/dist/chunk-ZIHC7WWT.js +4 -0
- package/dist/chunk-ZIHC7WWT.js.map +1 -0
- package/dist/electron.js +1 -1
- package/dist/{entry-GWZ7DELK.js → entry-O75LJP6A.js} +2 -2
- package/dist/{entry-GWZ7DELK.js.map → entry-O75LJP6A.js.map} +1 -1
- package/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/{list-LMIKCT2W.js → list-R3FH7CYE.js} +2 -2
- package/dist/{list-LMIKCT2W.js.map → list-R3FH7CYE.js.map} +1 -1
- package/dist/{list-FQZII7QD.js → list-RZROVSNS.js} +3 -3
- package/dist/{list-FQZII7QD.js.map → list-RZROVSNS.js.map} +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/{pages-NKE7FV34.js → pages-NBXY5WPW.js} +3 -3
- package/dist/{pages-NKE7FV34.js.map → pages-NBXY5WPW.js.map} +1 -1
- package/dist/{plugin-pages-4HTADSK3.js → plugin-pages-IPEYHBKC.js} +2 -2
- package/dist/{plugin-pages-4HTADSK3.js.map → plugin-pages-IPEYHBKC.js.map} +1 -1
- package/dist/record-links-D5GJWZIK.js +2 -0
- package/dist/{record-links-FDWV4X5W.js.map → record-links-D5GJWZIK.js.map} +1 -1
- package/dist/{root-GYJGAS22.js → root-3J3XAFUX.js} +2 -2
- package/dist/{root-GYJGAS22.js.map → root-3J3XAFUX.js.map} +1 -1
- package/dist/{root-ZYUSZZWR.js → root-LWFZRWNO.js} +3 -3
- package/dist/{root-ZYUSZZWR.js.map → root-LWFZRWNO.js.map} +1 -1
- package/dist/{root-X3V4NC2D.js → root-QKNPDDE4.js} +2 -2
- package/dist/{root-X3V4NC2D.js.map → root-QKNPDDE4.js.map} +1 -1
- package/dist/root-QRSWWD23.js +14 -0
- package/dist/root-QRSWWD23.js.map +1 -0
- package/dist/{root-OSXC52GL.js → root-TL5U37VT.js} +2 -2
- package/dist/{root-OSXC52GL.js.map → root-TL5U37VT.js.map} +1 -1
- package/dist/{root-VL4EM2IS.js → root-XXHLLKQS.js} +3 -3
- package/dist/{root-VL4EM2IS.js.map → root-XXHLLKQS.js.map} +1 -1
- package/dist/{search-UW7WE2CS.js → search-KXTZNQCX.js} +2 -2
- package/dist/{search-UW7WE2CS.js.map → search-KXTZNQCX.js.map} +1 -1
- package/dist/{skills-pages-Q4YSUQVZ.js → skills-pages-CDOGI5ZZ.js} +2 -2
- package/dist/{skills-pages-Q4YSUQVZ.js.map → skills-pages-CDOGI5ZZ.js.map} +1 -1
- package/dist/{source-PGSWL4DQ.js → source-HTBEV3UC.js} +2 -2
- package/dist/{source-PGSWL4DQ.js.map → source-HTBEV3UC.js.map} +1 -1
- package/dist/tanstack-start.js +1 -1
- package/dist/{user-nav-B37OEVQN.js → user-nav-OWTTAXZS.js} +2 -2
- package/dist/{user-nav-B37OEVQN.js.map → user-nav-OWTTAXZS.js.map} +1 -1
- package/package.json +6 -6
- package/dist/chunk-JIB4PRLH.js +0 -3
- package/dist/chunk-JIB4PRLH.js.map +0 -1
- package/dist/record-links-FDWV4X5W.js +0 -2
- package/dist/root-YDHREGTF.js +0 -14
- package/dist/root-YDHREGTF.js.map +0 -1
|
@@ -36,6 +36,8 @@ var userApiPaths = {
|
|
|
36
36
|
/** POST: Studio error reports (see core/error/error-reporter.ts). */
|
|
37
37
|
clientErrors: `/api/flexkit/${USER_API_SEGMENT}/client-errors`,
|
|
38
38
|
logout: `/api/flexkit/${USER_API_SEGMENT}/auth/logout`,
|
|
39
|
+
/** POST: product events only Studio sees (see core/analytics/product-events.ts). */
|
|
40
|
+
productEvents: `/api/flexkit/${USER_API_SEGMENT}/product-events`,
|
|
39
41
|
/** Signed-in user plus every project they can open. */
|
|
40
42
|
me: `/api/flexkit/${USER_API_SEGMENT}/me`,
|
|
41
43
|
/** The signed-in user's notification preferences (desktop kinds, approval email). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'./index.css';import {f as f$1,e as e$2}from'./chunk-
|
|
1
|
+
import'./index.css';import {f as f$1,e as e$2}from'./chunk-YRPFCYLR.js';import {p,o as o$1,h as h$1,i}from'./chunk-AMUTDCI7.js';import {b}from'./chunk-V7C4EHK3.js';import {j}from'./chunk-E2NDJLAI.js';import {d,c}from'./chunk-XMOSCJOI.js';import {s}from'./chunk-7KLXWCDS.js';import {f}from'./chunk-EYIV4KVY.js';import {na}from'./chunk-DGIY4SKN.js';import {e,g,h,j as j$1,o,n,k}from'./chunk-SZEGGBOC.js';import {a,d as d$1,c as c$1,e as e$1,g as g$1}from'./chunk-HDOIOXMP.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {PencilIcon,Trash2Icon,Ellipsis,Settings2,RefreshCw,Loader2,Trash2}from'lucide-react';import {jsxs,jsx}from'react/jsx-runtime';import {lazy,useState,Suspense}from'react';import {find,propEq}from'ramda';import {gql}from'@apollo/client';import {useApolloClient}from'@apollo/client/react';import {toast}from'sonner';function Be({entityName:e$1,entityNamePlural:a,row:c,options:i={canDelete:true,canEdit:true}}){let m=j(),N=b(),p=c.original._id,D=(i.canDelete??true)&&N,f=i.canEdit??true;function h$1(){m({type:"EditEntity",payload:{entityId:p,entityNamePlural:a}});}function d(){m({type:"DeleteEntity",payload:{entityId:p,entityName:e$1}});}return jsxs("div",{className:"fk:flex",children:[f&&jsxs(b$1,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:h$1,variant:"ghost",children:[jsx(PencilIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Edit"})]}),D&&!f&&jsxs(b$1,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:d,variant:"ghost",children:[jsx(Trash2Icon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Delete"})]}),f&&D&&jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b$1,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0",variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Additional actions"})]})}),jsxs(h,{align:"end",className:"w-[160px]",children:[jsxs(j$1,{onClick:h$1,children:[jsx(PencilIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Edit"]}),jsx(o,{}),jsxs(j$1,{className:"fk:text-destructive",onClick:d,children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]})]})}function Z({table:e$1}){return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b$1,{className:"fk:hidden fk:h-8 fk:lg:flex",size:"sm",variant:"outline",children:[jsx(Settings2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"View"]})}),jsxs(h,{align:"end",className:"fk:w-[150px]",children:[jsx(n,{children:"Toggle columns"}),jsx(o,{}),e$1.getAllColumns().filter(a=>typeof a.accessorFn<"u"&&a.getCanHide()).map(a=>jsx(k,{checked:a.getIsVisible(),className:"capitalize",onCheckedChange:c=>{a.toggleVisibility(!!c);},children:a.id},a.id))]})]})}var Ce=lazy(()=>import('./record-links-D5GJWZIK.js').then(e=>({default:e.EntityKnowledgeButton}))),ve=lazy(()=>import('./entry-O75LJP6A.js').then(e=>({default:e.EntityGraphButton})));function at({entityName:e,isReloading:a$1=false,onReload:c$2,table:i$1}){let m=j(),N=d(),p$1=c(),D=useApolloClient(),{currentProject:f$2,currentProjectId:h}=f(),d$2=f$2?.schema??[],w=f$2?.scopes,[ae,ne,le]=f$1(),[b$2,P]=useState(false),y=b(),r=i$1.getSelectedRowModel().rows.map(t=>t.original._id);function se(){m({type:"AddEntity",payload:{entityName:e}});}function ie(t){N({type:"setScope",payload:{projectId:h,scope:t}});}async function re(t){if(t.length===0)return;let u=h$1(e,d$2,t);await new Promise((pe,fe)=>{ne(gql`
|
|
2
2
|
${u}
|
|
3
|
-
`),le({variables:{where:i(t)},update(x){for(let me of t)x.evict({id:me});},onCompleted:()=>{pe();},onError:x=>{fe(x);}}),ae(true);});}function ce(){let t=e==="_asset"?"asset":e.toLowerCase();m({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${r.length} ${t}${r.length>1?"s":""}`,dialogMessage:r.length>1?`Are you sure you want to delete the selected ${t}s? They will be deleted permanently.`:`Are you sure you want to delete the selected ${t}? The item will be deleted permanently.`,dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionSubmit:async()=>{P(true);try{let u=[...r];await re(u),i$1.resetRowSelection(),await p(D,o$1(e,d$2),u),toast.success(u.length>1?"Items successfully deleted.":"Item successfully deleted.");}catch{toast.error("Failed to delete selected items.");}finally{P(false);}},dialogActionCancel:()=>{}}}});}return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[w&&w.length>0?jsxs(a,{defaultValue:p$1.scope,onValueChange:t=>{ie(t);},value:p$1.scope,children:[jsxs(d$1,{className:"fk:w-48!",id:"project",size:"sm",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:"}),jsx(c$1,{children:(find(propEq(p$1.scope??"","name"))(w)||null)?.label})]}),jsx(e$1,{children:w.map(t=>jsx(g$1,{value:t.name,children:t.label},t.name))})]}):null,jsx(Z,{table:i$1}),c$2?jsx(b$1,{"aria-label":"Reload",className:"fk:h-8",disabled:b$2||a$1,onClick:c$2,size:"icon-sm",variant:"outline",children:jsx(RefreshCw,{className:a$1?"fk:animate-spin":void 0})}):null,jsx(e$2,{table:i$1})]}),r.length>0?jsx(na,{disabled:!y,children:jsxs(b$1,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:b$2||!y,onClick:ce,size:"sm",variant:"destructive",children:[b$2?jsx(Loader2,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete (",r.length,")"]})}):null,e&&s(e)?jsx(Suspense,{fallback:null,children:jsx(Ce,{entityName:e})}):null,e?jsx(Suspense,{fallback:null,children:jsx(ve,{entityName:e,selectedIds:r})}):null,jsx(na,{disabled:!y,children:jsx(b$1,{className:"fk:h-8 fk:lg:flex",disabled:b$2||!y,onClick:se,size:"sm",variant:"default",children:"Create"})})]})}export{Be as a,Z as b,at as c};//# sourceMappingURL=chunk-
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
`),le({variables:{where:i(t)},update(x){for(let me of t)x.evict({id:me});},onCompleted:()=>{pe();},onError:x=>{fe(x);}}),ae(true);});}function ce(){let t=e==="_asset"?"asset":e.toLowerCase();m({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${r.length} ${t}${r.length>1?"s":""}`,dialogMessage:r.length>1?`Are you sure you want to delete the selected ${t}s? They will be deleted permanently.`:`Are you sure you want to delete the selected ${t}? The item will be deleted permanently.`,dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionSubmit:async()=>{P(true);try{let u=[...r];await re(u),i$1.resetRowSelection(),await p(D,o$1(e,d$2),u),toast.success(u.length>1?"Items successfully deleted.":"Item successfully deleted.");}catch{toast.error("Failed to delete selected items.");}finally{P(false);}},dialogActionCancel:()=>{}}}});}return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[w&&w.length>0?jsxs(a,{defaultValue:p$1.scope,onValueChange:t=>{ie(t);},value:p$1.scope,children:[jsxs(d$1,{className:"fk:w-48!",id:"project",size:"sm",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:"}),jsx(c$1,{children:(find(propEq(p$1.scope??"","name"))(w)||null)?.label})]}),jsx(e$1,{children:w.map(t=>jsx(g$1,{value:t.name,children:t.label},t.name))})]}):null,jsx(Z,{table:i$1}),c$2?jsx(b$1,{"aria-label":"Reload",className:"fk:h-8",disabled:b$2||a$1,onClick:c$2,size:"icon-sm",variant:"outline",children:jsx(RefreshCw,{className:a$1?"fk:animate-spin":void 0})}):null,jsx(e$2,{table:i$1})]}),r.length>0?jsx(na,{disabled:!y,children:jsxs(b$1,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:b$2||!y,onClick:ce,size:"sm",variant:"destructive",children:[b$2?jsx(Loader2,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete (",r.length,")"]})}):null,e&&s(e)?jsx(Suspense,{fallback:null,children:jsx(Ce,{entityName:e})}):null,e?jsx(Suspense,{fallback:null,children:jsx(ve,{entityName:e,selectedIds:r})}):null,jsx(na,{disabled:!y,children:jsx(b$1,{className:"fk:h-8 fk:lg:flex",disabled:b$2||!y,onClick:se,size:"sm",variant:"default",children:"Create"})})]})}export{Be as a,Z as b,at as c};//# sourceMappingURL=chunk-CAMLITJT.js.map
|
|
4
|
+
//# sourceMappingURL=chunk-CAMLITJT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/data-grid/data-table-row-actions.tsx","../src/data-grid/data-table-view-options.tsx","../src/data-grid/data-table-toolbar.tsx"],"names":["DataTableRowActions","entityName","entityNamePlural","row","options","actionDispatch","useDispatch","canMutate","useCanMutate","entityId","canDelete","canEdit","handleEdit","handleDelete","jsxs","Button","jsx","PencilIcon","Trash2Icon","DropdownMenu","DropdownMenuTrigger","Ellipsis","DropdownMenuContent","DropdownMenuItem","DropdownMenuSeparator","DataTableViewOptions","table","Settings2","DropdownMenuLabel","column","DropdownMenuCheckboxItem","value","EntityKnowledgeButton","lazy","m","EntityGraphButton","DataTableToolbar","isReloading","onReload","appDispatch","useAppDispatch","appContext","useAppContext","apolloClient","useApolloClient","currentProject","currentProjectId","useConfig","schema","scopes","runMutation","setMutation","setOptions","useEntityMutation","isDeleting","setIsDeleting","useState","selectedIds","handleCreate","handleScopeChange","deleteSelected","ids","mutation","getEntityDeleteMutation","resolve","reject","gql","getEntityDeleteWhere","cache","id","error","handleBatchDelete","itemLabel","idsToDelete","scheduleEntityListRemoval","getEntityListQueryName","toast","Select","SelectTrigger","SelectValue","find","propEq","SelectContent","scopeItem","SelectItem","RefreshCw","DataTableSortedBy","PermissionTooltip","Loader2","Trash2","isKnowledgeLinkableEntity","Suspense"],"mappings":"q0BA0BO,SAASA,EAAAA,CAA2B,CACzC,UAAA,CAAAC,GAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,GAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CAAU,CAAE,SAAA,CAAW,IAAA,CAAM,OAAA,CAAS,IAAK,CAC7C,CAAA,CAAiD,CAC/C,IAAMC,CAAAA,CAAiBC,CAAAA,EAAY,CAC7BC,CAAAA,CAAYC,CAAAA,EAAa,CAEzBC,CAAAA,CAAWN,CAAAA,CAAI,QAAA,CAAS,GAAA,CAGxBO,CAAAA,CAAAA,CAAaN,CAAAA,CAAQ,SAAA,EAAa,IAAA,GAASG,CAAAA,CAC3CI,CAAAA,CAAUP,CAAAA,CAAQ,OAAA,EAAW,IAAA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A,CAACuE,EAAAA,CAAA,CAAkB,QAAA,CAAU,CAAChF,EAC5B,QAAA,CAAAS,GAAAA,CAACD,IAAA,CACC,SAAA,CAAU,oBACV,QAAA,CAAUuC,GAAAA,EAAc,CAAC/C,CAAAA,CACzB,OAAA,CAASmD,GACT,IAAA,CAAK,IAAA,CACL,QAAQ,SAAA,CACT,QAAA,CAAA,QAAA,CAED,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"chunk-YXUEPR7K.js","sourcesContent":["'use client';\n\nimport type { JSX } from 'react';\nimport { Ellipsis, PencilIcon, Trash2Icon } from 'lucide-react';\nimport type { Row } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\nimport { useDispatch } from '../entities/actions-context';\nimport { useCanMutate } from '../core/permissions';\n\ninterface DataTableRowActionsProps<TData> {\n entityName: string;\n entityNamePlural: string;\n row: Row<TData>;\n options?: {\n canDelete?: boolean;\n canEdit?: boolean;\n };\n}\n\nexport function DataTableRowActions<TData>({\n entityName,\n entityNamePlural,\n row,\n options = { canDelete: true, canEdit: true },\n}: DataTableRowActionsProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const canMutate = useCanMutate();\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const entityId = row.original._id;\n // Read-only roles keep the pencil (the drawer doubles as their read view)\n // but lose the delete affordance entirely.\n const canDelete = (options.canDelete ?? true) && canMutate;\n const canEdit = options.canEdit ?? true;\n\n function handleEdit(): void {\n actionDispatch({ type: 'EditEntity', payload: { entityId, entityNamePlural } });\n }\n\n function handleDelete(): void {\n actionDispatch({ type: 'DeleteEntity', payload: { entityId, entityName } });\n }\n\n return (\n <div className=\"fk:flex\">\n {canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleEdit} variant=\"ghost\">\n <PencilIcon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Edit</span>\n </Button>\n )}\n {canDelete && !canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleDelete} variant=\"ghost\">\n <Trash2Icon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Delete</span>\n </Button>\n )}\n {canEdit && canDelete && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0\" variant=\"ghost\">\n <Ellipsis className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Additional actions</span>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-[160px]\">\n <DropdownMenuItem onClick={handleEdit}>\n <PencilIcon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Edit\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={handleDelete}>\n <Trash2Icon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n );\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { Settings2 } from 'lucide-react';\nimport type { Table } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\n\ninterface DataTableViewOptionsProps<TData> {\n table: Table<TData>;\n}\n\nexport function DataTableViewOptions<TData>({ table }: DataTableViewOptionsProps<TData>): JSX.Element {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:hidden fk:h-8 fk:lg:flex\" size=\"sm\" variant=\"outline\">\n <Settings2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n View\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-[150px]\">\n <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== 'undefined' && column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n checked={column.getIsVisible()}\n className=\"capitalize\"\n key={column.id}\n onCheckedChange={(value) => {\n column.toggleVisibility(Boolean(value));\n }}\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","'use client';\n\nimport { lazy, Suspense, useState } from 'react';\nimport type { JSX } from 'react';\nimport { find, propEq } from 'ramda';\nimport type { Table } from '@tanstack/react-table';\nimport { Loader2, RefreshCw, Trash2 } from 'lucide-react';\nimport { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { toast } from 'sonner';\nimport { Button } from '../ui/primitives/button';\nimport { PermissionTooltip } from '../ui/components/permission-tooltip';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/primitives/select';\nimport { useDispatch } from '../entities/actions-context';\nimport { useAppContext, useAppDispatch } from '../core/app-context';\nimport { useCanMutate } from '../core/permissions';\nimport { useConfig } from '../core/config/config-context';\nimport { DataTableViewOptions } from './data-table-view-options';\nimport { DataTableSortedBy } from './data-table-sorted-by';\nimport { useEntityMutation } from '../graphql-client/use-entity-mutation';\nimport { getEntityDeleteMutation, getEntityDeleteWhere } from '../graphql-client/queries';\nimport { getEntityListQueryName, scheduleEntityListRemoval } from '../graphql-client/refetch-entity-lists';\nimport { isKnowledgeLinkableEntity } from '../apps/knowledge/knowledge';\n\n// Loaded on demand: the Knowledge module should only download when a list of\n// a linkable entity is in view, the way the record drawer loads its panel.\nconst EntityKnowledgeButton = lazy(() =>\n import('../apps/knowledge/record-links').then((m) => ({ default: m.EntityKnowledgeButton }))\n);\nconst EntityGraphButton = lazy(() => import('../apps/graph/entry').then((m) => ({ default: m.EntityGraphButton })));\n\ninterface DataTableToolbarProps<TData> {\n entityName: string;\n isReloading?: boolean;\n onReload?: () => void;\n table: Table<TData>;\n}\n\nexport function DataTableToolbar<TData>({\n entityName,\n isReloading = false,\n onReload,\n table,\n}: DataTableToolbarProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const appDispatch = useAppDispatch();\n const appContext = useAppContext();\n const apolloClient = useApolloClient();\n const { currentProject, currentProjectId } = useConfig();\n const schema = currentProject?.schema ?? [];\n const scopes = currentProject?.scopes;\n const [runMutation, setMutation, setOptions] = useEntityMutation();\n const [isDeleting, setIsDeleting] = useState(false);\n const canMutate = useCanMutate();\n\n // Collect selected entity ids from the table\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const selectedIds: string[] = table.getSelectedRowModel().rows.map((row) => row.original._id as string);\n\n function handleCreate(): void {\n actionDispatch({ type: 'AddEntity', payload: { entityName } });\n }\n\n function handleScopeChange(value: string): void {\n appDispatch({ type: 'setScope', payload: { projectId: currentProjectId, scope: value } });\n }\n\n async function deleteSelected(ids: string[]): Promise<void> {\n if (ids.length === 0) {\n return;\n }\n\n const mutation = getEntityDeleteMutation(entityName, schema, ids);\n\n await new Promise<void>((resolve, reject) => {\n setMutation(gql`\n ${mutation}\n `);\n\n setOptions({\n variables: { where: getEntityDeleteWhere(ids) },\n update(cache: { evict: (arg0: { id: string }) => void }) {\n for (const id of ids) {\n cache.evict({ id });\n }\n },\n onCompleted: () => {\n resolve();\n },\n onError: (error: Error) => {\n reject(error);\n },\n });\n\n runMutation(true);\n });\n }\n\n function handleBatchDelete(): void {\n const itemLabel = entityName === '_asset' ? 'asset' : entityName.toLowerCase();\n\n actionDispatch({\n type: 'AlertDialog',\n payload: {\n options: {\n dialogTitle: `Delete ${selectedIds.length} ${itemLabel}${selectedIds.length > 1 ? 's' : ''}`,\n dialogMessage:\n selectedIds.length > 1\n ? `Are you sure you want to delete the selected ${itemLabel}s? They will be deleted permanently.`\n : `Are you sure you want to delete the selected ${itemLabel}? The item will be deleted permanently.`,\n dialogCancelTitle: 'Cancel',\n dialogActionLabel: 'Delete',\n isDestructive: true,\n dialogActionSubmit: async () => {\n setIsDeleting(true);\n\n try {\n const idsToDelete = [...selectedIds];\n\n await deleteSelected(idsToDelete);\n\n table.resetRowSelection();\n // Drop rows immediately, then soft-refetch counts/pages.\n await scheduleEntityListRemoval(apolloClient, getEntityListQueryName(entityName, schema), idsToDelete);\n toast.success(idsToDelete.length > 1 ? 'Items successfully deleted.' : 'Item successfully deleted.');\n } catch {\n toast.error('Failed to delete selected items.');\n } finally {\n setIsDeleting(false);\n }\n },\n dialogActionCancel: () => {\n // no-op\n },\n },\n },\n });\n }\n\n return (\n <div className=\"fk:flex fk:items-center fk:justify-between\">\n <div className=\"fk:flex fk:flex-1 fk:items-center fk:space-x-2\">\n {scopes && scopes.length > 0 ? (\n <Select\n defaultValue={appContext.scope}\n onValueChange={(value) => {\n handleScopeChange(value);\n }}\n value={appContext.scope}\n >\n <SelectTrigger className=\"fk:w-48!\" id=\"project\" size=\"sm\">\n <span className=\"fk:text-muted-foreground\">Scope:</span>\n <SelectValue>\n {\n ((find(propEq(appContext.scope ?? '', 'name'))(scopes) as { name: string; label: string }) || null)\n ?.label\n }\n </SelectValue>\n </SelectTrigger>\n <SelectContent>\n {scopes.map((scopeItem) => (\n <SelectItem key={scopeItem.name} value={scopeItem.name}>\n {scopeItem.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : null}\n <DataTableViewOptions table={table} />\n {onReload ? (\n <Button\n aria-label=\"Reload\"\n className=\"fk:h-8\"\n disabled={isDeleting || isReloading}\n onClick={onReload}\n size=\"icon-sm\"\n variant=\"outline\"\n >\n <RefreshCw className={isReloading ? 'fk:animate-spin' : undefined} />\n </Button>\n ) : null}\n <DataTableSortedBy table={table} />\n </div>\n {selectedIds.length > 0 ? (\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:h-8 fk:mr-2 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleBatchDelete}\n size=\"sm\"\n variant=\"destructive\"\n >\n {isDeleting ? (\n <Loader2 className=\"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin\" />\n ) : (\n <Trash2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n )}\n Delete ({selectedIds.length})\n </Button>\n </PermissionTooltip>\n ) : null}\n {entityName && isKnowledgeLinkableEntity(entityName) ? (\n <Suspense fallback={null}>\n <EntityKnowledgeButton entityName={entityName} />\n </Suspense>\n ) : null}\n {entityName ? (\n <Suspense fallback={null}>\n <EntityGraphButton entityName={entityName} selectedIds={selectedIds} />\n </Suspense>\n ) : null}\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:h-8 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleCreate}\n size=\"sm\"\n variant=\"default\"\n >\n Create\n </Button>\n </PermissionTooltip>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/data-grid/data-table-row-actions.tsx","../src/data-grid/data-table-view-options.tsx","../src/data-grid/data-table-toolbar.tsx"],"names":["DataTableRowActions","entityName","entityNamePlural","row","options","actionDispatch","useDispatch","canMutate","useCanMutate","entityId","canDelete","canEdit","handleEdit","handleDelete","jsxs","Button","jsx","PencilIcon","Trash2Icon","DropdownMenu","DropdownMenuTrigger","Ellipsis","DropdownMenuContent","DropdownMenuItem","DropdownMenuSeparator","DataTableViewOptions","table","Settings2","DropdownMenuLabel","column","DropdownMenuCheckboxItem","value","EntityKnowledgeButton","lazy","m","EntityGraphButton","DataTableToolbar","isReloading","onReload","appDispatch","useAppDispatch","appContext","useAppContext","apolloClient","useApolloClient","currentProject","currentProjectId","useConfig","schema","scopes","runMutation","setMutation","setOptions","useEntityMutation","isDeleting","setIsDeleting","useState","selectedIds","handleCreate","handleScopeChange","deleteSelected","ids","mutation","getEntityDeleteMutation","resolve","reject","gql","getEntityDeleteWhere","cache","id","error","handleBatchDelete","itemLabel","idsToDelete","scheduleEntityListRemoval","getEntityListQueryName","toast","Select","SelectTrigger","SelectValue","find","propEq","SelectContent","scopeItem","SelectItem","RefreshCw","DataTableSortedBy","PermissionTooltip","Loader2","Trash2","isKnowledgeLinkableEntity","Suspense"],"mappings":"q0BA0BO,SAASA,EAAAA,CAA2B,CACzC,UAAA,CAAAC,GAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,GAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CAAU,CAAE,SAAA,CAAW,IAAA,CAAM,OAAA,CAAS,IAAK,CAC7C,CAAA,CAAiD,CAC/C,IAAMC,CAAAA,CAAiBC,CAAAA,EAAY,CAC7BC,CAAAA,CAAYC,CAAAA,EAAa,CAEzBC,CAAAA,CAAWN,CAAAA,CAAI,QAAA,CAAS,GAAA,CAGxBO,CAAAA,CAAAA,CAAaN,CAAAA,CAAQ,SAAA,EAAa,IAAA,GAASG,CAAAA,CAC3CI,CAAAA,CAAUP,CAAAA,CAAQ,OAAA,EAAW,IAAA,CAEnC,SAASQ,GAAAA,EAAmB,CAC1BP,CAAAA,CAAe,CAAE,IAAA,CAAM,YAAA,CAAc,OAAA,CAAS,CAAE,SAAAI,CAAAA,CAAU,gBAAA,CAAAP,CAAiB,CAAE,CAAC,EAChF,CAEA,SAASW,CAAAA,EAAqB,CAC5BR,CAAAA,CAAe,CAAE,IAAA,CAAM,cAAA,CAAgB,OAAA,CAAS,CAAE,QAAA,CAAAI,CAAAA,CAAU,UAAA,CAAAR,GAAW,CAAE,CAAC,EAC5E,CAEA,OACEa,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,SAAA,CACZ,QAAA,CAAA,CAAAH,CAAAA,EACCG,IAAAA,CAACC,IAAA,CAAO,SAAA,CAAU,sCAAA,CAAuC,OAAA,CAASH,GAAAA,CAAY,OAAA,CAAQ,OAAA,CACpF,QAAA,CAAA,CAAAI,GAAAA,CAACC,UAAAA,CA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,IAAA,CACL,OAAA,CAAQ,cAEP,QAAA,CAAA,CAAAjB,GAAAA,CACCtC,IAACwE,OAAAA,CAAA,CAAQ,UAAU,uCAAA,CAAwC,CAAA,CAE3DxE,IAACyE,MAAAA,CAAA,CAAO,UAAU,uBAAA,CAAwB,CAAA,CAC1C,WACOhC,CAAAA,CAAY,MAAA,CAAO,KAC9B,CAAA,CACF,CAAA,CACE,KACHxD,CAAAA,EAAcyF,CAAAA,CAA0BzF,CAAU,CAAA,CACjDe,GAAAA,CAAC2E,SAAA,CAAS,QAAA,CAAU,IAAA,CAClB,QAAA,CAAA3E,GAAAA,CAACgB,EAAAA,CAAA,CAAsB,UAAA,CAAY/B,CAAAA,CAAY,EACjD,CAAA,CACE,IAAA,CACHA,EACCe,GAAAA,CAAC2E,QAAAA,CAAA,CAAS,QAAA,CAAU,IAAA,CAClB,SAAA3E,GAAAA,CAACmB,EAAAA,CAAA,CAAkB,UAAA,CAAYlC,CAAAA,CAAY,YAAawD,CAAAA,CAAa,CAAA,CACvE,CAAA,CACE,IAAA,CACJzC,GAAAA,CAACuE,EAAAA,CAAA,CAAkB,QAAA,CAAU,CAAChF,EAC5B,QAAA,CAAAS,GAAAA,CAACD,IAAA,CACC,SAAA,CAAU,oBACV,QAAA,CAAUuC,GAAAA,EAAc,CAAC/C,CAAAA,CACzB,OAAA,CAASmD,GACT,IAAA,CAAK,IAAA,CACL,QAAQ,SAAA,CACT,QAAA,CAAA,QAAA,CAED,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"chunk-CAMLITJT.js","sourcesContent":["'use client';\n\nimport type { JSX } from 'react';\nimport { Ellipsis, PencilIcon, Trash2Icon } from 'lucide-react';\nimport type { Row } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\nimport { useDispatch } from '../entities/actions-context';\nimport { useCanMutate } from '../core/permissions';\n\ninterface DataTableRowActionsProps<TData> {\n entityName: string;\n entityNamePlural: string;\n row: Row<TData>;\n options?: {\n canDelete?: boolean;\n canEdit?: boolean;\n };\n}\n\nexport function DataTableRowActions<TData>({\n entityName,\n entityNamePlural,\n row,\n options = { canDelete: true, canEdit: true },\n}: DataTableRowActionsProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const canMutate = useCanMutate();\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const entityId = row.original._id;\n // Read-only roles keep the pencil (the drawer doubles as their read view)\n // but lose the delete affordance entirely.\n const canDelete = (options.canDelete ?? true) && canMutate;\n const canEdit = options.canEdit ?? true;\n\n function handleEdit(): void {\n actionDispatch({ type: 'EditEntity', payload: { entityId, entityNamePlural } });\n }\n\n function handleDelete(): void {\n actionDispatch({ type: 'DeleteEntity', payload: { entityId, entityName } });\n }\n\n return (\n <div className=\"fk:flex\">\n {canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleEdit} variant=\"ghost\">\n <PencilIcon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Edit</span>\n </Button>\n )}\n {canDelete && !canEdit && (\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1\" onClick={handleDelete} variant=\"ghost\">\n <Trash2Icon className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Delete</span>\n </Button>\n )}\n {canEdit && canDelete && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:flex fk:h-7 fk:w-7 fk:p-0\" variant=\"ghost\">\n <Ellipsis className=\"fk:h-4 fk:w-4\" />\n <span className=\"fk:sr-only\">Additional actions</span>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"w-[160px]\">\n <DropdownMenuItem onClick={handleEdit}>\n <PencilIcon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Edit\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={handleDelete}>\n <Trash2Icon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n );\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { Settings2 } from 'lucide-react';\nimport type { Table } from '@tanstack/react-table';\nimport { Button } from '../ui/primitives/button';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../ui/primitives/dropdown-menu';\n\ninterface DataTableViewOptionsProps<TData> {\n table: Table<TData>;\n}\n\nexport function DataTableViewOptions<TData>({ table }: DataTableViewOptionsProps<TData>): JSX.Element {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:hidden fk:h-8 fk:lg:flex\" size=\"sm\" variant=\"outline\">\n <Settings2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n View\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-[150px]\">\n <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== 'undefined' && column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n checked={column.getIsVisible()}\n className=\"capitalize\"\n key={column.id}\n onCheckedChange={(value) => {\n column.toggleVisibility(Boolean(value));\n }}\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","'use client';\n\nimport { lazy, Suspense, useState } from 'react';\nimport type { JSX } from 'react';\nimport { find, propEq } from 'ramda';\nimport type { Table } from '@tanstack/react-table';\nimport { Loader2, RefreshCw, Trash2 } from 'lucide-react';\nimport { gql } from '@apollo/client';\nimport { useApolloClient } from '@apollo/client/react';\nimport { toast } from 'sonner';\nimport { Button } from '../ui/primitives/button';\nimport { PermissionTooltip } from '../ui/components/permission-tooltip';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/primitives/select';\nimport { useDispatch } from '../entities/actions-context';\nimport { useAppContext, useAppDispatch } from '../core/app-context';\nimport { useCanMutate } from '../core/permissions';\nimport { useConfig } from '../core/config/config-context';\nimport { DataTableViewOptions } from './data-table-view-options';\nimport { DataTableSortedBy } from './data-table-sorted-by';\nimport { useEntityMutation } from '../graphql-client/use-entity-mutation';\nimport { getEntityDeleteMutation, getEntityDeleteWhere } from '../graphql-client/queries';\nimport { getEntityListQueryName, scheduleEntityListRemoval } from '../graphql-client/refetch-entity-lists';\nimport { isKnowledgeLinkableEntity } from '../apps/knowledge/knowledge';\n\n// Loaded on demand: the Knowledge module should only download when a list of\n// a linkable entity is in view, the way the record drawer loads its panel.\nconst EntityKnowledgeButton = lazy(() =>\n import('../apps/knowledge/record-links').then((m) => ({ default: m.EntityKnowledgeButton }))\n);\nconst EntityGraphButton = lazy(() => import('../apps/graph/entry').then((m) => ({ default: m.EntityGraphButton })));\n\ninterface DataTableToolbarProps<TData> {\n entityName: string;\n isReloading?: boolean;\n onReload?: () => void;\n table: Table<TData>;\n}\n\nexport function DataTableToolbar<TData>({\n entityName,\n isReloading = false,\n onReload,\n table,\n}: DataTableToolbarProps<TData>): JSX.Element {\n const actionDispatch = useDispatch();\n const appDispatch = useAppDispatch();\n const appContext = useAppContext();\n const apolloClient = useApolloClient();\n const { currentProject, currentProjectId } = useConfig();\n const schema = currentProject?.schema ?? [];\n const scopes = currentProject?.scopes;\n const [runMutation, setMutation, setOptions] = useEntityMutation();\n const [isDeleting, setIsDeleting] = useState(false);\n const canMutate = useCanMutate();\n\n // Collect selected entity ids from the table\n // @ts-expect-error -- the DataGrid's original type doesn't know about the _id property\n const selectedIds: string[] = table.getSelectedRowModel().rows.map((row) => row.original._id as string);\n\n function handleCreate(): void {\n actionDispatch({ type: 'AddEntity', payload: { entityName } });\n }\n\n function handleScopeChange(value: string): void {\n appDispatch({ type: 'setScope', payload: { projectId: currentProjectId, scope: value } });\n }\n\n async function deleteSelected(ids: string[]): Promise<void> {\n if (ids.length === 0) {\n return;\n }\n\n const mutation = getEntityDeleteMutation(entityName, schema, ids);\n\n await new Promise<void>((resolve, reject) => {\n setMutation(gql`\n ${mutation}\n `);\n\n setOptions({\n variables: { where: getEntityDeleteWhere(ids) },\n update(cache: { evict: (arg0: { id: string }) => void }) {\n for (const id of ids) {\n cache.evict({ id });\n }\n },\n onCompleted: () => {\n resolve();\n },\n onError: (error: Error) => {\n reject(error);\n },\n });\n\n runMutation(true);\n });\n }\n\n function handleBatchDelete(): void {\n const itemLabel = entityName === '_asset' ? 'asset' : entityName.toLowerCase();\n\n actionDispatch({\n type: 'AlertDialog',\n payload: {\n options: {\n dialogTitle: `Delete ${selectedIds.length} ${itemLabel}${selectedIds.length > 1 ? 's' : ''}`,\n dialogMessage:\n selectedIds.length > 1\n ? `Are you sure you want to delete the selected ${itemLabel}s? They will be deleted permanently.`\n : `Are you sure you want to delete the selected ${itemLabel}? The item will be deleted permanently.`,\n dialogCancelTitle: 'Cancel',\n dialogActionLabel: 'Delete',\n isDestructive: true,\n dialogActionSubmit: async () => {\n setIsDeleting(true);\n\n try {\n const idsToDelete = [...selectedIds];\n\n await deleteSelected(idsToDelete);\n\n table.resetRowSelection();\n // Drop rows immediately, then soft-refetch counts/pages.\n await scheduleEntityListRemoval(apolloClient, getEntityListQueryName(entityName, schema), idsToDelete);\n toast.success(idsToDelete.length > 1 ? 'Items successfully deleted.' : 'Item successfully deleted.');\n } catch {\n toast.error('Failed to delete selected items.');\n } finally {\n setIsDeleting(false);\n }\n },\n dialogActionCancel: () => {\n // no-op\n },\n },\n },\n });\n }\n\n return (\n <div className=\"fk:flex fk:items-center fk:justify-between\">\n <div className=\"fk:flex fk:flex-1 fk:items-center fk:space-x-2\">\n {scopes && scopes.length > 0 ? (\n <Select\n defaultValue={appContext.scope}\n onValueChange={(value) => {\n handleScopeChange(value);\n }}\n value={appContext.scope}\n >\n <SelectTrigger className=\"fk:w-48!\" id=\"project\" size=\"sm\">\n <span className=\"fk:text-muted-foreground\">Scope:</span>\n <SelectValue>\n {\n ((find(propEq(appContext.scope ?? '', 'name'))(scopes) as { name: string; label: string }) || null)\n ?.label\n }\n </SelectValue>\n </SelectTrigger>\n <SelectContent>\n {scopes.map((scopeItem) => (\n <SelectItem key={scopeItem.name} value={scopeItem.name}>\n {scopeItem.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : null}\n <DataTableViewOptions table={table} />\n {onReload ? (\n <Button\n aria-label=\"Reload\"\n className=\"fk:h-8\"\n disabled={isDeleting || isReloading}\n onClick={onReload}\n size=\"icon-sm\"\n variant=\"outline\"\n >\n <RefreshCw className={isReloading ? 'fk:animate-spin' : undefined} />\n </Button>\n ) : null}\n <DataTableSortedBy table={table} />\n </div>\n {selectedIds.length > 0 ? (\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:h-8 fk:mr-2 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleBatchDelete}\n size=\"sm\"\n variant=\"destructive\"\n >\n {isDeleting ? (\n <Loader2 className=\"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin\" />\n ) : (\n <Trash2 className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n )}\n Delete ({selectedIds.length})\n </Button>\n </PermissionTooltip>\n ) : null}\n {entityName && isKnowledgeLinkableEntity(entityName) ? (\n <Suspense fallback={null}>\n <EntityKnowledgeButton entityName={entityName} />\n </Suspense>\n ) : null}\n {entityName ? (\n <Suspense fallback={null}>\n <EntityGraphButton entityName={entityName} selectedIds={selectedIds} />\n </Suspense>\n ) : null}\n <PermissionTooltip disabled={!canMutate}>\n <Button\n className=\"fk:h-8 fk:lg:flex\"\n disabled={isDeleting || !canMutate}\n onClick={handleCreate}\n size=\"sm\"\n variant=\"default\"\n >\n Create\n </Button>\n </PermissionTooltip>\n </div>\n );\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {a,c,d,f as f$1,g as g$1,e as e$1,i,h as h$2}from'./chunk-2NXQF2F7.js';import {b as b$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {a,c,d,f as f$1,g as g$1,e as e$1,i,h as h$2}from'./chunk-2NXQF2F7.js';import {b as b$1}from'./chunk-V7C4EHK3.js';import {h}from'./chunk-7KLXWCDS.js';import {f}from'./chunk-EYIV4KVY.js';import {qa}from'./chunk-DGIY4SKN.js';import {e,g,h as h$1,j as j$1,o,n}from'./chunk-SZEGGBOC.js';import {b}from'./chunk-32ZU4MLE.js';import {b as b$2}from'./chunk-6NRQMG26.js';import {put}from'@vercel/blob/client';import {useMemo,useRef,useEffect,useState}from'react';import {LoaderCircle,EllipsisVerticalIcon,DownloadIcon,ExternalLinkIcon,Trash2Icon}from'lucide-react';import {mutate}from'swr';import {Document}from'@untitledui/file-icons/dist/solid/document.mjs';import {Docx}from'@untitledui/file-icons/dist/solid/docx.mjs';import {Html}from'@untitledui/file-icons/dist/solid/html.mjs';import {Pdf}from'@untitledui/file-icons/dist/solid/pdf.mjs';import {Pptx}from'@untitledui/file-icons/dist/solid/pptx.mjs';import {Txt}from'@untitledui/file-icons/dist/solid/txt.mjs';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var u=class extends Error{code;status;constructor(n,t,r=null){super(t),this.name="KnowledgeApiError",this.code=r,this.status=n;}},k=class extends Error{status;constructor(n,t="Request failed"){super(t),this.name="FetcherError",this.status=n;}},fe=async e=>{let n=await fetch(e,{credentials:"include"});if(!n.ok)throw new k(n.status);return await n.json()};function j(e){let n=`/api/flexkit/${e}/knowledge`;return {entitySources:t=>`${n}/entities/${encodeURIComponent(t)}/sources`,file:t=>`${n}/sources/${encodeURIComponent(t)}/file`,job:t=>`${n}/jobs/${encodeURIComponent(t)}`,links:t=>`${n}/sources/${encodeURIComponent(t)}/links`,passages:(t,{from:r,to:o})=>`${n}/sources/${encodeURIComponent(t)}/passages?from=${String(r)}&to=${String(o)}`,recordSources:({entity:t,recordId:r})=>`${n}/records/${encodeURIComponent(t)}/${encodeURIComponent(r)}/sources`,source:t=>`${n}/sources/${encodeURIComponent(t)}`,sources:(t={})=>{let{limit:r=25,offset:o=0,search:i,status:a}=t,l=new URLSearchParams({limit:r.toString(),offset:o.toString()}),c=i?.trim();return c&&l.set("q",c),a&&l.set("status",a),`${n}/sources?${l.toString()}`},spaces:`/api/flexkit/${e}/spaces`}}function N(e){return typeof e=="string"&&e.includes("/knowledge/sources?")}function J(e){return typeof e=="string"&&(e.includes("/knowledge/records/")||e.includes("/knowledge/entities/")||e.includes("/knowledge/sources/")&&e.endsWith("/links"))}async function L(e,n){let t={};try{t=await e.json();}catch{}return new u(e.status,t.error?String(t.error):n,t.code??null)}function O(e){let n=`/api/flexkit/${e}/knowledge`;async function t(o,i){let{fallback:a,...l}=i,c=await fetch(o,{credentials:"include",headers:{"Content-Type":"application/json",...l.headers??{}},...l});if(!c.ok)throw await L(c,a);return await c.json()}function r(o){return t(`${n}/sources`,{body:JSON.stringify(o),fallback:"The document could not be added.",method:"POST"})}return {addFile:async(o,i)=>{let a=await fetch(`${n}/uploads`,{body:JSON.stringify({filename:o.name,mediaType:o.type||null,sizeBytes:o.size}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST",signal:i?.signal});if(!a.ok)throw await L(a,"The file could not be uploaded.");let l=await a.json();if(!l.pathname||!l.token||!l.mediaType)throw new u(a.status,"The file could not be uploaded.");return await put(l.pathname,o,{abortSignal:i?.signal,access:"public",contentType:l.mediaType,token:l.token}),r({kind:"upload",pathname:l.pathname})},addUrl:({title:o,url:i})=>r({kind:"url",url:i,...o?{title:o}:{}}),addChatAttachment:({filename:o,url:i})=>r({filename:o,kind:"chat-attachment",url:i}),deleteSource:o=>t(`${n}/sources/${encodeURIComponent(o)}`,{fallback:"The document could not be removed.",method:"DELETE"}),linkSource:(o,i)=>t(`${n}/sources/${encodeURIComponent(o)}/links`,{body:JSON.stringify(i),fallback:"The document could not be attached.",method:"POST"}),reingestSource:o=>t(`${n}/sources/${encodeURIComponent(o)}/reingest`,{fallback:"The document could not be re-indexed.",method:"POST"}),unlinkSource:(o,{entity:i,recordId:a})=>t(`${n}/sources/${encodeURIComponent(o)}/links/${encodeURIComponent(i)}${a===void 0?"":`/${encodeURIComponent(a)}`}`,{fallback:"The document could not be detached.",method:"DELETE"}),updateSource:(o,i)=>t(`${n}/sources/${encodeURIComponent(o)}`,{body:JSON.stringify(i),fallback:"The document could not be updated.",method:"PATCH"})}}var ae={busy:"fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400",error:"fk:bg-destructive/15 fk:text-destructive",muted:"fk:bg-muted fk:text-muted-foreground",ready:"fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400"};function le(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?O(e):null,[e]),projectId:e}}function de(){return mutate(N,void 0,{revalidate:true})}function Pe(){return mutate(J,void 0,{revalidate:true})}function ce(e,n){return e instanceof u||e instanceof Error?e.message:n}function Ee(e,n){if(e.duplicate){qa.info(`"${e.source.title}" is already in Knowledge.`);return}qa.success(`Added ${n}. Indexing starts now.`);}function _e({children:e}){return jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:e})}function Me({label:e,tone:n}){return jsxs(b,{className:`fk:border-none fk:corner-squircle ${ae[n]}`,variant:"outline",children:[n==="busy"?jsx(LoaderCircle,{className:"fk:size-3 fk:animate-spin"}):null,e]})}var ue={document:Document,docx:Docx,html:Html,pdf:Pdf,pptx:Pptx,txt:Txt};function ge({className:e="",size:n=24,source:t}){let r=h(t),o=ue[r.icon];return jsx("span",{"aria-label":r.label,className:`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${e}`,"data-knowledge-type":r.icon,role:"img",children:jsx(o,{size:n})})}function Ue({source:e}){return jsx(ge,{size:40,source:e})}function Le({onVisible:e}){let n=useRef(null),t=useRef(e);return t.current=e,useEffect(()=>{let r=n.current;if(!r)return;let o=new IntersectionObserver(i=>{i.some(a=>a.isIntersecting)&&t.current();});return o.observe(r),()=>{o.disconnect();}},[]),jsx("div",{"aria-hidden":true,className:"fk:h-px",ref:n})}function je({isBusy:e$2=false,onOpen:n$1,onRemoved:t,source:r,trigger:o$1="row"}){let{api:i$1,projectId:a$1}=le(),l=b$1(),[c$1,p]=useState(false),[f,b]=useState(false);if(!i$1||!a$1)return null;let X=i$1;async function H(){b(true);try{await X.deleteSource(r.id),qa.success(`Removed "${r.title}".`),p(!1),t(),de();}catch(w){qa.error(ce(w,"The document could not be removed."));}finally{b(false);}}return jsxs(Fragment,{children:[jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b$2,{"aria-label":`Actions for ${r.title}`,className:o$1==="row"?"fk:size-8 fk:shrink-0 fk:text-muted-foreground":void 0,"data-knowledge-menu":true,size:"icon-sm",variant:o$1==="row"?"ghost":"outline",children:jsx(EllipsisVerticalIcon,{className:"fk:size-4"})})}),jsxs(h$1,{align:"end",children:[n$1?jsx(j$1,{onSelect:n$1,children:"Open"}):null,r.path?jsx(j$1,{asChild:true,children:jsxs("a",{href:j(a$1).file(r.id),children:[jsx(DownloadIcon,{}),"Download"]})}):null,r.originUrl?jsx(j$1,{asChild:true,children:jsxs("a",{href:r.originUrl,rel:"noreferrer",target:"_blank",children:[jsx(ExternalLinkIcon,{}),"Open page"]})}):null,n$1||r.path||r.originUrl?jsx(o,{}):null,jsxs(j$1,{disabled:!l||e$2,variant:"destructive",onSelect:()=>p(true),children:[jsx(Trash2Icon,{}),"Remove"]}),l?null:jsx(n,{className:"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground",children:"Your member role cannot remove documents."})]})]}),jsx(a,{open:c$1,onOpenChange:p,children:jsxs(c,{children:[jsxs(d,{children:[jsx(f$1,{children:"Remove this document?"}),jsxs(g$1,{children:['"',r.title,'" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep their citations, but the document can no longer be opened.']})]}),jsxs(e$1,{children:[jsx(i,{disabled:f,children:"Cancel"}),jsxs(h$2,{disabled:f,onClick:w=>{w.preventDefault(),H();},children:[f?jsx(LoaderCircle,{className:"fk:animate-spin"}):null,"Remove document"]})]})]})})]})}export{k as a,fe as b,j as c,O as d,le as e,de as f,Pe as g,ce as h,Ee as i,_e as j,Me as k,ge as l,Ue as m,Le as n,je as o};//# sourceMappingURL=chunk-CJHMUEOB.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-CJHMUEOB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/apps/knowledge/api.ts","../src/apps/knowledge/shared.tsx"],"names":["KnowledgeApiError","status","message","code","FetcherError","fetcher","url","response","knowledgePaths","projectId","basePath","entity","sourceId","jobId","from","to","recordId","options","limit","offset","search","params","trimmedSearch","isKnowledgeListKey","key","isKnowledgeLinkKey","readError","fallback","data","createKnowledgeApi","request","init","requestInit","register","body","file","tokenResponse","tokenData","put","title","filename","target","patch","STATUS_TONE_CLASSES","useProjectKnowledge","currentProjectId","useConfig","useMemo","invalidateKnowledgeLists","mutateGlobal","invalidateKnowledgeLinks","describeApiError","error","announceRegistered","result","name","toast","PageMessage","children","jsx","StatusBadge","label","tone","jsxs","Badge","LoaderCircle","FILE_ICONS","Document","Docx","Html","Pdf","Pptx","Txt","KnowledgeTypeIcon","className","size","source","format","getKnowledgeFormat","Icon","SourceIcon","InfiniteScrollSentinel","onVisible","sentinelRef","useRef","onVisibleRef","useEffect","node","observer","entries","entry","SourceActionsMenu","isBusy","onOpen","onRemoved","trigger","api","canMutate","useCanMutate","isConfirmingRemoval","setIsConfirmingRemoval","useState","isRemoving","setIsRemoving","knowledgeApi","remove","removeError","Fragment","DropdownMenu","DropdownMenuTrigger","Button","EllipsisVerticalIcon","DropdownMenuContent","DropdownMenuItem","DownloadIcon","ExternalLinkIcon","DropdownMenuSeparator","Trash2Icon","DropdownMenuLabel","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","event"],"mappings":"0gCAYO,IAAMA,CAAAA,CAAN,cAAgC,KAAM,CAC3C,IAAA,CACA,MAAA,CAEA,YAAYC,CAAAA,CAAgBC,CAAAA,CAAiBC,EAAsB,IAAA,CAAM,CACvE,MAAMD,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,oBACZ,IAAA,CAAK,IAAA,CAAOC,CAAAA,CACZ,IAAA,CAAK,OAASF,EAChB,CACF,CAAA,CAsBaG,CAAAA,CAAN,cAA2B,KAAM,CACtC,OAEA,WAAA,CAAYH,CAAAA,CAAgBC,EAAU,gBAAA,CAAkB,CACtD,KAAA,CAAMA,CAAO,EACb,IAAA,CAAK,IAAA,CAAO,cAAA,CACZ,IAAA,CAAK,OAASD,EAChB,CACF,CAAA,CAEaI,EAAAA,CAAU,MAAUC,CAAAA,EAA4B,CAC3D,IAAMC,CAAAA,CAAW,MAAM,MAAMD,CAAAA,CAAK,CAAE,WAAA,CAAa,SAAU,CAAC,CAAA,CAE5D,GAAI,CAACC,CAAAA,CAAS,EAAA,CACZ,MAAM,IAAIH,CAAAA,CAAaG,CAAAA,CAAS,MAAM,EAGxC,OAAQ,MAAMA,EAAS,IAAA,EACzB,EAEO,SAASC,CAAAA,CAAeC,CAAAA,CAc7B,CACA,IAAMC,CAAAA,CAAW,CAAA,aAAA,EAAgBD,CAAS,CAAA,UAAA,CAAA,CAE1C,OAAO,CACL,aAAA,CAAgBE,CAAAA,EAAW,CAAA,EAAGD,CAAQ,CAAA,UAAA,EAAa,kBAAA,CAAmBC,CAAM,CAAC,CAAA,QAAA,CAAA,CAC7E,KAAOC,CAAAA,EAAa,CAAA,EAAGF,CAAQ,CAAA,SAAA,EAAY,mBA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AAA,CAAY,IAAA,CACXtC,GAAAA,CAAC2D,EAAA,CAAkB,SAAA,CAAU,qFAAA,CAAsF,QAAA,CAAA,2CAAA,CAEnH,GAEJ,CAAA,CAAA,CACF,CAAA,CACA3D,IAAC4D,CAAAA,CAAA,CAAY,KAAMpB,GAAAA,CAAqB,YAAA,CAAcC,CAAAA,CACpD,QAAA,CAAArC,KAACyD,CAAAA,CAAA,CACC,UAAAzD,IAAAA,CAAC0D,CAAAA,CAAA,CACC,QAAA,CAAA,CAAA9D,GAAAA,CAAC+D,GAAAA,CAAA,CAAiB,iCAAqB,CAAA,CACvC3D,IAAAA,CAAC4D,IAAA,CAAuB,QAAA,CAAA,CAAA,GAAA,CACpB/C,EAAO,KAAA,CAAM,qJAAA,CAAA,CAEjB,CAAA,CAAA,CACF,CAAA,CACAb,KAAC6D,GAAAA,CAAA,CACC,QAAA,CAAA,CAAAjE,GAAAA,CAACkE,EAAA,CAAkB,QAAA,CAAUvB,CAAAA,CAAY,QAAA,CAAA,QAAA,CAAM,EAC/CvC,IAAAA,CAAC+D,GAAAA,CAAA,CACC,QAAA,CAAUxB,CAAAA,CACV,QAAUyB,CAAAA,EAAsB,CAC9BA,CAAAA,CAAM,cAAA,GACDtB,CAAAA,GACP,EAEC,QAAA,CAAA,CAAAH,CAAAA,CAAa3C,IAACM,YAAAA,CAAA,CAAa,SAAA,CAAU,iBAAA,CAAkB,EAAK,IAAA,CAAK,iBAAA,CAAA,CAEpE,GACF,CAAA,CAAA,CACF,CAAA,CACF,GACF,CAEJ","file":"chunk-K2KW6UYG.js","sourcesContent":["import { put } from '@vercel/blob/client';\nimport type {\n KnowledgeJob,\n KnowledgeLinkTarget,\n KnowledgeRecordRef,\n KnowledgeSource,\n KnowledgeSourcePatch,\n KnowledgeSourceStatus,\n RegisterKnowledgeSourceResult,\n} from './knowledge';\n\n/** The platform refused a knowledge request; `code` lets the UI tailor the message. */\nexport class KnowledgeApiError extends Error {\n code: string | null;\n status: number;\n\n constructor(status: number, message: string, code: string | null = null) {\n super(message);\n this.name = 'KnowledgeApiError';\n this.code = code;\n this.status = status;\n }\n}\n\nexport interface ProjectSpace {\n code: string;\n id: string;\n label: string;\n}\n\nexport interface KnowledgeApi {\n /** Uploads a document to the file store, then registers it; resolves once indexing is queued or the file was already there. */\n addFile: (_file: File, _options?: { signal?: AbortSignal }) => Promise<RegisterKnowledgeSourceResult>;\n addUrl: (_input: { title?: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n /** Promotes a file the caller attached to a chat: the platform copies it into the knowledge folder. */\n addChatAttachment: (_input: { filename: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n deleteSource: (_sourceId: string) => Promise<{ deleted: true }>;\n /** Attaches the document to a record, or to every record of an entity type; `linked` is false when it already was. */\n linkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ linked: boolean }>;\n reingestSource: (_sourceId: string) => Promise<{ job: KnowledgeJob }>;\n unlinkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ unlinked: boolean }>;\n updateSource: (_sourceId: string, _patch: KnowledgeSourcePatch) => Promise<{ source: KnowledgeSource }>;\n}\n\nexport class FetcherError extends Error {\n status: number;\n\n constructor(status: number, message = 'Request failed') {\n super(message);\n this.name = 'FetcherError';\n this.status = status;\n }\n}\n\nexport const fetcher = async <T>(url: string): Promise<T> => {\n const response = await fetch(url, { credentials: 'include' });\n\n if (!response.ok) {\n throw new FetcherError(response.status);\n }\n\n return (await response.json()) as T;\n};\n\nexport function knowledgePaths(projectId: string): {\n /** The documents attached to every record of an entity type. */\n entitySources: (_entity: string) => string;\n /** The original file of an uploaded document, served under its name. */\n file: (_sourceId: string) => string;\n job: (_jobId: string) => string;\n /** The records a document is attached to, and the entity types it applies to. */\n links: (_sourceId: string) => string;\n passages: (_sourceId: string, _options: { from: number; to: number }) => string;\n /** The documents attached to a record. */\n recordSources: (_record: KnowledgeRecordRef) => string;\n source: (_sourceId: string) => string;\n sources: (_options?: { limit?: number; offset?: number; search?: string; status?: KnowledgeSourceStatus }) => string;\n spaces: string;\n} {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n return {\n entitySources: (entity) => `${basePath}/entities/${encodeURIComponent(entity)}/sources`,\n file: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/file`,\n job: (jobId) => `${basePath}/jobs/${encodeURIComponent(jobId)}`,\n links: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/links`,\n passages: (sourceId, { from, to }) =>\n `${basePath}/sources/${encodeURIComponent(sourceId)}/passages?from=${String(from)}&to=${String(to)}`,\n recordSources: ({ entity, recordId }) =>\n `${basePath}/records/${encodeURIComponent(entity)}/${encodeURIComponent(recordId)}/sources`,\n source: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}`,\n sources: (options = {}) => {\n const { limit = 25, offset = 0, search, status } = options;\n const params = new URLSearchParams({ limit: limit.toString(), offset: offset.toString() });\n const trimmedSearch = search?.trim();\n\n if (trimmedSearch) {\n params.set('q', trimmedSearch);\n }\n\n if (status) {\n params.set('status', status);\n }\n\n return `${basePath}/sources?${params.toString()}`;\n },\n spaces: `/api/flexkit/${projectId}/spaces`,\n };\n}\n\n/** Whether an SWR key is a page of the document list, whatever its filters. */\nexport function isKnowledgeListKey(key: unknown): boolean {\n return typeof key === 'string' && key.includes('/knowledge/sources?');\n}\n\n/** Whether an SWR key lists the documents of a record or an entity type, or the links of a document. */\nexport function isKnowledgeLinkKey(key: unknown): boolean {\n return (\n typeof key === 'string' &&\n (key.includes('/knowledge/records/') ||\n key.includes('/knowledge/entities/') ||\n (key.includes('/knowledge/sources/') && key.endsWith('/links')))\n );\n}\n\nasync function readError(response: Response, fallback: string): Promise<KnowledgeApiError> {\n let data: { code?: string; error?: string } = {};\n\n try {\n data = (await response.json()) as { code?: string; error?: string };\n } catch {\n // Non-JSON error bodies keep the fallback message.\n }\n\n return new KnowledgeApiError(response.status, data.error ? String(data.error) : fallback, data.code ?? null);\n}\n\nexport function createKnowledgeApi(projectId: string): KnowledgeApi {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n async function request<T>(url: string, init: RequestInit & { fallback: string }): Promise<T> {\n const { fallback, ...requestInit } = init;\n const response = await fetch(url, {\n credentials: 'include',\n headers: { 'Content-Type': 'application/json', ...(requestInit.headers ?? {}) },\n ...requestInit,\n });\n\n if (!response.ok) {\n throw await readError(response, fallback);\n }\n\n return (await response.json()) as T;\n }\n\n function register(body: Record<string, unknown>): Promise<RegisterKnowledgeSourceResult> {\n return request<RegisterKnowledgeSourceResult>(`${basePath}/sources`, {\n body: JSON.stringify(body),\n fallback: 'The document could not be added.',\n method: 'POST',\n });\n }\n\n return {\n addFile: async (file, options) => {\n // The platform issues a token pinned to one pathname, type and size; the\n // browser writes the bytes to the store itself, so a 20 MB document never\n // crosses the API function body limit. Registration then hashes the blob.\n const tokenResponse = await fetch(`${basePath}/uploads`, {\n body: JSON.stringify({ filename: file.name, mediaType: file.type || null, sizeBytes: file.size }),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n signal: options?.signal,\n });\n\n if (!tokenResponse.ok) {\n throw await readError(tokenResponse, 'The file could not be uploaded.');\n }\n\n const tokenData = (await tokenResponse.json()) as { mediaType?: string; pathname?: string; token?: string };\n\n if (!tokenData.pathname || !tokenData.token || !tokenData.mediaType) {\n throw new KnowledgeApiError(tokenResponse.status, 'The file could not be uploaded.');\n }\n\n await put(tokenData.pathname, file, {\n abortSignal: options?.signal,\n access: 'public',\n contentType: tokenData.mediaType,\n token: tokenData.token,\n });\n\n return register({ kind: 'upload', pathname: tokenData.pathname });\n },\n addUrl: ({ title, url }) => register({ kind: 'url', url, ...(title ? { title } : {}) }),\n addChatAttachment: ({ filename, url }) => register({ filename, kind: 'chat-attachment', url }),\n deleteSource: (sourceId) =>\n request<{ deleted: true }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n fallback: 'The document could not be removed.',\n method: 'DELETE',\n }),\n linkSource: (sourceId, target) =>\n request<{ linked: boolean }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/links`, {\n body: JSON.stringify(target),\n fallback: 'The document could not be attached.',\n method: 'POST',\n }),\n reingestSource: (sourceId) =>\n request<{ job: KnowledgeJob }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/reingest`, {\n fallback: 'The document could not be re-indexed.',\n method: 'POST',\n }),\n unlinkSource: (sourceId, { entity, recordId }) =>\n request<{ unlinked: boolean }>(\n `${basePath}/sources/${encodeURIComponent(sourceId)}/links/${encodeURIComponent(entity)}${\n recordId === undefined ? '' : `/${encodeURIComponent(recordId)}`\n }`,\n { fallback: 'The document could not be detached.', method: 'DELETE' }\n ),\n updateSource: (sourceId, patch) =>\n request<{ source: KnowledgeSource }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n body: JSON.stringify(patch),\n fallback: 'The document could not be updated.',\n method: 'PATCH',\n }),\n };\n}\n","import type { JSX, MouseEvent } from 'react';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { DownloadIcon, EllipsisVerticalIcon, ExternalLinkIcon, LoaderCircle, Trash2Icon } from 'lucide-react';\nimport { mutate as mutateGlobal } from 'swr';\n// File type icons: Untitled UI's free file icons, Solid variant. The set is\n// published as the MIT package `@untitledui/file-icons`; the page below shows\n// every icon and offers each as SVG or JSX should another format need one.\n// https://www.untitledui.com/resources/file-icons\nimport { Document } from '@untitledui/file-icons/dist/solid/document.mjs';\nimport { Docx } from '@untitledui/file-icons/dist/solid/docx.mjs';\nimport { Html } from '@untitledui/file-icons/dist/solid/html.mjs';\nimport { Pdf } from '@untitledui/file-icons/dist/solid/pdf.mjs';\nimport { Pptx } from '@untitledui/file-icons/dist/solid/pptx.mjs';\nimport { Txt } from '@untitledui/file-icons/dist/solid/txt.mjs';\nimport { useConfig } from '../../core/config/config-context';\nimport { useCanMutate } from '../../core/permissions';\nimport {\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n toast,\n} from '../../ui';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '../../ui/primitives/alert-dialog';\nimport {\n createKnowledgeApi,\n isKnowledgeLinkKey,\n isKnowledgeListKey,\n KnowledgeApiError,\n knowledgePaths,\n type KnowledgeApi,\n} from './api';\nimport {\n getKnowledgeFormat,\n type KnowledgeFileIcon,\n type KnowledgeSource,\n type KnowledgeStatusTone,\n type RegisterKnowledgeSourceResult,\n} from './knowledge';\n\nconst STATUS_TONE_CLASSES: { [tone in KnowledgeStatusTone]: string } = {\n busy: 'fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400',\n error: 'fk:bg-destructive/15 fk:text-destructive',\n muted: 'fk:bg-muted fk:text-muted-foreground',\n ready: 'fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400',\n};\n\nexport function useProjectKnowledge(): { api: KnowledgeApi | null; projectId: string | undefined } {\n const { currentProjectId } = useConfig();\n const api = useMemo(() => (currentProjectId ? createKnowledgeApi(currentProjectId) : null), [currentProjectId]);\n\n return { api, projectId: currentProjectId };\n}\n\n/** Drops every cached page of the document list, so the next visit fetches it afresh. */\nexport function invalidateKnowledgeLists(): Promise<unknown> {\n return mutateGlobal(isKnowledgeListKey, undefined, { revalidate: true });\n}\n\n/** Drops every cached link listing (a record's documents, a document's records) after a link changed. */\nexport function invalidateKnowledgeLinks(): Promise<unknown> {\n return mutateGlobal(isKnowledgeLinkKey, undefined, { revalidate: true });\n}\n\nexport function describeApiError(error: unknown, fallback: string): string {\n if (error instanceof KnowledgeApiError) {\n return error.message;\n }\n\n return error instanceof Error ? error.message : fallback;\n}\n\n/** What the user hears once a document was registered. */\nexport function announceRegistered(result: RegisterKnowledgeSourceResult, name: string): void {\n if (result.duplicate) {\n toast.info(`\"${result.source.title}\" is already in Knowledge.`);\n\n return;\n }\n\n toast.success(`Added ${name}. Indexing starts now.`);\n}\n\nexport function PageMessage({ children }: { children: string }): JSX.Element {\n return (\n <div className=\"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle\">\n {children}\n </div>\n );\n}\n\nexport function StatusBadge({ label, tone }: { label: string; tone: KnowledgeStatusTone }): JSX.Element {\n return (\n <Badge className={`fk:border-none fk:corner-squircle ${STATUS_TONE_CLASSES[tone]}`} variant=\"outline\">\n {tone === 'busy' ? <LoaderCircle className=\"fk:size-3 fk:animate-spin\" /> : null}\n {label}\n </Badge>\n );\n}\n\nconst FILE_ICONS: { [icon in KnowledgeFileIcon]: typeof Pdf } = {\n document: Document,\n docx: Docx,\n html: Html,\n pdf: Pdf,\n pptx: Pptx,\n txt: Txt,\n};\n\n/** The document's format as its file icon; the format's name is what a screen reader hears. */\nexport function KnowledgeTypeIcon({\n className = '',\n size = 24,\n source,\n}: {\n className?: string;\n size?: number;\n source: Pick<KnowledgeSource, 'kind' | 'mimeType'>;\n}): JSX.Element {\n const format = getKnowledgeFormat(source);\n const Icon = FILE_ICONS[format.icon];\n\n return (\n <span\n aria-label={format.label}\n className={`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${className}`}\n data-knowledge-type={format.icon}\n role=\"img\"\n >\n <Icon size={size} />\n </span>\n );\n}\n\n/** The larger file icon of the document page and the record panel: the same icon as the list, at 40px. */\nexport function SourceIcon({ source }: { source: Pick<KnowledgeSource, 'kind' | 'mimeType'> }): JSX.Element {\n return <KnowledgeTypeIcon size={40} source={source} />;\n}\n\nexport function InfiniteScrollSentinel({ onVisible }: { onVisible: () => void }): JSX.Element {\n const sentinelRef = useRef<HTMLDivElement>(null);\n const onVisibleRef = useRef(onVisible);\n\n onVisibleRef.current = onVisible;\n\n useEffect(() => {\n const node = sentinelRef.current;\n\n if (!node) {\n return;\n }\n\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n onVisibleRef.current();\n }\n });\n\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return <div aria-hidden className=\"fk:h-px\" ref={sentinelRef} />;\n}\n\n/**\n * The actions of one document, behind a three-dots button: open (lists\n * only), download the original file (web pages open their address instead)\n * and remove, behind one confirmation. The list and the document page share\n * it so the copy, the download link and the busy rules stay the same.\n */\nexport function SourceActionsMenu({\n isBusy = false,\n onOpen,\n onRemoved,\n source,\n trigger = 'row',\n}: {\n /** Another action on the document is in flight; removing waits for it. */\n isBusy?: boolean;\n /** Offered as the first item when given (the document page is already open). */\n onOpen?: () => void;\n /** The document is gone: drop it from the list, or leave its page. The list invalidation is done here. */\n onRemoved: () => void;\n source: KnowledgeSource;\n /** How the button looks: a quiet icon in a row or card, an outlined one next to page actions. */\n trigger?: 'row' | 'page';\n}): JSX.Element | null {\n const { api, projectId } = useProjectKnowledge();\n const canMutate = useCanMutate();\n const [isConfirmingRemoval, setIsConfirmingRemoval] = useState(false);\n const [isRemoving, setIsRemoving] = useState(false);\n\n if (!api || !projectId) {\n return null;\n }\n\n const knowledgeApi = api;\n\n async function remove(): Promise<void> {\n setIsRemoving(true);\n\n try {\n await knowledgeApi.deleteSource(source.id);\n toast.success(`Removed \"${source.title}\".`);\n setIsConfirmingRemoval(false);\n onRemoved();\n void invalidateKnowledgeLists();\n } catch (removeError) {\n toast.error(describeApiError(removeError, 'The document could not be removed.'));\n } finally {\n setIsRemoving(false);\n }\n }\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n aria-label={`Actions for ${source.title}`}\n className={trigger === 'row' ? 'fk:size-8 fk:shrink-0 fk:text-muted-foreground' : undefined}\n data-knowledge-menu\n size=\"icon-sm\"\n variant={trigger === 'row' ? 'ghost' : 'outline'}\n >\n <EllipsisVerticalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {onOpen ? <DropdownMenuItem onSelect={onOpen}>Open</DropdownMenuItem> : null}\n {source.path ? (\n <DropdownMenuItem asChild>\n <a href={knowledgePaths(projectId).file(source.id)}>\n <DownloadIcon />\n Download\n </a>\n </DropdownMenuItem>\n ) : null}\n {source.originUrl ? (\n <DropdownMenuItem asChild>\n <a href={source.originUrl} rel=\"noreferrer\" target=\"_blank\">\n <ExternalLinkIcon />\n Open page\n </a>\n </DropdownMenuItem>\n ) : null}\n {onOpen || source.path || source.originUrl ? <DropdownMenuSeparator /> : null}\n <DropdownMenuItem\n disabled={!canMutate || isBusy}\n variant=\"destructive\"\n onSelect={() => setIsConfirmingRemoval(true)}\n >\n <Trash2Icon />\n Remove\n </DropdownMenuItem>\n {canMutate ? null : (\n <DropdownMenuLabel className=\"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground\">\n Your member role cannot remove documents.\n </DropdownMenuLabel>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n <AlertDialog open={isConfirmingRemoval} onOpenChange={setIsConfirmingRemoval}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove this document?</AlertDialogTitle>\n <AlertDialogDescription>\n \"{source.title}\" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep\n their citations, but the document can no longer be opened.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={isRemoving}>Cancel</AlertDialogCancel>\n <AlertDialogAction\n disabled={isRemoving}\n onClick={(event: MouseEvent) => {\n event.preventDefault();\n void remove();\n }}\n >\n {isRemoving ? <LoaderCircle className=\"fk:animate-spin\" /> : null}\n Remove document\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/apps/knowledge/api.ts","../src/apps/knowledge/shared.tsx"],"names":["KnowledgeApiError","status","message","code","FetcherError","fetcher","url","response","knowledgePaths","projectId","basePath","entity","sourceId","jobId","from","to","recordId","options","limit","offset","search","params","trimmedSearch","isKnowledgeListKey","key","isKnowledgeLinkKey","readError","fallback","data","createKnowledgeApi","request","init","requestInit","register","body","file","tokenResponse","tokenData","put","title","filename","target","patch","STATUS_TONE_CLASSES","useProjectKnowledge","currentProjectId","useConfig","useMemo","invalidateKnowledgeLists","mutateGlobal","invalidateKnowledgeLinks","describeApiError","error","announceRegistered","result","name","toast","PageMessage","children","jsx","StatusBadge","label","tone","jsxs","Badge","LoaderCircle","FILE_ICONS","Document","Docx","Html","Pdf","Pptx","Txt","KnowledgeTypeIcon","className","size","source","format","getKnowledgeFormat","Icon","SourceIcon","InfiniteScrollSentinel","onVisible","sentinelRef","useRef","onVisibleRef","useEffect","node","observer","entries","entry","SourceActionsMenu","isBusy","onOpen","onRemoved","trigger","api","canMutate","useCanMutate","isConfirmingRemoval","setIsConfirmingRemoval","useState","isRemoving","setIsRemoving","knowledgeApi","remove","removeError","Fragment","DropdownMenu","DropdownMenuTrigger","Button","EllipsisVerticalIcon","DropdownMenuContent","DropdownMenuItem","DownloadIcon","ExternalLinkIcon","DropdownMenuSeparator","Trash2Icon","DropdownMenuLabel","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","event"],"mappings":"0gCAYO,IAAMA,CAAAA,CAAN,cAAgC,KAAM,CAC3C,IAAA,CACA,MAAA,CAEA,YAAYC,CAAAA,CAAgBC,CAAAA,CAAiBC,EAAsB,IAAA,CAAM,CACvE,MAAMD,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,oBACZ,IAAA,CAAK,IAAA,CAAOC,CAAAA,CACZ,IAAA,CAAK,OAASF,EAChB,CACF,CAAA,CAsBaG,CAAAA,CAAN,cAA2B,KAAM,CACtC,OAEA,WAAA,CAAYH,CAAAA,CAAgBC,EAAU,gBAAA,CAAkB,CACtD,KAAA,CAAMA,CAAO,EACb,IAAA,CAAK,IAAA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,CAAY,QAAA,CAAA,QAAA,CAAM,EAC/CvC,IAAAA,CAAC+D,GAAAA,CAAA,CACC,QAAA,CAAUxB,CAAAA,CACV,QAAUyB,CAAAA,EAAsB,CAC9BA,CAAAA,CAAM,cAAA,GACDtB,CAAAA,GACP,EAEC,QAAA,CAAA,CAAAH,CAAAA,CAAa3C,IAACM,YAAAA,CAAA,CAAa,SAAA,CAAU,iBAAA,CAAkB,EAAK,IAAA,CAAK,iBAAA,CAAA,CAEpE,GACF,CAAA,CAAA,CACF,CAAA,CACF,GACF,CAEJ","file":"chunk-CJHMUEOB.js","sourcesContent":["import { put } from '@vercel/blob/client';\nimport type {\n KnowledgeJob,\n KnowledgeLinkTarget,\n KnowledgeRecordRef,\n KnowledgeSource,\n KnowledgeSourcePatch,\n KnowledgeSourceStatus,\n RegisterKnowledgeSourceResult,\n} from './knowledge';\n\n/** The platform refused a knowledge request; `code` lets the UI tailor the message. */\nexport class KnowledgeApiError extends Error {\n code: string | null;\n status: number;\n\n constructor(status: number, message: string, code: string | null = null) {\n super(message);\n this.name = 'KnowledgeApiError';\n this.code = code;\n this.status = status;\n }\n}\n\nexport interface ProjectSpace {\n code: string;\n id: string;\n label: string;\n}\n\nexport interface KnowledgeApi {\n /** Uploads a document to the file store, then registers it; resolves once indexing is queued or the file was already there. */\n addFile: (_file: File, _options?: { signal?: AbortSignal }) => Promise<RegisterKnowledgeSourceResult>;\n addUrl: (_input: { title?: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n /** Promotes a file the caller attached to a chat: the platform copies it into the knowledge folder. */\n addChatAttachment: (_input: { filename: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n deleteSource: (_sourceId: string) => Promise<{ deleted: true }>;\n /** Attaches the document to a record, or to every record of an entity type; `linked` is false when it already was. */\n linkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ linked: boolean }>;\n reingestSource: (_sourceId: string) => Promise<{ job: KnowledgeJob }>;\n unlinkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ unlinked: boolean }>;\n updateSource: (_sourceId: string, _patch: KnowledgeSourcePatch) => Promise<{ source: KnowledgeSource }>;\n}\n\nexport class FetcherError extends Error {\n status: number;\n\n constructor(status: number, message = 'Request failed') {\n super(message);\n this.name = 'FetcherError';\n this.status = status;\n }\n}\n\nexport const fetcher = async <T>(url: string): Promise<T> => {\n const response = await fetch(url, { credentials: 'include' });\n\n if (!response.ok) {\n throw new FetcherError(response.status);\n }\n\n return (await response.json()) as T;\n};\n\nexport function knowledgePaths(projectId: string): {\n /** The documents attached to every record of an entity type. */\n entitySources: (_entity: string) => string;\n /** The original file of an uploaded document, served under its name. */\n file: (_sourceId: string) => string;\n job: (_jobId: string) => string;\n /** The records a document is attached to, and the entity types it applies to. */\n links: (_sourceId: string) => string;\n passages: (_sourceId: string, _options: { from: number; to: number }) => string;\n /** The documents attached to a record. */\n recordSources: (_record: KnowledgeRecordRef) => string;\n source: (_sourceId: string) => string;\n sources: (_options?: { limit?: number; offset?: number; search?: string; status?: KnowledgeSourceStatus }) => string;\n spaces: string;\n} {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n return {\n entitySources: (entity) => `${basePath}/entities/${encodeURIComponent(entity)}/sources`,\n file: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/file`,\n job: (jobId) => `${basePath}/jobs/${encodeURIComponent(jobId)}`,\n links: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/links`,\n passages: (sourceId, { from, to }) =>\n `${basePath}/sources/${encodeURIComponent(sourceId)}/passages?from=${String(from)}&to=${String(to)}`,\n recordSources: ({ entity, recordId }) =>\n `${basePath}/records/${encodeURIComponent(entity)}/${encodeURIComponent(recordId)}/sources`,\n source: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}`,\n sources: (options = {}) => {\n const { limit = 25, offset = 0, search, status } = options;\n const params = new URLSearchParams({ limit: limit.toString(), offset: offset.toString() });\n const trimmedSearch = search?.trim();\n\n if (trimmedSearch) {\n params.set('q', trimmedSearch);\n }\n\n if (status) {\n params.set('status', status);\n }\n\n return `${basePath}/sources?${params.toString()}`;\n },\n spaces: `/api/flexkit/${projectId}/spaces`,\n };\n}\n\n/** Whether an SWR key is a page of the document list, whatever its filters. */\nexport function isKnowledgeListKey(key: unknown): boolean {\n return typeof key === 'string' && key.includes('/knowledge/sources?');\n}\n\n/** Whether an SWR key lists the documents of a record or an entity type, or the links of a document. */\nexport function isKnowledgeLinkKey(key: unknown): boolean {\n return (\n typeof key === 'string' &&\n (key.includes('/knowledge/records/') ||\n key.includes('/knowledge/entities/') ||\n (key.includes('/knowledge/sources/') && key.endsWith('/links')))\n );\n}\n\nasync function readError(response: Response, fallback: string): Promise<KnowledgeApiError> {\n let data: { code?: string; error?: string } = {};\n\n try {\n data = (await response.json()) as { code?: string; error?: string };\n } catch {\n // Non-JSON error bodies keep the fallback message.\n }\n\n return new KnowledgeApiError(response.status, data.error ? String(data.error) : fallback, data.code ?? null);\n}\n\nexport function createKnowledgeApi(projectId: string): KnowledgeApi {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n async function request<T>(url: string, init: RequestInit & { fallback: string }): Promise<T> {\n const { fallback, ...requestInit } = init;\n const response = await fetch(url, {\n credentials: 'include',\n headers: { 'Content-Type': 'application/json', ...(requestInit.headers ?? {}) },\n ...requestInit,\n });\n\n if (!response.ok) {\n throw await readError(response, fallback);\n }\n\n return (await response.json()) as T;\n }\n\n function register(body: Record<string, unknown>): Promise<RegisterKnowledgeSourceResult> {\n return request<RegisterKnowledgeSourceResult>(`${basePath}/sources`, {\n body: JSON.stringify(body),\n fallback: 'The document could not be added.',\n method: 'POST',\n });\n }\n\n return {\n addFile: async (file, options) => {\n // The platform issues a token pinned to one pathname, type and size; the\n // browser writes the bytes to the store itself, so a 20 MB document never\n // crosses the API function body limit. Registration then hashes the blob.\n const tokenResponse = await fetch(`${basePath}/uploads`, {\n body: JSON.stringify({ filename: file.name, mediaType: file.type || null, sizeBytes: file.size }),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n signal: options?.signal,\n });\n\n if (!tokenResponse.ok) {\n throw await readError(tokenResponse, 'The file could not be uploaded.');\n }\n\n const tokenData = (await tokenResponse.json()) as { mediaType?: string; pathname?: string; token?: string };\n\n if (!tokenData.pathname || !tokenData.token || !tokenData.mediaType) {\n throw new KnowledgeApiError(tokenResponse.status, 'The file could not be uploaded.');\n }\n\n await put(tokenData.pathname, file, {\n abortSignal: options?.signal,\n access: 'public',\n contentType: tokenData.mediaType,\n token: tokenData.token,\n });\n\n return register({ kind: 'upload', pathname: tokenData.pathname });\n },\n addUrl: ({ title, url }) => register({ kind: 'url', url, ...(title ? { title } : {}) }),\n addChatAttachment: ({ filename, url }) => register({ filename, kind: 'chat-attachment', url }),\n deleteSource: (sourceId) =>\n request<{ deleted: true }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n fallback: 'The document could not be removed.',\n method: 'DELETE',\n }),\n linkSource: (sourceId, target) =>\n request<{ linked: boolean }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/links`, {\n body: JSON.stringify(target),\n fallback: 'The document could not be attached.',\n method: 'POST',\n }),\n reingestSource: (sourceId) =>\n request<{ job: KnowledgeJob }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/reingest`, {\n fallback: 'The document could not be re-indexed.',\n method: 'POST',\n }),\n unlinkSource: (sourceId, { entity, recordId }) =>\n request<{ unlinked: boolean }>(\n `${basePath}/sources/${encodeURIComponent(sourceId)}/links/${encodeURIComponent(entity)}${\n recordId === undefined ? '' : `/${encodeURIComponent(recordId)}`\n }`,\n { fallback: 'The document could not be detached.', method: 'DELETE' }\n ),\n updateSource: (sourceId, patch) =>\n request<{ source: KnowledgeSource }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n body: JSON.stringify(patch),\n fallback: 'The document could not be updated.',\n method: 'PATCH',\n }),\n };\n}\n","import type { JSX, MouseEvent } from 'react';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { DownloadIcon, EllipsisVerticalIcon, ExternalLinkIcon, LoaderCircle, Trash2Icon } from 'lucide-react';\nimport { mutate as mutateGlobal } from 'swr';\n// File type icons: Untitled UI's free file icons, Solid variant. The set is\n// published as the MIT package `@untitledui/file-icons`; the page below shows\n// every icon and offers each as SVG or JSX should another format need one.\n// https://www.untitledui.com/resources/file-icons\nimport { Document } from '@untitledui/file-icons/dist/solid/document.mjs';\nimport { Docx } from '@untitledui/file-icons/dist/solid/docx.mjs';\nimport { Html } from '@untitledui/file-icons/dist/solid/html.mjs';\nimport { Pdf } from '@untitledui/file-icons/dist/solid/pdf.mjs';\nimport { Pptx } from '@untitledui/file-icons/dist/solid/pptx.mjs';\nimport { Txt } from '@untitledui/file-icons/dist/solid/txt.mjs';\nimport { useConfig } from '../../core/config/config-context';\nimport { useCanMutate } from '../../core/permissions';\nimport {\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n toast,\n} from '../../ui';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '../../ui/primitives/alert-dialog';\nimport {\n createKnowledgeApi,\n isKnowledgeLinkKey,\n isKnowledgeListKey,\n KnowledgeApiError,\n knowledgePaths,\n type KnowledgeApi,\n} from './api';\nimport {\n getKnowledgeFormat,\n type KnowledgeFileIcon,\n type KnowledgeSource,\n type KnowledgeStatusTone,\n type RegisterKnowledgeSourceResult,\n} from './knowledge';\n\nconst STATUS_TONE_CLASSES: { [tone in KnowledgeStatusTone]: string } = {\n busy: 'fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400',\n error: 'fk:bg-destructive/15 fk:text-destructive',\n muted: 'fk:bg-muted fk:text-muted-foreground',\n ready: 'fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400',\n};\n\nexport function useProjectKnowledge(): { api: KnowledgeApi | null; projectId: string | undefined } {\n const { currentProjectId } = useConfig();\n const api = useMemo(() => (currentProjectId ? createKnowledgeApi(currentProjectId) : null), [currentProjectId]);\n\n return { api, projectId: currentProjectId };\n}\n\n/** Drops every cached page of the document list, so the next visit fetches it afresh. */\nexport function invalidateKnowledgeLists(): Promise<unknown> {\n return mutateGlobal(isKnowledgeListKey, undefined, { revalidate: true });\n}\n\n/** Drops every cached link listing (a record's documents, a document's records) after a link changed. */\nexport function invalidateKnowledgeLinks(): Promise<unknown> {\n return mutateGlobal(isKnowledgeLinkKey, undefined, { revalidate: true });\n}\n\nexport function describeApiError(error: unknown, fallback: string): string {\n if (error instanceof KnowledgeApiError) {\n return error.message;\n }\n\n return error instanceof Error ? error.message : fallback;\n}\n\n/** What the user hears once a document was registered. */\nexport function announceRegistered(result: RegisterKnowledgeSourceResult, name: string): void {\n if (result.duplicate) {\n toast.info(`\"${result.source.title}\" is already in Knowledge.`);\n\n return;\n }\n\n toast.success(`Added ${name}. Indexing starts now.`);\n}\n\nexport function PageMessage({ children }: { children: string }): JSX.Element {\n return (\n <div className=\"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle\">\n {children}\n </div>\n );\n}\n\nexport function StatusBadge({ label, tone }: { label: string; tone: KnowledgeStatusTone }): JSX.Element {\n return (\n <Badge className={`fk:border-none fk:corner-squircle ${STATUS_TONE_CLASSES[tone]}`} variant=\"outline\">\n {tone === 'busy' ? <LoaderCircle className=\"fk:size-3 fk:animate-spin\" /> : null}\n {label}\n </Badge>\n );\n}\n\nconst FILE_ICONS: { [icon in KnowledgeFileIcon]: typeof Pdf } = {\n document: Document,\n docx: Docx,\n html: Html,\n pdf: Pdf,\n pptx: Pptx,\n txt: Txt,\n};\n\n/** The document's format as its file icon; the format's name is what a screen reader hears. */\nexport function KnowledgeTypeIcon({\n className = '',\n size = 24,\n source,\n}: {\n className?: string;\n size?: number;\n source: Pick<KnowledgeSource, 'kind' | 'mimeType'>;\n}): JSX.Element {\n const format = getKnowledgeFormat(source);\n const Icon = FILE_ICONS[format.icon];\n\n return (\n <span\n aria-label={format.label}\n className={`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${className}`}\n data-knowledge-type={format.icon}\n role=\"img\"\n >\n <Icon size={size} />\n </span>\n );\n}\n\n/** The larger file icon of the document page and the record panel: the same icon as the list, at 40px. */\nexport function SourceIcon({ source }: { source: Pick<KnowledgeSource, 'kind' | 'mimeType'> }): JSX.Element {\n return <KnowledgeTypeIcon size={40} source={source} />;\n}\n\nexport function InfiniteScrollSentinel({ onVisible }: { onVisible: () => void }): JSX.Element {\n const sentinelRef = useRef<HTMLDivElement>(null);\n const onVisibleRef = useRef(onVisible);\n\n onVisibleRef.current = onVisible;\n\n useEffect(() => {\n const node = sentinelRef.current;\n\n if (!node) {\n return;\n }\n\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n onVisibleRef.current();\n }\n });\n\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return <div aria-hidden className=\"fk:h-px\" ref={sentinelRef} />;\n}\n\n/**\n * The actions of one document, behind a three-dots button: open (lists\n * only), download the original file (web pages open their address instead)\n * and remove, behind one confirmation. The list and the document page share\n * it so the copy, the download link and the busy rules stay the same.\n */\nexport function SourceActionsMenu({\n isBusy = false,\n onOpen,\n onRemoved,\n source,\n trigger = 'row',\n}: {\n /** Another action on the document is in flight; removing waits for it. */\n isBusy?: boolean;\n /** Offered as the first item when given (the document page is already open). */\n onOpen?: () => void;\n /** The document is gone: drop it from the list, or leave its page. The list invalidation is done here. */\n onRemoved: () => void;\n source: KnowledgeSource;\n /** How the button looks: a quiet icon in a row or card, an outlined one next to page actions. */\n trigger?: 'row' | 'page';\n}): JSX.Element | null {\n const { api, projectId } = useProjectKnowledge();\n const canMutate = useCanMutate();\n const [isConfirmingRemoval, setIsConfirmingRemoval] = useState(false);\n const [isRemoving, setIsRemoving] = useState(false);\n\n if (!api || !projectId) {\n return null;\n }\n\n const knowledgeApi = api;\n\n async function remove(): Promise<void> {\n setIsRemoving(true);\n\n try {\n await knowledgeApi.deleteSource(source.id);\n toast.success(`Removed \"${source.title}\".`);\n setIsConfirmingRemoval(false);\n onRemoved();\n void invalidateKnowledgeLists();\n } catch (removeError) {\n toast.error(describeApiError(removeError, 'The document could not be removed.'));\n } finally {\n setIsRemoving(false);\n }\n }\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n aria-label={`Actions for ${source.title}`}\n className={trigger === 'row' ? 'fk:size-8 fk:shrink-0 fk:text-muted-foreground' : undefined}\n data-knowledge-menu\n size=\"icon-sm\"\n variant={trigger === 'row' ? 'ghost' : 'outline'}\n >\n <EllipsisVerticalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {onOpen ? <DropdownMenuItem onSelect={onOpen}>Open</DropdownMenuItem> : null}\n {source.path ? (\n <DropdownMenuItem asChild>\n <a href={knowledgePaths(projectId).file(source.id)}>\n <DownloadIcon />\n Download\n </a>\n </DropdownMenuItem>\n ) : null}\n {source.originUrl ? (\n <DropdownMenuItem asChild>\n <a href={source.originUrl} rel=\"noreferrer\" target=\"_blank\">\n <ExternalLinkIcon />\n Open page\n </a>\n </DropdownMenuItem>\n ) : null}\n {onOpen || source.path || source.originUrl ? <DropdownMenuSeparator /> : null}\n <DropdownMenuItem\n disabled={!canMutate || isBusy}\n variant=\"destructive\"\n onSelect={() => setIsConfirmingRemoval(true)}\n >\n <Trash2Icon />\n Remove\n </DropdownMenuItem>\n {canMutate ? null : (\n <DropdownMenuLabel className=\"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground\">\n Your member role cannot remove documents.\n </DropdownMenuLabel>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n <AlertDialog open={isConfirmingRemoval} onOpenChange={setIsConfirmingRemoval}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove this document?</AlertDialogTitle>\n <AlertDialogDescription>\n \"{source.title}\" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep\n their citations, but the document can no longer be opened.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={isRemoving}>Cancel</AlertDialogCancel>\n <AlertDialogAction\n disabled={isRemoving}\n onClick={(event: MouseEvent) => {\n event.preventDefault();\n void remove();\n }}\n >\n {isRemoving ? <LoaderCircle className=\"fk:animate-spin\" /> : null}\n Remove document\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n );\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {e,c,b,a,g,h as h$1,m as m$1,k as k$2,n}from'./chunk-K2KW6UYG.js';import {m as m$2,s as s$2}from'./chunk-UCHWUGRT.js';import {b as b$3}from'./chunk-LIMXKPEK.js';import {j}from'./chunk-BM7INZL3.js';import {c as c$3}from'./chunk-XMOSCJOI.js';import {t,s,u,q as q$1,v,k as k$1,i as i$1,o as o$1,r as r$2,p as p$2}from'./chunk-7KLXWCDS.js';import {a as a$2}from'./chunk-ERDARDGB.js';import {f}from'./chunk-6AI7322C.js';import {na,p,q,r,t as t$2,u as u$1,v as v$1,qa,s as s$1}from'./chunk-DGIY4SKN.js';import {t as t$1}from'./chunk-SZEGGBOC.js';import {b as b$2,c as c$1,h,i,k,l,m,o,p as p$1,q as q$2,r as r$1,t as t$3}from'./chunk-32ZU4MLE.js';import {a as a$1,b as b$4,c as c$2,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {useState,useMemo,useDeferredValue}from'react';import {BookOpenTextIcon,PaperclipIcon,ChevronRightIcon,LayersIcon,XIcon,PlusIcon,Unlink2Icon,LoaderCircle,SearchIcon}from'lucide-react';import {Link}from'react-router-dom';import H from'swr';import Qe from'swr/infinite';import {jsxs,Fragment,jsx}from'react/jsx-runtime';var Be=50;function fe({disabled:n,label:l,onClick:o}){return jsxs(b$4,{children:[jsx(c$2,{asChild:true,children:jsx(b$1,{"aria-label":l,className:"fk:size-7 fk:shrink-0",disabled:n,size:"icon",variant:"ghost",onClick:o,children:jsx(Unlink2Icon,{className:"fk:size-4"})})}),jsx(e$1,{children:l})]})}function Xe({api:n$1,attachedIds:l$1,onAttached:o,onOpenChange:a,open:s,projectId:u,target:r,targetLabel:c$2}){let[p,h$2]=useState(""),m=useDeferredValue(p.trim()),[y,f]=useState(null),b$1=(k,K)=>!s||K&&!K.hasMore?null:c(u).sources({limit:Be,offset:k*Be,search:m||void 0}),{data:v,error:w,isLoading:x,setSize:i$2,size:d}=Qe(b$1,b,{keepPreviousData:true}),g=useMemo(()=>r$2(v?.flatMap(k=>k.sources)??[],l$1),[l$1,v]),L=v?.[v.length-1]?.hasMore??false,C=v!==void 0&&d>v.length;async function A(k){f(k.id);try{let K=await n$1.linkSource(k.id,r);qa.success(K.linked?`Attached "${k.title}".`:`"${k.title}" was already attached.`),o(k),a(!1);}catch(K){qa.error(h$1(K,"The document could not be attached."));}finally{f(null);}}let R;return w?R=jsx("p",{className:"fk:py-6 fk:text-center fk:text-sm fk:text-destructive",children:"The documents could not be loaded."}):x&&!v?R=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-3 fk:py-2",children:[jsx(t$1,{className:"fk:h-10 fk:w-full"}),jsx(t$1,{className:"fk:h-10 fk:w-full"}),jsx(t$1,{className:"fk:h-10 fk:w-full"})]}):g.length===0&&!L?R=jsx("p",{className:"fk:py-6 fk:text-center fk:text-sm fk:text-muted-foreground",children:m?"No documents match your search.":"Every document is attached already, or there are none yet. Add documents in Knowledge first."}):R=jsxs("ul",{className:"fk:flex fk:max-h-80 fk:flex-col fk:overflow-y-auto fk:-mx-2",children:[g.map(k=>{let K=k$1(k),B=y===k.id;return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-2 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:disabled:opacity-60 fk:corner-squircle",disabled:y!==null,type:"button",onClick:()=>{A(k);},children:[jsx(m$1,{source:k}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:k.title}),jsxs("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:[i$1(k)," \xB7 ",K.detail]})]}),B?jsx(LoaderCircle,{className:"fk:size-4 fk:shrink-0 fk:animate-spin fk:text-muted-foreground"}):jsx(k$2,{label:K.label,tone:K.tone})]})},k.id)}),L&&!C?jsx("li",{"aria-hidden":true,children:jsx(n,{onVisible:()=>{i$2(k=>k+1);}})}):null,C?jsx("li",{className:"fk:flex fk:justify-center fk:py-2",children:jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin fk:text-muted-foreground"})}):null]}),jsx(c$1,{open:s,onOpenChange:a,children:jsxs(h,{className:"fk:sm:max-w-lg",children:[jsxs(i,{children:[jsx(k,{children:"Attach a document"}),jsx(l,{children:r.recordId===void 0?`Documents attached to every ${c$2} are searched before the rest of Knowledge when a question is about one of them, or about ${c$2} in general.`:`Documents attached to ${c$2} are searched before the rest of Knowledge when a question is about it.`})]}),jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2.5 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s$1,{"aria-label":"Search documents",autoFocus:true,className:"fk:pl-8",placeholder:"Search documents by title",value:p,onChange:k=>h$2(k.target.value)})]}),R]})})}function re({projectId:n,renderAction:l,sources:o}){return jsx("ul",{className:"fk:flex fk:flex-col fk:gap-1 fk:-mx-2",children:o.map(a=>{let s=k$1(a);return jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2 fk:rounded-lg fk:px-2 fk:py-1.5 fk:corner-squircle",children:[jsxs(Link,{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-3 fk:rounded-md fk:hover:underline fk:underline-offset-2",to:o$1(n,a.id),children:[jsx(m$1,{source:a}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:a.title}),jsxs("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:[i$1(a)," \xB7 ",s.detail]})]})]}),jsx(k$2,{label:s.label,tone:s.tone}),l?.(a)]},a.id)})})}function yt({entityName:n}){let{api:l,projectId:o}=e(),{currentProject:a$1}=f(),[s$1,u$1]=useState(false),r=t(a$1?.schema??[],n),c$1=!!r&&s(n),{data:p,error:h}=H(o&&c$1?c(o).entitySources(n):null,b);if(!l||!o||!r||!c$1||h instanceof a&&h.status===404)return null;let m=p?.sources.length??0;return jsxs(Fragment,{children:[jsxs(b$1,{"aria-label":`Knowledge for every ${u(r)}`,className:"fk:mr-2 fk:h-8","data-knowledge-entity-button":true,size:"sm",variant:"outline",onClick:()=>u$1(true),children:[jsx(BookOpenTextIcon,{}),"Knowledge",m>0?jsx(b$2,{className:"fk:corner-squircle",variant:"secondary",children:m}):null]}),jsx(Ue,{api:l,entityLabel:u(r),entityName:n,open:s$1,projectId:o,onOpenChange:u$1})]})}function Ue({api:n,entityLabel:l$1,entityName:o,onOpenChange:a,open:s,projectId:u}){let r=b$3(),[c$2,p]=useState(false),[h$2,m]=useState(null),{data:y,error:f,isLoading:b$4,mutate:v}=H(c(u).entitySources(o),b),w=y?.sources??[],x=useMemo(()=>({entity:o}),[o]);async function i$1(g$1){m(g$1.id);try{await n.unlinkSource(g$1.id,x),qa.success(`"${g$1.title}" no longer applies to every ${l$1}.`),await v({sources:w.filter(L=>L.id!==g$1.id)},{revalidate:!1}),g();}catch(L){qa.error(h$1(L,"The document could not be detached."));}finally{m(null);}}let d;return f?d=jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The documents could not be loaded."}):b$4&&!y?d=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t$1,{className:"fk:h-9 fk:w-full"}),jsx(t$1,{className:"fk:h-9 fk:w-2/3"})]}):w.length===0?d=jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["No documents apply to every ",l$1," yet. Attach a guide, a policy or a spec that holds for all of them and the agent searches it first when asked about any ",l$1,", or about ",l$1," in general."]}):d=jsx(re,{projectId:u,sources:w,renderAction:g=>r?jsx(fe,{disabled:h$2!==null,label:`Detach ${g.title}`,onClick:()=>{i$1(g);}}):null}),jsx(c$1,{open:s,onOpenChange:a,children:jsxs(h,{className:"fk:sm:max-w-lg","data-knowledge-entity-dialog":true,children:[jsxs(i,{children:[jsxs(k,{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(BookOpenTextIcon,{className:"fk:size-4 fk:text-muted-foreground"}),"Knowledge for every ",l$1,y?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:w.length}):null]}),jsxs(l,{children:["Documents attached here apply to every ",l$1,"; each record can hold its own on top."]})]}),jsx("div",{className:"fk:max-h-80 fk:overflow-y-auto",children:d}),jsx("div",{className:"fk:flex fk:justify-end",children:jsx(na,{disabled:!r,children:jsxs(b$1,{disabled:!r,size:"sm",variant:"outline",onClick:()=>p(true),children:[jsx(PaperclipIcon,{}),"Attach document"]})})}),jsx(Xe,{api:n,attachedIds:w.map(g=>g.id),open:c$2,projectId:u,target:x,targetLabel:l$1,onAttached:g$1=>{v({sources:w.some(L=>L.id===g$1.id)?w:[...w,g$1]},{revalidate:false}),g();},onOpenChange:p})]})})}function bt({entityName:n,recordId:l,recordLabel:o}){let{api:a$2,projectId:s$1}=e(),{currentProject:u$1}=f(),r$1=b$3(),[c$1,p$1]=useState(false),[h,m]=useState(false),[y,f$1]=useState(null),b$4=useMemo(()=>({entity:n,recordId:l}),[n,l]),v=t(u$1?.schema??[],n),w=v?u(v):n,x=s(n),{data:i,error:d,isLoading:g$1,mutate:L}=H(s$1&&x?c(s$1).recordSources(b$4):null,b);if(!a$2||!s$1||!x||d instanceof a&&d.status===404)return null;let C=i?.sources??[],A=i?.inherited??[],R=C.map(N=>N.id),k=a$2;async function K(N){f$1(N.id);try{await k.unlinkSource(N.id,b$4),qa.success(`Detached "${N.title}".`),await L({sources:C.filter($=>$.id!==N.id),inherited:A},{revalidate:!1}),g();}catch($){qa.error(h$1($,"The document could not be detached."));}finally{f$1(null);}}let B;return d?B=jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The attached documents could not be loaded."}):g$1&&!i?B=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t$1,{className:"fk:h-9 fk:w-full"}),jsx(t$1,{className:"fk:h-9 fk:w-2/3"})]}):B=jsxs("div",{className:"fk:flex fk:flex-col fk:gap-4",children:[C.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:A.length>0?"No documents attached to this record itself; the ones below apply to every record of its type.":"No documents attached. Attach a manual, spec or contract and the agent will use it alongside the record's data when asked about this record."}):jsx(re,{projectId:s$1,sources:C,renderAction:N=>r$1?jsx(fe,{disabled:y!==null,label:`Detach ${N.title}`,onClick:()=>{K(N);}}):null}),A.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1","data-knowledge-inherited":true,children:[jsxs("span",{className:"fk:text-xs fk:font-medium fk:uppercase fk:tracking-wide fk:text-muted-foreground",children:["Applies to every ",w]}),jsx(re,{projectId:s$1,sources:A})]}):null]}),jsx(a$1,{children:jsxs(p,{className:`fk:z-10 fk:flex fk:shrink-0 fk:flex-col fk:border-t fk:bg-background ${c$1?"fk:h-1/2":""}`,"data-knowledge-record-panel":true,open:c$1,onOpenChange:p$1,children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pl-4 fk:pr-10 fk:py-2",children:[jsx(q,{asChild:true,children:jsxs("button",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2 fk:rounded-md fk:py-1 fk:text-left fk:text-sm fk:font-semibold fk:tracking-tight fk:hover:text-foreground/80 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring",type:"button",children:[jsx(ChevronRightIcon,{className:`fk:size-4 fk:shrink-0 fk:text-muted-foreground fk:transition-transform ${c$1?"fk:rotate-90":""}`}),jsx(BookOpenTextIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}),"Knowledge",i?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:C.length+A.length}):null]})}),c$1?jsx(na,{disabled:!r$1,children:jsxs(b$1,{disabled:!r$1,size:"sm",variant:"outline",onClick:()=>m(true),children:[jsx(PaperclipIcon,{}),"Attach document"]})}):null]}),jsx(r,{className:"fk:min-h-0 fk:flex-1 fk:overflow-y-auto fk:px-10 fk:pb-6",children:B}),jsx(Xe,{api:a$2,attachedIds:R,open:h,projectId:s$1,target:b$4,targetLabel:o||`this ${n}`,onAttached:N=>{L({sources:C.some($=>$.id===N.id)?C:[...C,N],inherited:A.filter($=>$.id!==N.id)},{revalidate:false}),g();},onOpenChange:m})]})})}function Ze(n,l,o){let{scope:a}=c$3(),s=n.links.map(r=>r.recordId),{data:u}=s$2({entityNamePlural:n.entityPlural,schema:l,scope:a,selection:"display",includeCount:false,variables:{where:{_id:{in:s}},limit:s.length}});return useMemo(()=>{let r={};for(let c of u??[]){let p=c[o.name];typeof p=="string"&&p.trim()&&(r[c._id]=p);}return r},[u,o])}function Ye(n){let{currentProject:l}=f(),o=useMemo(()=>l?.schema??[],[l]),a=m$2(o,n.group.entityPlural),s=a$2(a);return !a||!s?jsx(Je,{...n,entityLabel:a?u(a):n.group.entityPlural,labels:{}}):jsx(et,{...n,displayAttribute:s,schema:o,entityLabel:u(a)})}function et({displayAttribute:n,entityLabel:l,schema:o,...a}){let s=Ze(a.group,o,n);return jsx(Je,{...a,entityLabel:l,labels:s})}function Je({canMutate:n,detachingKey:l,entityLabel:o,group:a,labels:s,onDetach:u}){let r=j();return jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("span",{className:"fk:text-xs fk:font-medium fk:uppercase fk:tracking-wide fk:text-muted-foreground",children:o}),jsx("ul",{className:"fk:flex fk:flex-col fk:-mx-2",children:a.links.map(c=>{let p=p$2(c,s[c.recordId]),h=`${c.entity}:${c.recordId}`;return jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2 fk:rounded-lg fk:px-2 fk:py-1 fk:corner-squircle",children:[jsx("button",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-left fk:text-sm fk:hover:underline fk:underline-offset-2",title:c.recordId,type:"button",onClick:()=>r({type:"EditEntity",payload:{entityId:c.recordId,entityNamePlural:a.entityPlural}}),children:p}),n?jsx(fe,{disabled:l!==null,label:`Detach from ${p}`,onClick:()=>u(c)}):null]},h)})})]})}function vt({api:n,projectId:l,source:o}){let a=b$3(),[s,u$1]=useState(null),{data:r,error:c$1,isLoading:p,mutate:h}=H(c(l).links(o.id),b),m=useMemo(()=>r?.links??[],[r]),y=useMemo(()=>r?.entities??[],[r]),f=useMemo(()=>q$1(m),[m]);async function b$1(i){u$1(`${i.entity}:${i.recordId}`);try{await n.unlinkSource(o.id,{entity:i.entity,recordId:i.recordId}),qa.success("Detached."),await h({links:m.filter(d=>d.entity!==i.entity||d.recordId!==i.recordId),entities:y},{revalidate:!1}),g();}catch(d){qa.error(h$1(d,"The document could not be detached."));}finally{u$1(null);}}async function v(i){u$1(`${i.entity}:*`);try{await n.unlinkSource(o.id,{entity:i.entity}),qa.success("Detached."),await h({links:m,entities:y.filter(d=>d.entity!==i.entity)},{revalidate:!1}),g();}catch(d){qa.error(h$1(d,"The document could not be detached."));}finally{u$1(null);}}async function w(i){u$1(`${i.name}:+`);try{let d=await n.linkSource(o.id,{entity:i.name});qa.success(d.linked?`Applies to every ${u(i)} now.`:`Already applied to every ${u(i)}.`),await h({links:m,entities:y.some(g=>g.entity===i.name)?y:[...y,{entity:i.name,entityPlural:i.plural}]},{revalidate:!1}),g();}catch(d){qa.error(h$1(d,"The document could not be attached."));}finally{u$1(null);}}let x;return c$1?x=jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The linked records could not be loaded."}):p&&!r?x=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t$1,{className:"fk:h-6 fk:w-1/2"}),jsx(t$1,{className:"fk:h-6 fk:w-1/3"})]}):f.length===0?x=jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:'Not attached to any record. Open a record in the Desk and use "Attach document" so the agent searches this document before the rest of Knowledge when asked about that record.'}):x=jsx("div",{className:"fk:flex fk:flex-col fk:gap-4",children:f.map(i=>jsx(Ye,{canMutate:a,detachingKey:s,group:i,onDetach:d=>{b$1(d);}},i.entityPlural))}),jsxs(Fragment,{children:[jsx(tt,{busy:s!==null,canMutate:a,entities:y,isLoading:p&&!r,onAttach:i=>{w(i);},onDetach:i=>{v(i);}}),jsxs("div",{className:"fk:mt-2 fk:flex fk:items-center fk:gap-2",children:[jsx(PaperclipIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx("h3",{className:"fk:text-sm fk:font-semibold fk:tracking-tight",children:"Linked records"}),m.length>0?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:m.length}):null]}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"When a question is about one of these records, the agent searches this document before the rest."}),x]})}function tt({busy:n,canMutate:l,entities:o$1,isLoading:a,onAttach:s,onDetach:u$2}){let{currentProject:r}=f(),c=useMemo(()=>r?.schema??[],[r]),[p,h]=useState(false),m$1=useMemo(()=>v(c,o$1),[o$1,c]),y=f=>{let b=t(c,f.entity);return b?u(b):f.entityPlural};return jsxs("div",{className:"fk:flex fk:flex-col fk:gap-3","data-knowledge-applies-to":true,children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(LayersIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx("h3",{className:"fk:text-sm fk:font-semibold fk:tracking-tight",children:"Applies to"}),o$1.length>0?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:o$1.length}):null]}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Attach this document to a whole entity type and the agent searches it before the rest of Knowledge for every record of that type, and for questions about the type in general."}),a?jsx(t$1,{className:"fk:h-7 fk:w-1/3"}):jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[o$1.map(f=>{let b=y(f);return jsxs(b$2,{className:"fk:gap-1 fk:py-1 fk:pl-2.5 fk:pr-1 fk:corner-squircle",variant:"secondary",children:[jsx("span",{className:"fk:capitalize",children:b}),l?jsxs(b$4,{children:[jsx(c$2,{asChild:true,children:jsx("button",{"aria-label":`No longer apply to every ${b}`,className:"fk:rounded-sm fk:p-0.5 fk:text-muted-foreground fk:hover:text-foreground fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:disabled:opacity-50",disabled:n,type:"button",onClick:()=>u$2(f),children:jsx(XIcon,{className:"fk:size-3"})})}),jsxs(e$1,{children:["No longer apply to every ",b]})]}):null]},f.entity)}),jsxs(t$2,{open:p,onOpenChange:h,children:[jsx(na,{disabled:!l,children:jsx(u$1,{asChild:true,children:jsxs(b$1,{className:"fk:h-7",disabled:!l||m$1.length===0,size:"sm",variant:"outline",children:[jsx(PlusIcon,{}),"Add entity type"]})})}),jsx(v$1,{align:"start",className:"fk:w-64 fk:p-0",children:jsxs(m,{children:[jsx(o,{placeholder:"Search entity types"}),jsxs(p$1,{children:[jsx(q$2,{children:"No entity type matches."}),jsx(r$1,{children:m$1.map(f=>jsx(t$3,{keywords:[u(f),f.name,f.plural],value:f.name,onSelect:()=>{h(false),s(f);},children:jsx("span",{className:"fk:capitalize",children:u(f)})},f.name))})]})]})})]})]})]})}export{yt as a,bt as b,vt as c};//# sourceMappingURL=chunk-MHVZXDVL.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {e,c,b,a,g,h as h$1,m as m$1,k as k$2,n}from'./chunk-CJHMUEOB.js';import {m as m$2,s as s$2}from'./chunk-AMUTDCI7.js';import {b as b$3}from'./chunk-V7C4EHK3.js';import {j}from'./chunk-E2NDJLAI.js';import {c as c$3}from'./chunk-XMOSCJOI.js';import {t,s,u,q as q$1,v,k as k$1,i as i$1,o as o$1,r as r$2,p as p$2}from'./chunk-7KLXWCDS.js';import {a as a$2}from'./chunk-ERDARDGB.js';import {f}from'./chunk-EYIV4KVY.js';import {na,p,q,r,t as t$2,u as u$1,v as v$1,qa,s as s$1}from'./chunk-DGIY4SKN.js';import {t as t$1}from'./chunk-SZEGGBOC.js';import {b as b$2,c as c$1,h,i,k,l,m,o,p as p$1,q as q$2,r as r$1,t as t$3}from'./chunk-32ZU4MLE.js';import {a as a$1,b as b$4,c as c$2,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {useState,useMemo,useDeferredValue}from'react';import {BookOpenTextIcon,PaperclipIcon,ChevronRightIcon,LayersIcon,XIcon,PlusIcon,Unlink2Icon,LoaderCircle,SearchIcon}from'lucide-react';import {Link}from'react-router-dom';import H from'swr';import Qe from'swr/infinite';import {jsxs,Fragment,jsx}from'react/jsx-runtime';var Be=50;function fe({disabled:n,label:l,onClick:o}){return jsxs(b$4,{children:[jsx(c$2,{asChild:true,children:jsx(b$1,{"aria-label":l,className:"fk:size-7 fk:shrink-0",disabled:n,size:"icon",variant:"ghost",onClick:o,children:jsx(Unlink2Icon,{className:"fk:size-4"})})}),jsx(e$1,{children:l})]})}function Xe({api:n$1,attachedIds:l$1,onAttached:o,onOpenChange:a,open:s,projectId:u,target:r,targetLabel:c$2}){let[p,h$2]=useState(""),m=useDeferredValue(p.trim()),[y,f]=useState(null),b$1=(k,K)=>!s||K&&!K.hasMore?null:c(u).sources({limit:Be,offset:k*Be,search:m||void 0}),{data:v,error:w,isLoading:x,setSize:i$2,size:d}=Qe(b$1,b,{keepPreviousData:true}),g=useMemo(()=>r$2(v?.flatMap(k=>k.sources)??[],l$1),[l$1,v]),L=v?.[v.length-1]?.hasMore??false,C=v!==void 0&&d>v.length;async function A(k){f(k.id);try{let K=await n$1.linkSource(k.id,r);qa.success(K.linked?`Attached "${k.title}".`:`"${k.title}" was already attached.`),o(k),a(!1);}catch(K){qa.error(h$1(K,"The document could not be attached."));}finally{f(null);}}let R;return w?R=jsx("p",{className:"fk:py-6 fk:text-center fk:text-sm fk:text-destructive",children:"The documents could not be loaded."}):x&&!v?R=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-3 fk:py-2",children:[jsx(t$1,{className:"fk:h-10 fk:w-full"}),jsx(t$1,{className:"fk:h-10 fk:w-full"}),jsx(t$1,{className:"fk:h-10 fk:w-full"})]}):g.length===0&&!L?R=jsx("p",{className:"fk:py-6 fk:text-center fk:text-sm fk:text-muted-foreground",children:m?"No documents match your search.":"Every document is attached already, or there are none yet. Add documents in Knowledge first."}):R=jsxs("ul",{className:"fk:flex fk:max-h-80 fk:flex-col fk:overflow-y-auto fk:-mx-2",children:[g.map(k=>{let K=k$1(k),B=y===k.id;return jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-2 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:disabled:opacity-60 fk:corner-squircle",disabled:y!==null,type:"button",onClick:()=>{A(k);},children:[jsx(m$1,{source:k}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:k.title}),jsxs("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:[i$1(k)," \xB7 ",K.detail]})]}),B?jsx(LoaderCircle,{className:"fk:size-4 fk:shrink-0 fk:animate-spin fk:text-muted-foreground"}):jsx(k$2,{label:K.label,tone:K.tone})]})},k.id)}),L&&!C?jsx("li",{"aria-hidden":true,children:jsx(n,{onVisible:()=>{i$2(k=>k+1);}})}):null,C?jsx("li",{className:"fk:flex fk:justify-center fk:py-2",children:jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin fk:text-muted-foreground"})}):null]}),jsx(c$1,{open:s,onOpenChange:a,children:jsxs(h,{className:"fk:sm:max-w-lg",children:[jsxs(i,{children:[jsx(k,{children:"Attach a document"}),jsx(l,{children:r.recordId===void 0?`Documents attached to every ${c$2} are searched before the rest of Knowledge when a question is about one of them, or about ${c$2} in general.`:`Documents attached to ${c$2} are searched before the rest of Knowledge when a question is about it.`})]}),jsxs("div",{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2.5 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s$1,{"aria-label":"Search documents",autoFocus:true,className:"fk:pl-8",placeholder:"Search documents by title",value:p,onChange:k=>h$2(k.target.value)})]}),R]})})}function re({projectId:n,renderAction:l,sources:o}){return jsx("ul",{className:"fk:flex fk:flex-col fk:gap-1 fk:-mx-2",children:o.map(a=>{let s=k$1(a);return jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2 fk:rounded-lg fk:px-2 fk:py-1.5 fk:corner-squircle",children:[jsxs(Link,{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-3 fk:rounded-md fk:hover:underline fk:underline-offset-2",to:o$1(n,a.id),children:[jsx(m$1,{source:a}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:a.title}),jsxs("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:[i$1(a)," \xB7 ",s.detail]})]})]}),jsx(k$2,{label:s.label,tone:s.tone}),l?.(a)]},a.id)})})}function yt({entityName:n}){let{api:l,projectId:o}=e(),{currentProject:a$1}=f(),[s$1,u$1]=useState(false),r=t(a$1?.schema??[],n),c$1=!!r&&s(n),{data:p,error:h}=H(o&&c$1?c(o).entitySources(n):null,b);if(!l||!o||!r||!c$1||h instanceof a&&h.status===404)return null;let m=p?.sources.length??0;return jsxs(Fragment,{children:[jsxs(b$1,{"aria-label":`Knowledge for every ${u(r)}`,className:"fk:mr-2 fk:h-8","data-knowledge-entity-button":true,size:"sm",variant:"outline",onClick:()=>u$1(true),children:[jsx(BookOpenTextIcon,{}),"Knowledge",m>0?jsx(b$2,{className:"fk:corner-squircle",variant:"secondary",children:m}):null]}),jsx(Ue,{api:l,entityLabel:u(r),entityName:n,open:s$1,projectId:o,onOpenChange:u$1})]})}function Ue({api:n,entityLabel:l$1,entityName:o,onOpenChange:a,open:s,projectId:u}){let r=b$3(),[c$2,p]=useState(false),[h$2,m]=useState(null),{data:y,error:f,isLoading:b$4,mutate:v}=H(c(u).entitySources(o),b),w=y?.sources??[],x=useMemo(()=>({entity:o}),[o]);async function i$1(g$1){m(g$1.id);try{await n.unlinkSource(g$1.id,x),qa.success(`"${g$1.title}" no longer applies to every ${l$1}.`),await v({sources:w.filter(L=>L.id!==g$1.id)},{revalidate:!1}),g();}catch(L){qa.error(h$1(L,"The document could not be detached."));}finally{m(null);}}let d;return f?d=jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The documents could not be loaded."}):b$4&&!y?d=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t$1,{className:"fk:h-9 fk:w-full"}),jsx(t$1,{className:"fk:h-9 fk:w-2/3"})]}):w.length===0?d=jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["No documents apply to every ",l$1," yet. Attach a guide, a policy or a spec that holds for all of them and the agent searches it first when asked about any ",l$1,", or about ",l$1," in general."]}):d=jsx(re,{projectId:u,sources:w,renderAction:g=>r?jsx(fe,{disabled:h$2!==null,label:`Detach ${g.title}`,onClick:()=>{i$1(g);}}):null}),jsx(c$1,{open:s,onOpenChange:a,children:jsxs(h,{className:"fk:sm:max-w-lg","data-knowledge-entity-dialog":true,children:[jsxs(i,{children:[jsxs(k,{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(BookOpenTextIcon,{className:"fk:size-4 fk:text-muted-foreground"}),"Knowledge for every ",l$1,y?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:w.length}):null]}),jsxs(l,{children:["Documents attached here apply to every ",l$1,"; each record can hold its own on top."]})]}),jsx("div",{className:"fk:max-h-80 fk:overflow-y-auto",children:d}),jsx("div",{className:"fk:flex fk:justify-end",children:jsx(na,{disabled:!r,children:jsxs(b$1,{disabled:!r,size:"sm",variant:"outline",onClick:()=>p(true),children:[jsx(PaperclipIcon,{}),"Attach document"]})})}),jsx(Xe,{api:n,attachedIds:w.map(g=>g.id),open:c$2,projectId:u,target:x,targetLabel:l$1,onAttached:g$1=>{v({sources:w.some(L=>L.id===g$1.id)?w:[...w,g$1]},{revalidate:false}),g();},onOpenChange:p})]})})}function bt({entityName:n,recordId:l,recordLabel:o}){let{api:a$2,projectId:s$1}=e(),{currentProject:u$1}=f(),r$1=b$3(),[c$1,p$1]=useState(false),[h,m]=useState(false),[y,f$1]=useState(null),b$4=useMemo(()=>({entity:n,recordId:l}),[n,l]),v=t(u$1?.schema??[],n),w=v?u(v):n,x=s(n),{data:i,error:d,isLoading:g$1,mutate:L}=H(s$1&&x?c(s$1).recordSources(b$4):null,b);if(!a$2||!s$1||!x||d instanceof a&&d.status===404)return null;let C=i?.sources??[],A=i?.inherited??[],R=C.map(N=>N.id),k=a$2;async function K(N){f$1(N.id);try{await k.unlinkSource(N.id,b$4),qa.success(`Detached "${N.title}".`),await L({sources:C.filter($=>$.id!==N.id),inherited:A},{revalidate:!1}),g();}catch($){qa.error(h$1($,"The document could not be detached."));}finally{f$1(null);}}let B;return d?B=jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The attached documents could not be loaded."}):g$1&&!i?B=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t$1,{className:"fk:h-9 fk:w-full"}),jsx(t$1,{className:"fk:h-9 fk:w-2/3"})]}):B=jsxs("div",{className:"fk:flex fk:flex-col fk:gap-4",children:[C.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:A.length>0?"No documents attached to this record itself; the ones below apply to every record of its type.":"No documents attached. Attach a manual, spec or contract and the agent will use it alongside the record's data when asked about this record."}):jsx(re,{projectId:s$1,sources:C,renderAction:N=>r$1?jsx(fe,{disabled:y!==null,label:`Detach ${N.title}`,onClick:()=>{K(N);}}):null}),A.length>0?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1","data-knowledge-inherited":true,children:[jsxs("span",{className:"fk:text-xs fk:font-medium fk:uppercase fk:tracking-wide fk:text-muted-foreground",children:["Applies to every ",w]}),jsx(re,{projectId:s$1,sources:A})]}):null]}),jsx(a$1,{children:jsxs(p,{className:`fk:z-10 fk:flex fk:shrink-0 fk:flex-col fk:border-t fk:bg-background ${c$1?"fk:h-1/2":""}`,"data-knowledge-record-panel":true,open:c$1,onOpenChange:p$1,children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pl-4 fk:pr-10 fk:py-2",children:[jsx(q,{asChild:true,children:jsxs("button",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2 fk:rounded-md fk:py-1 fk:text-left fk:text-sm fk:font-semibold fk:tracking-tight fk:hover:text-foreground/80 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring",type:"button",children:[jsx(ChevronRightIcon,{className:`fk:size-4 fk:shrink-0 fk:text-muted-foreground fk:transition-transform ${c$1?"fk:rotate-90":""}`}),jsx(BookOpenTextIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}),"Knowledge",i?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:C.length+A.length}):null]})}),c$1?jsx(na,{disabled:!r$1,children:jsxs(b$1,{disabled:!r$1,size:"sm",variant:"outline",onClick:()=>m(true),children:[jsx(PaperclipIcon,{}),"Attach document"]})}):null]}),jsx(r,{className:"fk:min-h-0 fk:flex-1 fk:overflow-y-auto fk:px-10 fk:pb-6",children:B}),jsx(Xe,{api:a$2,attachedIds:R,open:h,projectId:s$1,target:b$4,targetLabel:o||`this ${n}`,onAttached:N=>{L({sources:C.some($=>$.id===N.id)?C:[...C,N],inherited:A.filter($=>$.id!==N.id)},{revalidate:false}),g();},onOpenChange:m})]})})}function Ze(n,l,o){let{scope:a}=c$3(),s=n.links.map(r=>r.recordId),{data:u}=s$2({entityNamePlural:n.entityPlural,schema:l,scope:a,selection:"display",includeCount:false,variables:{where:{_id:{in:s}},limit:s.length}});return useMemo(()=>{let r={};for(let c of u??[]){let p=c[o.name];typeof p=="string"&&p.trim()&&(r[c._id]=p);}return r},[u,o])}function Ye(n){let{currentProject:l}=f(),o=useMemo(()=>l?.schema??[],[l]),a=m$2(o,n.group.entityPlural),s=a$2(a);return !a||!s?jsx(Je,{...n,entityLabel:a?u(a):n.group.entityPlural,labels:{}}):jsx(et,{...n,displayAttribute:s,schema:o,entityLabel:u(a)})}function et({displayAttribute:n,entityLabel:l,schema:o,...a}){let s=Ze(a.group,o,n);return jsx(Je,{...a,entityLabel:l,labels:s})}function Je({canMutate:n,detachingKey:l,entityLabel:o,group:a,labels:s,onDetach:u}){let r=j();return jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1",children:[jsx("span",{className:"fk:text-xs fk:font-medium fk:uppercase fk:tracking-wide fk:text-muted-foreground",children:o}),jsx("ul",{className:"fk:flex fk:flex-col fk:-mx-2",children:a.links.map(c=>{let p=p$2(c,s[c.recordId]),h=`${c.entity}:${c.recordId}`;return jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2 fk:rounded-lg fk:px-2 fk:py-1 fk:corner-squircle",children:[jsx("button",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-left fk:text-sm fk:hover:underline fk:underline-offset-2",title:c.recordId,type:"button",onClick:()=>r({type:"EditEntity",payload:{entityId:c.recordId,entityNamePlural:a.entityPlural}}),children:p}),n?jsx(fe,{disabled:l!==null,label:`Detach from ${p}`,onClick:()=>u(c)}):null]},h)})})]})}function vt({api:n,projectId:l,source:o}){let a=b$3(),[s,u$1]=useState(null),{data:r,error:c$1,isLoading:p,mutate:h}=H(c(l).links(o.id),b),m=useMemo(()=>r?.links??[],[r]),y=useMemo(()=>r?.entities??[],[r]),f=useMemo(()=>q$1(m),[m]);async function b$1(i){u$1(`${i.entity}:${i.recordId}`);try{await n.unlinkSource(o.id,{entity:i.entity,recordId:i.recordId}),qa.success("Detached."),await h({links:m.filter(d=>d.entity!==i.entity||d.recordId!==i.recordId),entities:y},{revalidate:!1}),g();}catch(d){qa.error(h$1(d,"The document could not be detached."));}finally{u$1(null);}}async function v(i){u$1(`${i.entity}:*`);try{await n.unlinkSource(o.id,{entity:i.entity}),qa.success("Detached."),await h({links:m,entities:y.filter(d=>d.entity!==i.entity)},{revalidate:!1}),g();}catch(d){qa.error(h$1(d,"The document could not be detached."));}finally{u$1(null);}}async function w(i){u$1(`${i.name}:+`);try{let d=await n.linkSource(o.id,{entity:i.name});qa.success(d.linked?`Applies to every ${u(i)} now.`:`Already applied to every ${u(i)}.`),await h({links:m,entities:y.some(g=>g.entity===i.name)?y:[...y,{entity:i.name,entityPlural:i.plural}]},{revalidate:!1}),g();}catch(d){qa.error(h$1(d,"The document could not be attached."));}finally{u$1(null);}}let x;return c$1?x=jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The linked records could not be loaded."}):p&&!r?x=jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t$1,{className:"fk:h-6 fk:w-1/2"}),jsx(t$1,{className:"fk:h-6 fk:w-1/3"})]}):f.length===0?x=jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:'Not attached to any record. Open a record in the Desk and use "Attach document" so the agent searches this document before the rest of Knowledge when asked about that record.'}):x=jsx("div",{className:"fk:flex fk:flex-col fk:gap-4",children:f.map(i=>jsx(Ye,{canMutate:a,detachingKey:s,group:i,onDetach:d=>{b$1(d);}},i.entityPlural))}),jsxs(Fragment,{children:[jsx(tt,{busy:s!==null,canMutate:a,entities:y,isLoading:p&&!r,onAttach:i=>{w(i);},onDetach:i=>{v(i);}}),jsxs("div",{className:"fk:mt-2 fk:flex fk:items-center fk:gap-2",children:[jsx(PaperclipIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx("h3",{className:"fk:text-sm fk:font-semibold fk:tracking-tight",children:"Linked records"}),m.length>0?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:m.length}):null]}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"When a question is about one of these records, the agent searches this document before the rest."}),x]})}function tt({busy:n,canMutate:l,entities:o$1,isLoading:a,onAttach:s,onDetach:u$2}){let{currentProject:r}=f(),c=useMemo(()=>r?.schema??[],[r]),[p,h]=useState(false),m$1=useMemo(()=>v(c,o$1),[o$1,c]),y=f=>{let b=t(c,f.entity);return b?u(b):f.entityPlural};return jsxs("div",{className:"fk:flex fk:flex-col fk:gap-3","data-knowledge-applies-to":true,children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(LayersIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx("h3",{className:"fk:text-sm fk:font-semibold fk:tracking-tight",children:"Applies to"}),o$1.length>0?jsx(b$2,{className:"fk:corner-squircle",variant:"outline",children:o$1.length}):null]}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Attach this document to a whole entity type and the agent searches it before the rest of Knowledge for every record of that type, and for questions about the type in general."}),a?jsx(t$1,{className:"fk:h-7 fk:w-1/3"}):jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[o$1.map(f=>{let b=y(f);return jsxs(b$2,{className:"fk:gap-1 fk:py-1 fk:pl-2.5 fk:pr-1 fk:corner-squircle",variant:"secondary",children:[jsx("span",{className:"fk:capitalize",children:b}),l?jsxs(b$4,{children:[jsx(c$2,{asChild:true,children:jsx("button",{"aria-label":`No longer apply to every ${b}`,className:"fk:rounded-sm fk:p-0.5 fk:text-muted-foreground fk:hover:text-foreground fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:disabled:opacity-50",disabled:n,type:"button",onClick:()=>u$2(f),children:jsx(XIcon,{className:"fk:size-3"})})}),jsxs(e$1,{children:["No longer apply to every ",b]})]}):null]},f.entity)}),jsxs(t$2,{open:p,onOpenChange:h,children:[jsx(na,{disabled:!l,children:jsx(u$1,{asChild:true,children:jsxs(b$1,{className:"fk:h-7",disabled:!l||m$1.length===0,size:"sm",variant:"outline",children:[jsx(PlusIcon,{}),"Add entity type"]})})}),jsx(v$1,{align:"start",className:"fk:w-64 fk:p-0",children:jsxs(m,{children:[jsx(o,{placeholder:"Search entity types"}),jsxs(p$1,{children:[jsx(q$2,{children:"No entity type matches."}),jsx(r$1,{children:m$1.map(f=>jsx(t$3,{keywords:[u(f),f.name,f.plural],value:f.name,onSelect:()=>{h(false),s(f);},children:jsx("span",{className:"fk:capitalize",children:u(f)})},f.name))})]})]})})]})]})]})}export{yt as a,bt as b,vt as c};//# sourceMappingURL=chunk-DAM7JM5J.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-DAM7JM5J.js.map
|