/** * @license * Copyright Stbui All Rights Reserved. * https://github.com/stbui/prophet */ export interface Query { type: string; resource: string; payload: object; } export interface QueryOptions { action?: string; onSuccess?: (response: any) => any | Object; onError?: (error?: any) => any | Object; [key: string]: any; } export interface UseQueryValue { data?: any; total?: number; error?: any; loading?: boolean; loaded?: boolean; } /** * * @param {Object} query * @param {string} query.type * @param {string} query.resource * @param {Object} query.payload * @param {Object} options * @param {string} options.action * @param {Function} options.onSuccess * @param {Function} options.onFailure * * @returns { data, total, error, loading, loaded } * * @example * * import { useQuery } from '@stbui/prophet-core'; * * const UserProfile = record => { * const { data, loading, error } = useQuery({ * type: 'GET_ONE', * resource: 'users', * payload: { id: record.id }, * }); * * if (loading) { * return loading; * } * * if (error) { * return error.message; * } * * return