Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(sdk): declare the four message-list wire fields every typed client missed

Yudhi Armyndharis1af0bd4da87f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 302698906..ea998a753 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- The typed SDKs' message-list records declare `chatName`, `author`, `mediaPath` and `mediaMimetype` (the wire carried all four; every typed client missed them), and the contract-shape gate now maps `MessageRecord` in all four SDKs, including the Python functional-TypedDict form.
- The dashboard's manual WebSocket retry re-registers the message handler on the fresh socket; the handler effect only re-ran on events changes, so a reconnect left the new socket silent while reporting connected.
- The Chats page honours the system dark theme: four dark-palette rules (outgoing bubble, document media, quote box, action menus) only matched an explicit data-theme and left the default 'system' theme rendering light popups inside a dark thread.
- The Logs page resets to page 1 on a new search and its empty state distinguishes "no matches on this page" (search filters the fetched page only) from "no logs yet".
diff --git a/scripts/check-contract-shapes.mjs b/scripts/check-contract-shapes.mjs
index 438652349..19ab8b2fe 100644
--- a/scripts/check-contract-shapes.mjs
+++ b/scripts/check-contract-shapes.mjs
@@ -60,6 +60,7 @@ const MAPPINGS = {
GroupParticipant: 'GroupParticipantDto',
GroupSummary: 'GroupSummaryDto',
MessageListResponse: 'MessageListResponseDto',
+ MessageRecord: 'MessageListItemDto',
MessageResponse: 'MessageResponseDto',
PairingCodeResponse: 'PairingCodeResponseDto',
ParticipantPresence: 'ParticipantPresenceDto',
@@ -101,11 +102,11 @@ const MAPPINGS = {
* these floors as pairs are added makes the shrink loud.
*/
const MINIMUM_MAPPED = {
- 'sdk/javascript/src/types.ts': 24,
+ 'sdk/javascript/src/types.ts': 25,
'dashboard/src/services/api.ts': 20,
- 'sdk/python/openwa/types.py': 22,
- 'sdk/go': 24,
- 'sdk/java': 24,
+ 'sdk/python/openwa/types.py': 23,
+ 'sdk/go': 25,
+ 'sdk/java': 25,
};
/** Known drift, deliberately not gated yet — each line is a to-adjudicate follow-up. */
@@ -132,6 +133,7 @@ const PYTHON_MAPPING = {
GroupParticipant: 'GroupParticipantDto',
GroupSummary: 'GroupSummaryDto',
MessageListResponse: 'MessageListResponseDto',
+ MessageRecord: 'MessageListItemDto',
MessageResponse: 'MessageResponseDto',
PairingCodeResponse: 'PairingCodeResponseDto',
ParticipantPresence: 'ParticipantPresenceDto',
@@ -159,6 +161,7 @@ const GO_MAPPING = {
GroupParticipant: 'GroupParticipantDto',
GroupSummary: 'GroupSummaryDto',
MessageListResponse: 'MessageListResponseDto',
+ MessageRecord: 'MessageListItemDto',
MessageResponse: 'MessageResponseDto',
PairingCodeResponse: 'PairingCodeResponseDto',
ParticipantPresence: 'ParticipantPresenceDto',
@@ -187,6 +190,7 @@ const JAVA_MAPPING = {
GroupParticipant: 'GroupParticipantDto',
GroupSummary: 'GroupSummaryDto',
MessageListResponse: 'MessageListResponseDto',
+ MessageRecord: 'MessageListItemDto',
MessageResponse: 'MessageResponseDto',
PairingCodeResponse: 'PairingCodeResponseDto',
ParticipantPresence: 'ParticipantPresenceDto',
@@ -439,6 +443,30 @@ export function parsePythonTypes(source) {
const dicts = {};
const parents = {};
const optionalAll = new Set();
+ // Functional TypedDict form (`Name = TypedDict("Name", { ... }, total=False)`): the only way to
+ // declare a field named `from` (a Python keyword), so MessageRecord uses it. Normalise each into
+ // the same shape the class-form parse below produces, so both forms map identically.
+ for (const m of source.matchAll(/(\w+) = TypedDict\(\s*"\w+",\s*\{([\s\S]*?)\}\s*,?\s*(total=False)?\s*,?\s*\)/g)) {
+ const [, name, body, totalFalse] = m;
+ // Same member shape parsePythonMembers produces, so the downstream token merge treats both
+ // forms identically. Optional[...] unwraps to the inner type and marks the member optional.
+ const members = {};
+ // The bracket-joining preprocessing above collapses the dict to ONE line, so fields are
+ // delimited by the next `"key":` (lookahead), not by newlines.
+ for (const f of body.matchAll(/"([^"]+)"\s*:\s*(".*?"|[^,]+?)(?=\s*,?\s*(?:\}|$)|\s*,\s*"[^"]+"\s*:)/g)) {
+ // Optional[...] stays verbatim: the comparator reads it as `T|null` (nullability), distinct
+ // from optionality. Only total=False / NotRequired mark a member optional.
+ let token = f[2].trim().replace(/,$/, '');
+ let optional = !!totalFalse;
+ const notReq = token.match(/^NotRequired\[([\s\S]+)\]$/);
+ if (notReq) {
+ token = notReq[1].trim();
+ optional = true;
+ }
+ members[f[1]] = { optional, token, __py: true };
+ }
+ dicts[name] = members;
+ }
const blocks = [...source.matchAll(/class (\w+)\(([^)]*)\):\n([\s\S]*?)(?=\nclass |\n[A-Z]\w+ = |\n*$)/g)];
// A subclass never re-mentions TypedDict — accept any class whose base chain reaches one
// (fixpoint: a class is rooted when a base is itself a rooted class).
diff --git a/sdk/go/types_message.go b/sdk/go/types_message.go
index ff79c120d..424b8f144 100644
--- a/sdk/go/types_message.go
+++ b/sdk/go/types_message.go
@@ -180,21 +180,36 @@ func (q *MessageHistoryQuery) values() url.Values {
return v
}
+// DeliveryStatus is a message's send/read lifecycle state.
+type DeliveryStatus string
+
+const (
+ DeliveryPending DeliveryStatus = "pending"
+ DeliverySent DeliveryStatus = "sent"
+ DeliveryDelivered DeliveryStatus = "delivered"
+ DeliveryRead DeliveryStatus = "read"
+ DeliveryFailed DeliveryStatus = "failed"
+)
+
// MessageRecord is a persisted message row.
type MessageRecord struct {
- ID string `json:"id"`
- SessionID string `json:"sessionId"`
- WaMessageID *string `json:"waMessageId,omitempty"`
- ChatID string `json:"chatId"`
- From string `json:"from"`
- To string `json:"to"`
- Body *string `json:"body,omitempty"`
- Type string `json:"type"`
- Direction string `json:"direction"`
- Timestamp *int64 `json:"timestamp,omitempty"`
- Metadata map[string]any `json:"metadata,omitempty"`
- Status string `json:"status"`
- CreatedAt string `json:"createdAt"`
+ ID string `json:"id"`
+ SessionID string `json:"sessionId"`
+ WaMessageID *string `json:"waMessageId,omitempty"`
+ ChatID string `json:"chatId"`
+ From string `json:"from"`
+ To string `json:"to"`
+ Body *string `json:"body,omitempty"`
+ Type string `json:"type"`
+ Direction MessageDirection `json:"direction"`
+ ChatName *string `json:"chatName,omitempty"`
+ Author *string `json:"author,omitempty"`
+ MediaPath *string `json:"mediaPath,omitempty"`
+ MediaMimetype *string `json:"mediaMimetype,omitempty"`
+ Timestamp *int64 `json:"timestamp,omitempty"`
+ Metadata map[string]any `json:"metadata,omitempty"`
+ Status DeliveryStatus `json:"status"`
+ CreatedAt string `json:"createdAt"`
}
// MessageListResponse is the paginated message list payload.
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/MessageRecord.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/MessageRecord.java
index e0646eb6e..b6e96357c 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/MessageRecord.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/MessageRecord.java
@@ -17,6 +17,14 @@ public record MessageRecord(
String body,
String type,
MessageDirection direction,
+ /** Chat display name, when the session resolves one for the chat. */
+ String chatName,
+ /** Author display name for an inbound group message. */
+ String author,
+ /** Storage key of the archived media copy, when chat-media archiving wrote one. */
+ String mediaPath,
+ /** Mimetype of the archived media; null whenever mediaPath is. */
+ String mediaMimetype,
/** Unix timestamp in seconds. */
Long timestamp,
Map<String, Object> metadata,
diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.ts
index 4e96d5f2b..7590e0471 100644
--- a/sdk/javascript/src/types.ts
+++ b/sdk/javascript/src/types.ts
@@ -471,6 +471,14 @@ export interface MessageRecord {
body?: string | null;
type: string;
direction: MessageDirection;
+ /** Chat display name, when the session resolves one for the chat. */
+ chatName?: string | null;
+ /** Author display name for an inbound group message. */
+ author?: string | null;
+ /** Storage key of the archived media copy, when chat-media archiving wrote one. */
+ mediaPath?: string | null;
+ /** Mimetype of the archived media; null whenever `mediaPath` is. */
+ mediaMimetype?: string | null;
/** Unix timestamp in seconds. */
timestamp?: number | null;
metadata?: Record<string, unknown> | null;
diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.py
index e9181d95c..375313c38 100644
--- a/sdk/python/openwa/types.py
+++ b/sdk/python/openwa/types.py
@@ -12,10 +12,16 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, Optional, TypedDict
-if TYPE_CHECKING:
- # Annotations are lazy (`from __future__ import annotations`), so NotRequired — which typing
- # only ships from 3.11 — is needed exclusively where type checkers look, never at runtime.
- # typing_extensions rides along with mypy; the runtime dependency set stays httpx-only.
+# NotRequired ships in typing from 3.11. Class-form annotations are lazy (`from __future__ import
+# annotations`) and only type checkers evaluate them — but the FUNCTIONAL TypedDicts below
+# (MessageRecord: `from` is a keyword and cannot appear in a class body) evaluate their field
+# values at import time, so a real runtime import is needed on 3.9/3.10. typing_extensions is a
+# version-marked runtime dependency for exactly those Pythons.
+import sys
+
+if sys.version_info >= (3, 11):
+ from typing import NotRequired
+else:
from typing_extensions import NotRequired
Jid = str
@@ -433,24 +439,30 @@ class MessageHistoryQuery(TypedDict, total=False):
# ``from`` is a Python keyword, so use the functional TypedDict form (and
# Optional[...] rather than ``X | None`` so the runtime values stay 3.9-safe).
+# Functional form (not a class) because `from` is a Python keyword and cannot appear in a class
+# body. Required-vs-optional mirrors the wire DTO exactly; nullable-and-optional fields use
+# NotRequired[Optional[...]] like the class-form TypedDicts in this file.
MessageRecord = TypedDict(
"MessageRecord",
{
"id": str,
"sessionId": str,
- "waMessageId": Optional[str],
+ "waMessageId": NotRequired[Optional[str]],
"chatId": Jid,
"from": Jid,
"to": Jid,
- "body": Optional[str],
+ "body": NotRequired[Optional[str]],
"type": str,
"direction": MessageDirection,
- "timestamp": Optional[int],
- "metadata": dict,
+ "chatName": NotRequired[Optional[str]],
+ "author": NotRequired[Optional[str]],
+ "mediaPath": NotRequired[Optional[str]],
+ "mediaMimetype": NotRequired[Optional[str]],
+ "timestamp": NotRequired[Optional[int]],
+ "metadata": NotRequired[Optional[dict]],
"status": DeliveryStatus,
"createdAt": str,
},
- total=False,
)
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index cc1b23926..350581e80 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -16,6 +16,7 @@ keywords = ["whatsapp", "api", "sdk", "openwa", "gateway"]
dependencies = [
"httpx>=0.25.0,<1.0",
+ "typing_extensions>=4.0; python_version < '3.11'",
]
[project.optional-dependencies]