@zelloptt/react-native-zello-sdk 2.0.1 → 3.0.0

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 (196) hide show
  1. package/README.md +58 -15
  2. package/android/build.gradle +29 -10
  3. package/android/gradle.properties +4 -4
  4. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModule.kt +93 -68
  5. package/android/src/main/java/com/zellosdk/ZelloAndroidSdkModuleHelper.kt +25 -0
  6. package/ios/Extensions/ZelloContact+Extension.swift +26 -3
  7. package/ios/Extensions/ZelloHistoryVoiceMessage+Extension.swift +3 -0
  8. package/ios/Extensions/ZelloIOSSdkModule+Extension.swift +8 -2
  9. package/ios/Extensions/ZelloIncomingEmergency+Extension.swift +1 -0
  10. package/ios/Extensions/ZelloTranscription+Extension.swift +18 -0
  11. package/ios/ZelloIOSSdkModule.swift +24 -7
  12. package/ios/ZelloIOSSdkModuleBridge.m +1 -0
  13. package/ios/ZelloSdkModule.h +8 -0
  14. package/ios/ZelloSdkModule.mm +189 -0
  15. package/ios/ZelloSdkModuleImpl.swift +280 -0
  16. package/lib/commonjs/docs/assets/highlight.css +1 -1
  17. package/lib/commonjs/docs/assets/icons.js +1 -1
  18. package/lib/commonjs/docs/assets/icons.js.map +1 -1
  19. package/lib/commonjs/docs/assets/icons.svg +1 -1
  20. package/lib/commonjs/docs/assets/main.js +220 -288
  21. package/lib/commonjs/docs/assets/main.js.map +1 -1
  22. package/lib/commonjs/docs/assets/navigation.js +1 -1
  23. package/lib/commonjs/docs/assets/navigation.js.map +1 -1
  24. package/lib/commonjs/docs/assets/search.js +1 -1
  25. package/lib/commonjs/docs/assets/search.js.map +1 -1
  26. package/lib/commonjs/docs/assets/style.css +21 -6
  27. package/lib/commonjs/docs/classes/sdk.Zello.html +793 -97
  28. package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +122 -9
  29. package/lib/commonjs/docs/classes/types.ZelloChannel.html +155 -10
  30. package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +86 -4
  31. package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +90 -6
  32. package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +163 -11
  33. package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +178 -13
  34. package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +131 -10
  35. package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +123 -9
  36. package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +155 -13
  37. package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +131 -10
  38. package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +145 -10
  39. package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +130 -10
  40. package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +114 -9
  41. package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +124 -8
  42. package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +146 -12
  43. package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +98 -7
  44. package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +120 -9
  45. package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +114 -9
  46. package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +122 -9
  47. package/lib/commonjs/docs/classes/types.ZelloTranscription.html +122 -0
  48. package/lib/commonjs/docs/classes/types.ZelloTranslation.html +91 -0
  49. package/lib/commonjs/docs/classes/types.ZelloUser.html +142 -11
  50. package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +82 -5
  51. package/lib/commonjs/docs/enums/events.ZelloEvent.html +563 -95
  52. package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +67 -5
  53. package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +67 -5
  54. package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +68 -3
  55. package/lib/commonjs/docs/enums/types.ZelloChannelType.html +84 -0
  56. package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +68 -3
  57. package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +73 -3
  58. package/lib/commonjs/docs/enums/types.ZelloContactType.html +73 -3
  59. package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +73 -3
  60. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +63 -3
  61. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +78 -3
  62. package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +78 -3
  63. package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +81 -7
  64. package/lib/commonjs/docs/hierarchy.html +29 -1
  65. package/lib/commonjs/docs/index.html +122 -24
  66. package/lib/commonjs/docs/interfaces/specs_NativeZelloSdk.Spec.html +504 -0
  67. package/lib/commonjs/docs/modules/events.html +37 -1
  68. package/lib/commonjs/docs/modules/index.html +37 -1
  69. package/lib/commonjs/docs/modules/sdk.html +37 -1
  70. package/lib/commonjs/docs/modules/specs_NativeZelloSdk.html +41 -0
  71. package/lib/commonjs/docs/modules/types.html +45 -1
  72. package/lib/commonjs/docs/modules.html +36 -1
  73. package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +114 -9
  74. package/lib/commonjs/docs/types/types.ZelloConfig.html +86 -7
  75. package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +96 -9
  76. package/lib/commonjs/docs/types/types.ZelloContact.html +80 -6
  77. package/lib/commonjs/docs/types/types.ZelloCredentials.html +75 -6
  78. package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +97 -8
  79. package/lib/commonjs/docs/types/types.ZelloMessage.html +91 -7
  80. package/lib/commonjs/docs/variables/specs_NativeZelloSdk.default.html +34 -0
  81. package/lib/commonjs/events/index.js +217 -0
  82. package/lib/commonjs/events/index.js.map +1 -1
  83. package/lib/commonjs/sdk/index.js +731 -911
  84. package/lib/commonjs/sdk/index.js.map +1 -1
  85. package/lib/commonjs/specs/NativeZelloSdk.js +27 -0
  86. package/lib/commonjs/specs/NativeZelloSdk.js.map +1 -0
  87. package/lib/commonjs/types/index.js +423 -302
  88. package/lib/commonjs/types/index.js.map +1 -1
  89. package/lib/commonjs/utils/index.js +27 -4
  90. package/lib/commonjs/utils/index.js.map +1 -1
  91. package/lib/module/docs/assets/highlight.css +1 -1
  92. package/lib/module/docs/assets/icons.js +1 -1
  93. package/lib/module/docs/assets/icons.js.map +1 -1
  94. package/lib/module/docs/assets/icons.svg +1 -1
  95. package/lib/module/docs/assets/main.js +220 -288
  96. package/lib/module/docs/assets/main.js.map +1 -1
  97. package/lib/module/docs/assets/navigation.js +1 -1
  98. package/lib/module/docs/assets/navigation.js.map +1 -1
  99. package/lib/module/docs/assets/search.js +1 -1
  100. package/lib/module/docs/assets/search.js.map +1 -1
  101. package/lib/module/docs/assets/style.css +21 -6
  102. package/lib/module/docs/classes/sdk.Zello.html +793 -97
  103. package/lib/module/docs/classes/types.ZelloAlertMessage.html +122 -9
  104. package/lib/module/docs/classes/types.ZelloChannel.html +155 -10
  105. package/lib/module/docs/classes/types.ZelloChannelUser.html +86 -4
  106. package/lib/module/docs/classes/types.ZelloDispatchCall.html +90 -6
  107. package/lib/module/docs/classes/types.ZelloDispatchChannel.html +163 -11
  108. package/lib/module/docs/classes/types.ZelloGroupConversation.html +178 -13
  109. package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +131 -10
  110. package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +123 -9
  111. package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +155 -13
  112. package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +131 -10
  113. package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +145 -10
  114. package/lib/module/docs/classes/types.ZelloImageMessage.html +130 -10
  115. package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +114 -9
  116. package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +124 -8
  117. package/lib/module/docs/classes/types.ZelloLocationMessage.html +146 -12
  118. package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +98 -7
  119. package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +120 -9
  120. package/lib/module/docs/classes/types.ZelloRecentEntry.html +114 -9
  121. package/lib/module/docs/classes/types.ZelloTextMessage.html +122 -9
  122. package/lib/module/docs/classes/types.ZelloTranscription.html +122 -0
  123. package/lib/module/docs/classes/types.ZelloTranslation.html +91 -0
  124. package/lib/module/docs/classes/types.ZelloUser.html +142 -11
  125. package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +82 -5
  126. package/lib/module/docs/enums/events.ZelloEvent.html +563 -95
  127. package/lib/module/docs/enums/types.ZelloAccountStatus.html +67 -5
  128. package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +67 -5
  129. package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +68 -3
  130. package/lib/module/docs/enums/types.ZelloChannelType.html +84 -0
  131. package/lib/module/docs/enums/types.ZelloConnectionError.html +68 -3
  132. package/lib/module/docs/enums/types.ZelloConnectionState.html +73 -3
  133. package/lib/module/docs/enums/types.ZelloContactType.html +73 -3
  134. package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +73 -3
  135. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +63 -3
  136. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +78 -3
  137. package/lib/module/docs/enums/types.ZelloRecentEntryType.html +78 -3
  138. package/lib/module/docs/enums/types.ZelloUserStatus.html +81 -7
  139. package/lib/module/docs/hierarchy.html +29 -1
  140. package/lib/module/docs/index.html +122 -24
  141. package/lib/module/docs/interfaces/specs_NativeZelloSdk.Spec.html +504 -0
  142. package/lib/module/docs/modules/events.html +37 -1
  143. package/lib/module/docs/modules/index.html +37 -1
  144. package/lib/module/docs/modules/sdk.html +37 -1
  145. package/lib/module/docs/modules/specs_NativeZelloSdk.html +41 -0
  146. package/lib/module/docs/modules/types.html +45 -1
  147. package/lib/module/docs/modules.html +36 -1
  148. package/lib/module/docs/types/types.ZelloChannelOptions.html +114 -9
  149. package/lib/module/docs/types/types.ZelloConfig.html +86 -7
  150. package/lib/module/docs/types/types.ZelloConsoleSettings.html +96 -9
  151. package/lib/module/docs/types/types.ZelloContact.html +80 -6
  152. package/lib/module/docs/types/types.ZelloCredentials.html +75 -6
  153. package/lib/module/docs/types/types.ZelloHistoryMessage.html +97 -8
  154. package/lib/module/docs/types/types.ZelloMessage.html +91 -7
  155. package/lib/module/docs/variables/specs_NativeZelloSdk.default.html +34 -0
  156. package/lib/module/events/index.js +217 -0
  157. package/lib/module/events/index.js.map +1 -1
  158. package/lib/module/sdk/index.js +730 -912
  159. package/lib/module/sdk/index.js.map +1 -1
  160. package/lib/module/specs/NativeZelloSdk.js +25 -0
  161. package/lib/module/specs/NativeZelloSdk.js.map +1 -0
  162. package/lib/module/types/index.js +378 -301
  163. package/lib/module/types/index.js.map +1 -1
  164. package/lib/module/utils/index.js +27 -5
  165. package/lib/module/utils/index.js.map +1 -1
  166. package/lib/typescript/commonjs/src/events/index.d.ts +9 -0
  167. package/lib/typescript/commonjs/src/events/index.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/src/sdk/index.d.ts +10 -0
  169. package/lib/typescript/commonjs/src/sdk/index.d.ts.map +1 -1
  170. package/lib/typescript/commonjs/src/specs/NativeZelloSdk.d.ts +55 -0
  171. package/lib/typescript/commonjs/src/specs/NativeZelloSdk.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/types/index.d.ts +106 -4
  173. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -1
  175. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  176. package/lib/typescript/module/src/events/index.d.ts +9 -0
  177. package/lib/typescript/module/src/events/index.d.ts.map +1 -1
  178. package/lib/typescript/module/src/index.d.ts +4 -4
  179. package/lib/typescript/module/src/index.d.ts.map +1 -1
  180. package/lib/typescript/module/src/sdk/index.d.ts +11 -1
  181. package/lib/typescript/module/src/sdk/index.d.ts.map +1 -1
  182. package/lib/typescript/module/src/specs/NativeZelloSdk.d.ts +55 -0
  183. package/lib/typescript/module/src/specs/NativeZelloSdk.d.ts.map +1 -0
  184. package/lib/typescript/module/src/types/index.d.ts +106 -4
  185. package/lib/typescript/module/src/types/index.d.ts.map +1 -1
  186. package/lib/typescript/module/src/utils/algorithms/index.d.ts +1 -1
  187. package/lib/typescript/module/src/utils/algorithms/index.d.ts.map +1 -1
  188. package/lib/typescript/module/src/utils/index.d.ts +2 -1
  189. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  190. package/package.json +31 -15
  191. package/react-native-zello-sdk.podspec +26 -1
  192. package/src/events/index.ts +9 -0
  193. package/src/sdk/index.ts +105 -225
  194. package/src/specs/NativeZelloSdk.ts +89 -0
  195. package/src/types/index.ts +153 -6
  196. package/src/utils/index.ts +50 -3
@@ -30,6 +30,28 @@ export enum ZelloContactType {
30
30
  GroupConversation = 'groupConversation',
31
31
  }
32
32
 
33
+ /**
34
+ * The type of a {@link ZelloChannel}.
35
+ */
36
+ export enum ZelloChannelType {
37
+ /**
38
+ * A standard, dynamic Zello channel.
39
+ */
40
+ Dynamic = 'dynamic',
41
+ /**
42
+ * A dispatch channel. Dispatch channels carry calls between users and dispatchers and are surfaced as a {@link ZelloDispatchChannel}.
43
+ */
44
+ Dispatch = 'dispatch',
45
+ /**
46
+ * A team channel. Team channels allow private one-to-one direct messaging between users.
47
+ */
48
+ Team = 'team',
49
+ /**
50
+ * An ad-hoc group conversation provisioned by the end user, surfaced as a {@link ZelloGroupConversation}.
51
+ */
52
+ GroupConversation = 'groupConversation',
53
+ }
54
+
33
55
  /**
34
56
  * The status of a {@link ZelloUser}.
35
57
  */
@@ -133,13 +155,25 @@ export class ZelloChannel implements ZelloContact {
133
155
  * The options of the channel.
134
156
  */
135
157
  public options: ZelloChannelOptions;
158
+ /**
159
+ * The type of the channel.
160
+ */
161
+ public channelType: ZelloChannelType;
162
+ /**
163
+ * Whether this channel has translations enabled.
164
+ * When true, incoming voice messages on this channel may be played as TTS in the listener's language.
165
+ * See {@link ZelloIncomingVoiceMessage#isTranslation} for the per-message signal.
166
+ */
167
+ public translationsEnabled: boolean;
136
168
 
137
169
  constructor(
138
170
  name: string,
139
171
  isMuted: boolean,
140
172
  connectionStatus: ZelloChannelConnectionStatus,
141
173
  usersOnline: number,
142
- options: ZelloChannelOptions
174
+ options: ZelloChannelOptions,
175
+ channelType: ZelloChannelType = ZelloChannelType.Dynamic,
176
+ translationsEnabled: boolean = false
143
177
  ) {
144
178
  this.name = name;
145
179
  this.type = ZelloContactType.Channel;
@@ -147,6 +181,8 @@ export class ZelloChannel implements ZelloContact {
147
181
  this.connectionStatus = connectionStatus;
148
182
  this.usersOnline = usersOnline;
149
183
  this.options = options;
184
+ this.channelType = channelType;
185
+ this.translationsEnabled = translationsEnabled;
150
186
  }
151
187
  }
152
188
 
@@ -165,9 +201,18 @@ export class ZelloDispatchChannel extends ZelloChannel {
165
201
  connectionStatus: ZelloChannelConnectionStatus,
166
202
  usersOnline: number,
167
203
  options: ZelloChannelOptions,
168
- currentCall: ZelloDispatchCall | undefined
204
+ currentCall: ZelloDispatchCall | undefined,
205
+ translationsEnabled: boolean = false
169
206
  ) {
170
- super(name, isMuted, connectionStatus, usersOnline, options);
207
+ super(
208
+ name,
209
+ isMuted,
210
+ connectionStatus,
211
+ usersOnline,
212
+ options,
213
+ ZelloChannelType.Dispatch,
214
+ translationsEnabled
215
+ );
171
216
  this.type = ZelloContactType.DispatchChannel;
172
217
  this.currentCall = currentCall;
173
218
  }
@@ -231,7 +276,15 @@ export class ZelloGroupConversation extends ZelloChannel {
231
276
  users: ZelloChannelUser[],
232
277
  onlineUsers: ZelloChannelUser[]
233
278
  ) {
234
- super(name, isMuted, connectionStatus, usersOnline, options);
279
+ super(
280
+ name,
281
+ isMuted,
282
+ connectionStatus,
283
+ usersOnline,
284
+ options,
285
+ ZelloChannelType.GroupConversation,
286
+ false
287
+ );
235
288
  this.type = ZelloContactType.GroupConversation;
236
289
  this.displayName = displayName;
237
290
  this.users = users;
@@ -282,6 +335,16 @@ export type ZelloChannelOptions = {
282
335
  * When this is true, you should not show any UI to allow the user to send location messages to the channel.
283
336
  */
284
337
  allowLocationMessages: boolean;
338
+ /**
339
+ * Whether the user is allowed to end their own outgoing emergency on this channel.
340
+ * When this is false, you should not show any UI to allow the user to end their own emergency.
341
+ */
342
+ allowEmergencyEndOwn: boolean;
343
+ /**
344
+ * Whether the user is allowed to end another user's incoming emergency on this channel.
345
+ * When this is false, you should not show any UI to allow the user to end another user's emergency.
346
+ */
347
+ allowEmergencyEndOthers: boolean;
285
348
  };
286
349
 
287
350
  /**
@@ -389,15 +452,23 @@ export class ZelloIncomingVoiceMessage implements ZelloMessage {
389
452
  public channelUser: ZelloChannelUser | undefined;
390
453
  public timestamp: number;
391
454
  public incoming = true;
455
+ /**
456
+ * Whether this is a translation message.
457
+ * When true, the message will play as TTS in the listener's language as long as a valid translation arrives;
458
+ * if the translation fails, is empty, or TTS cannot be initiated, the original audio is played instead.
459
+ */
460
+ public isTranslation: boolean;
392
461
 
393
462
  constructor(
394
463
  contact: ZelloContact,
395
464
  channelUser: ZelloChannelUser | undefined,
396
- timestamp: number
465
+ timestamp: number,
466
+ isTranslation: boolean = false
397
467
  ) {
398
468
  this.contact = contact;
399
469
  this.channelUser = channelUser;
400
470
  this.timestamp = timestamp;
471
+ this.isTranslation = isTranslation;
401
472
  }
402
473
  }
403
474
 
@@ -736,6 +807,70 @@ export type ZelloHistoryMessage = {
736
807
  incoming: boolean;
737
808
  };
738
809
 
810
+ /**
811
+ * A translation of a {@link ZelloTranscription} into another language.
812
+ */
813
+ export class ZelloTranslation {
814
+ /**
815
+ * The translated text.
816
+ */
817
+ public readonly text: string;
818
+ /**
819
+ * Language tag of {@link text} as reported by the server (for example "en", "en-US", or "zh-Hans").
820
+ */
821
+ public readonly language: string;
822
+
823
+ constructor(text: string, language: string) {
824
+ this.text = text;
825
+ this.language = language;
826
+ }
827
+ }
828
+
829
+ /**
830
+ * A successful transcription for a Zello voice history message.
831
+ *
832
+ * Transcriptions are produced asynchronously by the Zello server after a voice message
833
+ * has finished sending or receiving, so this object may not be available immediately when
834
+ * the history message is created. Surfaced on {@link ZelloHistoryVoiceMessage#transcription} and
835
+ * delivered via the {@link events.ZelloEvent.HISTORY_VOICE_MESSAGE_TRANSCRIPTION_AVAILABLE | HISTORY_VOICE_MESSAGE_TRANSCRIPTION_AVAILABLE} event.
836
+ */
837
+ export class ZelloTranscription {
838
+ /**
839
+ * The transcribed text, in the language of the sender.
840
+ */
841
+ public readonly text: string | undefined;
842
+ /**
843
+ * Language tag of {@link text} as reported by the server (for example "en", "en-US", or "zh-Hans"), or undefined if unknown.
844
+ */
845
+ public readonly language: string | undefined;
846
+ /**
847
+ * Whether the server truncated {@link text} because the original audio was too long.
848
+ */
849
+ public readonly isTruncated: boolean;
850
+ /**
851
+ * Server-reported confidence in {@link text}, in the range 0.0 to 1.0.
852
+ */
853
+ public readonly confidence: number;
854
+ /**
855
+ * Available translations of {@link text} into other languages, or an empty array if none.
856
+ */
857
+ public readonly translations: ZelloTranslation[];
858
+
859
+ constructor(
860
+ text: string | undefined,
861
+ language: string | undefined,
862
+ isTruncated: boolean,
863
+ confidence: number,
864
+ translations: ZelloTranslation[]
865
+ ) {
866
+ this.text = text;
867
+ this.language = language;
868
+ this.isTruncated = isTruncated;
869
+ this.confidence = confidence;
870
+ this.translations = translations;
871
+ }
872
+ }
873
+
739
874
  /**
740
875
  * A Zello history voice message.
741
876
  * To play the message, use the {@link sdk.Zello#playHistoryMessage | Zello#playHistoryMessage} function.
@@ -750,6 +885,16 @@ export class ZelloHistoryVoiceMessage implements ZelloHistoryMessage {
750
885
  * The duration of the voice message in milliseconds.
751
886
  */
752
887
  public durationMs: number;
888
+ /**
889
+ * The successful transcription for this voice message, or undefined if no transcription has been
890
+ * received yet or the server reported a transcription error.
891
+ *
892
+ * Transcriptions are produced asynchronously by the Zello server after a voice message finishes
893
+ * sending or receiving, so this may be undefined when the message first appears in history and
894
+ * populated later. Subscribe to the {@link events.ZelloEvent.HISTORY_VOICE_MESSAGE_TRANSCRIPTION_AVAILABLE | HISTORY_VOICE_MESSAGE_TRANSCRIPTION_AVAILABLE}
895
+ * event to be notified when a transcription arrives.
896
+ */
897
+ public transcription: ZelloTranscription | undefined;
753
898
 
754
899
  constructor(
755
900
  contact: ZelloContact,
@@ -757,7 +902,8 @@ export class ZelloHistoryVoiceMessage implements ZelloHistoryMessage {
757
902
  timestamp: number,
758
903
  historyId: string,
759
904
  incoming: boolean,
760
- durationMs: number
905
+ durationMs: number,
906
+ transcription: ZelloTranscription | undefined = undefined
761
907
  ) {
762
908
  this.contact = contact;
763
909
  this.channelUser = channelUser;
@@ -765,6 +911,7 @@ export class ZelloHistoryVoiceMessage implements ZelloHistoryMessage {
765
911
  this.historyId = historyId;
766
912
  this.incoming = incoming;
767
913
  this.durationMs = durationMs;
914
+ this.transcription = transcription;
768
915
  }
769
916
  }
770
917
 
@@ -2,6 +2,7 @@ import {
2
2
  ZelloChannel,
3
3
  ZelloChannelConnectionStatus,
4
4
  ZelloChannelOptions,
5
+ ZelloChannelType,
5
6
  ZelloChannelUser,
6
7
  ZelloConsoleSettings,
7
8
  ZelloContact,
@@ -16,6 +17,8 @@ import {
16
17
  ZelloHistoryTextMessage,
17
18
  ZelloHistoryVoiceMessage,
18
19
  ZelloIncomingEmergency,
20
+ ZelloTranscription,
21
+ ZelloTranslation,
19
22
  ZelloUser,
20
23
  ZelloUserStatus,
21
24
  ZelloUserSupportedFeatures,
@@ -52,11 +55,15 @@ export function bridgeContactToSdkContact(
52
55
  allowAlertMessages: eventOptions.allowAlerts,
53
56
  allowLocationMessages: eventOptions.allowLocations,
54
57
  allowTextMessages: eventOptions.allowTextMessages,
58
+ allowEmergencyEndOwn: eventOptions.allowEmergencyEndOwn === true,
59
+ allowEmergencyEndOthers:
60
+ eventOptions.allowEmergencyEndOthers === true,
55
61
  };
56
62
  }
57
63
  if (!options) {
58
64
  return undefined;
59
65
  }
66
+ const translationsEnabled = eventContact.translationsEnabled === true;
60
67
  if (eventContact.isDispatchChannel) {
61
68
  let call: ZelloDispatchCall | undefined;
62
69
  if (eventContact.currentCall) {
@@ -75,7 +82,8 @@ export function bridgeContactToSdkContact(
75
82
  connectionStatus,
76
83
  usersOnline,
77
84
  options,
78
- call
85
+ call,
86
+ translationsEnabled
79
87
  );
80
88
  } else if (eventContact.isGroupConversation) {
81
89
  contact = new ZelloGroupConversation(
@@ -98,7 +106,9 @@ export function bridgeContactToSdkContact(
98
106
  isMuted,
99
107
  connectionStatus,
100
108
  usersOnline,
101
- options
109
+ options,
110
+ bridgeChannelTypeToSdkChannelType(eventContact.channelType),
111
+ translationsEnabled
102
112
  );
103
113
  }
104
114
  } else {
@@ -123,6 +133,42 @@ export function bridgeContactToSdkContact(
123
133
  return contact;
124
134
  }
125
135
 
136
+ function bridgeChannelTypeToSdkChannelType(channelType: any): ZelloChannelType {
137
+ switch (channelType?.toLowerCase()) {
138
+ case 'dispatch':
139
+ return ZelloChannelType.Dispatch;
140
+ case 'team':
141
+ return ZelloChannelType.Team;
142
+ case 'group_conversation':
143
+ return ZelloChannelType.GroupConversation;
144
+ default:
145
+ return ZelloChannelType.Dynamic;
146
+ }
147
+ }
148
+
149
+ export function bridgeTranscriptionToSdkTranscription(
150
+ transcription: any
151
+ ): ZelloTranscription | undefined {
152
+ if (!transcription) {
153
+ return undefined;
154
+ }
155
+ const translations = Array.isArray(transcription.translations)
156
+ ? transcription.translations
157
+ .filter((translation: any) => translation?.text != null)
158
+ .map(
159
+ (translation: any) =>
160
+ new ZelloTranslation(translation.text, translation.language)
161
+ )
162
+ : [];
163
+ return new ZelloTranscription(
164
+ transcription.text ?? undefined,
165
+ transcription.language ?? undefined,
166
+ transcription.isTruncated === true,
167
+ transcription.confidence ?? 0,
168
+ translations
169
+ );
170
+ }
171
+
126
172
  export function bridgeIncomingEmergencyToSdkIncomingEmergency(
127
173
  emergency: any
128
174
  ): ZelloIncomingEmergency | undefined {
@@ -155,7 +201,8 @@ export function bridgeHistoryMessageToSdkHistoryMessage(
155
201
  parseInt(message.timestamp, 10),
156
202
  message.historyId,
157
203
  message.incoming,
158
- message.durationMs
204
+ message.durationMs,
205
+ bridgeTranscriptionToSdkTranscription(message.transcription)
159
206
  );
160
207
  case 'image':
161
208
  return new ZelloHistoryImageMessage(