coveo-search-ui-extensions
Version:
Small generic components to extend the functionality of Coveo's Search UI framework.
104 lines (103 loc) • 3.12 kB
TypeScript
import { Model, IQueryResult, AccessToken, ISearchEndpoint } from 'coveo-search-ui';
import { UserActionType } from '../rest/UserProfilingEndpoint';
export declare class UserActionSession {
timestamp: Date;
actions: UserAction[];
expanded: boolean;
constructor(timestamp: Date, actions: UserAction[], expanded?: boolean);
}
/**
* Represent an action that a user has made.
*/
export declare class UserAction {
type: UserActionType;
timestamp: Date;
raw: {
[key: string]: string;
query_expression?: string;
uri_hash?: string;
event_type?: string;
event_value?: string;
origin_level_1?: string;
cause?: string;
content_id_key?: string;
content_id_value?: string;
language?: string;
title?: string;
};
document?: IQueryResult;
query?: string;
constructor(type: UserActionType, timestamp: Date, raw: {
[key: string]: string;
query_expression?: string;
uri_hash?: string;
event_type?: string;
event_value?: string;
origin_level_1?: string;
cause?: string;
content_id_key?: string;
content_id_value?: string;
language?: string;
title?: string;
}, document?: IQueryResult, query?: string);
}
/**
* Initialization options of the **UserProfileModel** class.
*/
export interface IUserProfileModelOptions {
searchEndpoint: ISearchEndpoint;
/**
* Search token to access the organization.
*/
accessToken?: AccessToken;
/**
* Organization id of the organizatrion.
*/
organizationId: string;
/**
* Uri of the User Profiling Endpoint.
*/
restUri: string;
}
/**
* Model that store each user profile informations such as actions made by them,
*/
export declare class UserProfileModel extends Model {
options: IUserProfileModelOptions;
/**
* Identifier of the Search-UI component.
*/
static readonly ID = "UserProfileModel";
private static readonly ERROR_MESSAGE;
private static readonly MODEL_CONFIG;
private endpoint;
private getOrFetchCache;
/**
* Create a `UserProfileModel` and bound it to `element`.
* Also create a `UserProfilingEndpoint` that will be use to fetch actions made by a user.
*
* @param element An element on which the model will be bound on.
* @param options A set of options necessary for the component creation.
*/
constructor(element: HTMLElement, options: IUserProfileModelOptions);
/**
* Get all actions related to a user.
*
* @param userId The identifier of a user.
*/
getActions(userId: string): Promise<UserAction[]>;
/**
* Delete all actions related to a user from the model.
*
* @param userId The identifier of a user.
*/
deleteActions(userId: string): void;
private fetchActions;
private parseGetActionsResponse;
private fetchDocuments;
private buildUserActions;
private isClick;
private isClickOrView;
private isSearch;
private sendUserActionLoad;
}