import { GraphqlResponseWrapper, PluginApi } from '..'; import { DataChannelPushEntryFunctionUserRole, DataChannelTypes } from './enums'; import { RESET_DATA_CHANNEL } from './constants'; export interface DataChannelArguments { dataChannelType?: DataChannelTypes; pluginName: string; channelName: string; subChannelName: string; } /** * Type to specify the useId that will be able to receive the data sent in the push function. */ export interface ToUserId { userId: string; } /** * Type to specify the role that will be able to receive the data sent in the push function. */ export interface ToRole { role: DataChannelPushEntryFunctionUserRole; } export type ObjectTo = ToUserId | ToRole; export type ObjectToDelete = typeof RESET_DATA_CHANNEL | string; export interface PushEntryFunctionOptionArgument { receivers?: ObjectTo[]; } export type PushEntryFunction = (objectToBePushed: T, options?: PushEntryFunctionOptionArgument) => void; export type DeleteEntryFunction = (objectToDelete: ObjectToDelete[]) => void; export type ReplaceEntryFunction = (entryId: string, payloadJson: T) => void; export interface ReplaceEntryFunctionArguments { entryId: string; payloadJson: T; } export interface MapOfPushEntryFunctions { [key: string]: PushEntryFunction; } export interface DataChannelEntryResponseType { createdAt: string; updatedAt: string; channelName: string; subChannelName: string; createdBy: string; entryId: string; payloadJson: T; pluginName: string; toRoles: string[]; } export interface UseDataChannelReturnType { data: GraphqlResponseWrapper[]>; pushEntry: PushEntryFunction; deleteEntry: DeleteEntryFunction; replaceEntry: ReplaceEntryFunction; } export type UseDataChannelFunctionFromPluginApi = (channelName: string, dataChannelType?: DataChannelTypes, subChannelName?: string) => UseDataChannelReturnType; export type UseDataChannelStaticFunction = (channelName: string, subChannelName: string, pluginName: string, pluginApi: PluginApi, dataChannelType: DataChannelTypes) => UseDataChannelReturnType;