@open-apime/sdk 0.5.0 → 0.7.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/dist/events-DI9IgIy3.d.cts +198 -0
- package/dist/events-DI9IgIy3.d.ts +198 -0
- package/dist/{index-TqYrYke0.d.ts → index-C6SaglOj.d.ts} +1 -1
- package/dist/{index-37ITjlwO.d.cts → index-D-LTc5od.d.cts} +1 -1
- package/dist/index.cjs +43 -0
- package/dist/index.d.cts +65 -4
- package/dist/index.d.ts +65 -4
- package/dist/index.js +43 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/webhook/index.d.cts +2 -2
- package/dist/webhook/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/events-BV5UVoFu.d.cts +0 -90
- package/dist/events-BV5UVoFu.d.ts +0 -90
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 12 event types the apime delivers. `ignore` is internal and never
|
|
3
|
+
* reaches a consumer, so it is not part of the union.
|
|
4
|
+
*/
|
|
5
|
+
type WebhookEventType = "message" | "receipt" | "presence" | "chat_presence" | "reaction" | "contact_update" | "connected" | "disconnected" | "temporary_ban" | "restriction_lifted" | "contact_reachout_locked" | "unknown";
|
|
6
|
+
interface WebhookEnvelope<T extends WebhookEventType = WebhookEventType, P = unknown> {
|
|
7
|
+
id: string;
|
|
8
|
+
instanceId: string;
|
|
9
|
+
type: T;
|
|
10
|
+
payload: P;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}
|
|
13
|
+
/** Button of an interactive message. `call`, `copy`, `reply` and `url` are button kinds, not events. */
|
|
14
|
+
interface MessageButton {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
type: "reply" | "url" | "copy" | "call";
|
|
18
|
+
url?: string;
|
|
19
|
+
code?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Row of a list section. */
|
|
23
|
+
interface MessageListRow {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}
|
|
28
|
+
/** Section of a list message. */
|
|
29
|
+
interface MessageListSection {
|
|
30
|
+
title: string;
|
|
31
|
+
rows: MessageListRow[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Interactive content of a received message. `kind` says how to render it:
|
|
35
|
+
* `buttons` carries `buttons`, `list` carries `sections`.
|
|
36
|
+
*/
|
|
37
|
+
interface MessageInteractive {
|
|
38
|
+
kind: "buttons" | "list";
|
|
39
|
+
text?: string;
|
|
40
|
+
footer?: string;
|
|
41
|
+
buttons?: MessageButton[];
|
|
42
|
+
sections?: MessageListSection[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What the contact picked when tapping a button or list row. `selectedId` and
|
|
46
|
+
* `selectedLabel` are the useful pair; `name` and `paramsJson` are the raw
|
|
47
|
+
* NativeFlow fields, kept for anything the normalizer did not extract.
|
|
48
|
+
*/
|
|
49
|
+
interface MessageInteractiveReply {
|
|
50
|
+
selectedId?: string;
|
|
51
|
+
selectedLabel?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
paramsJson?: string;
|
|
54
|
+
}
|
|
55
|
+
/** A broadcast recipient. At least one of the two identities is always present. */
|
|
56
|
+
interface BroadcastRecipient {
|
|
57
|
+
pn?: string;
|
|
58
|
+
lid?: string;
|
|
59
|
+
}
|
|
60
|
+
interface MessagePayload {
|
|
61
|
+
from: string;
|
|
62
|
+
to: string;
|
|
63
|
+
/** Chat the message belongs to. Equals `to`, resolved to a phone number when possible. */
|
|
64
|
+
chatJID?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Stable identity of the contact, emitted whenever known, even when the phone
|
|
67
|
+
* number was resolved. Use it to unify a contact instead of relying on the
|
|
68
|
+
* number, which changes.
|
|
69
|
+
*/
|
|
70
|
+
lid?: string;
|
|
71
|
+
/** How the chat is addressed by WhatsApp: by phone number or by LID. */
|
|
72
|
+
addressingMode?: string;
|
|
73
|
+
isFromMe: boolean;
|
|
74
|
+
isGroup: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Broadcast list or story. Present only in that case, so a plain 1:1 keeps the payload it had.
|
|
77
|
+
*
|
|
78
|
+
* WhatsApp emits ONE event for the whole list, never one per recipient, and `chatJID` is the
|
|
79
|
+
* list itself, which is not a real conversation. To register the message in each contact's 1:1
|
|
80
|
+
* chat, fan out over `broadcastRecipients`.
|
|
81
|
+
*/
|
|
82
|
+
isBroadcast?: boolean;
|
|
83
|
+
/** `true` for a story (status@broadcast), `false` for a regular broadcast list. */
|
|
84
|
+
isStatusBroadcast?: boolean;
|
|
85
|
+
/** Who sent it through the list, when the server informs it. */
|
|
86
|
+
broadcastListOwner?: string;
|
|
87
|
+
/** Every recipient of this message. The array is the only place this information arrives. */
|
|
88
|
+
broadcastRecipients?: BroadcastRecipient[];
|
|
89
|
+
messageId: string;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
pushName?: string;
|
|
92
|
+
/** Group only: who sent it inside the group. Both carry the same value. */
|
|
93
|
+
participant?: string;
|
|
94
|
+
author?: string;
|
|
95
|
+
/** Business accounts only, from the verified name certificate. */
|
|
96
|
+
verifiedName?: string;
|
|
97
|
+
issuer?: string;
|
|
98
|
+
text?: string;
|
|
99
|
+
mentionedJids?: string[];
|
|
100
|
+
mediaType?: "image" | "video" | "audio" | "document" | "sticker" | "location" | "contact";
|
|
101
|
+
mediaUrl?: string;
|
|
102
|
+
mimetype?: string;
|
|
103
|
+
caption?: string;
|
|
104
|
+
fileName?: string;
|
|
105
|
+
/** Size in bytes. */
|
|
106
|
+
fileSize?: number;
|
|
107
|
+
/** Audio and video: length in seconds. */
|
|
108
|
+
duration?: number;
|
|
109
|
+
/** Audio recorded as a voice note rather than an attached file. */
|
|
110
|
+
ptt?: boolean;
|
|
111
|
+
/** Video sent as a round "video note". */
|
|
112
|
+
isPtv?: boolean;
|
|
113
|
+
/** Location messages. */
|
|
114
|
+
latitude?: number;
|
|
115
|
+
longitude?: number;
|
|
116
|
+
address?: string;
|
|
117
|
+
/** Contact messages. `contactNumber` is the raw vCard, not a bare number. */
|
|
118
|
+
contactName?: string;
|
|
119
|
+
contactNumber?: string;
|
|
120
|
+
buttons?: MessageButton[];
|
|
121
|
+
/** Present when the message itself carries buttons or a list. */
|
|
122
|
+
interactive?: MessageInteractive;
|
|
123
|
+
/** Present when the message IS the contact's answer to a button or list. */
|
|
124
|
+
interactiveReply?: MessageInteractiveReply;
|
|
125
|
+
/**
|
|
126
|
+
* Present only when this event is an edit: the id of the message that was
|
|
127
|
+
* edited, and its new text. They always travel together, so checking one is
|
|
128
|
+
* enough to know it is an edit.
|
|
129
|
+
*/
|
|
130
|
+
editedMessageId?: string;
|
|
131
|
+
editedText?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A reaction added to, or removed from, a message. An empty `reactionEmoji`
|
|
135
|
+
* means the contact removed their reaction.
|
|
136
|
+
*/
|
|
137
|
+
interface ReactionPayload {
|
|
138
|
+
from: string;
|
|
139
|
+
chatJID: string;
|
|
140
|
+
isFromMe: boolean;
|
|
141
|
+
isGroup: boolean;
|
|
142
|
+
timestamp: number;
|
|
143
|
+
pushName?: string;
|
|
144
|
+
/** Group only: who reacted. Both carry the same value. */
|
|
145
|
+
participant?: string;
|
|
146
|
+
author?: string;
|
|
147
|
+
/** The emoji, or an empty string when the reaction was removed. */
|
|
148
|
+
reactionEmoji: string;
|
|
149
|
+
/** Id of the message that was reacted to. */
|
|
150
|
+
reactionMessageId?: string;
|
|
151
|
+
}
|
|
152
|
+
interface ReceiptPayload {
|
|
153
|
+
messageIds: string[];
|
|
154
|
+
timestamp: number;
|
|
155
|
+
chat: string;
|
|
156
|
+
status: "read" | "delivered" | "played";
|
|
157
|
+
}
|
|
158
|
+
interface PresencePayload {
|
|
159
|
+
from: string;
|
|
160
|
+
unavailable: boolean;
|
|
161
|
+
lastSeen?: number;
|
|
162
|
+
}
|
|
163
|
+
interface ChatPresencePayload {
|
|
164
|
+
from: string;
|
|
165
|
+
chatJID: string;
|
|
166
|
+
state: "composing" | "paused";
|
|
167
|
+
media?: "audio";
|
|
168
|
+
}
|
|
169
|
+
interface ContactUpdatePayload {
|
|
170
|
+
jid: string;
|
|
171
|
+
username: string;
|
|
172
|
+
}
|
|
173
|
+
interface DisconnectedPayload {
|
|
174
|
+
reason?: string;
|
|
175
|
+
}
|
|
176
|
+
/** Same shape for the account ban and for the reach-out timelock. */
|
|
177
|
+
interface TemporaryBanPayload {
|
|
178
|
+
reason?: string;
|
|
179
|
+
code?: number;
|
|
180
|
+
active: boolean;
|
|
181
|
+
restrictedUntil?: string;
|
|
182
|
+
enforcementType?: string;
|
|
183
|
+
}
|
|
184
|
+
interface RestrictionLiftedPayload {
|
|
185
|
+
active: false;
|
|
186
|
+
enforcementType?: string;
|
|
187
|
+
restrictedUntil?: string;
|
|
188
|
+
}
|
|
189
|
+
interface ContactReachoutLockedPayload {
|
|
190
|
+
to: string;
|
|
191
|
+
reason: string;
|
|
192
|
+
detail: string;
|
|
193
|
+
code: number;
|
|
194
|
+
}
|
|
195
|
+
/** Discriminated by `type`, so a switch narrows the payload. */
|
|
196
|
+
type WebhookEvent = WebhookEnvelope<"message", MessagePayload> | WebhookEnvelope<"receipt", ReceiptPayload> | WebhookEnvelope<"presence", PresencePayload> | WebhookEnvelope<"chat_presence", ChatPresencePayload> | WebhookEnvelope<"reaction", ReactionPayload> | WebhookEnvelope<"contact_update", ContactUpdatePayload> | WebhookEnvelope<"connected", Record<string, unknown>> | WebhookEnvelope<"disconnected", DisconnectedPayload> | WebhookEnvelope<"temporary_ban", TemporaryBanPayload> | WebhookEnvelope<"restriction_lifted", RestrictionLiftedPayload> | WebhookEnvelope<"contact_reachout_locked", ContactReachoutLockedPayload> | WebhookEnvelope<"unknown", Record<string, unknown>>;
|
|
197
|
+
|
|
198
|
+
export type { BroadcastRecipient as B, ChatPresencePayload as C, DisconnectedPayload as D, MessageButton as M, PresencePayload as P, ReactionPayload as R, TemporaryBanPayload as T, WebhookEnvelope as W, ContactReachoutLockedPayload as a, ContactUpdatePayload as b, MessageInteractive as c, MessageInteractiveReply as d, MessageListRow as e, MessageListSection as f, MessagePayload as g, ReceiptPayload as h, RestrictionLiftedPayload as i, WebhookEvent as j, WebhookEventType as k };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 12 event types the apime delivers. `ignore` is internal and never
|
|
3
|
+
* reaches a consumer, so it is not part of the union.
|
|
4
|
+
*/
|
|
5
|
+
type WebhookEventType = "message" | "receipt" | "presence" | "chat_presence" | "reaction" | "contact_update" | "connected" | "disconnected" | "temporary_ban" | "restriction_lifted" | "contact_reachout_locked" | "unknown";
|
|
6
|
+
interface WebhookEnvelope<T extends WebhookEventType = WebhookEventType, P = unknown> {
|
|
7
|
+
id: string;
|
|
8
|
+
instanceId: string;
|
|
9
|
+
type: T;
|
|
10
|
+
payload: P;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}
|
|
13
|
+
/** Button of an interactive message. `call`, `copy`, `reply` and `url` are button kinds, not events. */
|
|
14
|
+
interface MessageButton {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
type: "reply" | "url" | "copy" | "call";
|
|
18
|
+
url?: string;
|
|
19
|
+
code?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Row of a list section. */
|
|
23
|
+
interface MessageListRow {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}
|
|
28
|
+
/** Section of a list message. */
|
|
29
|
+
interface MessageListSection {
|
|
30
|
+
title: string;
|
|
31
|
+
rows: MessageListRow[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Interactive content of a received message. `kind` says how to render it:
|
|
35
|
+
* `buttons` carries `buttons`, `list` carries `sections`.
|
|
36
|
+
*/
|
|
37
|
+
interface MessageInteractive {
|
|
38
|
+
kind: "buttons" | "list";
|
|
39
|
+
text?: string;
|
|
40
|
+
footer?: string;
|
|
41
|
+
buttons?: MessageButton[];
|
|
42
|
+
sections?: MessageListSection[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What the contact picked when tapping a button or list row. `selectedId` and
|
|
46
|
+
* `selectedLabel` are the useful pair; `name` and `paramsJson` are the raw
|
|
47
|
+
* NativeFlow fields, kept for anything the normalizer did not extract.
|
|
48
|
+
*/
|
|
49
|
+
interface MessageInteractiveReply {
|
|
50
|
+
selectedId?: string;
|
|
51
|
+
selectedLabel?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
paramsJson?: string;
|
|
54
|
+
}
|
|
55
|
+
/** A broadcast recipient. At least one of the two identities is always present. */
|
|
56
|
+
interface BroadcastRecipient {
|
|
57
|
+
pn?: string;
|
|
58
|
+
lid?: string;
|
|
59
|
+
}
|
|
60
|
+
interface MessagePayload {
|
|
61
|
+
from: string;
|
|
62
|
+
to: string;
|
|
63
|
+
/** Chat the message belongs to. Equals `to`, resolved to a phone number when possible. */
|
|
64
|
+
chatJID?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Stable identity of the contact, emitted whenever known, even when the phone
|
|
67
|
+
* number was resolved. Use it to unify a contact instead of relying on the
|
|
68
|
+
* number, which changes.
|
|
69
|
+
*/
|
|
70
|
+
lid?: string;
|
|
71
|
+
/** How the chat is addressed by WhatsApp: by phone number or by LID. */
|
|
72
|
+
addressingMode?: string;
|
|
73
|
+
isFromMe: boolean;
|
|
74
|
+
isGroup: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Broadcast list or story. Present only in that case, so a plain 1:1 keeps the payload it had.
|
|
77
|
+
*
|
|
78
|
+
* WhatsApp emits ONE event for the whole list, never one per recipient, and `chatJID` is the
|
|
79
|
+
* list itself, which is not a real conversation. To register the message in each contact's 1:1
|
|
80
|
+
* chat, fan out over `broadcastRecipients`.
|
|
81
|
+
*/
|
|
82
|
+
isBroadcast?: boolean;
|
|
83
|
+
/** `true` for a story (status@broadcast), `false` for a regular broadcast list. */
|
|
84
|
+
isStatusBroadcast?: boolean;
|
|
85
|
+
/** Who sent it through the list, when the server informs it. */
|
|
86
|
+
broadcastListOwner?: string;
|
|
87
|
+
/** Every recipient of this message. The array is the only place this information arrives. */
|
|
88
|
+
broadcastRecipients?: BroadcastRecipient[];
|
|
89
|
+
messageId: string;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
pushName?: string;
|
|
92
|
+
/** Group only: who sent it inside the group. Both carry the same value. */
|
|
93
|
+
participant?: string;
|
|
94
|
+
author?: string;
|
|
95
|
+
/** Business accounts only, from the verified name certificate. */
|
|
96
|
+
verifiedName?: string;
|
|
97
|
+
issuer?: string;
|
|
98
|
+
text?: string;
|
|
99
|
+
mentionedJids?: string[];
|
|
100
|
+
mediaType?: "image" | "video" | "audio" | "document" | "sticker" | "location" | "contact";
|
|
101
|
+
mediaUrl?: string;
|
|
102
|
+
mimetype?: string;
|
|
103
|
+
caption?: string;
|
|
104
|
+
fileName?: string;
|
|
105
|
+
/** Size in bytes. */
|
|
106
|
+
fileSize?: number;
|
|
107
|
+
/** Audio and video: length in seconds. */
|
|
108
|
+
duration?: number;
|
|
109
|
+
/** Audio recorded as a voice note rather than an attached file. */
|
|
110
|
+
ptt?: boolean;
|
|
111
|
+
/** Video sent as a round "video note". */
|
|
112
|
+
isPtv?: boolean;
|
|
113
|
+
/** Location messages. */
|
|
114
|
+
latitude?: number;
|
|
115
|
+
longitude?: number;
|
|
116
|
+
address?: string;
|
|
117
|
+
/** Contact messages. `contactNumber` is the raw vCard, not a bare number. */
|
|
118
|
+
contactName?: string;
|
|
119
|
+
contactNumber?: string;
|
|
120
|
+
buttons?: MessageButton[];
|
|
121
|
+
/** Present when the message itself carries buttons or a list. */
|
|
122
|
+
interactive?: MessageInteractive;
|
|
123
|
+
/** Present when the message IS the contact's answer to a button or list. */
|
|
124
|
+
interactiveReply?: MessageInteractiveReply;
|
|
125
|
+
/**
|
|
126
|
+
* Present only when this event is an edit: the id of the message that was
|
|
127
|
+
* edited, and its new text. They always travel together, so checking one is
|
|
128
|
+
* enough to know it is an edit.
|
|
129
|
+
*/
|
|
130
|
+
editedMessageId?: string;
|
|
131
|
+
editedText?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A reaction added to, or removed from, a message. An empty `reactionEmoji`
|
|
135
|
+
* means the contact removed their reaction.
|
|
136
|
+
*/
|
|
137
|
+
interface ReactionPayload {
|
|
138
|
+
from: string;
|
|
139
|
+
chatJID: string;
|
|
140
|
+
isFromMe: boolean;
|
|
141
|
+
isGroup: boolean;
|
|
142
|
+
timestamp: number;
|
|
143
|
+
pushName?: string;
|
|
144
|
+
/** Group only: who reacted. Both carry the same value. */
|
|
145
|
+
participant?: string;
|
|
146
|
+
author?: string;
|
|
147
|
+
/** The emoji, or an empty string when the reaction was removed. */
|
|
148
|
+
reactionEmoji: string;
|
|
149
|
+
/** Id of the message that was reacted to. */
|
|
150
|
+
reactionMessageId?: string;
|
|
151
|
+
}
|
|
152
|
+
interface ReceiptPayload {
|
|
153
|
+
messageIds: string[];
|
|
154
|
+
timestamp: number;
|
|
155
|
+
chat: string;
|
|
156
|
+
status: "read" | "delivered" | "played";
|
|
157
|
+
}
|
|
158
|
+
interface PresencePayload {
|
|
159
|
+
from: string;
|
|
160
|
+
unavailable: boolean;
|
|
161
|
+
lastSeen?: number;
|
|
162
|
+
}
|
|
163
|
+
interface ChatPresencePayload {
|
|
164
|
+
from: string;
|
|
165
|
+
chatJID: string;
|
|
166
|
+
state: "composing" | "paused";
|
|
167
|
+
media?: "audio";
|
|
168
|
+
}
|
|
169
|
+
interface ContactUpdatePayload {
|
|
170
|
+
jid: string;
|
|
171
|
+
username: string;
|
|
172
|
+
}
|
|
173
|
+
interface DisconnectedPayload {
|
|
174
|
+
reason?: string;
|
|
175
|
+
}
|
|
176
|
+
/** Same shape for the account ban and for the reach-out timelock. */
|
|
177
|
+
interface TemporaryBanPayload {
|
|
178
|
+
reason?: string;
|
|
179
|
+
code?: number;
|
|
180
|
+
active: boolean;
|
|
181
|
+
restrictedUntil?: string;
|
|
182
|
+
enforcementType?: string;
|
|
183
|
+
}
|
|
184
|
+
interface RestrictionLiftedPayload {
|
|
185
|
+
active: false;
|
|
186
|
+
enforcementType?: string;
|
|
187
|
+
restrictedUntil?: string;
|
|
188
|
+
}
|
|
189
|
+
interface ContactReachoutLockedPayload {
|
|
190
|
+
to: string;
|
|
191
|
+
reason: string;
|
|
192
|
+
detail: string;
|
|
193
|
+
code: number;
|
|
194
|
+
}
|
|
195
|
+
/** Discriminated by `type`, so a switch narrows the payload. */
|
|
196
|
+
type WebhookEvent = WebhookEnvelope<"message", MessagePayload> | WebhookEnvelope<"receipt", ReceiptPayload> | WebhookEnvelope<"presence", PresencePayload> | WebhookEnvelope<"chat_presence", ChatPresencePayload> | WebhookEnvelope<"reaction", ReactionPayload> | WebhookEnvelope<"contact_update", ContactUpdatePayload> | WebhookEnvelope<"connected", Record<string, unknown>> | WebhookEnvelope<"disconnected", DisconnectedPayload> | WebhookEnvelope<"temporary_ban", TemporaryBanPayload> | WebhookEnvelope<"restriction_lifted", RestrictionLiftedPayload> | WebhookEnvelope<"contact_reachout_locked", ContactReachoutLockedPayload> | WebhookEnvelope<"unknown", Record<string, unknown>>;
|
|
197
|
+
|
|
198
|
+
export type { BroadcastRecipient as B, ChatPresencePayload as C, DisconnectedPayload as D, MessageButton as M, PresencePayload as P, ReactionPayload as R, TemporaryBanPayload as T, WebhookEnvelope as W, ContactReachoutLockedPayload as a, ContactUpdatePayload as b, MessageInteractive as c, MessageInteractiveReply as d, MessageListRow as e, MessageListSection as f, MessagePayload as g, ReceiptPayload as h, RestrictionLiftedPayload as i, WebhookEvent as j, WebhookEventType as k };
|
package/dist/index.cjs
CHANGED
|
@@ -526,6 +526,26 @@ var MessagesResource = class {
|
|
|
526
526
|
return this.http.request({ method: "GET", path: this.base, ...options ? { options } : {} });
|
|
527
527
|
}
|
|
528
528
|
};
|
|
529
|
+
var StoriesResource = class {
|
|
530
|
+
constructor(http, instanceId) {
|
|
531
|
+
this.http = http;
|
|
532
|
+
this.instanceId = instanceId;
|
|
533
|
+
}
|
|
534
|
+
http;
|
|
535
|
+
instanceId;
|
|
536
|
+
get base() {
|
|
537
|
+
return `/instances/${pathSegment(this.instanceId)}/stories`;
|
|
538
|
+
}
|
|
539
|
+
sendText(input, options) {
|
|
540
|
+
return this.http.request({ method: "POST", path: `${this.base}/text`, body: input, ...options ? { options } : {} });
|
|
541
|
+
}
|
|
542
|
+
sendMedia(input, options) {
|
|
543
|
+
const form = toForm(input, ["file", "filename"]);
|
|
544
|
+
const fallback = input.type === "video" ? "story.mp4" : "story.jpg";
|
|
545
|
+
form.set("file", input.file, input.filename ?? fileName(input.file, fallback));
|
|
546
|
+
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
547
|
+
}
|
|
548
|
+
};
|
|
529
549
|
function toForm(input, skip) {
|
|
530
550
|
const form = new FormData();
|
|
531
551
|
for (const [key, value] of Object.entries(input)) {
|
|
@@ -591,11 +611,13 @@ var WhatsAppResource = class {
|
|
|
591
611
|
this.instanceId = instanceId;
|
|
592
612
|
this.groups = new GroupsResource(http, instanceId);
|
|
593
613
|
this.newsletters = new NewslettersResource(http, instanceId);
|
|
614
|
+
this.broadcastLists = new BroadcastListsResource(http, instanceId);
|
|
594
615
|
}
|
|
595
616
|
http;
|
|
596
617
|
instanceId;
|
|
597
618
|
groups;
|
|
598
619
|
newsletters;
|
|
620
|
+
broadcastLists;
|
|
599
621
|
get base() {
|
|
600
622
|
return `/instances/${pathSegment(this.instanceId)}/whatsapp`;
|
|
601
623
|
}
|
|
@@ -671,6 +693,25 @@ var WhatsAppResource = class {
|
|
|
671
693
|
return this.http.request({ method: "POST", path: `${this.base}/qr/business-message/resolve`, body: { code }, ...options ? { options } : {} });
|
|
672
694
|
}
|
|
673
695
|
};
|
|
696
|
+
var BroadcastListsResource = class {
|
|
697
|
+
constructor(http, instanceId) {
|
|
698
|
+
this.http = http;
|
|
699
|
+
this.instanceId = instanceId;
|
|
700
|
+
}
|
|
701
|
+
http;
|
|
702
|
+
instanceId;
|
|
703
|
+
get base() {
|
|
704
|
+
return `/instances/${pathSegment(this.instanceId)}/whatsapp/broadcast-lists`;
|
|
705
|
+
}
|
|
706
|
+
list(options) {
|
|
707
|
+
return this.http.request({ method: "GET", path: this.base, ...options ? { options } : {} });
|
|
708
|
+
}
|
|
709
|
+
/** Accepts the full JID (`123@broadcast`) or the bare id (`123`). 404 while the list has not
|
|
710
|
+
* synced from the phone yet. */
|
|
711
|
+
get(jid, options) {
|
|
712
|
+
return this.http.request({ method: "GET", path: `${this.base}/${pathSegment(jid)}`, ...options ? { options } : {} });
|
|
713
|
+
}
|
|
714
|
+
};
|
|
674
715
|
var GroupsResource = class {
|
|
675
716
|
constructor(http, instanceId) {
|
|
676
717
|
this.http = http;
|
|
@@ -758,6 +799,7 @@ var ApimeInstanceClient = class {
|
|
|
758
799
|
instanceId;
|
|
759
800
|
instance;
|
|
760
801
|
messages;
|
|
802
|
+
stories;
|
|
761
803
|
whatsapp;
|
|
762
804
|
http;
|
|
763
805
|
constructor(auth, options) {
|
|
@@ -765,6 +807,7 @@ var ApimeInstanceClient = class {
|
|
|
765
807
|
this.instanceId = auth.instanceId;
|
|
766
808
|
this.instance = new ScopedInstanceResource(this.http, auth.instanceId);
|
|
767
809
|
this.messages = new MessagesResource(this.http, auth.instanceId);
|
|
810
|
+
this.stories = new StoriesResource(this.http, auth.instanceId);
|
|
768
811
|
this.whatsapp = new WhatsAppResource(this.http, auth.instanceId);
|
|
769
812
|
}
|
|
770
813
|
request(args) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as ApimeError } from './index-
|
|
2
|
-
export { a as ApiError, b as AuthenticationError, C as ConfigurationError, c as ConflictError, d as ConnectionError, I as InvalidRequestError, e as InvalidSignatureError, N as NotFoundError, P as PermissionError, R as RateLimitError, S as SessionUnavailableError, T as TimeoutError, U as UnprocessableError, f as constructEvent, v as verifyWebhookSignature } from './index-
|
|
1
|
+
import { A as ApimeError } from './index-D-LTc5od.cjs';
|
|
2
|
+
export { a as ApiError, b as AuthenticationError, C as ConfigurationError, c as ConflictError, d as ConnectionError, I as InvalidRequestError, e as InvalidSignatureError, N as NotFoundError, P as PermissionError, R as RateLimitError, S as SessionUnavailableError, T as TimeoutError, U as UnprocessableError, f as constructEvent, v as verifyWebhookSignature } from './index-D-LTc5od.cjs';
|
|
3
3
|
import { Instance, QrCode, EventLogEntry, InstanceInfo, Profile, SentMessage } from './types/index.cjs';
|
|
4
|
-
export { C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessagePayload, P as PresencePayload, R as ReceiptPayload,
|
|
4
|
+
export { B as BroadcastRecipient, C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessageInteractive, d as MessageInteractiveReply, e as MessageListRow, f as MessageListSection, g as MessagePayload, P as PresencePayload, R as ReactionPayload, h as ReceiptPayload, i as RestrictionLiftedPayload, T as TemporaryBanPayload, W as WebhookEnvelope, j as WebhookEvent, k as WebhookEventType } from './events-DI9IgIy3.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The apime has three credentials and they do not overlap: 46 routes only
|
|
@@ -289,6 +289,22 @@ interface SendLocationInput extends QuoteInput {
|
|
|
289
289
|
name?: string;
|
|
290
290
|
address?: string;
|
|
291
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* A story (status) has no recipient list: WhatsApp resolves the audience from the account's own
|
|
294
|
+
* status privacy settings, readable via `whatsapp.getStatusPrivacy()`.
|
|
295
|
+
*
|
|
296
|
+
* Not to be confused with `whatsapp.setStatusMessage()`, which changes the profile's "about" text.
|
|
297
|
+
*/
|
|
298
|
+
interface SendStoryTextInput {
|
|
299
|
+
text: string;
|
|
300
|
+
}
|
|
301
|
+
interface SendStoryMediaInput {
|
|
302
|
+
/** Stories take photos and videos only. */
|
|
303
|
+
type: "image" | "video";
|
|
304
|
+
file: Blob | File;
|
|
305
|
+
filename?: string;
|
|
306
|
+
caption?: string;
|
|
307
|
+
}
|
|
292
308
|
/**
|
|
293
309
|
* Sending is the one place where a retry can be seen by the customer, so every
|
|
294
310
|
* method takes an idempotency key through `options`. Without it the client
|
|
@@ -315,6 +331,15 @@ declare class MessagesResource {
|
|
|
315
331
|
}, options?: RequestOptions): Promise<SentMessage>;
|
|
316
332
|
list(options?: RequestOptions): Promise<SentMessage[]>;
|
|
317
333
|
}
|
|
334
|
+
/** Stories live apart from messages: they have no destination and no quoting. */
|
|
335
|
+
declare class StoriesResource {
|
|
336
|
+
private readonly http;
|
|
337
|
+
private readonly instanceId;
|
|
338
|
+
constructor(http: HttpClient, instanceId: string);
|
|
339
|
+
private get base();
|
|
340
|
+
sendText(input: SendStoryTextInput, options?: RequestOptions): Promise<SentMessage>;
|
|
341
|
+
sendMedia(input: SendStoryMediaInput, options?: RequestOptions): Promise<SentMessage>;
|
|
342
|
+
}
|
|
318
343
|
|
|
319
344
|
interface ApiToken {
|
|
320
345
|
id: string;
|
|
@@ -375,6 +400,24 @@ interface GroupInfo {
|
|
|
375
400
|
participants?: GroupParticipant[];
|
|
376
401
|
[key: string]: unknown;
|
|
377
402
|
}
|
|
403
|
+
/** One recipient of a broadcast list. Both identities travel: the phone number is what most
|
|
404
|
+
* consumers key a conversation by, and the LID survives a number change. */
|
|
405
|
+
interface BroadcastListParticipant {
|
|
406
|
+
pn?: string;
|
|
407
|
+
lid?: string;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* A broadcast list is local to the sender: recipients get a normal 1:1 chat and never learn the
|
|
411
|
+
* list exists. Lists are synced from the phone via app state, so one created on the phone only
|
|
412
|
+
* shows up here after that sync, and there is no way to create one through the API.
|
|
413
|
+
*/
|
|
414
|
+
interface BroadcastListInfo {
|
|
415
|
+
jid: string;
|
|
416
|
+
name: string;
|
|
417
|
+
participants: BroadcastListParticipant[];
|
|
418
|
+
labelIds: string[];
|
|
419
|
+
updatedAt: string;
|
|
420
|
+
}
|
|
378
421
|
type PresenceState = "composing" | "paused" | "available" | "unavailable";
|
|
379
422
|
type ParticipantAction = "add" | "remove" | "promote" | "demote";
|
|
380
423
|
type JoinRequestAction = "approve" | "reject";
|
|
@@ -387,6 +430,7 @@ declare class WhatsAppResource {
|
|
|
387
430
|
private readonly instanceId;
|
|
388
431
|
readonly groups: GroupsResource;
|
|
389
432
|
readonly newsletters: NewslettersResource;
|
|
433
|
+
readonly broadcastLists: BroadcastListsResource;
|
|
390
434
|
constructor(http: HttpClient, instanceId: string);
|
|
391
435
|
private get base();
|
|
392
436
|
checkNumber(phone: string, options?: RequestOptions): Promise<CheckNumberResult>;
|
|
@@ -450,6 +494,22 @@ declare class WhatsAppResource {
|
|
|
450
494
|
resolveContactQrLink(code: string, options?: RequestOptions): Promise<unknown>;
|
|
451
495
|
resolveBusinessMessageLink(code: string, options?: RequestOptions): Promise<unknown>;
|
|
452
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Read-only: broadcast lists come from the phone through app state, so there is nothing to create
|
|
499
|
+
* or edit here. To send to a list, address a normal message to its `jid` (`<id>@broadcast`).
|
|
500
|
+
*/
|
|
501
|
+
declare class BroadcastListsResource {
|
|
502
|
+
private readonly http;
|
|
503
|
+
private readonly instanceId;
|
|
504
|
+
constructor(http: HttpClient, instanceId: string);
|
|
505
|
+
private get base();
|
|
506
|
+
list(options?: RequestOptions): Promise<{
|
|
507
|
+
lists: BroadcastListInfo[];
|
|
508
|
+
}>;
|
|
509
|
+
/** Accepts the full JID (`123@broadcast`) or the bare id (`123`). 404 while the list has not
|
|
510
|
+
* synced from the phone yet. */
|
|
511
|
+
get(jid: string, options?: RequestOptions): Promise<BroadcastListInfo>;
|
|
512
|
+
}
|
|
453
513
|
declare class GroupsResource {
|
|
454
514
|
private readonly http;
|
|
455
515
|
private readonly instanceId;
|
|
@@ -537,6 +597,7 @@ declare class ApimeInstanceClient {
|
|
|
537
597
|
readonly instanceId: string;
|
|
538
598
|
readonly instance: ScopedInstanceResource;
|
|
539
599
|
readonly messages: MessagesResource;
|
|
600
|
+
readonly stories: StoriesResource;
|
|
540
601
|
readonly whatsapp: WhatsAppResource;
|
|
541
602
|
private readonly http;
|
|
542
603
|
constructor(auth: InstanceTokenAuth, options: ClientOptions);
|
|
@@ -563,4 +624,4 @@ interface HealthResult {
|
|
|
563
624
|
declare const DEFAULT_HEALTH_TIMEOUT_MS = 10000;
|
|
564
625
|
declare function checkHealth(baseUrl: string, options?: HealthOptions): Promise<HealthResult>;
|
|
565
626
|
|
|
566
|
-
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendGifInput, type SendLocationInput, type SendMediaInput, type SendStickerInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
|
627
|
+
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type BroadcastListInfo, type BroadcastListParticipant, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendGifInput, type SendLocationInput, type SendMediaInput, type SendStickerInput, type SendStoryMediaInput, type SendStoryTextInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as ApimeError } from './index-
|
|
2
|
-
export { a as ApiError, b as AuthenticationError, C as ConfigurationError, c as ConflictError, d as ConnectionError, I as InvalidRequestError, e as InvalidSignatureError, N as NotFoundError, P as PermissionError, R as RateLimitError, S as SessionUnavailableError, T as TimeoutError, U as UnprocessableError, f as constructEvent, v as verifyWebhookSignature } from './index-
|
|
1
|
+
import { A as ApimeError } from './index-C6SaglOj.js';
|
|
2
|
+
export { a as ApiError, b as AuthenticationError, C as ConfigurationError, c as ConflictError, d as ConnectionError, I as InvalidRequestError, e as InvalidSignatureError, N as NotFoundError, P as PermissionError, R as RateLimitError, S as SessionUnavailableError, T as TimeoutError, U as UnprocessableError, f as constructEvent, v as verifyWebhookSignature } from './index-C6SaglOj.js';
|
|
3
3
|
import { Instance, QrCode, EventLogEntry, InstanceInfo, Profile, SentMessage } from './types/index.js';
|
|
4
|
-
export { C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessagePayload, P as PresencePayload, R as ReceiptPayload,
|
|
4
|
+
export { B as BroadcastRecipient, C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessageInteractive, d as MessageInteractiveReply, e as MessageListRow, f as MessageListSection, g as MessagePayload, P as PresencePayload, R as ReactionPayload, h as ReceiptPayload, i as RestrictionLiftedPayload, T as TemporaryBanPayload, W as WebhookEnvelope, j as WebhookEvent, k as WebhookEventType } from './events-DI9IgIy3.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The apime has three credentials and they do not overlap: 46 routes only
|
|
@@ -289,6 +289,22 @@ interface SendLocationInput extends QuoteInput {
|
|
|
289
289
|
name?: string;
|
|
290
290
|
address?: string;
|
|
291
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* A story (status) has no recipient list: WhatsApp resolves the audience from the account's own
|
|
294
|
+
* status privacy settings, readable via `whatsapp.getStatusPrivacy()`.
|
|
295
|
+
*
|
|
296
|
+
* Not to be confused with `whatsapp.setStatusMessage()`, which changes the profile's "about" text.
|
|
297
|
+
*/
|
|
298
|
+
interface SendStoryTextInput {
|
|
299
|
+
text: string;
|
|
300
|
+
}
|
|
301
|
+
interface SendStoryMediaInput {
|
|
302
|
+
/** Stories take photos and videos only. */
|
|
303
|
+
type: "image" | "video";
|
|
304
|
+
file: Blob | File;
|
|
305
|
+
filename?: string;
|
|
306
|
+
caption?: string;
|
|
307
|
+
}
|
|
292
308
|
/**
|
|
293
309
|
* Sending is the one place where a retry can be seen by the customer, so every
|
|
294
310
|
* method takes an idempotency key through `options`. Without it the client
|
|
@@ -315,6 +331,15 @@ declare class MessagesResource {
|
|
|
315
331
|
}, options?: RequestOptions): Promise<SentMessage>;
|
|
316
332
|
list(options?: RequestOptions): Promise<SentMessage[]>;
|
|
317
333
|
}
|
|
334
|
+
/** Stories live apart from messages: they have no destination and no quoting. */
|
|
335
|
+
declare class StoriesResource {
|
|
336
|
+
private readonly http;
|
|
337
|
+
private readonly instanceId;
|
|
338
|
+
constructor(http: HttpClient, instanceId: string);
|
|
339
|
+
private get base();
|
|
340
|
+
sendText(input: SendStoryTextInput, options?: RequestOptions): Promise<SentMessage>;
|
|
341
|
+
sendMedia(input: SendStoryMediaInput, options?: RequestOptions): Promise<SentMessage>;
|
|
342
|
+
}
|
|
318
343
|
|
|
319
344
|
interface ApiToken {
|
|
320
345
|
id: string;
|
|
@@ -375,6 +400,24 @@ interface GroupInfo {
|
|
|
375
400
|
participants?: GroupParticipant[];
|
|
376
401
|
[key: string]: unknown;
|
|
377
402
|
}
|
|
403
|
+
/** One recipient of a broadcast list. Both identities travel: the phone number is what most
|
|
404
|
+
* consumers key a conversation by, and the LID survives a number change. */
|
|
405
|
+
interface BroadcastListParticipant {
|
|
406
|
+
pn?: string;
|
|
407
|
+
lid?: string;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* A broadcast list is local to the sender: recipients get a normal 1:1 chat and never learn the
|
|
411
|
+
* list exists. Lists are synced from the phone via app state, so one created on the phone only
|
|
412
|
+
* shows up here after that sync, and there is no way to create one through the API.
|
|
413
|
+
*/
|
|
414
|
+
interface BroadcastListInfo {
|
|
415
|
+
jid: string;
|
|
416
|
+
name: string;
|
|
417
|
+
participants: BroadcastListParticipant[];
|
|
418
|
+
labelIds: string[];
|
|
419
|
+
updatedAt: string;
|
|
420
|
+
}
|
|
378
421
|
type PresenceState = "composing" | "paused" | "available" | "unavailable";
|
|
379
422
|
type ParticipantAction = "add" | "remove" | "promote" | "demote";
|
|
380
423
|
type JoinRequestAction = "approve" | "reject";
|
|
@@ -387,6 +430,7 @@ declare class WhatsAppResource {
|
|
|
387
430
|
private readonly instanceId;
|
|
388
431
|
readonly groups: GroupsResource;
|
|
389
432
|
readonly newsletters: NewslettersResource;
|
|
433
|
+
readonly broadcastLists: BroadcastListsResource;
|
|
390
434
|
constructor(http: HttpClient, instanceId: string);
|
|
391
435
|
private get base();
|
|
392
436
|
checkNumber(phone: string, options?: RequestOptions): Promise<CheckNumberResult>;
|
|
@@ -450,6 +494,22 @@ declare class WhatsAppResource {
|
|
|
450
494
|
resolveContactQrLink(code: string, options?: RequestOptions): Promise<unknown>;
|
|
451
495
|
resolveBusinessMessageLink(code: string, options?: RequestOptions): Promise<unknown>;
|
|
452
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Read-only: broadcast lists come from the phone through app state, so there is nothing to create
|
|
499
|
+
* or edit here. To send to a list, address a normal message to its `jid` (`<id>@broadcast`).
|
|
500
|
+
*/
|
|
501
|
+
declare class BroadcastListsResource {
|
|
502
|
+
private readonly http;
|
|
503
|
+
private readonly instanceId;
|
|
504
|
+
constructor(http: HttpClient, instanceId: string);
|
|
505
|
+
private get base();
|
|
506
|
+
list(options?: RequestOptions): Promise<{
|
|
507
|
+
lists: BroadcastListInfo[];
|
|
508
|
+
}>;
|
|
509
|
+
/** Accepts the full JID (`123@broadcast`) or the bare id (`123`). 404 while the list has not
|
|
510
|
+
* synced from the phone yet. */
|
|
511
|
+
get(jid: string, options?: RequestOptions): Promise<BroadcastListInfo>;
|
|
512
|
+
}
|
|
453
513
|
declare class GroupsResource {
|
|
454
514
|
private readonly http;
|
|
455
515
|
private readonly instanceId;
|
|
@@ -537,6 +597,7 @@ declare class ApimeInstanceClient {
|
|
|
537
597
|
readonly instanceId: string;
|
|
538
598
|
readonly instance: ScopedInstanceResource;
|
|
539
599
|
readonly messages: MessagesResource;
|
|
600
|
+
readonly stories: StoriesResource;
|
|
540
601
|
readonly whatsapp: WhatsAppResource;
|
|
541
602
|
private readonly http;
|
|
542
603
|
constructor(auth: InstanceTokenAuth, options: ClientOptions);
|
|
@@ -563,4 +624,4 @@ interface HealthResult {
|
|
|
563
624
|
declare const DEFAULT_HEALTH_TIMEOUT_MS = 10000;
|
|
564
625
|
declare function checkHealth(baseUrl: string, options?: HealthOptions): Promise<HealthResult>;
|
|
565
626
|
|
|
566
|
-
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendGifInput, type SendLocationInput, type SendMediaInput, type SendStickerInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
|
627
|
+
export { type ApiToken, type ApiTokenAuth, Apime, ApimeError, ApimeInstanceClient, ApimeUserClient, type Auth, type AuthKind, type BroadcastListInfo, type BroadcastListParticipant, type CheckNumberResult, type ClientOptions, type ContactEntry, type CreateInstanceInput, DEFAULT_HEALTH_TIMEOUT_MS, EventLogEntry, type FailureInfo, type GroupInfo, type GroupParticipant, type HealthOptions, type HealthResult, Instance, InstanceInfo, type InstanceTokenAuth, type IpFamily, type JoinRequestAction, type MarkReadInput, type Observer, type ParticipantAction, type PresenceState, Profile, QrCode, type QuoteInput, type RequestInfo, type RequestOptions, type SendAudioInput, type SendContactInput, type SendDocumentInput, type SendGifInput, type SendLocationInput, type SendMediaInput, type SendStickerInput, type SendStoryMediaInput, type SendStoryTextInput, type SendTextInput, SentMessage, type SuccessInfo, type UpdateInstanceInput, type User, type UserAuth, type UserJwtAuth, checkHealth, hasSentry };
|
package/dist/index.js
CHANGED
|
@@ -455,6 +455,26 @@ var MessagesResource = class {
|
|
|
455
455
|
return this.http.request({ method: "GET", path: this.base, ...options ? { options } : {} });
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
|
+
var StoriesResource = class {
|
|
459
|
+
constructor(http, instanceId) {
|
|
460
|
+
this.http = http;
|
|
461
|
+
this.instanceId = instanceId;
|
|
462
|
+
}
|
|
463
|
+
http;
|
|
464
|
+
instanceId;
|
|
465
|
+
get base() {
|
|
466
|
+
return `/instances/${pathSegment(this.instanceId)}/stories`;
|
|
467
|
+
}
|
|
468
|
+
sendText(input, options) {
|
|
469
|
+
return this.http.request({ method: "POST", path: `${this.base}/text`, body: input, ...options ? { options } : {} });
|
|
470
|
+
}
|
|
471
|
+
sendMedia(input, options) {
|
|
472
|
+
const form = toForm(input, ["file", "filename"]);
|
|
473
|
+
const fallback = input.type === "video" ? "story.mp4" : "story.jpg";
|
|
474
|
+
form.set("file", input.file, input.filename ?? fileName(input.file, fallback));
|
|
475
|
+
return this.http.request({ method: "POST", path: `${this.base}/media`, body: form, ...options ? { options } : {} });
|
|
476
|
+
}
|
|
477
|
+
};
|
|
458
478
|
function toForm(input, skip) {
|
|
459
479
|
const form = new FormData();
|
|
460
480
|
for (const [key, value] of Object.entries(input)) {
|
|
@@ -520,11 +540,13 @@ var WhatsAppResource = class {
|
|
|
520
540
|
this.instanceId = instanceId;
|
|
521
541
|
this.groups = new GroupsResource(http, instanceId);
|
|
522
542
|
this.newsletters = new NewslettersResource(http, instanceId);
|
|
543
|
+
this.broadcastLists = new BroadcastListsResource(http, instanceId);
|
|
523
544
|
}
|
|
524
545
|
http;
|
|
525
546
|
instanceId;
|
|
526
547
|
groups;
|
|
527
548
|
newsletters;
|
|
549
|
+
broadcastLists;
|
|
528
550
|
get base() {
|
|
529
551
|
return `/instances/${pathSegment(this.instanceId)}/whatsapp`;
|
|
530
552
|
}
|
|
@@ -600,6 +622,25 @@ var WhatsAppResource = class {
|
|
|
600
622
|
return this.http.request({ method: "POST", path: `${this.base}/qr/business-message/resolve`, body: { code }, ...options ? { options } : {} });
|
|
601
623
|
}
|
|
602
624
|
};
|
|
625
|
+
var BroadcastListsResource = class {
|
|
626
|
+
constructor(http, instanceId) {
|
|
627
|
+
this.http = http;
|
|
628
|
+
this.instanceId = instanceId;
|
|
629
|
+
}
|
|
630
|
+
http;
|
|
631
|
+
instanceId;
|
|
632
|
+
get base() {
|
|
633
|
+
return `/instances/${pathSegment(this.instanceId)}/whatsapp/broadcast-lists`;
|
|
634
|
+
}
|
|
635
|
+
list(options) {
|
|
636
|
+
return this.http.request({ method: "GET", path: this.base, ...options ? { options } : {} });
|
|
637
|
+
}
|
|
638
|
+
/** Accepts the full JID (`123@broadcast`) or the bare id (`123`). 404 while the list has not
|
|
639
|
+
* synced from the phone yet. */
|
|
640
|
+
get(jid, options) {
|
|
641
|
+
return this.http.request({ method: "GET", path: `${this.base}/${pathSegment(jid)}`, ...options ? { options } : {} });
|
|
642
|
+
}
|
|
643
|
+
};
|
|
603
644
|
var GroupsResource = class {
|
|
604
645
|
constructor(http, instanceId) {
|
|
605
646
|
this.http = http;
|
|
@@ -687,6 +728,7 @@ var ApimeInstanceClient = class {
|
|
|
687
728
|
instanceId;
|
|
688
729
|
instance;
|
|
689
730
|
messages;
|
|
731
|
+
stories;
|
|
690
732
|
whatsapp;
|
|
691
733
|
http;
|
|
692
734
|
constructor(auth, options) {
|
|
@@ -694,6 +736,7 @@ var ApimeInstanceClient = class {
|
|
|
694
736
|
this.instanceId = auth.instanceId;
|
|
695
737
|
this.instance = new ScopedInstanceResource(this.http, auth.instanceId);
|
|
696
738
|
this.messages = new MessagesResource(this.http, auth.instanceId);
|
|
739
|
+
this.stories = new StoriesResource(this.http, auth.instanceId);
|
|
697
740
|
this.whatsapp = new WhatsAppResource(this.http, auth.instanceId);
|
|
698
741
|
}
|
|
699
742
|
request(args) {
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessagePayload, P as PresencePayload, R as ReceiptPayload,
|
|
1
|
+
export { B as BroadcastRecipient, C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessageInteractive, d as MessageInteractiveReply, e as MessageListRow, f as MessageListSection, g as MessagePayload, P as PresencePayload, R as ReactionPayload, h as ReceiptPayload, i as RestrictionLiftedPayload, T as TemporaryBanPayload, W as WebhookEnvelope, j as WebhookEvent, k as WebhookEventType } from '../events-DI9IgIy3.cjs';
|
|
2
2
|
|
|
3
3
|
/** Shapes the apime returns. Field names are the ones on the wire. */
|
|
4
4
|
interface Instance {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessagePayload, P as PresencePayload, R as ReceiptPayload,
|
|
1
|
+
export { B as BroadcastRecipient, C as ChatPresencePayload, a as ContactReachoutLockedPayload, b as ContactUpdatePayload, D as DisconnectedPayload, M as MessageButton, c as MessageInteractive, d as MessageInteractiveReply, e as MessageListRow, f as MessageListSection, g as MessagePayload, P as PresencePayload, R as ReactionPayload, h as ReceiptPayload, i as RestrictionLiftedPayload, T as TemporaryBanPayload, W as WebhookEnvelope, j as WebhookEvent, k as WebhookEventType } from '../events-DI9IgIy3.js';
|
|
2
2
|
|
|
3
3
|
/** Shapes the apime returns. Field names are the ones on the wire. */
|
|
4
4
|
interface Instance {
|
package/dist/webhook/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { e as InvalidSignatureError, g as SIGNATURE_HEADER, f as constructEvent, v as verifyWebhookSignature } from '../index-
|
|
2
|
-
export {
|
|
1
|
+
export { e as InvalidSignatureError, g as SIGNATURE_HEADER, f as constructEvent, v as verifyWebhookSignature } from '../index-D-LTc5od.cjs';
|
|
2
|
+
export { j as WebhookEvent } from '../events-DI9IgIy3.cjs';
|
package/dist/webhook/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { e as InvalidSignatureError, g as SIGNATURE_HEADER, f as constructEvent, v as verifyWebhookSignature } from '../index-
|
|
2
|
-
export {
|
|
1
|
+
export { e as InvalidSignatureError, g as SIGNATURE_HEADER, f as constructEvent, v as verifyWebhookSignature } from '../index-C6SaglOj.js';
|
|
2
|
+
export { j as WebhookEvent } from '../events-DI9IgIy3.js';
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The 12 event types the apime delivers. `ignore` is internal and never
|
|
3
|
-
* reaches a consumer, so it is not part of the union.
|
|
4
|
-
*/
|
|
5
|
-
type WebhookEventType = "message" | "receipt" | "presence" | "chat_presence" | "reaction" | "contact_update" | "connected" | "disconnected" | "temporary_ban" | "restriction_lifted" | "contact_reachout_locked" | "unknown";
|
|
6
|
-
interface WebhookEnvelope<T extends WebhookEventType = WebhookEventType, P = unknown> {
|
|
7
|
-
id: string;
|
|
8
|
-
instanceId: string;
|
|
9
|
-
type: T;
|
|
10
|
-
payload: P;
|
|
11
|
-
createdAt: string;
|
|
12
|
-
}
|
|
13
|
-
/** Button of an interactive message. `call`, `copy`, `reply` and `url` are button kinds, not events. */
|
|
14
|
-
interface MessageButton {
|
|
15
|
-
id: string;
|
|
16
|
-
label: string;
|
|
17
|
-
type: "reply" | "url" | "copy" | "call";
|
|
18
|
-
url?: string;
|
|
19
|
-
code?: string;
|
|
20
|
-
phone?: string;
|
|
21
|
-
}
|
|
22
|
-
interface MessagePayload {
|
|
23
|
-
from: string;
|
|
24
|
-
to: string;
|
|
25
|
-
isFromMe: boolean;
|
|
26
|
-
isGroup: boolean;
|
|
27
|
-
messageId: string;
|
|
28
|
-
timestamp: number;
|
|
29
|
-
pushName?: string;
|
|
30
|
-
text?: string;
|
|
31
|
-
mediaType?: "image" | "video" | "audio" | "document" | "sticker" | "location" | "contact";
|
|
32
|
-
mediaUrl?: string;
|
|
33
|
-
mimetype?: string;
|
|
34
|
-
caption?: string;
|
|
35
|
-
buttons?: MessageButton[];
|
|
36
|
-
/**
|
|
37
|
-
* Present only when this event is an edit: the id of the message that was
|
|
38
|
-
* edited, and its new text. They always travel together, so checking one is
|
|
39
|
-
* enough to know it is an edit.
|
|
40
|
-
*/
|
|
41
|
-
editedMessageId?: string;
|
|
42
|
-
editedText?: string;
|
|
43
|
-
}
|
|
44
|
-
interface ReceiptPayload {
|
|
45
|
-
messageIds: string[];
|
|
46
|
-
timestamp: number;
|
|
47
|
-
chat: string;
|
|
48
|
-
status: "read" | "delivered" | "played";
|
|
49
|
-
}
|
|
50
|
-
interface PresencePayload {
|
|
51
|
-
from: string;
|
|
52
|
-
unavailable: boolean;
|
|
53
|
-
lastSeen?: number;
|
|
54
|
-
}
|
|
55
|
-
interface ChatPresencePayload {
|
|
56
|
-
from: string;
|
|
57
|
-
chatJID: string;
|
|
58
|
-
state: "composing" | "paused";
|
|
59
|
-
media?: "audio";
|
|
60
|
-
}
|
|
61
|
-
interface ContactUpdatePayload {
|
|
62
|
-
jid: string;
|
|
63
|
-
username: string;
|
|
64
|
-
}
|
|
65
|
-
interface DisconnectedPayload {
|
|
66
|
-
reason?: string;
|
|
67
|
-
}
|
|
68
|
-
/** Same shape for the account ban and for the reach-out timelock. */
|
|
69
|
-
interface TemporaryBanPayload {
|
|
70
|
-
reason?: string;
|
|
71
|
-
code?: number;
|
|
72
|
-
active: boolean;
|
|
73
|
-
restrictedUntil?: string;
|
|
74
|
-
enforcementType?: string;
|
|
75
|
-
}
|
|
76
|
-
interface RestrictionLiftedPayload {
|
|
77
|
-
active: false;
|
|
78
|
-
enforcementType?: string;
|
|
79
|
-
restrictedUntil?: string;
|
|
80
|
-
}
|
|
81
|
-
interface ContactReachoutLockedPayload {
|
|
82
|
-
to: string;
|
|
83
|
-
reason: string;
|
|
84
|
-
detail: string;
|
|
85
|
-
code: number;
|
|
86
|
-
}
|
|
87
|
-
/** Discriminated by `type`, so a switch narrows the payload. */
|
|
88
|
-
type WebhookEvent = WebhookEnvelope<"message", MessagePayload> | WebhookEnvelope<"receipt", ReceiptPayload> | WebhookEnvelope<"presence", PresencePayload> | WebhookEnvelope<"chat_presence", ChatPresencePayload> | WebhookEnvelope<"reaction", Record<string, unknown>> | WebhookEnvelope<"contact_update", ContactUpdatePayload> | WebhookEnvelope<"connected", Record<string, unknown>> | WebhookEnvelope<"disconnected", DisconnectedPayload> | WebhookEnvelope<"temporary_ban", TemporaryBanPayload> | WebhookEnvelope<"restriction_lifted", RestrictionLiftedPayload> | WebhookEnvelope<"contact_reachout_locked", ContactReachoutLockedPayload> | WebhookEnvelope<"unknown", Record<string, unknown>>;
|
|
89
|
-
|
|
90
|
-
export type { ChatPresencePayload as C, DisconnectedPayload as D, MessageButton as M, PresencePayload as P, ReceiptPayload as R, TemporaryBanPayload as T, WebhookEnvelope as W, ContactReachoutLockedPayload as a, ContactUpdatePayload as b, MessagePayload as c, RestrictionLiftedPayload as d, WebhookEvent as e, WebhookEventType as f };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The 12 event types the apime delivers. `ignore` is internal and never
|
|
3
|
-
* reaches a consumer, so it is not part of the union.
|
|
4
|
-
*/
|
|
5
|
-
type WebhookEventType = "message" | "receipt" | "presence" | "chat_presence" | "reaction" | "contact_update" | "connected" | "disconnected" | "temporary_ban" | "restriction_lifted" | "contact_reachout_locked" | "unknown";
|
|
6
|
-
interface WebhookEnvelope<T extends WebhookEventType = WebhookEventType, P = unknown> {
|
|
7
|
-
id: string;
|
|
8
|
-
instanceId: string;
|
|
9
|
-
type: T;
|
|
10
|
-
payload: P;
|
|
11
|
-
createdAt: string;
|
|
12
|
-
}
|
|
13
|
-
/** Button of an interactive message. `call`, `copy`, `reply` and `url` are button kinds, not events. */
|
|
14
|
-
interface MessageButton {
|
|
15
|
-
id: string;
|
|
16
|
-
label: string;
|
|
17
|
-
type: "reply" | "url" | "copy" | "call";
|
|
18
|
-
url?: string;
|
|
19
|
-
code?: string;
|
|
20
|
-
phone?: string;
|
|
21
|
-
}
|
|
22
|
-
interface MessagePayload {
|
|
23
|
-
from: string;
|
|
24
|
-
to: string;
|
|
25
|
-
isFromMe: boolean;
|
|
26
|
-
isGroup: boolean;
|
|
27
|
-
messageId: string;
|
|
28
|
-
timestamp: number;
|
|
29
|
-
pushName?: string;
|
|
30
|
-
text?: string;
|
|
31
|
-
mediaType?: "image" | "video" | "audio" | "document" | "sticker" | "location" | "contact";
|
|
32
|
-
mediaUrl?: string;
|
|
33
|
-
mimetype?: string;
|
|
34
|
-
caption?: string;
|
|
35
|
-
buttons?: MessageButton[];
|
|
36
|
-
/**
|
|
37
|
-
* Present only when this event is an edit: the id of the message that was
|
|
38
|
-
* edited, and its new text. They always travel together, so checking one is
|
|
39
|
-
* enough to know it is an edit.
|
|
40
|
-
*/
|
|
41
|
-
editedMessageId?: string;
|
|
42
|
-
editedText?: string;
|
|
43
|
-
}
|
|
44
|
-
interface ReceiptPayload {
|
|
45
|
-
messageIds: string[];
|
|
46
|
-
timestamp: number;
|
|
47
|
-
chat: string;
|
|
48
|
-
status: "read" | "delivered" | "played";
|
|
49
|
-
}
|
|
50
|
-
interface PresencePayload {
|
|
51
|
-
from: string;
|
|
52
|
-
unavailable: boolean;
|
|
53
|
-
lastSeen?: number;
|
|
54
|
-
}
|
|
55
|
-
interface ChatPresencePayload {
|
|
56
|
-
from: string;
|
|
57
|
-
chatJID: string;
|
|
58
|
-
state: "composing" | "paused";
|
|
59
|
-
media?: "audio";
|
|
60
|
-
}
|
|
61
|
-
interface ContactUpdatePayload {
|
|
62
|
-
jid: string;
|
|
63
|
-
username: string;
|
|
64
|
-
}
|
|
65
|
-
interface DisconnectedPayload {
|
|
66
|
-
reason?: string;
|
|
67
|
-
}
|
|
68
|
-
/** Same shape for the account ban and for the reach-out timelock. */
|
|
69
|
-
interface TemporaryBanPayload {
|
|
70
|
-
reason?: string;
|
|
71
|
-
code?: number;
|
|
72
|
-
active: boolean;
|
|
73
|
-
restrictedUntil?: string;
|
|
74
|
-
enforcementType?: string;
|
|
75
|
-
}
|
|
76
|
-
interface RestrictionLiftedPayload {
|
|
77
|
-
active: false;
|
|
78
|
-
enforcementType?: string;
|
|
79
|
-
restrictedUntil?: string;
|
|
80
|
-
}
|
|
81
|
-
interface ContactReachoutLockedPayload {
|
|
82
|
-
to: string;
|
|
83
|
-
reason: string;
|
|
84
|
-
detail: string;
|
|
85
|
-
code: number;
|
|
86
|
-
}
|
|
87
|
-
/** Discriminated by `type`, so a switch narrows the payload. */
|
|
88
|
-
type WebhookEvent = WebhookEnvelope<"message", MessagePayload> | WebhookEnvelope<"receipt", ReceiptPayload> | WebhookEnvelope<"presence", PresencePayload> | WebhookEnvelope<"chat_presence", ChatPresencePayload> | WebhookEnvelope<"reaction", Record<string, unknown>> | WebhookEnvelope<"contact_update", ContactUpdatePayload> | WebhookEnvelope<"connected", Record<string, unknown>> | WebhookEnvelope<"disconnected", DisconnectedPayload> | WebhookEnvelope<"temporary_ban", TemporaryBanPayload> | WebhookEnvelope<"restriction_lifted", RestrictionLiftedPayload> | WebhookEnvelope<"contact_reachout_locked", ContactReachoutLockedPayload> | WebhookEnvelope<"unknown", Record<string, unknown>>;
|
|
89
|
-
|
|
90
|
-
export type { ChatPresencePayload as C, DisconnectedPayload as D, MessageButton as M, PresencePayload as P, ReceiptPayload as R, TemporaryBanPayload as T, WebhookEnvelope as W, ContactReachoutLockedPayload as a, ContactUpdatePayload as b, MessagePayload as c, RestrictionLiftedPayload as d, WebhookEvent as e, WebhookEventType as f };
|