@wazo/sdk 0.37.43 → 0.38.2

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.
Files changed (46) hide show
  1. package/README.md +246 -0
  2. package/dist/wazo-sdk.js +5 -5
  3. package/esm/__tests__/web-rtc-client.test.js +1 -1
  4. package/esm/checker/Checker.js +1 -1
  5. package/esm/checker/checks/index.js +1 -1
  6. package/esm/checker/checks/webrtc-transport.js +1 -1
  7. package/esm/checker/checks/webrtc.js +1 -1
  8. package/esm/index.js +361 -1
  9. package/esm/simple/Auth.js +361 -1
  10. package/esm/simple/Configuration.js +361 -1
  11. package/esm/simple/Phone.js +361 -1
  12. package/esm/simple/Softphone.js +360 -0
  13. package/esm/simple/index.js +361 -1
  14. package/esm/simple/room/LocalParticipant.js +361 -1
  15. package/esm/simple/room/Participant.js +361 -1
  16. package/esm/simple/room/RemoteParticipant.js +361 -1
  17. package/esm/simple/room/Room.js +361 -1
  18. package/esm/simple/room/SipRoom.js +361 -1
  19. package/esm/simple/room/Stream.js +361 -1
  20. package/esm/simple/room/__tests__/RemoteParticipant.test.js +361 -1
  21. package/esm/simple/utils.js +361 -1
  22. package/esm/web-rtc-client.js +1 -1
  23. package/lib/__tests__/web-rtc-client.test.js +1 -1
  24. package/lib/checker/Checker.js +1 -1
  25. package/lib/checker/checks/index.js +1 -1
  26. package/lib/checker/checks/webrtc-transport.js +1 -1
  27. package/lib/checker/checks/webrtc.js +1 -1
  28. package/lib/index.js +361 -1
  29. package/lib/simple/Auth.js +361 -1
  30. package/lib/simple/Configuration.js +361 -1
  31. package/lib/simple/Phone.js +361 -1
  32. package/lib/simple/Softphone.js +362 -0
  33. package/lib/simple/index.js +361 -1
  34. package/lib/simple/room/LocalParticipant.js +361 -1
  35. package/lib/simple/room/Participant.js +361 -1
  36. package/lib/simple/room/RemoteParticipant.js +361 -1
  37. package/lib/simple/room/Room.js +361 -1
  38. package/lib/simple/room/SipRoom.js +361 -1
  39. package/lib/simple/room/Stream.js +361 -1
  40. package/lib/simple/room/__tests__/RemoteParticipant.test.js +361 -1
  41. package/lib/simple/utils.js +361 -1
  42. package/lib/web-rtc-client.js +1 -1
  43. package/package.json +1 -1
  44. package/src/simple/Softphone.js +358 -0
  45. package/src/simple/index.js +2 -0
  46. package/src/web-rtc-client.js +1 -1
package/README.md CHANGED
@@ -57,6 +57,7 @@ Wazo's Javascript SDK allows you to use these features :
57
57
  - [Participant](#participant)
58
58
  - [Participant events](#participant-events)
59
59
  - [Stream](#stream)
60
+ + [Softphone integration](#softphone-integration)
60
61
  * [Advanced API](#advanced-api)
61
62
  + [Libraries](#libraries)
62
63
  - [Require / Import](#require--import)
@@ -599,6 +600,251 @@ Detaches a stream from an existing htmlElement.
599
600
 
600
601
  - `htmlElement`: htmlElement.
601
602
 
603
+ ### Softphone integration
604
+
605
+ To be able to integrate Wazo softphone in any web page, you can add :
606
+
607
+ ```js
608
+ Wazo.Softphone.init({
609
+ url, // Url of the softphone to be loaded in the iframe (optional).
610
+ width, // Width (in px) of the softphone (optional).
611
+ height, // Height (in px) of the softphone (optional).
612
+ server, // Stack host where the softphone should connect user (optional).
613
+ port, // Stack port where the softphone should connect user (optional).
614
+ language, // Softphone language (optional).
615
+ wrapUpDuration, // How long (in seconds) should the softphone display the card after the call (optional).
616
+ // When the user changes anything on the card, this timeout is canceled
617
+ enableAgent, // display the agent tab in the tab bar (defaults to true).
618
+ });
619
+ ```
620
+
621
+ #### Methods
622
+
623
+ ##### Making a call
624
+ ```js
625
+ Wazo.Softphone.makeCall(number);
626
+ ```
627
+ - `number`: Number to call through the softphone
628
+
629
+ ##### Showing / hidding the softphone
630
+ ```js
631
+ Wazo.Softphone.toggleSoftphoneDisplay();
632
+ Wazo.Softphone.displaySoftphone();
633
+ Wazo.Softphone.hideSoftphone();
634
+ ```
635
+
636
+ ##### Parsing links on the page
637
+ ```js
638
+ Wazo.Softphone.parseLinks();
639
+ ```
640
+
641
+ Each link with a `href="tel:"` or `href="callto:"` will make a call through the softphone.
642
+
643
+ #### Sending search results to the softphone:
644
+ ```js
645
+ Wazo.Softphone.onOptionsResults(fieldId, results);
646
+ ```
647
+
648
+ `onOptionsResults` is used to populate Autocomplete fields
649
+
650
+ #### Updating card value:
651
+ ```js
652
+ Wazo.Softphone.setCardValue(field, value);
653
+ ```
654
+
655
+ #### Customizing page style
656
+ ```js
657
+ Wazo.Softphone.injectCss(`
658
+ body {
659
+ background-color: #eee;
660
+ }
661
+ `);
662
+ ```
663
+
664
+ #### Override appearance
665
+ ```js
666
+ Softphone.customizeAppearance({
667
+ // Theme
668
+ }, {
669
+ // Translation
670
+ }, {
671
+ // Assets
672
+ });
673
+ ```
674
+
675
+ `onOptionsResults` is used to populate Autocomplete fields
676
+
677
+ #### Customizing card form
678
+
679
+ You can use [JSON schema](http://json-schema.org/) to customize the card form with `Softphone.setFormSchema(schema, uiSchema)`,
680
+ the Softphone uses [React Json schema form](https://react-jsonschema-form.readthedocs.io) internally to display card form :
681
+
682
+ ```js
683
+ Softphone.setFormSchema({
684
+ type: 'object',
685
+ required: ['title', 'phone'],
686
+ properties: {
687
+ title: { type: 'string', title: 'Title' },
688
+ phone: { type: 'string', title: 'Phone' },
689
+ note: { type: 'string', title: 'Note' },
690
+ },
691
+ }, {
692
+ note: { 'ui:widget': 'textarea' },
693
+ });
694
+ ```
695
+
696
+ ##### Auto complete
697
+ We can use an `autocomplete` widget to search on fields in the `uiSchema`:
698
+
699
+ ```js
700
+ {
701
+ note :{ 'ui:widget': 'textarea'},
702
+ clientId :{ 'ui:field': 'autocomplete'},
703
+ };
704
+ ```
705
+
706
+ In the `schema` field, we can customize if we want to display a `+` button :
707
+ ```js
708
+ clientId: {
709
+ type: 'object',
710
+ title: 'Client id',
711
+ // triggers the `onDisplayLinkedOption` event when changing the value
712
+ triggerDisplay: true,
713
+ // createForm is another JSON schema the description the add option form.
714
+ createForm: {
715
+ optionLabel: '%firstname% %lastname%',
716
+ schema: {
717
+ type: 'object',
718
+ required: ['phone'],
719
+ properties: {
720
+ firstname: { type: 'string', title: 'Firstname' },
721
+ lastname: { type: 'string', title: 'Lastname' },
722
+ phone: { type: 'string', title: 'Phone' },
723
+ }
724
+ },
725
+ uiSchema: {}
726
+ },
727
+ }
728
+ ```
729
+
730
+ #### Callbacks
731
+
732
+ You can listen to softphone callback, with :
733
+
734
+ ```js
735
+ Wazo.Softphone.onLinkEnabled = link => {
736
+ // link is `<a>` html tag in the page with a href="tel:xx" (or callto:xxx) beeing processed
737
+ // You can make change here, like addind className, etc ...
738
+ };
739
+
740
+ Softphone.onCallIncoming = call => {
741
+ // Invoked when a call is incoming in the softphone
742
+ // You can make action here like redirecting to the contact page (by using `call.number).
743
+ };
744
+
745
+ Softphone.onCallEnded = (call, card, direction) => {
746
+ // Invoked when the call is ended
747
+ };
748
+
749
+ Softphone.onCardSaved = card => {
750
+ // Invoked when the user save the card at the end of the call
751
+ };
752
+
753
+ Softphone.onCallMade = call => {
754
+ // Invoked when an outgoing call is made
755
+ };
756
+
757
+ Softphone.onSearchOptions = (fieldId: string, query: string) => {
758
+ // Invoked when the user is making a search from an Autocomplete field in the card form
759
+ // We need to call `onOptionsResults` here to send results to the softphone
760
+ };
761
+
762
+ Softphone.onDisplayLinkedOption = (optionId: string) => {
763
+ // Invoked when the user is selecting a value in a Autocomplete widget
764
+ // useful to display this entity in your application
765
+ };
766
+
767
+ Softphone.onWazoContactSearch = (query: string) => {
768
+ // Invoked when the user is searching from contact page
769
+ };
770
+
771
+ Softphone.onAgentLoggedIn = () => {
772
+ // Invoked when the agent logs in
773
+ };
774
+
775
+ Softphone.onAgentLoggedOut = () => {
776
+ // Invoked when the agent logs out
777
+ };
778
+
779
+ Softphone.onAgentPaused = () => {
780
+ // Invoked when the agent is paused
781
+ };
782
+
783
+ Softphone.onLanguageChanged = (language: string) => {
784
+ // Invoked when the user changed the softphone language
785
+ };
786
+
787
+ Softphone.onCallHeld = () => {
788
+ // Invoked when the current call is held
789
+ };
790
+
791
+ Softphone.onCallResumed = () => {
792
+ // Invoked when the current call is resumed
793
+ };
794
+
795
+ Softphone.onCallMuted = () => {
796
+ // Invoked when the current call is muted
797
+ };
798
+
799
+ Softphone.onCallUnMuted = () => {
800
+ // Invoked when the current call is un muted
801
+ };
802
+
803
+ Softphone.onDtmfSent = (tone: string) => {
804
+ // Invoked when the user is sending a DTMF in the current call
805
+ };
806
+
807
+ Softphone.onDirectTransfer = (number: string) => {
808
+ // Invoked when the user is transfers the current call directly
809
+ };
810
+
811
+ Softphone.onCreateIndirectTransfer = (number: string) => {
812
+ // Invoked when the user initiates an indirect transfer for the current call
813
+ };
814
+
815
+ Softphone.onCancelIndirectTransfer = () => {
816
+ // Invoked when the user cancels the current indirect transfer
817
+ };
818
+
819
+ Softphone.onConfirmIndirectTransfer = () => {
820
+ // Invoked when the user confirms the current indirect transfer
821
+ };
822
+
823
+ Softphone.onIndirectCallMade = (call: Object) => {
824
+ // Invoked when the current indirect transfer is made
825
+ };
826
+
827
+ Softphone.onIndirectTransferDone = (call: Object) => {
828
+ // Invoked when the current indirect transfer is over
829
+ };
830
+
831
+ Softphone.onStartRecording = () => {
832
+ // Invoked when the user records the current call
833
+ };
834
+
835
+ Softphone.onStopRecording = () => {
836
+ // Invoked when the user stops recording the current call
837
+ };
838
+
839
+ Softphone.onAuthenticated = session => {
840
+ // Invoked when the user is authenticated in the softphone
841
+ };
842
+
843
+ Softphone.onLoggedOut = session => {
844
+ // Invoked when the user is is logged out in the softphone
845
+ };
846
+ ```
847
+
602
848
  ## Advanced API
603
849
 
604
850
  ### Libraries