UNPKG

@veltdev/sdk

Version:

Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.

160 lines (159 loc) 7.74 kB
import { CoreEventTypes } from "../../utils/enums"; import { VeltButtonClickEvent } from "./button.data.model"; import { PermissionSource, User } from "./user.data.model"; export type CoreEventTypesMap = { [CoreEventTypes.PERMISSION_PROVIDER]: PermissionProviderEvent; [CoreEventTypes.USER_RESOLVER]: UserResolverEvent; [CoreEventTypes.COMMENT_RESOLVER]: CommentResolverEvent; [CoreEventTypes.ATTACHMENT_RESOLVER]: AttachmentResolverEvent; [CoreEventTypes.REACTION_RESOLVER]: ReactionResolverEvent; [CoreEventTypes.VELT_BUTTON_CLICK]: VeltButtonClickEvent; [CoreEventTypes.USER_UPDATE]: UserUpdateEvent; [CoreEventTypes.DOCUMENT_INIT]: DocumentInitEvent; [CoreEventTypes.ERROR]: ErrorEvent; [CoreEventTypes.INIT_UPDATE]: InitUpdateEvent; }; export type UserUpdateEvent = User | null; export type DocumentInitEvent = boolean | undefined; export declare enum UserResolverSource { RESOLVE_USERS = "resolveUsers", FORMAT_RESPONSE = "formatResponse", MERGE_USER_WITH_PROVIDED_USER_DATA = "mergeUserWithProvidedUserData", GET_TEMPORARY_USERS = "getTemporaryUsers", SET_SINGLE_EDITOR_MODE_LIVE_STATE_DATA_FOR_DIFFERENT_USER_PRESENT_ON_TAB = "setSingleEditorModeLiveStateDataForDifferentUserPresentOnTab", RESOLVE_AND_MERGE_SINGLE_EDITOR_LIVE_STATE_DATA_WITH_USER = "resolveAndMergeSingleEditorLiveStateDataWithUser", GET_SINGLE_EDITOR_MODE_DATA = "getSingleEditorModeData", RESOLVE_USERS_FROM_HUDDLE_MESSAGES = "resolveUsersFromHuddleMessages" } export declare enum CommentResolverSource { RESOLVE_COMMENT_ANNOTATIONS = "resolveCommentAnnotations", SAVE_COMMENT_ANNOTATION = "saveCommentAnnotation", DELETE_COMMENT_ANNOTATION = "deleteCommentAnnotation", FORMAT_RESPONSE = "formatResponse", INIT_DOCUMENTS = "initDocuments", SET_DATA = "setData", UPDATE_DATA = "updateData", DELETE_DATA = "deleteData" } export declare enum AttachmentResolverSource { SAVE_ATTACHMENT = "saveAttachment", DELETE_ATTACHMENT = "deleteAttachment", UPLOAD_TO_RESOLVER = "uploadToResolver" } export declare enum ReactionResolverSource { RESOLVE_REACTION_ANNOTATIONS = "resolveReactionAnnotations", SAVE_REACTION_ANNOTATION = "saveReactionAnnotation", DELETE_REACTION_ANNOTATION = "deleteReactionAnnotation", FORMAT_RESPONSE = "formatResponse", INIT_DOCUMENTS = "initDocuments", SET_DATA = "setData", UPDATE_DATA = "updateData", DELETE_DATA = "deleteData" } export type BaseResolverEvent<TEventType, TMethodName> = { event: TEventType; methodName?: TMethodName; source?: 'internal' | 'external'; timestamp?: number; uniqueId?: string; payload?: any; }; export type PermissionProviderEvent = BaseResolverEvent<PermissionProviderEventType, PermissionSource>; export type PermissionProviderEventType = { RESOURCE_ACCESS_REQUEST_FORMED: 'resourceAccessRequestFormed'; RESOURCE_ACCESS_REQUEST_TRIGGERED: 'resourceAccessRequestTriggered'; RESOURCE_ACCESS_RESULT: 'resourceAccessResult'; RESOURCE_ACCESS_ERROR: 'resourceAccessError'; RESOURCE_ACCESS_RESULT_FROM_CACHE: 'resourceAccessResultFromCache'; REVOKE_ACCESS_ON_DOCUMENT_UNSET_TRIGGERED: 'revokeAccessOnDocumentUnsetTriggered'; REVOKE_ACCESS_ON_DOCUMENT_UNSET_FORMED: 'revokeAccessOnDocumentUnsetFormed'; REVOKE_ACCESS_ON_DOCUMENT_UNSET_RESULT: 'revokeAccessOnDocumentUnsetResult'; REVOKE_ACCESS_ON_USER_LOGOUT_TRIGGERED: 'revokeAccessOnUserLogoutTriggered'; REVOKE_ACCESS_ON_USER_LOGOUT_FORMED: 'revokeAccessOnUserLogoutFormed'; REVOKE_ACCESS_ON_USER_LOGOUT_RESULT: 'revokeAccessOnUserLogoutResult'; REVOKE_ACCESS_ON_DOCUMENT_UNSET_ERROR: 'revokeAccessOnDocumentUnsetError'; REVOKE_ACCESS_ON_USER_LOGOUT_ERROR: 'revokeAccessOnUserLogoutError'; }; export type UserResolverEvent = BaseResolverEvent<UserResolverEventType, UserResolverSource>; export type UserResolverEventType = { USER_RESOLUTION_REQUEST_FORMED: 'userResolutionRequestFormed'; USER_RESOLUTION_REQUEST_TRIGGERED: 'userResolutionRequestTriggered'; USER_RESOLUTION_RESULT: 'userResolutionResult'; USER_RESOLUTION_ERROR: 'userResolutionError'; USER_RESOLUTION_RESULT_FROM_CACHE: 'userResolutionResultFromCache'; }; export type CommentResolverEvent = BaseResolverEvent<CommentResolverEventType, CommentResolverSource>; export type CommentResolverEventType = { COMMENT_RESOLUTION_REQUEST_FORMED: 'commentResolutionRequestFormed'; COMMENT_RESOLUTION_REQUEST_TRIGGERED: 'commentResolutionRequestTriggered'; COMMENT_RESOLUTION_RESULT: 'commentResolutionResult'; COMMENT_RESOLUTION_ERROR: 'commentResolutionError'; COMMENT_RESOLUTION_RESULT_FROM_CACHE: 'commentResolutionResultFromCache'; COMMENT_SAVE_REQUEST_FORMED: 'commentSaveRequestFormed'; COMMENT_SAVE_REQUEST_TRIGGERED: 'commentSaveRequestTriggered'; COMMENT_SAVE_RESULT: 'commentSaveResult'; COMMENT_SAVE_ERROR: 'commentSaveError'; COMMENT_DELETE_REQUEST_FORMED: 'commentDeleteRequestFormed'; COMMENT_DELETE_REQUEST_TRIGGERED: 'commentDeleteRequestTriggered'; COMMENT_DELETE_RESULT: 'commentDeleteResult'; COMMENT_DELETE_ERROR: 'commentDeleteError'; }; export type AttachmentResolverEvent = BaseResolverEvent<AttachmentResolverEventType, AttachmentResolverSource>; export type AttachmentResolverEventType = { ATTACHMENT_SAVE_REQUEST_FORMED: 'attachmentSaveRequestFormed'; ATTACHMENT_SAVE_REQUEST_TRIGGERED: 'attachmentSaveRequestTriggered'; ATTACHMENT_SAVE_RESULT: 'attachmentSaveResult'; ATTACHMENT_SAVE_ERROR: 'attachmentSaveError'; ATTACHMENT_DELETE_REQUEST_FORMED: 'attachmentDeleteRequestFormed'; ATTACHMENT_DELETE_REQUEST_TRIGGERED: 'attachmentDeleteRequestTriggered'; ATTACHMENT_DELETE_RESULT: 'attachmentDeleteResult'; ATTACHMENT_DELETE_ERROR: 'attachmentDeleteError'; }; export type ReactionResolverEvent = BaseResolverEvent<ReactionResolverEventType, ReactionResolverSource>; export type ReactionResolverEventType = { REACTION_RESOLUTION_REQUEST_FORMED: 'reactionResolutionRequestFormed'; REACTION_RESOLUTION_REQUEST_TRIGGERED: 'reactionResolutionRequestTriggered'; REACTION_RESOLUTION_RESULT: 'reactionResolutionResult'; REACTION_RESOLUTION_ERROR: 'reactionResolutionError'; REACTION_RESOLUTION_RESULT_FROM_CACHE: 'reactionResolutionResultFromCache'; REACTION_SAVE_REQUEST_FORMED: 'reactionSaveRequestFormed'; REACTION_SAVE_REQUEST_TRIGGERED: 'reactionSaveRequestTriggered'; REACTION_SAVE_RESULT: 'reactionSaveResult'; REACTION_SAVE_ERROR: 'reactionSaveError'; REACTION_DELETE_REQUEST_FORMED: 'reactionDeleteRequestFormed'; REACTION_DELETE_REQUEST_TRIGGERED: 'reactionDeleteRequestTriggered'; REACTION_DELETE_RESULT: 'reactionDeleteResult'; REACTION_DELETE_ERROR: 'reactionDeleteError'; }; export type ErrorEvent = { event?: string; sourceMethod?: string; documentIds?: string[]; userId?: string; timestamp?: number; error?: string; code?: string; message?: string; source?: string; }; export declare enum InitUpdateMethodNames { SET_DOCUMENTS = "setDocuments", SET_ROOT_DOCUMENT = "setRootDocument", SET_DOCUMENT_ID = "setDocumentId", UNSET_DOCUMENT_ID = "unsetDocumentId", UNSET_DOCUMENTS = "unsetDocuments", SET_LOCATION = "setLocation", SET_LOCATIONS = "setLocations", SET_ROOT_LOCATION = "setRootLocation", ADD_LOCATION = "addLocation", REMOVE_LOCATION = "removeLocation", REMOVE_LOCATIONS = "removeLocations", UNSET_LOCATION_IDS = "unsetLocationIds", REMOVE_LOCATIONS_SUCCESS = "removeLocationsSuccess" } export type InitUpdateEvent = { event: string; methodName?: string; source?: string; payload?: any; };