@pilot-status/sdk 0.1.3 → 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 +7 -14
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -1
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.d.ts.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/messages.test.d.ts +2 -0
- package/dist/messages.test.d.ts.map +1 -0
- package/dist/messages.test.js +107 -0
- package/dist/messages.test.js.map +1 -0
- package/dist/numbers.test.d.ts +2 -0
- package/dist/numbers.test.d.ts.map +1 -0
- package/dist/numbers.test.js +57 -0
- package/dist/numbers.test.js.map +1 -0
- 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/groups.d.ts +8 -0
- package/dist/resources/groups.d.ts.map +1 -0
- package/dist/resources/groups.js +13 -0
- package/dist/resources/groups.js.map +1 -0
- package/dist/resources/groups.test.d.ts +2 -0
- package/dist/resources/groups.test.d.ts.map +1 -0
- package/dist/resources/groups.test.js +19 -0
- package/dist/resources/groups.test.js.map +1 -0
- 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 +26 -7
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/newsletters.d.ts +8 -0
- package/dist/resources/newsletters.d.ts.map +1 -0
- package/dist/resources/newsletters.js +13 -0
- package/dist/resources/newsletters.js.map +1 -0
- package/dist/resources/newsletters.test.d.ts +2 -0
- package/dist/resources/newsletters.test.d.ts.map +1 -0
- package/dist/resources/newsletters.test.js +19 -0
- package/dist/resources/newsletters.test.js.map +1 -0
- package/dist/resources/numbers.d.ts +5 -1
- package/dist/resources/numbers.d.ts.map +1 -1
- package/dist/resources/numbers.js +30 -0
- 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/resources/templates.d.ts +9 -0
- package/dist/resources/templates.d.ts.map +1 -0
- package/dist/resources/templates.js +19 -0
- package/dist/resources/templates.js.map +1 -0
- package/dist/resources/templates.test.d.ts +2 -0
- package/dist/resources/templates.test.d.ts.map +1 -0
- package/dist/resources/templates.test.js +28 -0
- package/dist/resources/templates.test.js.map +1 -0
- package/dist/types.d.ts +123 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/webhooks/parse.d.ts.map +1 -1
- package/dist/webhooks/parse.js +101 -68
- package/dist/webhooks/parse.js.map +1 -1
- package/dist/webhooks/types.d.ts +105 -76
- 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 +8 -4
package/dist/webhooks/parse.js
CHANGED
|
@@ -1,107 +1,136 @@
|
|
|
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
|
-
content: z.string(),
|
|
11
|
-
status: z.literal("SENT"),
|
|
12
|
-
sentAt: z.string(),
|
|
31
|
+
...messageBase,
|
|
32
|
+
from: z.string().optional(),
|
|
33
|
+
to: z.string(),
|
|
34
|
+
fromMe: z.literal(true),
|
|
13
35
|
}),
|
|
14
36
|
});
|
|
15
37
|
const messageDeliveredSchema = z.object({
|
|
16
38
|
event: z.literal("message.delivered"),
|
|
17
39
|
data: z.object({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
content: z.string(),
|
|
23
|
-
status: z.literal("DELIVERED"),
|
|
24
|
-
deliveredAt: z.string(),
|
|
40
|
+
...messageBase,
|
|
41
|
+
from: z.string().optional(),
|
|
42
|
+
to: z.string(),
|
|
43
|
+
fromMe: z.literal(true),
|
|
25
44
|
}),
|
|
26
45
|
});
|
|
27
46
|
const messageReadSchema = z.object({
|
|
28
47
|
event: z.literal("message.read"),
|
|
29
48
|
data: z.object({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
content: z.string(),
|
|
35
|
-
status: z.literal("READ"),
|
|
36
|
-
readAt: z.string(),
|
|
49
|
+
...messageBase,
|
|
50
|
+
from: z.string().optional(),
|
|
51
|
+
to: z.string(),
|
|
52
|
+
fromMe: z.literal(true),
|
|
37
53
|
}),
|
|
38
54
|
});
|
|
39
55
|
const messageFailedSchema = z.object({
|
|
40
56
|
event: z.literal("message.failed"),
|
|
41
57
|
data: z.object({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
failedAt: z.string(),
|
|
49
|
-
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(),
|
|
50
64
|
}),
|
|
51
65
|
});
|
|
52
|
-
const
|
|
53
|
-
event: z.literal("message.
|
|
66
|
+
const messageReceivedSchema = z.object({
|
|
67
|
+
event: z.literal("message.received"),
|
|
54
68
|
data: z.object({
|
|
69
|
+
...messageBase,
|
|
55
70
|
from: z.string(),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
replyContent: z.string(),
|
|
59
|
-
receivedAt: z.string(),
|
|
60
|
-
messageId: z.string().nullable(),
|
|
61
|
-
quotedMessageId: z.string().nullable(),
|
|
62
|
-
messageRepliedId: z.string().nullable(),
|
|
63
|
-
environment: environmentSchema,
|
|
64
|
-
buttonId: z.string().nullable().optional(),
|
|
71
|
+
to: z.string(),
|
|
72
|
+
participantName: z.string().nullable().optional(),
|
|
65
73
|
}),
|
|
66
74
|
});
|
|
67
|
-
const
|
|
68
|
-
event: z.literal("message.
|
|
75
|
+
const messageReplySchema = z.object({
|
|
76
|
+
event: z.literal("message.reply"),
|
|
69
77
|
data: z.object({
|
|
70
|
-
|
|
78
|
+
...messageBase,
|
|
71
79
|
from: z.string(),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
environment: environmentSchema,
|
|
77
|
-
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(),
|
|
78
84
|
}),
|
|
79
85
|
});
|
|
80
86
|
const messageGroupSchema = z.object({
|
|
81
87
|
event: z.literal("message.group"),
|
|
82
88
|
data: z.object({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
messageId: z.string().nullable(),
|
|
89
|
+
...messageBase,
|
|
90
|
+
from: z.string(),
|
|
91
|
+
to: z.string(),
|
|
92
|
+
participantName: z.string().nullable().optional(),
|
|
93
|
+
groupId: z.string().optional(),
|
|
94
|
+
groupName: z.string().nullable().optional(),
|
|
90
95
|
}),
|
|
91
96
|
});
|
|
92
|
-
const
|
|
93
|
-
event: z.literal("
|
|
97
|
+
const messageNewsletterSchema = z.object({
|
|
98
|
+
event: z.literal("message.newsletter"),
|
|
94
99
|
data: z.object({
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
firstOptInAt: z.string(),
|
|
102
|
-
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(),
|
|
103
106
|
}),
|
|
104
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
|
+
};
|
|
118
|
+
const numberCreatedSchema = z.object({
|
|
119
|
+
event: z.literal("number.created"),
|
|
120
|
+
data: z.object({ ...numberBase }),
|
|
121
|
+
});
|
|
122
|
+
const numberConnectedSchema = z.object({
|
|
123
|
+
event: z.literal("number.connected"),
|
|
124
|
+
data: z.object({ ...numberBase }),
|
|
125
|
+
});
|
|
126
|
+
const numberDisconnectedSchema = z.object({
|
|
127
|
+
event: z.literal("number.disconnected"),
|
|
128
|
+
data: z.object({ ...numberBase }),
|
|
129
|
+
});
|
|
130
|
+
const numberRemovedSchema = z.object({
|
|
131
|
+
event: z.literal("number.removed"),
|
|
132
|
+
data: z.object({ ...numberBase }),
|
|
133
|
+
});
|
|
105
134
|
const customerWebhookEventSchema = z.discriminatedUnion("event", [
|
|
106
135
|
messageSentSchema,
|
|
107
136
|
messageDeliveredSchema,
|
|
@@ -110,7 +139,11 @@ const customerWebhookEventSchema = z.discriminatedUnion("event", [
|
|
|
110
139
|
messageReplySchema,
|
|
111
140
|
messageReceivedSchema,
|
|
112
141
|
messageGroupSchema,
|
|
113
|
-
|
|
142
|
+
messageNewsletterSchema,
|
|
143
|
+
numberCreatedSchema,
|
|
144
|
+
numberConnectedSchema,
|
|
145
|
+
numberDisconnectedSchema,
|
|
146
|
+
numberRemovedSchema,
|
|
114
147
|
]);
|
|
115
148
|
export function parseCustomerWebhook(payload) {
|
|
116
149
|
return customerWebhookEventSchema.parse(payload);
|
|
@@ -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,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,WAAW,GAAG;IAChB,QAAQ,EAAE,CAA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AAC,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,105 +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
|
-
status: Extract<MessageStatus, "SENT">;
|
|
11
|
-
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;
|
|
12
33
|
};
|
|
13
34
|
};
|
|
14
35
|
export type MessageDeliveredEvent = {
|
|
15
36
|
event: "message.delivered";
|
|
16
|
-
data: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
destinationNumber: string;
|
|
21
|
-
content: string;
|
|
22
|
-
status: Extract<MessageStatus, "DELIVERED">;
|
|
23
|
-
deliveredAt: string;
|
|
37
|
+
data: MessageEventBase & {
|
|
38
|
+
from?: string;
|
|
39
|
+
to: string;
|
|
40
|
+
fromMe: true;
|
|
24
41
|
};
|
|
25
42
|
};
|
|
26
43
|
export type MessageReadEvent = {
|
|
27
44
|
event: "message.read";
|
|
28
|
-
data: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
destinationNumber: string;
|
|
33
|
-
content: string;
|
|
34
|
-
status: Extract<MessageStatus, "READ">;
|
|
35
|
-
readAt: string;
|
|
45
|
+
data: MessageEventBase & {
|
|
46
|
+
from?: string;
|
|
47
|
+
to: string;
|
|
48
|
+
fromMe: true;
|
|
36
49
|
};
|
|
37
50
|
};
|
|
38
51
|
export type MessageFailedEvent = {
|
|
39
52
|
event: "message.failed";
|
|
40
|
-
data: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
status: Extract<MessageStatus, "FAILED">;
|
|
47
|
-
failedAt: string;
|
|
48
|
-
errorMessage: string;
|
|
53
|
+
data: MessageEventBase & {
|
|
54
|
+
from?: string;
|
|
55
|
+
to: string;
|
|
56
|
+
fromMe: true;
|
|
57
|
+
error: string;
|
|
58
|
+
errorCode?: string;
|
|
49
59
|
};
|
|
50
60
|
};
|
|
51
|
-
export type
|
|
52
|
-
event: "message.
|
|
53
|
-
data: {
|
|
61
|
+
export type MessageReceivedEvent = {
|
|
62
|
+
event: "message.received";
|
|
63
|
+
data: MessageEventBase & {
|
|
64
|
+
/** Sender / contact (E.164). */
|
|
54
65
|
from: string;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
receivedAt: string;
|
|
59
|
-
messageId: string | null;
|
|
60
|
-
quotedMessageId: string | null;
|
|
61
|
-
messageRepliedId: string | null;
|
|
62
|
-
environment: Environment;
|
|
63
|
-
buttonId?: string | null;
|
|
66
|
+
/** Own number (E.164). */
|
|
67
|
+
to: string;
|
|
68
|
+
participantName?: string | null;
|
|
64
69
|
};
|
|
65
70
|
};
|
|
66
|
-
export type
|
|
67
|
-
event: "message.
|
|
68
|
-
data: {
|
|
69
|
-
fromMe: boolean;
|
|
71
|
+
export type MessageReplyEvent = {
|
|
72
|
+
event: "message.reply";
|
|
73
|
+
data: MessageEventBase & {
|
|
70
74
|
from: string;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
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;
|
|
77
80
|
};
|
|
78
81
|
};
|
|
79
82
|
export type MessageGroupEvent = {
|
|
80
83
|
event: "message.group";
|
|
81
|
-
data: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
data: MessageEventBase & {
|
|
85
|
+
/** Participant (E.164). */
|
|
86
|
+
from: string;
|
|
87
|
+
/** Own number (E.164). */
|
|
88
|
+
to: string;
|
|
89
|
+
participantName?: string | null;
|
|
90
|
+
groupId?: string;
|
|
91
|
+
groupName?: string | null;
|
|
89
92
|
};
|
|
90
93
|
};
|
|
91
|
-
export type
|
|
92
|
-
event: "
|
|
93
|
-
data: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
isFirstOptIn: boolean;
|
|
100
|
-
firstOptInAt: string;
|
|
101
|
-
lastSeenAt: string;
|
|
94
|
+
export type MessageNewsletterEvent = {
|
|
95
|
+
event: "message.newsletter";
|
|
96
|
+
data: MessageEventBase & {
|
|
97
|
+
from: string;
|
|
98
|
+
to: string;
|
|
99
|
+
participantName?: string | null;
|
|
100
|
+
newsletterId?: string;
|
|
101
|
+
newsletterName?: string | null;
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
|
-
|
|
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;
|
|
115
|
+
};
|
|
116
|
+
export type NumberCreatedEvent = {
|
|
117
|
+
event: "number.created";
|
|
118
|
+
data: NumberEventBase;
|
|
119
|
+
};
|
|
120
|
+
export type NumberConnectedEvent = {
|
|
121
|
+
event: "number.connected";
|
|
122
|
+
data: NumberEventBase;
|
|
123
|
+
};
|
|
124
|
+
export type NumberDisconnectedEvent = {
|
|
125
|
+
event: "number.disconnected";
|
|
126
|
+
data: NumberEventBase;
|
|
127
|
+
};
|
|
128
|
+
export type NumberRemovedEvent = {
|
|
129
|
+
event: "number.removed";
|
|
130
|
+
data: NumberEventBase;
|
|
131
|
+
};
|
|
132
|
+
export type CustomerWebhookEvent = MessageSentEvent | MessageDeliveredEvent | MessageReadEvent | MessageFailedEvent | MessageReplyEvent | MessageReceivedEvent | MessageGroupEvent | MessageNewsletterEvent | NumberCreatedEvent | NumberConnectedEvent | NumberDisconnectedEvent | NumberRemovedEvent;
|
|
133
|
+
export {};
|
|
105
134
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,mBAAmB,GACzB,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,UAAU,GACV,UAAU,GACV,SAAS,GACT,UAAU,CAAC;AAEjB,KAAK,gBAAgB,GAAG;IACpB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,SAAS,EAAE,MAAM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EAAE,MAAM,CAAC;IAElB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,IAAI,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC1B,gBAAgB,GAChB,qBAAqB,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,sBAAsB,GACtB,kBAAkB,GAClB,oBAAoB,GACpB,uBAAuB,GACvB,kBAAkB,CAAC"}
|
package/dist/webhooks/types.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
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
|
+
*/
|
|
1
8
|
export {};
|
|
2
9
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pilot-status/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Official TypeScript SDK for the Pilot Status public API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/pilot-status/pilot-status.git"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://pilotstatuss.com",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/pilot-status/pilot-status/issues"
|
|
13
13
|
},
|
|
@@ -33,7 +33,10 @@
|
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc -p tsconfig.json",
|
|
36
|
-
"prepublishOnly": "npm run build"
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest",
|
|
39
|
+
"test:coverage": "vitest run -c vitest.coverage.config.ts"
|
|
37
40
|
},
|
|
38
41
|
"engines": {
|
|
39
42
|
"node": ">=18.0.0"
|
|
@@ -45,6 +48,7 @@
|
|
|
45
48
|
"zod": "^3.23.0"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
48
|
-
"typescript": "^5.6.0"
|
|
51
|
+
"typescript": "^5.6.0",
|
|
52
|
+
"vitest": "^4.0.18"
|
|
49
53
|
}
|
|
50
54
|
}
|