Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getAccessToken } from "./utils/auth-utils.js";
import { createFunctionsModule } from "./modules/functions.js";
import { createAgentsModule } from "./modules/agents.js";
import { createAppLogsModule } from "./modules/app-logs.js";
import { createUsersModule } from "./modules/users.js";
import { RoomsSocket, RoomsSocketConfig } from "./utils/socket-utils.js";

export type CreateClientOptions = {
Expand Down Expand Up @@ -119,6 +120,7 @@ export function createClient(config: {
token,
}),
appLogs: createAppLogsModule(axiosClient, appId),
users: createUsersModule(axiosClient, appId),
cleanup: () => {
socket.disconnect();
},
Expand Down
28 changes: 28 additions & 0 deletions src/modules/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { AxiosInstance } from "axios";

/**
* Creates the users module for the Base44 SDK
* @param {AxiosInstance} axios - Axios instance
* @param {string} appId - Application ID
* @returns {Object} Users module
*/
export function createUsersModule(axios: AxiosInstance, appId: string) {
return {
/**
* Invite a user to the application
* @param {string} user_email - User's email address
* @param {'user'|'admin'} role - User's role (user or admin)
* @returns {Promise<any>}
*/
async inviteUser(user_email: string, role: "user" | "admin"): Promise<any> {
if (role !== "user" && role !== "admin") {
throw new Error(
`Invalid role: "${role}". Role must be either "user" or "admin".`
);
}

const response = await axios.post(`/apps/${appId}/runtime/users/invite-user`, { user_email, role });
return response;
},
};
}