@pilot-status/sdk 0.2.0 → 0.3.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.
- package/README.md +1 -13
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/api-keys.d.ts.map +1 -1
- package/dist/resources/api-keys.js +3 -0
- package/dist/resources/api-keys.js.map +1 -1
- package/dist/resources/media.d.ts +8 -0
- package/dist/resources/media.d.ts.map +1 -0
- package/dist/resources/media.js +14 -0
- package/dist/resources/media.js.map +1 -0
- package/dist/resources/messages.d.ts +2 -2
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +23 -10
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/numbers.d.ts +3 -8
- package/dist/resources/numbers.d.ts.map +1 -1
- package/dist/resources/numbers.js +4 -14
- package/dist/resources/numbers.js.map +1 -1
- package/dist/resources/remote-pairing.d.ts +10 -0
- package/dist/resources/remote-pairing.d.ts.map +1 -0
- package/dist/resources/remote-pairing.js +25 -0
- package/dist/resources/remote-pairing.js.map +1 -0
- package/dist/types.d.ts +43 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/webhooks/parse.d.ts.map +1 -1
- package/dist/webhooks/parse.js +81 -130
- package/dist/webhooks/parse.js.map +1 -1
- package/dist/webhooks/types.d.ts +89 -140
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/webhooks/types.js +7 -0
- package/dist/webhooks/types.js.map +1 -1
- package/package.json +4 -3
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../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MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAuKvD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAE3E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,oBAAoB,CAExF"}
|
package/dist/webhooks/parse.js
CHANGED
|
@@ -1,183 +1,135 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
const
|
|
2
|
+
const messageType = z.enum([
|
|
3
|
+
"text",
|
|
4
|
+
"image",
|
|
5
|
+
"audio",
|
|
6
|
+
"video",
|
|
7
|
+
"document",
|
|
8
|
+
"location",
|
|
9
|
+
"contacts",
|
|
10
|
+
"sticker",
|
|
11
|
+
"reaction",
|
|
12
|
+
]);
|
|
13
|
+
/** Fields shared by every `message.*` event in schema v3. */
|
|
14
|
+
const messageBase = {
|
|
15
|
+
numberId: z.string(),
|
|
16
|
+
messageId: z.string().nullable(),
|
|
17
|
+
id: z.string(),
|
|
18
|
+
type: messageType.optional(),
|
|
19
|
+
fromMe: z.boolean(),
|
|
20
|
+
createdAt: z.string(),
|
|
21
|
+
correlationId: z.string().optional(),
|
|
22
|
+
content: z.string().optional(),
|
|
23
|
+
mediaLink: z.string().optional(),
|
|
24
|
+
mediaType: z.string().optional(),
|
|
25
|
+
mediaCaption: z.string().optional(),
|
|
26
|
+
mediaFilename: z.string().optional(),
|
|
27
|
+
};
|
|
3
28
|
const messageSentSchema = z.object({
|
|
4
29
|
event: z.literal("message.sent"),
|
|
5
30
|
data: z.object({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
destinationNumber: z.string(),
|
|
11
|
-
content: z.string(),
|
|
12
|
-
status: z.literal("SENT"),
|
|
13
|
-
sentAt: z.string(),
|
|
31
|
+
...messageBase,
|
|
32
|
+
from: z.string().optional(),
|
|
33
|
+
to: z.string(),
|
|
34
|
+
fromMe: z.literal(true),
|
|
14
35
|
}),
|
|
15
36
|
});
|
|
16
37
|
const messageDeliveredSchema = z.object({
|
|
17
38
|
event: z.literal("message.delivered"),
|
|
18
39
|
data: z.object({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
destinationNumber: z.string(),
|
|
24
|
-
content: z.string(),
|
|
25
|
-
status: z.literal("DELIVERED"),
|
|
26
|
-
deliveredAt: z.string(),
|
|
40
|
+
...messageBase,
|
|
41
|
+
from: z.string().optional(),
|
|
42
|
+
to: z.string(),
|
|
43
|
+
fromMe: z.literal(true),
|
|
27
44
|
}),
|
|
28
45
|
});
|
|
29
46
|
const messageReadSchema = z.object({
|
|
30
47
|
event: z.literal("message.read"),
|
|
31
48
|
data: z.object({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
destinationNumber: z.string(),
|
|
37
|
-
content: z.string(),
|
|
38
|
-
status: z.literal("READ"),
|
|
39
|
-
readAt: z.string(),
|
|
49
|
+
...messageBase,
|
|
50
|
+
from: z.string().optional(),
|
|
51
|
+
to: z.string(),
|
|
52
|
+
fromMe: z.literal(true),
|
|
40
53
|
}),
|
|
41
54
|
});
|
|
42
55
|
const messageFailedSchema = z.object({
|
|
43
56
|
event: z.literal("message.failed"),
|
|
44
57
|
data: z.object({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
status: z.literal("FAILED"),
|
|
52
|
-
failedAt: z.string(),
|
|
53
|
-
errorMessage: z.string(),
|
|
58
|
+
...messageBase,
|
|
59
|
+
from: z.string().optional(),
|
|
60
|
+
to: z.string(),
|
|
61
|
+
fromMe: z.literal(true),
|
|
62
|
+
error: z.string(),
|
|
63
|
+
errorCode: z.string().optional(),
|
|
54
64
|
}),
|
|
55
65
|
});
|
|
56
|
-
const
|
|
57
|
-
event: z.literal("message.
|
|
66
|
+
const messageReceivedSchema = z.object({
|
|
67
|
+
event: z.literal("message.received"),
|
|
58
68
|
data: z.object({
|
|
69
|
+
...messageBase,
|
|
59
70
|
from: z.string(),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
replyContent: z.string(),
|
|
63
|
-
receivedAt: z.string(),
|
|
64
|
-
messageId: z.string().nullable(),
|
|
65
|
-
quotedMessageId: z.string().nullable(),
|
|
66
|
-
messageRepliedId: z.string().nullable(),
|
|
67
|
-
correlationId: z.string().optional(),
|
|
68
|
-
environment: environmentSchema,
|
|
69
|
-
buttonId: z.string().nullable().optional(),
|
|
71
|
+
to: z.string(),
|
|
72
|
+
participantName: z.string().nullable().optional(),
|
|
70
73
|
}),
|
|
71
74
|
});
|
|
72
|
-
const
|
|
73
|
-
event: z.literal("message.
|
|
75
|
+
const messageReplySchema = z.object({
|
|
76
|
+
event: z.literal("message.reply"),
|
|
74
77
|
data: z.object({
|
|
75
|
-
|
|
78
|
+
...messageBase,
|
|
76
79
|
from: z.string(),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
messageId: z.string().nullable(),
|
|
82
|
-
correlationId: z.string().optional(),
|
|
83
|
-
environment: environmentSchema,
|
|
84
|
-
whatsappInstanceName: z.string().nullable().optional(),
|
|
80
|
+
to: z.string(),
|
|
81
|
+
participantName: z.string().nullable().optional(),
|
|
82
|
+
contentReplied: z.string().optional(),
|
|
83
|
+
quotedMessageId: z.string().nullable().optional(),
|
|
85
84
|
}),
|
|
86
85
|
});
|
|
87
86
|
const messageGroupSchema = z.object({
|
|
88
87
|
event: z.literal("message.group"),
|
|
89
88
|
data: z.object({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
content: z.string(),
|
|
95
|
-
environment: environmentSchema,
|
|
96
|
-
messageId: z.string().nullable(),
|
|
89
|
+
...messageBase,
|
|
90
|
+
from: z.string(),
|
|
91
|
+
to: z.string(),
|
|
92
|
+
participantName: z.string().nullable().optional(),
|
|
97
93
|
groupId: z.string().optional(),
|
|
98
|
-
|
|
94
|
+
groupName: z.string().nullable().optional(),
|
|
99
95
|
}),
|
|
100
96
|
});
|
|
101
97
|
const messageNewsletterSchema = z.object({
|
|
102
98
|
event: z.literal("message.newsletter"),
|
|
103
99
|
data: z.object({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
messageId: z.string().nullable(),
|
|
111
|
-
newsletterId: z.string(),
|
|
112
|
-
happenedAt: z.string(),
|
|
113
|
-
}),
|
|
114
|
-
});
|
|
115
|
-
const optinCreatedSchema = z.object({
|
|
116
|
-
event: z.literal("optin.created"),
|
|
117
|
-
data: z.object({
|
|
118
|
-
projectId: z.string(),
|
|
119
|
-
environment: environmentSchema,
|
|
120
|
-
whatsappInstanceName: z.string(),
|
|
121
|
-
destinationNumber: z.string(),
|
|
122
|
-
destinationHash: z.string(),
|
|
123
|
-
fromName: z.union([z.string(), z.null()]).optional(),
|
|
124
|
-
isFirstOptIn: z.boolean(),
|
|
125
|
-
firstOptInAt: z.string(),
|
|
126
|
-
lastSeenAt: z.string(),
|
|
100
|
+
...messageBase,
|
|
101
|
+
from: z.string(),
|
|
102
|
+
to: z.string(),
|
|
103
|
+
participantName: z.string().nullable().optional(),
|
|
104
|
+
newsletterId: z.string().optional(),
|
|
105
|
+
newsletterName: z.string().nullable().optional(),
|
|
127
106
|
}),
|
|
128
107
|
});
|
|
108
|
+
/** Fields shared by every `number.*` event in schema v3. */
|
|
109
|
+
const numberBase = {
|
|
110
|
+
numberId: z.string(),
|
|
111
|
+
phone: z.string(),
|
|
112
|
+
displayName: z.string(),
|
|
113
|
+
createdAt: z.string(),
|
|
114
|
+
profileName: z.string().optional(),
|
|
115
|
+
error: z.string().optional(),
|
|
116
|
+
errorCode: z.string().optional(),
|
|
117
|
+
};
|
|
129
118
|
const numberCreatedSchema = z.object({
|
|
130
119
|
event: z.literal("number.created"),
|
|
131
|
-
data: z.object({
|
|
132
|
-
numberId: z.string(),
|
|
133
|
-
whatsappInstanceName: z.string(),
|
|
134
|
-
displayName: z.string(),
|
|
135
|
-
number: z.string(),
|
|
136
|
-
status: z.string(),
|
|
137
|
-
createdAt: z.string(),
|
|
138
|
-
environment: environmentSchema,
|
|
139
|
-
}),
|
|
120
|
+
data: z.object({ ...numberBase }),
|
|
140
121
|
});
|
|
141
122
|
const numberConnectedSchema = z.object({
|
|
142
123
|
event: z.literal("number.connected"),
|
|
143
|
-
data: z.object({
|
|
144
|
-
numberId: z.string(),
|
|
145
|
-
whatsappInstanceName: z.string(),
|
|
146
|
-
displayName: z.string(),
|
|
147
|
-
number: z.string().nullable(),
|
|
148
|
-
previousState: z.string(),
|
|
149
|
-
nextState: z.string(),
|
|
150
|
-
connectedAt: z.string(),
|
|
151
|
-
environment: environmentSchema,
|
|
152
|
-
}),
|
|
124
|
+
data: z.object({ ...numberBase }),
|
|
153
125
|
});
|
|
154
126
|
const numberDisconnectedSchema = z.object({
|
|
155
127
|
event: z.literal("number.disconnected"),
|
|
156
|
-
data: z.object({
|
|
157
|
-
numberId: z.string(),
|
|
158
|
-
whatsappInstanceName: z.string(),
|
|
159
|
-
displayName: z.string(),
|
|
160
|
-
number: z.string().nullable(),
|
|
161
|
-
source: z.literal("healthcheck"),
|
|
162
|
-
previousState: z.string(),
|
|
163
|
-
nextState: z.string(),
|
|
164
|
-
connectionState: z.string().nullable(),
|
|
165
|
-
presenceStatus: z.number(),
|
|
166
|
-
disconnectedAt: z.string(),
|
|
167
|
-
environment: environmentSchema,
|
|
168
|
-
}),
|
|
128
|
+
data: z.object({ ...numberBase }),
|
|
169
129
|
});
|
|
170
130
|
const numberRemovedSchema = z.object({
|
|
171
131
|
event: z.literal("number.removed"),
|
|
172
|
-
data: z.object({
|
|
173
|
-
numberId: z.string(),
|
|
174
|
-
whatsappInstanceName: z.string(),
|
|
175
|
-
displayName: z.string(),
|
|
176
|
-
number: z.string(),
|
|
177
|
-
previousState: z.string(),
|
|
178
|
-
removedAt: z.string(),
|
|
179
|
-
environment: environmentSchema,
|
|
180
|
-
}),
|
|
132
|
+
data: z.object({ ...numberBase }),
|
|
181
133
|
});
|
|
182
134
|
const customerWebhookEventSchema = z.discriminatedUnion("event", [
|
|
183
135
|
messageSentSchema,
|
|
@@ -188,7 +140,6 @@ const customerWebhookEventSchema = z.discriminatedUnion("event", [
|
|
|
188
140
|
messageReceivedSchema,
|
|
189
141
|
messageGroupSchema,
|
|
190
142
|
messageNewsletterSchema,
|
|
191
|
-
optinCreatedSchema,
|
|
192
143
|
numberCreatedSchema,
|
|
193
144
|
numberConnectedSchema,
|
|
194
145
|
numberDisconnectedSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC;IACvB,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,UAAU;IACV,SAAS;IACT,UAAU;CACb,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AAK,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE;IAC7D,iBAAiB;IACjB,sBAAsB;IACtB,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;IAClB,qBAAqB;IACrB,kBAAkB;IAClB,uBAAuB;IACvB,mBAAmB;IACnB,qBAAqB;IACrB,wBAAwB;IACxB,mBAAmB;CACtB,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACjD,OAAO,0BAA0B,CAAC,KAAK,CAAC,OAAO,CAAyB,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACnD,OAAO,0BAA0B,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;AACjE,CAAC"}
|
package/dist/webhooks/types.d.ts
CHANGED
|
@@ -1,185 +1,134 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Customer webhook event types — schema v3 (camelCase, no legacy field names).
|
|
3
|
+
*
|
|
4
|
+
* Phones are always E.164 with a leading `+`. `numberId` is the public id of the
|
|
5
|
+
* number that handled the message/event (the same id `/v1/numbers` exposes).
|
|
6
|
+
* `createdAt` is the ISO-8601 timestamp of the event itself.
|
|
7
|
+
*/
|
|
8
|
+
export type WhatsAppMessageType = "text" | "image" | "audio" | "video" | "document" | "location" | "contacts" | "sticker" | "reaction";
|
|
9
|
+
type MessageEventBase = {
|
|
10
|
+
/** Public id of the number that handled the message. */
|
|
11
|
+
numberId: string;
|
|
12
|
+
/** Provider message id (null until the provider assigns one). */
|
|
13
|
+
messageId: string | null;
|
|
14
|
+
/** Pilot Status internal message id. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Derived message kind. Omitted only when truly indeterminable. */
|
|
17
|
+
type?: WhatsAppMessageType;
|
|
18
|
+
fromMe: boolean;
|
|
19
|
+
/** ISO-8601 timestamp of the event. */
|
|
20
|
+
createdAt: string;
|
|
21
|
+
/** Present when correlating to `POST /v1/messages/send` (HTTP 202). */
|
|
22
|
+
correlationId?: string;
|
|
23
|
+
content?: string;
|
|
24
|
+
};
|
|
2
25
|
export type MessageSentEvent = {
|
|
3
26
|
event: "message.sent";
|
|
4
|
-
data: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
destinationNumber: string;
|
|
11
|
-
content: string;
|
|
12
|
-
status: Extract<MessageStatus, "SENT">;
|
|
13
|
-
sentAt: string;
|
|
27
|
+
data: MessageEventBase & {
|
|
28
|
+
/** Own number (omitted when not cheaply resolvable). */
|
|
29
|
+
from?: string;
|
|
30
|
+
/** Destination contact (E.164). */
|
|
31
|
+
to: string;
|
|
32
|
+
fromMe: true;
|
|
14
33
|
};
|
|
15
34
|
};
|
|
16
35
|
export type MessageDeliveredEvent = {
|
|
17
36
|
event: "message.delivered";
|
|
18
|
-
data: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
environment: Environment;
|
|
23
|
-
destinationNumber: string;
|
|
24
|
-
content: string;
|
|
25
|
-
status: Extract<MessageStatus, "DELIVERED">;
|
|
26
|
-
deliveredAt: string;
|
|
37
|
+
data: MessageEventBase & {
|
|
38
|
+
from?: string;
|
|
39
|
+
to: string;
|
|
40
|
+
fromMe: true;
|
|
27
41
|
};
|
|
28
42
|
};
|
|
29
43
|
export type MessageReadEvent = {
|
|
30
44
|
event: "message.read";
|
|
31
|
-
data: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
environment: Environment;
|
|
36
|
-
destinationNumber: string;
|
|
37
|
-
content: string;
|
|
38
|
-
status: Extract<MessageStatus, "READ">;
|
|
39
|
-
readAt: string;
|
|
45
|
+
data: MessageEventBase & {
|
|
46
|
+
from?: string;
|
|
47
|
+
to: string;
|
|
48
|
+
fromMe: true;
|
|
40
49
|
};
|
|
41
50
|
};
|
|
42
51
|
export type MessageFailedEvent = {
|
|
43
52
|
event: "message.failed";
|
|
44
|
-
data: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
content: string;
|
|
51
|
-
status: Extract<MessageStatus, "FAILED">;
|
|
52
|
-
failedAt: string;
|
|
53
|
-
errorMessage: string;
|
|
53
|
+
data: MessageEventBase & {
|
|
54
|
+
from?: string;
|
|
55
|
+
to: string;
|
|
56
|
+
fromMe: true;
|
|
57
|
+
error: string;
|
|
58
|
+
errorCode?: string;
|
|
54
59
|
};
|
|
55
60
|
};
|
|
56
|
-
export type
|
|
57
|
-
event: "message.
|
|
58
|
-
data: {
|
|
61
|
+
export type MessageReceivedEvent = {
|
|
62
|
+
event: "message.received";
|
|
63
|
+
data: MessageEventBase & {
|
|
64
|
+
/** Sender / contact (E.164). */
|
|
59
65
|
from: string;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
receivedAt: string;
|
|
64
|
-
messageId: string | null;
|
|
65
|
-
quotedMessageId: string | null;
|
|
66
|
-
messageRepliedId: string | null;
|
|
67
|
-
correlationId?: string;
|
|
68
|
-
environment: Environment;
|
|
69
|
-
buttonId?: string | null;
|
|
66
|
+
/** Own number (E.164). */
|
|
67
|
+
to: string;
|
|
68
|
+
participantName?: string | null;
|
|
70
69
|
};
|
|
71
70
|
};
|
|
72
|
-
export type
|
|
73
|
-
event: "message.
|
|
74
|
-
data: {
|
|
75
|
-
fromMe: boolean;
|
|
71
|
+
export type MessageReplyEvent = {
|
|
72
|
+
event: "message.reply";
|
|
73
|
+
data: MessageEventBase & {
|
|
76
74
|
from: string;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
correlationId?: string;
|
|
83
|
-
environment: Environment;
|
|
84
|
-
whatsappInstanceName?: string | null;
|
|
75
|
+
to: string;
|
|
76
|
+
participantName?: string | null;
|
|
77
|
+
/** Text of the quoted (replied-to) message. */
|
|
78
|
+
contentReplied?: string;
|
|
79
|
+
quotedMessageId?: string | null;
|
|
85
80
|
};
|
|
86
81
|
};
|
|
87
82
|
export type MessageGroupEvent = {
|
|
88
83
|
event: "message.group";
|
|
89
|
-
data: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
environment: Environment;
|
|
96
|
-
messageId: string | null;
|
|
84
|
+
data: MessageEventBase & {
|
|
85
|
+
/** Participant (E.164). */
|
|
86
|
+
from: string;
|
|
87
|
+
/** Own number (E.164). */
|
|
88
|
+
to: string;
|
|
89
|
+
participantName?: string | null;
|
|
97
90
|
groupId?: string;
|
|
98
|
-
|
|
91
|
+
groupName?: string | null;
|
|
99
92
|
};
|
|
100
93
|
};
|
|
101
94
|
export type MessageNewsletterEvent = {
|
|
102
95
|
event: "message.newsletter";
|
|
103
|
-
data: {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
environment: Environment;
|
|
110
|
-
messageId: string | null;
|
|
111
|
-
newsletterId: string;
|
|
112
|
-
happenedAt: string;
|
|
96
|
+
data: MessageEventBase & {
|
|
97
|
+
from: string;
|
|
98
|
+
to: string;
|
|
99
|
+
participantName?: string | null;
|
|
100
|
+
newsletterId?: string;
|
|
101
|
+
newsletterName?: string | null;
|
|
113
102
|
};
|
|
114
103
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
firstOptInAt: string;
|
|
127
|
-
lastSeenAt: string;
|
|
128
|
-
};
|
|
104
|
+
type NumberEventBase = {
|
|
105
|
+
/** Public id of the number (same id `/v1/numbers` exposes). */
|
|
106
|
+
numberId: string;
|
|
107
|
+
/** E.164 with leading `+`. */
|
|
108
|
+
phone: string;
|
|
109
|
+
displayName: string;
|
|
110
|
+
/** ISO-8601 timestamp of the event. */
|
|
111
|
+
createdAt: string;
|
|
112
|
+
profileName?: string;
|
|
113
|
+
error?: string;
|
|
114
|
+
errorCode?: string;
|
|
129
115
|
};
|
|
130
116
|
export type NumberCreatedEvent = {
|
|
131
117
|
event: "number.created";
|
|
132
|
-
data:
|
|
133
|
-
numberId: string;
|
|
134
|
-
whatsappInstanceName: string;
|
|
135
|
-
displayName: string;
|
|
136
|
-
number: string;
|
|
137
|
-
status: string;
|
|
138
|
-
createdAt: string;
|
|
139
|
-
environment: Environment;
|
|
140
|
-
};
|
|
118
|
+
data: NumberEventBase;
|
|
141
119
|
};
|
|
142
120
|
export type NumberConnectedEvent = {
|
|
143
121
|
event: "number.connected";
|
|
144
|
-
data:
|
|
145
|
-
numberId: string;
|
|
146
|
-
whatsappInstanceName: string;
|
|
147
|
-
displayName: string;
|
|
148
|
-
number: string | null;
|
|
149
|
-
previousState: string;
|
|
150
|
-
nextState: string;
|
|
151
|
-
connectedAt: string;
|
|
152
|
-
environment: Environment;
|
|
153
|
-
};
|
|
122
|
+
data: NumberEventBase;
|
|
154
123
|
};
|
|
155
124
|
export type NumberDisconnectedEvent = {
|
|
156
125
|
event: "number.disconnected";
|
|
157
|
-
data:
|
|
158
|
-
numberId: string;
|
|
159
|
-
whatsappInstanceName: string;
|
|
160
|
-
displayName: string;
|
|
161
|
-
number: string | null;
|
|
162
|
-
/** Emitted after health-check confirmation, not on every transient Evolution signal. */
|
|
163
|
-
source: "healthcheck";
|
|
164
|
-
previousState: string;
|
|
165
|
-
nextState: string;
|
|
166
|
-
connectionState: string | null;
|
|
167
|
-
presenceStatus: number;
|
|
168
|
-
disconnectedAt: string;
|
|
169
|
-
environment: Environment;
|
|
170
|
-
};
|
|
126
|
+
data: NumberEventBase;
|
|
171
127
|
};
|
|
172
128
|
export type NumberRemovedEvent = {
|
|
173
129
|
event: "number.removed";
|
|
174
|
-
data:
|
|
175
|
-
numberId: string;
|
|
176
|
-
whatsappInstanceName: string;
|
|
177
|
-
displayName: string;
|
|
178
|
-
number: string;
|
|
179
|
-
previousState: string;
|
|
180
|
-
removedAt: string;
|
|
181
|
-
environment: Environment;
|
|
182
|
-
};
|
|
130
|
+
data: NumberEventBase;
|
|
183
131
|
};
|
|
184
|
-
export type CustomerWebhookEvent = MessageSentEvent | MessageDeliveredEvent | MessageReadEvent | MessageFailedEvent | MessageReplyEvent | MessageReceivedEvent | MessageGroupEvent | MessageNewsletterEvent |
|
|
132
|
+
export type CustomerWebhookEvent = MessageSentEvent | MessageDeliveredEvent | MessageReadEvent | MessageFailedEvent | MessageReplyEvent | MessageReceivedEvent | MessageGroupEvent | MessageNewsletterEvent | NumberCreatedEvent | NumberConnectedEvent | NumberDisconnectedEvent | NumberRemovedEvent;
|
|
133
|
+
export {};
|
|
185
134
|
//# sourceMappingURL=types.d.ts.map
|