@solufy/evolution-sdk
Version:
Unofficial SDK for the Evolution Whatsapp API v2
936 lines (935 loc) • 32.6 kB
text/typescript
import * as z from "zod/mini";
//#region src/schemas/client.d.ts
declare const ClientOptionsSchema: z.ZodMiniObject<{
/**
* Your server URL
*/
serverUrl: z.ZodMiniURL;
/**
* Your instance token or global API key
*/
token: z.ZodMiniString<string>;
}, z.z.core.$strip>;
type ClientOptions = z.infer<typeof ClientOptionsSchema>;
//#endregion
//#region src/types/api.d.ts
type APIRequestInit = Omit<RequestInit, "method" | "body" | "headers"> & {
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
params?: Record<string, string | number | boolean | undefined>;
headers?: Record<string, string>;
body?: object | FormData;
};
//#endregion
//#region src/api/index.d.ts
declare class EvolutionApi {
protected readonly options: ClientOptions;
constructor(options: ClientOptions);
get<T>(path: string, options?: Omit<APIRequestInit, "method">): Promise<T>;
post<T>(path: string, options?: Omit<APIRequestInit, "method">): Promise<T>;
put<T>(path: string, options?: Omit<APIRequestInit, "method">): Promise<T>;
patch<T>(path: string, options?: Omit<APIRequestInit, "method">): Promise<T>;
delete<T>(path: string, options?: Omit<APIRequestInit, "method">): Promise<T>;
request<T = unknown>(path: string, options?: APIRequestInit): Promise<T>;
protected makeInit(options: APIRequestInit): {
init: RequestInit & {
headers: Record<string, string>;
};
params: URLSearchParams;
};
}
//#endregion
//#region src/modules/instances/schemas/connect.d.ts
declare const Response$19: (response: unknown) => {
pairingCode: string | undefined;
code: string | undefined;
base64: string | undefined;
};
type ConnectInstanceResponse = ReturnType<typeof Response$19>;
//#endregion
//#region src/modules/instances/schemas/create.d.ts
declare const OptionsSchema$12: z.ZodMiniObject<{
name: z.ZodMiniString<string>;
integration: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"baileys">, z.ZodMiniLiteral<"business">, z.ZodMiniLiteral<"evolution">]>>;
token: z.ZodMiniOptional<z.ZodMiniString<string>>;
number: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.z.core.$strip>;
declare const Response$18: (response: unknown) => {
id: string;
name: string;
integration: "baileys" | "business" | "evolution";
status: "connecting" | "close" | "open";
token: string;
};
type CreateInstanceOptions = z.infer<typeof OptionsSchema$12>;
type CreateInstanceResponse = ReturnType<typeof Response$18>;
//#endregion
//#region src/modules/instances/schemas/find-all.d.ts
declare const Response$17: (response: unknown) => {
id: string;
name: string;
status: "connecting" | "close" | "open";
integration: "baileys" | "business" | "evolution";
number: string | undefined;
token: string;
businessId: string | undefined;
clientName: string;
createdAt: Date;
updatedAt: Date;
profile: {
jid: string;
name: string;
pictureUrl: string | undefined;
} | undefined;
disconnection: {
reasonCode: number;
object: string;
at: Date;
} | undefined;
count: {
messages: number;
contacts: number;
chats: number;
};
}[];
type FindAllInstancesResponse = ReturnType<typeof Response$17>;
//#endregion
//#region src/modules/instances/schemas/find-one.d.ts
declare const Response$16: (response: unknown) => {
id: string;
name: string;
status: "connecting" | "close" | "open";
integration: "baileys" | "business" | "evolution";
number: string | undefined;
token: string;
businessId: string | undefined;
clientName: string;
createdAt: Date;
updatedAt: Date;
profile: {
jid: string;
name: string;
pictureUrl: string | undefined;
} | undefined;
disconnection: {
reasonCode: number;
object: string;
at: Date;
} | undefined;
count: {
messages: number;
contacts: number;
chats: number;
};
};
type FindOneInstanceResponse = ReturnType<typeof Response$16>;
//#endregion
//#region src/modules/instances/schemas/status.d.ts
declare const Response$15: (response: unknown) => "connecting" | "close" | "open";
type InstanceStatusResponse = ReturnType<typeof Response$15>;
//#endregion
//#region src/modules/instances/index.d.ts
declare class InstancesModule {
private readonly api;
constructor(api: EvolutionApi);
/**
* Creates an instance
* @param options - Instance options
*/
create(options: CreateInstanceOptions): Promise<CreateInstanceResponse>;
/**
* Finds all instances
*/
findAll(): Promise<FindAllInstancesResponse>;
/**
* Finds one instance by id
*/
findById(id: string): Promise<FindOneInstanceResponse>;
/**
* Finds one instance by name
*/
findByName(name: string): Promise<FindOneInstanceResponse>;
/**
* Returns the QRCode and/or pairing code
*/
connect(instance: string): Promise<ConnectInstanceResponse>;
/**
* Restarts the instance and returns the QRCode and/or pairing code
*/
restart(instance: string): Promise<ConnectInstanceResponse>;
/**
* Returns the instance connection status
*/
status(instance: string): Promise<InstanceStatusResponse>;
/**
* Logs out the instance
*/
logout(instance: string): Promise<void>;
/**
* Deletes the instance
*/
delete(instance: string): Promise<void>;
}
//#endregion
//#region node_modules/.pnpm/libphonenumber-js@1.12.37/node_modules/libphonenumber-js/types.d.cts
// "Tagged" types are used to introduce some degree of type safety when passing in arguments to the functions.
// https://medium.com/@ethanresnick/advanced-typescript-tagged-types-for-fewer-bugs-and-better-security-24db681d5721
//
// For example, if some function returns an `E164Number`, it can only be interpreted as
// either a `string` or an `E164Number` and it can't mistakenly be interpreted as
// a `NationalNumber` or an `Extension` or a `CarrierCode` or a `CountryCallingCode`.
//
// Example:
//
// import type { E164Number, CarrierCode } from 'libphonenumber-js'
// const number: E164Number = '+78005553535'
// const carrierCode: CarrierCode = number
//
// Shows an error:
// Type 'E164Number' is not assignable to type 'CarrierCode'.
//
// Originally, the `__tag` property was declared optional in order to allow passing
// a generic `string` in place of a `Tagged` type argument to functions that receive such arguments:
// that would allow ingesting generic `string` values from an outside source such as a database.
// Without that, those externally-obtained `string` values would have to be forcefully converted
// to the `Tagged` type via TypeScript `as` operator which is an anti-pattern.
//
// Later, it has been decided to make the `__tag` property non-optional and instead
// declare the arguments of those functions as `string | Tagged` rather than just `Tagged`:
// that would still allow ingesting generic `string` values from an outside source
// and would also make the `Tagged` type more "type safe".
//
type Tagged<A, T> = A & {
__tag: T;
};
type E164Number = Tagged<string, "E164Number">;
//#endregion
//#region src/modules/chats/schemas/check.d.ts
declare const OptionsSchema$11: z.ZodMiniArray<z.ZodMiniString<string>>;
declare const Response$14: (response: unknown) => {
exists: boolean;
jid: `${string}.whatsapp.net`;
number: E164Number;
}[];
type CheckOptions = z.infer<typeof OptionsSchema$11>;
type CheckResponse = ReturnType<typeof Response$14>;
//#endregion
//#region src/types/tags.d.ts
type Jid = `${string}.whatsapp.net`;
declare const Jid: (jid: string) => Jid;
type GroupJid = `${string}.us`;
declare const GroupJid: (jid: string) => GroupJid;
type GroupInviteCode = string & {
__tag: "GroupInviteCode";
};
declare const GroupInviteCode: (code: string) => GroupInviteCode;
type MessageId = string & {
__tag: "MessageId";
};
declare const MessageId: (id: string) => MessageId;
type ChatId = string & {
__tag: "ChatId";
};
declare const ChatId: (id: string) => ChatId;
//#endregion
//#region src/modules/chats/schemas/find-all.d.ts
declare const Response$13: (response: unknown) => {
id: ChatId;
jid: `${string}.whatsapp.net` | `${string}.us`;
phoneNumber: E164Number;
name: string | undefined;
labels: string[] | undefined;
createdAt: Date;
updatedAt: Date;
pushName: string | undefined;
pictureUrl: string | undefined;
}[];
type FindAllChatsResponse = ReturnType<typeof Response$13>;
//#endregion
//#region src/modules/chats/schemas/presence.d.ts
declare const OptionsSchema$10: z.ZodMiniObject<{
/**
* Chat number or JID to receve the presence
*/
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
/**
* Duration of the presence in millisseconds
*/
duration: z.ZodMiniNumber<number>;
/**
* Presence state
* - `composing`: typing a message
* - `recording`: recording an audio
*/
presence: z.ZodMiniEnum<{
composing: "composing";
recording: "recording";
}>;
/**
* Whether to wait until the presence is finished (duration)
*/
waitUntilFinish: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
}, z.z.core.$strip>;
type PresenceOptions = z.infer<typeof OptionsSchema$10>;
//#endregion
//#region src/modules/groups/schemas/common.d.ts
declare const GroupSchema: z.ZodMiniObject<{
id: z.ZodMiniString<string>;
subject: z.ZodMiniString<string>;
subjectOwner: z.ZodMiniString<string>;
subjectTime: z.ZodMiniDate<unknown>;
pictureUrl: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniURL>>;
size: z.ZodMiniNumber<number>;
creation: z.ZodMiniDate<unknown>;
owner: z.ZodMiniString<string>;
restrict: z.ZodMiniBoolean<boolean>;
announce: z.ZodMiniBoolean<boolean>;
}, z.z.core.$strip>;
declare const ParticipantSchema: z.ZodMiniObject<{
id: z.ZodMiniString<string>;
admin: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
admin: "admin";
superadmin: "superadmin";
}>>>;
}, z.z.core.$strip>;
declare const GroupWithParticipantsSchema: z.ZodMiniObject<{
id: z.ZodMiniString<string>;
subject: z.ZodMiniString<string>;
subjectOwner: z.ZodMiniString<string>;
subjectTime: z.ZodMiniDate<unknown>;
pictureUrl: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniURL>>;
size: z.ZodMiniNumber<number>;
creation: z.ZodMiniDate<unknown>;
owner: z.ZodMiniString<string>;
restrict: z.ZodMiniBoolean<boolean>;
announce: z.ZodMiniBoolean<boolean>;
participants: z.ZodMiniArray<z.ZodMiniObject<{
id: z.ZodMiniString<string>;
admin: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
admin: "admin";
superadmin: "superadmin";
}>>>;
}, z.z.core.$strip>>;
}, z.z.core.$strip>;
declare const GroupResponse: (group: GroupResponse) => {
jid: `${string}.us`;
name: string;
pictureUrl: string | undefined;
size: number;
subject: {
owner: `${string}.whatsapp.net`;
time: Date;
};
owner: {
jid: `${string}.whatsapp.net`;
phoneNumber: E164Number;
};
createdAt: Date;
restrict: boolean;
announce: boolean;
};
declare const ParticipantResponse: (participant: ParticipantResponse) => {
id: string;
role: "admin" | "superadmin" | "member";
};
declare const GroupWithParticipantsResponse: (group: GroupWithParticipantsResponse) => {
participants: {
id: string;
role: "admin" | "superadmin" | "member";
}[];
jid: `${string}.us`;
name: string;
pictureUrl: string | undefined;
size: number;
subject: {
owner: `${string}.whatsapp.net`;
time: Date;
};
owner: {
jid: `${string}.whatsapp.net`;
phoneNumber: E164Number;
};
createdAt: Date;
restrict: boolean;
announce: boolean;
};
type GroupResponse = z.infer<typeof GroupSchema>;
type ParticipantResponse = z.infer<typeof ParticipantSchema>;
type GroupWithParticipantsResponse = z.infer<typeof GroupWithParticipantsSchema>;
//#endregion
//#region src/modules/groups/schemas/find-all.d.ts
declare const Response$12: (response: unknown) => {
jid: `${string}.us`;
name: string;
pictureUrl: string | undefined;
size: number;
subject: {
owner: `${string}.whatsapp.net`;
time: Date;
};
owner: {
jid: `${string}.whatsapp.net`;
phoneNumber: E164Number;
};
createdAt: Date;
restrict: boolean;
announce: boolean;
}[];
declare const ResponseWithParticipants: (response: unknown) => {
participants: {
id: string;
role: "admin" | "superadmin" | "member";
}[];
jid: `${string}.us`;
name: string;
pictureUrl: string | undefined;
size: number;
subject: {
owner: `${string}.whatsapp.net`;
time: Date;
};
owner: {
jid: `${string}.whatsapp.net`;
phoneNumber: E164Number;
};
createdAt: Date;
restrict: boolean;
announce: boolean;
}[];
type FindAllGroupsResponse = ReturnType<typeof Response$12>;
type FindAllGroupsWithParticipantsResponse = ReturnType<typeof ResponseWithParticipants>;
//#endregion
//#region src/modules/groups/schemas/find-by-invite-code.d.ts
declare const Response$11: (response: unknown) => {
isCommunity: boolean;
isCommunityAnnounce: boolean;
joinApprovalMode: boolean;
memberAddMode: boolean;
participants: {
id: string;
role: "admin" | "superadmin" | "member";
}[];
jid: `${string}.us`;
name: string;
pictureUrl: string | undefined;
size: number;
subject: {
owner: `${string}.whatsapp.net`;
time: Date;
};
owner: {
jid: `${string}.whatsapp.net`;
phoneNumber: E164Number;
};
createdAt: Date;
restrict: boolean;
announce: boolean;
};
type FindGroupByInviteCodeResponse = ReturnType<typeof Response$11>;
//#endregion
//#region src/modules/groups/schemas/find-by-jid.d.ts
declare const Response$10: (response: unknown) => {
participants: {
id: string;
role: "admin" | "superadmin" | "member";
}[];
jid: `${string}.us`;
name: string;
pictureUrl: string | undefined;
size: number;
subject: {
owner: `${string}.whatsapp.net`;
time: Date;
};
owner: {
jid: `${string}.whatsapp.net`;
phoneNumber: E164Number;
};
createdAt: Date;
restrict: boolean;
announce: boolean;
};
type FindGroupByJidResponse = ReturnType<typeof Response$10>;
//#endregion
//#region src/modules/instances/schemas/common.d.ts
declare const IntegrationSchema: {
Raw: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"WHATSAPP-BAILEYS">, z.ZodMiniLiteral<"WHATSAPP-BUSINESS">, z.ZodMiniLiteral<"EVOLUTION">]>;
Map: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"baileys">, z.ZodMiniLiteral<"business">, z.ZodMiniLiteral<"evolution">]>;
};
declare const StatusSchema: z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"connecting">, z.ZodMiniLiteral<"close">, z.ZodMiniLiteral<"open">]>;
type InstanceIntegration = z.infer<typeof IntegrationSchema.Map>;
type InstanceStatus = z.infer<typeof StatusSchema>;
//#endregion
//#region src/modules/messages/schemas/audio.d.ts
declare const OptionsSchema$9: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
audio: z.ZodMiniUnion<readonly [z.ZodMiniURL, z.ZodMiniBase64]>;
mimetype: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.z.core.$strip>;
declare const Response$9: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
media: {
url: string;
mimetype: string | undefined;
length: number;
durationInSeconds: number;
sha256: string;
encryptedSha256: string;
directPath: string;
key: string;
keyTimestamp: Date;
};
id: MessageId;
timestamp: Date;
};
type AudioMessageOptions = z.infer<typeof OptionsSchema$9>;
type AudioMessageResponse = ReturnType<typeof Response$9>;
//#endregion
//#region src/modules/messages/schemas/base.d.ts
declare const BaseMessageOptionsSchema: z.ZodMiniObject<{
/**
* Number (with country code) or JID to receive the message
*/
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
/**
* Time in milliseconds before sending message
*/
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
}, z.z.core.$strip>;
type BaseMessageOptions = z.infer<typeof BaseMessageOptionsSchema>;
//#endregion
//#region src/modules/messages/schemas/contact.d.ts
declare const OptionsSchema$8: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
contacts: z.ZodMiniArray<z.ZodMiniObject<{
/**
* Contact display name
*/
fullName: z.ZodMiniString<string>;
/**
* Contact phone number
*/
phoneNumber: z.ZodMiniString<string>;
/**
* Contact organization
*/
organization: z.ZodMiniOptional<z.ZodMiniString<string>>;
/**
* Contact email
*/
email: z.ZodMiniOptional<z.ZodMiniEmail>;
/**
* Contact website url
*/
url: z.ZodMiniOptional<z.ZodMiniURL>;
}, z.z.core.$strip>>;
}, z.z.core.$strip>;
declare const Response$8: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
contacts: {
displayName: string;
vcard: string;
}[];
id: MessageId;
timestamp: Date;
};
type ContactMessageOptions = z.infer<typeof OptionsSchema$8>;
type ContactMessageResponse = ReturnType<typeof Response$8>;
//#endregion
//#region src/modules/messages/schemas/document.d.ts
declare const OptionsSchema$7: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
document: z.ZodMiniUnion<readonly [z.ZodMiniURL, z.ZodMiniBase64]>;
caption: z.ZodMiniOptional<z.ZodMiniString<string>>;
mimetype: z.ZodMiniOptional<z.ZodMiniString<string>>;
fileName: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.z.core.$strip>;
declare const Response$7: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
media: {
url: string;
caption: string | undefined;
mimetype: string | undefined;
length: number;
sha256: string;
fileName: string;
encryptedSha256: string;
directPath: string;
key: string;
keyTimestamp: Date;
};
id: MessageId;
timestamp: Date;
};
type DocumentMessageOptions = z.infer<typeof OptionsSchema$7>;
type DocumentMessageResponse = ReturnType<typeof Response$7>;
//#endregion
//#region src/modules/messages/schemas/image.d.ts
declare const OptionsSchema$6: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
image: z.ZodMiniUnion<readonly [z.ZodMiniURL, z.ZodMiniBase64]>;
caption: z.ZodMiniOptional<z.ZodMiniString<string>>;
mimetype: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.z.core.$strip>;
declare const Response$6: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
media: {
url: string;
caption: string | undefined;
mimetype: string | undefined;
length: number;
height: number;
width: number;
sha256: string;
encryptedSha256: string;
directPath: string;
key: string;
keyTimestamp: Date;
};
id: MessageId;
timestamp: Date;
};
type ImageMessageOptions = z.infer<typeof OptionsSchema$6>;
type ImageMessageResponse = ReturnType<typeof Response$6>;
//#endregion
//#region src/modules/messages/schemas/location.d.ts
declare const OptionsSchema$5: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
name: z.ZodMiniString<string>;
address: z.ZodMiniString<string>;
latitude: z.ZodMiniNumber<number>;
longitude: z.ZodMiniNumber<number>;
}, z.z.core.$strip>;
declare const Response$5: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
location: {
latitude: number;
longitude: number;
name: string;
address: string;
};
id: MessageId;
timestamp: Date;
};
type LocationMessageOptions = z.infer<typeof OptionsSchema$5>;
type LocationMessageResponse = ReturnType<typeof Response$5>;
//#endregion
//#region src/modules/messages/schemas/poll.d.ts
declare const OptionsSchema$4: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
name: z.ZodMiniString<string>;
multiple: z.ZodMiniDefault<z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>>;
options: z.ZodMiniArray<z.ZodMiniString<string>>;
}, z.z.core.$strip>;
declare const Response$4: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
poll: {
name: string;
options: string[];
multiple: boolean;
};
id: MessageId;
timestamp: Date;
};
type PollMessageOptions = z.infer<typeof OptionsSchema$4>;
type PollMessageResponse = ReturnType<typeof Response$4>;
//#endregion
//#region src/modules/messages/schemas/sticker.d.ts
declare const OptionsSchema$3: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
sticker: z.ZodMiniUnion<readonly [z.ZodMiniURL, z.ZodMiniBase64]>;
}, z.z.core.$strip>;
declare const Response$3: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
media: {
url: string;
mimetype: string | undefined;
length: number;
sha256: string;
encryptedSha256: string;
directPath: string;
key: string;
keyTimestamp: Date;
};
id: MessageId;
timestamp: Date;
};
type StickerMessageOptions = z.infer<typeof OptionsSchema$3>;
type StickerMessageResponse = ReturnType<typeof Response$3>;
//#endregion
//#region src/modules/messages/schemas/text.d.ts
declare const OptionsSchema$2: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
text: z.ZodMiniString<string>;
linkPreview: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
}, z.z.core.$strip>;
declare const Response$2: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
messageId: MessageId;
timestamp: Date;
};
type TextMessageOptions = z.infer<typeof OptionsSchema$2>;
type TextMessageResponse = ReturnType<typeof Response$2>;
//#endregion
//#region src/modules/messages/schemas/video.d.ts
declare const OptionsSchema$1: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
video: z.ZodMiniUnion<readonly [z.ZodMiniURL, z.ZodMiniBase64]>;
caption: z.ZodMiniOptional<z.ZodMiniString<string>>;
mimetype: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.z.core.$strip>;
declare const Response$1: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
media: {
url: string;
caption: string | undefined;
mimetype: string | undefined;
gifPlayback: boolean;
length: number;
sha256: string;
encryptedSha256: string;
directPath: string;
key: string;
keyTimestamp: Date;
};
id: MessageId;
timestamp: Date;
};
type VideoMessageOptions = z.infer<typeof OptionsSchema$1>;
type VideoMessageResponse = ReturnType<typeof Response$1>;
//#endregion
//#region src/modules/messages/schemas/voice.d.ts
declare const OptionsSchema: z.ZodMiniObject<{
number: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.whatsapp.net`, `${string}.whatsapp.net`>>, z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniCustom<`${string}.us`, `${string}.us`>>]>;
delay: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
audio: z.ZodMiniUnion<readonly [z.ZodMiniURL, z.ZodMiniBase64]>;
encoding: z.ZodMiniDefault<z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>>;
}, z.z.core.$strip>;
declare const Response: (response: unknown) => {
receiver: {
phoneNumber: E164Number;
jid: `${string}.whatsapp.net`;
};
media: {
url: string;
mimetype: string;
length: number;
durationInSeconds: number;
sha256: string;
encryptedSha256: string;
directPath: string;
/**
* Indicates whether the audio message is a push-to-talk (PTT) message
*/
isPtt: boolean | undefined;
key: string;
keyTimestamp: Date;
waveform: string | null | undefined;
};
messageId: MessageId;
timestamp: Date;
};
type VoiceMessageOptions = z.infer<typeof OptionsSchema>;
type VoiceMessageResponse = ReturnType<typeof Response>;
//#endregion
//#region src/api/errors.d.ts
declare class EvolutionApiError extends Error {
code?: string;
instance?: string;
constructor(message: string, options?: {
cause?: unknown;
instance?: string;
code?: string;
});
}
//#endregion
//#region src/api/instance.d.ts
declare class InstanceApi extends EvolutionApi {
protected readonly instance: string;
protected readonly options: ClientOptions;
constructor(instance: string, options: ClientOptions);
request<T = unknown>(path: string, options?: APIRequestInit): Promise<T>;
}
//#endregion
//#region src/modules/chats/index.d.ts
declare class ChatsModule {
private readonly api;
constructor(api: InstanceApi);
/**
* Checks if a number has WhatsApp
* @param numbers - Number(s) (with country code) to check
*/
check(...numbers: CheckOptions | CheckOptions[]): Promise<CheckResponse>;
/**
* Gets all chats
*/
findAll(): Promise<FindAllChatsResponse>;
/**
* Sends a presence to a certain chat
* @param options - Presence options
*/
sendPresence(options: PresenceOptions): Promise<void>;
}
//#endregion
//#region src/modules/groups/index.d.ts
declare class GroupsModule {
private readonly api;
constructor(api: InstanceApi);
/**
* Gets all groups
* @param participants - Whether to fetch participants or not
*/
findAll(participants: false): Promise<FindAllGroupsResponse>;
findAll(participants: true): Promise<FindAllGroupsWithParticipantsResponse>;
/**
* Gets a group by invite code
* @param inviteCode - The group invite code (not the URL)
*/
findByInviteCode(inviteCode: string | GroupInviteCode): Promise<FindGroupByInviteCodeResponse>;
/**
* Gets a group by JID
* @param groupJid - The group JID terminated with \@g.us
*/
findByJid(groupJid: string | GroupJid): Promise<FindGroupByJidResponse>;
}
//#endregion
//#region src/modules/messages/index.d.ts
declare class MessagesModule {
private readonly api;
constructor(api: InstanceApi);
/**
* Sends a text message
* @param options - Text message options
*/
sendText(options: TextMessageOptions): Promise<TextMessageResponse>;
/**
* Sends an image
* @param options - Image message options
*/
sendImage(options: ImageMessageOptions): Promise<ImageMessageResponse>;
/**
* Sends a video
* @param options - Video message options
*/
sendVideo(options: VideoMessageOptions): Promise<VideoMessageResponse>;
/**
* Sends a document
* @param options - Document message options
*/
sendDocument(options: DocumentMessageOptions): Promise<DocumentMessageResponse>;
/**
* Sends an audio
* @param options - Audio message options
*/
sendAudio(options: AudioMessageOptions): Promise<AudioMessageResponse>;
/**
* Sends a voice message
* @param options - Voice message options
*/
sendVoice(options: VoiceMessageOptions): Promise<VoiceMessageResponse>;
/**
* Sends a sticker
* @param options - Sticker message options
*/
sendSticker(options: StickerMessageOptions): Promise<StickerMessageResponse>;
/**
* Sends a location
* @param options - Location message options
*/
sendLocation(options: LocationMessageOptions): Promise<LocationMessageResponse>;
/**
* Sends a contact
* @param options - Contact message options
*/
sendContact(options: ContactMessageOptions): Promise<ContactMessageResponse>;
}
//#endregion
//#region src/instance.d.ts
declare class EvolutionInstance {
readonly instance: string;
readonly options: ClientOptions;
/**
* API service for directly interacting with the Evolution API
*/
readonly api: InstanceApi;
/**
* Find and manage chats, send presences and check numbers
*/
readonly chats: ChatsModule;
/**
* Find and manage groups
*/
readonly groups: GroupsModule;
/**
* Send messages
*/
readonly messages: MessagesModule;
/**
* Evolution Instance - API client for interacting with the Evolution API for instance routes
* @param instance - Instance name
* @param options - Client options
*/
constructor(instance: string, options: ClientOptions);
}
//#endregion
//#region src/utils/phone-numer-from-jid.d.ts
/**
* Get phone number from JID
* @param jid - JID (remote JID)
*/
declare function phoneNumberFromJid(jid: string): E164Number;
//#endregion
//#region src/index.d.ts
declare class EvolutionClient {
readonly options: ClientOptions;
/**
* API service for directly interacting with the Evolution API (no specific typings)
*/
readonly api: EvolutionApi;
/**
* Find and manage instances
*/
readonly instances: InstancesModule;
/**
* Evolution Client - API client for interacting with the Evolution API
* @param options - Client options
*/
constructor(options: ClientOptions);
}
//#endregion
export { AudioMessageOptions, AudioMessageResponse, BaseMessageOptions, ChatId, CheckOptions, CheckResponse, type ClientOptions, ConnectInstanceResponse, ContactMessageOptions, ContactMessageResponse, CreateInstanceOptions, CreateInstanceResponse, DocumentMessageOptions, DocumentMessageResponse, EvolutionApiError, EvolutionClient, EvolutionInstance, FindAllChatsResponse, FindAllGroupsResponse, FindAllGroupsWithParticipantsResponse, FindAllInstancesResponse, FindGroupByInviteCodeResponse, FindGroupByJidResponse, FindOneInstanceResponse, GroupJid, GroupResponse, GroupWithParticipantsResponse, ImageMessageOptions, ImageMessageResponse, InstanceIntegration, InstanceStatus, InstanceStatusResponse, Jid, LocationMessageOptions, LocationMessageResponse, MessageId, ParticipantResponse, PollMessageOptions, PollMessageResponse, PresenceOptions, StickerMessageOptions, StickerMessageResponse, TextMessageOptions, TextMessageResponse, VideoMessageOptions, VideoMessageResponse, VoiceMessageOptions, VoiceMessageResponse, phoneNumberFromJid };