@flexkit/studio 0.2.40 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-page-I2IFVZA3.js → chat-page-DM5R7DEJ.js} +3 -3
- package/dist/{chat-page-I2IFVZA3.js.map → chat-page-DM5R7DEJ.js.map} +1 -1
- package/dist/{chunk-L62VVHKS.js → chunk-2MNG5HBI.js} +2 -2
- package/dist/{chunk-L62VVHKS.js.map → chunk-2MNG5HBI.js.map} +1 -1
- package/dist/{chunk-4JG3OWQW.js → chunk-3DT7IQLS.js} +2 -2
- package/dist/{chunk-4JG3OWQW.js.map → chunk-3DT7IQLS.js.map} +1 -1
- package/dist/{chunk-NPO7ISWV.js → chunk-3V7VAQBP.js} +2 -2
- package/dist/{chunk-NPO7ISWV.js.map → chunk-3V7VAQBP.js.map} +1 -1
- package/dist/{chunk-LO37DY2Z.js → chunk-JHYLYOJJ.js} +2 -2
- package/dist/{chunk-LO37DY2Z.js.map → chunk-JHYLYOJJ.js.map} +1 -1
- package/dist/{chunk-GPMBBJHK.js → chunk-KGNQ6P6R.js} +3 -3
- package/dist/{chunk-GPMBBJHK.js.map → chunk-KGNQ6P6R.js.map} +1 -1
- package/dist/{chunk-X5QKLF63.js → chunk-KL2NENPM.js} +3 -3
- package/dist/{chunk-X5QKLF63.js.map → chunk-KL2NENPM.js.map} +1 -1
- package/dist/{chunk-HOAVEDVI.js → chunk-NHNJNPF5.js} +3 -3
- package/dist/{chunk-HOAVEDVI.js.map → chunk-NHNJNPF5.js.map} +1 -1
- package/dist/{chunk-E3KO5NGM.js → chunk-NS4FHGIC.js} +2 -2
- package/dist/{chunk-E3KO5NGM.js.map → chunk-NS4FHGIC.js.map} +1 -1
- package/dist/{chunk-NPMBADZL.js → chunk-NVQANITJ.js} +3 -3
- package/dist/{chunk-NPMBADZL.js.map → chunk-NVQANITJ.js.map} +1 -1
- package/dist/{chunk-2IJWBRN2.js → chunk-OXJJX6QV.js} +2 -2
- package/dist/{chunk-2IJWBRN2.js.map → chunk-OXJJX6QV.js.map} +1 -1
- package/dist/{chunk-DAXVPJJS.js → chunk-T7IAVZCX.js} +4 -4
- package/dist/{chunk-DAXVPJJS.js.map → chunk-T7IAVZCX.js.map} +1 -1
- package/dist/{chunk-GPTSQ2WH.js → chunk-TATNK4AH.js} +3 -3
- package/dist/{chunk-GPTSQ2WH.js.map → chunk-TATNK4AH.js.map} +1 -1
- package/dist/{chunk-HUG2NGZI.js → chunk-VS7RDMW2.js} +2 -2
- package/dist/{chunk-HUG2NGZI.js.map → chunk-VS7RDMW2.js.map} +1 -1
- package/dist/{chunk-53GVTCXC.js → chunk-VT476KKC.js} +3 -3
- package/dist/{chunk-53GVTCXC.js.map → chunk-VT476KKC.js.map} +1 -1
- package/dist/{chunk-DFOPVG7I.js → chunk-VUGISMZA.js} +2 -2
- package/dist/{chunk-DFOPVG7I.js.map → chunk-VUGISMZA.js.map} +1 -1
- package/dist/{chunk-CQS6AIOX.js → chunk-VXRA33F4.js} +2 -2
- package/dist/{chunk-CQS6AIOX.js.map → chunk-VXRA33F4.js.map} +1 -1
- package/dist/{chunk-LWI3HNJL.js → chunk-XRZBQA6H.js} +3 -3
- package/dist/{chunk-LWI3HNJL.js.map → chunk-XRZBQA6H.js.map} +1 -1
- package/dist/{chunk-Y7VBTUNI.js → chunk-YGG43LHF.js} +3 -3
- package/dist/{chunk-Y7VBTUNI.js.map → chunk-YGG43LHF.js.map} +1 -1
- package/dist/{entry-NCKQ45MI.js → entry-4OP3BASI.js} +2 -2
- package/dist/{entry-NCKQ45MI.js.map → entry-4OP3BASI.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/{list-VWN4IJYC.js → list-4XKSEBGT.js} +3 -3
- package/dist/{list-VWN4IJYC.js.map → list-4XKSEBGT.js.map} +1 -1
- package/dist/{list-UHHDZ3DM.js → list-KPKWXWZZ.js} +2 -2
- package/dist/{list-UHHDZ3DM.js.map → list-KPKWXWZZ.js.map} +1 -1
- package/dist/pages-JYXHLRSZ.js +5 -0
- package/dist/pages-JYXHLRSZ.js.map +1 -0
- package/dist/{plugin-pages-LLJPZJWL.js → plugin-pages-5PNAZGCO.js} +2 -2
- package/dist/{plugin-pages-LLJPZJWL.js.map → plugin-pages-5PNAZGCO.js.map} +1 -1
- package/dist/{project-selector-K3T6H77F.js → project-selector-6VHU5KVQ.js} +2 -2
- package/dist/{project-selector-K3T6H77F.js.map → project-selector-6VHU5KVQ.js.map} +1 -1
- package/dist/record-links-KRMGWWLU.js +2 -0
- package/dist/{record-links-CILZYRSE.js.map → record-links-KRMGWWLU.js.map} +1 -1
- package/dist/{root-PY5SBJ4F.js → root-4F6MS4T7.js} +3 -3
- package/dist/{root-PY5SBJ4F.js.map → root-4F6MS4T7.js.map} +1 -1
- package/dist/{root-XTF6EH63.js → root-7UPTEL7G.js} +3 -3
- package/dist/{root-XTF6EH63.js.map → root-7UPTEL7G.js.map} +1 -1
- package/dist/{root-ADEORVTL.js → root-HYB5RRH4.js} +2 -2
- package/dist/{root-ADEORVTL.js.map → root-HYB5RRH4.js.map} +1 -1
- package/dist/{root-LSBCX6AE.js → root-ILUM4ZHH.js} +2 -2
- package/dist/{root-LSBCX6AE.js.map → root-ILUM4ZHH.js.map} +1 -1
- package/dist/{root-CE6LNBBW.js → root-KYXGSM45.js} +3 -3
- package/dist/{root-CE6LNBBW.js.map → root-KYXGSM45.js.map} +1 -1
- package/dist/{root-Y3D2FTDR.js → root-WOUYFOQO.js} +2 -2
- package/dist/{root-Y3D2FTDR.js.map → root-WOUYFOQO.js.map} +1 -1
- package/dist/{search-MGY3OWZQ.js → search-HV4MXIKW.js} +2 -2
- package/dist/{search-MGY3OWZQ.js.map → search-HV4MXIKW.js.map} +1 -1
- package/dist/{skills-pages-7QYBKBSB.js → skills-pages-C4OOTCLS.js} +2 -2
- package/dist/{skills-pages-7QYBKBSB.js.map → skills-pages-C4OOTCLS.js.map} +1 -1
- package/dist/{source-M746FR3B.js → source-EGHZGVN4.js} +2 -2
- package/dist/{source-M746FR3B.js.map → source-EGHZGVN4.js.map} +1 -1
- package/package.json +5 -5
- package/dist/pages-LZEKCA4W.js +0 -5
- package/dist/pages-LZEKCA4W.js.map +0 -1
- package/dist/record-links-CILZYRSE.js +0 -2
|
@@ -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:l})=>{console.warn(`[GraphQL error]: Message: ${s}, Location: ${i}, Path: ${l}`);}):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:l,errors:g,message:m}=s;if(typeof m=="string")i=m;else if(Array.isArray(g)){let[p]=g;if(p&&typeof p.message=="string"){let{message:D}=p;i=D;}}else typeof l=="string"?i=l:i=JSON.stringify(s);}else i=o.bodyText;r(i?.trim()||"A request to the project did not match its schema. Reload the page, and contact support if it keeps happening.");}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-YGG43LHF.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 project schema changed since this page loaded, so some fields no longer match.","Reload the page to use the latest schema.",...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:l})=>{console.warn(`[GraphQL error]: Message: ${s}, Location: ${i}, Path: ${l}`);}):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:l,errors:g,message:m}=s;if(typeof m=="string")i=m;else if(Array.isArray(g)){let[p]=g;if(p&&typeof p.message=="string"){let{message:D}=p;i=D;}}else typeof l=="string"?i=l:i=JSON.stringify(s);}else i=o.bodyText;r(i?.trim()||"A request to the project did not match its schema. Reload the page, and contact support if it keeps happening.");}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-KL2NENPM.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-KL2NENPM.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,CAAS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AAAA,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-X5QKLF63.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 project schema changed since this page loaded, so some fields no longer match.',\n 'Reload the page to use the latest schema.',\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 // `||`: an empty 400 body leaves '' here, which would hide the alert.\n setSchemaErrorMessage(\n message?.trim() ||\n 'A request to the project did not match its schema. Reload the page, and contact support if it keeps happening.'\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,CAC7B,OAAO,KAGT,GAAM,CAAE,OAAA,CAAAK,CAAQ,EAAIL,CAAAA,CAEpB,OAAO,OAAOK,CAAAA,EAAY,SAAWA,CAAAA,CAAU,IACjD,CAEO,SAASC,EAAkBC,CAAAA,CAAwC,CACxE,GAAI,CAACA,EACH,OAAO,IAAA,CAGT,GAAI,CACF,OAAO,IAAA,CAAK,KAAA,CAAMA,CAAQ,CAC5B,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CAEO,SAASC,CAAAA,CAAgCR,CAAAA,CAAkC,CAChF,GAAI,CAACA,CAAAA,CACH,OAAO,IAAA,CAGT,IAAMS,EAAWC,CAAAA,CAA6BV,CAAK,EAAE,MAAA,CAAQK,CAAAA,EAAY,CAACM,CAAAA,CAAgCN,CAAO,CAAC,CAAA,CAElH,OAAII,CAAAA,CAAS,MAAA,GAAW,CAAA,CACf,IAAA,CAGF,CACL,oFAAA,CACA,2CAAA,CACA,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,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-KL2NENPM.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 project schema changed since this page loaded, so some fields no longer match.',\n 'Reload the page to use the latest schema.',\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 // `||`: an empty 400 body leaves '' here, which would hide the alert.\n setSchemaErrorMessage(\n message?.trim() ||\n 'A request to the project did not match its schema. Reload the page, and contact support if it keeps happening.'\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,4 +1,4 @@
|
|
|
1
|
-
import'./index.css';import {b,c}from'./chunk-
|
|
1
|
+
import'./index.css';import {b,c}from'./chunk-YGG43LHF.js';import {find,propEq,omit,pick,toPairs,uniq}from'ramda';function W(n){if(n?.attributes.length)return n.display?n.attributes.find(t=>t.name===n.display)??n.attributes[0]:n.attributes[0]}function _(n){return n.dataType==="asset"?"global":n.scope}var sn=25,bn=3,on=3,Sn=["id","string"],En=["date","datetime","duration","time"],Z=`_id
|
|
2
2
|
originalFilename
|
|
3
3
|
mimeType
|
|
4
4
|
path
|
|
@@ -374,5 +374,5 @@ ${m} ]
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
`}}var z=n=>n.charAt(0).toUpperCase()+n.slice(1);function U(n){let t=n.split(/[^0-9A-Za-z]+/).filter(Boolean).map(z).join("");return t?/^[A-Za-z_]/.test(t)?t:`Entity${t}`:"Entity"}function x(n,t){return t==="_assets"?b:find(propEq(t,"plural"))(n)}function ot(n,t,e){if(!n||typeof n!="object")return {};let i=x(e,t);if(!i)return {};let s=`update${z(t)}`,o=n[s];if(!o||typeof o!="object")return {};let r=o[t],u=Array.isArray(r)?r[0]:void 0;return !u||typeof u!="object"?{}:i.attributes.reduce((a,l)=>{if(_(l)!=="local")return a;let c=M(u[l.name])?._id;return typeof c!="string"||c.length===0?a:{...a,[l.name]:c}},{})}export{_ as a,W as b,sn as c,un as d,In as e,Q as f,K as g,Jn as h,Rn as i,Yn as j,Pn as k,nt as l,tt as m,et as n,rt as o,it as p,st as q,U as r,x as s,ot as t};//# sourceMappingURL=chunk-
|
|
378
|
-
//# sourceMappingURL=chunk-
|
|
377
|
+
`}}var z=n=>n.charAt(0).toUpperCase()+n.slice(1);function U(n){let t=n.split(/[^0-9A-Za-z]+/).filter(Boolean).map(z).join("");return t?/^[A-Za-z_]/.test(t)?t:`Entity${t}`:"Entity"}function x(n,t){return t==="_assets"?b:find(propEq(t,"plural"))(n)}function ot(n,t,e){if(!n||typeof n!="object")return {};let i=x(e,t);if(!i)return {};let s=`update${z(t)}`,o=n[s];if(!o||typeof o!="object")return {};let r=o[t],u=Array.isArray(r)?r[0]:void 0;return !u||typeof u!="object"?{}:i.attributes.reduce((a,l)=>{if(_(l)!=="local")return a;let c=M(u[l.name])?._id;return typeof c!="string"||c.length===0?a:{...a,[l.name]:c}},{})}export{_ as a,W as b,sn as c,un as d,In as e,Q as f,K as g,Jn as h,Rn as i,Yn as j,Pn as k,nt as l,tt as m,et as n,rt as o,it as p,st as q,U as r,x as s,ot as t};//# sourceMappingURL=chunk-NHNJNPF5.js.map
|
|
378
|
+
//# sourceMappingURL=chunk-NHNJNPF5.js.map
|