@ipcom/asterisk-ari 0.0.139 → 0.0.140
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 +254 -0
- package/dist/cjs/index.cjs +990 -267
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/esm/index.js +993 -268
- package/dist/esm/index.js.map +3 -3
- package/dist/types/ari-client/ariClient.d.ts +64 -15
- package/dist/types/ari-client/ariClient.d.ts.map +1 -1
- package/dist/types/ari-client/baseClient.d.ts +55 -22
- package/dist/types/ari-client/baseClient.d.ts.map +1 -1
- package/dist/types/ari-client/resources/channels.d.ts +338 -47
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/resources/playbacks.d.ts +92 -19
- package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
- package/dist/types/ari-client/utils.d.ts.map +1 -1
- package/dist/types/ari-client/websocketClient.d.ts +44 -13
- package/dist/types/ari-client/websocketClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +26 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -6,51 +6,100 @@ import { type ChannelInstance, Channels } from "./resources/channels.js";
|
|
|
6
6
|
import { Endpoints } from "./resources/endpoints";
|
|
7
7
|
import { type PlaybackInstance, Playbacks } from "./resources/playbacks";
|
|
8
8
|
import { Sounds } from "./resources/sounds";
|
|
9
|
+
/**
|
|
10
|
+
* Main client class for interacting with the Asterisk REST Interface (ARI).
|
|
11
|
+
* Provides access to various ARI resources and WebSocket event handling capabilities.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const client = new AriClient({
|
|
16
|
+
* host: 'localhost',
|
|
17
|
+
* port: 8088,
|
|
18
|
+
* username: 'user',
|
|
19
|
+
* password: 'secret'
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
9
23
|
export declare class AriClient {
|
|
10
|
-
private config;
|
|
24
|
+
private readonly config;
|
|
11
25
|
private readonly baseClient;
|
|
12
26
|
private webSocketClient?;
|
|
13
|
-
channels: Channels;
|
|
14
|
-
endpoints: Endpoints;
|
|
15
|
-
applications: Applications;
|
|
16
|
-
playbacks: Playbacks;
|
|
17
|
-
sounds: Sounds;
|
|
18
|
-
asterisk: Asterisk;
|
|
19
|
-
bridges: Bridges;
|
|
27
|
+
readonly channels: Channels;
|
|
28
|
+
readonly endpoints: Endpoints;
|
|
29
|
+
readonly applications: Applications;
|
|
30
|
+
readonly playbacks: Playbacks;
|
|
31
|
+
readonly sounds: Sounds;
|
|
32
|
+
readonly asterisk: Asterisk;
|
|
33
|
+
readonly bridges: Bridges;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new instance of the ARI client.
|
|
36
|
+
*
|
|
37
|
+
* @param {AriClientConfig} config - Configuration options for the ARI client
|
|
38
|
+
* @throws {Error} If required configuration parameters are missing
|
|
39
|
+
*/
|
|
20
40
|
constructor(config: AriClientConfig);
|
|
21
41
|
/**
|
|
22
|
-
*
|
|
42
|
+
* Initializes a WebSocket connection for receiving events.
|
|
43
|
+
*
|
|
44
|
+
* @param {string[]} apps - List of application names to subscribe to
|
|
45
|
+
* @param {WebSocketEventType[]} [subscribedEvents] - Optional list of specific event types to subscribe to
|
|
46
|
+
* @returns {Promise<void>} Resolves when connection is established
|
|
47
|
+
* @throws {Error} If connection fails or if WebSocket is already connected
|
|
23
48
|
*/
|
|
24
49
|
connectWebSocket(apps: string[], subscribedEvents?: WebSocketEventType[]): Promise<void>;
|
|
25
50
|
/**
|
|
26
|
-
*
|
|
51
|
+
* Registers an event listener for WebSocket events.
|
|
52
|
+
*
|
|
53
|
+
* @param {T} event - The event type to listen for
|
|
54
|
+
* @param {Function} listener - Callback function for handling the event
|
|
55
|
+
* @throws {Error} If WebSocket is not connected
|
|
27
56
|
*/
|
|
28
57
|
on<T extends WebSocketEvent["type"]>(event: T, listener: (data: Extract<WebSocketEvent, {
|
|
29
58
|
type: T;
|
|
30
59
|
}>) => void): void;
|
|
31
60
|
/**
|
|
32
|
-
*
|
|
61
|
+
* Registers a one-time event listener for WebSocket events.
|
|
62
|
+
*
|
|
63
|
+
* @param {T} event - The event type to listen for
|
|
64
|
+
* @param {Function} listener - Callback function for handling the event
|
|
65
|
+
* @throws {Error} If WebSocket is not connected
|
|
33
66
|
*/
|
|
34
67
|
once<T extends WebSocketEvent["type"]>(event: T, listener: (data: Extract<WebSocketEvent, {
|
|
35
68
|
type: T;
|
|
36
69
|
}>) => void): void;
|
|
37
70
|
/**
|
|
38
|
-
*
|
|
71
|
+
* Removes an event listener for WebSocket events.
|
|
72
|
+
*
|
|
73
|
+
* @param {T} event - The event type to remove listener for
|
|
74
|
+
* @param {Function} listener - The listener function to remove
|
|
39
75
|
*/
|
|
40
76
|
off<T extends WebSocketEvent["type"]>(event: T, listener: (data: Extract<WebSocketEvent, {
|
|
41
77
|
type: T;
|
|
42
78
|
}>) => void): void;
|
|
43
79
|
/**
|
|
44
|
-
*
|
|
80
|
+
* Closes the WebSocket connection if one exists.
|
|
45
81
|
*/
|
|
46
82
|
closeWebSocket(): void;
|
|
47
83
|
/**
|
|
48
|
-
*
|
|
84
|
+
* Creates or retrieves a Channel instance.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} [channelId] - Optional ID of an existing channel
|
|
87
|
+
* @returns {ChannelInstance} A new or existing channel instance
|
|
49
88
|
*/
|
|
50
89
|
Channel(channelId?: string): ChannelInstance;
|
|
51
90
|
/**
|
|
52
|
-
*
|
|
91
|
+
* Creates or retrieves a Playback instance.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} [playbackId] - Optional ID of an existing playback
|
|
94
|
+
* @param {string} [_app] - Optional application name (deprecated)
|
|
95
|
+
* @returns {PlaybackInstance} A new or existing playback instance
|
|
53
96
|
*/
|
|
54
97
|
Playback(playbackId?: string, _app?: string): PlaybackInstance;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the current WebSocket connection status.
|
|
100
|
+
*
|
|
101
|
+
* @returns {boolean} True if WebSocket is connected, false otherwise
|
|
102
|
+
*/
|
|
103
|
+
isWebSocketConnected(): boolean;
|
|
55
104
|
}
|
|
56
105
|
//# sourceMappingURL=ariClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ariClient.d.ts","sourceRoot":"","sources":["../../../src/ari-client/ariClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"ariClient.d.ts","sourceRoot":"","sources":["../../../src/ari-client/ariClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,E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,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KAAK,IAAI,GAC/D,IAAI;IASP;;OAEG;IACI,cAAc,IAAI,IAAI;IAU7B;;;;;OAKG;IACI,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe;IAInD;;;;;;OAMG;IACI,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB;IAIrE;;;;OAIG;IACI,oBAAoB,IAAI,OAAO;CAGvC"}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { type AxiosRequestConfig } from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* BaseClient handles HTTP communications with the ARI server.
|
|
4
|
+
* Provides methods for making HTTP requests and manages authentication and error handling.
|
|
5
|
+
*/
|
|
2
6
|
export declare class BaseClient {
|
|
3
|
-
private baseUrl;
|
|
4
|
-
private username;
|
|
5
|
-
private password;
|
|
6
|
-
private client;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
private readonly username;
|
|
9
|
+
private readonly password;
|
|
10
|
+
private readonly client;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new BaseClient instance.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} baseUrl - The base URL for the API
|
|
15
|
+
* @param {string} username - Username for authentication
|
|
16
|
+
* @param {string} password - Password for authentication
|
|
17
|
+
* @param {number} [timeout=5000] - Request timeout in milliseconds
|
|
18
|
+
* @throws {Error} If the base URL format is invalid
|
|
19
|
+
*/
|
|
7
20
|
constructor(baseUrl: string, username: string, password: string, timeout?: number);
|
|
21
|
+
/**
|
|
22
|
+
* Gets the base URL of the client.
|
|
23
|
+
*/
|
|
8
24
|
getBaseUrl(): string;
|
|
9
25
|
/**
|
|
10
|
-
*
|
|
26
|
+
* Gets the configured credentials.
|
|
11
27
|
*/
|
|
12
28
|
getCredentials(): {
|
|
13
29
|
baseUrl: string;
|
|
@@ -15,45 +31,62 @@ export declare class BaseClient {
|
|
|
15
31
|
password: string;
|
|
16
32
|
};
|
|
17
33
|
/**
|
|
18
|
-
* Adds interceptors to the Axios instance.
|
|
34
|
+
* Adds request and response interceptors to the Axios instance.
|
|
19
35
|
*/
|
|
20
36
|
private addInterceptors;
|
|
21
37
|
/**
|
|
22
38
|
* Executes a GET request.
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
39
|
+
*
|
|
40
|
+
* @param path - API endpoint path
|
|
41
|
+
* @param config - Optional Axios request configuration
|
|
42
|
+
* @returns Promise with the response data
|
|
25
43
|
*/
|
|
26
44
|
get<T>(path: string, config?: AxiosRequestConfig): Promise<T>;
|
|
27
45
|
/**
|
|
28
46
|
* Executes a POST request.
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
47
|
+
*
|
|
48
|
+
* @param path - API endpoint path
|
|
49
|
+
* @param data - Request payload
|
|
50
|
+
* @param config - Optional Axios request configuration
|
|
51
|
+
* @returns Promise with the response data
|
|
32
52
|
*/
|
|
33
|
-
post<T>(path: string, data?:
|
|
53
|
+
post<T, D = unknown>(path: string, data?: D, config?: AxiosRequestConfig): Promise<T>;
|
|
34
54
|
/**
|
|
35
55
|
* Executes a PUT request.
|
|
36
|
-
*
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
56
|
+
*
|
|
57
|
+
* @param path - API endpoint path
|
|
58
|
+
* @param data - Request payload
|
|
59
|
+
* @param config - Optional Axios request configuration
|
|
60
|
+
* @returns Promise with the response data
|
|
39
61
|
*/
|
|
40
|
-
put<T>(path: string, data:
|
|
62
|
+
put<T, D = unknown>(path: string, data: D, config?: AxiosRequestConfig): Promise<T>;
|
|
41
63
|
/**
|
|
42
64
|
* Executes a DELETE request.
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
65
|
+
*
|
|
66
|
+
* @param path - API endpoint path
|
|
67
|
+
* @param config - Optional Axios request configuration
|
|
68
|
+
* @returns Promise with the response data
|
|
45
69
|
*/
|
|
46
70
|
delete<T>(path: string, config?: AxiosRequestConfig): Promise<T>;
|
|
47
71
|
/**
|
|
48
|
-
* Handles
|
|
49
|
-
|
|
72
|
+
* Handles and formats error messages from various error types.
|
|
73
|
+
*/
|
|
74
|
+
private getErrorMessage;
|
|
75
|
+
/**
|
|
76
|
+
* Handles errors from HTTP requests.
|
|
50
77
|
*/
|
|
51
78
|
private handleRequestError;
|
|
52
79
|
/**
|
|
53
80
|
* Sets custom headers for the client instance.
|
|
54
|
-
* Useful for adding dynamic tokens or specific API headers.
|
|
55
|
-
* @param headers - Headers to merge with existing configuration.
|
|
56
81
|
*/
|
|
57
82
|
setHeaders(headers: Record<string, string>): void;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the current request timeout setting.
|
|
85
|
+
*/
|
|
86
|
+
getTimeout(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Updates the request timeout setting.
|
|
89
|
+
*/
|
|
90
|
+
setTimeout(timeout: number): void;
|
|
58
91
|
}
|
|
59
92
|
//# sourceMappingURL=baseClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseClient.d.ts","sourceRoot":"","sources":["../../../src/ari-client/baseClient.ts"],"names":[],"mappings":"AAAA,OAAc,
|
|
1
|
+
{"version":3,"file":"baseClient.d.ts","sourceRoot":"","sources":["../../../src/ari-client/baseClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAEZ,KAAK,kBAAkB,EAExB,MAAM,OAAO,CAAC;AAiBf;;;GAGG;AACH,qBAAa,UAAU;IAajB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAd7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;;;;;;;OAQG;gBAEkB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ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