@wats/types 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/dist/index.d.ts +3 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/interactive.d.ts +8 -1
- package/dist/messages/media.d.ts +4 -0
- package/dist/messages/unsupported.d.ts +7 -0
- package/dist/statuses.d.ts +12 -4
- package/dist/webhook.d.ts +44 -2
- package/dist/webhook.js +2 -1
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
# @wats/types
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared TypeScript contracts for WATS and WhatsApp Cloud API payloads: config, webhook envelopes, message unions, status payloads, contacts, entities, and errors.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @wats/types
|
|
9
|
+
npm i @wats/types
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import type { WhatsAppMessage, WhatsAppMessageStatus } from "@wats/types";
|
|
16
|
+
|
|
17
|
+
function describeMessage(message: WhatsAppMessage): string {
|
|
18
|
+
return message.type;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isRead(status: WhatsAppMessageStatus): boolean {
|
|
22
|
+
return status.status === "read";
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use this package when you need WATS domain types without the Graph client, webhook adapter, CLI, or service runtime. Runtime helpers live in the other `@wats/*` packages.
|
|
27
|
+
|
|
28
|
+
Docs: https://github.com/Switchbord/wats
|
|
29
|
+
License: MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from "./config.js";
|
|
2
2
|
export * from "./webhook.js";
|
|
3
3
|
export * from "./entities.js";
|
|
4
|
-
export type {
|
|
4
|
+
export type { WhatsAppMessageStatus, WhatsAppMessageStatusKind, PricingRef, ConversationRef, WhatsAppPricingCategory, WhatsAppPricingModel, WhatsAppMarketingMessageStatus } from "./statuses.js";
|
|
5
|
+
export type { TextMessage, ImageMessage, VideoMessage, AudioMessage, DocumentMessage, StickerMessage, LocationMessage, LocationPayload, ContactsMessage, ReactionMessage, ReactionPayload, OrderMessage, OrderPayload, OrderProductItem, SystemMessage, SystemNotification, UnsupportedMessage, UnsupportedMessageDetail, InteractiveMessage, InteractiveReply, InteractiveButtonReply, InteractiveListReply, InteractiveNfmReply, InteractiveProductReply, InteractiveProductListReply, InteractiveCtaUrlReply, InteractiveCallPermissionReply, ButtonMessage, ButtonPayload, WhatsAppMessageKind, MediaReference, DocumentReference, MessageContext } from "./messages/index.js";
|
|
5
6
|
export { WATS_TYPES_MESSAGES_EXPORTS } from "./messages/index.js";
|
|
6
7
|
export { WATS_TYPES_STATUSES_EXPORTS } from "./statuses.js";
|
|
7
8
|
export { WATS_TYPES_CONTACTS_EXPORTS } from "./contacts.js";
|
|
8
9
|
export { WATS_TYPES_ERRORS_EXPORTS } from "./errors.js";
|
|
9
|
-
export type { WhatsAppMessagesFieldValue, WhatsAppTemplateStatusUpdateValue, WhatsAppAccountReviewUpdateValue, WhatsAppUserMarketingPreferencesValue, WhatsAppPhoneNumberChangeValue, WhatsAppIdentityChangeValue, WhatsAppRawWebhookValue } from "./webhook.js";
|
|
10
|
+
export type { WhatsAppMessagesFieldValue, WhatsAppAccountUpdateValue, WhatsAppTemplateStatusUpdateValue, WhatsAppAccountReviewUpdateValue, WhatsAppUserMarketingPreferencesValue, WhatsAppPhoneNumberChangeValue, WhatsAppIdentityChangeValue, WhatsAppRawWebhookValue } from "./webhook.js";
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export type { ContactsMessage } from "./contacts.js";
|
|
|
9
9
|
export type { ReactionMessage, ReactionPayload } from "./reaction.js";
|
|
10
10
|
export type { OrderMessage, OrderPayload, OrderProductItem } from "./order.js";
|
|
11
11
|
export type { SystemMessage, SystemNotification } from "./system.js";
|
|
12
|
-
export type { UnsupportedMessage } from "./unsupported.js";
|
|
13
|
-
export type { InteractiveMessage, InteractiveReply, InteractiveButtonReply, InteractiveListReply, InteractiveNfmReply, InteractiveProductReply, InteractiveProductListReply, InteractiveCtaUrlReply } from "./interactive.js";
|
|
12
|
+
export type { UnsupportedMessage, UnsupportedMessageDetail } from "./unsupported.js";
|
|
13
|
+
export type { InteractiveMessage, InteractiveReply, InteractiveButtonReply, InteractiveListReply, InteractiveNfmReply, InteractiveProductReply, InteractiveProductListReply, InteractiveCtaUrlReply, InteractiveCallPermissionReply } from "./interactive.js";
|
|
14
14
|
export type { ButtonMessage, ButtonPayload } from "./button.js";
|
|
15
15
|
export type { WhatsAppMessage, WhatsAppMessageKind } from "./union.js";
|
|
16
16
|
export type { MediaReference, DocumentReference, MessageContext } from "./media.js";
|
|
@@ -45,7 +45,14 @@ export interface InteractiveCtaUrlReply {
|
|
|
45
45
|
url: string;
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
export
|
|
48
|
+
export interface InteractiveCallPermissionReply {
|
|
49
|
+
type: "call_permission_reply";
|
|
50
|
+
callPermissionReply: {
|
|
51
|
+
response: "accepted" | "rejected";
|
|
52
|
+
expirationTimestamp?: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export type InteractiveReply = InteractiveButtonReply | InteractiveListReply | InteractiveNfmReply | InteractiveProductReply | InteractiveProductListReply | InteractiveCtaUrlReply | InteractiveCallPermissionReply;
|
|
49
56
|
export interface InteractiveMessage {
|
|
50
57
|
type: "interactive";
|
|
51
58
|
id: string;
|
package/dist/messages/media.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ export interface MediaReference {
|
|
|
2
2
|
id: string;
|
|
3
3
|
mimeType: string;
|
|
4
4
|
sha256?: string;
|
|
5
|
+
/** WATS-89 / v24+ incoming media download URL when Meta includes it on webhook media objects. */
|
|
6
|
+
url?: string;
|
|
5
7
|
caption?: string;
|
|
6
8
|
filename?: string;
|
|
9
|
+
/** WATS-90 / Graph v24+ audio voice-message designation when present on audio media. */
|
|
10
|
+
voice?: boolean;
|
|
7
11
|
}
|
|
8
12
|
export interface DocumentReference extends MediaReference {
|
|
9
13
|
filename: string;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { WhatsAppError } from "../errors.js";
|
|
2
|
+
export interface UnsupportedMessageDetail {
|
|
3
|
+
type?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
raw?: unknown;
|
|
7
|
+
}
|
|
2
8
|
export interface UnsupportedMessage {
|
|
3
9
|
type: "unsupported";
|
|
4
10
|
id: string;
|
|
5
11
|
from: string;
|
|
6
12
|
timestamp: string;
|
|
13
|
+
unsupported?: UnsupportedMessageDetail;
|
|
7
14
|
errors?: WhatsAppError[];
|
|
8
15
|
raw?: unknown;
|
|
9
16
|
}
|
package/dist/statuses.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { WhatsAppError } from "./errors.js";
|
|
2
|
-
export type WhatsAppMessageStatusKind = "sent" | "delivered" | "read" | "failed" | "deleted" | "warning";
|
|
2
|
+
export type WhatsAppMessageStatusKind = "sent" | "delivered" | "read" | "played" | "failed" | "deleted" | "warning";
|
|
3
|
+
export type WhatsAppPricingCategory = "marketing" | "marketing_lite" | string;
|
|
4
|
+
export type WhatsAppPricingModel = "CBP" | "NBP" | "PMP" | string;
|
|
5
|
+
export type WhatsAppMarketingMessageStatus = "accepted" | "held_for_quality_assessment" | "paused" | string;
|
|
3
6
|
export interface ConversationRef {
|
|
4
7
|
id: string;
|
|
8
|
+
/** WATS-98 Marketing Messages status webhooks can report `marketing_lite`. */
|
|
5
9
|
origin?: {
|
|
6
|
-
type: string;
|
|
10
|
+
type: "marketing_lite" | string;
|
|
7
11
|
};
|
|
8
12
|
expirationTimestamp?: string;
|
|
9
13
|
}
|
|
10
14
|
export interface PricingRef {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
/** WATS-98 accepts current Meta pricing categories including `marketing_lite`. */
|
|
16
|
+
category: WhatsAppPricingCategory;
|
|
17
|
+
/** WATS-98 MM API status examples use pricing model `PMP`. */
|
|
18
|
+
pricingModel: WhatsAppPricingModel;
|
|
13
19
|
billable?: boolean;
|
|
14
20
|
}
|
|
15
21
|
export interface WhatsAppMessageStatus {
|
|
@@ -19,6 +25,8 @@ export interface WhatsAppMessageStatus {
|
|
|
19
25
|
timestamp: string;
|
|
20
26
|
conversation?: ConversationRef;
|
|
21
27
|
pricing?: PricingRef;
|
|
28
|
+
/** WATS-98 Graph wire `message_status`: `accepted`, `held_for_quality_assessment`, or `paused`. */
|
|
29
|
+
messageStatus?: WhatsAppMarketingMessageStatus;
|
|
22
30
|
errors?: WhatsAppError[];
|
|
23
31
|
raw?: unknown;
|
|
24
32
|
}
|
package/dist/webhook.d.ts
CHANGED
|
@@ -50,6 +50,48 @@ export interface WhatsAppAccountReviewUpdateValue {
|
|
|
50
50
|
decision: string;
|
|
51
51
|
raw?: unknown;
|
|
52
52
|
}
|
|
53
|
+
export interface WhatsAppAccountUpdateValue {
|
|
54
|
+
event?: string;
|
|
55
|
+
disconnectionInfo?: {
|
|
56
|
+
reason?: string;
|
|
57
|
+
partnerId?: string;
|
|
58
|
+
partnerName?: string;
|
|
59
|
+
raw?: unknown;
|
|
60
|
+
};
|
|
61
|
+
/** WATS-95 normalized `phone_number_quality_update` details. */
|
|
62
|
+
phoneNumberQuality?: {
|
|
63
|
+
displayPhoneNumber?: string;
|
|
64
|
+
oldLimit?: string;
|
|
65
|
+
currentLimit?: string;
|
|
66
|
+
maxDailyConversationsPerBusiness?: string;
|
|
67
|
+
raw?: unknown;
|
|
68
|
+
};
|
|
69
|
+
/** WATS-95 normalized `account_alerts.alert_info` details. */
|
|
70
|
+
alert?: {
|
|
71
|
+
entityType?: string;
|
|
72
|
+
entityId?: string;
|
|
73
|
+
severity?: string;
|
|
74
|
+
status?: string;
|
|
75
|
+
type?: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
raw?: unknown;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* WATS-98 Marketing Messages onboarding/account-update details. Current Meta
|
|
81
|
+
* docs prefer `marketing_messages_onboarding_status`; the older
|
|
82
|
+
* `marketing_messages_lite_api_status` remains readable but deprecated in docs.
|
|
83
|
+
* Synthetic `account_update` payloads may include events such as
|
|
84
|
+
* `MM_LITE_TERMS_SIGNED`.
|
|
85
|
+
*/
|
|
86
|
+
marketingMessages?: {
|
|
87
|
+
wabaId?: string;
|
|
88
|
+
ownerBusinessId?: string;
|
|
89
|
+
onboardingStatus?: string;
|
|
90
|
+
liteApiStatus?: string;
|
|
91
|
+
raw?: unknown;
|
|
92
|
+
};
|
|
93
|
+
raw?: unknown;
|
|
94
|
+
}
|
|
53
95
|
export interface WhatsAppUserMarketingPreferencesValue {
|
|
54
96
|
waId: string;
|
|
55
97
|
category: string;
|
|
@@ -86,5 +128,5 @@ export interface WhatsAppRawWebhookValue {
|
|
|
86
128
|
* also carries its own `raw` reference so forward compatibility holds
|
|
87
129
|
* without re-opening the index signature.
|
|
88
130
|
*/
|
|
89
|
-
export type WhatsAppWebhookValue = WhatsAppMessagesFieldValue | WhatsAppTemplateStatusUpdateValue | WhatsAppAccountReviewUpdateValue | WhatsAppUserMarketingPreferencesValue | WhatsAppPhoneNumberChangeValue | WhatsAppIdentityChangeValue | WhatsAppRawWebhookValue;
|
|
90
|
-
export declare const WATS_TYPES_WEBHOOK_EXPORTS: readonly ["WhatsAppWebhookEnvelope", "WhatsAppWebhookEntry", "WhatsAppWebhookChange", "WhatsAppWebhookValue"];
|
|
131
|
+
export type WhatsAppWebhookValue = WhatsAppMessagesFieldValue | WhatsAppAccountUpdateValue | WhatsAppTemplateStatusUpdateValue | WhatsAppAccountReviewUpdateValue | WhatsAppUserMarketingPreferencesValue | WhatsAppPhoneNumberChangeValue | WhatsAppIdentityChangeValue | WhatsAppRawWebhookValue;
|
|
132
|
+
export declare const WATS_TYPES_WEBHOOK_EXPORTS: readonly ["WhatsAppWebhookEnvelope", "WhatsAppWebhookEntry", "WhatsAppWebhookChange", "WhatsAppWebhookValue", "WhatsAppAccountUpdateValue"];
|
package/dist/webhook.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wats/types",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -48,6 +48,15 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/Switchbord/wats.git",
|
|
54
|
+
"directory": "packages/types"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/Switchbord/wats#readme",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/Switchbord/wats/issues"
|
|
59
|
+
},
|
|
51
60
|
"keywords": [
|
|
52
61
|
"whatsapp",
|
|
53
62
|
"whatsapp-cloud-api",
|