Skip to content

Latest commit

 

History

History
877 lines (551 loc) · 63.2 KB

CHANGELOG.md

File metadata and controls

877 lines (551 loc) · 63.2 KB

@signalwire/realtime-api

All notable changes to this project will be documented in this file.

This project adheres to Semantic Versioning.

[4.0.1] - 2024-06-03

Fixed

Dependencies

[4.0.0] - 2024-04-17

Added

  • #881 b39b82fe Thanks @iAmmar7! - New interface for Voice APIs

    The new interface contains a single SW client with Chat and PubSub namespaces

    import { SignalWire } from '@signalwire/realtime-api'
    
    (async () => {
      const client = await SignalWire({
        host: process.env.HOST,
        project: process.env.PROJECT,
        token: process.env.TOKEN,
      })
    
      const unsubVoiceOffice = await client.voice.listen({
        topics: ['office'],
        onCallReceived: async (call) => {
          try {
            await call.answer()
    
            const unsubCall = await call.listen({
              onStateChanged: (call) => {},
              onPlaybackUpdated: (playback) => {},
              onRecordingStarted: (recording) => {},
              onCollectInputStarted: (collect) => {},
              onDetectStarted: (detect) => {},
              onTapStarted: (tap) => {},
              onPromptEnded: (prompt) => {}
              // ... more call listeners can be attached here
            })
    
            // ...
    
            await unsubCall()
          } catch (error) {
            console.error('Error answering inbound call', error)
          }
        }
      })
    
      const call = await client.voice.dialPhone({
        to: process.env.VOICE_DIAL_TO_NUMBER as string,
        from: process.env.VOICE_DIAL_FROM_NUMBER as string,
        timeout: 30,
        listen: {
          onStateChanged: async (call) => {
            // When call ends; unsubscribe all listeners and disconnect the client
            if (call.state === 'ended') {
              await unsubVoiceOffice()
    
              await unsubVoiceHome()
    
              await unsubPlay()
    
              client.disconnect()
            }
          },
          onPlaybackStarted: (playback) => {},
        },
      })
    
      const unsubCall = await call.listen({
        onPlaybackStarted: (playback) => {},
        onPlaybackEnded: (playback) => {
          // This will never run since we unsubscribe this listener before the playback stops
        },
      })
    
      // Play an audio
      const play = await call.playAudio({
        url: 'https://cdn.signalwire.com/default-music/welcome.mp3',
        listen: {
          onStarted: async (playback) => {
            await unsubCall()
    
            await play.stop()
          },
        },
      })
    
      const unsubPlay = await play.listen({
        onStarted: (playback) => {
          // This will never run since this listener is attached after the call.play has started
        },
        onEnded: async (playback) => {
          await call.hangup()
        },
      })
    
    })
  • #881 b39b82fe Thanks @iAmmar7! - - New interface for the realtime-api Video SDK.

    • Listen function with video, room, playback, recording, and stream objects.
    • Listen param with room.play, room.startRecording, and room.startStream functions.
    • Decorated promise for room.play, room.startRecording, and room.startStream functions.
    import { SignalWire } from '@signalwire/realtime-api'
    
    const client = await SignalWire({ project, token })
    
    const unsub = await client.video.listen({
      onRoomStarted: async (roomSession) => {
        console.log('room session started', roomSession)
    
        await roomSession.listen({
          onPlaybackStarted: (playback) => {
            console.log('plyaback started', playback)
          },
        })
    
        // Promise resolves when playback ends.
        await roomSession.play({
          url: 'http://.....',
          listen: { onEnded: () => {} },
        })
      },
      onRoomEnded: (roomSession) => {
        console.log('room session ended', roomSession)
      },
    })
  • #881 b39b82fe Thanks @iAmmar7! - New interface for PubSub and Chat APIs

    The new interface contains a single SW client with Chat and PubSub namespaces

    import { SignalWire } from '@signalwire/realtime-api'
    ;(async () => {
      const client = await SignalWire({
        host: process.env.HOST,
        project: process.env.PROJECT,
        token: process.env.TOKEN,
      })
    
      // Attach pubSub listeners
      const unsubHomePubSubListener = await client.pubSub.listen({
        channels: ['home'],
        onMessageReceived: (message) => {
          console.log('Message received under the "home" channel', message)
        },
      })
    
      // Publish on home channel
      await client.pubSub.publish({
        content: 'Hello There',
        channel: 'home',
        meta: {
          fooId: 'randomValue',
        },
      })
    
      // Attach chat listeners
      const unsubOfficeChatListener = await client.chat.listen({
        channels: ['office'],
        onMessageReceived: (message) => {
          console.log('Message received on "office" channel', message)
        },
        onMemberJoined: (member) => {
          console.log('Member joined on "office" channel', member)
        },
        onMemberUpdated: (member) => {
          console.log('Member updated on "office" channel', member)
        },
        onMemberLeft: (member) => {
          console.log('Member left on "office" channel', member)
        },
      })
    
      // Publish a chat message on the office channel
      const pubRes = await client.chat.publish({
        content: 'Hello There',
        channel: 'office',
      })
    
      // Get channel messages
      const messagesResult = await client.chat.getMessages({
        channel: 'office',
      })
    
      // Get channel members
      const getMembersResult = await client.chat.getMembers({ channel: 'office' })
    
      // Unsubscribe pubSub listener
      await unsubHomePubSubListener()
    
      // Unsubscribe chat listener
      await unsubOfficeChatListener()
    
      // Disconnect the client
      client.disconnect()
    })()
  • #881 b39b82fe Thanks @iAmmar7! - New interface for the Messaging API

    The new interface contains a single SW client with Messaging namespace

      const client = await SignalWire({
        host: process.env.HOST || 'relay.swire.io',
        project: process.env.PROJECT as string,
        token: process.env.TOKEN as string,
      })
    
      const unsubOfficeListener = await client.messaging.listen({
        topics: ['office'],
        onMessageReceived: (payload) => {
          console.log('Message received under "office" context', payload)
        },
        onMessageUpdated: (payload) => {
          console.log('Message updated under "office" context', payload)
        },
      })
    
      try {
        const response = await client.messaging.send({
          from: process.env.FROM_NUMBER_MSG as string,
          to: process.env.TO_NUMBER_MSG as string,
          body: 'Hello World!',
          context: 'office',
        })
    
        await client.messaging.send({
          from: process.env.FROM_NUMBER_MSG as string,
          to: process.env.TO_NUMBER_MSG as string,
          body: 'Hello John Doe!',
        })
      } catch (error) {
        console.log('>> send error', error)
      }
  • #881 b39b82fe Thanks @iAmmar7! - Decorated promise for the following APIs:

    • call.play()
      • call.playAudio()
      • call.playSilence()
      • call.playRingtone()
      • call.playTTS()
    • call.record()
      • call.recordAudio()
    • call.prompt()
      • call.promptAudio()
      • call.promptRingtone()
      • call.promptTTS()
    • call.tap()
      • call.tapAudio()
    • call.detect()
      • call.amd()
      • call.detectFax()
      • call.detectDigit
    • call.collect()

    Playback example 1 - Not resolving promise

    const play = call.playAudio({ url: '...' })
    await play.id

    Playback example 2 - Resolving promise when playback starts

    const play = await call.playAudio({ url: '...' }).onStarted()
    play.id

    Playback example 3 - Resolving promise when playback ends

    const play = await call.playAudio({ url: '...' }).onEnded()
    play.id

    Playback example 4 - Resolving promise when playback ends - Default behavior

    const play = await call.playAudio({ url: '...' })
    play.id

    All the other APIs work in a similar way.

  • #881 b39b82fe Thanks @iAmmar7! - Task namespace with new interface

Fixed

[3.13.0] - 2023-11-23

Added

  • #873 6c9d2aa5 Thanks @iAmmar7! - Introduce the hand raise API for the Video SDKs (browser and realtime-api)

Fixed

  • #892 d564c379 Thanks @ayeminag! - - Added state param to CallingCallCollectEventParams
    • Made sure voiceCallCollectWorker doesn't clean up CallCollect instance and emit ended/failed event if the state is "collecting"
    • Resolve CallCollect.ended() promise only when state is NOT "collecting" AND final is either undefined/true AND result.type is one of ENDED_STATES
    • Added more test cases for Call.collect() in @sw-internal/e2e-realtime-api
  • Updated dependencies [d564c379, 4ee7b6f8, 6c9d2aa5]:
    • @signalwire/core@3.21.0

[3.12.0] - 2023-11-07

Added

Added

Dependencies

[3.11.0] - 2023-09-14

Added

  • #866 1086a1b0 - Expose detectInterruptions params for detect methods and handle beep in the detect events

  • #864 be17e614 - Add alias 'topics' for 'contexts'

  • #862 2a9b88d9 - Add a new result getter to CallDetect to retrieve the result of the detector.

  • #863 fb45dce7 - Add support for CallRecording pause() and resume()

Changed

  • #853 5e1ff117 - Enhance shared function between realtime and browser SDK

  • #853 5e1ff117 - Introduce the session emitter and eliminate the global emitter

  • #853 5e1ff117 - Cleanup the SDK by removing eventsPrefix from the namespaces

  • #853 5e1ff117 - Attach listeners without the namespace prefix

  • #853 5e1ff117 - Cleanup the SDK by removing applyEmitterTransform

  • #875 a3ef96ed - Catchable voice calling workers saga

  • #853 5e1ff117 - Cleanup the global emitter

  • #853 5e1ff117 - Remove event emitter transform pipeline from browser SDK

  • #876 e5db0ef9 - Bump supported node version to at least 16

Dependencies

[3.10.3] - 2023-08-17

Fixed

  • #858 bb50b2fb - Fix custom CloseEvent implementation to avoid crash on WS close.

Dependencies

  • Updated dependencies [bb50b2fb]:
    • @signalwire/core@3.18.3

[3.10.2] - 2023-08-08

Dependencies

  • Updated dependencies [af7072b7]:
    • @signalwire/core@3.18.2

[3.10.1] - 2023-07-26

Fixed

Dependencies

  • Updated dependencies [81beb29a]:
    • @signalwire/core@3.18.1

[3.10.0] - 2023-07-19

Added

  • #827 6a35f0a3 - Introduce await call.pass() function to pass the call to another consumer.

Fixed

  • #828 a7426731 - bugfix: Add setPayload on CallTap instance.

Dependencies

[3.9.2] - 2023-07-07

Dependencies

[3.9.1] - 2023-06-21

Changed

Fixed

  • #808 9fd8f9cb - Fix Collect and Prompt APIs' speech

  • #776 602921a6 - Handle failed state for call.connect events.

  • #776 602921a6 - Return RoomSessionMember object instead of plain Member object.

Dependencies

[3.9.0] - 2023-05-22

Added

  • #778 aa31e1a0 - Add support for maxPricePerMinute in dial and connect for the Voice Call object.

Dependencies

[3.8.2] - 2023-03-30

Fixed

  • #774 09af75aa - Fix issue with simultaneous CallPlayback and CallRecording.

[3.8.1] - 2023-03-24

Dependencies

  • Updated dependencies [e299b048]:
    • @signalwire/core@3.14.1

[3.8.0] - 2023-03-22

Added

  • #664 bc56cc42 - Add promote/demote methods to RoomSession.

Changed

  • #738 ba39c819 - Remove executeActionWatcher and related functions.

  • #664 bc56cc42 - Expose the room.audience_count event on the RoomSession.

Dependencies

[3.7.0] - 2023-03-07

Added

Fixed

  • #732 9ad158b9 - Emit playback.failed event on playback failure Resolve the playback .ended() promise in case of Playback failure Resolve the playback .ended() promise in case of Prompt failure Resolve the playback .ended() promise in case of Recording failure Resolve the playback .ended() promise in case of Detect failure Resolve the playback .ended() promise in case of Collect failure Resolve the playback .ended() promise in case of Tap failure

  • #750 fe3b0e29 - Fix bug between getRoomSessions and nested objects in the Video client.

  • #711 45536d5f - Fix error on exposing the state property on the Voice Call object.

Dependencies

[3.6.0] - 2022-11-23

Added

  • #571 a32413d8 - Add detectAnsweringMachine(params) as an alias to amd(params) in Voice Call.

Changed

  • #623 3e7ce646 - Review the Voice namespace interface: deprecate waitForEnded and add ended.

Fixed

Dependencies

[3.5.1] - 2022-10-06

Fixed

  • #658 b765449b - Skip auto-subscribe logic for a RoomSession without valid subscriptions.
  • #657 50f2e07f - Hotfix for getRecordings, getPlaybacks and getStreams return objects without room_session_id.
  • #655 31af8209 - Fix race condition on auto-connect Clients.

Dependencies

[3.5.0] - 2022-09-21

Added

  • #633 f1102bb6 - Expose getStreams and startStream on the RoomSession object.
  • #627 6cf01e1c - Expose getMeta and getMemberMeta methods on the RoomSession.

Changed

  • #641 569213c8 - Move debounce implementation from realtime-api to core.

Fixed

  • #634 c09d7649 - Stop caching realtime-api clients to avoid race on disconnect/reconnect.

Dependencies

[3.4.0] - 2022-08-17

Added

  • #615 7b196107 - Expose .disconnect() method on all the client namespaces: Video, Chat, PubSub, Task, Voice and Messaging.
  • #619 d7ce34d3 - Add methods to manage a RoomSession and Member meta: updateMeta, deleteMeta, setMemberMeta, updateMemberMeta, deleteMemberMeta.

Fixed

  • #621 eff4736c - Fix comment for waitForDisconnected on Voice Call.
  • #615 7b196107 - hotfix: always connect the lower level client.

Changed

  • #610 eb1c3fe9 - Updated interfaces to match the spec, update RoomSession.getRecordings and RoomSession.getPlaybacks to return stateful objects, deprecated RoomSession.members and RoomSession.recordings in favour of their corresponding getters.

  • #601 d8cf078c - [internal] Updated internals to support ignoring methods coming from core.

  • #607 f421f92a - remove updateToken and session.expiring event from realtime-api Chat and PubSub namespaces.

Dependencies

[3.3.1]- 2022-07-27

Changed

  • #596 6bc89d81 - Improve auto-subscribe logic in Video and PubSub namespaces.

Fixed

Dependencies

  • Updated dependencies [6bc89d81]:
    • @signalwire/core@3.10.1

[3.3.0]- 2022-07-14

Added

  • #560 d308daf8 - Expose methods to seek to a specific video position during playback.

Fixed

  • #583 8ec914b6 - Fix issue with missing member.update events in Realtime-API SDK.

Changed

  • #577 9e1bf9d8 - Remove all the internal docs.ts files and overall intellisense improvements.
  • #584 9eb9851f - Remove option to pass volume from methods of Voice.Playlist typings.

Dependencies

[3.2.0] - 2022-06-24

Added

  • #580 e8a54a63 - Expose getRoomSessions() and getRoomSessionById() on the VideoClient to retrieve in-progress RoomSession objects.

Dependencies

[3.1.1] - 2022-06-15

Fixed

  • #570 b97ffcbe - Fix internal bundling to allow the usage of the esm output.

[3.1.0] - 2022-06-10

Added

  • #562 02d97ded - Add layout property to RoomSession.play().

Dependencies

  • Updated dependencies [02d97ded]:
    • @signalwire/core@3.9.0

[3.0.2] - 2022-06-06

Changed

  • #558 3a2b7883 - Remove under development warnings for Chat and PubSub namespaces.

[3.0.1] - 2022-06-01

Changed

  • #542 875b2bb8 - Add layoutName to the RoomSession interface.

  • #546 fc4689df - Internal changes to migrate from setWorker/attachWorker to runWorkers and from payload to initialState.

Fixed

  • #553 47ed1712 - Fix task.received handler on the Task namespace.

Dependencies

[3.1.0] - 2022-05-19

Added

  • #477 c6beec6d - Expose the Voice.createPlaylist() method to simplify playing media on a Voice Call.
  • #477 c6beec6d - Add ability to record audio in Voice Call.
  • #477 c6beec6d - Add ability to prompt for digits or speech using prompt() in Voice Call.
  • #477 c6beec6d - Expose the Voice.createDialer() method to simplify dialing devices on a Voice Call.
  • #460 7e64fb28 - Initial implementation of the Voice namespace. Adds ability to make outbound calls.
  • #472 76e92dd9 - Add Messaging namespace in realtime-api SDK.
  • #477 c6beec6d - Add ability to connect and disconnect legs in Voice namespace.
  • #477 c6beec6d - Add ability to start detectors for machine/digit/fax in Voice Call.
  • #477 c6beec6d - Add waitForEnded() method to the CallPlayback component to easily wait for playbacks to end.
  • #477 c6beec6d - Add ability to receive inbound Calls in the Voice namespace.
  • #539 4c0909dd - Rename Call method waitUntilConnected to waitForDisconnected and expose disconnect on the VoiceClient
  • #535 f89b8848 - Expose connectPhone() and connectSip() helper methods on the Voice Call.
  • #491 0b98a9e4 - Expose disconnect() from Messaging and Task Client objects.

  • #536 a6e27d88 - Fix calling.call.received event handler

  • #477 c6beec6d - Add ability to return the payload when the dial fails.

  • #531 9e6ad45f - Fix issue with Call.connect and inbound calls.

  • #499 19ffe276 - Make context optional in Messaging send() method.
  • #477 c6beec6d - Migrate createDialer and createPlaylist to Dialer and Playlist constructors
  • #529 e09afd5b - Renamed Dialer to DeviceBuilder, added ability to pass region to dialPhone and dialSip.

Changed

  • #532 12c64580 - Improve typings of the public interface for the Chat namespace.

Dependencies

[3.0.0-beta.9] - 2022-04-01

Dependencies

  • Updated dependencies [a9abe1d5]:
    • @signalwire/core@3.7.1

[3.0.0-beta.8] - 2022-03-25

Added

  • #456 c487d29b - Add ability to handle member's currentPosition.
  • #416 8f6e6819 - Initial implementation of the Chat namespace, Updated version of getClient to also cache the internals, Added utility for creating session clients (setupClient) to simplify and abstract all the required steps for creating (or getting from the cache) a client based on the passed credentials.

Changed

  • #452 563a31e5 - Expose setMeta and setMemberMeta methods on the RoomSession.

Fixed

  • #469 4d7bcc30 - Fix Chat methods that required the underlay client to be connected.

Dependencies

[3.0.0-beta.7] - 2022-03-02

Added

  • #426 edc573f2 - Expose the removeAllListeners method for all the components.

Patch Changes

  • #435 cc457600 - Calls to RoomSession.subscribe() are now optional.

Dependencies

[3.0.0-beta.6] - 2022-02-04

Dependencies

[3.0.0-beta.5] - 2022-01-11

Added

  • #394 03e5d42 - Add previewUrl property to the RoomSession object.

Dependencies

[3.0.0-beta.4] - 2021-11-02

Dependencies

[3.0.0-beta.2] - 2021-10-12

Added

  • #297 2675e5e - Add support for the Playback APIs: roomSession.play() and the RoomSessionPlayback object to control it.

Changed

  • #325 7d183de - Upgrade dependency for handling WebSocket connections.

Dependencies

[3.0.0-beta.1] - 2021-10-06

Changed

  • #302 2ac7f6d - Added setInputVolume/setOutputVolume and marked setMicrophoneVolume/setSpeakerVolume as deprecated.
  • #305 cec54bd - Convert timestamp properties to Date objects.
  • #311 febb842 - Allow users to listen the room.subscribed event and change the roomSession.subscribe() to return a Promise<RoomSessionFullState>.

Dependencies

[3.0.0-beta.0] - 2021-09-15

This is the initial release of @signalwire/realtime-api. Read the Release Notes on GitHub!