@wazo/sdk 0.43.0-rc.1 → 0.43.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 +32 -21
- package/dist/wazo-sdk.js +2 -2
- package/esm/__tests__/api-client.test.js +19 -0
- package/esm/api/auth.js +6 -0
- package/esm/domain/Incall.js +28 -0
- package/esm/domain/Profile.js +5 -1
- package/esm/domain/__tests__/Profile.test.js +32 -0
- package/esm/index.js +1 -0
- package/esm/simple/Auth.js +4 -0
- package/esm/types/api/auth.d.ts +1 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/domain/Incall.d.ts +21 -0
- package/esm/types/domain/Incall.d.ts.map +1 -0
- package/esm/types/domain/Line.d.ts +5 -16
- package/esm/types/domain/Line.d.ts.map +1 -1
- package/esm/types/domain/Phone/Phone.d.ts +1 -1
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
- package/esm/types/domain/Profile.d.ts +5 -1
- package/esm/types/domain/Profile.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +14 -13
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +1 -0
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/lib/__tests__/api-client.test.js +19 -0
- package/lib/api/auth.js +15 -0
- package/lib/domain/Incall.js +32 -0
- package/lib/domain/Profile.js +4 -1
- package/lib/domain/__tests__/Profile.test.js +32 -0
- package/lib/index.js +4 -2
- package/lib/simple/Auth.js +6 -0
- package/lib/types/api/auth.d.ts +1 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/domain/Incall.d.ts +21 -0
- package/lib/types/domain/Incall.d.ts.map +1 -0
- package/lib/types/domain/Line.d.ts +5 -16
- package/lib/types/domain/Line.d.ts.map +1 -1
- package/lib/types/domain/Phone/Phone.d.ts +1 -1
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
- package/lib/types/domain/Profile.d.ts +5 -1
- package/lib/types/domain/Profile.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +14 -13
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +1 -0
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/__tests__/api-client.test.ts +21 -0
- package/src/api/auth.ts +8 -0
- package/src/domain/Incall.ts +50 -0
- package/src/domain/Line.ts +5 -17
- package/src/domain/Phone/Phone.ts +1 -1
- package/src/domain/Profile.ts +8 -0
- package/src/domain/__tests__/Profile.test.ts +32 -0
- package/src/domain/types.ts +49 -38
- package/src/index.ts +1 -0
- package/src/simple/Auth.ts +5 -0
package/src/domain/Line.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import newFrom from '../utils/new-from';
|
|
2
|
+
import type { ExtensionRelation, Link } from './types';
|
|
2
3
|
|
|
3
|
-
type Extension = {
|
|
4
|
-
context: string;
|
|
5
|
-
exten: string;
|
|
6
|
-
id: number;
|
|
7
|
-
links?: Array<{
|
|
8
|
-
href: string;
|
|
9
|
-
rel: string;
|
|
10
|
-
}>;
|
|
11
|
-
};
|
|
12
4
|
export type Endpoint = {
|
|
13
5
|
id: number;
|
|
14
|
-
links:
|
|
15
|
-
href: string;
|
|
16
|
-
rel: string;
|
|
17
|
-
}>;
|
|
6
|
+
links: Link[];
|
|
18
7
|
username?: string;
|
|
19
8
|
};
|
|
20
9
|
|
|
@@ -22,13 +11,13 @@ export type LineResponse = {
|
|
|
22
11
|
endpoint_custom: Endpoint | null | undefined;
|
|
23
12
|
endpoint_sccp: Endpoint | null | undefined;
|
|
24
13
|
endpoint_sip: Endpoint | null | undefined;
|
|
25
|
-
extensions:
|
|
14
|
+
extensions: ExtensionRelation[];
|
|
26
15
|
id: number;
|
|
27
16
|
};
|
|
28
17
|
|
|
29
18
|
type LineArguments = {
|
|
30
19
|
id?: number;
|
|
31
|
-
extensions?:
|
|
20
|
+
extensions?: ExtensionRelation[];
|
|
32
21
|
endpointCustom?: Endpoint | null;
|
|
33
22
|
endpointSccp?: Endpoint | null;
|
|
34
23
|
endpointSip?: Endpoint | null;
|
|
@@ -38,7 +27,7 @@ export default class Line {
|
|
|
38
27
|
|
|
39
28
|
id: number | undefined;
|
|
40
29
|
|
|
41
|
-
extensions:
|
|
30
|
+
extensions: ExtensionRelation[] | undefined;
|
|
42
31
|
|
|
43
32
|
endpointCustom: Endpoint | null;
|
|
44
33
|
|
|
@@ -87,5 +76,4 @@ export default class Line {
|
|
|
87
76
|
// Useful to compare instead of instanceof with minified code
|
|
88
77
|
this.type = 'Line';
|
|
89
78
|
}
|
|
90
|
-
|
|
91
79
|
}
|
|
@@ -31,7 +31,7 @@ export type AvailablePhoneOptions = {
|
|
|
31
31
|
};
|
|
32
32
|
export interface Phone extends IEmitter {
|
|
33
33
|
accept(callSession: CallSession, enableVideo?: boolean): Promise<string | null>;
|
|
34
|
-
changeAudioDevice(id: string):
|
|
34
|
+
changeAudioDevice(id: string): Promise<void>;
|
|
35
35
|
changeRingDevice(id: string): PhoneVoid;
|
|
36
36
|
changeAudioVolume(volume: number): PhoneVoid;
|
|
37
37
|
changeRingVolume(volume: number): PhoneVoid;
|
package/src/domain/Profile.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Line, { LineResponse } from './Line';
|
|
|
2
2
|
import ForwardOption, { FORWARD_KEYS } from './ForwardOption';
|
|
3
3
|
import newFrom from '../utils/new-from';
|
|
4
4
|
import SipLine from './SipLine';
|
|
5
|
+
import Incall, { GenericIncall } from './Incall';
|
|
5
6
|
|
|
6
7
|
export const STATE = {
|
|
7
8
|
AVAILABLE: 'available',
|
|
@@ -74,6 +75,7 @@ type ProfileResponse = {
|
|
|
74
75
|
uuid: string;
|
|
75
76
|
}>;
|
|
76
77
|
online_call_record_enabled: boolean | null | undefined;
|
|
78
|
+
incalls: GenericIncall[];
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
type ProfileArguments = {
|
|
@@ -108,6 +110,7 @@ type ProfileArguments = {
|
|
|
108
110
|
uuid: string;
|
|
109
111
|
}>;
|
|
110
112
|
onlineCallRecordEnabled?: boolean | null | undefined;
|
|
113
|
+
incalls?: GenericIncall[];
|
|
111
114
|
};
|
|
112
115
|
export default class Profile {
|
|
113
116
|
id: string;
|
|
@@ -122,6 +125,8 @@ export default class Profile {
|
|
|
122
125
|
|
|
123
126
|
sipLines: Array<SipLine>;
|
|
124
127
|
|
|
128
|
+
incalls: Array<Incall>;
|
|
129
|
+
|
|
125
130
|
username: string;
|
|
126
131
|
|
|
127
132
|
mobileNumber: string;
|
|
@@ -167,6 +172,7 @@ export default class Profile {
|
|
|
167
172
|
lastName: plain.lastName || plain.lastname || '',
|
|
168
173
|
email: plain.email,
|
|
169
174
|
lines: plain.lines.map(line => Line.parse(line)),
|
|
175
|
+
incalls: plain.incalls,
|
|
170
176
|
username: plain.username,
|
|
171
177
|
mobileNumber: plain.mobile_phone_number || '',
|
|
172
178
|
ringSeconds: plain.ring_seconds,
|
|
@@ -206,6 +212,7 @@ export default class Profile {
|
|
|
206
212
|
sipLines,
|
|
207
213
|
callPickupTargetUsers,
|
|
208
214
|
onlineCallRecordEnabled,
|
|
215
|
+
incalls,
|
|
209
216
|
}: ProfileArguments) {
|
|
210
217
|
this.id = id;
|
|
211
218
|
this.firstName = firstName;
|
|
@@ -226,6 +233,7 @@ export default class Profile {
|
|
|
226
233
|
this.onlineCallRecordEnabled = onlineCallRecordEnabled;
|
|
227
234
|
this.ringSeconds = ringSeconds;
|
|
228
235
|
this.sipLines = sipLines || [];
|
|
236
|
+
this.incalls = incalls?.map(Incall.parse) || [];
|
|
229
237
|
}
|
|
230
238
|
|
|
231
239
|
static getLinesState(lines: Array<Record<string, any>>) {
|
|
@@ -54,6 +54,21 @@ describe('Profile domain', () => {
|
|
|
54
54
|
}],
|
|
55
55
|
endpoint_custom: null,
|
|
56
56
|
}],
|
|
57
|
+
incalls: [{
|
|
58
|
+
id: 1,
|
|
59
|
+
extensions: [{
|
|
60
|
+
id: 3,
|
|
61
|
+
exten: '8001112222',
|
|
62
|
+
context: 'incall',
|
|
63
|
+
}],
|
|
64
|
+
}, {
|
|
65
|
+
id: 2,
|
|
66
|
+
extensions: [{
|
|
67
|
+
id: 4,
|
|
68
|
+
exten: '8001113333',
|
|
69
|
+
context: 'incall',
|
|
70
|
+
}],
|
|
71
|
+
}],
|
|
57
72
|
username: 'john.doe',
|
|
58
73
|
services: {
|
|
59
74
|
dnd: {
|
|
@@ -121,6 +136,21 @@ describe('Profile domain', () => {
|
|
|
121
136
|
context: 'internal',
|
|
122
137
|
}],
|
|
123
138
|
})],
|
|
139
|
+
incalls: [{
|
|
140
|
+
id: 1,
|
|
141
|
+
extensions: [{
|
|
142
|
+
id: 3,
|
|
143
|
+
exten: '8001112222',
|
|
144
|
+
context: 'incall',
|
|
145
|
+
}],
|
|
146
|
+
}, {
|
|
147
|
+
id: 2,
|
|
148
|
+
extensions: [{
|
|
149
|
+
id: 4,
|
|
150
|
+
exten: '8001113333',
|
|
151
|
+
context: 'incall',
|
|
152
|
+
}],
|
|
153
|
+
}],
|
|
124
154
|
mobileNumber: '',
|
|
125
155
|
username: 'john.doe',
|
|
126
156
|
doNotDisturb: false,
|
|
@@ -134,5 +164,7 @@ describe('Profile domain', () => {
|
|
|
134
164
|
}],
|
|
135
165
|
onlineCallRecordEnabled: true,
|
|
136
166
|
}));
|
|
167
|
+
expect(profile.incalls[0].extension).toBe(plain.incalls[0].extensions[0].exten);
|
|
168
|
+
expect(profile.incalls[1].extension).toBe(plain.incalls[1].extensions[0].exten);
|
|
137
169
|
});
|
|
138
170
|
});
|
package/src/domain/types.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Invitation,
|
|
3
|
+
Inviter,
|
|
4
|
+
Session as SipSession,
|
|
5
|
+
UserAgentOptions as sipJsUserAgentOptions,
|
|
6
|
+
} from 'sip.js';
|
|
2
7
|
import { SessionDescriptionHandlerFactoryOptions } from 'sip.js/lib/platform/web';
|
|
3
8
|
import type { IncomingResponse as SipIncomingResponse } from 'sip.js/lib/core/messages/incoming-response';
|
|
4
9
|
import { Transport } from 'sip.js/lib/api';
|
|
@@ -6,10 +11,7 @@ import WazoSessionDescriptionHandler from '../lib/WazoSessionDescriptionHandler'
|
|
|
6
11
|
import { Websocket } from '../simple/Websocket';
|
|
7
12
|
import * as WebSocketClient from '../websocket-client';
|
|
8
13
|
|
|
9
|
-
const {
|
|
10
|
-
SOCKET_EVENTS,
|
|
11
|
-
...OTHER_EVENTS
|
|
12
|
-
} = WebSocketClient;
|
|
14
|
+
const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient;
|
|
13
15
|
|
|
14
16
|
type GenericObject = Record<string, any>;
|
|
15
17
|
|
|
@@ -79,6 +81,12 @@ export type Link = {
|
|
|
79
81
|
href: string;
|
|
80
82
|
rel: string;
|
|
81
83
|
};
|
|
84
|
+
export type ExtensionRelation = {
|
|
85
|
+
id: number;
|
|
86
|
+
exten: string;
|
|
87
|
+
context: string;
|
|
88
|
+
links?: Link[];
|
|
89
|
+
};
|
|
82
90
|
type LocalLine = {
|
|
83
91
|
id: number;
|
|
84
92
|
endpoint_sip: {
|
|
@@ -88,12 +96,7 @@ type LocalLine = {
|
|
|
88
96
|
};
|
|
89
97
|
endpoint_sccp: string | null | undefined;
|
|
90
98
|
endpoint_custom: string | null | undefined;
|
|
91
|
-
extensions:
|
|
92
|
-
id: number;
|
|
93
|
-
exten: string;
|
|
94
|
-
context: string;
|
|
95
|
-
links: Array<Link>;
|
|
96
|
-
}>;
|
|
99
|
+
extensions: ExtensionRelation[];
|
|
97
100
|
};
|
|
98
101
|
export type ConfdUser = {
|
|
99
102
|
id: number;
|
|
@@ -169,7 +172,6 @@ export type ConfdUser = {
|
|
|
169
172
|
// @TODO
|
|
170
173
|
voicemail: string | null | undefined;
|
|
171
174
|
queues: Array<Record<string, any>>; // @TODO
|
|
172
|
-
|
|
173
175
|
};
|
|
174
176
|
export type ListConfdUsersResponse = {
|
|
175
177
|
total: number;
|
|
@@ -193,7 +195,6 @@ export type ListApplicationsResponse = {
|
|
|
193
195
|
export type Node = {
|
|
194
196
|
uuid: UUID;
|
|
195
197
|
calls: Array<Record<string, any>>; // @TODO
|
|
196
|
-
|
|
197
198
|
};
|
|
198
199
|
export type CallNode = GenericObject;
|
|
199
200
|
export type ListNodesResponse = {
|
|
@@ -206,21 +207,26 @@ export type ListCallNodesResponse = {
|
|
|
206
207
|
export type GetTenantResponse = GenericObject;
|
|
207
208
|
export type GetUserResponse = GenericObject;
|
|
208
209
|
export type CTITransfer = {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
flow: string;
|
|
211
|
+
id: string;
|
|
212
|
+
initiator_call: string;
|
|
213
|
+
initiator_uuid: string;
|
|
214
|
+
recipient_call: string;
|
|
215
|
+
status: string;
|
|
216
|
+
transferred_call: string;
|
|
216
217
|
};
|
|
217
218
|
export type UserAgentOptions = sipJsUserAgentOptions & {
|
|
218
|
-
peerConnectionOptions?: Record<string, any
|
|
219
|
-
sessionDescriptionHandlerFactory: (
|
|
219
|
+
peerConnectionOptions?: Record<string, any>;
|
|
220
|
+
sessionDescriptionHandlerFactory: (
|
|
221
|
+
session: SipSession,
|
|
222
|
+
options: SessionDescriptionHandlerFactoryOptions
|
|
223
|
+
) => WazoSessionDescriptionHandler;
|
|
220
224
|
};
|
|
221
|
-
export type UserAgentConfigOverrides = Partial<
|
|
222
|
-
|
|
223
|
-
|
|
225
|
+
export type UserAgentConfigOverrides = Partial<
|
|
226
|
+
UserAgentOptions & {
|
|
227
|
+
traceSip: any;
|
|
228
|
+
}
|
|
229
|
+
>;
|
|
224
230
|
export type MediaConfig = {
|
|
225
231
|
audio: Record<string, any> | boolean;
|
|
226
232
|
video?: Record<string, any> | boolean;
|
|
@@ -252,21 +258,24 @@ export type WebRtcConfig = {
|
|
|
252
258
|
export type IncomingResponse = SipIncomingResponse & { session: any };
|
|
253
259
|
|
|
254
260
|
export type PeerConnection = RTCPeerConnection & {
|
|
255
|
-
getRemoteStreams: () => MediaStream[]
|
|
256
|
-
getLocalStreams: () => MediaStream[]
|
|
257
|
-
onremovestream: (func: any) => void
|
|
258
|
-
addStream: (stream: MediaStream) => void
|
|
259
|
-
sfu: any
|
|
261
|
+
getRemoteStreams: () => MediaStream[];
|
|
262
|
+
getLocalStreams: () => MediaStream[];
|
|
263
|
+
onremovestream: (func: any) => void;
|
|
264
|
+
addStream: (stream: MediaStream) => void;
|
|
265
|
+
sfu: any;
|
|
260
266
|
};
|
|
261
267
|
|
|
262
|
-
export type WazoSession = (Invitation | Inviter) & {
|
|
268
|
+
export type WazoSession = (Invitation | Inviter) & {
|
|
269
|
+
remoteTag?: any;
|
|
270
|
+
callId?: string;
|
|
271
|
+
};
|
|
263
272
|
|
|
264
273
|
export type WazoTransport = Transport & {
|
|
265
|
-
configuration: Record<string, any
|
|
266
|
-
connectPromise: Promise<any
|
|
267
|
-
disconnectPromise: Promise<any
|
|
268
|
-
disconnectResolve: any
|
|
269
|
-
transitionState: any
|
|
274
|
+
configuration: Record<string, any>;
|
|
275
|
+
connectPromise: Promise<any>;
|
|
276
|
+
disconnectPromise: Promise<any>;
|
|
277
|
+
disconnectResolve: any;
|
|
278
|
+
transitionState: any;
|
|
270
279
|
transitioningState: any;
|
|
271
280
|
_ws: any;
|
|
272
281
|
};
|
|
@@ -299,7 +308,7 @@ export type PresenceResponse = {
|
|
|
299
308
|
state: string;
|
|
300
309
|
status: string;
|
|
301
310
|
user_uuid: string;
|
|
302
|
-
last_activity?: string
|
|
311
|
+
last_activity?: string;
|
|
303
312
|
};
|
|
304
313
|
|
|
305
314
|
export type QueryParams = {
|
|
@@ -317,4 +326,6 @@ export type UuidSearchableQueryParams = SearchableQueryParams & {
|
|
|
317
326
|
uuid?: string;
|
|
318
327
|
};
|
|
319
328
|
|
|
320
|
-
export type WebsocketType = Websocket &
|
|
329
|
+
export type WebsocketType = Websocket &
|
|
330
|
+
typeof SOCKET_EVENTS &
|
|
331
|
+
typeof OTHER_EVENTS;
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { default as Contact } from './domain/Contact';
|
|
|
14
14
|
export { default as COUNTRIES } from './domain/Country';
|
|
15
15
|
export { default as Features } from './domain/Features';
|
|
16
16
|
export { default as ForwardOption, FORWARD_KEYS } from './domain/ForwardOption';
|
|
17
|
+
export { default as Incall } from './domain/Incall';
|
|
17
18
|
export { default as Line } from './domain/Line';
|
|
18
19
|
export { default as NotificationOptions } from './domain/NotificationOptions';
|
|
19
20
|
export { default as Profile, STATE as PROFILE_STATE, LINE_STATE } from './domain/Profile';
|
package/src/simple/Auth.ts
CHANGED
|
@@ -160,6 +160,11 @@ export class Auth {
|
|
|
160
160
|
return this._onAuthenticated(rawSession as Session);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
async samlLogIn(samlSessionId: string): Promise<Session | null> {
|
|
164
|
+
const rawSession = await getApiClient().auth.samlLogIn(samlSessionId);
|
|
165
|
+
return this._onAuthenticated(rawSession as Session);
|
|
166
|
+
}
|
|
167
|
+
|
|
163
168
|
async logInViaRefreshToken(refreshToken: string): Promise<Session | null> {
|
|
164
169
|
const rawSession = await getApiClient().auth.refreshToken(refreshToken, '', this.expiration, this.mobile);
|
|
165
170
|
return this._onAuthenticated(rawSession as Session);
|