import { gql, useDataClientLazyQuery as useLazyQuery, useDataClientMutation as useMutation, useDataClientQuery as useQuery, useDataClientSubscription as useSubscription } from "@twilio/flex-sdk/data-client";
/**
* @private
* @since 2.5.0
* @deprecated
* @deprecatedSince 2.9.0
* @altRecommendation Use `FlexDataCustomization` instead.
* @altRecommendationExample
*
*
* {(client) => {
* return
{client ? "Client Provided" : "No Client"}
;
* }}
*
*
*/
export { DataClientProvider as FlexDataProvider } from "@twilio/flex-sdk/data-client";
export { FlexDataCustomization } from "./FlexDataCustomization";
export * from "./generated/graphql";
export { ActivityDetail, Participant } from "./types";
/**
* FlexDataClient contains a set utility functions to fetch Flex data using GraphQL syntax.
* @name FlexDataClient
* @category Components / Programmable
* @docname Flex Data Client
*/
/**
* useFlexQuery is a React hook that executes GraphQL queries automatically within a React component.
* @name useFlexQuery
* @function
* @memberOf FlexDataClient
* @param {object} query - The GraphQL query document to be executed.
* @param {object} [options] - Additional options for configuring the query execution.
* @param {object} [options.variables] - An object containing variables to be used in the query.
* @param {boolean} [options.skip] - If true, the query execution is skipped.
* @param {string} [options.fetchPolicy] - The fetch policy for the query (e.g., 'cache-first', 'network-only', 'cache-and-network', etc.).
* @param {boolean} [options.notifyOnNetworkStatusChange] - If true, the component will re-render when the network status changes.
* @param {boolean} [options.pollInterval] - The interval (in milliseconds) for polling the query.
* @returns {object} - An object containing the query result and related information.
* @example
* import { FlexDataClient } from '@twilio/flex-ui';
* import { GET_USER } from './queries'; // Import your GraphQL query
*
* function UserProfile({ userId }) {
* const { loading, error, data } = FlexDataClient.useFlexQuery(GET_USER, {
* variables: { id: userId },
* });
*
* if (loading) return
Loading...
;
* if (error) return
Error: {error.message}
;
*
* const user = data.user;
*
* return (
*
*
{user.username}
*
Email: {user.email}
*
* );
* }
*/
export declare const useFlexQuery: typeof useQuery;
/**
* useFlexLazyQuery is a React hook that returns a query function that will execute a GraphQL query within a React component.
* This hook does not execute the query immediately and is used for executing queries in response to different events
* such as a user click event.
*
* @private
* @name useFlexLazyQuery
* @function
* @memberOf FlexDataClient
* @param {object} query - The GraphQL query document to be executed.
* @param {object} [options] - Additional options for configuring the query execution.
* @param {object} [options.variables] - An object containing variables to be used in the query.
* @param {boolean} [options.skip] - If true, the query execution is skipped.
* @param {string} [options.fetchPolicy] - The fetch policy for the query (e.g., 'cache-first', 'network-only', 'cache-and-network', etc.).
* @param {boolean} [options.notifyOnNetworkStatusChange] - If true, the component will re-render when the network status changes.
* @param {boolean} [options.pollInterval] - The interval (in milliseconds) for polling the query.
* @returns {object} - An object containing the query result and related information.
* @example
* import { FlexDataClient } from '@twilio/flex-ui';
* import { GET_USER } from './queries'; // Import your GraphQL query
*
* function UserProfile({ userId }) {
* const [userData, setUserData] = useState({});
* const [getUserProfile, { loading, error, data }] = FlexDataClient.useFlexLazyQuery(GET_USER, {
* variables: { id: userId },
* });
*
* if (loading) return
* );
* }
*/
export declare const useFlexLazyQuery: typeof useLazyQuery;
/**
* useFlexMutation is a React hook for executing GraphQL mutations within a React components.
* It provides a function to trigger the mutation and returns an object with mutation-related information and functions.
* @name useFlexMutation
* @function
* @memberOf FlexDataClient
* @param {object} mutation - The GraphQL mutation document.
* @param {object} [options] - An options object that allows you to customize the behavior of the mutation.
* @param {object} [options.update] - A function to update the GraphQL client cache after a successful mutation.
* @param {boolean} [options.onCompleted] - A callback function to be executed when the mutation is completed successfully.
* @param {string} [options.onError] - A callback function to handle errors that occur during the mutation.
* @param {boolean} [options.ignoreResults=false] - If true, the mutation response will not be automatically written to the client cache.
* @returns {object} - A tuple containing the mutation function and an object with mutation-related information:
* - {MutationFunction} mutationFn - The mutation function that can be invoked to trigger the mutation.
* - {boolean} loading - Indicates whether the mutation is currently in progress.
* - {Error | null} error - Contains any errors that occurred during the mutation.
* - {Object | null} data - Contains the result data from the mutation when it's successful.
* @example
* // Using useFlexMutation in a React component:
* import { FlexDataClient } from '@twilio/flex-ui';
*
* const { useFlexMutation, gql } = FlexDataClient';
*
* const MY_MUTATION = gql`
* mutation MyMutation($input: MyInput!) {
* myMutation(input: $input) {
* // Your mutation fields here
* }
* }
* `;
*
* function MyComponent() {
* const [mutationFn, { loading, error, data }] = useFlexMutation(MY_MUTATION);
*
* const handleButtonClick = () => {
* mutationFn({
* variables: { input: 'your_input_data_here' },
* // Optional: You can use 'update', 'onCompleted', and 'onError' callbacks here.
* });
* };
*
* return (
*
*
* {error &&
Error: {error.message}
}
* {data &&
Mutation Result: {JSON.stringify(data)}
}
*
* );
* }
*/
export declare const useFlexMutation: typeof useMutation;
/**
* useFlexSubscription is a React hook for executing GraphQL subscriptions within a React component.
* It returns an object with subscription-related information and functions.
* The subscription is automatically executed when the component is mounted and unsubscribed when the component is unmounted.
* The subscription result is automatically written to the client cache.
* If you want to execute a subscription in response to an event, use useFlexLazyQuery instead.
*
* @name useFlexSubscription
* @private
* @function
* @memberOf FlexDataClient
* @param {object} subscription - The GraphQL subscription document.
* @param {object} [options] - An options object that allows you to customize the behavior of the subscription.
* @param {object} [options.variables] - An object containing variables to be used in the subscription.
* @param {boolean} [options.skip] - If true, the subscription is skipped.
* @param {any} [options.onData] - Allows the registration of a callback function that will be triggered each time the useFlexSubscription Hook / Subscription component receives data.
* @param {any} [options.onError] - Allows the registration of a callback function that will be triggered each time the useFlexSubscription Hook / Subscription component receives an error.
* @param {any} [options.onComplete] - Allows the registration of a callback function that will be triggered each time the useFlexSubscription Hook / Subscription component completes the subscription.
* @returns {object} - An object containing the subscription result and related information.
* @example
* import { FlexDataClient } from '@twilio/flex-ui';
*
* const { gql, useFlexSubscription } = FlexDataClient';
*
* const INVITES_SUBSCRIPTION = gql`
* subscription OnInviteAdded {
* invites
* }
*`;
*
* function UserProfile({ userId }) {
* const { loading, error, data } = useFlexSubscription(USER_UPDATED, {
* variables: {
* input: {
* interactionSid: "xxx",
* channelSid: "xxx"
* }
* }
* });
*
* if (loading) return
Loading...
;
* if (error) return
Error: {error.message}
;
*
* return
{JSON.stringify(data)}
;
*/
export declare const useFlexSubscription: typeof useSubscription;
/**
* Utility function for parsing GraphQL query strings into the standard GraphQL AST.
* It parses a GraphQL query string into a GraphQL DocumentNode using tagged template literals.
* @name gql
* @function
* @memberOf FlexDataClient
* @param {TemplateStringsArray} templateStrings - An array of string literals from the template literal.
* @returns {object} - The parsed GraphQL DocumentNode representing the query or mutation.
* @example
* import { FlexDataClient } from '@twilio/flex-ui';
*
* // Define a GraphQL query using gql
* const GET_USER = FlexDataClient.gql`
* query GetUser($userId: ID!) {
* user(id: $userId) {
* id
* username
* email
* }
* }
* `;
*/
export { gql };