@open-apime/sdk 0.6.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-BUqVWlyS.d.cts → events-DI9IgIy3.d.cts} +20 -1
- package/dist/{events-BUqVWlyS.d.ts → events-DI9IgIy3.d.ts} +20 -1
- package/dist/{index-CauhD-7n.d.ts → index-C6SaglOj.d.ts} +1 -1
- package/dist/{index-CJP98yfj.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
|
@@ -52,6 +52,11 @@ interface MessageInteractiveReply {
|
|
|
52
52
|
name?: string;
|
|
53
53
|
paramsJson?: string;
|
|
54
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
|
+
}
|
|
55
60
|
interface MessagePayload {
|
|
56
61
|
from: string;
|
|
57
62
|
to: string;
|
|
@@ -67,6 +72,20 @@ interface MessagePayload {
|
|
|
67
72
|
addressingMode?: string;
|
|
68
73
|
isFromMe: boolean;
|
|
69
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[];
|
|
70
89
|
messageId: string;
|
|
71
90
|
timestamp: number;
|
|
72
91
|
pushName?: string;
|
|
@@ -176,4 +195,4 @@ interface ContactReachoutLockedPayload {
|
|
|
176
195
|
/** Discriminated by `type`, so a switch narrows the payload. */
|
|
177
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>>;
|
|
178
197
|
|
|
179
|
-
export type { 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 };
|
|
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 };
|
|
@@ -52,6 +52,11 @@ interface MessageInteractiveReply {
|
|
|
52
52
|
name?: string;
|
|
53
53
|
paramsJson?: string;
|
|
54
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
|
+
}
|
|
55
60
|
interface MessagePayload {
|
|
56
61
|
from: string;
|
|
57
62
|
to: string;
|
|
@@ -67,6 +72,20 @@ interface MessagePayload {
|
|
|
67
72
|
addressingMode?: string;
|
|
68
73
|
isFromMe: boolean;
|
|
69
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[];
|
|
70
89
|
messageId: string;
|
|
71
90
|
timestamp: number;
|
|
72
91
|
pushName?: string;
|
|
@@ -176,4 +195,4 @@ interface ContactReachoutLockedPayload {
|
|
|
176
195
|
/** Discriminated by `type`, so a switch narrows the payload. */
|
|
177
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>>;
|
|
178
197
|
|
|
179
|
-
export type { 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 };
|
|
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 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-
|
|
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 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-
|
|
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 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-
|
|
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 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-
|
|
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 { j as WebhookEvent } from '../events-
|
|
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 { j as WebhookEvent } from '../events-
|
|
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';
|