@collective-intelligence/external-apps-client-sdk-react 0.1.34 → 0.1.36
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 +105 -22
- package/dist/effect.d.ts +60 -0
- package/dist/effect.js +2 -0
- package/dist/index-6ra894v2.js +2 -0
- package/dist/index-bjd4xpqf.js +2 -0
- package/dist/index.d.ts +104 -925
- package/dist/index.js +1 -1
- package/dist/resources.d.ts +79 -337
- package/dist/resources.js +1 -1
- package/package.json +20 -6
- package/dist/index-m8zsc3k7.js +0 -49
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{__export,FederatedAuthError,realtimeTopicKey,EntityRuntimeProvider,createDelegatedEntitySource,defineEntity2,useEntityViewState2,useMemoryEntityViewState2,EntityTable2,EntityList2,EntityForm2}from"./index-m8zsc3k7.js";var exports_src={};__export(exports_src,{AgentPrompt:()=>AgentPrompt,AgentPromptPrimitive:()=>AgentPromptPrimitive,CollectiveIntelligenceLoginProvider:()=>CollectiveIntelligenceLoginProvider,CollectiveIntelligenceProvider:()=>CollectiveIntelligenceProvider,EntityForm:()=>EntityForm2,EntityList:()=>EntityList2,EntityTable:()=>EntityTable2,LoginButton:()=>LoginButton,LoginCallback:()=>LoginCallback,LoginCallbackPrimitive:()=>LoginCallbackPrimitive,RealtimeProvider:()=>RealtimeProvider,SessionGate:()=>SessionGate,clientSdkReactEntrypoint:()=>clientSdkReactEntrypoint,createDelegatedEntitySource:()=>createDelegatedEntitySource,createPromptKeyHandler:()=>createPromptKeyHandler,defineEntity:()=>defineEntity2,useAgentInvocation:()=>useAgentInvocation,useAgents:()=>useAgents,useAttachments:()=>useAttachments,useClientContext:()=>useClientContext,useCollectiveIntelligenceAuth:()=>useCollectiveIntelligenceAuth,useCollectiveIntelligenceClient:()=>useCollectiveIntelligenceClient,useEntityViewState:()=>useEntityViewState2,useKnowledge:()=>useKnowledge,useMemoryEntityViewState:()=>useMemoryEntityViewState2,useOrganizationClient:()=>useOrganizationClient,useRealtimeClient:()=>useRealtimeClient,useRealtimeTopic:()=>useRealtimeTopic,useRuns:()=>useRuns,useSession:()=>useSession,useSkills:()=>useSkills,useWorkflows:()=>useWorkflows});import{useCallback,useId,useState as useState2}from"react";import{QueryClient,QueryClientProvider}from"@tanstack/react-query";import{createContext,useContext,useMemo,useState}from"react";import{jsx}from"react/jsx-runtime";var ClientContext=createContext(null);var CollectiveIntelligenceProvider=(props)=>{const{clientFactory}=props;const[queryClient]=useState(()=>new QueryClient({defaultOptions:{mutations:{retry:false},queries:{retry:false}}}));const ownedClient=useMemo(()=>clientFactory===undefined?undefined:clientFactory(),[clientFactory]);const client=props.client??ownedClient;if(client===undefined){throw new TypeError("A client or clientFactory is required")}return jsx(ClientContext.Provider,{value:client,children:jsx(QueryClientProvider,{client:queryClient,children:props.entitySource===undefined?props.children:jsx(EntityRuntimeProvider,{source:props.entitySource,children:props.children})})})};var useCollectiveIntelligenceClient=()=>{const client=useContext(ClientContext);if(client===null){throw new Error("CollectiveIntelligenceProvider must wrap Collective Intelligence hooks")}return client};var useOrganizationClient=(organizationId)=>{const client=useCollectiveIntelligenceClient();return useMemo(()=>client.forOrganization(organizationId),[client,organizationId])};var useKnowledge=(organizationId)=>useOrganizationClient(organizationId).knowledge;var useAgents=(organizationId)=>useOrganizationClient(organizationId).agents;var useSkills=(organizationId)=>useOrganizationClient(organizationId).skills;var useWorkflows=(organizationId)=>useOrganizationClient(organizationId).workflows;var useRuns=(organizationId)=>useOrganizationClient(organizationId).runs;var useAttachments=(organizationId)=>useOrganizationClient(organizationId).attachments;var useClientContext=(organizationId)=>useOrganizationClient(organizationId).context;import{jsx as jsx2,jsxs}from"react/jsx-runtime";var ignoreSubmit=()=>false;var createPromptKeyHandler=(onSubmit)=>(event)=>{if(event.key==="Enter"&&!event.shiftKey&&!event.isComposing){event.preventDefault();onSubmit()}};var AgentPromptPrimitive=({autoFocus=false,className,components,id,label,onChange,onSubmit,pending,status,style,submitLabel="Send",value})=>{const Form=components?.Form??"form";const Label=components?.Label??"label";const Textarea=components?.Textarea??"textarea";const Button=components?.Button??"button";const Status=components?.Status??"div";const statusId=`${id}-status`;const submit=(event)=>{event.preventDefault();if(!pending){onSubmit()}};const onKeyDown=(event)=>{createPromptKeyHandler(pending?ignoreSubmit:onSubmit)({isComposing:event.nativeEvent.isComposing,key:event.key,preventDefault:()=>{event.preventDefault()},shiftKey:event.shiftKey})};return jsxs(Form,{className:["ci-agent-prompt",className].filter(Boolean).join(" "),onSubmit:submit,style,children:[jsx2(Label,{className:"ci-agent-prompt__label",htmlFor:id,children:label}),jsx2(Textarea,{"aria-describedby":statusId,autoFocus,className:"ci-agent-prompt__input",disabled:pending,id,onChange:(event)=>{onChange(event.currentTarget.value)},onKeyDown,value}),jsx2(Button,{className:"ci-agent-prompt__submit",disabled:pending||value.trim().length===0,type:"submit",children:submitLabel}),jsx2(Status,{"aria-live":"polite",className:"ci-agent-prompt__status",id:statusId,children:status})]})};var useAgentInvocation=(organizationId)=>{const{agents}=useOrganizationClient(organizationId);const[state,setState]=useState2({status:"idle"});const invoke=useCallback(async(input)=>{setState({status:"submitting"});try{const result=await agents.invoke(input);setState(result.ok?{result,status:"success"}:{result,status:"failure"});return result}catch(error){setState({error,status:"error"});throw error}},[agents]);return{invoke,reset:()=>{setState({status:"idle"})},state}};var invocationStatus=(state)=>{switch(state.status){case"submitting":{return"Sending"}case"success":{return"Request started"}case"failure":{return state.result.error.message}case"error":{return"Request failed"}case"idle":{return null}default:{return null}}};var EMPTY_AGENT_PROMPT_COMPONENTS={};var EMPTY_AGENT_PROMPT_STYLE={};var createDefaultIdempotencyKey=()=>globalThis.crypto.randomUUID();var AgentPrompt=({agentId,autoFocus=false,className="",components=EMPTY_AGENT_PROMPT_COMPONENTS,createIdempotencyKey=createDefaultIdempotencyKey,label="Message",onResult,organizationId,style=EMPTY_AGENT_PROMPT_STYLE,submitLabel="Send"})=>{const id=`ci-agent-prompt-${useId().replaceAll(":","")}`;const[value,setValue]=useState2("");const invocation=useAgentInvocation(organizationId);const submit=()=>{const prompt=value.trim();if(prompt.length===0||invocation.state.status==="submitting"){return}const submitInvocation=async()=>{try{const result=await invocation.invoke({agentId,idempotencyKey:createIdempotencyKey(),input:{prompt}});if(result.ok){setValue("")}onResult?.(result)}catch{}};submitInvocation()};return jsx2(AgentPromptPrimitive,{autoFocus,className,components,id,label,onChange:setValue,onSubmit:submit,pending:invocation.state.status==="submitting",status:invocationStatus(invocation.state),style,submitLabel,value})};import{createContext as createContext2,useCallback as useCallback2,useContext as useContext2,useEffect,useMemo as useMemo2,useSyncExternalStore}from"react";import{jsx as jsx3}from"react/jsx-runtime";var AuthContext=createContext2(null);var toFederatedAuthError=(error)=>new FederatedAuthError("authorization_failed",error.message);var unknownAuthError=()=>new FederatedAuthError("authorization_failed","Sign in failed");var CollectiveIntelligenceLoginProvider=(props)=>{const state=useSyncExternalStore(props.auth.subscribe,props.auth.getState,props.auth.getState);const contextValue=useMemo2(()=>({auth:props.auth,state}),[props.auth,state]);return jsx3(AuthContext.Provider,{value:contextValue,children:props.clientFactory===undefined?jsx3(CollectiveIntelligenceProvider,{client:props.client,entitySource:props.entitySource,children:props.children}):jsx3(CollectiveIntelligenceProvider,{clientFactory:props.clientFactory,entitySource:props.entitySource,children:props.children})})};var useCollectiveIntelligenceAuth=()=>{const value=useContext2(AuthContext);if(value===null){throw new Error("CollectiveIntelligenceLoginProvider must wrap authentication bindings")}return{...value,beginLogin:value.auth.beginLogin,completeLogin:value.auth.completeLogin,logout:value.auth.logout,reauthorize:value.auth.reauthorize}};var LoginButton=({children="Sign in with Collective Intelligence",className,components,disabled=false,onError,returnTo,style})=>{const{auth,state}=useCollectiveIntelligenceAuth();const Button=components?.Button??"button";const redirecting=state.status==="redirecting";const onClick=useCallback2((event)=>{event.preventDefault();const target=returnTo??globalThis.location.href;const begin=async()=>{try{await auth.beginLogin({returnTo:target})}catch(error){onError?.(error instanceof Error?toFederatedAuthError(error):unknownAuthError())}};begin()},[auth,onError,returnTo]);return jsx3(Button,{"aria-busy":redirecting,className:["ci-login-button",className].filter(Boolean).join(" "),disabled:disabled||redirecting,onClick,style,type:"button",children})};var callbackMessage=(state)=>{switch(state.status){case"authenticated":{return"Sign in complete"}case"error":{return state.error.message}case"expired":{return"Sign in expired"}case"anonymous":case"redirecting":{return"Completing sign in"}default:{return"Completing sign in"}}};var LoginCallbackPrimitive=({className,components,state,style})=>{const Status=components?.Status??"div";return jsx3(Status,{"aria-live":"polite",className:["ci-login-callback",className].filter(Boolean).join(" "),style,children:callbackMessage(state)})};var LoginCallback=({callbackUrl,onComplete,onError,...primitiveProps})=>{const{auth,state}=useCollectiveIntelligenceAuth();useEffect(()=>{const url=callbackUrl??globalThis.location.href;const complete=async()=>{try{const{returnTo}=await auth.completeLogin(url);onComplete?.(returnTo)}catch(error){onError?.(error instanceof Error?toFederatedAuthError(error):unknownAuthError())}};complete()},[auth,callbackUrl,onComplete,onError]);return jsx3(LoginCallbackPrimitive,{...primitiveProps,state})};var useSession=()=>{const{state}=useCollectiveIntelligenceAuth();return state};var SessionGate=({children,fallback=null})=>{const session=useSession();if(session.status!=="authenticated"){return fallback}return children};import{createContext as createContext3,useContext as useContext3,useEffect as useEffect2,useRef,useState as useState3}from"react";import{jsx as jsx4}from"react/jsx-runtime";var RealtimeContext=createContext3(null);var RealtimeProvider=({children,client})=>jsx4(RealtimeContext.Provider,{value:client,children});var useRealtimeClient=()=>{const client=useContext3(RealtimeContext);if(client===null){throw new Error("useRealtimeClient requires a RealtimeProvider")}return client};var useRealtimeTopic=(topic,onChanges)=>{const client=useRealtimeClient();const latest=useRef(onChanges);const key=topic===null?null:realtimeTopicKey(topic);const[subscribed,setSubscribed]=useState3({key,topic});if(subscribed.key!==key){setSubscribed({key,topic})}useEffect2(()=>{latest.current=onChanges});useEffect2(()=>subscribed.topic===null?undefined:client.subscribe(subscribed.topic,(changes)=>latest.current(changes)),[client,subscribed])};"use client";var clientSdkReactEntrypoint="react";"use client";var{AgentPrompt:AgentPrompt2,AgentPromptPrimitive:AgentPromptPrimitive2,CollectiveIntelligenceLoginProvider:CollectiveIntelligenceLoginProvider2,CollectiveIntelligenceProvider:CollectiveIntelligenceProvider2,LoginButton:LoginButton2,LoginCallback:LoginCallback2,LoginCallbackPrimitive:LoginCallbackPrimitive2,RealtimeProvider:RealtimeProvider2,SessionGate:SessionGate2,clientSdkReactEntrypoint:clientSdkReactEntrypoint2,createPromptKeyHandler:createPromptKeyHandler2,useAgents:useAgents2,useAttachments:useAttachments2,useClientContext:useClientContext2,useCollectiveIntelligenceAuth:useCollectiveIntelligenceAuth2,useCollectiveIntelligenceClient:useCollectiveIntelligenceClient2,useKnowledge:useKnowledge2,useOrganizationClient:useOrganizationClient2,useRealtimeClient:useRealtimeClient2,useRealtimeTopic:useRealtimeTopic2,useRuns:useRuns2,useSession:useSession2,useSkills:useSkills2,useWorkflows:useWorkflows2,useAgentInvocation:useAgentInvocation2}=exports_src;export{AgentPrompt2 as AgentPrompt,AgentPromptPrimitive2 as AgentPromptPrimitive,CollectiveIntelligenceLoginProvider2 as CollectiveIntelligenceLoginProvider,CollectiveIntelligenceProvider2 as CollectiveIntelligenceProvider,LoginButton2 as LoginButton,LoginCallback2 as LoginCallback,LoginCallbackPrimitive2 as LoginCallbackPrimitive,RealtimeProvider2 as RealtimeProvider,SessionGate2 as SessionGate,clientSdkReactEntrypoint2 as clientSdkReactEntrypoint,createPromptKeyHandler2 as createPromptKeyHandler,useAgentInvocation2 as useAgentInvocation,useAgents2 as useAgents,useAttachments2 as useAttachments,useClientContext2 as useClientContext,useCollectiveIntelligenceAuth2 as useCollectiveIntelligenceAuth,useCollectiveIntelligenceClient2 as useCollectiveIntelligenceClient,useKnowledge2 as useKnowledge,useOrganizationClient2 as useOrganizationClient,useRealtimeClient2 as useRealtimeClient,useRealtimeTopic2 as useRealtimeTopic,useRuns2 as useRuns,useSession2 as useSession,useSkills2 as useSkills,useWorkflows2 as useWorkflows};
|
|
2
|
+
import{EntityRuntimeProvider,createDelegatedEntitySource,defineEntity2,useEntityViewState2,useMemoryEntityViewState2,EntityTable2,EntityList2,EntityForm2}from"./index-bjd4xpqf.js";import{__export}from"./index-6ra894v2.js";var exports_src={};__export(exports_src,{AgentPrompt:()=>AgentPrompt,AgentPromptPrimitive:()=>AgentPromptPrimitive,CollectiveIntelligenceLoginProvider:()=>CollectiveIntelligenceLoginProvider,CollectiveIntelligenceProvider:()=>CollectiveIntelligenceProvider,EntityForm:()=>EntityForm2,EntityList:()=>EntityList2,EntityTable:()=>EntityTable2,LoginButton:()=>LoginButton,LoginCallback:()=>LoginCallback,LoginCallbackPrimitive:()=>LoginCallbackPrimitive,RealtimeProvider:()=>RealtimeProvider,SessionGate:()=>SessionGate,clientSdkReactEntrypoint:()=>clientSdkReactEntrypoint,createDelegatedEntitySource:()=>createDelegatedEntitySource,createPromptKeyHandler:()=>createPromptKeyHandler,defineEntity:()=>defineEntity2,useAgentInvocation:()=>useAgentInvocation,useAgents:()=>useAgents,useAttachments:()=>useAttachments,useClientContext:()=>useClientContext,useCollectiveIntelligenceAuth:()=>useCollectiveIntelligenceAuth,useCollectiveIntelligenceClient:()=>useCollectiveIntelligenceClient,useEntityViewState:()=>useEntityViewState2,useKnowledge:()=>useKnowledge,useMemoryEntityViewState:()=>useMemoryEntityViewState2,useOrganizationClient:()=>useOrganizationClient,useRealtimeClient:()=>useRealtimeClient,useRealtimeTopic:()=>useRealtimeTopic,useRuns:()=>useRuns,useSession:()=>useSession,useSkills:()=>useSkills,useWorkflows:()=>useWorkflows});import{useCallback,useId,useState as useState2}from"react";import{QueryClient,QueryClientProvider}from"@tanstack/react-query";import{createContext,useContext,useMemo,useState}from"react";import{jsx}from"react/jsx-runtime";var ClientContext=createContext(null);var CollectiveIntelligenceProvider=(props)=>{const{clientFactory}=props;const[ownedQueryClient]=useState(()=>new QueryClient({defaultOptions:{mutations:{retry:false},queries:{retry:false}}}));const ownedClient=useMemo(()=>clientFactory===undefined?undefined:clientFactory(),[clientFactory]);const client=props.client??ownedClient;const queryClient=props.queryClient??ownedQueryClient;if(client===undefined){throw new TypeError("A client or clientFactory is required")}return jsx(ClientContext.Provider,{value:client,children:jsx(QueryClientProvider,{client:queryClient,children:props.entitySource===undefined?props.children:jsx(EntityRuntimeProvider,{source:props.entitySource,children:props.children})})})};var useCollectiveIntelligenceClient=()=>{const client=useContext(ClientContext);if(client===null){throw new Error("CollectiveIntelligenceProvider must wrap Collective Intelligence hooks")}return client};var useOrganizationClient=(organizationId)=>{const client=useCollectiveIntelligenceClient();return useMemo(()=>client.forOrganization(organizationId),[client,organizationId])};var useKnowledge=(organizationId)=>useOrganizationClient(organizationId).knowledge;var useAgents=(organizationId)=>useOrganizationClient(organizationId).agents;var useSkills=(organizationId)=>useOrganizationClient(organizationId).skills;var useWorkflows=(organizationId)=>useOrganizationClient(organizationId).workflows;var useRuns=(organizationId)=>useOrganizationClient(organizationId).runs;var useAttachments=(organizationId)=>useOrganizationClient(organizationId).attachments;var useClientContext=(organizationId)=>useOrganizationClient(organizationId).context;import{jsx as jsx2,jsxs}from"react/jsx-runtime";var ignoreSubmit=()=>false;var createPromptKeyHandler=(onSubmit)=>(event)=>{if(event.key==="Enter"&&!event.shiftKey&&!event.isComposing){event.preventDefault();onSubmit()}};var AgentPromptPrimitive=({autoFocus=false,className,components,id,label,onChange,onSubmit,pending,status,style,submitLabel="Send",value})=>{const Form=components?.Form??"form";const Label=components?.Label??"label";const Textarea=components?.Textarea??"textarea";const Button=components?.Button??"button";const Status=components?.Status??"div";const statusId=`${id}-status`;const submit=(event)=>{event.preventDefault();if(!pending){onSubmit()}};const onKeyDown=(event)=>{createPromptKeyHandler(pending?ignoreSubmit:onSubmit)({isComposing:event.nativeEvent.isComposing,key:event.key,preventDefault:()=>{event.preventDefault()},shiftKey:event.shiftKey})};return jsxs(Form,{className:["ci-agent-prompt",className].filter(Boolean).join(" "),onSubmit:submit,style,children:[jsx2(Label,{className:"ci-agent-prompt__label",htmlFor:id,children:label}),jsx2(Textarea,{"aria-describedby":statusId,autoFocus,className:"ci-agent-prompt__input",disabled:pending,id,onChange:(event)=>{onChange(event.currentTarget.value)},onKeyDown,value}),jsx2(Button,{className:"ci-agent-prompt__submit",disabled:pending||value.trim().length===0,type:"submit",children:submitLabel}),jsx2(Status,{"aria-live":"polite",className:"ci-agent-prompt__status",id:statusId,children:status})]})};var useAgentInvocation=(organizationId)=>{const{agents}=useOrganizationClient(organizationId);const[state,setState]=useState2({status:"idle"});const invoke=useCallback(async(input)=>{setState({status:"submitting"});try{const result=await agents.invoke(input);setState(result.ok?{result,status:"success"}:{result,status:"failure"});return result}catch(error){setState({error,status:"error"});throw error}},[agents]);return{invoke,reset:()=>{setState({status:"idle"})},state}};var invocationStatus=(state)=>{switch(state.status){case"submitting":{return"Sending"}case"success":{return"Request started"}case"failure":{return state.result.error.message}case"error":{return"Request failed"}case"idle":{return null}default:{return null}}};var EMPTY_AGENT_PROMPT_COMPONENTS={};var EMPTY_AGENT_PROMPT_STYLE={};var createDefaultIdempotencyKey=()=>globalThis.crypto.randomUUID();var AgentPrompt=({agentId,autoFocus=false,className="",components=EMPTY_AGENT_PROMPT_COMPONENTS,createIdempotencyKey=createDefaultIdempotencyKey,label="Message",onResult,organizationId,style=EMPTY_AGENT_PROMPT_STYLE,submitLabel="Send"})=>{const id=`ci-agent-prompt-${useId().replaceAll(":","")}`;const[value,setValue]=useState2("");const invocation=useAgentInvocation(organizationId);const submit=()=>{const prompt=value.trim();if(prompt.length===0||invocation.state.status==="submitting"){return}const submitInvocation=async()=>{try{const result=await invocation.invoke({agentId,idempotencyKey:createIdempotencyKey(),input:{prompt}});if(result.ok){setValue("")}onResult?.(result)}catch{}};submitInvocation()};return jsx2(AgentPromptPrimitive,{autoFocus,className,components,id,label,onChange:setValue,onSubmit:submit,pending:invocation.state.status==="submitting",status:invocationStatus(invocation.state),style,submitLabel,value})};import{FederatedAuthError}from"@collective-intelligence/external-apps-client-sdk";import{createContext as createContext2,useCallback as useCallback2,useContext as useContext2,useEffect,useMemo as useMemo2,useSyncExternalStore}from"react";import{jsx as jsx3}from"react/jsx-runtime";var AuthContext=createContext2(null);var toFederatedAuthError=(error)=>new FederatedAuthError("authorization_failed",error.message);var unknownAuthError=()=>new FederatedAuthError("authorization_failed","Sign in failed");var CollectiveIntelligenceLoginProvider=(props)=>{const state=useSyncExternalStore(props.auth.subscribe,props.auth.getState,props.auth.getState);const contextValue=useMemo2(()=>({auth:props.auth,state}),[props.auth,state]);return jsx3(AuthContext.Provider,{value:contextValue,children:props.clientFactory===undefined?jsx3(CollectiveIntelligenceProvider,{client:props.client,entitySource:props.entitySource,queryClient:props.queryClient,children:props.children}):jsx3(CollectiveIntelligenceProvider,{clientFactory:props.clientFactory,entitySource:props.entitySource,queryClient:props.queryClient,children:props.children})})};var useCollectiveIntelligenceAuth=()=>{const value=useContext2(AuthContext);if(value===null){throw new Error("CollectiveIntelligenceLoginProvider must wrap authentication bindings")}return{...value,beginLogin:value.auth.beginLogin,completeLogin:value.auth.completeLogin,logout:value.auth.logout,reauthorize:value.auth.reauthorize}};var LoginButton=({children="Sign in with Collective Intelligence",className,components,disabled=false,onError,returnTo,style})=>{const{auth,state}=useCollectiveIntelligenceAuth();const Button=components?.Button??"button";const redirecting=state.status==="redirecting";const onClick=useCallback2((event)=>{event.preventDefault();const target=returnTo??globalThis.location.href;const begin=async()=>{try{await auth.beginLogin({returnTo:target})}catch(error){onError?.(error instanceof Error?toFederatedAuthError(error):unknownAuthError())}};begin()},[auth,onError,returnTo]);return jsx3(Button,{"aria-busy":redirecting,className:["ci-login-button",className].filter(Boolean).join(" "),disabled:disabled||redirecting,onClick,style,type:"button",children})};var callbackMessage=(state)=>{switch(state.status){case"authenticated":{return"Sign in complete"}case"error":{return state.error.message}case"expired":{return"Sign in expired"}case"anonymous":case"redirecting":{return"Completing sign in"}default:{return"Completing sign in"}}};var LoginCallbackPrimitive=({className,components,state,style})=>{const Status=components?.Status??"div";return jsx3(Status,{"aria-live":"polite",className:["ci-login-callback",className].filter(Boolean).join(" "),style,children:callbackMessage(state)})};var LoginCallback=({callbackUrl,onComplete,onError,...primitiveProps})=>{const{auth,state}=useCollectiveIntelligenceAuth();useEffect(()=>{const url=callbackUrl??globalThis.location.href;const complete=async()=>{try{const{returnTo}=await auth.completeLogin(url);onComplete?.(returnTo)}catch(error){onError?.(error instanceof Error?toFederatedAuthError(error):unknownAuthError())}};complete()},[auth,callbackUrl,onComplete,onError]);return jsx3(LoginCallbackPrimitive,{...primitiveProps,state})};var useSession=()=>{const{state}=useCollectiveIntelligenceAuth();return state};var SessionGate=({children,fallback=null})=>{const session=useSession();if(session.status!=="authenticated"){return fallback}return children};import{createRealtimeClient}from"@collective-intelligence/external-apps-client-sdk";import{createContext as createContext3,useContext as useContext3,useEffect as useEffect2,useState as useState3}from"react";import{jsx as jsx4}from"react/jsx-runtime";var idle={connections:0,lastEventId:undefined,status:"idle",topics:[]};var hasOnReset=(options)=>options.onReset!==undefined;var shareClient=(initial)=>{let options=initial;let client;let holders=0;const subscriptions=new Set;const create=()=>createRealtimeClient({document:globalThis.document,window:globalThis.window,...options,onAccessChanged:()=>options.onAccessChanged?.(),...hasOnReset(options)&&{onReset:()=>options.onReset?.()}});const acquire=()=>{holders+=1;client??=create();return client};const release=()=>{holders-=1;queueMicrotask(()=>{if(holders===0){client?.close();client=undefined}})};const subscribe=(topic,onChanges)=>{const subscription={onChanges,topic,unsubscribe:acquire().subscribe(topic,onChanges)};subscriptions.add(subscription);return()=>{if(subscriptions.delete(subscription)){subscription.unsubscribe();release()}}};return{acquire,getState:()=>client?.getState()??idle,release,subscribe,update:(next)=>{const previous=options;options=next;if(client===undefined||hasOnReset(next)===hasOnReset(previous)){return}for(const subscription of subscriptions){subscription.unsubscribe()}client.close();client=create();for(const subscription of subscriptions){subscription.unsubscribe=client.subscribe(subscription.topic,subscription.onChanges)}}}};var RealtimeContext=createContext3(null);var RealtimeProvider=({children,...options})=>{const[shared]=useState3(()=>shareClient(options));useEffect2(()=>{shared.update(options)});useEffect2(()=>{shared.acquire();return shared.release},[shared]);return jsx4(RealtimeContext.Provider,{value:shared,children})};var useRealtimeClient=()=>{const client=useContext3(RealtimeContext);if(client===null){throw new Error("useRealtimeClient requires a RealtimeProvider")}return client};import{realtimeTopicKey}from"@collective-intelligence/external-apps-client-sdk";import{useEffect as useEffect3,useRef,useState as useState4}from"react";var useRealtimeTopic=(topic,onChanges)=>{const client=useRealtimeClient();const latest=useRef(onChanges);const key=topic===null?null:realtimeTopicKey(topic);const[subscribed,setSubscribed]=useState4({key,topic});if(subscribed.key!==key){setSubscribed({key,topic})}useEffect3(()=>{latest.current=onChanges});useEffect3(()=>subscribed.topic===null?undefined:client.subscribe(subscribed.topic,(changes)=>latest.current(changes)),[client,subscribed])};"use client";var clientSdkReactEntrypoint="react";"use client";var{AgentPrompt:AgentPrompt2,AgentPromptPrimitive:AgentPromptPrimitive2,CollectiveIntelligenceLoginProvider:CollectiveIntelligenceLoginProvider2,CollectiveIntelligenceProvider:CollectiveIntelligenceProvider2,LoginButton:LoginButton2,LoginCallback:LoginCallback2,LoginCallbackPrimitive:LoginCallbackPrimitive2,RealtimeProvider:RealtimeProvider2,SessionGate:SessionGate2,clientSdkReactEntrypoint:clientSdkReactEntrypoint2,createPromptKeyHandler:createPromptKeyHandler2,useAgents:useAgents2,useAttachments:useAttachments2,useClientContext:useClientContext2,useCollectiveIntelligenceAuth:useCollectiveIntelligenceAuth2,useCollectiveIntelligenceClient:useCollectiveIntelligenceClient2,useKnowledge:useKnowledge2,useOrganizationClient:useOrganizationClient2,useRealtimeClient:useRealtimeClient2,useRealtimeTopic:useRealtimeTopic2,useRuns:useRuns2,useSession:useSession2,useSkills:useSkills2,useWorkflows:useWorkflows2,useAgentInvocation:useAgentInvocation2}=exports_src;export{AgentPrompt2 as AgentPrompt,AgentPromptPrimitive2 as AgentPromptPrimitive,CollectiveIntelligenceLoginProvider2 as CollectiveIntelligenceLoginProvider,CollectiveIntelligenceProvider2 as CollectiveIntelligenceProvider,LoginButton2 as LoginButton,LoginCallback2 as LoginCallback,LoginCallbackPrimitive2 as LoginCallbackPrimitive,RealtimeProvider2 as RealtimeProvider,SessionGate2 as SessionGate,clientSdkReactEntrypoint2 as clientSdkReactEntrypoint,createPromptKeyHandler2 as createPromptKeyHandler,useAgentInvocation2 as useAgentInvocation,useAgents2 as useAgents,useAttachments2 as useAttachments,useClientContext2 as useClientContext,useCollectiveIntelligenceAuth2 as useCollectiveIntelligenceAuth,useCollectiveIntelligenceClient2 as useCollectiveIntelligenceClient,useKnowledge2 as useKnowledge,useOrganizationClient2 as useOrganizationClient,useRealtimeClient2 as useRealtimeClient,useRealtimeTopic2 as useRealtimeTopic,useRuns2 as useRuns,useSession2 as useSession,useSkills2 as useSkills,useWorkflows2 as useWorkflows};
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,282 +1,10 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
import { ClientFetch, FederatedAuthErrorCode, FederatedAuthState, FederatedSessionIdentity } from '@collective-intelligence/external-apps-client-sdk';
|
|
4
|
+
import { EntityClient, EntityCreateInput, EntityDeleteInput, EntityListQuery, EntityMemberValue, EntityPage, EntityUpdateInput, EntityUploadInput, EntityUploadSlot, IdempotencyKey, PortableResourceSchema, ResourceCapabilities, ResourceClient, ResourceCreateInput, ResourceCursor, ResourceDefinition, ResourceError, ResourceErrorCode, ResourceFilter, ResourceId, ResourceIdentityField, ResourceJsonValue, ResourceLifecycleInput, ResourceListQuery, ResourceListResult, ResourceMutationInput, ResourcePaginationMode, ResourceRecord, ResourceRecordId, ResourceRequestOptions, ResourceResult, ResourceRevision, ResourceSort } from '@collective-intelligence/external-apps-client-sdk/resources';
|
|
5
|
+
import { ResourceField, ResourceFieldControlProps, ResourceObject, ResourceValue } from '@collective-intelligence/ui-react/resources';
|
|
3
6
|
import { ComponentType, ReactNode } from 'react';
|
|
4
7
|
|
|
5
|
-
export type FederatedAuthErrorCode = "configuration_error" | "invalid_return_target" | "invalid_callback" | "invalid_state" | "transaction_expired" | "authorization_failed" | "token_exchange_failed" | "reauthorization_required";
|
|
6
|
-
declare class FederatedAuthError extends Error {
|
|
7
|
-
readonly code: FederatedAuthErrorCode;
|
|
8
|
-
constructor(code: FederatedAuthErrorCode, message: string);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The signed-in CI user as the application's BFF reports it: the fields of
|
|
12
|
-
* CI's `/oauth/identity`, read live by the server, plus email and name.
|
|
13
|
-
*/
|
|
14
|
-
export type FederatedSessionIdentity = Readonly<{
|
|
15
|
-
appId: string;
|
|
16
|
-
/** The App Permissions of the user's effective roles. */
|
|
17
|
-
appPermissions: readonly string[];
|
|
18
|
-
email: string | null;
|
|
19
|
-
/** A person is a member or an External App User of one Organization, never both. */
|
|
20
|
-
kind: "member" | "external_app_user";
|
|
21
|
-
name: string | null;
|
|
22
|
-
organizationId: string;
|
|
23
|
-
/** The user's effective roles on the app. */
|
|
24
|
-
roles: readonly string[];
|
|
25
|
-
userId: string;
|
|
26
|
-
}>;
|
|
27
|
-
export type FederatedAuthState = Readonly<{
|
|
28
|
-
status: "anonymous";
|
|
29
|
-
}> | Readonly<{
|
|
30
|
-
status: "redirecting";
|
|
31
|
-
}> | Readonly<{
|
|
32
|
-
expiresAt: number;
|
|
33
|
-
identity?: FederatedSessionIdentity;
|
|
34
|
-
status: "authenticated";
|
|
35
|
-
}> | Readonly<{
|
|
36
|
-
status: "expired";
|
|
37
|
-
}> | Readonly<{
|
|
38
|
-
error: FederatedAuthError;
|
|
39
|
-
status: "error";
|
|
40
|
-
}>;
|
|
41
|
-
export type ClientFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
42
|
-
export type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
|
|
43
|
-
[key: string]: ResourceJsonValue;
|
|
44
|
-
}>;
|
|
45
|
-
/** Opaque wire identity. Callers must not infer or concatenate its internals. */
|
|
46
|
-
export type ResourceId = string;
|
|
47
|
-
export type ResourceRecordId = ResourceId;
|
|
48
|
-
/** Opaque concurrency token independent from source timestamps. */
|
|
49
|
-
export type ResourceRevision = string;
|
|
50
|
-
/** Opaque pagination position issued and consumed only by a resource adapter. */
|
|
51
|
-
export type ResourceCursor = string;
|
|
52
|
-
export type IdempotencyKey = string;
|
|
53
|
-
export type ResourceIdentityField = Readonly<{
|
|
54
|
-
name: string;
|
|
55
|
-
type: "number" | "string";
|
|
56
|
-
}>;
|
|
57
|
-
export type ResourceCapabilities = Readonly<{
|
|
58
|
-
create?: boolean;
|
|
59
|
-
/** Common entity deletion is always soft deletion. */
|
|
60
|
-
delete?: boolean;
|
|
61
|
-
get?: boolean;
|
|
62
|
-
hardDelete?: boolean;
|
|
63
|
-
includeDeleted?: boolean;
|
|
64
|
-
restore?: boolean;
|
|
65
|
-
search: true;
|
|
66
|
-
softDelete?: boolean;
|
|
67
|
-
update?: boolean;
|
|
68
|
-
/** File uploads for the File fields of a common entity resource. */
|
|
69
|
-
upload?: boolean;
|
|
70
|
-
}>;
|
|
71
|
-
export type ResourcePaginationMode = "cursor" | "page";
|
|
72
|
-
export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
|
|
73
|
-
export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>> = Readonly<{
|
|
74
|
-
capabilities: ResourceCapabilities;
|
|
75
|
-
concurrency: "revision";
|
|
76
|
-
id: string;
|
|
77
|
-
identity: Readonly<{
|
|
78
|
-
fields: readonly [
|
|
79
|
-
ResourceIdentityField,
|
|
80
|
-
...ResourceIdentityField[]
|
|
81
|
-
];
|
|
82
|
-
}>;
|
|
83
|
-
query: Readonly<{
|
|
84
|
-
filterableFields: readonly string[];
|
|
85
|
-
pagination: Readonly<{
|
|
86
|
-
modes: readonly ResourcePaginationMode[];
|
|
87
|
-
}>;
|
|
88
|
-
sortableFields: readonly string[];
|
|
89
|
-
textSearchFields?: readonly string[];
|
|
90
|
-
}>;
|
|
91
|
-
schemas: Readonly<{
|
|
92
|
-
create?: PortableResourceSchema;
|
|
93
|
-
entity: PortableResourceSchema;
|
|
94
|
-
update?: PortableResourceSchema;
|
|
95
|
-
}>;
|
|
96
|
-
version: string;
|
|
97
|
-
/** Portable UI metadata; required/enum/nullability remain in schemas. */
|
|
98
|
-
metadata?: Readonly<Record<string, ResourceJsonValue>>;
|
|
99
|
-
/** Type-only slots keep definition values portable and serializable. */
|
|
100
|
-
readonly __types?: Readonly<{
|
|
101
|
-
create: Create;
|
|
102
|
-
entity: Entity;
|
|
103
|
-
update: Update;
|
|
104
|
-
}>;
|
|
105
|
-
}>;
|
|
106
|
-
export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
|
|
107
|
-
/**
|
|
108
|
-
* A filter predicate. `field` names a declared filterable field, or a path
|
|
109
|
-
* through at most three fields that hold Entity References to a field of
|
|
110
|
-
* the last target, such as `company.industry` or
|
|
111
|
-
* `contacts.company.parent.industry`. On a field that holds Entity
|
|
112
|
-
* References, `is_empty` means no reference. User fields accept identity
|
|
113
|
-
* predicates for one ID and `contains_any`, `contains_all`, `contains_none`
|
|
114
|
-
* for multiple IDs, plus empty/not-empty aliases. CI validates operators
|
|
115
|
-
* against the actual field semantic; UUID shape alone does not declare User.
|
|
116
|
-
*/
|
|
117
|
-
export type ResourceFilter = Readonly<{
|
|
118
|
-
field: string;
|
|
119
|
-
operator: "contains" | "contains_all" | "contains_any" | "contains_none" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
|
|
120
|
-
value: FilterValue;
|
|
121
|
-
}> | Readonly<{
|
|
122
|
-
field: string;
|
|
123
|
-
operator: "is_empty" | "is_not_empty" | "is_not_null" | "is_null";
|
|
124
|
-
}> | Readonly<{
|
|
125
|
-
filters: readonly ResourceFilter[];
|
|
126
|
-
operator: "and" | "or";
|
|
127
|
-
}> | Readonly<{
|
|
128
|
-
filter: ResourceFilter;
|
|
129
|
-
operator: "not";
|
|
130
|
-
}>;
|
|
131
|
-
export type ResourceSort = Readonly<{
|
|
132
|
-
direction: "asc" | "desc";
|
|
133
|
-
field: string;
|
|
134
|
-
}>;
|
|
135
|
-
export type ResourcePagination = Readonly<{
|
|
136
|
-
mode: "cursor";
|
|
137
|
-
cursor?: ResourceCursor;
|
|
138
|
-
limit: number;
|
|
139
|
-
}> | Readonly<{
|
|
140
|
-
mode: "page";
|
|
141
|
-
page: number;
|
|
142
|
-
pageSize: number;
|
|
143
|
-
}>;
|
|
144
|
-
export type ResourceListQuery = Readonly<{
|
|
145
|
-
filter?: ResourceFilter;
|
|
146
|
-
/**
|
|
147
|
-
* Include Paths, such as `["company", "contacts.company"]`: relation
|
|
148
|
-
* fields whose records each item carries in `included`.
|
|
149
|
-
*/
|
|
150
|
-
include?: readonly string[];
|
|
151
|
-
includeDeleted?: boolean;
|
|
152
|
-
pagination: ResourcePagination;
|
|
153
|
-
sort?: readonly ResourceSort[];
|
|
154
|
-
textSearch?: string;
|
|
155
|
-
}>;
|
|
156
|
-
export type ResourceRecord<Entity> = Readonly<{
|
|
157
|
-
deletedAt?: string;
|
|
158
|
-
id: ResourceRecordId;
|
|
159
|
-
/**
|
|
160
|
-
* The records of the read's Include Paths by relation field key: one
|
|
161
|
-
* record, or the records of a `many` field in reference order. Untyped:
|
|
162
|
-
* the target schemas are CI's.
|
|
163
|
-
*/
|
|
164
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
165
|
-
revision: ResourceRevision;
|
|
166
|
-
/** The keys whose included records were cut to the first 100. */
|
|
167
|
-
truncated?: readonly string[];
|
|
168
|
-
value: Entity;
|
|
169
|
-
}>;
|
|
170
|
-
export type ResourceListResult<Entity> = Readonly<{
|
|
171
|
-
items: readonly ResourceRecord<Entity>[];
|
|
172
|
-
nextCursor?: ResourceCursor;
|
|
173
|
-
pagination: "cursor";
|
|
174
|
-
}> | Readonly<{
|
|
175
|
-
items: readonly ResourceRecord<Entity>[];
|
|
176
|
-
page: number;
|
|
177
|
-
pageSize: number;
|
|
178
|
-
pagination: "page";
|
|
179
|
-
totalItems: number;
|
|
180
|
-
totalPages: number;
|
|
181
|
-
}>;
|
|
182
|
-
export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
|
|
183
|
-
/** The CI Organization storage can not take a presigned File upload. */
|
|
184
|
-
"upload_not_supported";
|
|
185
|
-
export type ResourceError = Readonly<{
|
|
186
|
-
code: ResourceErrorCode;
|
|
187
|
-
/** Client-observed dispatch outcome; uncertainty never proves rollback. */
|
|
188
|
-
outcome?: "not_dispatched" | "rejected" | "uncertain";
|
|
189
|
-
details?: Readonly<Record<string, ResourceJsonValue>>;
|
|
190
|
-
message: string;
|
|
191
|
-
retryable: boolean;
|
|
192
|
-
}>;
|
|
193
|
-
export type ResourceResult<Value> = Readonly<{
|
|
194
|
-
correlationId: string;
|
|
195
|
-
ok: true;
|
|
196
|
-
value: Value;
|
|
197
|
-
}> | Readonly<{
|
|
198
|
-
correlationId: string;
|
|
199
|
-
error: ResourceError;
|
|
200
|
-
ok: false;
|
|
201
|
-
}>;
|
|
202
|
-
export type ResourceRequestOptions = Readonly<{
|
|
203
|
-
signal?: AbortSignal;
|
|
204
|
-
}>;
|
|
205
|
-
export type ResourceMutationInput<Value> = Readonly<{
|
|
206
|
-
expectedRevision: ResourceRevision;
|
|
207
|
-
id: ResourceRecordId;
|
|
208
|
-
idempotencyKey?: IdempotencyKey;
|
|
209
|
-
value: Value;
|
|
210
|
-
}>;
|
|
211
|
-
export type ResourceLifecycleInput = Readonly<{
|
|
212
|
-
expectedRevision: ResourceRevision;
|
|
213
|
-
id: ResourceRecordId;
|
|
214
|
-
idempotencyKey?: IdempotencyKey;
|
|
215
|
-
}>;
|
|
216
|
-
export type ResourceCreateInput<Value> = Readonly<{
|
|
217
|
-
idempotencyKey: IdempotencyKey;
|
|
218
|
-
value: Value;
|
|
219
|
-
}>;
|
|
220
|
-
export interface ResourceClient<Entity, Create = Entity, Update = Partial<Entity>> {
|
|
221
|
-
readonly capabilities: ResourceCapabilities;
|
|
222
|
-
readonly create: (input: ResourceCreateInput<Create>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
223
|
-
readonly definition: ResourceDefinition<Entity, Create, Update>;
|
|
224
|
-
readonly get: (input: Readonly<{
|
|
225
|
-
id: ResourceRecordId;
|
|
226
|
-
includeDeleted?: boolean;
|
|
227
|
-
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
228
|
-
readonly hardDelete: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<void>>;
|
|
229
|
-
readonly list: (query: ResourceListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceListResult<Entity>>>;
|
|
230
|
-
readonly restore: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
231
|
-
readonly softDelete: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
232
|
-
readonly update: (input: ResourceMutationInput<Update>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
233
|
-
}
|
|
234
|
-
export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
|
|
235
|
-
pagination: Extract<ResourcePagination, {
|
|
236
|
-
mode: "page";
|
|
237
|
-
}>;
|
|
238
|
-
}>;
|
|
239
|
-
export type EntityPage<Value> = Extract<ResourceListResult<Value>, {
|
|
240
|
-
pagination: "page";
|
|
241
|
-
}>;
|
|
242
|
-
/** Member schemas are resolved by CI, independently of the parent resource. */
|
|
243
|
-
export type EntityMemberValue = Readonly<Record<string, ResourceJsonValue>>;
|
|
244
|
-
export type EntityCreateInput<Value> = ResourceCreateInput<Value>;
|
|
245
|
-
export type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
|
|
246
|
-
idempotencyKey: IdempotencyKey;
|
|
247
|
-
}>;
|
|
248
|
-
export type EntityDeleteInput = ResourceLifecycleInput & Readonly<{
|
|
249
|
-
idempotencyKey: IdempotencyKey;
|
|
250
|
-
}>;
|
|
251
|
-
/** A File upload request for one File field of the entity schema. */
|
|
252
|
-
export type EntityUploadInput = Readonly<{
|
|
253
|
-
field: string;
|
|
254
|
-
filename: string;
|
|
255
|
-
mimeType: string;
|
|
256
|
-
}>;
|
|
257
|
-
/** PUT the file bytes to `url` with `headers`; then write `{ upload: uploadId }`. */
|
|
258
|
-
export type EntityUploadSlot = Readonly<{
|
|
259
|
-
headers: Readonly<Record<string, string>>;
|
|
260
|
-
method: "PUT";
|
|
261
|
-
uploadId: string;
|
|
262
|
-
url: string;
|
|
263
|
-
}>;
|
|
264
|
-
/** A logical write retains its key, payload and edited revision on explicit resubmission. */
|
|
265
|
-
export interface EntityClient<Value, Create = Value, Patch = Partial<Value>> {
|
|
266
|
-
/** Filter, sort and page the resolved member schema; includes remain bounded. */
|
|
267
|
-
readonly listMembers: (parentId: ResourceRecordId, field: string, query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<EntityMemberValue>>>;
|
|
268
|
-
readonly definition: ResourceDefinition<Value, Create, Patch>;
|
|
269
|
-
readonly list: (query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<Value>>>;
|
|
270
|
-
readonly get: (input: Readonly<{
|
|
271
|
-
id: ResourceRecordId;
|
|
272
|
-
include?: readonly string[];
|
|
273
|
-
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
274
|
-
readonly create: (input: EntityCreateInput<Create>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
275
|
-
readonly update: (input: EntityUpdateInput<Patch>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
276
|
-
readonly delete: (input: EntityDeleteInput) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
277
|
-
/** A single-use File upload slot; requires the `upload` capability. */
|
|
278
|
-
readonly upload: (input: EntityUploadInput, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityUploadSlot>>;
|
|
279
|
-
}
|
|
280
8
|
export declare class ResourceQueryError extends Error {
|
|
281
9
|
readonly correlationId: string;
|
|
282
10
|
readonly resourceError: ResourceError;
|
|
@@ -360,7 +88,7 @@ export type ResourcePaginationProps<Entity> = Readonly<{
|
|
|
360
88
|
query: ResourceListQuery;
|
|
361
89
|
result: ResourceListResult<Entity>;
|
|
362
90
|
}>;
|
|
363
|
-
declare const ResourcePagination
|
|
91
|
+
export declare const ResourcePagination: <Entity>({ components, isPending, onQueryChange, query, result }: ResourcePaginationProps<Entity>) => import("react").JSX.Element;
|
|
364
92
|
export type ResourceTableColumn<Entity> = Readonly<{
|
|
365
93
|
id: string;
|
|
366
94
|
label: ReactNode;
|
|
@@ -459,9 +187,9 @@ export declare const useEntityList: <Value, Create, Patch>(contract: ResourceDef
|
|
|
459
187
|
data: NoInfer<Readonly<{
|
|
460
188
|
items: readonly Readonly<{
|
|
461
189
|
deletedAt?: string;
|
|
462
|
-
id: ResourceRecordId;
|
|
463
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
464
|
-
revision: ResourceRevision;
|
|
190
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
191
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
192
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
465
193
|
truncated?: readonly string[];
|
|
466
194
|
value: Value;
|
|
467
195
|
}>[];
|
|
@@ -495,9 +223,9 @@ export declare const useEntityRecord: <Value, Create, Patch>(contract: ResourceD
|
|
|
495
223
|
}>;
|
|
496
224
|
data: NoInfer<Readonly<{
|
|
497
225
|
deletedAt?: string;
|
|
498
|
-
id: ResourceRecordId;
|
|
499
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
500
|
-
revision: ResourceRevision;
|
|
226
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
227
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
228
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
501
229
|
truncated?: readonly string[];
|
|
502
230
|
value: Value;
|
|
503
231
|
}>> | undefined;
|
|
@@ -512,9 +240,9 @@ export declare const useEntityUpdate: <Value, Create, Patch>(contract: ResourceD
|
|
|
512
240
|
available: boolean;
|
|
513
241
|
data: Readonly<{
|
|
514
242
|
deletedAt?: string;
|
|
515
|
-
id: ResourceRecordId;
|
|
516
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
517
|
-
revision: ResourceRevision;
|
|
243
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
244
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
245
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
518
246
|
truncated?: readonly string[];
|
|
519
247
|
value: Value;
|
|
520
248
|
}> | undefined;
|
|
@@ -522,18 +250,18 @@ export declare const useEntityUpdate: <Value, Create, Patch>(contract: ResourceD
|
|
|
522
250
|
pending: boolean;
|
|
523
251
|
resubmit: () => Promise<ResourceResult<Readonly<{
|
|
524
252
|
deletedAt?: string;
|
|
525
|
-
id: ResourceRecordId;
|
|
526
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
527
|
-
revision: ResourceRevision;
|
|
253
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
254
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
255
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
528
256
|
truncated?: readonly string[];
|
|
529
257
|
value: Value;
|
|
530
258
|
}>>>;
|
|
531
259
|
status: "pending" | "success" | "idle" | "conflict" | "uncertain" | "rejected";
|
|
532
260
|
submit: (input: Omit<EntityUpdateInput<Patch>, "id" | "idempotencyKey">) => Promise<ResourceResult<Readonly<{
|
|
533
261
|
deletedAt?: string;
|
|
534
|
-
id: ResourceRecordId;
|
|
535
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
536
|
-
revision: ResourceRevision;
|
|
262
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
263
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
264
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
537
265
|
truncated?: readonly string[];
|
|
538
266
|
value: Value;
|
|
539
267
|
}>>>;
|
|
@@ -543,9 +271,9 @@ export declare const useEntityCreate: <Value, Create, Patch>(contract: ResourceD
|
|
|
543
271
|
available: boolean;
|
|
544
272
|
data: Readonly<{
|
|
545
273
|
deletedAt?: string;
|
|
546
|
-
id: ResourceRecordId;
|
|
547
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
548
|
-
revision: ResourceRevision;
|
|
274
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
275
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
276
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
549
277
|
truncated?: readonly string[];
|
|
550
278
|
value: Value;
|
|
551
279
|
}> | undefined;
|
|
@@ -553,26 +281,26 @@ export declare const useEntityCreate: <Value, Create, Patch>(contract: ResourceD
|
|
|
553
281
|
pending: boolean;
|
|
554
282
|
resubmit: () => Promise<ResourceResult<Readonly<{
|
|
555
283
|
deletedAt?: string;
|
|
556
|
-
id: ResourceRecordId;
|
|
557
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
558
|
-
revision: ResourceRevision;
|
|
284
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
285
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
286
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
559
287
|
truncated?: readonly string[];
|
|
560
288
|
value: Value;
|
|
561
289
|
}>>>;
|
|
562
290
|
status: "pending" | "success" | "idle" | "conflict" | "uncertain" | "rejected";
|
|
563
291
|
submit: (input: Omit<Readonly<{
|
|
564
|
-
idempotencyKey: IdempotencyKey;
|
|
292
|
+
idempotencyKey: import("@collective-intelligence/external-apps-client-sdk").IdempotencyKey;
|
|
565
293
|
value: Create;
|
|
566
294
|
}>, "idempotencyKey">) => Promise<ResourceResult<Readonly<{
|
|
567
295
|
deletedAt?: string;
|
|
568
|
-
id: ResourceRecordId;
|
|
569
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
570
|
-
revision: ResourceRevision;
|
|
296
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
297
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
298
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
571
299
|
truncated?: readonly string[];
|
|
572
300
|
value: Value;
|
|
573
301
|
}>>>;
|
|
574
302
|
submitted: Readonly<{
|
|
575
|
-
idempotencyKey: IdempotencyKey;
|
|
303
|
+
idempotencyKey: import("@collective-intelligence/external-apps-client-sdk").IdempotencyKey;
|
|
576
304
|
value: Create;
|
|
577
305
|
}> | undefined;
|
|
578
306
|
};
|
|
@@ -582,9 +310,9 @@ export declare const useEntityDelete: <Value, Create, Patch>(contract: ResourceD
|
|
|
582
310
|
available: boolean;
|
|
583
311
|
data: Readonly<{
|
|
584
312
|
deletedAt?: string;
|
|
585
|
-
id: ResourceRecordId;
|
|
586
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
587
|
-
revision: ResourceRevision;
|
|
313
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
314
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
315
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
588
316
|
truncated?: readonly string[];
|
|
589
317
|
value: Value;
|
|
590
318
|
}> | undefined;
|
|
@@ -592,48 +320,23 @@ export declare const useEntityDelete: <Value, Create, Patch>(contract: ResourceD
|
|
|
592
320
|
pending: boolean;
|
|
593
321
|
resubmit: () => Promise<ResourceResult<Readonly<{
|
|
594
322
|
deletedAt?: string;
|
|
595
|
-
id: ResourceRecordId;
|
|
596
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
597
|
-
revision: ResourceRevision;
|
|
323
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
324
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
325
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
598
326
|
truncated?: readonly string[];
|
|
599
327
|
value: Value;
|
|
600
328
|
}>>>;
|
|
601
329
|
status: "pending" | "success" | "idle" | "conflict" | "uncertain" | "rejected";
|
|
602
330
|
submit: (input: Omit<EntityDeleteInput, "id" | "idempotencyKey">) => Promise<ResourceResult<Readonly<{
|
|
603
331
|
deletedAt?: string;
|
|
604
|
-
id: ResourceRecordId;
|
|
605
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
606
|
-
revision: ResourceRevision;
|
|
332
|
+
id: import("@collective-intelligence/external-apps-client-sdk").ResourceRecordId;
|
|
333
|
+
included?: Readonly<Record<string, import("@collective-intelligence/external-apps-client-sdk").ResourceJsonValue>>;
|
|
334
|
+
revision: import("@collective-intelligence/external-apps-client-sdk").ResourceRevision;
|
|
607
335
|
truncated?: readonly string[];
|
|
608
336
|
value: Value;
|
|
609
337
|
}>>>;
|
|
610
338
|
submitted: EntityDeleteInput | undefined;
|
|
611
339
|
};
|
|
612
|
-
export type ResourceValue = string | number | boolean | null | readonly ResourceValue[] | ResourceObject;
|
|
613
|
-
export interface ResourceObject {
|
|
614
|
-
readonly [key: string]: ResourceValue;
|
|
615
|
-
}
|
|
616
|
-
/** Display-ready controls. Schema inference and registry selection belong to the consumer. */
|
|
617
|
-
export type ResourceField = Readonly<{
|
|
618
|
-
name: string;
|
|
619
|
-
label: string;
|
|
620
|
-
control: "text" | "email" | "number" | "checkbox" | "date" | "datetime-local" | "select" | "custom";
|
|
621
|
-
required?: boolean;
|
|
622
|
-
readOnly?: boolean;
|
|
623
|
-
nullable?: boolean;
|
|
624
|
-
options?: readonly Readonly<{
|
|
625
|
-
label: string;
|
|
626
|
-
value: string | number | boolean;
|
|
627
|
-
}>[];
|
|
628
|
-
}>;
|
|
629
|
-
export type ResourceFieldControlProps = Readonly<{
|
|
630
|
-
field: ResourceField;
|
|
631
|
-
id: string;
|
|
632
|
-
value: ResourceValue | undefined;
|
|
633
|
-
disabled: boolean;
|
|
634
|
-
errorId?: string | undefined;
|
|
635
|
-
onChange: (value: ResourceValue) => void;
|
|
636
|
-
}>;
|
|
637
340
|
export type EntityFieldKey<Value> = Extract<keyof Value, string>;
|
|
638
341
|
export type EntityFieldConfig = Readonly<{
|
|
639
342
|
control?: ResourceField["control"] | string;
|
|
@@ -737,8 +440,47 @@ export declare const useMemoryEntityViewState: (input?: Readonly<{
|
|
|
737
440
|
export type ResourceLifecycleOperation = "hard_delete" | "restore" | "soft_delete";
|
|
738
441
|
|
|
739
442
|
export {
|
|
443
|
+
ClientFetch,
|
|
444
|
+
EntityClient,
|
|
445
|
+
EntityCreateInput,
|
|
446
|
+
EntityDeleteInput,
|
|
447
|
+
EntityListQuery,
|
|
448
|
+
EntityMemberValue,
|
|
449
|
+
EntityPage,
|
|
450
|
+
EntityUpdateInput,
|
|
451
|
+
EntityUploadInput,
|
|
452
|
+
EntityUploadSlot,
|
|
453
|
+
FederatedAuthErrorCode,
|
|
454
|
+
FederatedAuthState,
|
|
455
|
+
FederatedSessionIdentity,
|
|
456
|
+
IdempotencyKey,
|
|
457
|
+
PortableResourceSchema,
|
|
458
|
+
ResourceCapabilities,
|
|
459
|
+
ResourceClient,
|
|
460
|
+
ResourceCreateInput,
|
|
461
|
+
ResourceCursor,
|
|
462
|
+
ResourceDefinition,
|
|
463
|
+
ResourceError,
|
|
464
|
+
ResourceErrorCode,
|
|
465
|
+
ResourceField,
|
|
466
|
+
ResourceFieldControlProps,
|
|
740
467
|
ResourceFilter$1 as ResourceFilter,
|
|
741
|
-
|
|
468
|
+
ResourceId,
|
|
469
|
+
ResourceIdentityField,
|
|
470
|
+
ResourceJsonValue,
|
|
471
|
+
ResourceLifecycleInput,
|
|
472
|
+
ResourceListQuery,
|
|
473
|
+
ResourceListResult,
|
|
474
|
+
ResourceMutationInput,
|
|
475
|
+
ResourceObject,
|
|
476
|
+
ResourcePaginationMode,
|
|
477
|
+
ResourceRecord,
|
|
478
|
+
ResourceRecordId,
|
|
479
|
+
ResourceRequestOptions,
|
|
480
|
+
ResourceResult,
|
|
481
|
+
ResourceRevision,
|
|
482
|
+
ResourceSort,
|
|
483
|
+
ResourceValue,
|
|
742
484
|
};
|
|
743
485
|
|
|
744
486
|
export {};
|
package/dist/resources.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{
|
|
2
|
+
import{resourceKeys,ResourceQueryError2,unwrapResourceResult2,createResourceListQueryOptions,mapResourceAuthState2,hasResourceCapability2,clearProtectedResourceQueries,createDelegatedEntitySource,defineEntity2,useEntityUpdate2,useEntityCreate2,useEntityDelete2,useEntityList2,useEntityRecord2,useEntityViewState2,useMemoryEntityViewState2,EntityTable2,EntityList2,EntityForm2}from"./index-bjd4xpqf.js";import{__export}from"./index-6ra894v2.js";var exports_resources={};__export(exports_resources,{EntityForm:()=>EntityForm2,EntityList:()=>EntityList2,EntityTable:()=>EntityTable2,ResourceCapabilityAction:()=>ResourceCapabilityAction,ResourceFilter:()=>ResourceFilter,ResourceLifecycleAction:()=>ResourceLifecycleAction,ResourceList:()=>ResourceList,ResourcePagination:()=>ResourcePagination,ResourceProvider:()=>ResourceProvider,ResourceQueryError:()=>ResourceQueryError2,ResourceTable:()=>ResourceTable,createDelegatedEntitySource:()=>createDelegatedEntitySource,defineEntity:()=>defineEntity2,hasResourceCapability:()=>hasResourceCapability2,mapResourceAuthState:()=>mapResourceAuthState2,unwrapResourceResult:()=>unwrapResourceResult2,useEntityCreate:()=>useEntityCreate2,useEntityDelete:()=>useEntityDelete2,useEntityList:()=>useEntityList2,useEntityRecord:()=>useEntityRecord2,useEntityUpdate:()=>useEntityUpdate2,useEntityViewState:()=>useEntityViewState2,useMemoryEntityViewState:()=>useMemoryEntityViewState2});import{useMutation,useQuery,useQueryClient as useQueryClient2}from"@tanstack/react-query";import{mutationOptions}from"@tanstack/react-query";var invalidateResource=async(options)=>{await options.queryClient.invalidateQueries({queryKey:resourceKeys.resource(options.organizationId,options.client.definition.id,options.client.definition.version)})};var createResourceMutationOptions=(options)=>mutationOptions({mutationFn:async(input)=>{let result;switch(options.operation){case"hard_delete":{unwrapResourceResult2(await options.client.hardDelete(input));break}case"restore":{result=unwrapResourceResult2(await options.client.restore(input));break}case"soft_delete":{result=unwrapResourceResult2(await options.client.softDelete(input));break}default:{throw new TypeError(`Unknown resource operation: ${String(options.operation)}`)}}return result},mutationKey:[...resourceKeys.resource(options.organizationId,options.client.definition.id,options.client.definition.version),"mutations",options.operation],onSuccess:async()=>{await invalidateResource(options)}});import{useQueryClient}from"@tanstack/react-query";import{createContext,useContext,useEffect,useMemo,useRef}from"react";import{jsx}from"react/jsx-runtime";var useResourceQueryCleanup=(queryClient,authStatus,organizationId)=>{const previousOrganizationId=useRef(null);const input=useMemo(()=>({authStatus,organizationId}),[authStatus,organizationId]);useEffect(()=>{const previous=previousOrganizationId.current;previousOrganizationId.current=input.organizationId;if(input.authStatus!=="authenticated"){clearProtectedResourceQueries(queryClient);return}if(previous!==null&&previous!==input.organizationId){clearProtectedResourceQueries(queryClient,previous)}},[input,queryClient])};var ResourceContext=createContext(null);var ResourceProvider=({authState,capabilities,children,organizationId})=>{const queryClient=useQueryClient();useResourceQueryCleanup(queryClient,authState.status,organizationId);const value=useMemo(()=>({authState,capabilities,organizationId}),[authState,capabilities,organizationId]);return jsx(ResourceContext.Provider,{value,children})};var useResourceContext=()=>{const value=useContext(ResourceContext);if(value===null){throw new Error("ResourceProvider must wrap resource bindings")}return value};var authStateForError=(error,fallback)=>error instanceof ResourceQueryError2?mapResourceAuthState2({correlationId:error.correlationId,error:error.resourceError,ok:false}):fallback;var useResourceList=(client,query)=>{const context=useResourceContext();const result=useQuery({...createResourceListQueryOptions({client,organizationId:context.organizationId,query}),enabled:context.authState.status==="authenticated"});return{...result,authState:authStateForError(result.error,context.authState)}};var useResourceLifecycleMutation=(client,operation)=>{const{capabilities,organizationId}=useResourceContext();const queryClient=useQueryClient2();const mutation=useMutation(createResourceMutationOptions({client,operation,organizationId,queryClient}));let capability;if(operation==="hard_delete"){capability="hardDelete"}else if(operation==="soft_delete"){capability="softDelete"}else{capability=operation}return{...mutation,available:capabilities[capability]===true}};import{jsx as jsx2,jsxs,Fragment}from"react/jsx-runtime";var nextQuery=(query,result)=>{if(result.pagination==="cursor"){return result.nextCursor===undefined?undefined:{...query,pagination:{cursor:result.nextCursor,limit:query.pagination.mode==="cursor"?query.pagination.limit:25,mode:"cursor"}}}return result.page>=result.totalPages?undefined:{...query,pagination:{mode:"page",page:result.page+1,pageSize:result.pageSize}}};var previousQuery=(query,result)=>result.pagination==="page"&&result.page>1?{...query,pagination:{mode:"page",page:result.page-1,pageSize:result.pageSize}}:undefined;var DefaultStatus=({authState,error,pending})=>{let message=authState.status;if(authState.status==="authenticated"){message=pending?"Loading resources":error?.message??""}return jsx2("output",{"aria-live":"polite",children:message})};var ResourceList=({client,components,onQueryChange,query,renderItem})=>{const resourceQuery=useResourceList(client,query);const Status=components.Status??DefaultStatus;if(resourceQuery.authState.status!=="authenticated"||resourceQuery.isPending||resourceQuery.error!==null){return jsx2(Status,{authState:resourceQuery.authState,pending:resourceQuery.isPending,...resourceQuery.error===null?{}:{error:resourceQuery.error}})}const{List}=components;const{Pagination}=components;const result=resourceQuery.data;const next=nextQuery(query,result);const previous=previousQuery(query,result);return jsxs(Fragment,{children:[jsx2(List,{getItemKey:(item)=>item.id,items:result.items,renderItem}),Pagination===undefined?null:jsx2(Pagination,{hasNextPage:next!==undefined,hasPreviousPage:previous!==undefined,isPending:resourceQuery.isFetching,onNext:()=>{if(next!==undefined){onQueryChange?.(next)}},onPrevious:()=>{if(previous!==undefined){onQueryChange?.(previous)}},...result.pagination==="page"?{currentPage:result.page}:{}})]})};var ResourceCapabilityAction=({capability,children,components,unsupported="disable"})=>{const{capabilities}=useResourceContext();const supported=capabilities[capability]===true;if(!supported&&unsupported==="hide"){return null}const{Action}=components;return jsx2(Action,{disabled:!supported,children})};var ResourceFilter=({components,label="Search resources",onQueryChange,query})=>{const{Filter}=components;const{textSearch:_textSearch,...queryWithoutTextSearch}=query;return jsx2(Filter,{label,onChange:(value)=>{onQueryChange(value===""?queryWithoutTextSearch:{...query,textSearch:value})},value:query.textSearch??""})};var ResourcePagination=({components,isPending=false,onQueryChange,query,result})=>{const{Pagination}=components;const next=nextQuery(query,result);const previous=previousQuery(query,result);return jsx2(Pagination,{hasNextPage:next!==undefined,hasPreviousPage:previous!==undefined,isPending,onNext:()=>{if(next!==undefined){onQueryChange(next)}},onPrevious:()=>{if(previous!==undefined){onQueryChange(previous)}},...result.pagination==="page"?{currentPage:result.page}:{}})};var ResourceTable=({caption,client,columns,components,query})=>{const resourceQuery=useResourceList(client,query);const Status=components.Status??DefaultStatus;if(resourceQuery.authState.status!=="authenticated"||resourceQuery.isPending||resourceQuery.error!==null){return jsx2(Status,{authState:resourceQuery.authState,pending:resourceQuery.isPending,...resourceQuery.error===null?{}:{error:resourceQuery.error}})}const{Table}=components;return jsx2(Table,{caption,columns,getRowKey:(row)=>row.id,renderCell:(row,column)=>column.render(row),rows:resourceQuery.data.items})};var ResourceLifecycleAction=({children,client,components,input,operation,unsupported="disable"})=>{const mutation=useResourceLifecycleMutation(client,operation);if(!mutation.available&&unsupported==="hide"){return null}const{Action}=components;return jsx2(Action,{disabled:!mutation.available,onClick:()=>{mutation.mutate(input)},pending:mutation.isPending,children})};"use client";var{defineEntity,EntityForm,EntityList,EntityTable,ResourceCapabilityAction:ResourceCapabilityAction2,ResourceFilter:ResourceFilter2,ResourceLifecycleAction:ResourceLifecycleAction2,ResourceList:ResourceList2,ResourcePagination:ResourcePagination2,ResourceProvider:ResourceProvider2,ResourceQueryError,ResourceTable:ResourceTable2,hasResourceCapability,mapResourceAuthState,unwrapResourceResult,useEntityCreate,useEntityDelete,useEntityList,useEntityRecord,useEntityUpdate,useEntityViewState,useMemoryEntityViewState}=exports_resources;export{EntityForm,EntityList,EntityTable,ResourceCapabilityAction2 as ResourceCapabilityAction,ResourceFilter2 as ResourceFilter,ResourceLifecycleAction2 as ResourceLifecycleAction,ResourceList2 as ResourceList,ResourcePagination2 as ResourcePagination,ResourceProvider2 as ResourceProvider,ResourceQueryError,ResourceTable2 as ResourceTable,defineEntity,hasResourceCapability,mapResourceAuthState,unwrapResourceResult,useEntityCreate,useEntityDelete,useEntityList,useEntityRecord,useEntityUpdate,useEntityViewState,useMemoryEntityViewState};
|