@zapyapi/sdk 1.0.0-beta.6 → 1.0.0-beta.8

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.
@@ -1,257 +0,0 @@
1
- /**
2
- * Webhook event type definitions
3
- * Types for webhook payloads sent by ZapyAPI
4
- */
5
- import type { MessageType, MessageAckStatus, ConnectionStatus, InstanceStatus, WebhookEventType as WebhookEventTypeEnum } from './enums';
6
- /**
7
- * Re-export the enum type for convenience
8
- */
9
- export type WebhookEventType = WebhookEventTypeEnum;
10
- /**
11
- * Base webhook event payload
12
- * All webhook events include these fields
13
- */
14
- export interface WebhookEventBase<T extends WebhookEventType = WebhookEventType> {
15
- /** Event type identifier */
16
- event: T;
17
- /** Instance ID that generated the event */
18
- instanceId: string;
19
- }
20
- /**
21
- * Message sender/recipient info
22
- */
23
- export interface MessageParticipant {
24
- /** WhatsApp ID (e.g., "5511999999999@c.us") */
25
- id: string;
26
- /** Phone number (e.g., "5511999999999") */
27
- phone: string;
28
- /** Display name if available */
29
- name?: string;
30
- /** Push name (user's WhatsApp name) */
31
- pushName?: string;
32
- }
33
- /**
34
- * Media information in messages
35
- */
36
- export interface MediaInfo {
37
- /** MIME type of the media */
38
- mimeType: string;
39
- /** File name if available */
40
- fileName?: string;
41
- /** File size in bytes */
42
- fileSize?: number;
43
- /** Media URL (temporary, expires) */
44
- url?: string;
45
- }
46
- /**
47
- * Message webhook event data
48
- */
49
- export interface MessageEventData {
50
- /** WhatsApp message ID */
51
- messageId: string;
52
- /** Message sender */
53
- from: MessageParticipant;
54
- /** Message recipient (your number/instance) */
55
- to: MessageParticipant;
56
- /** Message content type */
57
- type: MessageType;
58
- /** Text content (for text messages) */
59
- text?: string;
60
- /** Caption (for media messages) */
61
- caption?: string;
62
- /** Media information (for media messages) */
63
- media?: MediaInfo;
64
- /** Whether this is a group message */
65
- isGroup: boolean;
66
- /** Group participant who sent the message (for group messages) */
67
- participant?: MessageParticipant;
68
- /** ID of quoted/replied message */
69
- quotedMessageId?: string;
70
- /** Message timestamp (Unix ms) */
71
- timestamp: number;
72
- /** Whether this is a forwarded message */
73
- isForwarded?: boolean;
74
- /** Whether this is a broadcast message */
75
- isBroadcast?: boolean;
76
- }
77
- /**
78
- * Message webhook event
79
- */
80
- export interface MessageWebhookEvent extends WebhookEventBase<'message'> {
81
- data: MessageEventData;
82
- }
83
- /**
84
- * Message status update event data
85
- */
86
- export interface MessageStatusEventData {
87
- /** WhatsApp message ID */
88
- messageId: string;
89
- /** New acknowledgment status */
90
- ack: MessageAckStatus;
91
- /** Sender of the original message */
92
- from: string;
93
- /** Recipient of the original message */
94
- to: string;
95
- /** Timestamp of status update (Unix ms) */
96
- timestamp: number;
97
- }
98
- /**
99
- * Message acknowledgment/status webhook event
100
- */
101
- export interface MessageAckWebhookEvent extends WebhookEventBase<'message-status'> {
102
- data: MessageStatusEventData;
103
- }
104
- /**
105
- * QR code update event data
106
- */
107
- export interface QRCodeEventData {
108
- /** QR code as base64 data URL */
109
- qrCode: string;
110
- /** QR code generation attempt number */
111
- attempt: number;
112
- /** Expiration timestamp (Unix ms) */
113
- expiresAt: number;
114
- }
115
- /**
116
- * QR code update webhook event
117
- */
118
- export interface QRCodeWebhookEvent extends WebhookEventBase<'qr-code'> {
119
- data: QRCodeEventData;
120
- }
121
- /**
122
- * Contact information
123
- */
124
- export interface ContactInfo {
125
- /** WhatsApp ID */
126
- id: string;
127
- /** Phone number */
128
- phone: string;
129
- /** Contact name */
130
- name?: string;
131
- /** Push name (WhatsApp display name) */
132
- pushName?: string;
133
- /** Profile picture URL */
134
- profilePicUrl?: string;
135
- /** Whether this is a business account */
136
- isBusiness?: boolean;
137
- }
138
- /**
139
- * Contact created event data
140
- */
141
- export interface ContactCreatedEventData {
142
- /** The new contact */
143
- contact: ContactInfo;
144
- }
145
- /**
146
- * Contact created webhook event
147
- */
148
- export interface ContactCreatedWebhookEvent extends WebhookEventBase<'contact-created'> {
149
- data: ContactCreatedEventData;
150
- }
151
- /**
152
- * Contact updated event data
153
- */
154
- export interface ContactUpdatedEventData {
155
- /** The updated contact */
156
- contact: ContactInfo;
157
- /** Fields that were updated */
158
- updatedFields: string[];
159
- }
160
- /**
161
- * Contact updated webhook event
162
- */
163
- export interface ContactUpdatedWebhookEvent extends WebhookEventBase<'contact-updated'> {
164
- data: ContactUpdatedEventData;
165
- }
166
- /**
167
- * Contact deduplicated event data
168
- */
169
- export interface ContactDeduplicatedEventData {
170
- /** The primary contact that was kept */
171
- primaryContact: ContactInfo;
172
- /** The duplicate contact that was merged */
173
- duplicateContact: ContactInfo;
174
- }
175
- /**
176
- * Contact deduplicated webhook event
177
- */
178
- export interface ContactDeduplicatedWebhookEvent extends WebhookEventBase<'contact-deduplicated'> {
179
- data: ContactDeduplicatedEventData;
180
- }
181
- /**
182
- * Instance status change event data
183
- */
184
- export interface InstanceStatusEventData {
185
- /** Instance ID */
186
- instanceId: string;
187
- /** Current status */
188
- status: InstanceStatus;
189
- /** Previous status before this change */
190
- previousStatus?: InstanceStatus;
191
- /** Timestamp of status change (Unix ms) */
192
- timestamp: number;
193
- /** Reason for status change */
194
- reason?: string;
195
- /** Connected WhatsApp number (if available) */
196
- connectedNumber?: string;
197
- }
198
- /**
199
- * Instance status change webhook event
200
- */
201
- export interface InstanceStatusWebhookEvent extends WebhookEventBase<'instance-status'> {
202
- data: InstanceStatusEventData;
203
- }
204
- /**
205
- * Connection status update event data
206
- * @deprecated Use InstanceStatusEventData instead
207
- */
208
- export interface ConnectionEventData {
209
- /** Connection status */
210
- status: ConnectionStatus;
211
- /** Reason for status change */
212
- reason?: string;
213
- }
214
- /**
215
- * Connection status webhook event
216
- * @deprecated Use InstanceStatusWebhookEvent instead
217
- */
218
- export interface ConnectionWebhookEvent {
219
- event: 'connection.update';
220
- instanceId: string;
221
- data: ConnectionEventData;
222
- }
223
- /**
224
- * Union type for all webhook events
225
- *
226
- * @example
227
- * ```typescript
228
- * import { WebhookEvent, WebhookEventType } from '@zapyapi/sdk';
229
- *
230
- * function handleWebhook(event: WebhookEvent) {
231
- * switch (event.event) {
232
- * case 'message':
233
- * console.log('New message:', event.data.text);
234
- * break;
235
- * case 'message-status':
236
- * console.log('Status update:', event.data.ack);
237
- * break;
238
- * }
239
- * }
240
- * ```
241
- */
242
- export type WebhookEvent = MessageWebhookEvent | MessageAckWebhookEvent | QRCodeWebhookEvent | ContactCreatedWebhookEvent | ContactUpdatedWebhookEvent | ContactDeduplicatedWebhookEvent | InstanceStatusWebhookEvent;
243
- /** Type guard for message events */
244
- export declare function isMessageEvent(event: WebhookEvent): event is MessageWebhookEvent;
245
- /** Type guard for message status events */
246
- export declare function isMessageStatusEvent(event: WebhookEvent): event is MessageAckWebhookEvent;
247
- /** Type guard for QR code events */
248
- export declare function isQRCodeEvent(event: WebhookEvent): event is QRCodeWebhookEvent;
249
- /** Type guard for contact created events */
250
- export declare function isContactCreatedEvent(event: WebhookEvent): event is ContactCreatedWebhookEvent;
251
- /** Type guard for contact updated events */
252
- export declare function isContactUpdatedEvent(event: WebhookEvent): event is ContactUpdatedWebhookEvent;
253
- /** Type guard for contact deduplicated events */
254
- export declare function isContactDeduplicatedEvent(event: WebhookEvent): event is ContactDeduplicatedWebhookEvent;
255
- /** Type guard for instance status events */
256
- export declare function isInstanceStatusEvent(event: WebhookEvent): event is InstanceStatusWebhookEvent;
257
- //# sourceMappingURL=webhook-events.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webhook-events.types.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk/src/types/webhook-events.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,IAAI,oBAAoB,EACzC,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,S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