softchatjs-core
Version:
Javascript client for JS based frameworks
1 lines • 8.51 kB
Source Map (JSON)
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export enum ClientActions {\r\n INCOMING_MESSAGE = 'incomingMessage',\r\n MESSAGES_READ = 'messagesRead',\r\n USER_IS_TYPING = 'userIsTyping',\r\n MESSAGE_ERROR = 'sendMessageError',\r\n NEW_MESSAGE_REACTION = 'newMessageReaction',\r\n ACK_HEALTH_CHECK = 'acknowledgeHealthCheck',\r\n EDITED_MESSAGE = 'editedMessage',\r\n MESSAGE_DELETED = 'deletedMessage',\r\n MESSAGE_SENT = 'messageSent'\r\n}\r\n\r\n// sent to the server\r\nexport enum ServerActions {\r\n INITIALIZE = 'initialize',\r\n SEND_MESSAGE = 'sendMessage',\r\n CREATE_CONVERSATION = 'createConversation',\r\n SEND_MESSAGE_REPLY = 'sendMessageReply',\r\n USER_TYPING = 'userTyping',\r\n HEALTH_CHECK = 'healthCheck',\r\n SEND_LOCATION = 'sendLocation',\r\n READ_MESSAGES = 'readMessages',\r\n DELETE_MESSAGE = 'deleteMessage',\r\n EDIT_MESSAGE = 'editMessage',\r\n SEND_MESSAGE_REACTION = 'sendMessageReaction',\r\n CONNECTION_CLOSED = 'clearUserSession',\r\n CREATE_BROADCAST_LIST = 'createBroadcastList',\r\n BROADCAST_MESSAGE = 'sendMessageToBroadcastList',\r\n UPDATE_BROADCAST_LIST = 'updateUserBroadcastList',\r\n DELETE_BROADCAST_LIST = 'deleteBroadcastList'\r\n}\r\n\r\ntype Timetamps = {\r\n createdAt: string | Date\r\n updatedAt: string | Date\r\n deletedAt?: string | Date\r\n}\r\n\r\nexport type Prettify<T> = {\r\n [K in keyof T]: T[K]\r\n} & {}\r\n\r\nexport enum AttachmentTypes {\r\n NONE = 'none',\r\n MAP = 'map',\r\n MEDIA = 'media',\r\n STICKER = 'sticker'\r\n}\r\n\r\nexport interface Participant extends User {\r\n meta: UserMeta\r\n}\r\n\r\ntype User = {\r\n uid: string,\r\n connectionId?: string,\r\n projectId?: string,\r\n meta: UserMeta\r\n} & Timetamps\r\n\r\nexport type UserMeta = {\r\n username: string,\r\n uid: string,\r\n firstname?: string,\r\n lastname?: string,\r\n profileUrl?: string,\r\n custom?: Record<string, string>,\r\n color?: string\r\n}\r\n\r\nexport enum MediaType {\r\n VIDEO = 'video',\r\n AUDIO = 'audio',\r\n IMAGE = 'image',\r\n DOCUMENT = 'document',\r\n STICKER = 'sticker'\r\n}\r\n\r\nexport type Media = {\r\n type: MediaType,\r\n ext: string,\r\n mediaId: string,\r\n mediaUrl: string,\r\n mimeType?: string,\r\n meta?: {\r\n aspectRatio?: number,\r\n height?: number,\r\n width?: number,\r\n size?: number,\r\n audioDurationSec?: number,\r\n },\r\n uploading?: boolean\r\n}\r\n\r\nexport type Point = {\r\n lng: number,\r\n lat: number\r\n}\r\n\r\ntype QuotedMessage = Message | null\r\n\r\nexport type Message = {\r\n conversationId: string,\r\n from: string,\r\n to: string,\r\n quotedMessage: QuotedMessage | null,\r\n message: string,\r\n messageState: number,\r\n messageId: string,\r\n attachmentType?: AttachmentTypes,\r\n messageOwner: UserMeta,\r\n replyTo?: string,\r\n sharedLocation?: Point,\r\n sharedImage?: {\r\n url: string,\r\n aspectRatio?: number,\r\n },\r\n attachedMedia: Media[],\r\n token?: string,\r\n quotedMessageId?: string,\r\n reactions: Reaction[],\r\n lastEdited: Date | string | null,\r\n broadcastListId?: string,\r\n isBroadcast?: boolean\r\n} & Timetamps\r\n\r\nexport type ParticipantListInfo = {\r\n id: string;\r\n uid: string,\r\n projectId?: string | null;\r\n connectionId?: string;\r\n participantId: string,\r\n participantDetails: UserMeta\r\n} & Timetamps\r\n\r\nexport type ConversationType = 'private-chat' | 'group-chat' | \"admin-chat\" | \"broadcast-chat\"\r\n\r\nexport type GroupChatMeta = {\r\n groupName: string,\r\n groupIcon?: string,\r\n groupWallpaper?: string,\r\n groupBanner?: string\r\n}\r\n\r\nexport type PrivateChatMeta = {\r\n chatWallpaper?: string,\r\n}\r\n\r\nexport type Conversation = {\r\n participants: string[],\r\n admins: string[],\r\n conversationId: string,\r\n messages: Message[],\r\n conversationType: ConversationType,\r\n participantList: ParticipantListInfo[],\r\n meta: PrivateChatMeta | null,\r\n groupMeta: GroupChatMeta | null\r\n name?: string\r\n} & Timetamps\r\n\r\nexport type UploadContent = {\r\n base64: string,\r\n conversationId: string,\r\n key: string\r\n}\r\n// & Omit<Media, 'mediaUrl'>\r\n\r\nexport type IncomingMessage = {\r\n action: ClientActions.INCOMING_MESSAGE,\r\n message: Message\r\n}\r\n\r\nexport type WsPayLoad<Action, Data> = {\r\n action: Action,\r\n message: Data\r\n}\r\n\r\nexport type ReceivedAction = ServerActions\r\n\r\nexport type ReadMessages = {\r\n uid: string\r\n messageIds: string[],\r\n}\r\n\r\nexport type UserTyping = {\r\n uid: string\r\n}\r\n\r\nexport type InitiateConnection = {\r\n from: string,\r\n to: string,\r\n newConversation: boolean,\r\n userDetails: UserMeta,\r\n recipientMeta: UserMeta,\r\n}\r\n\r\nexport type StringOrNumber = string | number\r\n\r\nexport type Config = {\r\n/**\r\n * - `projectId`: The ID of the project.\r\n */\r\n projectId: string,\r\n /**\r\n * - `subId`: The subscriber ID.\r\n */\r\n subId: string\r\n}\r\n\r\nexport type StartConversation = {\r\n from: string,\r\n recipientMeta: UserMeta\r\n message: string\r\n}\r\n\r\nexport type Reaction = {\r\n emoji: string,\r\n uid: string\r\n}\r\n\r\nexport enum MessageStates {\r\n NONE = 0,\r\n FAILED = 1,\r\n LOADING = 2,\r\n SENT = 3,\r\n DELIVERED = 4,\r\n READ = 5,\r\n}\r\n\r\nexport type WsAccessConfig = {\r\n url: string,\r\n token: string\r\n}\r\n\r\nexport enum Screens {\r\n CHAT = \"chat\",\r\n CONVERSATIONS = \"conversations\",\r\n}\r\n\r\nexport type EditedMessage = { from: string, to: string, conversationId: string, messageId: string, textMessage: string, shouldEdit: boolean, isBroadcast?: boolean }\r\n\r\nexport type DeletedMessage = {\r\n conversationId: string, \r\n messageId: string, \r\n}\r\n\r\nexport type ConversationWithTypingIndicator = {\r\n conversationId: string;\r\n timer: NodeJS.Timeout;\r\n timeActive: Date | string;\r\n};\r\n\r\nexport type MessageReactionPayload = {\r\n action: ServerActions,\r\n message: {\r\n conversationId: string,\r\n messageId: string,\r\n from: string,\r\n to: string,\r\n reactions: Array<Reaction>,\r\n },\r\n}\r\n\r\nexport type ConversationMap = {\r\n [key: string]: Conversation\r\n}\r\n\r\nexport type ConversationListItem = {\r\n conversation: Conversation,\r\n lastMessage: Message | null,\r\n unread: string[]\r\n}\r\n\r\nexport type ConversationListMeta = {\r\n [key: string]: ConversationListItem\r\n}\r\n\r\nexport type BroadcastListMeta = {\r\n [key: string]: Conversation\r\n}\r\n\r\nexport type ChatEventGenerics<T> = T\r\n\r\nexport type ConnectionEvent = {\r\n connecting: boolean, \r\n fetchingConversations: boolean, \r\n isConnected: boolean\r\n}\r\n\r\nexport type SendMessageGenerics<M> = Omit<M, \r\n'from' | \r\n'messageState' |\r\n'messageId' |\r\n'messageOwner' |\r\n'token' |\r\n'lastEdit' |\r\n'lastEdited' |\r\n'deletedAt' |\r\n'createdAt' |\r\n'updatedAt' |\r\n'quotedMessageId'\r\n>\r\n\r\nexport type SendGroupMessageGenerics<M> = Omit<M, \r\n'to' |\r\n'from' | \r\n'messageState' |\r\n'messageId' |\r\n'messageOwner' |\r\n'token' |\r\n'lastEdit' |\r\n'lastEdited' |\r\n'deletedAt' |\r\n'createdAt' |\r\n'updatedAt' |\r\n'replyTo' |\r\n'quotedMessageId' |\r\n'quotedMessage' |\r\n'conversationId' |\r\n'attachedMedia'\r\n>\r\n\r\nexport type Emoji = {\r\n emoji: string,\r\n description: string,\r\n category: string,\r\n aliases: string[],\r\n tags: string[],\r\n unicode_version: string,\r\n ios_version: string\r\n}"],"mappings":"AAAO,IAAKA,OACVA,EAAA,iBAAmB,kBACnBA,EAAA,cAAgB,eAChBA,EAAA,eAAiB,eACjBA,EAAA,cAAgB,mBAChBA,EAAA,qBAAuB,qBACvBA,EAAA,iBAAmB,yBACnBA,EAAA,eAAiB,gBACjBA,EAAA,gBAAkB,iBAClBA,EAAA,aAAe,cATLA,OAAA,IAaAC,OACVA,EAAA,WAAa,aACbA,EAAA,aAAe,cACfA,EAAA,oBAAsB,qBACtBA,EAAA,mBAAqB,mBACrBA,EAAA,YAAc,aACdA,EAAA,aAAe,cACfA,EAAA,cAAgB,eAChBA,EAAA,cAAgB,eAChBA,EAAA,eAAiB,gBACjBA,EAAA,aAAe,cACfA,EAAA,sBAAwB,sBACxBA,EAAA,kBAAoB,mBACpBA,EAAA,sBAAwB,sBACxBA,EAAA,kBAAoB,6BACpBA,EAAA,sBAAwB,0BACxBA,EAAA,sBAAwB,sBAhBdA,OAAA,IA6BAC,OACVA,EAAA,KAAO,OACPA,EAAA,IAAM,MACNA,EAAA,MAAQ,QACRA,EAAA,QAAU,UAJAA,OAAA,IA4BAC,OACVA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,QAAU,UALAA,OAAA,IAsJAC,OACVA,IAAA,KAAO,GAAP,OACAA,IAAA,OAAS,GAAT,SACAA,IAAA,QAAU,GAAV,UACAA,IAAA,KAAO,GAAP,OACAA,IAAA,UAAY,GAAZ,YACAA,IAAA,KAAO,GAAP,OANUA,OAAA,IAcAC,OACVA,EAAA,KAAO,OACPA,EAAA,cAAgB,gBAFNA,OAAA","names":["ClientActions","ServerActions","AttachmentTypes","MediaType","MessageStates","Screens"]}