Spaces:
Runtime error
Runtime error
| import { | |
| ApiExtraModels, | |
| ApiHideProperty, | |
| ApiProperty, | |
| getSchemaPath, | |
| } from '@nestjs/swagger'; | |
| import { IsFileType } from '@waha/nestjs/validation/IsFileType'; | |
| import { GetChatMessagesQuery } from '@waha/structures/chats.dto'; | |
| import { plainToInstance, Transform, Type } from 'class-transformer'; | |
| import { | |
| IsArray, | |
| IsBoolean, | |
| IsNotEmpty, | |
| IsNumber, | |
| IsOptional, | |
| IsString, | |
| IsUrl, | |
| ValidateNested, | |
| } from 'class-validator'; | |
| import { | |
| SessionBaseRequest, | |
| SessionQuery, | |
| WHATSAPP_DEFAULT_SESSION_NAME, | |
| } from './base.dto'; | |
| import { | |
| BinaryFile, | |
| FileContent, | |
| FileType, | |
| FileURL, | |
| RemoteFile, | |
| VideoBinaryFile, | |
| VideoRemoteFile, | |
| VoiceBinaryFile, | |
| VoiceRemoteFile, | |
| } from './files.dto'; | |
| import { | |
| ChatIdProperty, | |
| ConvertApiProperty, | |
| ReplyToProperty, | |
| } from './properties.dto'; | |
| /** | |
| * Queries | |
| */ | |
| export class CheckNumberStatusQuery extends SessionQuery { | |
| ({ | |
| description: 'The phone number to check', | |
| example: '1213213213', | |
| }) | |
| () | |
| phone: string; | |
| } | |
| export class MessageTextQuery extends SessionQuery { | |
| () | |
| phone: string; | |
| () | |
| text: string; | |
| } | |
| export class ChatQuery extends SessionQuery { | |
| () | |
| chatId: string; | |
| } | |
| export class GetMessageQuery extends GetChatMessagesQuery { | |
| () | |
| () | |
| session: string = WHATSAPP_DEFAULT_SESSION_NAME; | |
| () | |
| () | |
| chatId: string; | |
| } | |
| export class GetPresenceQuery extends ChatQuery {} | |
| /** | |
| * Requests | |
| */ | |
| export class ChatRequest extends SessionBaseRequest { | |
| () | |
| () | |
| chatId: string; | |
| } | |
| export class SendSeenRequest extends ChatRequest { | |
| ({ | |
| example: null, | |
| deprecated: true, | |
| required: false, | |
| }) | |
| messageId?: string; | |
| ({ | |
| example: ['false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA'], | |
| required: false, | |
| }) | |
| messageIds?: string[]; | |
| ({ | |
| example: '11111111111@c.us', | |
| required: false, | |
| default: null, | |
| description: | |
| 'NOWEB engine only - the ID of the user that sent the message (undefined for individual chats)', | |
| }) | |
| participant?: string; | |
| } | |
| export class MessageRequest extends SessionBaseRequest { | |
| ({ | |
| example: 'false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA', | |
| }) | |
| messageId: string; | |
| } | |
| export class VCardContact { | |
| ({ | |
| example: | |
| 'BEGIN:VCARD\nVERSION:3.0\nFN:Jane Doe\nORG:Company Name;\nTEL;type=CELL;type=VOICE;waid=911111111111:+91 11111 11111\nEND:VCARD', | |
| description: 'The vcard string', | |
| }) | |
| vcard: string; | |
| } | |
| export class Contact { | |
| ({ | |
| example: 'John Doe', | |
| description: 'The full name of the contact', | |
| }) | |
| fullName: string; | |
| ({ | |
| example: 'Company Name', | |
| description: 'The organization of the contact', | |
| required: false, | |
| }) | |
| organization: string; | |
| ({ | |
| example: '+91 11111 11111', | |
| description: 'The phone number of the contact', | |
| }) | |
| phoneNumber: string; | |
| ({ | |
| example: '911111111111', | |
| description: 'The whatsapp id of the contact. DO NOT add + or @c.us', | |
| required: false, | |
| }) | |
| whatsappId: string; | |
| vcard: string = null; | |
| } | |
| (Contact, VCardContact) | |
| export class MessageContactVcardRequest extends ChatRequest { | |
| ({ | |
| type: 'array', | |
| oneOf: [ | |
| { | |
| $ref: getSchemaPath(VCardContact), | |
| }, | |
| { | |
| $ref: getSchemaPath(Contact), | |
| }, | |
| ], | |
| }) | |
| contacts: (VCardContact | Contact)[]; | |
| () | |
| reply_to?: string; | |
| } | |
| export class MessageTextRequest extends ChatRequest { | |
| text: string = 'Hi there!'; | |
| () | |
| mentions?: string[]; | |
| () | |
| reply_to?: string; | |
| linkPreview?: boolean = true; | |
| linkPreviewHighQuality?: boolean = false; | |
| } | |
| (FileURL, FileContent) | |
| export class LinkPreviewData { | |
| () | |
| ({ | |
| protocols: ['http', 'https'], | |
| require_protocol: true, | |
| require_tld: false, | |
| }) | |
| url: string = 'https://github.com/'; | |
| () | |
| title: string = 'Your Title'; | |
| () | |
| description: string = 'Check this out, amazing!'; | |
| () | |
| () | |
| ( | |
| ({ value }) => { | |
| if (value?.url) { | |
| return plainToInstance(FileURL, value); | |
| } | |
| if (value?.data) { | |
| return plainToInstance(FileContent, value); | |
| } | |
| return value; | |
| }, | |
| { toClassOnly: true }, | |
| ) | |
| ({ message: 'Image must contain either "data" or "url".' }) | |
| ({ | |
| oneOf: [ | |
| { $ref: getSchemaPath(FileURL) }, | |
| { $ref: getSchemaPath(FileContent) }, | |
| ], | |
| example: { | |
| url: | |
| process.env.WHATSAPP_SWAGGER_JPG_EXAMPLE_URL || | |
| 'https://github.com/devlikeapro/waha/raw/core/examples/waha.jpg', | |
| }, | |
| }) | |
| image?: FileType; | |
| } | |
| export class MessageLinkCustomPreviewRequest extends ChatRequest { | |
| () | |
| ({ | |
| description: | |
| 'The text to send. MUST include the URL provided in preview.url', | |
| }) | |
| text: string = 'Check this out! https://github.com/'; | |
| () | |
| () | |
| linkPreviewHighQuality?: boolean = true; | |
| () | |
| (() => LinkPreviewData) | |
| preview: LinkPreviewData; | |
| () | |
| () | |
| () | |
| reply_to?: string; | |
| } | |
| export class EditMessageRequest { | |
| text: string = 'Hello, world!'; | |
| () | |
| mentions?: string[]; | |
| linkPreview?: boolean = true; | |
| linkPreviewHighQuality?: boolean = false; | |
| } | |
| export class MessageReplyRequest extends MessageTextRequest { | |
| text: string = 'Reply text'; | |
| } | |
| export class MessageLocationRequest extends ChatRequest { | |
| ({ | |
| example: 38.8937255, | |
| }) | |
| latitude: number; | |
| ({ | |
| example: -77.0969763, | |
| }) | |
| longitude: number; | |
| ({ | |
| example: 'Our office', | |
| }) | |
| title: string; | |
| () | |
| reply_to?: string; | |
| } | |
| (BinaryFile, RemoteFile) | |
| class FileRequest extends ChatRequest { | |
| ({ | |
| oneOf: [ | |
| { $ref: getSchemaPath(RemoteFile) }, | |
| { $ref: getSchemaPath(BinaryFile) }, | |
| ], | |
| }) | |
| file: BinaryFile | RemoteFile; | |
| } | |
| export class MessageImageRequest extends FileRequest { | |
| caption?: string; | |
| () | |
| reply_to?: string; | |
| } | |
| export class MessageFileRequest extends FileRequest { | |
| caption?: string; | |
| () | |
| reply_to?: string; | |
| } | |
| (VoiceBinaryFile, VoiceRemoteFile) | |
| export class MessageVoiceRequest extends ChatRequest { | |
| ({ | |
| oneOf: [ | |
| { $ref: getSchemaPath(VoiceRemoteFile) }, | |
| { $ref: getSchemaPath(VoiceBinaryFile) }, | |
| ], | |
| }) | |
| file: VoiceBinaryFile | VoiceRemoteFile; | |
| () | |
| reply_to?: string; | |
| () | |
| convert: boolean; | |
| } | |
| (VideoRemoteFile, VideoBinaryFile) | |
| export class MessageVideoRequest extends ChatRequest { | |
| ({ | |
| oneOf: [ | |
| { $ref: getSchemaPath(VideoRemoteFile) }, | |
| { $ref: getSchemaPath(VideoBinaryFile) }, | |
| ], | |
| }) | |
| file: VideoRemoteFile | VideoBinaryFile; | |
| caption?: string = 'Just watch at this!'; | |
| ({ | |
| description: | |
| 'The ID of the message to reply to - false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA', | |
| example: null, | |
| }) | |
| reply_to?: string; | |
| ({ | |
| description: 'Send as video note (aka instant or round video).', | |
| example: false, | |
| }) | |
| asNote?: boolean; | |
| () | |
| convert: boolean; | |
| } | |
| export class MessageLinkPreviewRequest extends ChatRequest { | |
| url: string; | |
| title: string; | |
| } | |
| export class MessageForwardRequest extends ChatRequest { | |
| ({ | |
| example: 'false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA', | |
| }) | |
| messageId: string; | |
| } | |
| export class MessageReactionRequest extends MessageRequest { | |
| ({ | |
| description: | |
| 'Emoji to react with. Send an empty string to remove the reaction', | |
| example: '👍', | |
| }) | |
| reaction: string; | |
| } | |
| export class MessageStarRequest extends MessageRequest { | |
| () | |
| chatId: string; | |
| star: boolean; | |
| } | |
| export class WANumberExistResult { | |
| numberExists: boolean; | |
| ({ | |
| example: | |
| 'Chat id for the phone number. Undefined if the number does not exist', | |
| }) | |
| chatId?: string; | |
| } | |
| export class MessagePoll { | |
| ({ | |
| example: 'How are you?', | |
| }) | |
| name: string; | |
| ({ | |
| example: ['Awesome!', 'Good!', 'Not bad!'], | |
| }) | |
| options: string[]; | |
| multipleAnswers = false; | |
| } | |
| export class MessagePollRequest extends ChatRequest { | |
| poll: MessagePoll; | |
| ({ | |
| description: | |
| 'The ID of the message to reply to - false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA', | |
| example: null, | |
| }) | |
| reply_to?: string; | |
| } | |
| export class MessageDestination { | |
| ({ | |
| description: 'Message ID', | |
| example: 'false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA', | |
| }) | |
| id: string; | |
| to: string; | |
| from: string; | |
| fromMe: boolean; | |
| participant?: string; | |
| } | |
| export class MessageButtonReply extends ChatRequest { | |
| () | |
| () | |
| () | |
| replyTo?: string; | |
| () | |
| () | |
| selectedDisplayText: string; | |
| () | |
| () | |
| selectedButtonID: string; | |
| } | |
| export class NewMessageIDResponse { | |
| ({ | |
| description: 'Pre-generated message id', | |
| example: 'BBBBBBBBBBBBBBBBB', | |
| required: true, | |
| }) | |
| id: string; | |
| } | |
| export class MessagePollVoteRequest extends ChatRequest { | |
| ({ | |
| description: | |
| 'The ID of the poll message. Format: {fromMe}_{chatID}_{messageId}[_{participant}] or just ID for GOWS', | |
| example: 'false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA', | |
| required: true, | |
| }) | |
| () | |
| () | |
| pollMessageId: string; | |
| ({ | |
| description: | |
| 'Only for Channels - server message id (if known); if omitted, API may look it up in the storage', | |
| required: false, | |
| example: null, | |
| }) | |
| () | |
| () | |
| pollServerId?: number; | |
| ({ | |
| description: 'Poll options you are voting for', | |
| example: 'Awesome!', | |
| isArray: true, | |
| }) | |
| () | |
| ({ each: true }) | |
| votes: string[]; | |
| } | |