@zyratalk1/zyra-twilio-wrapper 1.2.7 → 1.2.9

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/index.js CHANGED
@@ -319,11 +319,13 @@ var TwilioVoiceAdapter = class {
319
319
  async endCall(input) {
320
320
  console.log("[VOIP SDK] endCall() invoked", { callId: input.callId });
321
321
  const tracked = this.calls.get(input.callId);
322
- if (!tracked) return { success: false, error: "Call not found" };
322
+ if (!tracked) {
323
+ console.log("[VOIP SDK] endCall() call already ended", { callId: input.callId });
324
+ return { success: true, data: {} };
325
+ }
323
326
  try {
324
- await tracked.call.disconnect();
325
327
  this.calls.delete(input.callId);
326
- this.emit("onCallEnded", { callId: input.callId });
328
+ await tracked.call.disconnect();
327
329
  console.log("[VOIP SDK] call ended", { callId: input.callId });
328
330
  return { success: true, data: {} };
329
331
  } catch (error) {
@@ -403,7 +405,7 @@ var TwilioVoiceAdapter = class {
403
405
  const callSid = tracked?.callSid ?? input.callId;
404
406
  const conferenceName = tracked?.conferenceName ?? this.defaultConferenceName;
405
407
  const endpoint = direction === "INBOUND" ? "outgoingCall.addNewCalleeIncoming" : "outgoingCall.addNewCallee";
406
- const payload = direction === "INBOUND" ? { callSid, newParticipantNo: input.newParticipantNo } : { callSid, newParticipantNo: input.newParticipantNo };
408
+ const payload = direction === "INBOUND" ? { callSid, newParticipantNo: input.newParticipantNo } : { callSid: input.callId, newParticipantNo: input.newParticipantNo };
407
409
  console.log("[VOIP SDK] addNewCalleeByDirection() start", {
408
410
  callId: input.callId,
409
411
  direction,
@@ -694,6 +696,10 @@ var TwilioVoiceAdapter = class {
694
696
  console.log("[VOIP DEBUG] call disconnected while held \u2014 keeping tracked entry", { callId });
695
697
  return;
696
698
  }
699
+ if (!heldEntry) {
700
+ console.log("[VOIP DEBUG] call disconnected but already removed", { callId });
701
+ return;
702
+ }
697
703
  this.calls.delete(callId);
698
704
  this.emit("onCallEnded", {
699
705
  callId,