@wavv/dialer 2.2.1 → 2.4.1
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.
- package/README.md +17 -0
- package/dist/constants.js +13 -13
- package/dist/events.d.ts +3 -19
- package/dist/index.d.ts +24 -19
- package/dist/index.js +38 -30
- package/dist/options.d.ts +10 -1
- package/dist/utils.d.ts +48 -0
- package/dist/utils.js +126 -0
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -4,6 +4,23 @@ For more information, see our [documentation](https://docs.wavv.com)
|
|
|
4
4
|
|
|
5
5
|
<br />
|
|
6
6
|
|
|
7
|
+
### Version 2.4.0
|
|
8
|
+
|
|
9
|
+
- Added `close`
|
|
10
|
+
- Added `endCampaign`
|
|
11
|
+
|
|
12
|
+
<br />
|
|
13
|
+
|
|
14
|
+
### Version 2.3.0
|
|
15
|
+
|
|
16
|
+
- Added `purchaseDialer`
|
|
17
|
+
- Added `listVoicemails`
|
|
18
|
+
- Added `dropVoicemail`
|
|
19
|
+
- Added `recordCall`
|
|
20
|
+
- Added `close`
|
|
21
|
+
|
|
22
|
+
<br />
|
|
23
|
+
|
|
7
24
|
### Version 2.1.0
|
|
8
25
|
|
|
9
26
|
- Added `addOverlayVisibleListener`
|
package/dist/constants.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DNC_TYPE_MANUAL = exports.DNC_TYPE_SMS = exports.DNC_TYPE_IVR = exports.OUTCOME_UNKNOWN = exports.OUTCOME_NO_VOICEMAIL = exports.OUTCOME_NO_CALLBACK = exports.OUTCOME_VOICEMAIL = exports.OUTCOME_CALLBACK = exports.OUTCOME_DISCONNECTED = exports.OUTCOME_BUSY = exports.OUTCOME_NO_ANSWER = exports.OUTCOME_USER_HUNG_UP = exports.OUTCOME_HUNG_UP = void 0;
|
|
4
|
-
exports.OUTCOME_HUNG_UP = 'HUNG_UP';
|
|
5
|
-
exports.OUTCOME_USER_HUNG_UP = 'USER_HUNG_UP';
|
|
6
|
-
exports.OUTCOME_NO_ANSWER = 'NO_ANSWER';
|
|
7
|
-
exports.OUTCOME_BUSY = 'BUSY';
|
|
8
|
-
exports.OUTCOME_DISCONNECTED = 'DISCONNECTED';
|
|
9
|
-
exports.OUTCOME_CALLBACK = 'CALLBACK';
|
|
10
|
-
exports.OUTCOME_VOICEMAIL = 'VOICEMAIL';
|
|
11
|
-
exports.OUTCOME_NO_CALLBACK = 'NO_CALLBACK';
|
|
12
|
-
exports.OUTCOME_NO_VOICEMAIL = 'NO_VOICEMAIL';
|
|
13
|
-
exports.OUTCOME_UNKNOWN = 'UNKNOWN';
|
|
14
|
-
exports.DNC_TYPE_IVR = 'IVR OPT-OUT';
|
|
15
|
-
exports.DNC_TYPE_SMS = 'SMS OPT-OUT';
|
|
16
|
-
exports.DNC_TYPE_MANUAL = 'MANUAL';
|
|
4
|
+
exports.OUTCOME_HUNG_UP = 'HUNG_UP';
|
|
5
|
+
exports.OUTCOME_USER_HUNG_UP = 'USER_HUNG_UP';
|
|
6
|
+
exports.OUTCOME_NO_ANSWER = 'NO_ANSWER';
|
|
7
|
+
exports.OUTCOME_BUSY = 'BUSY';
|
|
8
|
+
exports.OUTCOME_DISCONNECTED = 'DISCONNECTED';
|
|
9
|
+
exports.OUTCOME_CALLBACK = 'CALLBACK';
|
|
10
|
+
exports.OUTCOME_VOICEMAIL = 'VOICEMAIL';
|
|
11
|
+
exports.OUTCOME_NO_CALLBACK = 'NO_CALLBACK';
|
|
12
|
+
exports.OUTCOME_NO_VOICEMAIL = 'NO_VOICEMAIL';
|
|
13
|
+
exports.OUTCOME_UNKNOWN = 'UNKNOWN';
|
|
14
|
+
exports.DNC_TYPE_IVR = 'IVR OPT-OUT';
|
|
15
|
+
exports.DNC_TYPE_SMS = 'SMS OPT-OUT';
|
|
16
|
+
exports.DNC_TYPE_MANUAL = 'MANUAL';
|
package/dist/events.d.ts
CHANGED
|
@@ -6,65 +6,49 @@ interface Call {
|
|
|
6
6
|
contactId: string;
|
|
7
7
|
}
|
|
8
8
|
interface Line extends Call {
|
|
9
|
-
/** Call should have focus in your app */
|
|
10
9
|
focused: boolean;
|
|
11
|
-
/** Numbers the dialer intends to skip */
|
|
12
10
|
skippedNumbers: string[];
|
|
13
11
|
}
|
|
14
12
|
export interface CallStarted extends Call {
|
|
15
13
|
}
|
|
16
14
|
export interface CallAnswered extends Call {
|
|
17
|
-
/** Call answered in the background */
|
|
18
15
|
backgrounded: boolean;
|
|
19
16
|
}
|
|
20
17
|
export interface CallEnded extends Call {
|
|
21
|
-
|
|
22
|
-
duration: number;
|
|
23
|
-
/** Call was answered by a human */
|
|
18
|
+
answered: boolean;
|
|
24
19
|
human: boolean;
|
|
25
|
-
|
|
20
|
+
duration: number;
|
|
26
21
|
outcome: Outcome;
|
|
22
|
+
voicemailId?: string;
|
|
27
23
|
}
|
|
28
24
|
export interface CallRecorded extends Call {
|
|
29
|
-
/** Call recording ID */
|
|
30
25
|
recordingId: string;
|
|
31
26
|
}
|
|
32
27
|
export interface WaitingForContinue extends Call {
|
|
33
|
-
/** Dialer is waiting on host app to continue */
|
|
34
28
|
waiting: boolean;
|
|
35
29
|
}
|
|
36
30
|
export interface LinesChanged {
|
|
37
|
-
/** Lines currently in use by the dialer */
|
|
38
31
|
lines: Line[];
|
|
39
32
|
}
|
|
40
33
|
export interface DialerIdle {
|
|
41
|
-
/** Dialer is idle, pending auto-disconnect */
|
|
42
34
|
idle: boolean;
|
|
43
35
|
}
|
|
44
36
|
export interface CampaignEnded {
|
|
45
|
-
/** All contacts in the campaign were called */
|
|
46
37
|
complete: boolean;
|
|
47
|
-
/** History of call objects for the campaign */
|
|
48
38
|
history: CallEnded[];
|
|
49
39
|
}
|
|
50
40
|
export interface DncChanged {
|
|
51
|
-
/** Number on the DNC list */
|
|
52
41
|
number: string;
|
|
53
|
-
/** Reason for being on DNC list */
|
|
54
42
|
type: DncType;
|
|
55
|
-
/** Number was removed (added when false) */
|
|
56
43
|
removed: boolean;
|
|
57
44
|
}
|
|
58
45
|
export interface DialerVisible {
|
|
59
|
-
/** Dialer is visible */
|
|
60
46
|
visible: boolean;
|
|
61
47
|
}
|
|
62
48
|
export interface MiniDialerVisible {
|
|
63
|
-
/** Mini dialer is visible */
|
|
64
49
|
visible: boolean;
|
|
65
50
|
}
|
|
66
51
|
export interface OverlayVisible {
|
|
67
|
-
/** Overlay is visible */
|
|
68
52
|
visible: boolean;
|
|
69
53
|
}
|
|
70
54
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Listener, InitOps, SetThemeOps, Voicemail } from './utils';
|
|
1
2
|
import { CallAnswered, CallEnded, CallRecorded, CallStarted, CampaignEnded, DialerIdle, DialerVisible, DncChanged, LinesChanged, MiniDialerVisible, WaitingForContinue, OverlayVisible } from './events';
|
|
2
|
-
import { AddDncNumberOps, AddPhoneOps, CallPhoneOps, ContinueCampaignOps, RemoveContactOps, RemoveDncNumberOps, RemovePhoneOps, StartCampaignOps } from './options';
|
|
3
|
+
import { AddDncNumberOps, AddPhoneOps, CallPhoneOps, ContinueCampaignOps, RemoveContactOps, RemoveDncNumberOps, RemovePhoneOps, StartCampaignOps, DropVoicemailOps, EndCampaignOps } from './options';
|
|
3
4
|
export * from './constants';
|
|
4
|
-
export declare const init: (options:
|
|
5
|
-
export declare const close: () => any
|
|
6
|
-
export declare const setTheme: (options:
|
|
5
|
+
export declare const init: (options: InitOps) => Promise<any>;
|
|
6
|
+
export declare const close: () => Promise<any>;
|
|
7
|
+
export declare const setTheme: (options: SetThemeOps) => Promise<any>;
|
|
7
8
|
export declare const addDncNumber: (options: AddDncNumberOps) => Promise<void>;
|
|
8
9
|
export declare const addPhone: (options: AddPhoneOps) => Promise<void>;
|
|
9
10
|
export declare const callPhone: (options: CallPhoneOps) => Promise<void>;
|
|
@@ -13,19 +14,23 @@ export declare const removeContact: (options: RemoveContactOps) => Promise<void>
|
|
|
13
14
|
export declare const removeDncNumber: (options: RemoveDncNumberOps) => Promise<void>;
|
|
14
15
|
export declare const removePhone: (options: RemovePhoneOps) => Promise<void>;
|
|
15
16
|
export declare const startCampaign: (options: StartCampaignOps) => Promise<void>;
|
|
17
|
+
export declare const endCampaign: (options: EndCampaignOps) => Promise<void>;
|
|
16
18
|
export declare const purchaseDialer: () => Promise<void>;
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const
|
|
19
|
+
export declare const recordCall: () => Promise<void>;
|
|
20
|
+
export declare const listVoicemails: () => Promise<Voicemail[]>;
|
|
21
|
+
export declare const dropVoicemail: (options: DropVoicemailOps) => Promise<void>;
|
|
22
|
+
export declare const addCallAnsweredListener: (callback: (event: CallAnswered) => void) => Listener;
|
|
23
|
+
export declare const addCallEndedListener: (callback: (event: CallEnded) => void) => Listener;
|
|
24
|
+
export declare const addCallRecordedListener: (callback: (event: CallRecorded) => void) => Listener;
|
|
25
|
+
export declare const addCallStartedListener: (callback: (event: CallStarted) => void) => Listener;
|
|
26
|
+
export declare const addCampaignEndedListener: (callback: (event: CampaignEnded) => void) => Listener;
|
|
27
|
+
export declare const addDialerIdleListener: (callback: (event: DialerIdle) => void) => Listener;
|
|
28
|
+
export declare const addDialerVisibleListener: (callback: (event: DialerVisible) => void) => Listener;
|
|
29
|
+
export declare const addDncChangedListener: (callback: (event: DncChanged) => void) => Listener;
|
|
30
|
+
export declare const addLinesChangedListener: (callback: (event: LinesChanged) => void) => Listener;
|
|
31
|
+
export declare const addMiniDialerVisibleListener: (callback: (event: MiniDialerVisible) => void) => Listener;
|
|
32
|
+
export declare const addWaitingForContinueListener: (callback: (event: WaitingForContinue) => void) => Listener;
|
|
33
|
+
export declare const addOverlayVisibleListener: (callback: (event: OverlayVisible) => void) => Listener;
|
|
34
|
+
export declare const addClosedListener: (callback: () => void) => Listener;
|
|
35
|
+
export declare const addManageSubscriptionListener: (callback: () => void) => Listener;
|
|
36
|
+
export declare const addUpsellClickListener: (callback: () => void) => Listener;
|
package/dist/index.js
CHANGED
|
@@ -10,8 +10,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.addUpsellClickListener = exports.addManageSubscriptionListener = exports.addClosedListener = exports.addOverlayVisibleListener = exports.addWaitingForContinueListener = exports.addMiniDialerVisibleListener = exports.addLinesChangedListener = exports.addDncChangedListener = exports.addDialerVisibleListener = exports.addDialerIdleListener = exports.addCampaignEndedListener = exports.addCallStartedListener = exports.addCallRecordedListener = exports.addCallEndedListener = exports.addCallAnsweredListener = exports.purchaseDialer = exports.startCampaign = exports.removePhone = exports.removeDncNumber = exports.removeContact = exports.load = exports.continueCampaign = exports.callPhone = exports.addPhone = exports.addDncNumber = exports.setTheme = exports.close = exports.init = void 0;
|
|
14
|
-
const
|
|
13
|
+
exports.addUpsellClickListener = exports.addManageSubscriptionListener = exports.addClosedListener = exports.addOverlayVisibleListener = exports.addWaitingForContinueListener = exports.addMiniDialerVisibleListener = exports.addLinesChangedListener = exports.addDncChangedListener = exports.addDialerVisibleListener = exports.addDialerIdleListener = exports.addCampaignEndedListener = exports.addCallStartedListener = exports.addCallRecordedListener = exports.addCallEndedListener = exports.addCallAnsweredListener = exports.dropVoicemail = exports.listVoicemails = exports.recordCall = exports.purchaseDialer = exports.endCampaign = exports.startCampaign = exports.removePhone = exports.removeDncNumber = exports.removeContact = exports.load = exports.continueCampaign = exports.callPhone = exports.addPhone = exports.addDncNumber = exports.setTheme = exports.close = exports.init = void 0;
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
15
|
// -----------
|
|
16
16
|
// VERSION
|
|
17
17
|
// -----------
|
|
@@ -23,63 +23,71 @@ __exportStar(require("./constants"), exports);
|
|
|
23
23
|
// -----------
|
|
24
24
|
// FUNCTIONS
|
|
25
25
|
// -----------
|
|
26
|
-
const init = (options) =>
|
|
26
|
+
const init = (options) => utils_1.initialize(V, options);
|
|
27
27
|
exports.init = init;
|
|
28
|
-
const close = () =>
|
|
28
|
+
const close = () => utils_1.deinitialize(V);
|
|
29
29
|
exports.close = close;
|
|
30
|
-
const setTheme = (options) =>
|
|
30
|
+
const setTheme = (options) => utils_1.execute(V, 'SET_THEME', options);
|
|
31
31
|
exports.setTheme = setTheme;
|
|
32
|
-
const addDncNumber = (options) =>
|
|
32
|
+
const addDncNumber = (options) => utils_1.execute(V, 'ADD_DNC_NUMBER', options);
|
|
33
33
|
exports.addDncNumber = addDncNumber;
|
|
34
|
-
const addPhone = (options) =>
|
|
34
|
+
const addPhone = (options) => utils_1.execute(V, 'ADD_PHONE', options);
|
|
35
35
|
exports.addPhone = addPhone;
|
|
36
36
|
// TODO: accept contact object (for additional fields)
|
|
37
|
-
const callPhone = (options) =>
|
|
37
|
+
const callPhone = (options) => utils_1.execute(V, 'CALL_PHONE', options);
|
|
38
38
|
exports.callPhone = callPhone;
|
|
39
|
-
const continueCampaign = (options) =>
|
|
39
|
+
const continueCampaign = (options) => utils_1.execute(V, 'CONTINUE', options);
|
|
40
40
|
exports.continueCampaign = continueCampaign;
|
|
41
|
-
const load = () =>
|
|
41
|
+
const load = () => utils_1.execute(V, 'LOAD_DIALER');
|
|
42
42
|
exports.load = load;
|
|
43
|
-
const removeContact = (options) =>
|
|
43
|
+
const removeContact = (options) => utils_1.execute(V, 'REMOVE_CONTACT', options);
|
|
44
44
|
exports.removeContact = removeContact;
|
|
45
|
-
const removeDncNumber = (options) =>
|
|
45
|
+
const removeDncNumber = (options) => utils_1.execute(V, 'REMOVE_DNC_NUMBER', options);
|
|
46
46
|
exports.removeDncNumber = removeDncNumber;
|
|
47
|
-
const removePhone = (options) =>
|
|
47
|
+
const removePhone = (options) => utils_1.execute(V, 'REMOVE_PHONE', options);
|
|
48
48
|
exports.removePhone = removePhone;
|
|
49
|
-
const startCampaign = (options) =>
|
|
49
|
+
const startCampaign = (options) => utils_1.execute(V, 'START_CAMPAIGN', options);
|
|
50
50
|
exports.startCampaign = startCampaign;
|
|
51
|
-
const
|
|
51
|
+
const endCampaign = (options) => utils_1.execute(V, 'END_CAMPAIGN', options);
|
|
52
|
+
exports.endCampaign = endCampaign;
|
|
53
|
+
const purchaseDialer = () => utils_1.execute(V, 'PURCHASE_DIALER');
|
|
52
54
|
exports.purchaseDialer = purchaseDialer;
|
|
55
|
+
const recordCall = () => utils_1.execute(V, 'RECORD_CALL');
|
|
56
|
+
exports.recordCall = recordCall;
|
|
57
|
+
const listVoicemails = () => utils_1.execute(V, 'LIST_VOICEMAILS');
|
|
58
|
+
exports.listVoicemails = listVoicemails;
|
|
59
|
+
const dropVoicemail = (options) => utils_1.execute(V, 'DROP_VOICEMAIL');
|
|
60
|
+
exports.dropVoicemail = dropVoicemail;
|
|
53
61
|
// -----------
|
|
54
62
|
// LISTENERS
|
|
55
63
|
// -----------
|
|
56
|
-
const addCallAnsweredListener = (callback) =>
|
|
64
|
+
const addCallAnsweredListener = (callback) => utils_1.listen(V, 'CALL_ANSWERED', callback);
|
|
57
65
|
exports.addCallAnsweredListener = addCallAnsweredListener;
|
|
58
|
-
const addCallEndedListener = (callback) =>
|
|
66
|
+
const addCallEndedListener = (callback) => utils_1.listen(V, 'CALL_ENDED', callback);
|
|
59
67
|
exports.addCallEndedListener = addCallEndedListener;
|
|
60
|
-
const addCallRecordedListener = (callback) =>
|
|
68
|
+
const addCallRecordedListener = (callback) => utils_1.listen(V, 'CALL_RECORDED', callback);
|
|
61
69
|
exports.addCallRecordedListener = addCallRecordedListener;
|
|
62
|
-
const addCallStartedListener = (callback) =>
|
|
70
|
+
const addCallStartedListener = (callback) => utils_1.listen(V, 'CALL_STARTED', callback);
|
|
63
71
|
exports.addCallStartedListener = addCallStartedListener;
|
|
64
|
-
const addCampaignEndedListener = (callback) =>
|
|
72
|
+
const addCampaignEndedListener = (callback) => utils_1.listen(V, 'CAMPAIGN_ENDED', callback);
|
|
65
73
|
exports.addCampaignEndedListener = addCampaignEndedListener;
|
|
66
|
-
const addDialerIdleListener = (callback) =>
|
|
74
|
+
const addDialerIdleListener = (callback) => utils_1.listen(V, 'DIALER_IDLE', callback);
|
|
67
75
|
exports.addDialerIdleListener = addDialerIdleListener;
|
|
68
|
-
const addDialerVisibleListener = (callback) =>
|
|
76
|
+
const addDialerVisibleListener = (callback) => utils_1.listen(V, 'DIALER_VISIBLE', callback);
|
|
69
77
|
exports.addDialerVisibleListener = addDialerVisibleListener;
|
|
70
|
-
const addDncChangedListener = (callback) =>
|
|
78
|
+
const addDncChangedListener = (callback) => utils_1.listen(V, 'DNC_CHANGED', callback);
|
|
71
79
|
exports.addDncChangedListener = addDncChangedListener;
|
|
72
|
-
const addLinesChangedListener = (callback) =>
|
|
80
|
+
const addLinesChangedListener = (callback) => utils_1.listen(V, 'LINES_CHANGED', callback);
|
|
73
81
|
exports.addLinesChangedListener = addLinesChangedListener;
|
|
74
|
-
const addMiniDialerVisibleListener = (callback) =>
|
|
82
|
+
const addMiniDialerVisibleListener = (callback) => utils_1.listen(V, 'DIALER_MINI_VISIBLE', callback);
|
|
75
83
|
exports.addMiniDialerVisibleListener = addMiniDialerVisibleListener;
|
|
76
|
-
const addWaitingForContinueListener = (callback) =>
|
|
84
|
+
const addWaitingForContinueListener = (callback) => utils_1.listen(V, 'WAITING_FOR_CONTINUE', callback);
|
|
77
85
|
exports.addWaitingForContinueListener = addWaitingForContinueListener;
|
|
78
|
-
const addOverlayVisibleListener = (callback) =>
|
|
86
|
+
const addOverlayVisibleListener = (callback) => utils_1.listen(V, 'OVERLAY_VISIBLE', callback);
|
|
79
87
|
exports.addOverlayVisibleListener = addOverlayVisibleListener;
|
|
80
|
-
const addClosedListener = (callback) =>
|
|
88
|
+
const addClosedListener = (callback) => utils_1.listen(V, 'CLOSED', callback);
|
|
81
89
|
exports.addClosedListener = addClosedListener;
|
|
82
|
-
const addManageSubscriptionListener = (callback) =>
|
|
90
|
+
const addManageSubscriptionListener = (callback) => utils_1.listen(V, 'MANAGE_SUBSCRIPTION', callback);
|
|
83
91
|
exports.addManageSubscriptionListener = addManageSubscriptionListener;
|
|
84
|
-
const addUpsellClickListener = (callback) =>
|
|
92
|
+
const addUpsellClickListener = (callback) => utils_1.listen(V, 'UPSELL_CLICK', callback);
|
|
85
93
|
exports.addUpsellClickListener = addUpsellClickListener;
|
package/dist/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Contact } from '
|
|
1
|
+
import { Contact } from './utils';
|
|
2
2
|
export interface AddDncNumberOps {
|
|
3
3
|
number: string;
|
|
4
4
|
addedBy?: string;
|
|
@@ -29,3 +29,12 @@ export interface RemovePhoneOps {
|
|
|
29
29
|
export interface StartCampaignOps {
|
|
30
30
|
contacts: Contact[];
|
|
31
31
|
}
|
|
32
|
+
export interface EndCampaignOps {
|
|
33
|
+
/**
|
|
34
|
+
* @param {boolean} close - Close WAVV after ending the campaign
|
|
35
|
+
*/
|
|
36
|
+
close?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface DropVoicemailOps {
|
|
39
|
+
id: string;
|
|
40
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const listen: (version: number, event: string, callback: Function) => {
|
|
2
|
+
remove(): void;
|
|
3
|
+
};
|
|
4
|
+
export declare const execute: (version: number, action: string, options?: object) => Promise<any>;
|
|
5
|
+
export declare const initialize: (version: number, options: object) => Promise<any>;
|
|
6
|
+
export declare const deinitialize: (version: number) => Promise<any>;
|
|
7
|
+
export interface Listener {
|
|
8
|
+
remove: Function;
|
|
9
|
+
}
|
|
10
|
+
export interface InitOps {
|
|
11
|
+
token: string;
|
|
12
|
+
server?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SetThemeOps {
|
|
15
|
+
theme: 'LIGHT' | 'DARK';
|
|
16
|
+
primaryColor?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface MergeField {
|
|
19
|
+
/** Field ID, e.g. "first_name" */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Field label, e.g. "First Name" */
|
|
22
|
+
label: string;
|
|
23
|
+
}
|
|
24
|
+
interface MergeFieldValue extends MergeField {
|
|
25
|
+
/** Field value, e.g. "Jerry" */
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
export interface Contact {
|
|
29
|
+
contactId: string;
|
|
30
|
+
numbers: string[];
|
|
31
|
+
name?: string;
|
|
32
|
+
firstName?: string;
|
|
33
|
+
lastName?: string;
|
|
34
|
+
address?: string;
|
|
35
|
+
city?: string;
|
|
36
|
+
/** Avatar image URL */
|
|
37
|
+
avatarUrl?: string;
|
|
38
|
+
/** Subheading, appears below name */
|
|
39
|
+
subheading?: string;
|
|
40
|
+
/** Additional merge field data */
|
|
41
|
+
mergeFields?: MergeFieldValue[];
|
|
42
|
+
}
|
|
43
|
+
export interface Voicemail {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
seconds: number;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.deinitialize = exports.initialize = exports.execute = exports.listen = void 0;
|
|
13
|
+
const WINDOW_VAR = 'Storm';
|
|
14
|
+
const DOMAIN = 'stormapp.com';
|
|
15
|
+
const JS_FILE = 'storm.js';
|
|
16
|
+
const SUBDOMAIN = 'app';
|
|
17
|
+
let initializing = false;
|
|
18
|
+
let deinitializing = false;
|
|
19
|
+
let interval;
|
|
20
|
+
let waitingMs = 0;
|
|
21
|
+
const ms = 100;
|
|
22
|
+
const maxMs = 10000;
|
|
23
|
+
const buffer = [];
|
|
24
|
+
const win = window;
|
|
25
|
+
const wait = () => {
|
|
26
|
+
if (interval)
|
|
27
|
+
return;
|
|
28
|
+
interval = setInterval(() => {
|
|
29
|
+
if (win[WINDOW_VAR]) {
|
|
30
|
+
clearInterval(interval);
|
|
31
|
+
buffer.forEach(win[WINDOW_VAR].dispatch);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (waitingMs > maxMs) {
|
|
35
|
+
clearInterval(interval);
|
|
36
|
+
console.error('Timed out waiting for WAVV');
|
|
37
|
+
}
|
|
38
|
+
waitingMs += ms;
|
|
39
|
+
}
|
|
40
|
+
}, ms);
|
|
41
|
+
};
|
|
42
|
+
const dispatch = (type, payload, version, resolve, reject) => {
|
|
43
|
+
const action = {
|
|
44
|
+
type,
|
|
45
|
+
payload,
|
|
46
|
+
resolve,
|
|
47
|
+
reject,
|
|
48
|
+
version,
|
|
49
|
+
};
|
|
50
|
+
if (win[WINDOW_VAR]) {
|
|
51
|
+
win[WINDOW_VAR].dispatch(action);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
buffer.push(action);
|
|
55
|
+
wait();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const bootstrap = ({ server = SUBDOMAIN }, callback) => {
|
|
59
|
+
if (win[WINDOW_VAR])
|
|
60
|
+
return callback();
|
|
61
|
+
const url = `https://${server}.${DOMAIN}/${JS_FILE}`;
|
|
62
|
+
const script = document.createElement('script');
|
|
63
|
+
script.id = JS_FILE;
|
|
64
|
+
script.src = url;
|
|
65
|
+
script.onload = () => {
|
|
66
|
+
callback();
|
|
67
|
+
};
|
|
68
|
+
script.onerror = () => {
|
|
69
|
+
callback(`Failed to load WAVV from ${url}`);
|
|
70
|
+
};
|
|
71
|
+
document.body.appendChild(script);
|
|
72
|
+
};
|
|
73
|
+
const debootstrap = (version, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
if (win[WINDOW_VAR])
|
|
76
|
+
dispatch('CLOSE_STORM', {}, version);
|
|
77
|
+
callback(null);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
callback(err);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const listen = (version, event, callback) => {
|
|
84
|
+
dispatch('SET_CALLBACK', { event, callback }, version);
|
|
85
|
+
return {
|
|
86
|
+
remove() {
|
|
87
|
+
dispatch('REMOVE_CALLBACK', { event, callback }, version);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
exports.listen = listen;
|
|
92
|
+
const execute = (version, action, options = {}) => {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
dispatch(action, options, version, resolve, reject);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
exports.execute = execute;
|
|
98
|
+
const initialize = (version, options) => {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
if (initializing)
|
|
101
|
+
return reject('Init in progress');
|
|
102
|
+
initializing = true;
|
|
103
|
+
bootstrap(options, (err) => {
|
|
104
|
+
initializing = false;
|
|
105
|
+
if (err)
|
|
106
|
+
return reject(err);
|
|
107
|
+
dispatch('AUTH', options, version, resolve, reject);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
exports.initialize = initialize;
|
|
112
|
+
const deinitialize = (version) => {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
if (deinitializing)
|
|
115
|
+
return reject('Deinit in progress');
|
|
116
|
+
deinitializing = true;
|
|
117
|
+
debootstrap(version, (err) => {
|
|
118
|
+
deinitializing = false;
|
|
119
|
+
if (err)
|
|
120
|
+
reject(err);
|
|
121
|
+
else
|
|
122
|
+
resolve(true);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
exports.deinitialize = deinitialize;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wavv/dialer",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "2.4.1",
|
|
4
|
+
"description": "WAVV Dialer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "tsc",
|
|
7
|
+
"build": "tsc --removeComments",
|
|
8
8
|
"start": "tsc -w",
|
|
9
9
|
"pub": "npm publish --access public"
|
|
10
10
|
},
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
"keywords": [],
|
|
15
15
|
"author": "WAVV Communications",
|
|
16
16
|
"license": "ISC",
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@wavv/internal": "^2.1.1"
|
|
19
|
-
},
|
|
20
17
|
"devDependencies": {
|
|
18
|
+
"@types/node": "^17.0.21",
|
|
21
19
|
"prettier": "^2.2.1",
|
|
22
20
|
"tslint": "^6.1.3",
|
|
23
21
|
"tslint-config-prettier": "^1.18.0",
|