@wats/types 0.3.1

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/config.d.ts +15 -0
  4. package/dist/config.js +4 -0
  5. package/dist/contacts.d.ts +58 -0
  6. package/dist/contacts.js +9 -0
  7. package/dist/entities.d.ts +16 -0
  8. package/dist/entities.js +6 -0
  9. package/dist/errors.d.ts +27 -0
  10. package/dist/errors.js +4 -0
  11. package/dist/index.d.ts +9 -0
  12. package/dist/index.js +7 -0
  13. package/dist/messages/audio.d.ts +10 -0
  14. package/dist/messages/audio.js +0 -0
  15. package/dist/messages/button.d.ts +14 -0
  16. package/dist/messages/button.js +0 -0
  17. package/dist/messages/contacts.d.ts +11 -0
  18. package/dist/messages/contacts.js +0 -0
  19. package/dist/messages/document.d.ts +10 -0
  20. package/dist/messages/document.js +0 -0
  21. package/dist/messages/image.d.ts +10 -0
  22. package/dist/messages/image.js +0 -0
  23. package/dist/messages/index.d.ts +17 -0
  24. package/dist/messages/index.js +21 -0
  25. package/dist/messages/interactive.d.ts +57 -0
  26. package/dist/messages/interactive.js +0 -0
  27. package/dist/messages/location.d.ts +16 -0
  28. package/dist/messages/location.js +0 -0
  29. package/dist/messages/media.d.ts +24 -0
  30. package/dist/messages/media.js +0 -0
  31. package/dist/messages/order.d.ts +21 -0
  32. package/dist/messages/order.js +0 -0
  33. package/dist/messages/reaction.d.ts +14 -0
  34. package/dist/messages/reaction.js +0 -0
  35. package/dist/messages/sticker.d.ts +10 -0
  36. package/dist/messages/sticker.js +0 -0
  37. package/dist/messages/system.d.ts +16 -0
  38. package/dist/messages/system.js +0 -0
  39. package/dist/messages/text.d.ts +12 -0
  40. package/dist/messages/text.js +0 -0
  41. package/dist/messages/union.d.ts +21 -0
  42. package/dist/messages/union.js +0 -0
  43. package/dist/messages/unsupported.d.ts +9 -0
  44. package/dist/messages/unsupported.js +0 -0
  45. package/dist/messages/video.d.ts +10 -0
  46. package/dist/messages/video.js +0 -0
  47. package/dist/statuses.d.ts +25 -0
  48. package/dist/statuses.js +4 -0
  49. package/dist/webhook.d.ts +90 -0
  50. package/dist/webhook.js +6 -0
  51. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WATS contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @wats/types
2
+
3
+ Alpha WATS package. See the repository README and docs at https://github.com/Switchbord/wats.
@@ -0,0 +1,15 @@
1
+ export interface WhatsAppClientConfig {
2
+ token: string;
3
+ phoneNumberId: string;
4
+ appSecret?: string;
5
+ verifyToken?: string;
6
+ apiVersion?: string;
7
+ baseUrl?: string;
8
+ }
9
+ export interface WhatsAppClientRuntimeConfig extends Required<Pick<WhatsAppClientConfig, "token" | "phoneNumberId">> {
10
+ appSecret?: string;
11
+ verifyToken?: string;
12
+ apiVersion: string;
13
+ baseUrl: string;
14
+ }
15
+ export declare const WATS_TYPES_CONFIG_EXPORTS: readonly ["WhatsAppClientConfig", "WhatsAppClientRuntimeConfig"];
package/dist/config.js ADDED
@@ -0,0 +1,4 @@
1
+ export const WATS_TYPES_CONFIG_EXPORTS = [
2
+ "WhatsAppClientConfig",
3
+ "WhatsAppClientRuntimeConfig"
4
+ ];
@@ -0,0 +1,58 @@
1
+ export interface WhatsAppContactName {
2
+ formatted?: string;
3
+ first_name?: string;
4
+ last_name?: string;
5
+ middle_name?: string;
6
+ suffix?: string;
7
+ prefix?: string;
8
+ /**
9
+ * Legacy camelCase fields retained from B1. Either casing style may be
10
+ * populated depending on who authored the payload.
11
+ * TODO(F-8): collapse to camelCase-only once the normalizer lands.
12
+ */
13
+ formattedName?: string;
14
+ firstName?: string;
15
+ lastName?: string;
16
+ }
17
+ export interface ContactPhone {
18
+ phone?: string;
19
+ type?: string;
20
+ wa_id?: string;
21
+ }
22
+ export interface ContactEmail {
23
+ email?: string;
24
+ type?: string;
25
+ }
26
+ export interface ContactAddress {
27
+ street?: string;
28
+ city?: string;
29
+ state?: string;
30
+ zip?: string;
31
+ country?: string;
32
+ country_code?: string;
33
+ type?: string;
34
+ }
35
+ export interface ContactOrg {
36
+ company?: string;
37
+ department?: string;
38
+ title?: string;
39
+ }
40
+ export interface ContactUrl {
41
+ url?: string;
42
+ type?: string;
43
+ }
44
+ export interface WhatsAppContact {
45
+ wa_id?: string;
46
+ profile?: {
47
+ name?: string;
48
+ };
49
+ name?: WhatsAppContactName;
50
+ phones?: ContactPhone[];
51
+ emails?: ContactEmail[];
52
+ addresses?: ContactAddress[];
53
+ org?: ContactOrg;
54
+ urls?: ContactUrl[];
55
+ birthday?: string;
56
+ raw?: unknown;
57
+ }
58
+ export declare const WATS_TYPES_CONTACTS_EXPORTS: readonly ["WhatsAppContact", "WhatsAppContactName", "ContactPhone", "ContactEmail", "ContactAddress", "ContactOrg", "ContactUrl"];
@@ -0,0 +1,9 @@
1
+ export const WATS_TYPES_CONTACTS_EXPORTS = [
2
+ "WhatsAppContact",
3
+ "WhatsAppContactName",
4
+ "ContactPhone",
5
+ "ContactEmail",
6
+ "ContactAddress",
7
+ "ContactOrg",
8
+ "ContactUrl"
9
+ ];
@@ -0,0 +1,16 @@
1
+ export type { WhatsAppMessage } from "./messages/union";
2
+ export type { WhatsAppContact, WhatsAppContactName, ContactPhone, ContactEmail, ContactAddress, ContactOrg, ContactUrl } from "./contacts";
3
+ export type { WhatsAppMessageStatus, WhatsAppMessageStatusKind, ConversationRef, PricingRef } from "./statuses";
4
+ export type { WhatsAppError, WhatsAppErrorPayload } from "./errors";
5
+ export interface WhatsAppMessageText {
6
+ body: string;
7
+ }
8
+ /**
9
+ * Legacy message-context shape carried over from B1. New code should
10
+ * prefer `MessageContext` from `@wats/types/messages`.
11
+ */
12
+ export interface WhatsAppMessageContext {
13
+ from?: string;
14
+ id?: string;
15
+ }
16
+ export declare const WATS_TYPES_ENTITIES_EXPORTS: readonly ["WhatsAppMessage", "WhatsAppContact", "WhatsAppErrorPayload", "WhatsAppMessageStatus"];
@@ -0,0 +1,6 @@
1
+ export const WATS_TYPES_ENTITIES_EXPORTS = [
2
+ "WhatsAppMessage",
3
+ "WhatsAppContact",
4
+ "WhatsAppErrorPayload",
5
+ "WhatsAppMessageStatus"
6
+ ];
@@ -0,0 +1,27 @@
1
+ export interface WhatsAppError {
2
+ code: number;
3
+ title: string;
4
+ message: string;
5
+ errorData?: {
6
+ details?: string;
7
+ href?: string;
8
+ };
9
+ href?: string;
10
+ }
11
+ /**
12
+ * Backward-compatible payload shape introduced in B1. Retained so
13
+ * existing consumers that inspect only-optional fields continue to
14
+ * compile. New code should prefer `WhatsAppError`.
15
+ */
16
+ export interface WhatsAppErrorPayload {
17
+ code?: number;
18
+ title?: string;
19
+ message?: string;
20
+ details?: string;
21
+ errorData?: {
22
+ details?: string;
23
+ href?: string;
24
+ };
25
+ href?: string;
26
+ }
27
+ export declare const WATS_TYPES_ERRORS_EXPORTS: readonly ["WhatsAppError", "WhatsAppErrorPayload"];
package/dist/errors.js ADDED
@@ -0,0 +1,4 @@
1
+ export const WATS_TYPES_ERRORS_EXPORTS = [
2
+ "WhatsAppError",
3
+ "WhatsAppErrorPayload"
4
+ ];
@@ -0,0 +1,9 @@
1
+ export * from "./config";
2
+ export * from "./webhook";
3
+ export * from "./entities";
4
+ export type { TextMessage, ImageMessage, VideoMessage, AudioMessage, DocumentMessage, StickerMessage, LocationMessage, LocationPayload, ContactsMessage, ReactionMessage, ReactionPayload, OrderMessage, OrderPayload, OrderProductItem, SystemMessage, SystemNotification, UnsupportedMessage, InteractiveMessage, InteractiveReply, InteractiveButtonReply, InteractiveListReply, InteractiveNfmReply, InteractiveProductReply, InteractiveProductListReply, InteractiveCtaUrlReply, ButtonMessage, ButtonPayload, WhatsAppMessageKind, MediaReference, DocumentReference, MessageContext } from "./messages";
5
+ export { WATS_TYPES_MESSAGES_EXPORTS } from "./messages";
6
+ export { WATS_TYPES_STATUSES_EXPORTS } from "./statuses";
7
+ export { WATS_TYPES_CONTACTS_EXPORTS } from "./contacts";
8
+ export { WATS_TYPES_ERRORS_EXPORTS } from "./errors";
9
+ export type { WhatsAppMessagesFieldValue, WhatsAppTemplateStatusUpdateValue, WhatsAppAccountReviewUpdateValue, WhatsAppUserMarketingPreferencesValue, WhatsAppPhoneNumberChangeValue, WhatsAppIdentityChangeValue, WhatsAppRawWebhookValue } from "./webhook";
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./config";
2
+ export * from "./webhook";
3
+ export * from "./entities";
4
+ export { WATS_TYPES_MESSAGES_EXPORTS } from "./messages";
5
+ export { WATS_TYPES_STATUSES_EXPORTS } from "./statuses";
6
+ export { WATS_TYPES_CONTACTS_EXPORTS } from "./contacts";
7
+ export { WATS_TYPES_ERRORS_EXPORTS } from "./errors";
@@ -0,0 +1,10 @@
1
+ import type { MediaReference, MessageContext } from "./media";
2
+ export interface AudioMessage {
3
+ type: "audio";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ audio: MediaReference;
8
+ context?: MessageContext;
9
+ raw?: unknown;
10
+ }
File without changes
@@ -0,0 +1,14 @@
1
+ import type { MessageContext } from "./media";
2
+ export interface ButtonPayload {
3
+ text: string;
4
+ payload?: string;
5
+ }
6
+ export interface ButtonMessage {
7
+ type: "button";
8
+ id: string;
9
+ from: string;
10
+ timestamp: string;
11
+ button: ButtonPayload;
12
+ context?: MessageContext;
13
+ raw?: unknown;
14
+ }
File without changes
@@ -0,0 +1,11 @@
1
+ import type { WhatsAppContact } from "../contacts";
2
+ import type { MessageContext } from "./media";
3
+ export interface ContactsMessage {
4
+ type: "contacts";
5
+ id: string;
6
+ from: string;
7
+ timestamp: string;
8
+ contacts: WhatsAppContact[];
9
+ context?: MessageContext;
10
+ raw?: unknown;
11
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import type { DocumentReference, MessageContext } from "./media";
2
+ export interface DocumentMessage {
3
+ type: "document";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ document: DocumentReference;
8
+ context?: MessageContext;
9
+ raw?: unknown;
10
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import type { MediaReference, MessageContext } from "./media";
2
+ export interface ImageMessage {
3
+ type: "image";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ image: MediaReference;
8
+ context?: MessageContext;
9
+ raw?: unknown;
10
+ }
File without changes
@@ -0,0 +1,17 @@
1
+ export type { TextMessage } from "./text";
2
+ export type { ImageMessage } from "./image";
3
+ export type { VideoMessage } from "./video";
4
+ export type { AudioMessage } from "./audio";
5
+ export type { DocumentMessage } from "./document";
6
+ export type { StickerMessage } from "./sticker";
7
+ export type { LocationMessage, LocationPayload } from "./location";
8
+ export type { ContactsMessage } from "./contacts";
9
+ export type { ReactionMessage, ReactionPayload } from "./reaction";
10
+ export type { OrderMessage, OrderPayload, OrderProductItem } from "./order";
11
+ export type { SystemMessage, SystemNotification } from "./system";
12
+ export type { UnsupportedMessage } from "./unsupported";
13
+ export type { InteractiveMessage, InteractiveReply, InteractiveButtonReply, InteractiveListReply, InteractiveNfmReply, InteractiveProductReply, InteractiveProductListReply, InteractiveCtaUrlReply } from "./interactive";
14
+ export type { ButtonMessage, ButtonPayload } from "./button";
15
+ export type { WhatsAppMessage, WhatsAppMessageKind } from "./union";
16
+ export type { MediaReference, DocumentReference, MessageContext } from "./media";
17
+ export declare const WATS_TYPES_MESSAGES_EXPORTS: readonly ["TextMessage", "ImageMessage", "VideoMessage", "AudioMessage", "DocumentMessage", "StickerMessage", "LocationMessage", "ContactsMessage", "ReactionMessage", "OrderMessage", "SystemMessage", "UnsupportedMessage", "InteractiveMessage", "ButtonMessage", "WhatsAppMessage", "InteractiveReply", "MediaReference", "DocumentReference", "MessageContext"];
@@ -0,0 +1,21 @@
1
+ export const WATS_TYPES_MESSAGES_EXPORTS = [
2
+ "TextMessage",
3
+ "ImageMessage",
4
+ "VideoMessage",
5
+ "AudioMessage",
6
+ "DocumentMessage",
7
+ "StickerMessage",
8
+ "LocationMessage",
9
+ "ContactsMessage",
10
+ "ReactionMessage",
11
+ "OrderMessage",
12
+ "SystemMessage",
13
+ "UnsupportedMessage",
14
+ "InteractiveMessage",
15
+ "ButtonMessage",
16
+ "WhatsAppMessage",
17
+ "InteractiveReply",
18
+ "MediaReference",
19
+ "DocumentReference",
20
+ "MessageContext"
21
+ ];
@@ -0,0 +1,57 @@
1
+ import type { MessageContext } from "./media";
2
+ export interface InteractiveButtonReply {
3
+ type: "button_reply";
4
+ buttonReply: {
5
+ id: string;
6
+ title: string;
7
+ };
8
+ }
9
+ export interface InteractiveListReply {
10
+ type: "list_reply";
11
+ listReply: {
12
+ id: string;
13
+ title: string;
14
+ description?: string;
15
+ };
16
+ }
17
+ export interface InteractiveNfmReply {
18
+ type: "nfm_reply";
19
+ nfmReply: {
20
+ responseJson?: string;
21
+ body?: string;
22
+ name?: string;
23
+ };
24
+ }
25
+ export interface InteractiveProductReply {
26
+ type: "product_reply";
27
+ productReply: {
28
+ catalogId: string;
29
+ productRetailerId: string;
30
+ };
31
+ }
32
+ export interface InteractiveProductListReply {
33
+ type: "product_list_reply";
34
+ productListReply: {
35
+ catalogId: string;
36
+ productItems: ReadonlyArray<{
37
+ productRetailerId: string;
38
+ }>;
39
+ };
40
+ }
41
+ export interface InteractiveCtaUrlReply {
42
+ type: "cta_url_reply";
43
+ ctaUrlReply: {
44
+ displayText: string;
45
+ url: string;
46
+ };
47
+ }
48
+ export type InteractiveReply = InteractiveButtonReply | InteractiveListReply | InteractiveNfmReply | InteractiveProductReply | InteractiveProductListReply | InteractiveCtaUrlReply;
49
+ export interface InteractiveMessage {
50
+ type: "interactive";
51
+ id: string;
52
+ from: string;
53
+ timestamp: string;
54
+ interactive: InteractiveReply;
55
+ context?: MessageContext;
56
+ raw?: unknown;
57
+ }
File without changes
@@ -0,0 +1,16 @@
1
+ import type { MessageContext } from "./media";
2
+ export interface LocationPayload {
3
+ latitude: number;
4
+ longitude: number;
5
+ name?: string;
6
+ address?: string;
7
+ }
8
+ export interface LocationMessage {
9
+ type: "location";
10
+ id: string;
11
+ from: string;
12
+ timestamp: string;
13
+ location: LocationPayload;
14
+ context?: MessageContext;
15
+ raw?: unknown;
16
+ }
File without changes
@@ -0,0 +1,24 @@
1
+ export interface MediaReference {
2
+ id: string;
3
+ mimeType: string;
4
+ sha256?: string;
5
+ caption?: string;
6
+ filename?: string;
7
+ }
8
+ export interface DocumentReference extends MediaReference {
9
+ filename: string;
10
+ }
11
+ export interface MessageContext {
12
+ messageId: string;
13
+ from?: string;
14
+ forwarded?: boolean;
15
+ frequentlyForwarded?: boolean;
16
+ /**
17
+ * WATS-43A normalizes the wire `referred_product` object to camelCase
18
+ * when present on inbound message contexts.
19
+ */
20
+ referredProduct?: {
21
+ catalogId: string;
22
+ productRetailerId: string;
23
+ };
24
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import type { MessageContext } from "./media";
2
+ export interface OrderProductItem {
3
+ productRetailerId: string;
4
+ quantity?: number;
5
+ itemPrice?: number;
6
+ currency?: string;
7
+ }
8
+ export interface OrderPayload {
9
+ catalogId: string;
10
+ text?: string;
11
+ productItems: OrderProductItem[];
12
+ }
13
+ export interface OrderMessage {
14
+ type: "order";
15
+ id: string;
16
+ from: string;
17
+ timestamp: string;
18
+ order: OrderPayload;
19
+ context?: MessageContext;
20
+ raw?: unknown;
21
+ }
File without changes
@@ -0,0 +1,14 @@
1
+ import type { MessageContext } from "./media";
2
+ export interface ReactionPayload {
3
+ messageId: string;
4
+ emoji: string;
5
+ }
6
+ export interface ReactionMessage {
7
+ type: "reaction";
8
+ id: string;
9
+ from: string;
10
+ timestamp: string;
11
+ reaction: ReactionPayload;
12
+ context?: MessageContext;
13
+ raw?: unknown;
14
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import type { MediaReference, MessageContext } from "./media";
2
+ export interface StickerMessage {
3
+ type: "sticker";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ sticker: MediaReference;
8
+ context?: MessageContext;
9
+ raw?: unknown;
10
+ }
File without changes
@@ -0,0 +1,16 @@
1
+ export interface SystemNotification {
2
+ body: string;
3
+ type?: string;
4
+ identity?: string;
5
+ wa_id?: string;
6
+ customer?: string;
7
+ newWaId?: string;
8
+ }
9
+ export interface SystemMessage {
10
+ type: "system";
11
+ id: string;
12
+ from: string;
13
+ timestamp: string;
14
+ system: SystemNotification;
15
+ raw?: unknown;
16
+ }
File without changes
@@ -0,0 +1,12 @@
1
+ import type { MessageContext } from "./media";
2
+ export interface TextMessage {
3
+ type: "text";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ text: {
8
+ body: string;
9
+ };
10
+ context?: MessageContext;
11
+ raw?: unknown;
12
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import type { TextMessage } from "./text";
2
+ import type { ImageMessage } from "./image";
3
+ import type { VideoMessage } from "./video";
4
+ import type { AudioMessage } from "./audio";
5
+ import type { DocumentMessage } from "./document";
6
+ import type { StickerMessage } from "./sticker";
7
+ import type { LocationMessage } from "./location";
8
+ import type { ContactsMessage } from "./contacts";
9
+ import type { ReactionMessage } from "./reaction";
10
+ import type { OrderMessage } from "./order";
11
+ import type { SystemMessage } from "./system";
12
+ import type { UnsupportedMessage } from "./unsupported";
13
+ import type { InteractiveMessage } from "./interactive";
14
+ import type { ButtonMessage } from "./button";
15
+ export type WhatsAppMessage = TextMessage | ImageMessage | VideoMessage | AudioMessage | DocumentMessage | StickerMessage | LocationMessage | ContactsMessage | ReactionMessage | OrderMessage | SystemMessage | UnsupportedMessage | InteractiveMessage | ButtonMessage;
16
+ /**
17
+ * The closed set of `WhatsAppMessage.type` discriminators. Useful for
18
+ * building runtime allow-lists, but the canonical source of truth is
19
+ * the union itself — consumers should narrow via `switch (msg.type)`.
20
+ */
21
+ export type WhatsAppMessageKind = WhatsAppMessage["type"];
File without changes
@@ -0,0 +1,9 @@
1
+ import type { WhatsAppError } from "../errors";
2
+ export interface UnsupportedMessage {
3
+ type: "unsupported";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ errors?: WhatsAppError[];
8
+ raw?: unknown;
9
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import type { MediaReference, MessageContext } from "./media";
2
+ export interface VideoMessage {
3
+ type: "video";
4
+ id: string;
5
+ from: string;
6
+ timestamp: string;
7
+ video: MediaReference;
8
+ context?: MessageContext;
9
+ raw?: unknown;
10
+ }
File without changes
@@ -0,0 +1,25 @@
1
+ import type { WhatsAppError } from "./errors";
2
+ export type WhatsAppMessageStatusKind = "sent" | "delivered" | "read" | "failed" | "deleted" | "warning";
3
+ export interface ConversationRef {
4
+ id: string;
5
+ origin?: {
6
+ type: string;
7
+ };
8
+ expirationTimestamp?: string;
9
+ }
10
+ export interface PricingRef {
11
+ category: string;
12
+ pricingModel: string;
13
+ billable?: boolean;
14
+ }
15
+ export interface WhatsAppMessageStatus {
16
+ id: string;
17
+ recipientId: string;
18
+ status: WhatsAppMessageStatusKind;
19
+ timestamp: string;
20
+ conversation?: ConversationRef;
21
+ pricing?: PricingRef;
22
+ errors?: WhatsAppError[];
23
+ raw?: unknown;
24
+ }
25
+ export declare const WATS_TYPES_STATUSES_EXPORTS: readonly ["WhatsAppMessageStatus", "WhatsAppMessageStatusKind"];
@@ -0,0 +1,4 @@
1
+ export const WATS_TYPES_STATUSES_EXPORTS = [
2
+ "WhatsAppMessageStatus",
3
+ "WhatsAppMessageStatusKind"
4
+ ];
@@ -0,0 +1,90 @@
1
+ import type { WhatsAppError, WhatsAppErrorPayload } from "./errors";
2
+ import type { WhatsAppContact } from "./contacts";
3
+ import type { WhatsAppMessage } from "./messages/union";
4
+ import type { WhatsAppMessageStatus } from "./statuses";
5
+ export interface WhatsAppWebhookEnvelope {
6
+ object: string;
7
+ entry: WhatsAppWebhookEntry[];
8
+ }
9
+ export interface WhatsAppWebhookEntry {
10
+ id?: string;
11
+ time?: number;
12
+ changes: WhatsAppWebhookChange[];
13
+ }
14
+ export interface WhatsAppWebhookChange {
15
+ field: string;
16
+ value: WhatsAppWebhookValue;
17
+ event?: string;
18
+ }
19
+ /**
20
+ * The "messages" field carries inbound messages + statuses + contacts.
21
+ * This is the most common shape and the only one that exposes the
22
+ * message union.
23
+ */
24
+ export interface WhatsAppMessagesFieldValue {
25
+ messagingProduct: "whatsapp";
26
+ metadata: {
27
+ displayPhoneNumber: string;
28
+ phoneNumberId: string;
29
+ };
30
+ contacts?: WhatsAppContact[];
31
+ messages?: WhatsAppMessage[];
32
+ statuses?: WhatsAppMessageStatus[];
33
+ errors?: WhatsAppErrorPayload[];
34
+ raw?: unknown;
35
+ }
36
+ /**
37
+ * Template status lifecycle events (approved / rejected / etc). The
38
+ * WhatsApp wire uses uppercase event values; preserved here as the
39
+ * canonical closed enum.
40
+ */
41
+ export interface WhatsAppTemplateStatusUpdateValue {
42
+ messageTemplateId: string;
43
+ messageTemplateName: string;
44
+ messageTemplateLanguage: string;
45
+ event: "APPROVED" | "REJECTED" | "FLAGGED" | "PAUSED" | "DISABLED" | "PENDING_DELETION";
46
+ reason?: string;
47
+ raw?: unknown;
48
+ }
49
+ export interface WhatsAppAccountReviewUpdateValue {
50
+ decision: string;
51
+ raw?: unknown;
52
+ }
53
+ export interface WhatsAppUserMarketingPreferencesValue {
54
+ waId: string;
55
+ category: string;
56
+ preference: "opt_in" | "opt_out";
57
+ timestamp: string;
58
+ raw?: unknown;
59
+ }
60
+ export interface WhatsAppPhoneNumberChangeValue {
61
+ mobileDisplayName?: string;
62
+ oldPhoneNumber?: string;
63
+ newPhoneNumber: string;
64
+ raw?: unknown;
65
+ }
66
+ export interface WhatsAppIdentityChangeValue {
67
+ waId: string;
68
+ acknowledged: boolean;
69
+ createdTimestamp: string;
70
+ hash?: string;
71
+ raw?: unknown;
72
+ }
73
+ /**
74
+ * Generic catch-all variant for fields not yet promoted to a concrete
75
+ * shape. Callers that need to handle unknown field types reach into
76
+ * `raw` to inspect the original payload.
77
+ */
78
+ export interface WhatsAppRawWebhookValue {
79
+ raw: unknown;
80
+ errors?: WhatsAppError[];
81
+ }
82
+ /**
83
+ * Closed union of webhook-value shapes. Because WhatsApp frequently
84
+ * introduces new webhook fields without advance notice, this union
85
+ * includes `WhatsAppRawWebhookValue` as the catch-all — every variant
86
+ * also carries its own `raw` reference so forward compatibility holds
87
+ * without re-opening the index signature.
88
+ */
89
+ export type WhatsAppWebhookValue = WhatsAppMessagesFieldValue | WhatsAppTemplateStatusUpdateValue | WhatsAppAccountReviewUpdateValue | WhatsAppUserMarketingPreferencesValue | WhatsAppPhoneNumberChangeValue | WhatsAppIdentityChangeValue | WhatsAppRawWebhookValue;
90
+ export declare const WATS_TYPES_WEBHOOK_EXPORTS: readonly ["WhatsAppWebhookEnvelope", "WhatsAppWebhookEntry", "WhatsAppWebhookChange", "WhatsAppWebhookValue"];
@@ -0,0 +1,6 @@
1
+ export const WATS_TYPES_WEBHOOK_EXPORTS = [
2
+ "WhatsAppWebhookEnvelope",
3
+ "WhatsAppWebhookEntry",
4
+ "WhatsAppWebhookChange",
5
+ "WhatsAppWebhookValue"
6
+ ];
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@wats/types",
3
+ "version": "0.3.1",
4
+ "private": false,
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./config": {
15
+ "types": "./dist/config.d.ts",
16
+ "import": "./dist/config.js"
17
+ },
18
+ "./webhook": {
19
+ "types": "./dist/webhook.d.ts",
20
+ "import": "./dist/webhook.js"
21
+ },
22
+ "./entities": {
23
+ "types": "./dist/entities.d.ts",
24
+ "import": "./dist/entities.js"
25
+ },
26
+ "./messages": {
27
+ "types": "./dist/messages/index.d.ts",
28
+ "import": "./dist/messages/index.js"
29
+ },
30
+ "./statuses": {
31
+ "types": "./dist/statuses.d.ts",
32
+ "import": "./dist/statuses.js"
33
+ },
34
+ "./contacts": {
35
+ "types": "./dist/contacts.d.ts",
36
+ "import": "./dist/contacts.js"
37
+ },
38
+ "./errors": {
39
+ "types": "./dist/errors.d.ts",
40
+ "import": "./dist/errors.js"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md",
46
+ "LICENSE"
47
+ ],
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "keywords": [
52
+ "whatsapp",
53
+ "whatsapp-cloud-api",
54
+ "bun",
55
+ "typescript",
56
+ "wats"
57
+ ]
58
+ }