/** * @module UsersLists */ import { BehaviorSubject, Subscription } from "rxjs"; import { RBEvent } from "../../models/event.model"; import { UsersList, UsersListProfile, UsersListRB } from "../../models/usersList.model"; import { Contact } from '../../models/contact.model'; import { Service } from "../../services/service"; /** @internal */ export declare const USERSLISTS_SVC = "UsersListsService"; /** * @eventProperty * UsersLists service events send to other services * Can listen to it via `UsersListsService.subscribe()` API */ export declare enum UsersListsServiceEvents { /** * @eventProperty * This `RBEvent` is sent when a new users list has been created. * * **Event Data** * - **data**: The new created users list (as UsersList model) */ ON_USERS_LIST_CREATED = "ON_USERS_LIST_CREATED", /** * @eventProperty * This `RBEvent` is sent when the list information (name, description or favorite status) has been modified. * * **Event Data** * - **data**: The updated users list (as UsersList object) */ ON_USERS_LIST_PROFILE_UPDATED = "ON_USERS_LIST_PROFILE_UPDATED", /** * @eventProperty * This `RBEvent` is sent when a users list has been deleted. * * **Event Data** * - **data**: The id (as string) of the users list that has been deleted. */ ON_USERS_LIST_DELETED = "ON_USERS_LIST_DELETED", /** * @eventProperty * This `RBEvent` is sent when a user has been added to the list. * * **Event Data** * - **user**: The user (as User object) added to the list * - **list**: The users list (as UsersList object) to which the user has been added. */ ON_USER_ADDED_TO_LIST = "ON_USER_ADDED_TO_LIST", /** * @eventProperty * This `RBEvent` is sent when a user has been removed from the list. * * **Event Data** * - **userId**: The id (as string) of the user removed from the list. * - **list**: The users list (as UsersList object) to which the user has been added. */ ON_USER_REMOVED_FROM_LIST = "ON_USER_REMOVED_FROM_LIST" } export interface UsersListsService { /** * Subscribe to the users lists updates, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - (optional) array of event to listen * @returns Returns RxJS Subscription */ subscribe(callback: (event: RBEvent) => any, eventNames?: UsersListsServiceEvents | UsersListsServiceEvents[]): Subscription; /** * Get all users lists with all their properties. */ getUsersLists(): UsersList[]; /** * Get the data associated with the specified users list. * @param id - The id of the users list */ getUsersListById(id: string): UsersList; /** * Create a new list of users * Only the name of the users list is mandatory. * The other information (description and favorite status) are optional and can be set afterwards using the 'updateUsersListInfo' method. * A ON_USERS_LIST_CREATED event is sent afterwards at the completion of the operation to notify about the users list creation. * @param profile name - Name of the users list
* description - (optional) A description of the users list. If not specified, set by default to "".
* favorite - (optional) Flag indicating if the users list is marked as "favorite". If not specified, set by default to false. */ createUsersList(profile: UsersListProfile): Promise; /** * Delete a users list specified either by its reference or by its unique identifier. * A ON_USERS_LIST_DELETED event is sent afterwards at the completion of the operation to notify about the users list deletion. * @param listRef - Reference or identifier of the users list to delete */ deleteUsersList(listRef: string | UsersList): Promise; } /** * @internal */ export declare class UsersListsServiceRB extends Service implements UsersListsService { private portalURL; private xmppManagementHandler; private startInProgress; private authService; private xmppService; private contactService; private errorHelperService; private logger; private rxSubject; serviceReady: BehaviorSubject; private usersLists; /** * Returns the UsersListRB service singleton */ static getInstance(): UsersListsServiceRB; static build(): UsersListsServiceRB; private constructor(); start(): Promise; stop(): Promise; reconnect(): void; private attachHandlers; private removeHandlers; /** * Subscribe to the users lists updates, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - (optional) array of event to listen * @returns Returns RxJS Subscription */ subscribe(callback: (event: RBEvent) => any, eventNames?: UsersListsServiceEvents | UsersListsServiceEvents[]): Subscription; /** * UsersList service events send to other services via sendEvent() * Can listen to it via UsersListsServiceRB.subscribe() API * @param name - the name of the event * @param data - the data to be send (an object) */ private sendEvent; /** * Management of XMPP management message * @param stanza - The received stanza. */ private onUsersListMessageReceived; /** * Get all users lists from the server */ private getUsersListsFromServer; /** * Add a users list in cache ('usersLists' data) * @param listId - The id of the list to add in cache * @returns The data associated with the new users list */ addListToCache(listId: string): Promise; /** * Update a users list from cache ('usersLists' data) * The modification may come from the client who performed the action, or from another connected client (from the same connected user). * @param listId - The id of the list to remove from cache * @param name - Name of the users list * @param description - A description of the users list. * @param isFavorite - Flag indicating if the users list is marked as "favorite". * @returns The data associated with the updated users list */ private updateListFomCache; /** * Remove a users list from cache ('usersLists' data) * @param listId - The id of the list to remove from cache */ private removeListFomCache; /** * Add a user to the members of a users list in cache ('usersLists' data) * @param userId - The dbId of the user to add to users list * @param listId - The id of the users list to which the user must be added */ private addUserToCache; /** * Remove a user from the members of a users list in cache ('usersLists' data) * @param userId - The dbId of the user to remove from the list * @param listId - The id of the users list in which the user must be removed */ private removeUserFromCache; /** * Log main infos for all retrieved users lists: list + members names * @param lists - The users lists internal cache */ private logUsersLists; /** * Create a new list of users * Only the name of the users list is mandatory. * The other information (description and favorite status) are optional and can be set afterwards using the 'updateUsersListInfo' method. * A ON_USERS_LIST_CREATED event is sent afterwards at the completion of the operation to notify about the users list creation. * @param profile - Profile (general information) of the users list */ createUsersList(profile: UsersListProfile): Promise; /** * Delete a users list specified either by its reference or by its unique identifier. * A ON_USERS_LIST_DELETED event is sent afterwards at the completion of the operation to notify about the users list deletion. * @param listRef - Reference or identifier of the users list to delete */ deleteUsersList(listRef: string | UsersList): Promise; /** * Update the general information associated with the users list * Only the general information, i.e. the name, the description and the favorite status can be updated using this method. * Users are added to or removed from the list using methods 'addUserToList' and 'removeUserFromList' respectively. * A ON_USERS_LIST_PROFILE_UPDATED event is sent afterwards at the completion of the operation to notify about the users list update. * @param list - The users list with the general information to be updated */ updateUsersListInfo(list: UsersList): Promise; /** * Add a user in a users list. * A ON_USER_ADDED_TO_LIST event is sent afterwards at the completion of the operation to notify about adding the user to the list. * @param user - The user to add to users list * @param list - The users list to which the user is to be added */ addUserToList(user: Contact, list: UsersList): Promise; /** * Remove a user from a users list. * A ON_USER_REMOVED_FROM_LIST event is sent afterwards at the completion of the operation to notify about removing a user from the list. * @param user - Reference of the user to remove from the list * @param list - The users list from which the user is to be removed */ removeUserFromList(user: Contact, list: UsersList): Promise; /** * Get all users lists data with their data */ getUsersLists(): UsersList[]; /** * @public * Get the data associated with a specifid users list. * @param id - The unique identifier of the users list * @returns The data associated with a users list */ getUsersListById(id: string): UsersList; /** * @public * Get the data associated with a specifid users list. * @param criteria - The criteria to find from usersList.name * @returns The data associated with the found users list */ searchUsersListByName(criteria: string): UsersListRB[]; } //# sourceMappingURL=usersLists.service.d.ts.map