Skip to content

Commit dc29052

Browse files
committed
Add client API
1 parent bd5250d commit dc29052

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2025 New Vector Ltd.
3+
4+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5+
Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import type { Room } from "../models/Room";
9+
10+
/**
11+
* Modify account data stored on the homeserver.
12+
* @public
13+
*/
14+
export interface AccountDataApi {
15+
/**
16+
* Fetch account data stored from homeserver.
17+
*/
18+
get(eventType: string): unknown;
19+
/**
20+
* Sett account data on the homeserver.
21+
*/
22+
set(eventType: string, content: unknown): Promise<void>;
23+
/**
24+
* Delete account data from homeserver.
25+
*/
26+
delete(eventType: string): Promise<void>;
27+
}
28+
29+
/**
30+
* Access some limited functionality from the SDK.
31+
* @public
32+
*/
33+
export interface ClientApi {
34+
/**
35+
* Use this to modify account data on the homeserver.
36+
*/
37+
getAccountDataApi: () => AccountDataApi;
38+
39+
/**
40+
* Fetch room by id from SDK.
41+
* @param id - Id of the room to get
42+
* @returns Room object from SDK
43+
*/
44+
getRoom: (id: string) => Room | null;
45+
}

packages/element-web-module-api/src/api/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { AccountAuthApiExtension } from "./auth.ts";
1717
import { ProfileApiExtension } from "./profile.ts";
1818
import { ExtrasApi } from "./extras.ts";
1919
import { BuiltinsApi } from "./builtins.ts";
20+
import { ClientApi } from "./client.ts";
2021

2122
/**
2223
* Module interface for modules to implement.
@@ -123,6 +124,11 @@ export interface Api
123124
*/
124125
readonly extras: ExtrasApi;
125126

127+
/**
128+
* Access some very specific functionality from the client.
129+
*/
130+
readonly client: ClientApi;
131+
126132
/**
127133
* Create a ReactDOM root for rendering React components.
128134
* Exposed to allow modules to avoid needing to bundle their own ReactDOM.

packages/element-web-module-api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export type * from "./api/dialog";
2020
export type * from "./api/profile";
2121
export type * from "./api/navigation";
2222
export type * from "./api/builtins";
23+
export type * from "./api/client";
2324
export * from "./api/watchable";

0 commit comments

Comments
 (0)