UNPKG

@twilio/flex-ui

Version:

Twilio Flex UI

270 lines (269 loc) 8.58 kB
import { AxiosError } from "axios"; import { InsightsPlayerMediaLink, INSIGHTS_PLAYER_MEDIA_SELECT } from "../components/Insights/Player/Player.definitions"; import { FINDINGS_SET, IFinding } from "../core/Insights/Findings/Finding.models"; import { ASSESSMENTS_ADD, ASSESSMENTS_REMOVE, ASSESSMENTS_SETTINGS_UPDATE, ASSESSMENTS_UPDATE, COMMENTS_ADD, COMMENTS_UPDATE, IAssessment, IAssessmentSettings, IComment, IQuestionnaire, QUESTIONNAIRES_UPDATE } from "../core/Insights/Questionnaires/Questionnaire.models"; import { AnalyticalDashboard, GoodDataProfileInfo, ProjectDashboard } from "../models/InsightsModel"; /** * Insights State * * @typedef InsightsState * @property {object} segmentsById - Dictionary of segments with the segmentId as the key * @property {number} [selectedMediaLink] - selected media link * @property {Array<IQuestionnaire>} questionnaires - array of questionnaires * @property {object} assessments - Dictionary of array of assessments with the segmentId as the key * @property {object} comments - comments * @property {IAssessmentSettings} assessmentSettings - assessmentSettings * @property {object} findingsBySegment - findings by segment * @property {string | undefined} segmentId - segmentId * @property {object} insightsProjectDashboards - insights project dashboards * @property {object} insightsDashboardCategory - insights dashboard category * @property {object} drillableItemsByDashboard - drillable items by dashboard * @property {Array<string>} drillableItemsAttributes - global drillable attributes * @property {object} profileInfo - profile info * @memberof AppState */ export interface InsightsState { readonly segmentsById: { [segmentId: string]: Segment; }; readonly selectedMediaLink?: number; readonly questionnaires: Array<IQuestionnaire>; readonly assessments: { [segmentId: string]: Array<IAssessment>; }; readonly comments: { [segmentId: string]: Array<IComment>; }; readonly assessmentSettings?: IAssessmentSettings; readonly findingsBySegment: { [segmentId: string]: IFinding[]; }; readonly segmentId: string | undefined; readonly insightsProjectDashboards: { [dashboardId: string]: ProjectDashboard; }; readonly insightsAnalyticalDashboards: { [dashboardId: string]: AnalyticalDashboard; }; readonly insightsDashboardCategory: string | undefined; readonly drillableItemsByDashboard: { [dashboardId: string]: Array<string>; }; readonly drillableItemsAttributes: string[]; readonly profileInfo?: GoodDataProfileInfo; } export type InsightsStateActionTypes = { type: typeof UPDATE_RECORDING_URL; payload: { recordingUrl: string; recordingUrlExpiresAt: number; segmentId: string; }; } | { type: typeof SEGMENT_FETCH_START; payload: string; } | { type: typeof SEGMENT_FETCH_SUCCESS; payload: { [id: string]: { id: string; data: SegmentData; }; }; } | { type: typeof SEGMENT_FETCH_FAILURE; payload: { id: string; error: AxiosError; }; } | { type: typeof INSIGHTS_PLAYER_MEDIA_SELECT; payload: number; } | { type: typeof QUESTIONNAIRES_UPDATE; payload: IQuestionnaire[]; } | { type: typeof ASSESSMENTS_UPDATE; payload: IAssessment[]; } | { type: typeof COMMENTS_UPDATE; payload: { agentId: string; data: IComment[]; }; } | { type: typeof COMMENTS_ADD; payload: IComment; } | { type: typeof ASSESSMENTS_ADD; payload: IAssessment; } | { type: typeof ASSESSMENTS_REMOVE; payload: IAssessment; } | { type: typeof ASSESSMENTS_SETTINGS_UPDATE; payload: IAssessmentSettings; } | { type: typeof FINDINGS_SET; payload: { segmentId: string; findings: IFinding[]; }; } | { type: typeof UPDATE_CURRENT_SEGMENT_ID; payload: string | undefined; } | { type: typeof UPDATE_INSIGHTS_PROJECT_DASHBOARDS; payload: ProjectDashboard[]; } | { type: typeof UPDATE_INSIGHTS_ANALYTICAL_DASHBOARDS; payload: AnalyticalDashboard[]; } | { type: typeof UPDATE_DASHBOARD_CATEGORY; payload: string | undefined; } | { type: typeof DELETE_DASHBOARD; payload: string; } | { type: typeof UPDATE_DASHBOARD_DRILLABLE_ITEMS; payload: { dashboardId: string; items: string[]; }; } | { type: typeof UPDATE_INSIGHTS_GLOBAL_DRILLABLE_ITEMS; payload: string[]; } | { type: typeof UPDATE_INSIGHTS_PROFILE_INFO; payload: GoodDataProfileInfo; }; export declare const SEGMENT_FETCH_START = "FLEX_ACTION_SEGMENT_FETCH_START"; export declare const SEGMENT_FETCH_SUCCESS = "FLEX_ACTION_SEGMENT_FETCH_SUCCESS"; export declare const SEGMENT_FETCH_FAILURE = "FLEX_ACTION_SEGMENT_FETCH_FAILURE"; export declare const UPDATE_CURRENT_SEGMENT_ID = "FLEX_ACTION_UPDATE_CURRENT_SEGMENT_ID"; export declare const UPDATE_RECORDING_URL = "FLEX_ACTION_UPDATE_RECORDING_URL"; export declare const UPDATE_INSIGHTS_PROJECT_DASHBOARDS = "FLEX_UPDATE_INSIGHTS_PROJECT_DASHBOARDS"; export declare const UPDATE_INSIGHTS_ANALYTICAL_DASHBOARDS = "FLEX_UPDATE_INSIGHTS_ANALYTICAL_DASHBOARDS"; export declare const UPDATE_DASHBOARD_CATEGORY = "FLEX_UPDATE_DASHBOARD_CATEGORY"; export declare const DELETE_DASHBOARD = "FLEX_DELETE_DASHBOARD"; export declare const UPDATE_DASHBOARD_DRILLABLE_ITEMS = "FLEX_UPDATE_DASHBOARD_DRILLABLE_ITEMS"; export declare const UPDATE_INSIGHTS_PROFILE_INFO = "UPDATE_INSIGHTS_PROFILE_INFO"; export declare const UPDATE_INSIGHTS_GLOBAL_DRILLABLE_ITEMS = "UPDATE_INSIGHTS_GLOBAL_DRILLABLE_ITEMS"; export interface Segment { id: string; hasFetched: boolean; error?: AxiosError; data?: SegmentData; } export type SegmentData = MediaResponse["metadata"] & { links: MediaResponse["_links"]; recordingUrl?: string; recordingUrlExpiresAt?: number; peaks?: number[][]; conversation: { conversation_id: string; segmentCount: number; segments: ConversationResponse["_embedded"]["segment"]; }; media?: InsightsPlayerMediaLink[] | null; allVoiceRecordings?: string[]; }; export type PublicSegment = { id: Segment["id"]; mediaLinks?: MediaResponse["_links"]["content"]; }; export type SegmentList = { id: string; duration: number; offset: number; agentName: string; hasFetched: boolean; }[]; export interface MediaResponse { metadata: { external_id: string; agent_id: string; queue: string; external_contact: string; timestamp: string; account_id: string; agent_phone?: string; agent_name: string; agent_team_name: string; agent_team_name_in_hierarchy: string; agent_link: null | string; customer_phone?: string; customer_name: string; customer_link: null | string; assessment_type: string[]; assessment_percentage: string[]; external_segment_link_id: string; segment_id: string; offset: null | number; media?: null | InsightsPlayerMediaLink[]; source: string; platform: string; speakers: string[]; }; _links: { self: { href: string; }; peaks: { href?: string; }; result: { href?: string; }; statistics: { href?: string; }; index: { href?: string; }; transcript: { href?: string; }; activity: { href?: string; }; media: { href: string; href_secure?: string; }; content: InsightsPlayerMediaLink[]; }; } export interface ConversationResponse { account_id: string; conversation_id: string; segment_count: number; _links: { self: { href: string; }; }; _embedded: { segment: [ { segment_id: string; order: number; offset: number | null; talk_time: number; timestamp: string; agent_name: string; _links: { self: { href: string; }; play: { href: string; }; }; } ]; }; } export interface PeaksResponse { peaks: number[][]; }