import { ITodoMsgContent, TodoCategory, TodoElem, TodoPersonalContent } from '../../models/todo.model'; import { Subscription } from 'rxjs/internal/Subscription'; import { RBEvent } from '../../models/event.model'; import { Service } from '../../services/service'; import { MessageID } from '../../models'; /** @internal */ export declare const TODO_SVC = "TodoService"; /** * TodoServiceRB events list * @eventProperty */ export declare enum TodoServiceEvents { /** * @eventProperty * This RBEvent is send when the list of todos is updated */ ON_TODOS_UPDATED = "ON_TODOS_UPDATED", /** * @eventProperty * This RBEvent is send when a todo is created */ ON_TODO_CREATED = "ON_TODO_CREATED", /** * @eventProperty * This RBEvent is send when a todo is updated */ ON_TODO_UPDATED = "ON_TODO_UPDATED", /** * @eventProperty * This RBEvent is send when a todo is deleted */ ON_TODO_DELETED = "ON_TODO_DELETED", /** * @eventProperty * This RBEvent is send when a todo message map is modified */ ON_TODO_MESSAGEMAP_MODIFIED = "ON_TODO_MESSAGEMAP_MODIFIED", /** * @eventProperty * This RBEvent is send when the TodoService status changes */ ON_TODO_SERVICE_STATUS = "ON_TODO_SERVICE_STATUS", /** * @eventProperty * This RBEvent is send when a todo category is created */ ON_TODO_CATEGORY_CREATED = "ON_TODO_CATEGORY_CREATED", /** * @eventProperty * This RBEvent is send when a todo category is updated */ ON_TODO_CATEGORY_UPDATED = "ON_TODO_CATEGORY_UPDATED", /** * @eventProperty * This RBEvent is send when a todo category is deleted */ ON_TODO_CATEGORY_DELETED = "ON_TODO_CATEGORY_DELETED" } export interface TodoService { /** * Indicates whether the Bubble Service has been started or not. * If this is not the case, no bubble can yet been retrieved. */ started: boolean; /** * Subscribe to todo updates; All events send to the callback are of type {@link RBEvent} * @param callback - The callback function that will be called when events are received */ subscribe(handler: (event: RBEvent) => any, eventNames?: TodoServiceEvents | TodoServiceEvents[]): Subscription; /** * Creates a todo category * @param name - name of the category to be created * @param color - color of the category to be created as hexadecimal RGB value (e.g. #FFFFFF) * @returns The {@link TodoCategory} created or throws an error if category with the same name already exists or something bad happened */ createCategory(name: string, color?: string): Promise; /** * Updates an existing todo category * @param category - {@link TodoCategory} to be updated * @param data - JSON object with optional properties name and color * @returns the updated {@link TodoCategory} */ updateCategory(category: TodoCategory, data: { name?: string; color?: string; }): Promise; /** * Deletes an existing todo category * @param category - {@link TodoCategory} to delete */ deleteCategory(category: TodoCategory): Promise; /** * Get an existing {@link TodoCategory} by it's unique identifier * @param categoryId - ID of {@link TodoCategory} to retrieve * @returns The {@link TodoCategory} if found, undefined otherwise */ getCategoryById(categoryId: string): TodoCategory | undefined; /** * Get an existing {@link TodoCategory} by it's unique name * @param categoryName - name of {@link TodoCategory} to retrieve * @returns The {@link TodoCategory} if found, undefined otherwise */ getCategoryByName(categoryName: string): TodoCategory | undefined; /** * Creates a todo * @param content - content of todo as {@link TodoPersonalContent} or {@link ITodoMsgContent} * @param category - the {@link TodoCategory} to which the todo will be added * @param position - the position of the todo in the category. Defaults to 0 (first) * @returns The {@link TodoElem} created */ createTodo(content: TodoPersonalContent | ITodoMsgContent, category: TodoCategory, position?: number): Promise; /** * Changes the category to which the todo belongs * @param todo - the {@link TodoElem} to be updated * @param newCategory - the new {@link TodoCategory} to which the todo will be assigned * @returns The {@link TodoElem} updated * */ updateTodoCategory(todo: TodoElem, newCategory: TodoCategory): Promise>; /** * Updates the content of a todo * @param todo - the {@link TodoElem} to be updated * @param content - content of todo as {@link TodoPersonalContent} or {@link ITodoMsgContent} * @returns The {@link TodoElem} updated * */ updateTodoContent(todo: TodoElem, content: TodoPersonalContent | ITodoMsgContent): Promise>; /** * Updates the position of a todo * @param todo - the {@link TodoElem} to be updated * @param position - new position of todo in category * @returns The {@link TodoElem} updated * */ updateTodoPosition(todo: TodoElem, position: number): Promise>; /** * Deletes a todo * @param todo - The {@link TodoElem} to be deleted */ deleteTodo(todo: TodoElem): Promise; /** * Get all todos of connected user * @returns The list of {@link TodoElem} belonging to user */ getAllTodos(): TodoElem[]; /** * Get all todos from a given category of connected user * @param category - the {@link TodoCategory} to retrieve * @returns The list of {@link TodoElem} of the given category belonging to user * */ getAllTodosByCategory(category: TodoCategory): TodoElem[]; /** * Get all categories of connected user * @returns The list of {@link TodoCategory} belonging to user * */ getAllCategories(): TodoCategory[]; /** * Whether user can create a new category * @returns true if can, false otherwise */ canCreateNewCategory(): boolean; } export declare class TodoServiceRB extends Service implements TodoService { private logger; private authService; private contactService; private xmppService; private errorHelperService; private profileService; private utilitiesService; private conversationService; private portalURL; private todos; private rxSubject; private listenerRef; private _started; get started(): boolean; set started(value: boolean); private categories; todoEnabled: boolean; private messageMap; private subscription; private todoMaxCategories; static getInstance(): TodoServiceRB; static build(): TodoServiceRB; private constructor(); getCategoryById(categoryId: string): TodoCategory | undefined; getCategoryByName(categoryName: string): TodoCategory | undefined; createCategory(name: string, color?: string): Promise; updateCategory(category: TodoCategory, data: { name?: string; color?: string; }): Promise; deleteCategory(category: TodoCategory): Promise; createTodo(content: TodoPersonalContent | ITodoMsgContent, category: TodoCategory, position?: number): Promise; updateTodoCategory(todo: TodoElem, newCategory: TodoCategory): Promise>; updateTodoContent(todo: TodoElem, content: TodoPersonalContent | ITodoMsgContent): Promise>; updateTodoPosition(todo: TodoElem, position: number): Promise>; deleteTodo(todo: TodoElem): Promise; getAllTodos(): TodoElem[]; getAllTodosByCategory(category: TodoCategory): TodoElem[]; getAllCategories(): TodoCategory[]; getCategoriesMap(): Map; canCreateNewCategory(): boolean; /** * @public * Allows to subscribe to instance's RX subject * @param handler - The handler function to be called when event is fired * @returns the subscription */ subscribe(handler: any): Subscription; /** * @internal * Allows to send an event (of type RBEvent) via the RX subject of the instance, and to be captured by subscribe * @param name - The name of the event * @param data - The data */ private sendEvent; start(): Promise; stop(): Promise; reconnect(attempt?: number): Promise; private attachHandlers; /** * @param id - id of element to fetch * @returns the element found or null */ getTodoById(id: string): TodoElem | null; /** * Adds a todo item to the internal list of todos * @param categoryId - the category identifier to which the todo belongs * @param todoId - Unique identifier of the todo * @param content - data of the todo item * @param position - of the item in the category */ private addTodo; /** * @internal * Updates a todo item to the internal list of todos * @param categoryId - the category identifier to which the todo belongs * @param todoId - Unique identifier of the todo * @param content - data of the todo item * @param position - of the item in the category */ private updateTodo; /** * * @internal * Updates position parameter of each item in array to reflect position in array * @param arr - array to modify */ private updateItemsPositionValue; /** * @internal * Deletes a todo item to the internal list of todos * @param id - Unique identifier of the todo */ private deleteTodoInternal; /** * @internal * Handler function for XMPP messages * @param stanza - received */ private onConfigMessage; private onTodoConfigMessage; private onCategoryConfigMessage; /** * @public * Handler function for XMPP messages * @returns the list of todo */ getTodos(): Map[]>; /** * @public * Retrieve the list of todos of the connected user and store it locally * @param category - optional category to specify which category to retrieve * @returns the list of todo retrieved * @fires TodoEvent#ON_TODOS_UPDATED with local list is updated */ retrieveUserTodoList(category?: string): Promise[]>>; /** * @public * retrieves a todo element from server * @param todoId - Identifier of the todo to retrieve * @returns resolves with the todo as created on server */ retrieveTodo(todoId: string): Promise>; /** * @public * updates a todo element on server * @param todoId - Unique identifier of the todo * @param content - data of the todo item * @param category - the {@link TodoCategory} to which the todo belongs * @param position - position of the item in the category * @returns resolves with the todo as updated on server */ updateTodoElem(todoId: string, content: any, category: TodoCategory, position?: number): Promise>; /** * @public * Allows user to retrieve it's ims by list of message Ids, peer and peer type This API can only be used by user himself (i.e. userId of logged in user = value of userId parameter in URL) If message cannot be retrieved response will return status not found * @param ims - array of ims where * type: Conversation type ("user", "room", "bot") * peer: jid with which message has been exchanged * msgId: xmpp message id of the message to retrieve * @returns resolves with the ims retrieved */ retrieveIms(ims: { type: string; peer: string; msgId: MessageID; around: number; }[]): Promise; /** * @public * Retrieve message data of all messages saved in todo list and save them in todo as displayText * @returns resolves with the ims retrieved */ retrieveAllMessageDataOfTodos(): Promise; private syncMessageMapToTodo; private extractTextFromXmpp; isMessageSaved(messageId: MessageID): boolean; getSavedMessageTodoColor(messageId: MessageID): string; addMapElement(key: MessageID, value?: string): void; updateMapElement(key: MessageID, value?: string): void; removeMapElement(key: MessageID): void; getNumberOfTodos(): number; /** * @public * Removes a message that was added to todo list * @param messageId - ID of message to delete from todo list * @returns resolves if success, throws an error otherwise */ removeMessageFromTodo(messageId: MessageID): Promise; private addCategoryToCache; private deleteCategoryFromCache; private updateCategoryInCache; } //# sourceMappingURL=todo.service.d.ts.map