@ipcom/asterisk-ari 0.0.142 → 0.0.144

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/dist/esm/index.js CHANGED
@@ -598,7 +598,9 @@ var BaseClient = class {
598
598
  this.username = username;
599
599
  this.password = password;
600
600
  if (!/^https?:\/\/.+/.test(baseUrl)) {
601
- throw new Error("Invalid base URL. It must start with http:// or https://");
601
+ throw new Error(
602
+ "Invalid base URL. It must start with http:// or https://"
603
+ );
602
604
  }
603
605
  this.client = axios.create({
604
606
  baseURL: baseUrl,
@@ -609,7 +611,6 @@ var BaseClient = class {
609
611
  }
610
612
  });
611
613
  this.addInterceptors();
612
- console.log(`BaseClient initialized for ${baseUrl}`);
613
614
  }
614
615
  client;
615
616
  /**
@@ -634,7 +635,6 @@ var BaseClient = class {
634
635
  addInterceptors() {
635
636
  this.client.interceptors.request.use(
636
637
  (config) => {
637
- console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
638
638
  return config;
639
639
  },
640
640
  (error) => {
@@ -645,7 +645,6 @@ var BaseClient = class {
645
645
  );
646
646
  this.client.interceptors.response.use(
647
647
  (response) => {
648
- console.log(`[Response] ${response.status} ${response.config.url}`);
649
648
  return response;
650
649
  },
651
650
  (error) => {
@@ -768,7 +767,6 @@ var BaseClient = class {
768
767
  ...this.client.defaults.headers.common,
769
768
  ...headers
770
769
  };
771
- console.log("Updated client headers");
772
770
  }
773
771
  /**
774
772
  * Gets the current request timeout setting.
@@ -781,7 +779,6 @@ var BaseClient = class {
781
779
  */
782
780
  setTimeout(timeout) {
783
781
  this.client.defaults.timeout = timeout;
784
- console.log(`Updated timeout to ${timeout}ms`);
785
782
  }
786
783
  };
787
784
 
@@ -1074,7 +1071,6 @@ var ChannelInstance = class {
1074
1071
  this.client = client;
1075
1072
  this.baseClient = baseClient;
1076
1073
  this.id = channelId || `channel-${Date.now()}`;
1077
- console.log(`Channel instance initialized with ID: ${this.id}`);
1078
1074
  }
1079
1075
  eventEmitter = new EventEmitter();
1080
1076
  channelData = null;
@@ -1092,7 +1088,6 @@ var ChannelInstance = class {
1092
1088
  }
1093
1089
  };
1094
1090
  this.eventEmitter.on(event, wrappedListener);
1095
- console.log(`Event listener registered for ${event} on channel ${this.id}`);
1096
1091
  }
1097
1092
  /**
1098
1093
  * Registers a one-time event listener
@@ -1107,9 +1102,6 @@ var ChannelInstance = class {
1107
1102
  }
1108
1103
  };
1109
1104
  this.eventEmitter.once(event, wrappedListener);
1110
- console.log(
1111
- `One-time event listener registered for ${event} on channel ${this.id}`
1112
- );
1113
1105
  }
1114
1106
  /**
1115
1107
  * Removes event listener(s) for a specific WebSocket event type.
@@ -1126,12 +1118,8 @@ var ChannelInstance = class {
1126
1118
  }
1127
1119
  if (listener) {
1128
1120
  this.eventEmitter.off(event, listener);
1129
- console.log(
1130
- `Specific listener removed for ${event} on channel ${this.id}`
1131
- );
1132
1121
  } else {
1133
1122
  this.eventEmitter.removeAllListeners(event);
1134
- console.log(`All listeners removed for ${event} on channel ${this.id}`);
1135
1123
  }
1136
1124
  }
1137
1125
  /**
@@ -1144,7 +1132,6 @@ var ChannelInstance = class {
1144
1132
  }
1145
1133
  if ("channel" in event && event.channel?.id === this.id) {
1146
1134
  this.eventEmitter.emit(event.type, event);
1147
- console.log(`Event ${event.type} emitted for channel ${this.id}`);
1148
1135
  }
1149
1136
  }
1150
1137
  /**
@@ -1154,7 +1141,6 @@ var ChannelInstance = class {
1154
1141
  * @return {void} This method does not return a value.
1155
1142
  */
1156
1143
  removeAllListeners() {
1157
- console.log(`Removendo todos os listeners para o canal ${this.id}`);
1158
1144
  this.eventEmitter.removeAllListeners();
1159
1145
  }
1160
1146
  /**
@@ -1163,7 +1149,6 @@ var ChannelInstance = class {
1163
1149
  async answer() {
1164
1150
  try {
1165
1151
  await this.baseClient.post(`/channels/${this.id}/answer`);
1166
- console.log(`Channel ${this.id} answered`);
1167
1152
  } catch (error) {
1168
1153
  const message = getErrorMessage(error);
1169
1154
  console.error(`Error answering channel ${this.id}:`, message);
@@ -1186,9 +1171,6 @@ var ChannelInstance = class {
1186
1171
  "/channels",
1187
1172
  data
1188
1173
  );
1189
- console.log(
1190
- `Channel originated successfully with ID: ${this.channelData.id}`
1191
- );
1192
1174
  return this.channelData;
1193
1175
  } catch (error) {
1194
1176
  const message = getErrorMessage(error);
@@ -1205,7 +1187,6 @@ var ChannelInstance = class {
1205
1187
  }
1206
1188
  try {
1207
1189
  if (!this.channelData) {
1208
- console.log("Initializing channel details...");
1209
1190
  this.channelData = await this.getDetails();
1210
1191
  }
1211
1192
  const playback = this.client.Playback(playbackId || v4_default());
@@ -1213,7 +1194,6 @@ var ChannelInstance = class {
1213
1194
  `/channels/${this.id}/play/${playback.id}`,
1214
1195
  options
1215
1196
  );
1216
- console.log(`Media playback started on channel ${this.id}`);
1217
1197
  return playback;
1218
1198
  } catch (error) {
1219
1199
  const message = getErrorMessage(error);
@@ -1236,7 +1216,6 @@ var ChannelInstance = class {
1236
1216
  `/channels/${this.id}`
1237
1217
  );
1238
1218
  this.channelData = details;
1239
- console.log(`Retrieved channel details for ${this.id}`);
1240
1219
  return details;
1241
1220
  } catch (error) {
1242
1221
  const message = getErrorMessage(error);
@@ -1283,7 +1262,6 @@ var ChannelInstance = class {
1283
1262
  */
1284
1263
  async hangup() {
1285
1264
  if (!this.channelData) {
1286
- console.log("Canal n\xE3o inicializado, buscando detalhes...");
1287
1265
  this.channelData = await this.getDetails();
1288
1266
  }
1289
1267
  if (!this.channelData?.id) {
@@ -1472,16 +1450,13 @@ var Channels = class {
1472
1450
  if (!id) {
1473
1451
  const instance = new ChannelInstance(this.client, this.baseClient);
1474
1452
  this.channelInstances.set(instance.id, instance);
1475
- console.log(`New channel instance created with ID: ${instance.id}`);
1476
1453
  return instance;
1477
1454
  }
1478
1455
  if (!this.channelInstances.has(id)) {
1479
1456
  const instance = new ChannelInstance(this.client, this.baseClient, id);
1480
1457
  this.channelInstances.set(id, instance);
1481
- console.log(`New channel instance created with provided ID: ${id}`);
1482
1458
  return instance;
1483
1459
  }
1484
- console.log(`Returning existing channel instance: ${id}`);
1485
1460
  return this.channelInstances.get(id);
1486
1461
  } catch (error) {
1487
1462
  const message = getErrorMessage(error);
@@ -1498,12 +1473,10 @@ var Channels = class {
1498
1473
  */
1499
1474
  async get(id) {
1500
1475
  try {
1501
- if (id) {
1476
+ if (!id) {
1502
1477
  throw new Error("No channel ID associated with this instance");
1503
1478
  }
1504
- const details = await this.baseClient.get(`/channels/${id}`);
1505
- console.log(`Retrieved channel details for ${id}`);
1506
- return details;
1479
+ return await this.baseClient.get(`/channels/${id}`);
1507
1480
  } catch (error) {
1508
1481
  const message = getErrorMessage(error);
1509
1482
  console.error(`Error retrieving channel details for ${id}:`, message);
@@ -1521,7 +1494,6 @@ var Channels = class {
1521
1494
  const instance = this.channelInstances.get(channelId);
1522
1495
  instance?.removeAllListeners();
1523
1496
  this.channelInstances.delete(channelId);
1524
- console.log(`Channel instance removed: ${channelId}`);
1525
1497
  } else {
1526
1498
  console.warn(`Attempt to remove non-existent instance: ${channelId}`);
1527
1499
  }
@@ -1538,9 +1510,6 @@ var Channels = class {
1538
1510
  const instance = this.channelInstances.get(event.channel.id);
1539
1511
  if (instance) {
1540
1512
  instance.emitEvent(event);
1541
- console.log(
1542
- `Event propagated to channel ${event.channel.id}: ${event.type}`
1543
- );
1544
1513
  } else {
1545
1514
  console.warn(`No instance found for channel ${event.channel.id}`);
1546
1515
  }
@@ -1554,9 +1523,7 @@ var Channels = class {
1554
1523
  throw new Error("Endpoint is required for channel origination");
1555
1524
  }
1556
1525
  try {
1557
- const channel = await this.baseClient.post("/channels", data);
1558
- console.log(`Channel originated successfully with ID: ${channel.id}`);
1559
- return channel;
1526
+ return await this.baseClient.post("/channels", data);
1560
1527
  } catch (error) {
1561
1528
  const message = getErrorMessage(error);
1562
1529
  console.error(`Error originating channel:`, message);
@@ -1572,7 +1539,6 @@ var Channels = class {
1572
1539
  if (!Array.isArray(channels)) {
1573
1540
  throw new Error("API response for /channels is not an array");
1574
1541
  }
1575
- console.log(`Retrieved ${channels.length} active channels`);
1576
1542
  return channels;
1577
1543
  } catch (error) {
1578
1544
  const message = getErrorMessage(error);
@@ -2026,7 +1992,6 @@ var PlaybackInstance = class {
2026
1992
  this.baseClient = baseClient;
2027
1993
  this.playbackId = playbackId;
2028
1994
  this.id = playbackId;
2029
- console.log(`PlaybackInstance initialized with ID: ${this.id}`);
2030
1995
  }
2031
1996
  eventEmitter = new EventEmitter2();
2032
1997
  playbackData = null;
@@ -2047,9 +2012,6 @@ var PlaybackInstance = class {
2047
2012
  }
2048
2013
  };
2049
2014
  this.eventEmitter.on(event, wrappedListener);
2050
- console.log(
2051
- `Event listener registered for ${event} on playback ${this.id}`
2052
- );
2053
2015
  }
2054
2016
  /**
2055
2017
  * Registers a one-time event listener for a specific WebSocket event type.
@@ -2067,9 +2029,6 @@ var PlaybackInstance = class {
2067
2029
  }
2068
2030
  };
2069
2031
  this.eventEmitter.once(event, wrappedListener);
2070
- console.log(
2071
- `One-time event listener registered for ${event} on playback ${this.id}`
2072
- );
2073
2032
  }
2074
2033
  /**
2075
2034
  * Removes event listener(s) for a specific WebSocket event type.
@@ -2083,12 +2042,8 @@ var PlaybackInstance = class {
2083
2042
  }
2084
2043
  if (listener) {
2085
2044
  this.eventEmitter.off(event, listener);
2086
- console.log(
2087
- `Specific listener removed for ${event} on playback ${this.id}`
2088
- );
2089
2045
  } else {
2090
2046
  this.eventEmitter.removeAllListeners(event);
2091
- console.log(`All listeners removed for ${event} on playback ${this.id}`);
2092
2047
  }
2093
2048
  }
2094
2049
  /**
@@ -2103,7 +2058,6 @@ var PlaybackInstance = class {
2103
2058
  }
2104
2059
  if ("playback" in event && event.playback?.id === this.id) {
2105
2060
  this.eventEmitter.emit(event.type, event);
2106
- console.log(`Event ${event.type} emitted for playback ${this.id}`);
2107
2061
  }
2108
2062
  }
2109
2063
  /**
@@ -2120,7 +2074,6 @@ var PlaybackInstance = class {
2120
2074
  this.playbackData = await this.baseClient.get(
2121
2075
  `/playbacks/${this.id}`
2122
2076
  );
2123
- console.log(`Retrieved playback data for ${this.id}`);
2124
2077
  return this.playbackData;
2125
2078
  } catch (error) {
2126
2079
  const message = getErrorMessage2(error);
@@ -2142,9 +2095,6 @@ var PlaybackInstance = class {
2142
2095
  await this.baseClient.post(
2143
2096
  `/playbacks/${this.id}/control?operation=${operation}`
2144
2097
  );
2145
- console.log(
2146
- `Operation ${operation} executed successfully on playback ${this.id}`
2147
- );
2148
2098
  } catch (error) {
2149
2099
  const message = getErrorMessage2(error);
2150
2100
  console.error(`Error controlling playback ${this.id}:`, message);
@@ -2162,7 +2112,6 @@ var PlaybackInstance = class {
2162
2112
  }
2163
2113
  try {
2164
2114
  await this.baseClient.delete(`/playbacks/${this.id}`);
2165
- console.log(`Playback ${this.id} stopped successfully`);
2166
2115
  } catch (error) {
2167
2116
  const message = getErrorMessage2(error);
2168
2117
  console.error(`Error stopping playback ${this.id}:`, message);
@@ -2174,7 +2123,6 @@ var PlaybackInstance = class {
2174
2123
  */
2175
2124
  removeAllListeners() {
2176
2125
  this.eventEmitter.removeAllListeners();
2177
- console.log(`All listeners removed from playback ${this.id}`);
2178
2126
  }
2179
2127
  /**
2180
2128
  * Checks if the playback instance has any listeners for a specific event.
@@ -2212,16 +2160,13 @@ var Playbacks = class {
2212
2160
  if (!id) {
2213
2161
  const instance = new PlaybackInstance(this.client, this.baseClient);
2214
2162
  this.playbackInstances.set(instance.id, instance);
2215
- console.log(`New playback instance created with ID: ${instance.id}`);
2216
2163
  return instance;
2217
2164
  }
2218
2165
  if (!this.playbackInstances.has(id)) {
2219
2166
  const instance = new PlaybackInstance(this.client, this.baseClient, id);
2220
2167
  this.playbackInstances.set(id, instance);
2221
- console.log(`New playback instance created with provided ID: ${id}`);
2222
2168
  return instance;
2223
2169
  }
2224
- console.log(`Returning existing playback instance: ${id}`);
2225
2170
  return this.playbackInstances.get(id);
2226
2171
  } catch (error) {
2227
2172
  const message = getErrorMessage2(error);
@@ -2242,7 +2187,6 @@ var Playbacks = class {
2242
2187
  const instance = this.playbackInstances.get(playbackId);
2243
2188
  instance?.removeAllListeners();
2244
2189
  this.playbackInstances.delete(playbackId);
2245
- console.log(`Playback instance removed: ${playbackId}`);
2246
2190
  } else {
2247
2191
  console.warn(`Attempt to remove non-existent instance: ${playbackId}`);
2248
2192
  }
@@ -2253,16 +2197,12 @@ var Playbacks = class {
2253
2197
  */
2254
2198
  propagateEventToPlayback(event) {
2255
2199
  if (!event) {
2256
- console.warn("Invalid WebSocket event received");
2257
2200
  return;
2258
2201
  }
2259
2202
  if ("playback" in event && event.playback?.id) {
2260
2203
  const instance = this.playbackInstances.get(event.playback.id);
2261
2204
  if (instance) {
2262
2205
  instance.emitEvent(event);
2263
- console.log(
2264
- `Event propagated to playback ${event.playback.id}: ${event.type}`
2265
- );
2266
2206
  } else {
2267
2207
  console.warn(`No instance found for playback ${event.playback.id}`);
2268
2208
  }
@@ -2299,7 +2239,6 @@ var Playbacks = class {
2299
2239
  try {
2300
2240
  const playback = this.Playback({ id: playbackId });
2301
2241
  await playback.control(operation);
2302
- console.log(`Operation ${operation} executed on playback ${playbackId}`);
2303
2242
  } catch (error) {
2304
2243
  const message = getErrorMessage2(error);
2305
2244
  console.error(`Error controlling playback ${playbackId}:`, message);
@@ -2318,7 +2257,6 @@ var Playbacks = class {
2318
2257
  try {
2319
2258
  const playback = this.Playback({ id: playbackId });
2320
2259
  await playback.stop();
2321
- console.log(`Playback ${playbackId} stopped`);
2322
2260
  } catch (error) {
2323
2261
  const message = getErrorMessage2(error);
2324
2262
  console.error(`Error stopping playback ${playbackId}:`, message);
@@ -2501,9 +2439,11 @@ var WebSocketClient = class extends EventEmitter3 {
2501
2439
  event.instancePlayback = instancePlayback;
2502
2440
  }
2503
2441
  this.emit(event.type, event);
2504
- console.log(`Event processed: ${event.type}`);
2505
2442
  } catch (error) {
2506
- console.error("Error processing WebSocket message:", error instanceof Error ? error.message : "Unknown error");
2443
+ console.error(
2444
+ "Error processing WebSocket message:",
2445
+ error instanceof Error ? error.message : "Unknown error"
2446
+ );
2507
2447
  this.emit("error", new Error("Failed to decode WebSocket message"));
2508
2448
  }
2509
2449
  }
@@ -2516,13 +2456,15 @@ var WebSocketClient = class extends EventEmitter3 {
2516
2456
  this.isReconnecting = true;
2517
2457
  console.log("Initiating reconnection attempt...");
2518
2458
  this.removeAllListeners();
2519
- (0, import_exponential_backoff.backOff)(() => this.initializeWebSocket(wsUrl), this.backOffOptions).catch((error) => {
2520
- console.error(
2521
- "Failed to reconnect after multiple attempts:",
2522
- error instanceof Error ? error.message : "Unknown error"
2523
- );
2524
- this.emit("reconnectFailed", error);
2525
- });
2459
+ (0, import_exponential_backoff.backOff)(() => this.initializeWebSocket(wsUrl), this.backOffOptions).catch(
2460
+ (error) => {
2461
+ console.error(
2462
+ "Failed to reconnect after multiple attempts:",
2463
+ error instanceof Error ? error.message : "Unknown error"
2464
+ );
2465
+ this.emit("reconnectFailed", error);
2466
+ }
2467
+ );
2526
2468
  }
2527
2469
  /**
2528
2470
  * Manually closes the WebSocket connection.