@gymspace/evolution 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/index.d.mts +26 -19
  2. package/dist/index.d.ts +26 -19
  3. package/dist/index.js +173 -62
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +173 -62
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +1 -3
  8. package/src/api/errors.ts +0 -220
  9. package/src/api/routes.ts +0 -76
  10. package/src/api/service.ts +0 -141
  11. package/src/index.ts +0 -89
  12. package/src/modules/chats/index.ts +0 -253
  13. package/src/modules/chats/schemas/archive.ts +0 -15
  14. package/src/modules/chats/schemas/check.ts +0 -20
  15. package/src/modules/chats/schemas/delete-message.ts +0 -16
  16. package/src/modules/chats/schemas/fetch-profile-picture.ts +0 -13
  17. package/src/modules/chats/schemas/find-all.ts +0 -49
  18. package/src/modules/chats/schemas/find-contacts.ts +0 -17
  19. package/src/modules/chats/schemas/find-messages.ts +0 -55
  20. package/src/modules/chats/schemas/find-status-message.ts +0 -11
  21. package/src/modules/chats/schemas/get-base64-from-media-message.ts +0 -20
  22. package/src/modules/chats/schemas/index.ts +0 -33
  23. package/src/modules/chats/schemas/mark-as-read.ts +0 -20
  24. package/src/modules/chats/schemas/mark-as-unread.ts +0 -17
  25. package/src/modules/chats/schemas/presence.ts +0 -41
  26. package/src/modules/chats/schemas/update-message.ts +0 -16
  27. package/src/modules/groups/index.ts +0 -246
  28. package/src/modules/groups/schemas/accept-invite-code.ts +0 -14
  29. package/src/modules/groups/schemas/common.ts +0 -89
  30. package/src/modules/groups/schemas/create.ts +0 -15
  31. package/src/modules/groups/schemas/fetch-invite-code.ts +0 -13
  32. package/src/modules/groups/schemas/find-all.ts +0 -26
  33. package/src/modules/groups/schemas/find-by-invite-code.ts +0 -39
  34. package/src/modules/groups/schemas/find-by-jid.ts +0 -14
  35. package/src/modules/groups/schemas/find-members.ts +0 -16
  36. package/src/modules/groups/schemas/index.ts +0 -24
  37. package/src/modules/groups/schemas/leave.ts +0 -14
  38. package/src/modules/groups/schemas/revoke-invite-code.ts +0 -14
  39. package/src/modules/groups/schemas/send-group-invite.ts +0 -15
  40. package/src/modules/groups/schemas/toggle-ephemeral.ts +0 -15
  41. package/src/modules/groups/schemas/update-description.ts +0 -15
  42. package/src/modules/groups/schemas/update-members.ts +0 -18
  43. package/src/modules/groups/schemas/update-picture.ts +0 -15
  44. package/src/modules/groups/schemas/update-setting.ts +0 -16
  45. package/src/modules/groups/schemas/update-subject.ts +0 -15
  46. package/src/modules/index.ts +0 -7
  47. package/src/modules/instance/index.ts +0 -126
  48. package/src/modules/instance/schemas/connect.ts +0 -14
  49. package/src/modules/instance/schemas/connection-state.ts +0 -16
  50. package/src/modules/instance/schemas/create.ts +0 -99
  51. package/src/modules/instance/schemas/delete.ts +0 -21
  52. package/src/modules/instance/schemas/fetch-all.ts +0 -57
  53. package/src/modules/instance/schemas/index.ts +0 -8
  54. package/src/modules/instance/schemas/logout.ts +0 -22
  55. package/src/modules/instance/schemas/restart.ts +0 -13
  56. package/src/modules/instance/schemas/set-presence.ts +0 -20
  57. package/src/modules/messages/index.ts +0 -246
  58. package/src/modules/messages/schemas/audio.ts +0 -12
  59. package/src/modules/messages/schemas/base.ts +0 -11
  60. package/src/modules/messages/schemas/contact.ts +0 -70
  61. package/src/modules/messages/schemas/document.ts +0 -12
  62. package/src/modules/messages/schemas/image.ts +0 -12
  63. package/src/modules/messages/schemas/index.ts +0 -31
  64. package/src/modules/messages/schemas/list.ts +0 -36
  65. package/src/modules/messages/schemas/location.ts +0 -76
  66. package/src/modules/messages/schemas/media.ts +0 -51
  67. package/src/modules/messages/schemas/poll.ts +0 -87
  68. package/src/modules/messages/schemas/reaction.ts +0 -21
  69. package/src/modules/messages/schemas/status.ts +0 -18
  70. package/src/modules/messages/schemas/sticker.ts +0 -77
  71. package/src/modules/messages/schemas/template.ts +0 -39
  72. package/src/modules/messages/schemas/text.ts +0 -88
  73. package/src/modules/messages/schemas/video.ts +0 -12
  74. package/src/modules/messages/schemas/voice.ts +0 -94
  75. package/src/modules/profile/index.ts +0 -110
  76. package/src/modules/profile/schemas/fetch-business-profile.ts +0 -29
  77. package/src/modules/profile/schemas/fetch-privacy-settings.ts +0 -11
  78. package/src/modules/profile/schemas/fetch-profile.ts +0 -23
  79. package/src/modules/profile/schemas/index.ts +0 -8
  80. package/src/modules/profile/schemas/remove-picture.ts +0 -4
  81. package/src/modules/profile/schemas/update-name.ts +0 -11
  82. package/src/modules/profile/schemas/update-picture.ts +0 -11
  83. package/src/modules/profile/schemas/update-privacy-settings.ts +0 -18
  84. package/src/modules/profile/schemas/update-status.ts +0 -11
  85. package/src/modules/settings/index.ts +0 -28
  86. package/src/modules/settings/schemas/find.ts +0 -11
  87. package/src/modules/settings/schemas/index.ts +0 -2
  88. package/src/modules/settings/schemas/set.ts +0 -18
  89. package/src/modules/webhook/index.ts +0 -28
  90. package/src/modules/webhook/schemas/find.ts +0 -7
  91. package/src/modules/webhook/schemas/index.ts +0 -2
  92. package/src/modules/webhook/schemas/set.ts +0 -16
  93. package/src/schemas/client.ts +0 -23
  94. package/src/schemas/common.ts +0 -44
  95. package/src/types/api.ts +0 -17
  96. package/src/types/events.ts +0 -53
  97. package/src/types/messages.ts +0 -5
  98. package/src/types/tags.ts +0 -14
  99. package/src/types/webhooks.ts +0 -255
  100. package/src/utils/phone-numer-from-jid.ts +0 -9
@@ -1,94 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- import type { Media } from "@/schemas/common";
3
- import { Jid, MessageId } from "@/types/tags";
4
- import { phoneNumberFromJid } from "@/utils/phone-numer-from-jid";
5
- import { BaseMessageOptions } from "./base";
6
-
7
- // Raw response interface from API
8
- export interface VoiceMessageResponseRaw {
9
- key: {
10
- remoteJid: string;
11
- id: string;
12
- };
13
- message: {
14
- audioMessage: {
15
- url: string;
16
- mimetype: string;
17
- fileSha256: string;
18
- fileLength: number | string;
19
- seconds: number;
20
- ptt?: boolean;
21
- mediaKey: string;
22
- fileEncSha256: string;
23
- directPath: string;
24
- mediaKeyTimestamp: number | string;
25
- waveform?: string | null;
26
- };
27
- };
28
- messageTimestamp: string | Date;
29
- }
30
-
31
- // Request interfaces
32
- export interface VoiceMessageOptions extends BaseMessageOptions {
33
- /**
34
- * Audio URL or file in base64
35
- */
36
- audio: Media;
37
- /**
38
- * Encode audio into WhatsApp default format (allows audio to be sped up)
39
- * @default true
40
- */
41
- encoding?: boolean;
42
- }
43
-
44
- // Response interfaces
45
- export interface VoiceMessageResponse {
46
- receiver: {
47
- phoneNumber: string;
48
- jid: Jid;
49
- };
50
- media: {
51
- url: string;
52
- mimetype: string;
53
- length: number;
54
- durationInSeconds: number;
55
- sha256: string;
56
- encryptedSha256: string;
57
- directPath: string;
58
- /**
59
- * Indicates whether the audio message is a push-to-talk (PTT) message
60
- */
61
- isPtt?: boolean;
62
- key: string;
63
- keyTimestamp: Date;
64
- waveform?: string | null;
65
- };
66
- messageId: MessageId;
67
- timestamp: Date;
68
- }
69
-
70
- // Transform function
71
- export const VoiceMessageResponseTransform = (data: VoiceMessageResponseRaw): VoiceMessageResponse => ({
72
- receiver: {
73
- phoneNumber: phoneNumberFromJid(data.key.remoteJid),
74
- jid: Jid(data.key.remoteJid),
75
- },
76
- media: {
77
- url: data.message.audioMessage.url,
78
- mimetype: data.message.audioMessage.mimetype,
79
- length: Number(data.message.audioMessage.fileLength),
80
- durationInSeconds: data.message.audioMessage.seconds,
81
- sha256: data.message.audioMessage.fileSha256,
82
- encryptedSha256: data.message.audioMessage.fileEncSha256,
83
- directPath: data.message.audioMessage.directPath,
84
- isPtt: data.message.audioMessage.ptt,
85
- key: data.message.audioMessage.mediaKey,
86
- keyTimestamp: new Date(Number(data.message.audioMessage.mediaKeyTimestamp)),
87
- waveform: data.message.audioMessage.waveform,
88
- },
89
- messageId: MessageId(data.key.id),
90
- timestamp: new Date(data.messageTimestamp),
91
- });
92
-
93
- // Backward compatibility aliases
94
- export const ResponseSchema = { parse: VoiceMessageResponseTransform };
@@ -1,110 +0,0 @@
1
- import { Routes } from "@/api/routes";
2
- import type { ApiService } from "@/api/service";
3
- import type { MethodOptions } from "@/types/api";
4
-
5
- import type * as FetchBusinessProfile from "./schemas/fetch-business-profile";
6
- import type * as FetchPrivacySettings from "./schemas/fetch-privacy-settings";
7
- import type * as FetchProfile from "./schemas/fetch-profile";
8
- import type * as RemovePicture from "./schemas/remove-picture";
9
- import type * as UpdateName from "./schemas/update-name";
10
- import type * as UpdatePicture from "./schemas/update-picture";
11
- import type * as UpdatePrivacySettings from "./schemas/update-privacy-settings";
12
- import type * as UpdateStatus from "./schemas/update-status";
13
-
14
- export class ProfileModule {
15
- constructor(private readonly api: ApiService) {}
16
-
17
- async fetchBusinessProfile(
18
- options: FetchBusinessProfile.FetchBusinessProfileRequest,
19
- methodOptions?: MethodOptions
20
- ): Promise<FetchBusinessProfile.FetchBusinessProfileResponse> {
21
- const response = await this.api.post(Routes.Profile.FetchBusinessProfile, {
22
- body: options,
23
- ...methodOptions,
24
- });
25
-
26
- return response as FetchBusinessProfile.FetchBusinessProfileResponse;
27
- }
28
-
29
- async fetchProfile(
30
- options: FetchProfile.FetchProfileRequest,
31
- methodOptions?: MethodOptions
32
- ): Promise<FetchProfile.FetchProfileResponse> {
33
- const response = await this.api.post(Routes.Profile.FetchProfile, {
34
- body: options,
35
- ...methodOptions,
36
- });
37
-
38
- return response as FetchProfile.FetchProfileResponse;
39
- }
40
-
41
- async updateName(
42
- options: UpdateName.UpdateNameRequest,
43
- methodOptions?: MethodOptions
44
- ): Promise<UpdateName.UpdateNameResponse> {
45
- const response = await this.api.post(Routes.Profile.UpdateName, {
46
- body: options,
47
- ...methodOptions,
48
- });
49
-
50
- return response as UpdateName.UpdateNameResponse;
51
- }
52
-
53
- async updateStatus(
54
- options: UpdateStatus.UpdateStatusRequest,
55
- methodOptions?: MethodOptions
56
- ): Promise<UpdateStatus.UpdateStatusResponse> {
57
- const response = await this.api.post(Routes.Profile.UpdateStatus, {
58
- body: options,
59
- ...methodOptions,
60
- });
61
-
62
- return response as UpdateStatus.UpdateStatusResponse;
63
- }
64
-
65
- async updatePicture(
66
- options: UpdatePicture.UpdatePictureRequest,
67
- methodOptions?: MethodOptions
68
- ): Promise<UpdatePicture.UpdatePictureResponse> {
69
- const response = await this.api.post(Routes.Profile.UpdatePicture, {
70
- body: options,
71
- ...methodOptions,
72
- });
73
-
74
- return response as UpdatePicture.UpdatePictureResponse;
75
- }
76
-
77
- async removePicture(
78
- methodOptions?: MethodOptions
79
- ): Promise<RemovePicture.RemovePictureResponse> {
80
- const response = await this.api.delete(
81
- Routes.Profile.RemovePicture,
82
- methodOptions
83
- );
84
-
85
- return response as RemovePicture.RemovePictureResponse;
86
- }
87
-
88
- async fetchPrivacySettings(
89
- methodOptions?: MethodOptions
90
- ): Promise<FetchPrivacySettings.FetchPrivacySettingsResponse> {
91
- const response = await this.api.get(
92
- Routes.Profile.FetchPrivacySettings,
93
- methodOptions
94
- );
95
-
96
- return response as FetchPrivacySettings.FetchPrivacySettingsResponse;
97
- }
98
-
99
- async updatePrivacySettings(
100
- options: UpdatePrivacySettings.UpdatePrivacySettingsRequest,
101
- methodOptions?: MethodOptions
102
- ): Promise<UpdatePrivacySettings.UpdatePrivacySettingsResponse> {
103
- const response = await this.api.put(Routes.Profile.UpdatePrivacySettings, {
104
- body: options,
105
- ...methodOptions,
106
- });
107
-
108
- return response as UpdatePrivacySettings.UpdatePrivacySettingsResponse;
109
- }
110
- }
@@ -1,29 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
-
3
- export interface FetchBusinessProfileRequest {
4
- number: string;
5
- }
6
-
7
- export interface BusinessHoursConfig {
8
- day_of_week: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
9
- mode: "open_24h" | "specific_hours" | "closed";
10
- open_time?: string;
11
- close_time?: string;
12
- }
13
-
14
- export interface BusinessHours {
15
- timezone: string;
16
- business_config: BusinessHoursConfig[];
17
- }
18
-
19
- export interface FetchBusinessProfileResponse {
20
- isBusiness: boolean;
21
- wid: string;
22
- description: string;
23
- website: string[];
24
- category: string;
25
- business_hours: BusinessHours;
26
- }
27
-
28
- // Backward compatibility aliases
29
- export type FetchBusinessProfileOptions = FetchBusinessProfileRequest;
@@ -1,11 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export type PrivacySetting = "all" | "contacts" | "contact_blacklist" | "none";
3
-
4
- export interface FetchPrivacySettingsResponse {
5
- online: PrivacySetting;
6
- profile: PrivacySetting;
7
- status: PrivacySetting;
8
- readreceipts: PrivacySetting;
9
- last: PrivacySetting;
10
- groupadd: PrivacySetting;
11
- }
@@ -1,23 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
-
3
- export interface FetchProfileRequest {
4
- number: string;
5
- }
6
-
7
- export interface ProfileStatus {
8
- status: string;
9
- setAt: string;
10
- }
11
-
12
- export interface FetchProfileResponse {
13
- wuid: string;
14
- name: string | null;
15
- numberExists: boolean;
16
- picture?: string;
17
- status?: ProfileStatus;
18
- isBusiness: boolean;
19
- description?: string;
20
- }
21
-
22
- // Backward compatibility aliases
23
- export type FetchProfileOptions = FetchProfileRequest;
@@ -1,8 +0,0 @@
1
- export * from "./fetch-business-profile";
2
- export * from "./fetch-profile";
3
- export * from "./fetch-privacy-settings";
4
- export * from "./remove-picture";
5
- export * from "./update-name";
6
- export { type UpdatePictureOptions as UpdateProfilePictureOptions, type UpdatePictureResponse as UpdateProfilePictureResponse } from "./update-picture";
7
- export * from "./update-privacy-settings";
8
- export * from "./update-status";
@@ -1,4 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface RemovePictureResponse {
3
- status: string;
4
- }
@@ -1,11 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface UpdateNameRequest {
3
- name: string;
4
- }
5
-
6
- export interface UpdateNameResponse {
7
- update: "success" | "error";
8
- }
9
-
10
- // Backward compatibility aliases
11
- export type UpdateNameOptions = UpdateNameRequest;
@@ -1,11 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface UpdatePictureRequest {
3
- picture: string;
4
- }
5
-
6
- export interface UpdatePictureResponse {
7
- update: "success" | "error";
8
- }
9
-
10
- // Backward compatibility aliases
11
- export type UpdatePictureOptions = UpdatePictureRequest;
@@ -1,18 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- import type { PrivacySetting } from "./fetch-privacy-settings";
3
-
4
- export interface UpdatePrivacySettingsRequest {
5
- online?: PrivacySetting;
6
- profile?: PrivacySetting;
7
- status?: PrivacySetting;
8
- readreceipts?: PrivacySetting;
9
- last?: PrivacySetting;
10
- groupadd?: PrivacySetting;
11
- }
12
-
13
- export interface UpdatePrivacySettingsResponse {
14
- status: string;
15
- }
16
-
17
- // Backward compatibility aliases
18
- export type UpdatePrivacySettingsOptions = UpdatePrivacySettingsRequest;
@@ -1,11 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface UpdateStatusRequest {
3
- status: string;
4
- }
5
-
6
- export interface UpdateStatusResponse {
7
- status: string;
8
- }
9
-
10
- // Backward compatibility aliases
11
- export type UpdateStatusOptions = UpdateStatusRequest;
@@ -1,28 +0,0 @@
1
- import { Routes } from "@/api/routes";
2
- import type { ApiService } from "@/api/service";
3
- import type { MethodOptions } from "@/types/api";
4
-
5
- import type * as Find from "./schemas/find";
6
- import type * as Set from "./schemas/set";
7
-
8
- export class SettingsModule {
9
- constructor(private readonly api: ApiService) {}
10
-
11
- async set(
12
- options: Set.SetRequest,
13
- methodOptions?: MethodOptions
14
- ): Promise<Set.SetResponse> {
15
- const response = await this.api.post(Routes.Settings.Set, {
16
- body: options,
17
- ...methodOptions,
18
- });
19
-
20
- return response as Set.SetResponse;
21
- }
22
-
23
- async find(methodOptions?: MethodOptions): Promise<Find.FindResponse> {
24
- const response = await this.api.get(Routes.Settings.Find, methodOptions);
25
-
26
- return response as Find.FindResponse;
27
- }
28
- }
@@ -1,11 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface FindResponse {
3
- rejectCall: boolean;
4
- msgCall: string;
5
- groupsIgnore: boolean;
6
- alwaysOnline: boolean;
7
- readMessages: boolean;
8
- readStatus: boolean;
9
- syncFullHistory: boolean;
10
- wavoipToken: string;
11
- }
@@ -1,2 +0,0 @@
1
- export { type FindResponse as FindSettingsResponse } from "./find";
2
- export { type SetOptions as SetSettingsOptions, type SetResponse as SetSettingsResponse } from "./set";
@@ -1,18 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface SetRequest {
3
- rejectCall?: boolean;
4
- msgCall?: string;
5
- groupsIgnore: boolean; // Required by API
6
- alwaysOnline: boolean; // Required by API
7
- readMessages: boolean; // Required by API
8
- readStatus: boolean; // Required by API
9
- syncFullHistory: boolean; // Required by API
10
- wavoipToken?: string;
11
- }
12
-
13
- export interface SetResponse {
14
- message: string;
15
- }
16
-
17
- // Backward compatibility aliases
18
- export type SetOptions = SetRequest;
@@ -1,28 +0,0 @@
1
- import { Routes } from "@/api/routes";
2
- import type { ApiService } from "@/api/service";
3
- import type { MethodOptions } from "@/types/api";
4
-
5
- import type * as Find from "./schemas/find";
6
- import type * as Set from "./schemas/set";
7
-
8
- export class WebhookModule {
9
- constructor(private readonly api: ApiService) {}
10
-
11
- async set(
12
- options: Set.SetRequest,
13
- methodOptions?: MethodOptions
14
- ): Promise<Set.SetResponse> {
15
- const response = await this.api.post(Routes.Webhook.Set, {
16
- body: options,
17
- ...methodOptions,
18
- });
19
-
20
- return response as Set.SetResponse;
21
- }
22
-
23
- async find(methodOptions?: MethodOptions): Promise<Find.FindResponse> {
24
- const response = await this.api.get(Routes.Webhook.Find, methodOptions);
25
-
26
- return response as Find.FindResponse;
27
- }
28
- }
@@ -1,7 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
- export interface FindResponse {
3
- webhook: string;
4
- enabled: boolean;
5
- webhook_by_events: boolean;
6
- events: string[];
7
- }
@@ -1,2 +0,0 @@
1
- export { type FindResponse as FindWebhookResponse } from "./find";
2
- export { type SetOptions as SetWebhookOptions, type SetResponse as SetWebhookResponse } from "./set";
@@ -1,16 +0,0 @@
1
- import { WebhookEventSetup } from "@/types/events";
2
- // Pure TypeScript interfaces for better IDE support and performance
3
- export interface SetRequest {
4
- enabled: boolean;
5
- url: string;
6
- webhookByEvents: boolean;
7
- webhookBase64: boolean;
8
- events: WebhookEventSetup[];
9
- }
10
-
11
- export interface SetResponse {
12
- message: string;
13
- }
14
-
15
- // Backward compatibility aliases
16
- export type SetOptions = SetRequest;
@@ -1,23 +0,0 @@
1
- // Pure TypeScript interfaces for better IDE support and performance
2
-
3
- /**
4
- * Configuration options for the Evolution API client
5
- */
6
- export interface ClientOptions {
7
- /**
8
- * Your server URL
9
- */
10
- serverUrl: string;
11
- /**
12
- * Your instance token or global API key
13
- */
14
- token: string;
15
- /**
16
- * Your instance name
17
- */
18
- instance?: string;
19
- /**
20
- * Custom headers to include in requests
21
- */
22
- headers?: Record<string, string>;
23
- }
@@ -1,44 +0,0 @@
1
- // Pure TypeScript types and utility functions for better IDE support and performance
2
- import { isValidPhoneNumber, parsePhoneNumber } from "libphonenumber-js";
3
- import type { GroupInviteCode, GroupJid, Jid } from "@/types/tags";
4
-
5
- // Type definitions
6
- export type PhoneNumber = string;
7
- export type MessageId = string;
8
- export type ChatId = PhoneNumber | Jid | GroupJid;
9
- export type ApiNumber = PhoneNumber | Jid | GroupJid;
10
- export type Media = string; // URL or base64 string
11
-
12
- // Utility functions
13
- export const validatePhoneNumber = (value: string): boolean => isValidPhoneNumber(value);
14
- export const parsePhoneNumberUtil = (phoneNumber: string): string => parsePhoneNumber(phoneNumber).number;
15
-
16
- export const validateJid = (value: string): boolean => value.endsWith("@s.whatsapp.net");
17
- export const validateGroupJid = (value: string): boolean => value.endsWith("@g.us");
18
- export const validateGroupInviteCode = (value: string): boolean =>
19
- value.length === 22 && /^[a-zA-Z0-9]{22}$/.test(value);
20
-
21
- export const validateMedia = (value: string): boolean => {
22
- // Check if it's a URL or base64 string
23
- try {
24
- new URL(value);
25
- return true;
26
- } catch {
27
- // Check if it's a valid base64 string
28
- try {
29
- return btoa(atob(value)) === value;
30
- } catch {
31
- return false;
32
- }
33
- }
34
- };
35
-
36
- // Backward compatibility - keeping the schema names but as type aliases
37
- export type PhoneNumberSchema = PhoneNumber;
38
- export type JidSchema = Jid;
39
- export type GroupJidSchema = GroupJid;
40
- export type GroupInviteCodeSchema = GroupInviteCode;
41
- export type MessageIdSchema = MessageId;
42
- export type ChatIdSchema = ChatId;
43
- export type ApiNumberSchema = ApiNumber;
44
- export type mediaSchema = Media;
package/src/types/api.ts DELETED
@@ -1,17 +0,0 @@
1
- // Internal interface used by the service
2
- export interface APIRequestInit {
3
- method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
4
- params?: any; // Accept any object type for params
5
- body?: any; // Accept any object type for body
6
- headers?: Record<string, string>;
7
- isInstanceUrl?: boolean;
8
- instance?: string;
9
- }
10
-
11
- // Public interface for method options that users can pass
12
- export interface MethodOptions {
13
- /**
14
- * Instance name to use for this request (overrides default instance)
15
- */
16
- instance?: string;
17
- }
@@ -1,53 +0,0 @@
1
- export enum WebhookEvent {
2
- APPLICATION_STARTUP = "application.startup",
3
- QRCODE_UPDATED = "qrcode.updated",
4
- CONNECTION_UPDATE = "connection.update",
5
- MESSAGES_SET = "messages.set",
6
- MESSAGES_UPSERT = "messages.upsert",
7
- MESSAGES_UPDATE = "messages.update",
8
- MESSAGES_DELETE = "messages.delete",
9
- SEND_MESSAGE = "send.message",
10
- CONTACTS_SET = "contacts.set",
11
- CONTACTS_UPSERT = "contacts.upsert",
12
- CONTACTS_UPDATE = "contacts.update",
13
- PRESENCE_UPDATE = "presence.update",
14
- CHATS_SET = "chats.set",
15
- CHATS_UPDATE = "chats.update",
16
- CHATS_UPSERT = "chats.upsert",
17
- CHATS_DELETE = "chats.delete",
18
- GROUPS_UPSERT = "groups.upsert",
19
- GROUPS_UPDATE = "groups.update",
20
- GROUP_PARTICIPANTS_UPDATE = "group.participants.update",
21
- NEW_TOKEN = "new.jwt",
22
- }
23
-
24
- export enum WebhookEventSetup {
25
- APPLICATION_STARTUP = "APPLICATION_STARTUP",
26
- QRCODE_UPDATED = "QRCODE_UPDATED",
27
- CONNECTION_UPDATE = "CONNECTION_UPDATE",
28
- MESSAGES_SET = "MESSAGES_SET",
29
- MESSAGES_UPSERT = "MESSAGES_UPSERT",
30
- MESSAGES_UPDATE = "MESSAGES_UPDATE",
31
- MESSAGES_DELETE = "MESSAGES_DELETE",
32
- SEND_MESSAGE = "SEND_MESSAGE",
33
- CONTACTS_SET = "CONTACTS_SET",
34
- CONTACTS_UPSERT = "CONTACTS_UPSERT",
35
- CONTACTS_UPDATE = "CONTACTS_UPDATE",
36
- PRESENCE_UPDATE = "PRESENCE_UPDATE",
37
- CHATS_SET = "CHATS_SET",
38
- CHATS_UPDATE = "CHATS_UPDATE",
39
- CHATS_UPSERT = "CHATS_UPSERT",
40
- CHATS_DELETE = "CHATS_DELETE",
41
- GROUPS_UPSERT = "GROUPS_UPSERT",
42
- GROUPS_UPDATE = "GROUPS_UPDATE",
43
- GROUP_PARTICIPANTS_UPDATE = "GROUP_PARTICIPANTS_UPDATE",
44
- NEW_TOKEN = "NEW_TOKEN",
45
- MESSAGES_EDITED = "MESSAGES_EDITED",
46
- LABELS_EDIT = "LABELS_EDIT",
47
- LABELS_ASSOCIATION = "LABELS_ASSOCIATION",
48
- CALL = "CALL",
49
- TYPEBOT_START = "TYPEBOT_START",
50
- TYPEBOT_CHANGE_STATUS = "TYPEBOT_CHANGE_STATUS",
51
- ERRORS = "ERRORS",
52
- ERRORS_WEBHOOK = "ERRORS_WEBHOOK",
53
- }
@@ -1,5 +0,0 @@
1
- export enum MessageUpdateStatus {
2
- DELIVERY_ACK = "DELIVERY_ACK",
3
- READ = "READ",
4
- SERVER_ACK = "SERVER_ACK",
5
- }
package/src/types/tags.ts DELETED
@@ -1,14 +0,0 @@
1
- export type Jid = `${string}@s.whatsapp.net` | string;
2
- export const Jid = (jid: string) => jid as Jid;
3
-
4
- export type GroupJid = `${string}@g.us` | string;
5
- export const GroupJid = (jid: string) => jid as GroupJid;
6
-
7
- export type GroupInviteCode = string & { __tag: "GroupInviteCode" };
8
- export const GroupInviteCode = (code: string) => code as GroupInviteCode;
9
-
10
- export type MessageId = string & { __tag: "MessageId" };
11
- export const MessageId = (id: string) => id as MessageId;
12
-
13
- export type ChatId = string & { __tag: "ChatId" };
14
- export const ChatId = (id: string) => id as ChatId;