Add client API

This commit is contained in:
R Midhun Suresh 2025-10-23 12:21:22 +05:30
parent 949e64c7b5
commit 00f9283262
3 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,45 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import type { Room } from "../models/Room";
/**
* Modify account data stored on the homeserver.
* @public
*/
export interface AccountDataApi {
/**
* Fetch account data stored from homeserver.
*/
get(eventType: string): unknown;
/**
* Sett account data on the homeserver.
*/
set(eventType: string, content: unknown): Promise<void>;
/**
* Delete account data from homeserver.
*/
delete(eventType: string): Promise<void>;
}
/**
* Access some limited functionality from the SDK.
* @public
*/
export interface ClientApi {
/**
* Use this to modify account data on the homeserver.
*/
getAccountDataApi: () => AccountDataApi;
/**
* Fetch room by id from SDK.
* @param id - Id of the room to get
* @returns Room object from SDK
*/
getRoom: (id: string) => Room | null;
}

View File

@ -17,6 +17,7 @@ import { AccountAuthApiExtension } from "./auth.ts";
import { ProfileApiExtension } from "./profile.ts";
import { ExtrasApi } from "./extras.ts";
import { BuiltinsApi } from "./builtins.ts";
import { ClientApi } from "./client.ts";
/**
* Module interface for modules to implement.
@ -123,6 +124,11 @@ export interface Api
*/
readonly extras: ExtrasApi;
/**
* Access some very specific functionality from the client.
*/
readonly client: ClientApi;
/**
* Create a ReactDOM root for rendering React components.
* Exposed to allow modules to avoid needing to bundle their own ReactDOM.

View File

@ -20,4 +20,5 @@ export type * from "./api/dialog";
export type * from "./api/profile";
export type * from "./api/navigation";
export type * from "./api/builtins";
export type * from "./api/client";
export * from "./api/watchable";