Add client API
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ import { AccountAuthApiExtension } from "./auth.ts";
|
|||||||
import { ProfileApiExtension } from "./profile.ts";
|
import { ProfileApiExtension } from "./profile.ts";
|
||||||
import { ExtrasApi } from "./extras.ts";
|
import { ExtrasApi } from "./extras.ts";
|
||||||
import { BuiltinsApi } from "./builtins.ts";
|
import { BuiltinsApi } from "./builtins.ts";
|
||||||
|
import { ClientApi } from "./client.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module interface for modules to implement.
|
* Module interface for modules to implement.
|
||||||
@@ -123,6 +124,11 @@ export interface Api
|
|||||||
*/
|
*/
|
||||||
readonly extras: ExtrasApi;
|
readonly extras: ExtrasApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access some very specific functionality from the client.
|
||||||
|
*/
|
||||||
|
readonly client: ClientApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a ReactDOM root for rendering React components.
|
* Create a ReactDOM root for rendering React components.
|
||||||
* Exposed to allow modules to avoid needing to bundle their own ReactDOM.
|
* Exposed to allow modules to avoid needing to bundle their own ReactDOM.
|
||||||
|
|||||||
@@ -20,4 +20,5 @@ export type * from "./api/dialog";
|
|||||||
export type * from "./api/profile";
|
export type * from "./api/profile";
|
||||||
export type * from "./api/navigation";
|
export type * from "./api/navigation";
|
||||||
export type * from "./api/builtins";
|
export type * from "./api/builtins";
|
||||||
|
export type * from "./api/client";
|
||||||
export * from "./api/watchable";
|
export * from "./api/watchable";
|
||||||
|
|||||||
Reference in New Issue
Block a user