Chore: Attachment Definitions and UiKitDefinitions (#22354)
Co-authored-by: Diego Sampaio <chinello@gmail.com>pull/22430/head
parent
16520f1a98
commit
6924f93e2f
@ -1,10 +0,0 @@ |
||||
import { ComponentProps } from 'react'; |
||||
|
||||
import DefaultAttachment from './DefaultAttachment'; |
||||
import { FileAttachmentProps } from './Files'; |
||||
import { QuoteAttachmentProps } from './QuoteAttachment'; |
||||
|
||||
export type AttachmentProps = |
||||
| ComponentProps<typeof DefaultAttachment> |
||||
| FileAttachmentProps |
||||
| QuoteAttachmentProps; |
@ -1,37 +0,0 @@ |
||||
import { IRocketChatRecord } from './IRocketChatRecord'; |
||||
import { IUser } from './IUser'; |
||||
import { ChannelName, RoomID } from './IRoom'; |
||||
|
||||
type MentionType = 'user' | 'team'; |
||||
|
||||
export interface IMessage extends IRocketChatRecord { |
||||
rid: RoomID; |
||||
msg: string; |
||||
tmid?: string; |
||||
ts: Date; |
||||
mentions?: { |
||||
_id: string; |
||||
type: MentionType; |
||||
name?: string; |
||||
username?: string; |
||||
}[]; |
||||
channels?: Array<ChannelName>; |
||||
u: Pick<IUser, '_id' | 'username' | 'name'>; |
||||
|
||||
_hidden?: boolean; |
||||
imported?: boolean; |
||||
replies?: IUser['_id'][]; |
||||
location?: { |
||||
type: 'Point'; |
||||
coordinates: [string, string]; |
||||
}; |
||||
starred?: {_id: string}[]; |
||||
pinned?: boolean; |
||||
drid?: RoomID; |
||||
tlm?: Date; |
||||
|
||||
dcount?: number; |
||||
tcount?: number; |
||||
t?: string; |
||||
e2e?: 'pending'; |
||||
} |
@ -0,0 +1,72 @@ |
||||
import { MessageSurfaceLayout } from '@rocket.chat/ui-kit'; |
||||
import { parser } from '@rocket.chat/message-parser'; |
||||
|
||||
import { IRocketChatRecord } from '../IRocketChatRecord'; |
||||
import { IUser } from '../IUser'; |
||||
import { ChannelName, RoomID } from '../IRoom'; |
||||
import { MessageAttachment } from './MessageAttachment/MessageAttachment'; |
||||
|
||||
type MentionType = 'user' | 'team'; |
||||
|
||||
|
||||
type MessageTypesValues = |
||||
| 'e2e' |
||||
| 'uj' |
||||
| 'ul' |
||||
| 'ru' |
||||
| 'au' |
||||
| 'mute_unmute' |
||||
| 'r' |
||||
| 'ut' |
||||
| 'wm' |
||||
| 'rm' |
||||
| 'subscription-role-added' |
||||
| 'subscription-role-removed' |
||||
| 'room_archived' |
||||
| 'room_unarchived' |
||||
| 'room_changed_privacy' |
||||
| 'room_changed_avatar' |
||||
| 'room_changed_topic' |
||||
| 'room_e2e_enabled' |
||||
| 'room_e2e_disabled' |
||||
| 'livechat-close' |
||||
|
||||
|
||||
export interface IMessage extends IRocketChatRecord { |
||||
rid: RoomID; |
||||
msg: string; |
||||
tmid?: string; |
||||
ts: Date; |
||||
mentions?: { |
||||
_id: string; |
||||
type: MentionType; |
||||
name?: string; |
||||
username?: string; |
||||
}[]; |
||||
groupable?: false; |
||||
channels?: Array<ChannelName>; |
||||
u: Pick<IUser, '_id' | 'username' | 'name'>; |
||||
blocks?: MessageSurfaceLayout; |
||||
md?: ReturnType<typeof parser>; |
||||
|
||||
_hidden?: boolean; |
||||
imported?: boolean; |
||||
replies?: IUser['_id'][]; |
||||
location?: { |
||||
type: 'Point'; |
||||
coordinates: [string, string]; |
||||
}; |
||||
starred?: {_id: IUser['_id']}[]; |
||||
pinned?: boolean; |
||||
drid?: RoomID; |
||||
tlm?: Date; |
||||
|
||||
dcount?: number; |
||||
tcount?: number; |
||||
t?: MessageTypesValues; |
||||
e2e?: 'pending'; |
||||
|
||||
urls: any; |
||||
file: any; |
||||
attachments: MessageAttachment[]; |
||||
} |
@ -0,0 +1,5 @@ |
||||
export type FieldProps = { |
||||
short?: boolean; |
||||
title: string; |
||||
value: string; |
||||
}; |
@ -0,0 +1,15 @@ |
||||
|
||||
import { MessageAttachmentBase } from '../MessageAttachmentBase'; |
||||
import { FileAttachmentProps } from './FileAttachmentProps'; |
||||
import { FileProp } from './FileProp'; |
||||
|
||||
export type AudioAttachmentProps = { |
||||
audio_url: string; |
||||
audio_type: string; |
||||
audio_size?: number; |
||||
file?: FileProp; |
||||
} & MessageAttachmentBase; |
||||
|
||||
export const isFileAudioAttachment = ( |
||||
attachment: FileAttachmentProps, |
||||
): attachment is AudioAttachmentProps & { type: 'file' } => 'audio_url' in attachment; |
@ -0,0 +1,14 @@ |
||||
|
||||
import { MessageAttachmentBase } from '../MessageAttachmentBase'; |
||||
import { AudioAttachmentProps } from './AudioAttachmentProps'; |
||||
import { FileProp } from './FileProp'; |
||||
import { ImageAttachmentProps } from './ImageAttachmentProps'; |
||||
import { VideoAttachmentProps } from './VideoAttachmentProps'; |
||||
|
||||
export type FileAttachmentProps = { |
||||
type: 'file'; |
||||
file?: FileProp; |
||||
} & (VideoAttachmentProps | ImageAttachmentProps | AudioAttachmentProps); |
||||
|
||||
export const isFileAttachment = (attachment: MessageAttachmentBase): attachment is FileAttachmentProps => |
||||
'type' in attachment && (attachment as any).type === 'file'; |
@ -0,0 +1,18 @@ |
||||
|
||||
import { MessageAttachmentBase } from '../MessageAttachmentBase'; |
||||
import { Dimensions } from './Dimensions'; |
||||
import { FileAttachmentProps } from './FileAttachmentProps'; |
||||
import { FileProp } from './FileProp'; |
||||
|
||||
export type ImageAttachmentProps = { |
||||
image_dimensions?: Dimensions; |
||||
image_preview?: string; |
||||
image_url: string; |
||||
image_type: string; |
||||
image_size?: number; |
||||
file?: FileProp; |
||||
} & MessageAttachmentBase; |
||||
|
||||
export const isFileImageAttachment = ( |
||||
attachment: FileAttachmentProps, |
||||
): attachment is ImageAttachmentProps & { type: 'file' } => 'image_url' in attachment; |
@ -0,0 +1,7 @@ |
||||
|
||||
import { MessageAttachmentBase } from '../MessageAttachmentBase'; |
||||
import { FileProp } from './FileProp'; |
||||
|
||||
export type PDFAttachmentProps = { |
||||
file: FileProp; |
||||
} & MessageAttachmentBase; |
@ -0,0 +1,15 @@ |
||||
|
||||
import { MessageAttachmentBase } from '../MessageAttachmentBase'; |
||||
import { FileAttachmentProps } from './FileAttachmentProps'; |
||||
import { FileProp } from './FileProp'; |
||||
|
||||
export type VideoAttachmentProps = { |
||||
video_url: string; |
||||
video_type: string; |
||||
video_size: number; |
||||
file?: FileProp; |
||||
} & MessageAttachmentBase; |
||||
|
||||
export const isFileVideoAttachment = ( |
||||
attachment: FileAttachmentProps, |
||||
): attachment is VideoAttachmentProps & { type: 'file' } => 'video_url' in attachment; |
@ -0,0 +1,6 @@ |
||||
import { MessageAttachmentDefault } from './MessageAttachmentDefault'; |
||||
import { FileAttachmentProps } from './Files/FileAttachmentProps'; |
||||
import { MessageQuoteAttachment } from './MessageQuoteAttachment'; |
||||
import { MessageAttachmentAction } from './MessageAttachmentAction'; |
||||
|
||||
export type MessageAttachment = MessageAttachmentAction | MessageAttachmentDefault | FileAttachmentProps | MessageQuoteAttachment; |
@ -0,0 +1,24 @@ |
||||
// DEPRECATED
|
||||
|
||||
import { MessageAttachmentBase } from './MessageAttachmentBase'; |
||||
|
||||
type Action = { |
||||
msgId?: string; |
||||
type: 'button'; |
||||
text: string; |
||||
msg?: string; |
||||
url?: string; |
||||
image_url?: string; |
||||
is_webview?: true; |
||||
msg_in_chat_window?: true; |
||||
msg_processing_type?: 'sendMessage' | 'respondWithMessage' | 'respondWithQuotedMessage'; |
||||
}; |
||||
|
||||
export type MessageAttachmentAction = { |
||||
button_alignment?: 'horizontal' | 'vertical'; |
||||
actions: Array<Action>; |
||||
} & MessageAttachmentBase; |
||||
|
||||
export const isActionAttachment = ( |
||||
attachment: MessageAttachmentBase, |
||||
): attachment is MessageAttachmentAction => 'actions' in attachment; |
@ -1,10 +1,10 @@ |
||||
export type AttachmentPropsBase = { |
||||
export type MessageAttachmentBase = { |
||||
title?: string; |
||||
|
||||
ts: Date; |
||||
ts?: Date; |
||||
collapsed?: boolean; |
||||
description?: string; |
||||
|
||||
title_link?: string; |
||||
title_link_download: boolean; |
||||
title_link_download?: boolean; |
||||
}; |
@ -0,0 +1,28 @@ |
||||
import { FieldProps } from './FieldProps'; |
||||
import { Dimensions } from './Files/Dimensions'; |
||||
import { MessageAttachmentBase } from './MessageAttachmentBase'; |
||||
|
||||
export type MarkdownFields = 'text' | 'pretext' | 'fields'; |
||||
|
||||
export type MessageAttachmentDefault = { |
||||
|
||||
author_icon?: string; |
||||
author_link?: string; |
||||
author_name?: string; |
||||
|
||||
fields?: FieldProps[]; |
||||
|
||||
// footer
|
||||
// footer_icon
|
||||
|
||||
image_url?: string; |
||||
image_dimensions?: Dimensions; |
||||
|
||||
mrkdwn_in?: Array<MarkdownFields>; |
||||
pretext?: string; |
||||
text?: string; |
||||
|
||||
thumb_url?: string; |
||||
|
||||
color?: string; |
||||
} & MessageAttachmentBase; |
@ -0,0 +1,15 @@ |
||||
import { MessageAttachmentBase } from './MessageAttachmentBase'; |
||||
|
||||
export type MessageQuoteAttachment = { |
||||
author_name: string; |
||||
author_link: string; |
||||
author_icon: string; |
||||
message_link?: string; |
||||
text: string; |
||||
attachments?: Array<MessageQuoteAttachment>; |
||||
} & MessageAttachmentBase; |
||||
|
||||
export const isQuoteAttachment = ( |
||||
attachment: MessageAttachmentBase, |
||||
): attachment is MessageQuoteAttachment => |
||||
'message_link' in attachment; |
@ -0,0 +1 @@ |
||||
export * from './IMessage'; |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue