@convirza/dialer-sdk 1.0.0
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 +1841 -0
- package/dist/api/CallHistoryAPI.d.ts +16 -0
- package/dist/api/DialerAPI.d.ts +52 -0
- package/dist/api/PhoneNumbersAPI.d.ts +21 -0
- package/dist/constants/api-config.d.ts +12 -0
- package/dist/constants/countries.d.ts +7 -0
- package/dist/constants/index.d.ts +30 -0
- package/dist/constants/sip-config.d.ts +14 -0
- package/dist/core/ConvirzaDialer.d.ts +40 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.umd.js +1 -0
- package/dist/init.d.ts +4 -0
- package/dist/media/AudioDeviceManager.d.ts +34 -0
- package/dist/media/CallQualityMonitor.d.ts +41 -0
- package/dist/services/CallHistoryService.d.ts +41 -0
- package/dist/sip/SipAdapter.d.ts +99 -0
- package/dist/storage/CallHistoryStore.d.ts +16 -0
- package/dist/types/call-history.d.ts +29 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/phone-numbers.d.ts +22 -0
- package/dist/ui/ConvirzaDialerElement.d.ts +250 -0
- package/dist/ui/ConvirzaDialerElement.styles.d.ts +2 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/validators.d.ts +4 -0
- package/package.json +70 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CallRecord, CallHistoryResponse, CallHistoryQueryParams } from '../types/call-history.js';
|
|
2
|
+
/**
|
|
3
|
+
* Backend API client for call history
|
|
4
|
+
* Handles REST communication with server
|
|
5
|
+
*/
|
|
6
|
+
export declare class CallHistoryAPI {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private authToken;
|
|
9
|
+
constructor(baseUrl: string, authToken?: string);
|
|
10
|
+
setAuthToken(token: string): void;
|
|
11
|
+
private getHeaders;
|
|
12
|
+
fetchHistory(params: CallHistoryQueryParams): Promise<CallHistoryResponse>;
|
|
13
|
+
saveCall(call: Omit<CallRecord, 'id' | 'createdAt'>): Promise<CallRecord>;
|
|
14
|
+
updateCall(callId: string, updates: Partial<CallRecord>): Promise<CallRecord>;
|
|
15
|
+
private normalizeTimestamps;
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface DialerInitConfig {
|
|
2
|
+
access_token: string;
|
|
3
|
+
refresh_token: string;
|
|
4
|
+
oauth_endpoint?: string;
|
|
5
|
+
api_url?: string;
|
|
6
|
+
dark_theme?: boolean;
|
|
7
|
+
showPopup?: boolean;
|
|
8
|
+
primaryColor?: string;
|
|
9
|
+
accentColor?: string;
|
|
10
|
+
brandName?: string;
|
|
11
|
+
brandLogo?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CallListItem {
|
|
14
|
+
id: string;
|
|
15
|
+
phoneNumber: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
duration?: number;
|
|
18
|
+
direction: 'inbound' | 'outbound';
|
|
19
|
+
status: 'answered' | 'missed' | 'voicemail';
|
|
20
|
+
}
|
|
21
|
+
declare class DialerAPI {
|
|
22
|
+
private element;
|
|
23
|
+
private config;
|
|
24
|
+
private callHistory;
|
|
25
|
+
private activeCallId;
|
|
26
|
+
private isMuted;
|
|
27
|
+
private isRecording;
|
|
28
|
+
private errorHandler;
|
|
29
|
+
private callEndedHandler;
|
|
30
|
+
private storageHandler;
|
|
31
|
+
private validateConfig;
|
|
32
|
+
init(config: DialerInitConfig): void;
|
|
33
|
+
private setupGlobalErrorHandlers;
|
|
34
|
+
refresh(): void;
|
|
35
|
+
hidePopup(): void;
|
|
36
|
+
showPopup(): void;
|
|
37
|
+
getActiveCallID(): string | null;
|
|
38
|
+
call(phoneNumber?: string): void;
|
|
39
|
+
mute(enable?: boolean): boolean;
|
|
40
|
+
hold(enable?: boolean): boolean;
|
|
41
|
+
record(enable?: boolean): boolean;
|
|
42
|
+
callList(limit?: number): CallListItem[];
|
|
43
|
+
endCall(): void;
|
|
44
|
+
transfer(target: string): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
private setupEventListeners;
|
|
47
|
+
private generateCallId;
|
|
48
|
+
get isMutedState(): boolean;
|
|
49
|
+
get isRecordingState(): boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare const convirzaDialer: DialerAPI;
|
|
52
|
+
export { DialerAPI };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OrderedPhoneNumbersResponse } from '../types/phone-numbers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Phone Numbers API Parameters
|
|
4
|
+
*/
|
|
5
|
+
export interface FetchOrderedNumbersParams {
|
|
6
|
+
domainId: number;
|
|
7
|
+
limit?: number;
|
|
8
|
+
status?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Backend API client for phone numbers
|
|
12
|
+
* Handles REST communication with dialer backend
|
|
13
|
+
*/
|
|
14
|
+
export declare class PhoneNumbersAPI {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private authToken;
|
|
17
|
+
constructor(baseUrl: string, authToken?: string);
|
|
18
|
+
setAuthToken(token: string): void;
|
|
19
|
+
private getHeaders;
|
|
20
|
+
fetchOrderedNumbers(params: FetchOrderedNumbersParams): Promise<OrderedPhoneNumbersResponse>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default API configuration
|
|
3
|
+
*
|
|
4
|
+
* TODO: Replace with production endpoints before deploying to prod
|
|
5
|
+
* Current endpoints point to staging environment (stag-5)
|
|
6
|
+
*
|
|
7
|
+
* Production endpoints:
|
|
8
|
+
* - API_BASE_URL: https://dialer-apis.convirza.com
|
|
9
|
+
* - OAUTH_URL: https://oauth.convirza.com/oauth/internal/token
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_API_BASE_URL = "https://stag-5-dialer-apis.convirza.com";
|
|
12
|
+
export declare const DEFAULT_OAUTH_URL = "https://stag-5-oauth.convirza.com/oauth/internal/token";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const DEFAULT_CONFIG: {
|
|
2
|
+
position: "bottom-right";
|
|
3
|
+
zIndex: number;
|
|
4
|
+
defaultState: "collapsed";
|
|
5
|
+
primaryColor: string;
|
|
6
|
+
accentColor: string;
|
|
7
|
+
dangerColor: string;
|
|
8
|
+
iceServers: {
|
|
9
|
+
urls: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export declare const CALL_STATUS: {
|
|
13
|
+
readonly IDLE: "idle";
|
|
14
|
+
readonly DIALING: "dialing";
|
|
15
|
+
readonly RINGING: "ringing";
|
|
16
|
+
readonly CONNECTED: "connected";
|
|
17
|
+
readonly ENDED: "ended";
|
|
18
|
+
readonly ERROR: "error";
|
|
19
|
+
};
|
|
20
|
+
export declare const VALID_STATE_TRANSITIONS: Record<string, string[]>;
|
|
21
|
+
export declare const WIDGET_POSITIONS: {
|
|
22
|
+
readonly TOP_LEFT: "top-left";
|
|
23
|
+
readonly TOP_RIGHT: "top-right";
|
|
24
|
+
readonly BOTTOM_LEFT: "bottom-left";
|
|
25
|
+
readonly BOTTOM_RIGHT: "bottom-right";
|
|
26
|
+
};
|
|
27
|
+
export declare const WIDGET_STATES: {
|
|
28
|
+
readonly COLLAPSED: "collapsed";
|
|
29
|
+
readonly EXPANDED: "expanded";
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const SIP_DEFAULTS: {
|
|
2
|
+
readonly REGISTER_EXPIRES: 300;
|
|
3
|
+
readonly QUALITY_INTERVAL_MS: 2000;
|
|
4
|
+
readonly CONNECTION_TIMEOUT_S: 5;
|
|
5
|
+
readonly STUN_SERVERS: readonly [{
|
|
6
|
+
readonly urls: "stun:stun.l.google.com:19302";
|
|
7
|
+
}];
|
|
8
|
+
readonly MAX_RECONNECTION_ATTEMPTS: 3;
|
|
9
|
+
readonly RECONNECTION_TIMEOUT_S: 4;
|
|
10
|
+
};
|
|
11
|
+
export declare const CALL_STATE: {
|
|
12
|
+
readonly MAX_RESTORE_AGE_MS: 3600000;
|
|
13
|
+
readonly MAX_HISTORY_ITEMS: 50;
|
|
14
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DialerConfig, CallOptions, CallSession, DialerEvents } from '../types/index.js';
|
|
2
|
+
export declare class ConvirzaDialer {
|
|
3
|
+
private config;
|
|
4
|
+
private container;
|
|
5
|
+
private state;
|
|
6
|
+
private callStatus;
|
|
7
|
+
private currentCall;
|
|
8
|
+
private durationInterval;
|
|
9
|
+
private events;
|
|
10
|
+
private readonly STORAGE_KEY;
|
|
11
|
+
constructor(config: DialerConfig, events?: DialerEvents);
|
|
12
|
+
private isValidTransition;
|
|
13
|
+
private transitionState;
|
|
14
|
+
private getCallMetadata;
|
|
15
|
+
private persistCallState;
|
|
16
|
+
private restoreCallState;
|
|
17
|
+
mount(targetElement?: HTMLElement): void;
|
|
18
|
+
unmount(): void;
|
|
19
|
+
placeCall(phoneNumber: string, options?: CallOptions): CallSession;
|
|
20
|
+
open(): void;
|
|
21
|
+
close(): void;
|
|
22
|
+
toggle(): void;
|
|
23
|
+
protected initiateCall(_phoneNumber: string, _options?: CallOptions): void;
|
|
24
|
+
protected handleCallRinging(): void;
|
|
25
|
+
protected handleCallAnswered(): void;
|
|
26
|
+
protected handleCallTerminated(): void;
|
|
27
|
+
private startDurationTimer;
|
|
28
|
+
private stopDurationTimer;
|
|
29
|
+
private endCall;
|
|
30
|
+
private isValidPhoneNumber;
|
|
31
|
+
private formatPhoneNumber;
|
|
32
|
+
private formatDuration;
|
|
33
|
+
private applyCustomColors;
|
|
34
|
+
private render;
|
|
35
|
+
private renderCollapsed;
|
|
36
|
+
private renderExpanded;
|
|
37
|
+
private renderDialpad;
|
|
38
|
+
private renderActiveCall;
|
|
39
|
+
private attachEventListeners;
|
|
40
|
+
}
|