@gymspace/evolution 1.0.0

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 (101) hide show
  1. package/README.md +1273 -0
  2. package/dist/index.d.mts +1790 -0
  3. package/dist/index.d.ts +1790 -0
  4. package/dist/index.js +1091 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +1077 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +63 -0
  9. package/src/api/errors.ts +220 -0
  10. package/src/api/routes.ts +76 -0
  11. package/src/api/service.ts +141 -0
  12. package/src/index.ts +89 -0
  13. package/src/modules/chats/index.ts +253 -0
  14. package/src/modules/chats/schemas/archive.ts +15 -0
  15. package/src/modules/chats/schemas/check.ts +20 -0
  16. package/src/modules/chats/schemas/delete-message.ts +16 -0
  17. package/src/modules/chats/schemas/fetch-profile-picture.ts +13 -0
  18. package/src/modules/chats/schemas/find-all.ts +49 -0
  19. package/src/modules/chats/schemas/find-contacts.ts +17 -0
  20. package/src/modules/chats/schemas/find-messages.ts +55 -0
  21. package/src/modules/chats/schemas/find-status-message.ts +11 -0
  22. package/src/modules/chats/schemas/get-base64-from-media-message.ts +20 -0
  23. package/src/modules/chats/schemas/index.ts +33 -0
  24. package/src/modules/chats/schemas/mark-as-read.ts +20 -0
  25. package/src/modules/chats/schemas/mark-as-unread.ts +17 -0
  26. package/src/modules/chats/schemas/presence.ts +41 -0
  27. package/src/modules/chats/schemas/update-message.ts +16 -0
  28. package/src/modules/groups/index.ts +246 -0
  29. package/src/modules/groups/schemas/accept-invite-code.ts +14 -0
  30. package/src/modules/groups/schemas/common.ts +89 -0
  31. package/src/modules/groups/schemas/create.ts +15 -0
  32. package/src/modules/groups/schemas/fetch-invite-code.ts +13 -0
  33. package/src/modules/groups/schemas/find-all.ts +26 -0
  34. package/src/modules/groups/schemas/find-by-invite-code.ts +39 -0
  35. package/src/modules/groups/schemas/find-by-jid.ts +14 -0
  36. package/src/modules/groups/schemas/find-members.ts +16 -0
  37. package/src/modules/groups/schemas/index.ts +24 -0
  38. package/src/modules/groups/schemas/leave.ts +14 -0
  39. package/src/modules/groups/schemas/revoke-invite-code.ts +14 -0
  40. package/src/modules/groups/schemas/send-group-invite.ts +15 -0
  41. package/src/modules/groups/schemas/toggle-ephemeral.ts +15 -0
  42. package/src/modules/groups/schemas/update-description.ts +15 -0
  43. package/src/modules/groups/schemas/update-members.ts +18 -0
  44. package/src/modules/groups/schemas/update-picture.ts +15 -0
  45. package/src/modules/groups/schemas/update-setting.ts +16 -0
  46. package/src/modules/groups/schemas/update-subject.ts +15 -0
  47. package/src/modules/index.ts +7 -0
  48. package/src/modules/instance/index.ts +126 -0
  49. package/src/modules/instance/schemas/connect.ts +14 -0
  50. package/src/modules/instance/schemas/connection-state.ts +16 -0
  51. package/src/modules/instance/schemas/create.ts +99 -0
  52. package/src/modules/instance/schemas/delete.ts +21 -0
  53. package/src/modules/instance/schemas/fetch-all.ts +57 -0
  54. package/src/modules/instance/schemas/index.ts +8 -0
  55. package/src/modules/instance/schemas/logout.ts +22 -0
  56. package/src/modules/instance/schemas/restart.ts +13 -0
  57. package/src/modules/instance/schemas/set-presence.ts +20 -0
  58. package/src/modules/messages/index.ts +246 -0
  59. package/src/modules/messages/schemas/audio.ts +12 -0
  60. package/src/modules/messages/schemas/base.ts +11 -0
  61. package/src/modules/messages/schemas/contact.ts +70 -0
  62. package/src/modules/messages/schemas/document.ts +12 -0
  63. package/src/modules/messages/schemas/image.ts +12 -0
  64. package/src/modules/messages/schemas/index.ts +31 -0
  65. package/src/modules/messages/schemas/list.ts +36 -0
  66. package/src/modules/messages/schemas/location.ts +76 -0
  67. package/src/modules/messages/schemas/media.ts +51 -0
  68. package/src/modules/messages/schemas/poll.ts +87 -0
  69. package/src/modules/messages/schemas/reaction.ts +21 -0
  70. package/src/modules/messages/schemas/status.ts +18 -0
  71. package/src/modules/messages/schemas/sticker.ts +77 -0
  72. package/src/modules/messages/schemas/template.ts +39 -0
  73. package/src/modules/messages/schemas/text.ts +88 -0
  74. package/src/modules/messages/schemas/video.ts +12 -0
  75. package/src/modules/messages/schemas/voice.ts +94 -0
  76. package/src/modules/profile/index.ts +110 -0
  77. package/src/modules/profile/schemas/fetch-business-profile.ts +29 -0
  78. package/src/modules/profile/schemas/fetch-privacy-settings.ts +11 -0
  79. package/src/modules/profile/schemas/fetch-profile.ts +23 -0
  80. package/src/modules/profile/schemas/index.ts +8 -0
  81. package/src/modules/profile/schemas/remove-picture.ts +4 -0
  82. package/src/modules/profile/schemas/update-name.ts +11 -0
  83. package/src/modules/profile/schemas/update-picture.ts +11 -0
  84. package/src/modules/profile/schemas/update-privacy-settings.ts +18 -0
  85. package/src/modules/profile/schemas/update-status.ts +11 -0
  86. package/src/modules/settings/index.ts +28 -0
  87. package/src/modules/settings/schemas/find.ts +11 -0
  88. package/src/modules/settings/schemas/index.ts +2 -0
  89. package/src/modules/settings/schemas/set.ts +18 -0
  90. package/src/modules/webhook/index.ts +28 -0
  91. package/src/modules/webhook/schemas/find.ts +7 -0
  92. package/src/modules/webhook/schemas/index.ts +2 -0
  93. package/src/modules/webhook/schemas/set.ts +16 -0
  94. package/src/schemas/client.ts +23 -0
  95. package/src/schemas/common.ts +44 -0
  96. package/src/types/api.ts +17 -0
  97. package/src/types/events.ts +53 -0
  98. package/src/types/messages.ts +5 -0
  99. package/src/types/tags.ts +14 -0
  100. package/src/types/webhooks.ts +255 -0
  101. package/src/utils/phone-numer-from-jid.ts +9 -0
@@ -0,0 +1,77 @@
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 StickerMessageResponseRaw {
9
+ key: {
10
+ remoteJid: string;
11
+ id: string;
12
+ };
13
+ message: {
14
+ stickerMessage: {
15
+ url: string;
16
+ fileSha256: string;
17
+ fileEncSha256: string;
18
+ mediaKey: string;
19
+ mimetype?: string;
20
+ directPath: string;
21
+ fileLength: number | string;
22
+ mediaKeyTimestamp: number | string;
23
+ };
24
+ };
25
+ messageTimestamp: string | Date;
26
+ }
27
+
28
+ // Request interfaces
29
+ export interface StickerMessageOptions extends BaseMessageOptions {
30
+ /**
31
+ * Image URL or file in base64
32
+ */
33
+ sticker: Media;
34
+ }
35
+
36
+ // Response interfaces
37
+ export interface StickerMessageResponse {
38
+ receiver: {
39
+ phoneNumber: string;
40
+ jid: Jid;
41
+ };
42
+ media: {
43
+ url: string;
44
+ mimetype?: string;
45
+ length: number;
46
+ sha256: string;
47
+ encryptedSha256: string;
48
+ directPath: string;
49
+ key: string;
50
+ keyTimestamp: Date;
51
+ };
52
+ id: MessageId;
53
+ timestamp: Date;
54
+ }
55
+
56
+ // Transform function
57
+ export const StickerMessageResponseTransform = (data: StickerMessageResponseRaw): StickerMessageResponse => ({
58
+ receiver: {
59
+ phoneNumber: phoneNumberFromJid(data.key.remoteJid),
60
+ jid: Jid(data.key.remoteJid),
61
+ },
62
+ media: {
63
+ url: data.message.stickerMessage.url,
64
+ mimetype: data.message.stickerMessage.mimetype,
65
+ length: Number(data.message.stickerMessage.fileLength),
66
+ sha256: data.message.stickerMessage.fileSha256,
67
+ encryptedSha256: data.message.stickerMessage.fileEncSha256,
68
+ directPath: data.message.stickerMessage.directPath,
69
+ key: data.message.stickerMessage.mediaKey,
70
+ keyTimestamp: new Date(Number(data.message.stickerMessage.mediaKeyTimestamp)),
71
+ },
72
+ id: MessageId(data.key.id),
73
+ timestamp: new Date(data.messageTimestamp),
74
+ });
75
+
76
+ // Backward compatibility aliases
77
+ export const ResponseSchema = { parse: StickerMessageResponseTransform };
@@ -0,0 +1,39 @@
1
+ // Pure TypeScript interfaces for better IDE support and performance
2
+ import type { ChatId, MessageId } from "@/types/tags";
3
+
4
+ export interface ComponentParameter {
5
+ type: "text" | "image" | "document" | "video";
6
+ text?: string;
7
+ image?: { link: string };
8
+ document?: { link: string };
9
+ video?: { link: string };
10
+ }
11
+
12
+ export interface Component {
13
+ type: "body" | "header" | "button";
14
+ sub_type?: "text" | "url" | "quick_reply";
15
+ parameters: ComponentParameter[];
16
+ }
17
+
18
+ export interface TemplateMessageOptions {
19
+ number: ChatId;
20
+ name: string;
21
+ language: {
22
+ code: string;
23
+ };
24
+ components: Component[];
25
+ options?: {
26
+ delay?: number;
27
+ messageId?: MessageId;
28
+ };
29
+ }
30
+
31
+ export interface TemplateMessageResponse {
32
+ key: {
33
+ remoteJid: ChatId;
34
+ fromMe: boolean;
35
+ id: MessageId;
36
+ };
37
+ messageTimestamp: string;
38
+ status: string;
39
+ }
@@ -0,0 +1,88 @@
1
+ // Pure TypeScript interfaces for better IDE support and performance
2
+ import { Jid, MessageId } from "@/types/tags";
3
+ import { phoneNumberFromJid } from "@/utils/phone-numer-from-jid";
4
+ import { BaseMessageOptions } from "./base";
5
+
6
+ // Raw response interface from API
7
+ export interface TextMessageResponseRaw {
8
+ key: {
9
+ remoteJid: string;
10
+ fromMe: boolean;
11
+ id: string;
12
+ };
13
+ pushName: string;
14
+ status: string;
15
+ message: {
16
+ conversation: string;
17
+ };
18
+ contextInfo: null;
19
+ messageType: string;
20
+ messageTimestamp: number;
21
+ instanceId: string;
22
+ source: string;
23
+ }
24
+
25
+ // Request interfaces
26
+ export interface TextMessageOptions extends BaseMessageOptions {
27
+ /**
28
+ * Message text content
29
+ */
30
+ text: string;
31
+ /**
32
+ * Whether link preview should be shown
33
+ */
34
+ linkPreview?: boolean;
35
+ }
36
+
37
+ // Response interfaces
38
+ export interface TextMessageResponse {
39
+ key: {
40
+ remoteJid: string;
41
+ fromMe: boolean;
42
+ id: string;
43
+ };
44
+ pushName: string;
45
+ status: string;
46
+ message: {
47
+ conversation: string;
48
+ };
49
+ contextInfo: null;
50
+ messageType: string;
51
+ messageTimestamp: number;
52
+ instanceId: string;
53
+ source: string;
54
+ receiver: {
55
+ phoneNumber: string;
56
+ jid: Jid;
57
+ };
58
+ messageId: MessageId;
59
+ timestamp: Date;
60
+ }
61
+
62
+ export interface TextMessageReceived {
63
+ conversation: string;
64
+ extendedTextMessage: {
65
+ text: string;
66
+ };
67
+ }
68
+
69
+ // Transform function
70
+ export const TextMessageResponseTransform = (
71
+ data: TextMessageResponseRaw
72
+ ): TextMessageResponse => ({
73
+ receiver: {
74
+ phoneNumber: phoneNumberFromJid(data.key.remoteJid),
75
+ jid: Jid(data.key.remoteJid),
76
+ },
77
+ messageId: MessageId(data.key.id),
78
+ timestamp: new Date(data.messageTimestamp),
79
+ key: data.key,
80
+ pushName: data.pushName,
81
+ status: data.status,
82
+ message: data.message,
83
+ contextInfo: data.contextInfo,
84
+ messageType: data.messageType,
85
+ messageTimestamp: data.messageTimestamp,
86
+ instanceId: data.instanceId,
87
+ source: data.source,
88
+ });
@@ -0,0 +1,12 @@
1
+ // Pure TypeScript interfaces for better IDE support and performance
2
+ import { MediaMessageOptions, MediaMessageResponse } from "./media";
3
+
4
+ // Request interfaces
5
+ export interface VideoMessageOptions extends MediaMessageOptions {}
6
+
7
+ // Response interfaces
8
+ export interface VideoMessageResponse extends MediaMessageResponse {
9
+ message: MediaMessageResponse["message"] & {
10
+ videoMessage: MediaMessageResponse["message"]["videoMessage"];
11
+ };
12
+ }
@@ -0,0 +1,94 @@
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 };
@@ -0,0 +1,110 @@
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
+ }
@@ -0,0 +1,29 @@
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;
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1,23 @@
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;
@@ -0,0 +1,8 @@
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";
@@ -0,0 +1,4 @@
1
+ // Pure TypeScript interfaces for better IDE support and performance
2
+ export interface RemovePictureResponse {
3
+ status: string;
4
+ }
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export { type FindResponse as FindSettingsResponse } from "./find";
2
+ export { type SetOptions as SetSettingsOptions, type SetResponse as SetSettingsResponse } from "./set";
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export { type FindResponse as FindWebhookResponse } from "./find";
2
+ export { type SetOptions as SetWebhookOptions, type SetResponse as SetWebhookResponse } from "./set";
@@ -0,0 +1,16 @@
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;