@experteam-mx/ngx-services
Version:
Angular common services for Experteam apps
163 lines (162 loc) • 7.39 kB
TypeScript
import { QueryParams } from './models/api.models';
import { AuthLoginIn, AuthLoginOut, AuthMeOut, AuthUserLoginIn, ChangeLanguageIn, GetUserOut, GetUsersOut, ModulesOut, PutUsersIn, PutUsersOut, RoleIn, RoleOut, RolesOut, RoleTypesOut, SessionIn, SessionOut } from './models/api-security.types';
import { HttpClient } from '@angular/common/http';
import { Environment } from '../ngx-services.models';
import { Observable } from 'rxjs';
import { CookieService } from 'ngx-cookie-service';
import * as i0 from "@angular/core";
export declare class ApiSecurityService {
private environments;
private cookie;
private http;
constructor(environments: Environment, cookie: CookieService, http: HttpClient);
/**
* Retrieves the API security URL from the environments configuration.
*
* @return {string} The API security URL.
*/
get url(): string;
/**
* Handles the login authentication request by sending the login data to the authentication endpoint.
*
* @param {AuthLoginIn} body The payload containing login credentials.
* @return {Observable<AuthLoginOut>} An observable emitting the authentication response data.
*/
postAuthLogin(body: AuthLoginIn): Observable<AuthLoginOut>;
/**
* Handles the user login process by sending user credentials to the authentication endpoint.
*
* @param {AuthUserLoginIn} body - The request payload containing user login details such as username and password.
* @return {Observable<AuthLoginOut>} An observable that emits the authenticated user's login data upon successful login.
*/
postAuthUserLogin(body: AuthUserLoginIn): Observable<AuthLoginOut>;
/**
* Logs out the current user by making a POST request to the logout endpoint.
*
* This method deletes all cookies after a successful logout.
*
* @return {Observable<{}>} An observable that emits the server's response to the logout request.
*/
postAuthLogout(): Observable<{}>;
/**
* Creates a new session for a specified model.
*
* @param {Object} params - The parameters for creating the session.
* @param {string} params.modelType - The type of the model.
* @param {string} params.modelId - The ID of the model.
* @param {string} [params.token] - Optional authorization token.
*
* @return {Observable<SessionOut>} An observable containing the created session details.
*/
postSession({ modelType, modelId, token, }: SessionIn): Observable<SessionOut>;
/**
* Fetches the authenticated user's information.
* Sends a GET request to the endpoint '/auth/me' to retrieve information
* about the currently authenticated user.
*
* @return {Observable<AuthMeOut>} An observable that emits the authenticated user's data.
*/
getAuthMe(): Observable<AuthMeOut>;
/**
* Fetches the authenticated user's details from the server.
*
* @param token The JWT token used for authorization.
* @return An Observable that emits the user's details encapsulated in a MeOut object.
*/
getOtherMe(token: string): Observable<AuthMeOut>;
/**
* Fetches a user by their unique ID.
*
* @param {number} id - The unique identifier of the user to be fetched.
* @return {Observable<GetUserOut>} An observable containing the user information.
*/
getUser(id: number): Observable<GetUserOut>;
/**
* Fetches a list of users from the server based on the specified query parameters.
*
* @param {QueryParams} params - The query parameters to filter the list of users.
* @return {Observable<GetUsersOut>} An observable that emits the list of users retrieved from the server.
*/
getUsers(params: QueryParams): Observable<GetUsersOut>;
/**
* Updates the information of a specified user on the server.
*
* @param {Object} params - The parameter object.
* @param {Object} params.user - The user object containing updated data.
* @param {string} params.user.id - The unique identifier of the user to be updated.
*
* @return {void} This method does not return a value.
*/
putUsers({ user }: PutUsersIn): Observable<PutUsersOut>;
/**
* Changes the language for the authenticated user.
*
* @param {Object} params - The input parameters for changing the language.
* @param {string} params.languageId - The ID of the new language to be set.
* @return {Observable<ApiSuccess<AuthMeOut>>} An observable that emits the result of the language change request.
*/
putChangeLanguage({ languageId }: ChangeLanguageIn): Observable<AuthMeOut>;
/**
* Retrieves a list of roles with their permissions.
*
* @param {QueryParams} params - The query parameters to filter the roles.
* @returns {Observable<RoleIn[]>} An observable that emits an array of role permissions.
*/
getRoles(params: QueryParams): Observable<RolesOut>;
/**
* Retrieves roles by the specified ID.
*
* @param id - The ID of the role to retrieve.
* @returns An Observable that emits the role data.
*/
getRole(id: number): Observable<RoleOut>;
/**
* Creates a new role with the specified permissions.
*
* @param {RoleIn} body - The permissions and details for the new role.
* @returns {Observable<RoleOut>} An observable containing the created role's permissions.
*/
postRole(body: RoleIn): Observable<RoleOut>;
/**
* Updates the permissions of a specific role.
*
* @param id - The unique identifier of the role to update.
* @param body - The new permissions to assign to the role.
* @returns An Observable that emits the updated module permissions.
*/
putRole(id: number, body: RoleIn): Observable<RoleOut>;
/**
* Deletes the permissions associated with a specific role.
*
* @param {number} id - The unique identifier of the role whose permissions are to be deleted.
* @returns {Observable<{}>} An observable that emits the result of the delete operation.
*/
deleteRole(id: number): Observable<{}>;
/**
* Retrieves the role types from the API.
*
* @param {QueryParams} params - The query parameters to be sent with the request.
* @returns {Observable<RoleTypesOut>} An observable containing the role types output.
*/
getRoleTypes(params: QueryParams): Observable<RoleTypesOut>;
/**
* Retrieves a list of modules and permissions
*
* @param queryParams - The query parameters to filter the modules.
* @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
*/
getModules(queryParams: QueryParams): Observable<ModulesOut>;
/**
* Retrieves a list of modules and permissions
*
* @param params.token - Custom token for authorization.
* @param params.queryParams - The query parameters to filter the modules.
* @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
*/
getModulesByToken(params: {
token: string;
queryParams: QueryParams;
}): Observable<ModulesOut>;
static ɵfac: i0.ɵɵFactoryDeclaration<ApiSecurityService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ApiSecurityService>;
}