Skip to content

Commit f328da5

Browse files
committed
feat: improving mangement apis
1 parent bf2f196 commit f328da5

10 files changed

Lines changed: 2204 additions & 196 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rapidaai/react",
3-
"version": "1.1.82",
3+
"version": "1.1.83",
44
"description": "An easy to use react client for building generative ai application using Rapida platform.",
55
"repository": {
66
"type": "git",

src/clients/organization.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ import {
3030
GetOrganizationResponse,
3131
CreateOrganizationResponse,
3232
UpdateOrganizationResponse,
33+
InviteUserToOrganizationRequest,
34+
InviteUserToOrganizationResponse,
35+
DeleteUserFromOrganizationRequest,
36+
DeleteUserFromOrganizationResponse,
3337
} from "./protos/web-api_pb";
3438
import {
3539
UserAuthInfo,
@@ -138,3 +142,43 @@ export function GetOrganization(
138142
cb
139143
);
140144
}
145+
146+
export function InviteUserToOrganization(
147+
connectionConfig: ConnectionConfig,
148+
req: InviteUserToOrganizationRequest,
149+
authHeader?: UserAuthInfo | ClientAuthInfo
150+
): Promise<InviteUserToOrganizationResponse> {
151+
return new Promise((resolve, reject) => {
152+
connectionConfig.organizationClient.inviteUserToOrganization(
153+
req,
154+
WithAuthContext(connectionConfig.auth || authHeader),
155+
(
156+
err: ServiceError | null,
157+
response: InviteUserToOrganizationResponse | null
158+
) => {
159+
if (err) reject(err);
160+
else resolve(response!);
161+
}
162+
);
163+
});
164+
}
165+
166+
export function DeleteUserFromOrganization(
167+
connectionConfig: ConnectionConfig,
168+
req: DeleteUserFromOrganizationRequest,
169+
authHeader?: UserAuthInfo | ClientAuthInfo
170+
): Promise<DeleteUserFromOrganizationResponse> {
171+
return new Promise((resolve, reject) => {
172+
connectionConfig.organizationClient.deleteUserFromOrganization(
173+
req,
174+
WithAuthContext(connectionConfig.auth || authHeader),
175+
(
176+
err: ServiceError | null,
177+
response: DeleteUserFromOrganizationResponse | null
178+
) => {
179+
if (err) reject(err);
180+
else resolve(response!);
181+
}
182+
);
183+
});
184+
}

src/clients/project.ts

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@
2525
*/
2626

2727
import {
28-
AddUsersToProjectRequest,
28+
AddUserToProjectsRequest,
29+
AddUserToProjectsResponse,
2930
CreateProjectRequest,
3031
CreateProjectResponse,
32+
DeleteUserFromProjectRequest,
33+
DeleteUserFromProjectResponse,
3134
GetAllProjectResponse,
3235
UpdateProjectRequest,
3336
UpdateProjectResponse,
3437
GetProjectResponse,
3538
GetProjectRequest,
3639
ArchiveProjectResponse,
3740
ArchiveProjectRequest,
38-
AddUsersToProjectResponse,
3941
GetAllProjectCredentialResponse,
4042
GetAllProjectCredentialRequest,
4143
CreateProjectCredentialRequest,
@@ -51,37 +53,44 @@ import {
5153
import { ServiceError } from "@/rapida/clients/types";
5254
import { ConnectionConfig } from "@/rapida/types/connection-config";
5355

54-
/**
55-
* Adds users to a project with specified roles.
56-
*
57-
* @param email - The email address of the user to add.
58-
* @param role - The role to assign to the user.
59-
* @param projectIds - List of project IDs to which the user will be added.
60-
* @param cb - Callback function to handle the response.
61-
* @param authHeader - Authentication headers for the request.
62-
* @returns UnaryResponse - The gRPC response object.
63-
*/
64-
export function AddUsersToProject(
56+
export function AddUserToProjects(
6557
connectionConfig: ConnectionConfig,
66-
email: string,
67-
role: string,
68-
projectIds: string[],
69-
cb: (
70-
err: ServiceError | null,
71-
response: AddUsersToProjectResponse | null
72-
) => void,
73-
authHeader: ClientAuthInfo | UserAuthInfo
74-
) {
75-
const requestObject = new AddUsersToProjectRequest();
76-
requestObject.setEmail(email);
77-
requestObject.setRole(role);
78-
requestObject.setProjectidsList(projectIds);
58+
req: AddUserToProjectsRequest,
59+
authHeader?: UserAuthInfo | ClientAuthInfo
60+
): Promise<AddUserToProjectsResponse> {
61+
return new Promise((resolve, reject) => {
62+
connectionConfig.projectClient.addUserToProjects(
63+
req,
64+
WithAuthContext(connectionConfig.auth || authHeader),
65+
(
66+
err: ServiceError | null,
67+
response: AddUserToProjectsResponse | null
68+
) => {
69+
if (err) reject(err);
70+
else resolve(response!);
71+
}
72+
);
73+
});
74+
}
7975

80-
return connectionConfig.projectClient.addUsersToProject(
81-
requestObject,
82-
WithAuthContext(authHeader),
83-
cb
84-
);
76+
export function DeleteUserFromProject(
77+
connectionConfig: ConnectionConfig,
78+
req: DeleteUserFromProjectRequest,
79+
authHeader?: UserAuthInfo | ClientAuthInfo
80+
): Promise<DeleteUserFromProjectResponse> {
81+
return new Promise((resolve, reject) => {
82+
connectionConfig.projectClient.deleteUserFromProject(
83+
req,
84+
WithAuthContext(connectionConfig.auth || authHeader),
85+
(
86+
err: ServiceError | null,
87+
response: DeleteUserFromProjectResponse | null
88+
) => {
89+
if (err) reject(err);
90+
else resolve(response!);
91+
}
92+
);
93+
});
8594
}
8695

8796
/**

src/clients/protos/artifacts

0 commit comments

Comments
 (0)