Skip to content

Commit 066f457

Browse files
committed
Adição de mapeamento de bridges e eventos
1 parent f07f9ed commit 066f457

File tree

8 files changed

+307
-0
lines changed

8 files changed

+307
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export interface Bridge {
2+
id: string;
3+
technology: string;
4+
bridge_type: "mixing" | "holding" | "dtmf_events" | "proxy_media";
5+
bridge_class?: string;
6+
creator?: string;
7+
name?: string;
8+
channels?: string[];
9+
creationtime?: string;
10+
video_mode?: "none" | "talker" | "single";
11+
video_source_id?: string;
12+
}
13+
export interface CreateBridgeRequest {
14+
type: "mixing" | "holding" | "dtmf_events" | "proxy_media";
15+
name?: string;
16+
bridgeId?: string;
17+
}
18+
export interface AddChannelRequest {
19+
channel: string | string[];
20+
role?: "participant" | "announcer";
21+
}
22+
export interface RemoveChannelRequest {
23+
channel: string | string[];
24+
}
25+
export interface PlayMediaRequest {
26+
media: string;
27+
lang?: string;
28+
offsetms?: number;
29+
skipms?: number;
30+
playbackId?: string;
31+
}
32+
export interface BridgePlayback {
33+
id: string;
34+
media_uri: string;
35+
state: "queued" | "playing" | "done" | "failed";
36+
bridge: Bridge;
37+
}
38+
//# sourceMappingURL=bridges.types.d.ts.map

dist/types/ari-client/interfaces/bridges.types.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
import type { ChannelInstance } from "../resources/channels";
2+
import type { PlaybackInstance, Playbacks } from "../resources/playbacks";
3+
import type { Channel } from "./channels.types";
4+
import type { Playback } from "./playbacks.types";
5+
export type ChannelEvent = Extract<WebSocketEvent, {
6+
channel: Channel;
7+
}>;
8+
export type PlaybackEvent = Extract<WebSocketEvent, {
9+
playback: Playback;
10+
}>;
11+
export type WebSocketEventType = "DeviceStateChanged" | "PlaybackStarted" | "PlaybackContinuing" | "PlaybackFinished" | "RecordingStarted" | "RecordingFinished" | "RecordingFailed" | "ApplicationMoveFailed" | "ApplicationReplaced" | "BridgeCreated" | "BridgeDestroyed" | "BridgeMerged" | "BridgeBlindTransfer" | "BridgeAttendedTransfer" | "BridgeVideoSourceChanged" | "ChannelCreated" | "ChannelDestroyed" | "ChannelEnteredBridge" | "ChannelLeftBridge" | "ChannelStateChange" | "ChannelDtmfReceived" | "ChannelDialplan" | "ChannelCallerId" | "ChannelUserevent" | "ChannelHangupRequest" | "ChannelVarset" | "ChannelTalkingStarted" | "ChannelTalkingFinished" | "ChannelHold" | "ChannelUnhold" | "ContactStatusChange" | "EndpointStateChange" | "Dial" | "StasisEnd" | "StasisStart" | "TextMessageReceived" | "ChannelConnectedLine" | "PeerStatusChange";
12+
export type WebSocketEvent = {
13+
type: "ChannelDtmfReceived";
14+
digit: string;
15+
duration_ms: number;
16+
channel: Channel;
17+
instanceChannel?: ChannelInstance;
18+
application: string;
19+
} | {
20+
type: "ChannelDialplan";
21+
channel: Channel;
22+
instanceChannel?: ChannelInstance;
23+
dialplan_app: string;
24+
dialplan_app_data: string;
25+
application: string;
26+
} | {
27+
type: "ChannelVarset";
28+
variable: string;
29+
value: string;
30+
channel?: Channel;
31+
application: string;
32+
instanceChannel?: ChannelInstance;
33+
} | {
34+
type: "StasisStart";
35+
args: string[];
36+
channel: Channel;
37+
instanceChannel?: ChannelInstance;
38+
replace_channel?: Channel;
39+
application: string;
40+
} | {
41+
type: "PlaybackStarted";
42+
playback: Playbacks;
43+
asterisk_id: string;
44+
application: string;
45+
instancePlayback?: PlaybackInstance;
46+
} | {
47+
type: "PlaybackContinuing";
48+
playback: Playbacks;
49+
playbackId: string;
50+
asterisk_id: string;
51+
application: string;
52+
instancePlayback?: PlaybackInstance;
53+
} | {
54+
type: "PlaybackFinished";
55+
playback: Playbacks;
56+
playbackId: string;
57+
asterisk_id: string;
58+
application: string;
59+
instancePlayback?: PlaybackInstance;
60+
} | {
61+
type: "BridgeCreated";
62+
bridgeId: string;
63+
bridgeType: string;
64+
channels: Channel[];
65+
application: string;
66+
} | {
67+
type: "BridgeDestroyed";
68+
bridgeId: string;
69+
application: string;
70+
} | {
71+
type: "ChannelCreated";
72+
channel: Channel;
73+
instanceChannel?: ChannelInstance;
74+
application: string;
75+
} | {
76+
type: "ChannelDestroyed";
77+
channel: Channel;
78+
instanceChannel?: ChannelInstance;
79+
application: string;
80+
} | {
81+
type: "ApplicationMoveFailed";
82+
application: string;
83+
channel: Channel;
84+
instanceChannel?: ChannelInstance;
85+
} | {
86+
type: "RecordingStarted";
87+
recordingId: string;
88+
name: string;
89+
application: string;
90+
} | {
91+
type: "RecordingFinished";
92+
recordingId: string;
93+
name: string;
94+
application: string;
95+
} | {
96+
type: "RecordingFailed";
97+
recordingId: string;
98+
name: string;
99+
reason: string;
100+
application: string;
101+
} | {
102+
type: "DeviceStateChanged";
103+
device: string;
104+
state: string;
105+
application: string;
106+
} | {
107+
type: "BridgeMerged";
108+
bridgeId: string;
109+
bridges: string[];
110+
application: string;
111+
} | {
112+
type: "BridgeBlindTransfer";
113+
bridgeId: string;
114+
channel: Channel;
115+
instanceChannel?: ChannelInstance;
116+
transferee: Channel;
117+
application: string;
118+
} | {
119+
type: "BridgeAttendedTransfer";
120+
bridgeId: string;
121+
transferer: Channel;
122+
transferee: Channel;
123+
destination: Channel;
124+
application: string;
125+
} | {
126+
type: "BridgeVideoSourceChanged";
127+
bridgeId: string;
128+
old_video_source_id?: string;
129+
new_video_source_id: string;
130+
application: string;
131+
} | {
132+
type: "ChannelEnteredBridge";
133+
bridgeId: string;
134+
channel: Channel;
135+
instanceChannel?: ChannelInstance;
136+
application: string;
137+
} | {
138+
type: "ChannelLeftBridge";
139+
bridgeId: string;
140+
channel: Channel;
141+
instanceChannel?: ChannelInstance;
142+
application: string;
143+
} | {
144+
type: "ChannelStateChange";
145+
channel: Channel;
146+
instanceChannel?: ChannelInstance;
147+
application: string;
148+
} | {
149+
type: "ChannelTalkingStarted";
150+
channel: Channel;
151+
instanceChannel?: ChannelInstance;
152+
application: string;
153+
} | {
154+
type: "ChannelTalkingFinished";
155+
channel: Channel;
156+
instanceChannel?: ChannelInstance;
157+
application: string;
158+
} | {
159+
type: "ChannelUnhold";
160+
channel: Channel;
161+
instanceChannel?: ChannelInstance;
162+
application: string;
163+
} | {
164+
type: "ChannelHold";
165+
channel: Channel;
166+
instanceChannel?: ChannelInstance;
167+
application: string;
168+
} | {
169+
type: "ContactStatusChange";
170+
contact_info: Record<string, any>;
171+
status: string;
172+
aor?: string;
173+
application: string;
174+
} | {
175+
type: "EndpointStateChange";
176+
endpoint: Record<string, any>;
177+
state: string;
178+
application: string;
179+
} | {
180+
type: "Dial";
181+
caller: Channel;
182+
peer: Channel;
183+
dialstring?: string;
184+
application: string;
185+
} | {
186+
type: "StasisEnd";
187+
channel: Channel;
188+
instanceChannel?: ChannelInstance;
189+
application: string;
190+
} | {
191+
type: "TextMessageReceived";
192+
to: string;
193+
from: string;
194+
body: string;
195+
variables?: Record<string, any>;
196+
application: string;
197+
} | {
198+
type: "ChannelConnectedLine";
199+
channel: Channel;
200+
instanceChannel?: ChannelInstance;
201+
application: string;
202+
} | {
203+
type: "ChannelHangupRequest";
204+
cause: number;
205+
soft: boolean;
206+
channel: Channel;
207+
instanceChannel?: ChannelInstance;
208+
application: string;
209+
} | {
210+
type: "PeerStatusChange";
211+
peer: string;
212+
peer_status: string;
213+
application: string;
214+
} | {
215+
type: string;
216+
[key: string]: any;
217+
};
218+
//# sourceMappingURL=events.types.d.ts.map

dist/types/ari-client/interfaces/events.types.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { AriClient } from "../ariClient";
2+
export declare abstract class BaseResource {
3+
protected readonly client: AriClient;
4+
private readonly emitter;
5+
private readonly resourceId;
6+
protected constructor(client: AriClient, resourceId: string);
7+
/**
8+
* Registra um listener para eventos do recurso.
9+
* @param event O tipo de evento a escutar.
10+
* @param callback Função callback a ser chamada quando o evento ocorre.
11+
*/
12+
on<T extends string>(event: T, callback: (data: any) => void): void;
13+
/**
14+
* Remove um listener para eventos do recurso.
15+
* @param event O tipo de evento.
16+
* @param callback Função callback a ser removida.
17+
*/
18+
removeListener<T extends string>(event: T, callback: (data: any) => void): void;
19+
/**
20+
* Remove todos os listeners de um tipo de evento.
21+
* @param event O tipo de evento.
22+
*/
23+
removeAllListeners<T extends string>(event: T): void;
24+
/**
25+
* Emite um evento específico para este recurso.
26+
* @param event O tipo de evento.
27+
* @param data Os dados associados ao evento.
28+
*/
29+
emit<T extends string>(event: T, data: any): void;
30+
}
31+
//# sourceMappingURL=baseResource.d.ts.map

dist/types/ari-client/resources/baseResource.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/ari-client/utils.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { Channel, WebSocketEvent } from "./interfaces";
2+
export declare function toQueryParams<T>(options: T): string;
3+
export declare function isPlaybackEvent(event: WebSocketEvent, playbackId?: string): event is Extract<WebSocketEvent, {
4+
playbackId: string;
5+
}>;
6+
/**
7+
* Verifica se um evento pertence a um canal e opcionalmente valida o ID do canal.
8+
* @param event O evento WebSocket a ser validado.
9+
* @param channelId Opcional. O ID do canal a ser validado.
10+
* @returns Verdadeiro se o evento é relacionado a um canal (e ao ID, se fornecido).
11+
*/
12+
export declare function isChannelEvent(event: WebSocketEvent, channelId?: string): event is Extract<WebSocketEvent, {
13+
channel: Channel;
14+
}>;
15+
export declare const channelEvents: string[];
16+
//# sourceMappingURL=utils.d.ts.map

dist/types/ari-client/utils.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)