@flexkit/studio 0.2.38 → 0.2.39
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/README.md +76 -7
- package/dist/{chat-page-DW3FP4UZ.js → chat-page-2ES466GO.js} +3 -3
- package/dist/{chat-page-DW3FP4UZ.js.map → chat-page-2ES466GO.js.map} +1 -1
- package/dist/{chunk-JUWAKQPE.js → chunk-7FYOLFHG.js} +3 -3
- package/dist/{chunk-JUWAKQPE.js.map → chunk-7FYOLFHG.js.map} +1 -1
- package/dist/{chunk-UOTVVZPA.js → chunk-CESG6WQB.js} +3 -3
- package/dist/{chunk-UOTVVZPA.js.map → chunk-CESG6WQB.js.map} +1 -1
- package/dist/{chunk-DSZJXMN5.js → chunk-DQ2OVNOB.js} +2 -2
- package/dist/{chunk-DSZJXMN5.js.map → chunk-DQ2OVNOB.js.map} +1 -1
- package/dist/{chunk-IUWDNPMY.js → chunk-DR36N2JC.js} +2 -2
- package/dist/{chunk-IUWDNPMY.js.map → chunk-DR36N2JC.js.map} +1 -1
- package/dist/{chunk-IJECATW3.js → chunk-DUS2CRB3.js} +2 -2
- package/dist/{chunk-IJECATW3.js.map → chunk-DUS2CRB3.js.map} +1 -1
- package/dist/{chunk-3GXM5SSM.js → chunk-JJFOUJMQ.js} +3 -3
- package/dist/{chunk-3GXM5SSM.js.map → chunk-JJFOUJMQ.js.map} +1 -1
- package/dist/{chunk-AQBULUC2.js → chunk-KWE3LHFM.js} +4 -4
- package/dist/{chunk-AQBULUC2.js.map → chunk-KWE3LHFM.js.map} +1 -1
- package/dist/{chunk-GSKQHFQM.js → chunk-MGCXYA2S.js} +3 -3
- package/dist/{chunk-GSKQHFQM.js.map → chunk-MGCXYA2S.js.map} +1 -1
- package/dist/{chunk-CCVE7GGO.js → chunk-PR3MTHFM.js} +2 -2
- package/dist/{chunk-CCVE7GGO.js.map → chunk-PR3MTHFM.js.map} +1 -1
- package/dist/{chunk-32B35YDF.js → chunk-R7EOMV6C.js} +3 -3
- package/dist/{chunk-32B35YDF.js.map → chunk-R7EOMV6C.js.map} +1 -1
- package/dist/{chunk-GORBKX24.js → chunk-SAVZBVP5.js} +3 -3
- package/dist/{chunk-GORBKX24.js.map → chunk-SAVZBVP5.js.map} +1 -1
- package/dist/{chunk-6J3ZIVDQ.js → chunk-SGQMQZIW.js} +2 -2
- package/dist/{chunk-6J3ZIVDQ.js.map → chunk-SGQMQZIW.js.map} +1 -1
- package/dist/{chunk-LMJEP4VR.js → chunk-TOISBMRE.js} +2 -2
- package/dist/{chunk-LMJEP4VR.js.map → chunk-TOISBMRE.js.map} +1 -1
- package/dist/{chunk-INZZOKRC.js → chunk-TP6QGIJH.js} +3 -3
- package/dist/{chunk-INZZOKRC.js.map → chunk-TP6QGIJH.js.map} +1 -1
- package/dist/{chunk-377TM7UG.js → chunk-U3PTPLSE.js} +2 -2
- package/dist/{chunk-377TM7UG.js.map → chunk-U3PTPLSE.js.map} +1 -1
- package/dist/{chunk-4OGLWOO3.js → chunk-VR3LFFJ3.js} +3 -3
- package/dist/{chunk-4OGLWOO3.js.map → chunk-VR3LFFJ3.js.map} +1 -1
- package/dist/{chunk-WYVXSLB7.js → chunk-WSXNYZQC.js} +2 -2
- package/dist/{chunk-WYVXSLB7.js.map → chunk-WSXNYZQC.js.map} +1 -1
- package/dist/{chunk-KV4OGH5U.js → chunk-Z7JAN2UW.js} +2 -2
- package/dist/{chunk-KV4OGH5U.js.map → chunk-Z7JAN2UW.js.map} +1 -1
- package/dist/{entry-G2R3W5NU.js → entry-ZYSQFFEW.js} +2 -2
- package/dist/{entry-G2R3W5NU.js.map → entry-ZYSQFFEW.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/{list-IRTUEW55.js → list-4EXGXJZA.js} +2 -2
- package/dist/{list-IRTUEW55.js.map → list-4EXGXJZA.js.map} +1 -1
- package/dist/{list-LVXMUJHP.js → list-XTC2OYA6.js} +3 -3
- package/dist/{list-LVXMUJHP.js.map → list-XTC2OYA6.js.map} +1 -1
- package/dist/{pages-HJHR7DFO.js → pages-HW4OCENA.js} +3 -3
- package/dist/{pages-HJHR7DFO.js.map → pages-HW4OCENA.js.map} +1 -1
- package/dist/{plugin-pages-ZO3TLUYW.js → plugin-pages-CUTCB6NU.js} +2 -2
- package/dist/{plugin-pages-ZO3TLUYW.js.map → plugin-pages-CUTCB6NU.js.map} +1 -1
- package/dist/{project-selector-OXDEHTJ5.js → project-selector-Z4Q6G6GM.js} +2 -2
- package/dist/{project-selector-OXDEHTJ5.js.map → project-selector-Z4Q6G6GM.js.map} +1 -1
- package/dist/record-links-DBU5G6ZH.js +2 -0
- package/dist/{record-links-SZQUATM6.js.map → record-links-DBU5G6ZH.js.map} +1 -1
- package/dist/{root-MMGPZ4ZF.js → root-3Q44ISGQ.js} +3 -3
- package/dist/{root-MMGPZ4ZF.js.map → root-3Q44ISGQ.js.map} +1 -1
- package/dist/{root-BIUU3CXY.js → root-422O7YX5.js} +3 -3
- package/dist/{root-BIUU3CXY.js.map → root-422O7YX5.js.map} +1 -1
- package/dist/{root-E4GIVJYA.js → root-7FYWXLI6.js} +3 -3
- package/dist/{root-E4GIVJYA.js.map → root-7FYWXLI6.js.map} +1 -1
- package/dist/{root-P537YXFS.js → root-7NZPP7IC.js} +2 -2
- package/dist/{root-P537YXFS.js.map → root-7NZPP7IC.js.map} +1 -1
- package/dist/{root-BRIEXCDH.js → root-Q6SHODPG.js} +2 -2
- package/dist/{root-BRIEXCDH.js.map → root-Q6SHODPG.js.map} +1 -1
- package/dist/{root-4ATHF5ZZ.js → root-SYRZ3UBN.js} +2 -2
- package/dist/{root-4ATHF5ZZ.js.map → root-SYRZ3UBN.js.map} +1 -1
- package/dist/{search-57W7MXQ3.js → search-X7F5JZOU.js} +2 -2
- package/dist/{search-57W7MXQ3.js.map → search-X7F5JZOU.js.map} +1 -1
- package/dist/{skills-pages-LUOBTEAP.js → skills-pages-X3DVZXY5.js} +2 -2
- package/dist/{skills-pages-LUOBTEAP.js.map → skills-pages-X3DVZXY5.js.map} +1 -1
- package/dist/{source-CJPY5PTU.js → source-43PHAELP.js} +2 -2
- package/dist/{source-CJPY5PTU.js.map → source-43PHAELP.js.map} +1 -1
- package/package.json +6 -6
- package/dist/record-links-SZQUATM6.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {c,e}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {c,e}from'./chunk-DQ2OVNOB.js';import {b}from'./chunk-SAVZBVP5.js';import {f}from'./chunk-TP6QGIJH.js';import {d}from'./chunk-MBBE4RND.js';import {useMemo}from'react';import I from'swr';import {find,propEq}from'ramda';function $(n,o){let{scope:l}=c(),{currentProject:e$1}=f(),a=useMemo(()=>e$1?.schema??[],[e$1]),m=e$1?.scopes,u=e(m),t=o?.commonParams.q?JSON.stringify(o):null,{data:r,error:s,isLoading:y}=I(t,()=>fetch(d(n).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(o),method:"POST",mode:"cors"}).then(i=>i.json()),{keepPreviousData:true});return {results:useMemo(()=>t?O(r?.results??[],n,a,l,u)??[]:[],[r,u,n,a,l,t]),error:s,isLoading:y}}function O(n,o,l,e,a){return n?.filter(m=>m?.hits?.length>0).map(m=>{let u=m,t=u.collection.replace(`${o}_`,"").replace(/_\d+$/,""),r=find(propEq(t,"plural"))(l);if(!r)return [];let s=b(r)?.name??"",y=r?.name??t;return u.hits.map(({document:c})=>{let i=c[s],N=(i&&typeof i!="string"?i[e]??i[a]:null)??c[s],_=Object.entries(c).reduce((h,[p,f])=>{if(p!==s&&p!=="id"&&p!=="_updatedAt"){let A=typeof f!="string"?f[e]??f[a]:f;h[p]=A;}return h},{});return {_id:c.id,_entityName:y,_entityNamePlural:t,[s]:N,..._}})}).flat()}export{$ as a};//# sourceMappingURL=chunk-U3PTPLSE.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-U3PTPLSE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/use-search.tsx"],"names":["useSearch","projectId","searchRequest","scope","useAppContext","currentProject","useConfig","schema","useMemo","scopes","defaultScope","defaultScopeName","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","results","result","item","entityNamePlural","entitySchema","find","propEq","primaryAttributeName","getDisplayAttribute","entityName","document","primaryAttribute","primaryAttributeValue","attributes","acc","key","value","scopedValue"],"mappings":"qPAYO,SAASA,EACdC,CAAAA,CACAC,CAAAA,CACwE,CACxE,GAAM,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAIC,GAAc,CAC1B,CAAE,cAAA,CAAAC,GAAe,EAAIC,CAAAA,EAAU,CAC/BC,CAAAA,CAASC,OAAAA,CAAQ,IAAMH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CAAG,CAACA,GAAc,CAAC,CAAA,CACrEI,EAASJ,GAAAA,EAAgB,MAAA,CACzBK,CAAAA,CAAeC,CAAAA,CAAiBF,CAAM,CAAA,CACtCG,CAAAA,CAASV,CAAAA,EAAe,aAAa,CAAA,CAAI,IAAA,CAAK,SAAA,CAAUA,CAAa,CAAA,CAAI,IAAA,CACzE,CAAE,IAAA,CAAAW,EAAM,KAAA,CAAAC,CAAAA,CAAO,SAAA,CAAAC,CAAU,EAAIC,CAAAA,CACjCJ,CAAAA,CACA,IACE,KAAA,CAAMK,EAAShB,CAAS,CAAA,CAAE,MAAA,CAAQ,CAChC,OAAA,CAAS,CAAE,cAAA,CAAgB,kBAAmB,EAC9C,IAAA,CAAM,IAAA,CAAK,SAAA,CAAUC,CAAa,CAAA,CAClC,MAAA,CAAQ,MAAA,CACR,IAAA,CAAM,MACR,CAAC,CAAA,CAAE,IAAA,CAAMgB,CAAAA,EAAQA,CAAAA,CAAI,IAAA,EAAoD,CAAA,CAE3E,CAAE,gBAAA,CAAkB,IAAK,CAC3B,CAAA,CAQA,OAAO,CAAE,OAAA,CAPOV,OAAAA,CAGd,IAAOI,EAAUO,CAAAA,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AAY,CAAA,CACzD,IAAA,GACkDoB,CAAAA,CAASH,CAAoB,CAAA,CAC/EM,CAAAA,CAAa,MAAA,CAAO,OAAA,CAAQH,CAAQ,CAAA,CAAE,MAAA,CAC1C,CAACI,EAA0E,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAM,CAC1F,GAAID,CAAAA,GAAQR,CAAAA,EAAwBQ,IAAQ,IAAA,EAAQA,CAAAA,GAAQ,YAAA,CAAc,CACxE,IAAME,CAAAA,CAAc,OAAOD,CAAAA,EAAU,QAAA,CAAYA,EAAMjC,CAAK,CAAA,EAAKiC,CAAAA,CAAM1B,CAAY,CAAA,CAAK0B,CAAAA,CAExFF,CAAAA,CAAIC,CAAG,EAAIE,EACb,CAEA,OAAOH,CACT,EACA,EACF,CAAA,CAEA,OAAO,CACL,GAAA,CAAKJ,CAAAA,CAAS,EAAA,CACd,WAAA,CAAaD,CAAAA,CACb,iBAAA,CAAmBN,CAAAA,CACnB,CAACI,CAAoB,EAAGK,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/core/use-search.tsx"],"names":["useSearch","projectId","searchRequest","scope","useAppContext","currentProject","useConfig","schema","useMemo","scopes","defaultScope","defaultScopeName","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","results","result","item","entityNamePlural","entitySchema","find","propEq","primaryAttributeName","getDisplayAttribute","entityName","document","primaryAttribute","primaryAttributeValue","attributes","acc","key","value","scopedValue"],"mappings":"qPAYO,SAASA,EACdC,CAAAA,CACAC,CAAAA,CACwE,CACxE,GAAM,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAIC,GAAc,CAC1B,CAAE,cAAA,CAAAC,GAAe,EAAIC,CAAAA,EAAU,CAC/BC,CAAAA,CAASC,OAAAA,CAAQ,IAAMH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CAAG,CAACA,GAAc,CAAC,CAAA,CACrEI,EAASJ,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D,CAAAA,CACb,iBAAA,CAAmBN,CAAAA,CACnB,CAACI,CAAoB,EAAGK,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-U3PTPLSE.js","sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport { defaultScopeName } from './default-scope';\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport { getDisplayAttribute } from './get-display-attribute';\nimport type { Entity, RawResultItem, RawSearchResultItems, SearchRequestProps, SearchResultItem } from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { currentProject } = useConfig();\n const schema = useMemo(() => currentProject?.schema ?? [], [currentProject]);\n const scopes = currentProject?.scopes;\n const defaultScope = defaultScopeName(scopes);\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(\n swrKey,\n () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>),\n // Show the previous hits until the next request lands instead of flashing an empty list per keystroke.\n { keepPreviousData: true }\n );\n const results = useMemo(\n // SWR keeps the previous key's data while a new key loads, and also after the key becomes null.\n // Callers treat an empty query as \"no search\", so return no hits once there is nothing to search for.\n () => (swrKey ? (mapResults(data?.results ?? [], projectId, schema, scope, defaultScope) ?? []) : []),\n [data, defaultScope, projectId, schema, scope, swrKey]\n );\n\n return { results, error, isLoading };\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getDisplayAttribute(entitySchema)?.name ?? '';\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import'./index.css';import {f as f$1}from'./chunk-
|
|
2
|
-
`)}function er(r,e){return r?C(r).some(t=>t.includes(`Cannot query field "${e}"`)):false}function C(r){if(CombinedGraphQLErrors.is(r))return r.errors.filter(y).map(({message:o})=>o);let e=L(r);if(e&&a(e))return [e];let t=f(r);if(t?.statusCode!==400)return [];let n=d(t.bodyText)??P(t)??b(r);return n?Array.isArray(n.errors)?n.errors.filter(y).map(o=>o.message):typeof n.message=="string"&&a(n.message)?[n.message]:typeof n.error=="string"&&a(n.error)?[n.error]:[]:[]}function P(r){let{result:e}=r;return !e||typeof e!="object"?null:e}function b(r){if(!A(r))return null;let{cause:e}=r,t=L(e);if(t&&a(t))return {message:t};if(!e||typeof e!="object")return null;let{result:n}=e;return n&&typeof n=="object"?n:null}function y(r){if(!r||typeof r!="object")return false;let{extensions:e,message:t}=r;return e?.code==="GRAPHQL_VALIDATION_FAILED"&&typeof t=="string"?true:typeof t=="string"&&a(t)}function a(r){return r.startsWith("Cannot query field ")||r.startsWith("Unknown type ")||r.startsWith('Cannot query field "')||r.includes("GRAPHQL_VALIDATION_FAILED")}function I(r){return /Cannot query field "[_A-Za-z][_0-9A-Za-z]*Total" on type "Query"/.test(r)}var U=ApolloProvider,v=createContext(void 0);function pr(){let r=useContext(v);if(!r)throw new Error("useGraphQLError must be used within GraphQLProvider");return r}var fr={userQuery:true};function H(r){return new ErrorLink(({error:e,operation:t})=>{if(t.getContext().userQuery===true)return;let n=k(e);if(n){r(n);return}CombinedGraphQLErrors.is(e)?e.errors.forEach(({message:s,locations:i,path:c})=>{console.warn(`[GraphQL error]: Message: ${s}, Location: ${i}, Path: ${c}`);}):CombinedProtocolErrors.is(e)&&e.errors.forEach(({message:s,extensions:i})=>{console.warn(`[Protocol error]: Message: ${s}, Extensions: ${JSON.stringify(i)}`);});let o=f(e);if(o?.statusCode===400){let s=d(o.bodyText),i=null;if(s&&typeof s=="object"){let{error:c,errors:g,message:E}=s;if(typeof E=="string")i=E;else if(Array.isArray(g)){let[p]=g;if(p&&typeof p.message=="string"){let{message:D}=p;i=D;}}else typeof c=="string"?i=c:i=JSON.stringify(s);}else i=o.bodyText;r(i??"There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.");}if(o){console.warn(`[Network error]: ${o.message}`);return}e&&console.warn(`[Network error]: ${e.message}`);})}function z(r,e){return from([H(e),new HttpLink({uri:`/api/flexkit/${r}/graphql`})])}function Z(r,e){return new ApolloClient({link:z(r??"",e),cache:new InMemoryCache({dataIdFromObject:t=>t._id?t._id:defaultDataIdFromObject(t)})})}function dr({children:r}){let{currentProjectId:e}=f$1(),[t,n]=useState(null),o=useMemo(()=>({schemaErrorMessage:t,setSchemaErrorMessage:n}),[t]),s=useMemo(()=>Z(e,n),[e]);return jsx(v.Provider,{value:o,children:jsx(U,{client:s,children:r})})}var G=createContext([]),M=createContext(()=>{});function K(r,e){let t=e.type;switch(e._id||(e._id=Date.now().toString()),t){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "AddEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...r,e]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...r,e]);case "Dismiss":return r.filter(n=>n._id!==e._id);default:throw Error(`Unknown action: ${t}`)}}function yr({children:r}){let[e,t]=useReducer(K,[]);return jsx(G.Provider,{value:e,children:jsx(M.Provider,{value:t,children:r})})}function Ar(){return useContext(G)}function Lr(){return useContext(M)}export{f as a,d as b,k as c,er as d,pr as e,fr as f,dr as g,yr as h,Ar as i,Lr as j};//# sourceMappingURL=chunk-
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {f as f$1}from'./chunk-TP6QGIJH.js';import {ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';import {ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import {createContext,useContext,useState,useMemo,useReducer}from'react';import {jsx}from'react/jsx-runtime';import {uniqBy,props}from'ramda';function A(r){return r?"cause"in r:false}function f(r){if(!r)return null;if(ServerError.is(r))return r;if(A(r)){let e=r.cause;if(ServerError.is(e))return e}return null}function L(r){if(!r||typeof r!="object")return null;let{message:e}=r;return typeof e=="string"?e:null}function d(r){if(!r)return null;try{return JSON.parse(r)}catch{return null}}function k(r){if(!r)return null;let e=C(r).filter(t=>!I(t));return e.length===0?null:["The deployed schema is out of sync with your local Flexkit schema.","Run `flexkit deploy` using the CLI to apply your latest schema changes.",...e.map(t=>`- ${t}`)].join(`
|
|
2
|
+
`)}function er(r,e){return r?C(r).some(t=>t.includes(`Cannot query field "${e}"`)):false}function C(r){if(CombinedGraphQLErrors.is(r))return r.errors.filter(y).map(({message:o})=>o);let e=L(r);if(e&&a(e))return [e];let t=f(r);if(t?.statusCode!==400)return [];let n=d(t.bodyText)??P(t)??b(r);return n?Array.isArray(n.errors)?n.errors.filter(y).map(o=>o.message):typeof n.message=="string"&&a(n.message)?[n.message]:typeof n.error=="string"&&a(n.error)?[n.error]:[]:[]}function P(r){let{result:e}=r;return !e||typeof e!="object"?null:e}function b(r){if(!A(r))return null;let{cause:e}=r,t=L(e);if(t&&a(t))return {message:t};if(!e||typeof e!="object")return null;let{result:n}=e;return n&&typeof n=="object"?n:null}function y(r){if(!r||typeof r!="object")return false;let{extensions:e,message:t}=r;return e?.code==="GRAPHQL_VALIDATION_FAILED"&&typeof t=="string"?true:typeof t=="string"&&a(t)}function a(r){return r.startsWith("Cannot query field ")||r.startsWith("Unknown type ")||r.startsWith('Cannot query field "')||r.includes("GRAPHQL_VALIDATION_FAILED")}function I(r){return /Cannot query field "[_A-Za-z][_0-9A-Za-z]*Total" on type "Query"/.test(r)}var U=ApolloProvider,v=createContext(void 0);function pr(){let r=useContext(v);if(!r)throw new Error("useGraphQLError must be used within GraphQLProvider");return r}var fr={userQuery:true};function H(r){return new ErrorLink(({error:e,operation:t})=>{if(t.getContext().userQuery===true)return;let n=k(e);if(n){r(n);return}CombinedGraphQLErrors.is(e)?e.errors.forEach(({message:s,locations:i,path:c})=>{console.warn(`[GraphQL error]: Message: ${s}, Location: ${i}, Path: ${c}`);}):CombinedProtocolErrors.is(e)&&e.errors.forEach(({message:s,extensions:i})=>{console.warn(`[Protocol error]: Message: ${s}, Extensions: ${JSON.stringify(i)}`);});let o=f(e);if(o?.statusCode===400){let s=d(o.bodyText),i=null;if(s&&typeof s=="object"){let{error:c,errors:g,message:E}=s;if(typeof E=="string")i=E;else if(Array.isArray(g)){let[p]=g;if(p&&typeof p.message=="string"){let{message:D}=p;i=D;}}else typeof c=="string"?i=c:i=JSON.stringify(s);}else i=o.bodyText;r(i??"There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.");}if(o){console.warn(`[Network error]: ${o.message}`);return}e&&console.warn(`[Network error]: ${e.message}`);})}function z(r,e){return from([H(e),new HttpLink({uri:`/api/flexkit/${r}/graphql`})])}function Z(r,e){return new ApolloClient({link:z(r??"",e),cache:new InMemoryCache({dataIdFromObject:t=>t._id?t._id:defaultDataIdFromObject(t)})})}function dr({children:r}){let{currentProjectId:e}=f$1(),[t,n]=useState(null),o=useMemo(()=>({schemaErrorMessage:t,setSchemaErrorMessage:n}),[t]),s=useMemo(()=>Z(e,n),[e]);return jsx(v.Provider,{value:o,children:jsx(U,{client:s,children:r})})}var G=createContext([]),M=createContext(()=>{});function K(r,e){let t=e.type;switch(e._id||(e._id=Date.now().toString()),t){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "AddEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...r,e]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...r,e]);case "Dismiss":return r.filter(n=>n._id!==e._id);default:throw Error(`Unknown action: ${t}`)}}function yr({children:r}){let[e,t]=useReducer(K,[]);return jsx(G.Provider,{value:e,children:jsx(M.Provider,{value:t,children:r})})}function Ar(){return useContext(G)}function Lr(){return useContext(M)}export{f as a,d as b,k as c,er as d,pr as e,fr as f,dr as g,yr as h,Ar as i,Lr as j};//# sourceMappingURL=chunk-VR3LFFJ3.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-VR3LFFJ3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphql-client/error-utils.ts","../src/graphql-client/graphql-context.tsx","../src/entities/actions-context.tsx"],"names":["hasCause","error","getServerError","ServerError","possibleServerError","getErrorMessage","message","parseErrorBody","bodyText","getGraphQLSchemaMismatchMessage","messages","getGraphQLValidationMessages","isMissingCountStoreFieldMessage","isMissingGraphQLFieldError","fieldName","CombinedGraphQLErrors","isSchemaValidationError","directMessage","isSchemaValidationMessage","serverError","responseBody","getServerErrorResult","getErrorCauseResponse","item","result","cause","causeMessage","extensions","ApolloProviderCompat","ApolloProvider","GraphQLErrorContext","createContext","useGraphQLError","ctx","useContext","USER_QUERY_CONTEXT","createErrorLink","setSchemaErrorMessage","ErrorLink","operation","schemaMismatchMessage","locations","path","CombinedProtocolErrors","responseError","errors","responseMessage","firstError","firstErrorMessage","additiveLink","currentProjectId","from","HttpLink","client","ApolloClient","InMemoryCache","responseObject","defaultDataIdFromObject","GraphQLProvider","children","useConfig","schemaErrorMessage","useState","useMemo","apolloClient","jsx","ActionsContext","EntityDispatchContext","actionsReducer","actions","action","actionType","uniqBy","props","ActionsProvider","entityActions","dispatchEntityActions","useReducer","useActions","useDispatch"],"mappings":"4eAsBA,SAASA,CAAAA,CAASC,EAA2C,CAC3D,OAAKA,EAIE,OAAA,GAAYA,CAAAA,CAHV,KAIX,CAEO,SAASC,CAAAA,CAAeD,CAAAA,CAAuC,CACpE,GAAI,CAACA,CAAAA,CACH,OAAO,IAAA,CAGT,GAAIE,YAAY,EAAA,CAAGF,CAAK,EACtB,OAAOA,CAAAA,CAGT,GAAID,CAAAA,CAASC,CAAK,CAAA,CAAG,CACnB,IAAMG,CAAAA,CAAsBH,CAAAA,CAAM,KAAA,CAElC,GAAIE,YAAY,EAAA,CAAGC,CAAmB,CAAA,CACpC,OAAOA,CAEX,CAEA,OAAO,IACT,CAEA,SAASC,EAAgBJ,CAAAA,CAA+B,CACtD,GAAI,CAACA,GAAS,OAAOA,CAAAA,EAAU,QAAA,CAC7B,OAAO,KAGT,GAAM,CAAE,OAAA,CAAAK,CAAQ,EAAIL,CAAAA,CAEpB,OAAO,OAAOK,CAAAA,EAAY,SAAWA,CA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AAAA,CAAM,CAAC,MAAA,CAAkB,KAAK,CAAC,CAAA,CAAG,CAAC,GAAIJ,EAAsCC,CAAM,CAAC,EAEpG,KAAK,aAAA,CACH,OAAOE,MAAAA,CAAOC,KAAAA,CAAM,CAAC,MAAA,CAAkB,KAAK,CAAC,EAAG,CAAC,GAAIJ,EAAiCC,CAAM,CAAC,EAE/F,KAAK,SAAA,CACH,OAAOD,CAAAA,CAAQ,MAAA,CAAQ9C,CAAAA,EAASA,EAAK,GAAA,GAAQ+C,CAAAA,CAAO,GAAG,CAAA,CAEzD,QACE,MAAM,KAAA,CAAM,CAAA,gBAAA,EAAmBC,CAAoB,CAAA,CAAE,CAEzD,CACF,CAEA,SAASG,EAAAA,CAAgB,CAAE,QAAA,CAAAf,CAAS,EAAyC,CAC3E,GAAM,CAACgB,CAAAA,CAAeC,CAAqB,CAAA,CAAIC,WAAWT,CAAAA,CAAgB,EAAE,CAAA,CAE5E,OACEH,IAACC,CAAAA,CAAe,QAAA,CAAf,CAAwB,KAAA,CAAOS,CAAAA,CAC9B,QAAA,CAAAV,IAACE,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOS,CAAAA,CAAwB,SAAAjB,CAAAA,CAAS,CAAA,CAC1E,CAEJ,CAEA,SAASmB,EAAAA,EAAuB,CAC9B,OAAO5C,UAAAA,CAAWgC,CAAc,CAClC,CAEA,SAASa,IAAgC,CACvC,OAAO7C,UAAAA,CAAWiC,CAAqB,CACzC","file":"chunk-4OGLWOO3.js","sourcesContent":["import type { ErrorLike } from '@apollo/client';\nimport { CombinedGraphQLErrors, ServerError } from '@apollo/client/errors';\n\ntype ErrorWithCause = ErrorLike & { cause?: unknown };\ntype ErrorWithMessage = {\n message?: unknown;\n};\ntype ServerErrorWithResult = ServerError & {\n result?: unknown;\n};\ntype GraphQLErrorResponse = {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n};\ntype GraphQLErrorItem = {\n extensions?: {\n code?: unknown;\n };\n message?: unknown;\n};\n\nfunction hasCause(error: ErrorLike): error is ErrorWithCause {\n if (!error) {\n return false;\n }\n\n return 'cause' in (error as ErrorWithCause);\n}\n\nexport function getServerError(error?: ErrorLike): ServerError | null {\n if (!error) {\n return null;\n }\n\n if (ServerError.is(error)) {\n return error;\n }\n\n if (hasCause(error)) {\n const possibleServerError = error.cause;\n\n if (ServerError.is(possibleServerError)) {\n return possibleServerError;\n }\n }\n\n return null;\n}\n\nfunction getErrorMessage(error: unknown): string | null {\n if (!error || typeof error !== 'object') {\n return null;\n }\n\n const { message } = error as ErrorWithMessage;\n\n return typeof message === 'string' ? message : null;\n}\n\nexport function parseErrorBody<T>(bodyText: string | undefined): T | null {\n if (!bodyText) {\n return null;\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch {\n return null;\n }\n}\n\nexport function getGraphQLSchemaMismatchMessage(error?: ErrorLike): string | null {\n if (!error) {\n return null;\n }\n\n const messages = getGraphQLValidationMessages(error).filter((message) => !isMissingCountStoreFieldMessage(message));\n\n if (messages.length === 0) {\n return null;\n }\n\n return [\n 'The deployed schema is out of sync with your local Flexkit schema.',\n 'Run `flexkit deploy` using the CLI to apply your latest schema changes.',\n ...messages.map((message) => `- ${message}`),\n ].join('\\n');\n}\n\nexport function isMissingGraphQLFieldError(error: ErrorLike | undefined, fieldName: string): boolean {\n if (!error) {\n return false;\n }\n\n return getGraphQLValidationMessages(error).some((message) => {\n return message.includes(`Cannot query field \"${fieldName}\"`);\n });\n}\n\nfunction getGraphQLValidationMessages(error: ErrorLike): string[] {\n if (CombinedGraphQLErrors.is(error)) {\n return error.errors.filter(isSchemaValidationError).map(({ message }) => message);\n }\n\n const directMessage = getErrorMessage(error);\n\n if (directMessage && isSchemaValidationMessage(directMessage)) {\n return [directMessage];\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode !== 400) {\n return [];\n }\n\n const responseBody =\n parseErrorBody<GraphQLErrorResponse>(serverError.bodyText) ??\n getServerErrorResult(serverError) ??\n getErrorCauseResponse(error);\n\n if (!responseBody) {\n return [];\n }\n\n if (Array.isArray(responseBody.errors)) {\n return responseBody.errors.filter(isSchemaValidationError).map((item) => item.message);\n }\n\n if (typeof responseBody.message === 'string' && isSchemaValidationMessage(responseBody.message)) {\n return [responseBody.message];\n }\n\n if (typeof responseBody.error === 'string' && isSchemaValidationMessage(responseBody.error)) {\n return [responseBody.error];\n }\n\n return [];\n}\n\nfunction getServerErrorResult(serverError: ServerError): GraphQLErrorResponse | null {\n const { result } = serverError as ServerErrorWithResult;\n\n if (!result || typeof result !== 'object') {\n return null;\n }\n\n return result as GraphQLErrorResponse;\n}\n\nfunction getErrorCauseResponse(error: ErrorLike): GraphQLErrorResponse | null {\n if (!hasCause(error)) {\n return null;\n }\n\n const { cause } = error;\n const causeMessage = getErrorMessage(cause);\n\n if (causeMessage && isSchemaValidationMessage(causeMessage)) {\n return { message: causeMessage };\n }\n\n if (!cause || typeof cause !== 'object') {\n return null;\n }\n\n const { result } = cause as { result?: unknown };\n\n if (result && typeof result === 'object') {\n return result as GraphQLErrorResponse;\n }\n\n return null;\n}\n\nfunction isSchemaValidationError(error: unknown): error is GraphQLErrorItem & { message: string } {\n if (!error || typeof error !== 'object') {\n return false;\n }\n\n const { extensions, message } = error as GraphQLErrorItem;\n const code = extensions?.code;\n\n if (code === 'GRAPHQL_VALIDATION_FAILED' && typeof message === 'string') {\n return true;\n }\n\n return typeof message === 'string' && isSchemaValidationMessage(message);\n}\n\nfunction isSchemaValidationMessage(message: string): boolean {\n return (\n message.startsWith('Cannot query field ') ||\n message.startsWith('Unknown type ') ||\n message.startsWith('Cannot query field \"') ||\n message.includes('GRAPHQL_VALIDATION_FAILED')\n );\n}\n\nfunction isMissingCountStoreFieldMessage(message: string): boolean {\n return /Cannot query field \"[_A-Za-z][_0-9A-Za-z]*Total\" on type \"Query\"/.test(message);\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { ApolloClient, InMemoryCache, defaultDataIdFromObject, from, HttpLink } from '@apollo/client';\nimport type { ApolloLink } from '@apollo/client';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { CombinedGraphQLErrors, CombinedProtocolErrors } from '@apollo/client/errors';\nimport { getGraphQLSchemaMismatchMessage, getServerError, parseErrorBody } from './error-utils';\nimport { useConfig } from '../core/config/config-context';\nimport React, { createContext, useContext, useMemo, useState } from 'react';\n\nconst ApolloProviderCompat = ApolloProvider as unknown as React.ComponentType<{\n children?: React.ReactNode;\n client: ApolloClient;\n}>;\n\ntype GraphQLErrorContextValue = {\n schemaErrorMessage: string | null;\n setSchemaErrorMessage: React.Dispatch<React.SetStateAction<string | null>>;\n};\n\nconst GraphQLErrorContext = createContext<GraphQLErrorContextValue | undefined>(undefined);\n\nfunction useGraphQLError(): GraphQLErrorContextValue {\n const ctx = useContext(GraphQLErrorContext);\n\n if (!ctx) {\n throw new Error('useGraphQLError must be used within GraphQLProvider');\n }\n\n return ctx;\n}\n\n/**\n * Context flag for operations the user writes themselves (the Graph app's\n * Query view): any error there, a mismatch or a 400, is a typo, not a\n * deployment that drifted from the local schema, so it must not raise the\n * schema banner. The caller shows the error itself.\n */\nexport const USER_QUERY_CONTEXT = { userQuery: true } as const;\n\nfunction createErrorLink(setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return new ErrorLink(({ error, operation }) => {\n if (operation.getContext().userQuery === true) {\n return;\n }\n\n const schemaMismatchMessage = getGraphQLSchemaMismatchMessage(error);\n\n if (schemaMismatchMessage) {\n setSchemaErrorMessage(schemaMismatchMessage);\n\n return;\n }\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }) => {\n console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);\n });\n } else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }) => {\n console.warn(`[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(extensions)}`);\n });\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode === 400) {\n const responseBody = parseErrorBody<Record<string, unknown>>(serverError.bodyText);\n let message: string | null = null;\n\n if (responseBody && typeof responseBody === 'object') {\n const {\n error: responseError,\n errors,\n message: responseMessage,\n } = responseBody as {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n };\n\n if (typeof responseMessage === 'string') {\n message = responseMessage;\n } else if (Array.isArray(errors)) {\n const [firstError] = errors as { message?: unknown }[];\n\n if (firstError && typeof firstError.message === 'string') {\n const { message: firstErrorMessage } = firstError;\n message = firstErrorMessage;\n }\n } else if (typeof responseError === 'string') {\n message = responseError;\n } else {\n message = JSON.stringify(responseBody);\n }\n } else {\n message = serverError.bodyText;\n }\n\n setSchemaErrorMessage(\n message ?? 'There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.'\n );\n }\n\n if (serverError) {\n console.warn(`[Network error]: ${serverError.message}`);\n\n return;\n }\n\n if (error) {\n console.warn(`[Network error]: ${error.message}`);\n }\n });\n}\n\nfunction additiveLink(currentProjectId: string, setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return from([\n createErrorLink(setSchemaErrorMessage),\n new HttpLink({ uri: `/api/flexkit/${currentProjectId}/graphql` }),\n ]);\n}\n\nfunction client(\n currentProjectId: string | undefined,\n setSchemaErrorMessage: (msg: string | null) => void\n): ApolloClient {\n return new ApolloClient({\n link: additiveLink(currentProjectId ?? '', setSchemaErrorMessage),\n cache: new InMemoryCache({\n dataIdFromObject: (responseObject) => {\n return responseObject._id ? (responseObject._id as string) : defaultDataIdFromObject(responseObject);\n },\n }),\n });\n}\n\nexport function GraphQLProvider({ children }: { children: React.ReactNode }): JSX.Element {\n const { currentProjectId } = useConfig();\n const [schemaErrorMessage, setSchemaErrorMessage] = useState<string | null>(null);\n const ctx = useMemo(() => ({ schemaErrorMessage, setSchemaErrorMessage }), [schemaErrorMessage]);\n const apolloClient = useMemo(() => client(currentProjectId, setSchemaErrorMessage), [currentProjectId]);\n\n return (\n <GraphQLErrorContext.Provider value={ctx}>\n <ApolloProviderCompat client={apolloClient}>{children}</ApolloProviderCompat>\n </GraphQLErrorContext.Provider>\n );\n}\n\nexport { useGraphQLError };\n","'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, JSX, ReactNode } from 'react';\nimport { props, uniqBy } from 'ramda';\nimport type {\n Action,\n ActionAddEntity,\n ActionAlertDialog,\n ActionDeleteEntity,\n ActionEditEntity,\n ActionEditRelationship,\n} from './types';\n\nconst ActionsContext = createContext<Action[] | []>([]);\nconst EntityDispatchContext = createContext<Dispatch<Action>>(() => undefined);\n\nfunction actionsReducer(actions: Action[], action: Action): Action[] {\n const actionType = action.type;\n\n if (!action._id) {\n action._id = Date.now().toString();\n }\n\n switch (actionType) {\n case 'DeleteEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionDeleteEntity[]), action]);\n }\n case 'AddEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAddEntity[]), action]);\n }\n case 'EditEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditEntity[]), action]);\n }\n case 'EditRelationship': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditRelationship[]), action]);\n }\n case 'AlertDialog': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAlertDialog[]), action]);\n }\n case 'Dismiss': {\n return actions.filter((item) => item._id !== action._id);\n }\n default: {\n throw Error(`Unknown action: ${actionType as string}`);\n }\n }\n}\n\nfunction ActionsProvider({ children }: { children: ReactNode }): JSX.Element {\n const [entityActions, dispatchEntityActions] = useReducer(actionsReducer, []);\n\n return (\n <ActionsContext.Provider value={entityActions}>\n <EntityDispatchContext.Provider value={dispatchEntityActions}>{children}</EntityDispatchContext.Provider>\n </ActionsContext.Provider>\n );\n}\n\nfunction useActions(): Action[] {\n return useContext(ActionsContext);\n}\n\nfunction useDispatch(): Dispatch<Action> {\n return useContext(EntityDispatchContext);\n}\n\nexport { ActionsProvider, useActions, useDispatch };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphql-client/error-utils.ts","../src/graphql-client/graphql-context.tsx","../src/entities/actions-context.tsx"],"names":["hasCause","error","getServerError","ServerError","possibleServerError","getErrorMessage","message","parseErrorBody","bodyText","getGraphQLSchemaMismatchMessage","messages","getGraphQLValidationMessages","isMissingCountStoreFieldMessage","isMissingGraphQLFieldError","fieldName","CombinedGraphQLErrors","isSchemaValidationError","directMessage","isSchemaValidationMessage","serverError","responseBody","getServerErrorResult","getErrorCauseResponse","item","result","cause","causeMessage","extensions","ApolloProviderCompat","ApolloProvider","GraphQLErrorContext","createContext","useGraphQLError","ctx","useContext","USER_QUERY_CONTEXT","createErrorLink","setSchemaErrorMessage","ErrorLink","operation","schemaMismatchMessage","locations","path","CombinedProtocolErrors","responseError","errors","responseMessage","firstError","firstErrorMessage","additiveLink","currentProjectId","from","HttpLink","client","ApolloClient","InMemoryCache","responseObject","defaultDataIdFromObject","GraphQLProvider","children","useConfig","schemaErrorMessage","useState","useMemo","apolloClient","jsx","ActionsContext","EntityDispatchContext","actionsReducer","actions","action","actionType","uniqBy","props","ActionsProvider","entityActions","dispatchEntityActions","useReducer","useActions","useDispatch"],"mappings":"4eAsBA,SAASA,CAAAA,CAASC,EAA2C,CAC3D,OAAKA,EAIE,OAAA,GAAYA,CAAAA,CAHV,KAIX,CAEO,SAASC,CAAAA,CAAeD,CAAAA,CAAuC,CACpE,GAAI,CAACA,CAAAA,CACH,OAAO,IAAA,CAGT,GAAIE,YAAY,EAAA,CAAGF,CAAK,EACtB,OAAOA,CAAAA,CAGT,GAAID,CAAAA,CAASC,CAAK,CAAA,CAAG,CACnB,IAAMG,CAAAA,CAAsBH,CAAAA,CAAM,KAAA,CAElC,GAAIE,YAAY,EAAA,CAAGC,CAAmB,CAAA,CACpC,OAAOA,CAEX,CAEA,OAAO,IACT,CAEA,SAASC,EAAgBJ,CAAAA,CAA+B,CACtD,GAAI,CAACA,GAAS,OAAOA,CAAAA,EAAU,QAAA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K,CAAC,CAAA,CAAG,CAAC,GAAIJ,CAAAA,CAAgCC,CAAM,CAAC,EAE9F,KAAK,kBAAA,CACH,OAAOE,MAAAA,CAAOC,KAAAA,CAAM,CAAC,MAAA,CAAkB,KAAK,CAAC,CAAA,CAAG,CAAC,GAAIJ,EAAsCC,CAAM,CAAC,EAEpG,KAAK,aAAA,CACH,OAAOE,MAAAA,CAAOC,KAAAA,CAAM,CAAC,MAAA,CAAkB,KAAK,CAAC,EAAG,CAAC,GAAIJ,EAAiCC,CAAM,CAAC,EAE/F,KAAK,SAAA,CACH,OAAOD,CAAAA,CAAQ,MAAA,CAAQ9C,CAAAA,EAASA,EAAK,GAAA,GAAQ+C,CAAAA,CAAO,GAAG,CAAA,CAEzD,QACE,MAAM,KAAA,CAAM,CAAA,gBAAA,EAAmBC,CAAoB,CAAA,CAAE,CAEzD,CACF,CAEA,SAASG,EAAAA,CAAgB,CAAE,QAAA,CAAAf,CAAS,EAAyC,CAC3E,GAAM,CAACgB,CAAAA,CAAeC,CAAqB,CAAA,CAAIC,WAAWT,CAAAA,CAAgB,EAAE,CAAA,CAE5E,OACEH,IAACC,CAAAA,CAAe,QAAA,CAAf,CAAwB,KAAA,CAAOS,CAAAA,CAC9B,QAAA,CAAAV,IAACE,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOS,CAAAA,CAAwB,SAAAjB,CAAAA,CAAS,CAAA,CAC1E,CAEJ,CAEA,SAASmB,EAAAA,EAAuB,CAC9B,OAAO5C,UAAAA,CAAWgC,CAAc,CAClC,CAEA,SAASa,IAAgC,CACvC,OAAO7C,UAAAA,CAAWiC,CAAqB,CACzC","file":"chunk-VR3LFFJ3.js","sourcesContent":["import type { ErrorLike } from '@apollo/client';\nimport { CombinedGraphQLErrors, ServerError } from '@apollo/client/errors';\n\ntype ErrorWithCause = ErrorLike & { cause?: unknown };\ntype ErrorWithMessage = {\n message?: unknown;\n};\ntype ServerErrorWithResult = ServerError & {\n result?: unknown;\n};\ntype GraphQLErrorResponse = {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n};\ntype GraphQLErrorItem = {\n extensions?: {\n code?: unknown;\n };\n message?: unknown;\n};\n\nfunction hasCause(error: ErrorLike): error is ErrorWithCause {\n if (!error) {\n return false;\n }\n\n return 'cause' in (error as ErrorWithCause);\n}\n\nexport function getServerError(error?: ErrorLike): ServerError | null {\n if (!error) {\n return null;\n }\n\n if (ServerError.is(error)) {\n return error;\n }\n\n if (hasCause(error)) {\n const possibleServerError = error.cause;\n\n if (ServerError.is(possibleServerError)) {\n return possibleServerError;\n }\n }\n\n return null;\n}\n\nfunction getErrorMessage(error: unknown): string | null {\n if (!error || typeof error !== 'object') {\n return null;\n }\n\n const { message } = error as ErrorWithMessage;\n\n return typeof message === 'string' ? message : null;\n}\n\nexport function parseErrorBody<T>(bodyText: string | undefined): T | null {\n if (!bodyText) {\n return null;\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch {\n return null;\n }\n}\n\nexport function getGraphQLSchemaMismatchMessage(error?: ErrorLike): string | null {\n if (!error) {\n return null;\n }\n\n const messages = getGraphQLValidationMessages(error).filter((message) => !isMissingCountStoreFieldMessage(message));\n\n if (messages.length === 0) {\n return null;\n }\n\n return [\n 'The deployed schema is out of sync with your local Flexkit schema.',\n 'Run `flexkit deploy` using the CLI to apply your latest schema changes.',\n ...messages.map((message) => `- ${message}`),\n ].join('\\n');\n}\n\nexport function isMissingGraphQLFieldError(error: ErrorLike | undefined, fieldName: string): boolean {\n if (!error) {\n return false;\n }\n\n return getGraphQLValidationMessages(error).some((message) => {\n return message.includes(`Cannot query field \"${fieldName}\"`);\n });\n}\n\nfunction getGraphQLValidationMessages(error: ErrorLike): string[] {\n if (CombinedGraphQLErrors.is(error)) {\n return error.errors.filter(isSchemaValidationError).map(({ message }) => message);\n }\n\n const directMessage = getErrorMessage(error);\n\n if (directMessage && isSchemaValidationMessage(directMessage)) {\n return [directMessage];\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode !== 400) {\n return [];\n }\n\n const responseBody =\n parseErrorBody<GraphQLErrorResponse>(serverError.bodyText) ??\n getServerErrorResult(serverError) ??\n getErrorCauseResponse(error);\n\n if (!responseBody) {\n return [];\n }\n\n if (Array.isArray(responseBody.errors)) {\n return responseBody.errors.filter(isSchemaValidationError).map((item) => item.message);\n }\n\n if (typeof responseBody.message === 'string' && isSchemaValidationMessage(responseBody.message)) {\n return [responseBody.message];\n }\n\n if (typeof responseBody.error === 'string' && isSchemaValidationMessage(responseBody.error)) {\n return [responseBody.error];\n }\n\n return [];\n}\n\nfunction getServerErrorResult(serverError: ServerError): GraphQLErrorResponse | null {\n const { result } = serverError as ServerErrorWithResult;\n\n if (!result || typeof result !== 'object') {\n return null;\n }\n\n return result as GraphQLErrorResponse;\n}\n\nfunction getErrorCauseResponse(error: ErrorLike): GraphQLErrorResponse | null {\n if (!hasCause(error)) {\n return null;\n }\n\n const { cause } = error;\n const causeMessage = getErrorMessage(cause);\n\n if (causeMessage && isSchemaValidationMessage(causeMessage)) {\n return { message: causeMessage };\n }\n\n if (!cause || typeof cause !== 'object') {\n return null;\n }\n\n const { result } = cause as { result?: unknown };\n\n if (result && typeof result === 'object') {\n return result as GraphQLErrorResponse;\n }\n\n return null;\n}\n\nfunction isSchemaValidationError(error: unknown): error is GraphQLErrorItem & { message: string } {\n if (!error || typeof error !== 'object') {\n return false;\n }\n\n const { extensions, message } = error as GraphQLErrorItem;\n const code = extensions?.code;\n\n if (code === 'GRAPHQL_VALIDATION_FAILED' && typeof message === 'string') {\n return true;\n }\n\n return typeof message === 'string' && isSchemaValidationMessage(message);\n}\n\nfunction isSchemaValidationMessage(message: string): boolean {\n return (\n message.startsWith('Cannot query field ') ||\n message.startsWith('Unknown type ') ||\n message.startsWith('Cannot query field \"') ||\n message.includes('GRAPHQL_VALIDATION_FAILED')\n );\n}\n\nfunction isMissingCountStoreFieldMessage(message: string): boolean {\n return /Cannot query field \"[_A-Za-z][_0-9A-Za-z]*Total\" on type \"Query\"/.test(message);\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { ApolloClient, InMemoryCache, defaultDataIdFromObject, from, HttpLink } from '@apollo/client';\nimport type { ApolloLink } from '@apollo/client';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { CombinedGraphQLErrors, CombinedProtocolErrors } from '@apollo/client/errors';\nimport { getGraphQLSchemaMismatchMessage, getServerError, parseErrorBody } from './error-utils';\nimport { useConfig } from '../core/config/config-context';\nimport React, { createContext, useContext, useMemo, useState } from 'react';\n\nconst ApolloProviderCompat = ApolloProvider as unknown as React.ComponentType<{\n children?: React.ReactNode;\n client: ApolloClient;\n}>;\n\ntype GraphQLErrorContextValue = {\n schemaErrorMessage: string | null;\n setSchemaErrorMessage: React.Dispatch<React.SetStateAction<string | null>>;\n};\n\nconst GraphQLErrorContext = createContext<GraphQLErrorContextValue | undefined>(undefined);\n\nfunction useGraphQLError(): GraphQLErrorContextValue {\n const ctx = useContext(GraphQLErrorContext);\n\n if (!ctx) {\n throw new Error('useGraphQLError must be used within GraphQLProvider');\n }\n\n return ctx;\n}\n\n/**\n * Context flag for operations the user writes themselves (the Graph app's\n * Query view): any error there, a mismatch or a 400, is a typo, not a\n * deployment that drifted from the local schema, so it must not raise the\n * schema banner. The caller shows the error itself.\n */\nexport const USER_QUERY_CONTEXT = { userQuery: true } as const;\n\nfunction createErrorLink(setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return new ErrorLink(({ error, operation }) => {\n if (operation.getContext().userQuery === true) {\n return;\n }\n\n const schemaMismatchMessage = getGraphQLSchemaMismatchMessage(error);\n\n if (schemaMismatchMessage) {\n setSchemaErrorMessage(schemaMismatchMessage);\n\n return;\n }\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }) => {\n console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);\n });\n } else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }) => {\n console.warn(`[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(extensions)}`);\n });\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode === 400) {\n const responseBody = parseErrorBody<Record<string, unknown>>(serverError.bodyText);\n let message: string | null = null;\n\n if (responseBody && typeof responseBody === 'object') {\n const {\n error: responseError,\n errors,\n message: responseMessage,\n } = responseBody as {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n };\n\n if (typeof responseMessage === 'string') {\n message = responseMessage;\n } else if (Array.isArray(errors)) {\n const [firstError] = errors as { message?: unknown }[];\n\n if (firstError && typeof firstError.message === 'string') {\n const { message: firstErrorMessage } = firstError;\n message = firstErrorMessage;\n }\n } else if (typeof responseError === 'string') {\n message = responseError;\n } else {\n message = JSON.stringify(responseBody);\n }\n } else {\n message = serverError.bodyText;\n }\n\n setSchemaErrorMessage(\n message ?? 'There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.'\n );\n }\n\n if (serverError) {\n console.warn(`[Network error]: ${serverError.message}`);\n\n return;\n }\n\n if (error) {\n console.warn(`[Network error]: ${error.message}`);\n }\n });\n}\n\nfunction additiveLink(currentProjectId: string, setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return from([\n createErrorLink(setSchemaErrorMessage),\n new HttpLink({ uri: `/api/flexkit/${currentProjectId}/graphql` }),\n ]);\n}\n\nfunction client(\n currentProjectId: string | undefined,\n setSchemaErrorMessage: (msg: string | null) => void\n): ApolloClient {\n return new ApolloClient({\n link: additiveLink(currentProjectId ?? '', setSchemaErrorMessage),\n cache: new InMemoryCache({\n dataIdFromObject: (responseObject) => {\n return responseObject._id ? (responseObject._id as string) : defaultDataIdFromObject(responseObject);\n },\n }),\n });\n}\n\nexport function GraphQLProvider({ children }: { children: React.ReactNode }): JSX.Element {\n const { currentProjectId } = useConfig();\n const [schemaErrorMessage, setSchemaErrorMessage] = useState<string | null>(null);\n const ctx = useMemo(() => ({ schemaErrorMessage, setSchemaErrorMessage }), [schemaErrorMessage]);\n const apolloClient = useMemo(() => client(currentProjectId, setSchemaErrorMessage), [currentProjectId]);\n\n return (\n <GraphQLErrorContext.Provider value={ctx}>\n <ApolloProviderCompat client={apolloClient}>{children}</ApolloProviderCompat>\n </GraphQLErrorContext.Provider>\n );\n}\n\nexport { useGraphQLError };\n","'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, JSX, ReactNode } from 'react';\nimport { props, uniqBy } from 'ramda';\nimport type {\n Action,\n ActionAddEntity,\n ActionAlertDialog,\n ActionDeleteEntity,\n ActionEditEntity,\n ActionEditRelationship,\n} from './types';\n\nconst ActionsContext = createContext<Action[] | []>([]);\nconst EntityDispatchContext = createContext<Dispatch<Action>>(() => undefined);\n\nfunction actionsReducer(actions: Action[], action: Action): Action[] {\n const actionType = action.type;\n\n if (!action._id) {\n action._id = Date.now().toString();\n }\n\n switch (actionType) {\n case 'DeleteEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionDeleteEntity[]), action]);\n }\n case 'AddEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAddEntity[]), action]);\n }\n case 'EditEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditEntity[]), action]);\n }\n case 'EditRelationship': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditRelationship[]), action]);\n }\n case 'AlertDialog': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAlertDialog[]), action]);\n }\n case 'Dismiss': {\n return actions.filter((item) => item._id !== action._id);\n }\n default: {\n throw Error(`Unknown action: ${actionType as string}`);\n }\n }\n}\n\nfunction ActionsProvider({ children }: { children: ReactNode }): JSX.Element {\n const [entityActions, dispatchEntityActions] = useReducer(actionsReducer, []);\n\n return (\n <ActionsContext.Provider value={entityActions}>\n <EntityDispatchContext.Provider value={dispatchEntityActions}>{children}</EntityDispatchContext.Provider>\n </ActionsContext.Provider>\n );\n}\n\nfunction useActions(): Action[] {\n return useContext(ActionsContext);\n}\n\nfunction useDispatch(): Dispatch<Action> {\n return useContext(EntityDispatchContext);\n}\n\nexport { ActionsProvider, useActions, useDispatch };\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {e,c,b,a,g,h as h$1,m,k as k$2,n}from'./chunk-IJECATW3.js';import {e as e$3}from'./chunk-CCVE7GGO.js';import {b as b$2}from'./chunk-DSLPTDZX.js';import {j as j$1}from'./chunk-4OGLWOO3.js';import {c as c$4}from'./chunk-DSZJXMN5.js';import {t,s,u,q as q$2,v,k as k$1,i,o as o$1,r as r$1,p as p$2}from'./chunk-7KLXWCDS.js';import {s as s$3,b as b$5}from'./chunk-GORBKX24.js';import {f}from'./chunk-INZZOKRC.js';import {ja,o,p as p$1,q as q$1,r,s as s$2,t as t$3,ma}from'./chunk-RULCANNM.js';import {t as t$1}from'./chunk-A4DPLZZF.js';import {b as b$4}from'./chunk-G5N6HEPW.js';import {b as b$1,c as c$3,e as e$2,f as f$1,g as g$1,h,j}from'./chunk-5JUG4BEF.js';import {k,p,q,s as s$1,t as t$2}from'./chunk-S7Z6KKIN.js';import {a as a$1,b as b$3,c as c$2,e as e$1}from'./chunk-N33S7BSG.js';import {c as c$1}from'./chunk-X3SHNHHM.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$3,{children:[jsx(c$2,{asChild:true,children:jsx(c$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,onAttached:o,onOpenChange:a,open:s,projectId:u,target:r,targetLabel:c$1}){let[p$1,h]=useState(""),m$1=useDeferredValue(p$1.trim()),[y,f]=useState(null),b$1=(k,K)=>!s||K&&!K.hasMore?null:c(u).sources({limit:Be,offset:k*Be,search:m$1||void 0}),{data:v,error:w,isLoading:x,setSize:i$1,size:d}=Qe(b$1,b,{keepPreviousData:true}),g=useMemo(()=>r$1(v?.flatMap(k=>k.sources)??[],l),[l,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);ma.success(K.linked?`Attached "${k.title}".`:`"${k.title}" was already attached.`),o(k),a(!1);}catch(K){ma.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$1?"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,{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(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$1(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(k,{open:s,onOpenChange:a,children:jsxs(p,{className:"fk:sm:max-w-lg",children:[jsxs(q,{children:[jsx(s$1,{children:"Attach a document"}),jsx(t$2,{children:r.recordId===void 0?`Documents attached to every ${c$1} are searched before the rest of Knowledge when a question is about one of them, or about ${c$1} in general.`:`Documents attached to ${c$1} 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(b$4,{"aria-label":"Search documents",autoFocus:true,className:"fk:pl-8",placeholder:"Search documents by title",value:p$1,onChange:k=>h(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,{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(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$2=!!r&&s(n),{data:p,error:h}=H(o&&c$2?c(o).entitySources(n):null,b);if(!l||!o||!r||!c$2||h instanceof a&&h.status===404)return null;let m=p?.sources.length??0;return jsxs(Fragment,{children:[jsxs(c$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$1,{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,entityName:o,onOpenChange:a,open:s,projectId:u}){let r=b$2(),[c$2,p$1]=useState(false),[h,m]=useState(null),{data:y,error:f,isLoading:b$3,mutate:v}=H(c(u).entitySources(o),b),w=y?.sources??[],x=useMemo(()=>({entity:o}),[o]);async function i(g$1){m(g$1.id);try{await n.unlinkSource(g$1.id,x),ma.success(`"${g$1.title}" no longer applies to every ${l}.`),await v({sources:w.filter(L=>L.id!==g$1.id)},{revalidate:!1}),g();}catch(L){ma.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$3&&!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," 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,", or about ",l," in general."]}):d=jsx(re,{projectId:u,sources:w,renderAction:g=>r?jsx(fe,{disabled:h!==null,label:`Detach ${g.title}`,onClick:()=>{i(g);}}):null}),jsx(k,{open:s,onOpenChange:a,children:jsxs(p,{className:"fk:sm:max-w-lg","data-knowledge-entity-dialog":true,children:[jsxs(q,{children:[jsxs(s$1,{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(BookOpenTextIcon,{className:"fk:size-4 fk:text-muted-foreground"}),"Knowledge for every ",l,y?jsx(b$1,{className:"fk:corner-squircle",variant:"outline",children:w.length}):null]}),jsxs(t$2,{children:["Documents attached here apply to every ",l,"; 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(ja,{disabled:!r,children:jsxs(c$1,{disabled:!r,size:"sm",variant:"outline",onClick:()=>p$1(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,onAttached:g$1=>{v({sources:w.some(L=>L.id===g$1.id)?w:[...w,g$1]},{revalidate:false}),g();},onOpenChange:p$1})]})})}function bt({entityName:n,recordId:l,recordLabel:o$1}){let{api:a$2,projectId:s$1}=e(),{currentProject:u$1}=f(),r=b$2(),[c$2,p]=useState(false),[h,m]=useState(false),[y,f$1]=useState(null),b$3=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$3):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$3),ma.success(`Detached "${N.title}".`),await L({sources:C.filter($=>$.id!==N.id),inherited:A},{revalidate:!1}),g();}catch($){ma.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?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(o,{className:`fk:z-10 fk:flex fk:shrink-0 fk:flex-col fk:border-t fk:bg-background ${c$2?"fk:h-1/2":""}`,"data-knowledge-record-panel":true,open:c$2,onOpenChange:p,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(p$1,{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$2?"fk:rotate-90":""}`}),jsx(BookOpenTextIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}),"Knowledge",i?jsx(b$1,{className:"fk:corner-squircle",variant:"outline",children:C.length+A.length}):null]})}),c$2?jsx(ja,{disabled:!r,children:jsxs(c$1,{disabled:!r,size:"sm",variant:"outline",onClick:()=>m(true),children:[jsx(PaperclipIcon,{}),"Attach document"]})}):null]}),jsx(q$1,{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$3,targetLabel:o$1||`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$4(),s=n.links.map(r=>r.recordId),{data:u}=e$3({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=s$3(o,n.group.entityPlural),s=b$5(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$1();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$2(),[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$2(m),[m]);async function b$3(i){u$1(`${i.entity}:${i.recordId}`);try{await n.unlinkSource(o.id,{entity:i.entity,recordId:i.recordId}),ma.success("Detached."),await h({links:m.filter(d=>d.entity!==i.entity||d.recordId!==i.recordId),entities:y},{revalidate:!1}),g();}catch(d){ma.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}),ma.success("Detached."),await h({links:m,entities:y.filter(d=>d.entity!==i.entity)},{revalidate:!1}),g();}catch(d){ma.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});ma.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){ma.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$3(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$1,{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,isLoading:a,onAttach:s,onDetach:u$1}){let{currentProject:r$1}=f(),c=useMemo(()=>r$1?.schema??[],[r$1]),[p,h$1]=useState(false),m=useMemo(()=>v(c,o),[o,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.length>0?jsx(b$1,{className:"fk:corner-squircle",variant:"outline",children:o.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.map(f=>{let b=y(f);return jsxs(b$1,{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$3,{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$1(f),children:jsx(XIcon,{className:"fk:size-3"})})}),jsxs(e$1,{children:["No longer apply to every ",b]})]}):null]},f.entity)}),jsxs(r,{open:p,onOpenChange:h$1,children:[jsx(ja,{disabled:!l,children:jsx(s$2,{asChild:true,children:jsxs(c$1,{className:"fk:h-7",disabled:!l||m.length===0,size:"sm",variant:"outline",children:[jsx(PlusIcon,{}),"Add entity type"]})})}),jsx(t$3,{align:"start",className:"fk:w-64 fk:p-0",children:jsxs(c$3,{children:[jsx(e$2,{placeholder:"Search entity types"}),jsxs(f$1,{children:[jsx(g$1,{children:"No entity type matches."}),jsx(h,{children:m.map(f=>jsx(j,{keywords:[u(f),f.name,f.plural],value:f.name,onSelect:()=>{h$1(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-WYVXSLB7.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {e,c,b,a,g,h as h$1,m,k as k$2,n}from'./chunk-DUS2CRB3.js';import {e as e$3}from'./chunk-PR3MTHFM.js';import {b as b$2}from'./chunk-DSLPTDZX.js';import {j as j$1}from'./chunk-VR3LFFJ3.js';import {c as c$4}from'./chunk-DQ2OVNOB.js';import {t,s,u,q as q$2,v,k as k$1,i,o as o$1,r as r$1,p as p$2}from'./chunk-7KLXWCDS.js';import {s as s$3,b as b$5}from'./chunk-SAVZBVP5.js';import {f}from'./chunk-TP6QGIJH.js';import {ja,o,p as p$1,q as q$1,r,s as s$2,t as t$3,ma}from'./chunk-RULCANNM.js';import {t as t$1}from'./chunk-A4DPLZZF.js';import {b as b$4}from'./chunk-G5N6HEPW.js';import {b as b$1,c as c$3,e as e$2,f as f$1,g as g$1,h,j}from'./chunk-5JUG4BEF.js';import {k,p,q,s as s$1,t as t$2}from'./chunk-S7Z6KKIN.js';import {a as a$1,b as b$3,c as c$2,e as e$1}from'./chunk-N33S7BSG.js';import {c as c$1}from'./chunk-X3SHNHHM.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$3,{children:[jsx(c$2,{asChild:true,children:jsx(c$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,onAttached:o,onOpenChange:a,open:s,projectId:u,target:r,targetLabel:c$1}){let[p$1,h]=useState(""),m$1=useDeferredValue(p$1.trim()),[y,f]=useState(null),b$1=(k,K)=>!s||K&&!K.hasMore?null:c(u).sources({limit:Be,offset:k*Be,search:m$1||void 0}),{data:v,error:w,isLoading:x,setSize:i$1,size:d}=Qe(b$1,b,{keepPreviousData:true}),g=useMemo(()=>r$1(v?.flatMap(k=>k.sources)??[],l),[l,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);ma.success(K.linked?`Attached "${k.title}".`:`"${k.title}" was already attached.`),o(k),a(!1);}catch(K){ma.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$1?"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,{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(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$1(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(k,{open:s,onOpenChange:a,children:jsxs(p,{className:"fk:sm:max-w-lg",children:[jsxs(q,{children:[jsx(s$1,{children:"Attach a document"}),jsx(t$2,{children:r.recordId===void 0?`Documents attached to every ${c$1} are searched before the rest of Knowledge when a question is about one of them, or about ${c$1} in general.`:`Documents attached to ${c$1} 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(b$4,{"aria-label":"Search documents",autoFocus:true,className:"fk:pl-8",placeholder:"Search documents by title",value:p$1,onChange:k=>h(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,{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(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$2=!!r&&s(n),{data:p,error:h}=H(o&&c$2?c(o).entitySources(n):null,b);if(!l||!o||!r||!c$2||h instanceof a&&h.status===404)return null;let m=p?.sources.length??0;return jsxs(Fragment,{children:[jsxs(c$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$1,{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,entityName:o,onOpenChange:a,open:s,projectId:u}){let r=b$2(),[c$2,p$1]=useState(false),[h,m]=useState(null),{data:y,error:f,isLoading:b$3,mutate:v}=H(c(u).entitySources(o),b),w=y?.sources??[],x=useMemo(()=>({entity:o}),[o]);async function i(g$1){m(g$1.id);try{await n.unlinkSource(g$1.id,x),ma.success(`"${g$1.title}" no longer applies to every ${l}.`),await v({sources:w.filter(L=>L.id!==g$1.id)},{revalidate:!1}),g();}catch(L){ma.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$3&&!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," 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,", or about ",l," in general."]}):d=jsx(re,{projectId:u,sources:w,renderAction:g=>r?jsx(fe,{disabled:h!==null,label:`Detach ${g.title}`,onClick:()=>{i(g);}}):null}),jsx(k,{open:s,onOpenChange:a,children:jsxs(p,{className:"fk:sm:max-w-lg","data-knowledge-entity-dialog":true,children:[jsxs(q,{children:[jsxs(s$1,{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(BookOpenTextIcon,{className:"fk:size-4 fk:text-muted-foreground"}),"Knowledge for every ",l,y?jsx(b$1,{className:"fk:corner-squircle",variant:"outline",children:w.length}):null]}),jsxs(t$2,{children:["Documents attached here apply to every ",l,"; 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(ja,{disabled:!r,children:jsxs(c$1,{disabled:!r,size:"sm",variant:"outline",onClick:()=>p$1(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,onAttached:g$1=>{v({sources:w.some(L=>L.id===g$1.id)?w:[...w,g$1]},{revalidate:false}),g();},onOpenChange:p$1})]})})}function bt({entityName:n,recordId:l,recordLabel:o$1}){let{api:a$2,projectId:s$1}=e(),{currentProject:u$1}=f(),r=b$2(),[c$2,p]=useState(false),[h,m]=useState(false),[y,f$1]=useState(null),b$3=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$3):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$3),ma.success(`Detached "${N.title}".`),await L({sources:C.filter($=>$.id!==N.id),inherited:A},{revalidate:!1}),g();}catch($){ma.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?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(o,{className:`fk:z-10 fk:flex fk:shrink-0 fk:flex-col fk:border-t fk:bg-background ${c$2?"fk:h-1/2":""}`,"data-knowledge-record-panel":true,open:c$2,onOpenChange:p,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(p$1,{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$2?"fk:rotate-90":""}`}),jsx(BookOpenTextIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}),"Knowledge",i?jsx(b$1,{className:"fk:corner-squircle",variant:"outline",children:C.length+A.length}):null]})}),c$2?jsx(ja,{disabled:!r,children:jsxs(c$1,{disabled:!r,size:"sm",variant:"outline",onClick:()=>m(true),children:[jsx(PaperclipIcon,{}),"Attach document"]})}):null]}),jsx(q$1,{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$3,targetLabel:o$1||`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$4(),s=n.links.map(r=>r.recordId),{data:u}=e$3({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=s$3(o,n.group.entityPlural),s=b$5(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$1();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$2(),[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$2(m),[m]);async function b$3(i){u$1(`${i.entity}:${i.recordId}`);try{await n.unlinkSource(o.id,{entity:i.entity,recordId:i.recordId}),ma.success("Detached."),await h({links:m.filter(d=>d.entity!==i.entity||d.recordId!==i.recordId),entities:y},{revalidate:!1}),g();}catch(d){ma.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}),ma.success("Detached."),await h({links:m,entities:y.filter(d=>d.entity!==i.entity)},{revalidate:!1}),g();}catch(d){ma.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});ma.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){ma.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$3(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$1,{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,isLoading:a,onAttach:s,onDetach:u$1}){let{currentProject:r$1}=f(),c=useMemo(()=>r$1?.schema??[],[r$1]),[p,h$1]=useState(false),m=useMemo(()=>v(c,o),[o,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.length>0?jsx(b$1,{className:"fk:corner-squircle",variant:"outline",children:o.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.map(f=>{let b=y(f);return jsxs(b$1,{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$3,{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$1(f),children:jsx(XIcon,{className:"fk:size-3"})})}),jsxs(e$1,{children:["No longer apply to every ",b]})]}):null]},f.entity)}),jsxs(r,{open:p,onOpenChange:h$1,children:[jsx(ja,{disabled:!l,children:jsx(s$2,{asChild:true,children:jsxs(c$1,{className:"fk:h-7",disabled:!l||m.length===0,size:"sm",variant:"outline",children:[jsx(PlusIcon,{}),"Add entity type"]})})}),jsx(t$3,{align:"start",className:"fk:w-64 fk:p-0",children:jsxs(c$3,{children:[jsx(e$2,{placeholder:"Search entity types"}),jsxs(f$1,{children:[jsx(g$1,{children:"No entity type matches."}),jsx(h,{children:m.map(f=>jsx(j,{keywords:[u(f),f.name,f.plural],value:f.name,onSelect:()=>{h$1(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-WSXNYZQC.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-WSXNYZQC.js.map
|