@zyratalk1/zyra-twilio-wrapper 1.2.5 → 1.2.7

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.d.mts CHANGED
@@ -339,8 +339,8 @@ declare class ReactNativeVoipSdk {
339
339
  disconnectParticipant(participantId: string): Promise<void>;
340
340
  init(): Promise<void>;
341
341
  verifySDKToken(): Promise<boolean>;
342
- makeCall(to: string): Promise<CallResponse<CallSession>>;
343
- addCall(to: string): Promise<CallResponse<CallSession>>;
342
+ makeCall(to: string, callSid?: string): Promise<CallResponse<CallSession>>;
343
+ addCall(to: string, callSid?: string): Promise<CallResponse<CallSession>>;
344
344
  acceptCall(callId?: string): Promise<CallResponse<null>>;
345
345
  rejectCall(callId: string): Promise<CallResponse<null>>;
346
346
  hangup(callId?: string): Promise<CallResponse<null>>;
package/dist/index.d.ts CHANGED
@@ -339,8 +339,8 @@ declare class ReactNativeVoipSdk {
339
339
  disconnectParticipant(participantId: string): Promise<void>;
340
340
  init(): Promise<void>;
341
341
  verifySDKToken(): Promise<boolean>;
342
- makeCall(to: string): Promise<CallResponse<CallSession>>;
343
- addCall(to: string): Promise<CallResponse<CallSession>>;
342
+ makeCall(to: string, callSid?: string): Promise<CallResponse<CallSession>>;
343
+ addCall(to: string, callSid?: string): Promise<CallResponse<CallSession>>;
344
344
  acceptCall(callId?: string): Promise<CallResponse<null>>;
345
345
  rejectCall(callId: string): Promise<CallResponse<null>>;
346
346
  hangup(callId?: string): Promise<CallResponse<null>>;
package/dist/index.js CHANGED
@@ -1792,32 +1792,47 @@ var ReactNativeVoipSdk = class {
1792
1792
  return false;
1793
1793
  }
1794
1794
  }
1795
- async makeCall(to) {
1796
- logVoipDebug("makeCall() start", { to, hasActiveCall: Boolean(this.activeCallId) });
1795
+ async makeCall(to, callSid) {
1796
+ logVoipDebug("makeCall() start", {
1797
+ to,
1798
+ callSid,
1799
+ hasActiveCall: Boolean(this.activeCallId)
1800
+ });
1797
1801
  try {
1798
1802
  const destination = to.trim();
1799
1803
  if (!destination) {
1800
1804
  return createErrorResult("Destination required");
1801
1805
  }
1806
+ if (!this.activeCallId && callSid) {
1807
+ this.activeCallId = callSid;
1808
+ }
1802
1809
  if (!this.activeCallId) {
1803
1810
  const data = await this.startCall(destination);
1804
- logVoipDebug("makeCall() new call started", { callId: data.callId });
1811
+ logVoipDebug("makeCall() new call started", {
1812
+ callId: data.callId
1813
+ });
1805
1814
  return createSuccessResult("Call started", data);
1806
1815
  }
1807
1816
  if (!this.bridge.nativeModule.addNewCallee) {
1808
- return createErrorResult("addNewCallee not supported by native module");
1817
+ return createErrorResult(
1818
+ "addNewCallee not supported by native module"
1819
+ );
1809
1820
  }
1810
1821
  const result = await this.bridge.nativeModule.addNewCallee({
1811
- callId: this.activeCallId,
1822
+ callId: callSid ?? this.activeCallId,
1812
1823
  newParticipantNo: destination
1813
1824
  });
1814
1825
  if (!result.success) {
1815
- logVoipDebug("makeCall() addNewCallee failed", { error: result.error });
1816
- return createErrorResult(result.error ?? "Failed to add participant");
1826
+ logVoipDebug("makeCall() addNewCallee failed", {
1827
+ error: result.error
1828
+ });
1829
+ return createErrorResult(
1830
+ result.error ?? "Failed to add participant"
1831
+ );
1817
1832
  }
1818
- const existingSession = this.callEngine.getSession(this.activeCallId);
1833
+ const existingSession = this.callEngine.getSession(callSid ?? "");
1819
1834
  const session = existingSession ?? {
1820
- callId: this.activeCallId,
1835
+ callId: this.activeCallId ?? callSid,
1821
1836
  direction: "OUTBOUND",
1822
1837
  status: "MERGED",
1823
1838
  participants: [],
@@ -1832,11 +1847,13 @@ var ReactNativeVoipSdk = class {
1832
1847
  logVoipDebug("makeCall() failure", {
1833
1848
  message: error instanceof Error ? error.message : String(error)
1834
1849
  });
1835
- return createErrorResult(error instanceof Error ? error : "Failed to start call");
1850
+ return createErrorResult(
1851
+ error instanceof Error ? error : "Failed to start call"
1852
+ );
1836
1853
  }
1837
1854
  }
1838
- async addCall(to) {
1839
- return this.makeCall(to);
1855
+ async addCall(to, callSid) {
1856
+ return this.makeCall(to, callSid);
1840
1857
  }
1841
1858
  async acceptCall(callId) {
1842
1859
  try {