webapp/platform/client/CLAUDE.OPTIONAL.md
platform/client/ (@mattermost/client)src/client4.ts – REST endpoints, auth handling, retries.src/websocket.ts – WebSocket manager for real-time events.src/helpers.ts / errors.ts – shared logic for response parsing and error types.Singleton HTTP client for all Mattermost API requests. Methods return Promise<ClientResponse<T>>:
interface ClientResponse<T> {
response: Response; // Fetch Response object
headers: Headers; // Response headers
data: T; // Parsed response data
}
Client4 should only be called from Redux actions, never directly in components.Add new API methods to client4.ts. Keep signatures Promise-based.
getSomething = (id: string) => {
return this.doFetch<SomethingType>(
`${this.getSomethingRoute(id)}`,
{method: 'get'},
);
};
ClientError (see errors.ts) with enough context.forceLogoutIfNecessary logic upstream in calling actions; do not couple that here.websocket.ts provides real-time event handling, connection management, and automatic reconnection. Accessed via WebSocketClient wrapper in web app.
webapp/STYLE_GUIDE.md → Networking.