@ipcom/asterisk-ari 0.0.140 → 0.0.141

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
@@ -1005,6 +1005,7 @@ var Bridges = class {
1005
1005
 
1006
1006
  // src/ari-client/resources/channels.ts
1007
1007
  import { EventEmitter } from "events";
1008
+ import { isAxiosError as isAxiosError2 } from "axios";
1008
1009
 
1009
1010
  // node_modules/uuid/dist/esm/stringify.js
1010
1011
  var byteToHex = [];
@@ -1059,7 +1060,6 @@ function toQueryParams2(options) {
1059
1060
  }
1060
1061
 
1061
1062
  // src/ari-client/resources/channels.ts
1062
- import { isAxiosError as isAxiosError2 } from "axios";
1063
1063
  var getErrorMessage = (error) => {
1064
1064
  if (isAxiosError2(error)) {
1065
1065
  return error.response?.data?.message || error.message || "An axios error occurred";
@@ -1107,7 +1107,9 @@ var ChannelInstance = class {
1107
1107
  }
1108
1108
  };
1109
1109
  this.eventEmitter.once(event, wrappedListener);
1110
- console.log(`One-time event listener registered for ${event} on channel ${this.id}`);
1110
+ console.log(
1111
+ `One-time event listener registered for ${event} on channel ${this.id}`
1112
+ );
1111
1113
  }
1112
1114
  /**
1113
1115
  * Removes event listener(s) for a specific WebSocket event type.
@@ -1124,7 +1126,9 @@ var ChannelInstance = class {
1124
1126
  }
1125
1127
  if (listener) {
1126
1128
  this.eventEmitter.off(event, listener);
1127
- console.log(`Specific listener removed for ${event} on channel ${this.id}`);
1129
+ console.log(
1130
+ `Specific listener removed for ${event} on channel ${this.id}`
1131
+ );
1128
1132
  } else {
1129
1133
  this.eventEmitter.removeAllListeners(event);
1130
1134
  console.log(`All listeners removed for ${event} on channel ${this.id}`);
@@ -1178,8 +1182,13 @@ var ChannelInstance = class {
1178
1182
  throw new Error("Channel has already been created");
1179
1183
  }
1180
1184
  try {
1181
- this.channelData = await this.baseClient.post("/channels", data);
1182
- console.log(`Channel originated successfully with ID: ${this.channelData.id}`);
1185
+ this.channelData = await this.baseClient.post(
1186
+ "/channels",
1187
+ data
1188
+ );
1189
+ console.log(
1190
+ `Channel originated successfully with ID: ${this.channelData.id}`
1191
+ );
1183
1192
  return this.channelData;
1184
1193
  } catch (error) {
1185
1194
  const message = getErrorMessage(error);
@@ -1223,13 +1232,18 @@ var ChannelInstance = class {
1223
1232
  if (!this.id) {
1224
1233
  throw new Error("No channel ID associated with this instance");
1225
1234
  }
1226
- const details = await this.baseClient.get(`/channels/${this.id}`);
1235
+ const details = await this.baseClient.get(
1236
+ `/channels/${this.id}`
1237
+ );
1227
1238
  this.channelData = details;
1228
1239
  console.log(`Retrieved channel details for ${this.id}`);
1229
1240
  return details;
1230
1241
  } catch (error) {
1231
1242
  const message = getErrorMessage(error);
1232
- console.error(`Error retrieving channel details for ${this.id}:`, message);
1243
+ console.error(
1244
+ `Error retrieving channel details for ${this.id}:`,
1245
+ message
1246
+ );
1233
1247
  throw new Error(`Failed to get channel details: ${message}`);
1234
1248
  }
1235
1249
  }
@@ -1438,10 +1452,23 @@ var Channels = class {
1438
1452
  }
1439
1453
  channelInstances = /* @__PURE__ */ new Map();
1440
1454
  /**
1441
- * Creates or retrieves a ChannelInstance based on the provided id.
1455
+ * Creates or retrieves a ChannelInstance.
1456
+ *
1457
+ * @param {Object} [params] - Optional parameters for getting/creating a channel instance
1458
+ * @param {string} [params.id] - Optional ID of an existing channel
1459
+ * @returns {ChannelInstance} The requested or new channel instance
1460
+ * @throws {Error} If channel creation/retrieval fails
1461
+ *
1462
+ * @example
1463
+ * // Create new channel without ID
1464
+ * const channel1 = client.channels.Channel();
1465
+ *
1466
+ * // Create/retrieve channel with specific ID
1467
+ * const channel2 = client.channels.Channel({ id: 'some-id' });
1442
1468
  */
1443
- Channel({ id }) {
1469
+ Channel(params) {
1444
1470
  try {
1471
+ const id = params?.id;
1445
1472
  if (!id) {
1446
1473
  const instance = new ChannelInstance(this.client, this.baseClient);
1447
1474
  this.channelInstances.set(instance.id, instance);
@@ -1490,7 +1517,9 @@ var Channels = class {
1490
1517
  const instance = this.channelInstances.get(event.channel.id);
1491
1518
  if (instance) {
1492
1519
  instance.emitEvent(event);
1493
- console.log(`Event propagated to channel ${event.channel.id}: ${event.type}`);
1520
+ console.log(
1521
+ `Event propagated to channel ${event.channel.id}: ${event.type}`
1522
+ );
1494
1523
  } else {
1495
1524
  console.warn(`No instance found for channel ${event.channel.id}`);
1496
1525
  }
@@ -1997,7 +2026,9 @@ var PlaybackInstance = class {
1997
2026
  }
1998
2027
  };
1999
2028
  this.eventEmitter.on(event, wrappedListener);
2000
- console.log(`Event listener registered for ${event} on playback ${this.id}`);
2029
+ console.log(
2030
+ `Event listener registered for ${event} on playback ${this.id}`
2031
+ );
2001
2032
  }
2002
2033
  /**
2003
2034
  * Registers a one-time event listener for a specific WebSocket event type.
@@ -2015,7 +2046,9 @@ var PlaybackInstance = class {
2015
2046
  }
2016
2047
  };
2017
2048
  this.eventEmitter.once(event, wrappedListener);
2018
- console.log(`One-time event listener registered for ${event} on playback ${this.id}`);
2049
+ console.log(
2050
+ `One-time event listener registered for ${event} on playback ${this.id}`
2051
+ );
2019
2052
  }
2020
2053
  /**
2021
2054
  * Removes event listener(s) for a specific WebSocket event type.
@@ -2029,7 +2062,9 @@ var PlaybackInstance = class {
2029
2062
  }
2030
2063
  if (listener) {
2031
2064
  this.eventEmitter.off(event, listener);
2032
- console.log(`Specific listener removed for ${event} on playback ${this.id}`);
2065
+ console.log(
2066
+ `Specific listener removed for ${event} on playback ${this.id}`
2067
+ );
2033
2068
  } else {
2034
2069
  this.eventEmitter.removeAllListeners(event);
2035
2070
  console.log(`All listeners removed for ${event} on playback ${this.id}`);
@@ -2086,7 +2121,9 @@ var PlaybackInstance = class {
2086
2121
  await this.baseClient.post(
2087
2122
  `/playbacks/${this.id}/control?operation=${operation}`
2088
2123
  );
2089
- console.log(`Operation ${operation} executed successfully on playback ${this.id}`);
2124
+ console.log(
2125
+ `Operation ${operation} executed successfully on playback ${this.id}`
2126
+ );
2090
2127
  } catch (error) {
2091
2128
  const message = getErrorMessage2(error);
2092
2129
  console.error(`Error controlling playback ${this.id}:`, message);
@@ -2144,12 +2181,13 @@ var Playbacks = class {
2144
2181
  playbackInstances = /* @__PURE__ */ new Map();
2145
2182
  /**
2146
2183
  * Gets or creates a playback instance
2147
- * @param {Object} params - Parameters for getting/creating a playback instance
2184
+ * @param {Object} [params] - Optional parameters for getting/creating a playback instance
2148
2185
  * @param {string} [params.id] - Optional ID of an existing playback
2149
2186
  * @returns {PlaybackInstance} The requested or new playback instance
2150
2187
  */
2151
- Playback({ id }) {
2188
+ Playback(params) {
2152
2189
  try {
2190
+ const id = params?.id;
2153
2191
  if (!id) {
2154
2192
  const instance = new PlaybackInstance(this.client, this.baseClient);
2155
2193
  this.playbackInstances.set(instance.id, instance);
@@ -2201,7 +2239,9 @@ var Playbacks = class {
2201
2239
  const instance = this.playbackInstances.get(event.playback.id);
2202
2240
  if (instance) {
2203
2241
  instance.emitEvent(event);
2204
- console.log(`Event propagated to playback ${event.playback.id}: ${event.type}`);
2242
+ console.log(
2243
+ `Event propagated to playback ${event.playback.id}: ${event.type}`
2244
+ );
2205
2245
  } else {
2206
2246
  console.warn(`No instance found for playback ${event.playback.id}`);
2207
2247
  }