@myinterview/widget-react 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,12 +17,19 @@ export declare const enum CandidateSessionError {
17
17
  JOB_INACTIVE = "JOB_INACTIVE",
18
18
  SUBSCRIPTION_PAUSED = "SUBSCRIPTION_PAUSED",
19
19
  SUBSCRIPTION_CANCELLED = "SUBSCRIPTION_CANCELLED",
20
- INTERVIEW_ALREADY_COMPLETED = "INTERVIEW_ALREADY_COMPLETED"
20
+ INTERVIEW_ALREADY_COMPLETED = "INTERVIEW_ALREADY_COMPLETED",
21
+ MEDIA_RECORDER_ERROR = "MEDIA_RECORDER_ERROR"
21
22
  }
22
23
  export declare const enum CandidateSessionWarnings {
23
24
  LOW_LIGHT = "LOW_LIGHT",
24
25
  LOW_VOLUME = "LOW_VOLUME",
25
- SLOW_CONNECTION = "SLOW_CONNECTION"
26
+ SLOW_CONNECTION = "SLOW_CONNECTION",
27
+ NO_INTERNET = "NO_INTERNET",
28
+ NotAllowedError = "NotAllowedError",
29
+ NotFoundError = "NotFoundError",
30
+ NotReadableError = "NotReadableError",
31
+ OverconstrainedError = "OverconstrainedError",
32
+ SecurityError = "SecurityError"
26
33
  }
27
34
  export declare type CandidateSessionSourceType = 'direct' | 'email' | 'sms' | 'email_reminder' | 'sms_reminder';
28
35
  export declare const enum CandidateSessionSourceMap {
@@ -39,6 +46,7 @@ export interface ICandidateSession {
39
46
  warnings?: (keyof typeof CandidateSessionWarnings)[];
40
47
  reload_count: number;
41
48
  files_uploaded_count: number;
49
+ widget_version: string;
42
50
  company_id: string;
43
51
  apiKey: string;
44
52
  job_id?: string;
@@ -58,13 +66,10 @@ export interface ICandidateSession {
58
66
  widget_shown?: Date;
59
67
  widget_practiced?: Date;
60
68
  widget_camera_setup?: Date;
61
- widget_camera_error?: Date;
62
69
  widget_microphone_setup?: Date;
63
- widget_microphone_error?: Date;
64
70
  widget_slow_internet_setup?: Date;
65
71
  widget_high_internet_setup?: Date;
66
72
  widget_medium_internet_setup?: Date;
67
- widget_no_internet_setup?: Date;
68
73
  widget_start_click_setup?: Date;
69
74
  widget_change_camera_setup?: Date;
70
75
  widget_change_mic_setup?: Date;
@@ -1,6 +1,7 @@
1
+ import { CSSProperties } from 'react';
1
2
  import { ICandidate } from './candidateInterface';
2
3
  import { ICompany } from './companyInterface';
3
- import { IJob } from './jobInterface';
4
+ import { IJob, IQuestion } from './jobInterface';
4
5
  import { IVideo } from './videoInterface';
5
6
  export declare type IMessageType = 'completed' | 'deadline' | 'applied' | 'inactiveJob';
6
7
  export interface IOnCompleteCallback {
@@ -10,24 +11,36 @@ export interface IOnCompleteCallback {
10
11
  export interface IOnError {
11
12
  messageType: IMessageType;
12
13
  }
13
- export interface IConfig {
14
+ interface IConfig {
15
+ auth: string;
16
+ onWidgetClicked?: () => void;
17
+ onCompleteCallback?: (data: IOnCompleteCallback) => void;
18
+ onError?: (data: IOnError) => void;
19
+ openAnimation?: boolean;
20
+ debug?: boolean;
21
+ practiceQuestions?: IQuestion[];
22
+ overlay?: string;
23
+ introVideo?: string;
24
+ introVideoTitle?: string;
25
+ }
26
+ export interface IWidgetConfig {
14
27
  video?: IVideo;
15
28
  candidate: ICandidate;
16
29
  job?: IJob;
17
30
  company?: ICompany;
18
- config: {
19
- auth: string;
20
- onCompleteCallback?: (data: IOnCompleteCallback) => void;
21
- onError?: (data: IOnError) => void;
22
- };
31
+ config: IConfig;
32
+ disabled?: boolean;
33
+ buttonText?: string;
34
+ buttonStyle?: CSSProperties;
23
35
  }
24
- export interface IConfigResponse {
36
+ export interface IWidgetConfigResponse {
25
37
  video: IVideo;
26
38
  candidate: ICandidate;
27
39
  job: IJob;
28
40
  }
29
- export interface IConfigRequest {
41
+ export interface IWidgetConfigRequest {
30
42
  video?: IVideo;
31
43
  candidate?: ICandidate;
32
44
  job?: IJob;
33
45
  }
46
+ export {};
@@ -9,7 +9,6 @@ export interface IQuestion {
9
9
  }
10
10
  export interface IJob {
11
11
  language?: string;
12
- overlay?: string;
13
12
  transcriptLanguage?: string;
14
13
  title?: string;
15
14
  company?: string;
@@ -23,6 +23,7 @@ export interface IVideoFile {
23
23
  videoLength?: number;
24
24
  uploadUrl?: string;
25
25
  question?: string;
26
+ selectedTake?: number;
26
27
  }
27
28
  export interface IVideo {
28
29
  video_id: string;
@@ -1,6 +1,6 @@
1
1
  import { RefObject } from 'react';
2
2
  import { ActorRef, BaseActionObject, DoneInvokeEvent, Event, EventData, ResolveTypegenMeta, SCXML, ServiceMap, SingleOrArray, State, TypegenDisabled } from 'xstate';
3
- import { IConfig } from './configInterface';
3
+ import { IWidgetConfig } from './configInterface';
4
4
  import { CAMERA_STATES_MESSAGES, INTERNET_STATES_MESSAGES, MICROPHONE_STATES_MESSAGES } from '../utils/messages.utils';
5
5
  import { TAKE_TYPES } from './storageInterface';
6
6
  import { IQuestion } from './jobInterface';
@@ -8,9 +8,15 @@ import { IVideoError } from '../utils/errors.utils';
8
8
  declare type IUploaderRef = {
9
9
  [uploaderRef: string]: ActorRef<DoneInvokeEvent<any>>;
10
10
  };
11
+ export declare const VIDEO_ERROR_MESSAGES: {
12
+ RETRY: "RETRY";
13
+ REDIRECT: "REDIRECT";
14
+ NO_ERROR: "";
15
+ };
11
16
  export declare type ICameraStateKey = keyof typeof CAMERA_STATES_MESSAGES;
12
17
  export declare type IMicrophoneStateKey = keyof typeof MICROPHONE_STATES_MESSAGES;
13
18
  export declare type IInternetStateKey = keyof typeof INTERNET_STATES_MESSAGES;
19
+ export declare type IVideoCorruptedMessagesKey = keyof typeof VIDEO_ERROR_MESSAGES;
14
20
  export declare const CAMERA_STATES: {
15
21
  [K in ICameraStateKey]: K;
16
22
  };
@@ -20,6 +26,9 @@ export declare const MICROPHONE_STATES: {
20
26
  export declare const INTERNET_STATES: {
21
27
  [K in IInternetStateKey]: K;
22
28
  };
29
+ export declare const VIDEO_CORRUPTED_STATES: {
30
+ [K in IVideoCorruptedMessagesKey]: K;
31
+ };
23
32
  export interface IChecksMetaObj {
24
33
  key: 'camera' | 'microphone' | 'internet';
25
34
  state: ICameraStateKey | IMicrophoneStateKey | IInternetStateKey;
@@ -37,7 +46,7 @@ interface IChecksMessage {
37
46
  }
38
47
  export interface InitialState {
39
48
  speedTestResult: number;
40
- config: IConfig;
49
+ widgetConfig: IWidgetConfig;
41
50
  questions: IQuestion[];
42
51
  isConnected: boolean;
43
52
  videoRef: RefObject<HTMLVideoElement>;
@@ -60,6 +69,8 @@ export interface InitialState {
60
69
  [questionNumber: string]: number;
61
70
  };
62
71
  error: IVideoError | null;
72
+ failedRecordingAttempts: number;
73
+ failedRecordingMessage: IVideoCorruptedMessagesKey;
63
74
  }
64
75
  export interface IWidgetMachineProps {
65
76
  widgetMachine: State<InitialState, DoneInvokeEvent<any>, any, {
@@ -70,6 +81,7 @@ export interface IWidgetMachineProps {
70
81
  }
71
82
  export declare const enum STATES {
72
83
  INIT = "init",
84
+ WELCOME = "welcome",
73
85
  SETUP = "setup",
74
86
  SETUP__INIT_STORAGE = "initStorage",
75
87
  SETUP__INIT_RECORDER = "initRecorder",
@@ -103,6 +115,7 @@ export declare const enum STATES {
103
115
  }
104
116
  export declare const enum ACTIONS {
105
117
  CONSOLE_LOG = "consoleLog",
118
+ CONSOLE_DEBUG = "consoleDebug",
106
119
  SET_CONNECTION = "setConnection",
107
120
  SET_CONFIG = "getConfig",
108
121
  SET_NEXT_QUESTION = "setNextQuestion",
@@ -128,6 +141,7 @@ export declare const enum ACTIONS {
128
141
  UPDATE_RETAKES_NUMBER = "updateRetakesNumber",
129
142
  UPDATE_AXION_AUTH = "updateAxiosAuth",
130
143
  RECORDER_RE_INIT = "recorderReInit",
144
+ RECORDER_RE_INIT_AUTO_START = "recorderReInitAutoStart",
131
145
  UPDATE_RECORDER_PARAMS = "updateRecorderParams",
132
146
  UPDATE_TOTAL_UPLOADED = "updateTotalUploaded",
133
147
  SET_VIDEO_ERROR = "setVideoError",
@@ -137,7 +151,10 @@ export declare const enum ACTIONS {
137
151
  SESSION_EVENT = "sessionEvent",
138
152
  REVOKE_MEMORY = "revokeMemory",
139
153
  UPDATE_VIDEO_OBJECT = "updateVideoObject",
140
- UPDATE_VIDEO_PART = "updateVideoPart"
154
+ UPDATE_VIDEO_PART = "updateVideoPart",
155
+ INCREASE_FAILED_RECORDING_ATTEMPTS = "increaseFailedRecordingAttempts",
156
+ RESET_FAILED_RECORDING_ATTEMPTS = "resetFailedRecordingAttempts",
157
+ CLEAR_VIDEO_ERROR = "clearVideoError"
141
158
  }
142
159
  export declare const enum EVENTS {
143
160
  SPAWN_UPLOADER = "SPAWN_UPLOADER",
@@ -173,12 +190,14 @@ export declare const enum GUARDS {
173
190
  IS_PRACTICE_MODE = "isPracticeMod",
174
191
  IS_NOT_LAST_TAKE = "isNotLastTake",
175
192
  IS_LAST_INTERVIEW_QUESTION = "isLastInterviewQuestion",
176
- IS_UPLOAD_FINISHED = "isUploadFinished",
177
193
  CAN_RETEST_SPEED_CONNECTION = "canRetestSpeedConnection",
178
194
  IS_CONNECTED = "isConnected",
179
195
  IS_DISCONNECTED = "isDisconnected",
180
196
  CAN_START_INTERVIEW = "canStartInterview",
181
- ARE_ALL_QUESTIONS_UPLOADED = "areAllQuestionsUploaded"
197
+ ARE_ALL_QUESTIONS_UPLOADED = "areAllQuestionsUploaded",
198
+ SHOULD_SHOW_WELCOME = "shouldShowWelcome",
199
+ IS_NO_SOUND_ERROR = "isNoSoundError",
200
+ IS_VIDEO_CORRUPTED = "isVideoCorrupted"
182
201
  }
183
202
  export declare const enum TAGS {
184
203
  SETUP = "setup",
@@ -34,7 +34,7 @@ declare type KeysMatching<T, V> = {
34
34
  * A cute shortcut for updating a date event in the session
35
35
  * just give it the key of the date event, and it will update it
36
36
  * @param eventType
37
- */
37
+ */
38
38
  export declare function registerDateEvent(eventType: KeysMatching<ICandidateSession, Date>): Promise<ICandidateSession | undefined>;
39
39
  /**
40
40
  * Another cute shortcut for updating a number state of a session
@@ -43,4 +43,15 @@ export declare function registerDateEvent(eventType: KeysMatching<ICandidateSess
43
43
  * @param data
44
44
  */
45
45
  export declare function registerCountEvent(eventType: KeysMatching<ICandidateSession, number>, data?: number): Promise<ICandidateSession | undefined>;
46
+ /**
47
+ * Another cute shortcut for updating a number state of a session
48
+ * if no data is provided, it will just increment the number
49
+ * @param warning
50
+ */
51
+ export declare function registerWarning(warning: string): Promise<ICandidateSession | undefined>;
52
+ export declare const triggerEvent: {
53
+ warning: typeof registerWarning;
54
+ date: typeof registerDateEvent;
55
+ number: typeof registerCountEvent;
56
+ };
46
57
  export {};
@@ -1,7 +1,7 @@
1
- import { IConfigRequest, IConfigResponse } from '../interfaces/configInterface';
1
+ import { IWidgetConfigRequest, IWidgetConfigResponse } from '../interfaces/configInterface';
2
2
  import { IVideo, IVideoFile } from '../interfaces/videoInterface';
3
- export declare const createVideo: (config: IConfigRequest) => Promise<IConfigResponse>;
4
- export declare const getVideo: (videoId: string) => Promise<IConfigResponse>;
5
- export declare const updateVideo: ({ video_id, completed, uploaded, bandwidth }: IVideo) => Promise<IConfigResponse>;
6
- export declare const updateVideoFile: (videoId: string, videoFile: IVideoFile) => Promise<IConfigResponse>;
7
- export declare const getUploadUrl: (videoId: string, fileName: string, typeExtension: string) => Promise<IConfigResponse>;
3
+ export declare const createVideo: (widgetConfig: IWidgetConfigRequest) => Promise<IWidgetConfigResponse>;
4
+ export declare const getVideo: (videoId: string) => Promise<IWidgetConfigResponse>;
5
+ export declare const updateVideo: ({ video_id, completed, uploaded, bandwidth }: IVideo) => Promise<IWidgetConfigResponse>;
6
+ export declare const updateVideoFile: (videoId: string, videoFile: IVideoFile) => Promise<IWidgetConfigResponse>;
7
+ export declare const getUploadUrl: (videoId: string, fileName: string, typeExtension: string) => Promise<IWidgetConfigResponse>;
@@ -0,0 +1,7 @@
1
+ interface IGetToken {
2
+ type: string;
3
+ value: string;
4
+ secretKey: string;
5
+ }
6
+ export declare const getToken: ({ type, value, secretKey }: IGetToken) => string;
7
+ export {};
@@ -5,5 +5,6 @@ export declare const SPEED_TEST_FILE_SIZE = 5;
5
5
  export declare const FAST_UPLOAD_SPEED = 0.35;
6
6
  export declare const SLOW_UPLOAD_SPEED = 0.1;
7
7
  export declare const SPEED_TEST_TIMEOUT = 5000;
8
- export declare const MICROPHONE_NO_SOUND_ERROR_CODE = 777;
9
8
  export declare const VIDEO_INACTIVE_TIMEOUT = 2000;
9
+ export declare const MICROPHONE_NO_SOUND_ERROR_CODE = 777;
10
+ export declare const MAX_FAILED_RECORDING_ATTEMPTS = 2;
@@ -0,0 +1,19 @@
1
+ export declare const enum DEBUG {
2
+ FETCHING_INTERVIEW = "Fetching interview data",
3
+ INTERVIEW_DATA_RECEIVED = "Interview data received",
4
+ FETCHING_INTERVIEW_ERROR = "Failed to fetch interview",
5
+ WELCOME_PAGE_STAGE = "In welcome page stage",
6
+ SETUP_STAGE = "In setup stage",
7
+ MEIDA_DEVICE_SUCCESS = "Media device available",
8
+ MEDIA_DEVICE_ERROR = "Media device error",
9
+ NO_SOUND_DETECTED = "No sound detected",
10
+ DEVICE_CHANGED = "Device changed",
11
+ SPEED_TEST_DONE = "Speed test result received",
12
+ PRACTICE_STARTED = "Practice started",
13
+ INTERVIEW_STARTED = "Interview started",
14
+ RETAKE_CLICKED = "Retake clicked",
15
+ QUESTION_SUBMITTED = "Qeustion submitted",
16
+ UPLOADING_STATE = "In uploading state",
17
+ UPLOAD_COMPLETED = "Upload completed",
18
+ INTERVIEW_SUBMITTED = "Interview submitted successfully"
19
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { CSSProperties } from 'react';
2
2
 
3
3
  interface ICandidate {
4
4
  candidate_id?: string;
@@ -26,7 +26,6 @@ interface IQuestion {
26
26
  }
27
27
  interface IJob {
28
28
  language?: string;
29
- overlay?: string;
30
29
  transcriptLanguage?: string;
31
30
  title?: string;
32
31
  company?: string;
@@ -63,6 +62,7 @@ interface IVideoFile {
63
62
  videoLength?: number;
64
63
  uploadUrl?: string;
65
64
  question?: string;
65
+ selectedTake?: number;
66
66
  }
67
67
  interface IVideo {
68
68
  video_id: string;
@@ -97,21 +97,35 @@ interface IOnError {
97
97
  messageType: IMessageType;
98
98
  }
99
99
  interface IConfig {
100
+ auth: string;
101
+ onWidgetClicked?: () => void;
102
+ onCompleteCallback?: (data: IOnCompleteCallback) => void;
103
+ onError?: (data: IOnError) => void;
104
+ openAnimation?: boolean;
105
+ debug?: boolean;
106
+ practiceQuestions?: IQuestion[];
107
+ overlay?: string;
108
+ introVideo?: string;
109
+ introVideoTitle?: string;
110
+ }
111
+ interface IWidgetConfig {
100
112
  video?: IVideo;
101
113
  candidate: ICandidate;
102
114
  job?: IJob;
103
115
  company?: ICompany;
104
- config: {
105
- auth: string;
106
- onCompleteCallback?: (data: IOnCompleteCallback) => void;
107
- onError?: (data: IOnError) => void;
108
- };
109
- }
110
-
111
- interface IProps extends IConfig {
116
+ config: IConfig;
112
117
  disabled?: boolean;
113
118
  buttonText?: string;
119
+ buttonStyle?: CSSProperties;
120
+ }
121
+
122
+ interface IGetToken {
123
+ type: string;
124
+ value: string;
125
+ secretKey: string;
114
126
  }
115
- declare const Widget: React.FC<IProps>;
127
+ declare const getToken: ({ type, value, secretKey }: IGetToken) => string;
128
+
129
+ declare const Widget: React.FC<IWidgetConfig>;
116
130
 
117
- export { Widget };
131
+ export { IWidgetConfig, Widget, getToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myinterview/widget-react",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "myInterview widget v3",
5
5
  "module": "dist/esm/index.js",
6
6
  "files": [
@@ -30,8 +30,8 @@
30
30
  "start-prod": "REACT_APP_ENV=prod HTTPS=true react-scripts start",
31
31
  "start-staging": "REACT_APP_ENV=staging HTTPS=true react-scripts start",
32
32
  "build": "react-scripts build",
33
- "rollup": "REACT_APP_ENV=prod rollup -c",
34
- "rollup-staging": "REACT_APP_ENV=staging rollup -c",
33
+ "publish-prod": "REACT_APP_ENV=prod rollup -c && npm publish",
34
+ "publish-staging": "REACT_APP_ENV=staging rollup -c && npm publish --tag beta",
35
35
  "test": "react-scripts test",
36
36
  "eject": "react-scripts eject"
37
37
  },
@@ -91,8 +91,8 @@
91
91
  "webpack-cli": "^4.10.0"
92
92
  },
93
93
  "peerDependencies": {
94
- "@testing-library/react": "^12.1.5 || ^13.4.0",
95
94
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
96
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
95
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
96
+ "@testing-library/react": "^12.1.5 || ^13.4.0"
97
97
  }
98
98
  }