@webex/plugin-meetings 3.12.0-next.6 → 3.12.0-next.61

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 (158) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +15 -2
  3. package/dist/aiEnableRequest/index.js.map +1 -1
  4. package/dist/breakouts/breakout.js +8 -3
  5. package/dist/breakouts/breakout.js.map +1 -1
  6. package/dist/breakouts/index.js +26 -2
  7. package/dist/breakouts/index.js.map +1 -1
  8. package/dist/config.js +2 -0
  9. package/dist/config.js.map +1 -1
  10. package/dist/constants.js +6 -3
  11. package/dist/constants.js.map +1 -1
  12. package/dist/controls-options-manager/constants.js +11 -1
  13. package/dist/controls-options-manager/constants.js.map +1 -1
  14. package/dist/controls-options-manager/index.js +38 -24
  15. package/dist/controls-options-manager/index.js.map +1 -1
  16. package/dist/controls-options-manager/util.js +91 -0
  17. package/dist/controls-options-manager/util.js.map +1 -1
  18. package/dist/hashTree/constants.js +10 -1
  19. package/dist/hashTree/constants.js.map +1 -1
  20. package/dist/hashTree/hashTreeParser.js +716 -370
  21. package/dist/hashTree/hashTreeParser.js.map +1 -1
  22. package/dist/hashTree/utils.js +22 -0
  23. package/dist/hashTree/utils.js.map +1 -1
  24. package/dist/index.js +7 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/interceptors/locusRetry.js +23 -8
  27. package/dist/interceptors/locusRetry.js.map +1 -1
  28. package/dist/interpretation/index.js +10 -1
  29. package/dist/interpretation/index.js.map +1 -1
  30. package/dist/interpretation/siLanguage.js +1 -1
  31. package/dist/locus-info/controlsUtils.js +4 -1
  32. package/dist/locus-info/controlsUtils.js.map +1 -1
  33. package/dist/locus-info/index.js +289 -87
  34. package/dist/locus-info/index.js.map +1 -1
  35. package/dist/locus-info/types.js +19 -0
  36. package/dist/locus-info/types.js.map +1 -1
  37. package/dist/media/index.js +3 -1
  38. package/dist/media/index.js.map +1 -1
  39. package/dist/media/properties.js +1 -0
  40. package/dist/media/properties.js.map +1 -1
  41. package/dist/meeting/in-meeting-actions.js +3 -1
  42. package/dist/meeting/in-meeting-actions.js.map +1 -1
  43. package/dist/meeting/index.js +907 -535
  44. package/dist/meeting/index.js.map +1 -1
  45. package/dist/meeting/util.js +19 -2
  46. package/dist/meeting/util.js.map +1 -1
  47. package/dist/meetings/index.js +231 -78
  48. package/dist/meetings/index.js.map +1 -1
  49. package/dist/meetings/meetings.types.js +6 -1
  50. package/dist/meetings/meetings.types.js.map +1 -1
  51. package/dist/meetings/request.js +39 -0
  52. package/dist/meetings/request.js.map +1 -1
  53. package/dist/meetings/util.js +79 -5
  54. package/dist/meetings/util.js.map +1 -1
  55. package/dist/member/index.js +10 -0
  56. package/dist/member/index.js.map +1 -1
  57. package/dist/member/types.js.map +1 -1
  58. package/dist/member/util.js +3 -0
  59. package/dist/member/util.js.map +1 -1
  60. package/dist/metrics/constants.js +4 -1
  61. package/dist/metrics/constants.js.map +1 -1
  62. package/dist/multistream/codec/constants.js +63 -0
  63. package/dist/multistream/codec/constants.js.map +1 -0
  64. package/dist/multistream/mediaRequestManager.js +62 -15
  65. package/dist/multistream/mediaRequestManager.js.map +1 -1
  66. package/dist/multistream/receiveSlot.js +9 -0
  67. package/dist/multistream/receiveSlot.js.map +1 -1
  68. package/dist/reactions/reactions.type.js.map +1 -1
  69. package/dist/recording-controller/index.js +1 -3
  70. package/dist/recording-controller/index.js.map +1 -1
  71. package/dist/types/config.d.ts +2 -0
  72. package/dist/types/constants.d.ts +2 -0
  73. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  74. package/dist/types/controls-options-manager/index.d.ts +10 -0
  75. package/dist/types/hashTree/constants.d.ts +1 -0
  76. package/dist/types/hashTree/hashTreeParser.d.ts +92 -16
  77. package/dist/types/hashTree/utils.d.ts +11 -0
  78. package/dist/types/index.d.ts +2 -0
  79. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  80. package/dist/types/locus-info/index.d.ts +46 -6
  81. package/dist/types/locus-info/types.d.ts +21 -1
  82. package/dist/types/media/properties.d.ts +1 -0
  83. package/dist/types/meeting/in-meeting-actions.d.ts +2 -0
  84. package/dist/types/meeting/index.d.ts +87 -3
  85. package/dist/types/meeting/util.d.ts +8 -0
  86. package/dist/types/meetings/index.d.ts +30 -2
  87. package/dist/types/meetings/meetings.types.d.ts +15 -0
  88. package/dist/types/meetings/request.d.ts +14 -0
  89. package/dist/types/member/index.d.ts +1 -0
  90. package/dist/types/member/types.d.ts +1 -0
  91. package/dist/types/member/util.d.ts +1 -0
  92. package/dist/types/metrics/constants.d.ts +3 -0
  93. package/dist/types/multistream/codec/constants.d.ts +7 -0
  94. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  95. package/dist/types/reactions/reactions.type.d.ts +3 -0
  96. package/dist/webinar/index.js +361 -235
  97. package/dist/webinar/index.js.map +1 -1
  98. package/package.json +22 -22
  99. package/src/aiEnableRequest/index.ts +16 -0
  100. package/src/breakouts/breakout.ts +3 -1
  101. package/src/breakouts/index.ts +31 -0
  102. package/src/config.ts +2 -0
  103. package/src/constants.ts +5 -1
  104. package/src/controls-options-manager/constants.ts +14 -1
  105. package/src/controls-options-manager/index.ts +47 -24
  106. package/src/controls-options-manager/util.ts +81 -1
  107. package/src/hashTree/constants.ts +9 -0
  108. package/src/hashTree/hashTreeParser.ts +429 -183
  109. package/src/hashTree/utils.ts +17 -0
  110. package/src/index.ts +5 -0
  111. package/src/interceptors/locusRetry.ts +25 -4
  112. package/src/interpretation/index.ts +25 -8
  113. package/src/locus-info/controlsUtils.ts +3 -1
  114. package/src/locus-info/index.ts +291 -97
  115. package/src/locus-info/types.ts +25 -1
  116. package/src/media/index.ts +3 -0
  117. package/src/media/properties.ts +1 -0
  118. package/src/meeting/in-meeting-actions.ts +4 -0
  119. package/src/meeting/index.ts +388 -33
  120. package/src/meeting/util.ts +20 -2
  121. package/src/meetings/index.ts +134 -44
  122. package/src/meetings/meetings.types.ts +19 -0
  123. package/src/meetings/request.ts +43 -0
  124. package/src/meetings/util.ts +97 -1
  125. package/src/member/index.ts +10 -0
  126. package/src/member/types.ts +1 -0
  127. package/src/member/util.ts +3 -0
  128. package/src/metrics/constants.ts +3 -0
  129. package/src/multistream/codec/constants.ts +58 -0
  130. package/src/multistream/mediaRequestManager.ts +119 -28
  131. package/src/multistream/receiveSlot.ts +18 -0
  132. package/src/reactions/reactions.type.ts +3 -0
  133. package/src/recording-controller/index.ts +1 -2
  134. package/src/webinar/index.ts +162 -21
  135. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  136. package/test/unit/spec/breakouts/breakout.ts +9 -3
  137. package/test/unit/spec/breakouts/index.ts +49 -0
  138. package/test/unit/spec/controls-options-manager/index.js +140 -29
  139. package/test/unit/spec/controls-options-manager/util.js +165 -0
  140. package/test/unit/spec/hashTree/hashTreeParser.ts +1508 -149
  141. package/test/unit/spec/hashTree/utils.ts +88 -1
  142. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  143. package/test/unit/spec/interpretation/index.ts +26 -4
  144. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  145. package/test/unit/spec/locus-info/index.js +475 -81
  146. package/test/unit/spec/media/index.ts +31 -0
  147. package/test/unit/spec/meeting/in-meeting-actions.ts +2 -0
  148. package/test/unit/spec/meeting/index.js +1131 -49
  149. package/test/unit/spec/meeting/muteState.js +3 -0
  150. package/test/unit/spec/meeting/utils.js +33 -0
  151. package/test/unit/spec/meetings/index.js +360 -10
  152. package/test/unit/spec/meetings/request.js +141 -0
  153. package/test/unit/spec/meetings/utils.js +189 -0
  154. package/test/unit/spec/member/index.js +7 -0
  155. package/test/unit/spec/member/util.js +24 -0
  156. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  157. package/test/unit/spec/recording-controller/index.js +9 -8
  158. package/test/unit/spec/webinar/index.ts +141 -16
@@ -34,6 +34,7 @@ import BEHAVIORAL_METRICS from '../metrics/constants';
34
34
  import HashTreeParser, {
35
35
  DataSet,
36
36
  HashTreeMessage,
37
+ LocusInfoUpdate,
37
38
  LocusInfoUpdateType,
38
39
  Metadata,
39
40
  } from '../hashTree/hashTreeParser';
@@ -97,7 +98,7 @@ export type HashTreeParserEntry = {
97
98
  * Gets the replacement information
98
99
  *
99
100
  * @param {any} self - "self" object from Locus DTO
100
- * @param {string} deviceUrl - The URL of the user's device
101
+ * @param {string} deviceUrl - The URL of the specified device
101
102
  * @returns {any} The replace information if available, otherwise undefined
102
103
  */
103
104
  function getReplaceInfoFromSelf(self: any, deviceUrl: string): ReplacesInfo | undefined {
@@ -137,14 +138,15 @@ function findLocusUrlInAnyHashTreeParser(
137
138
  *
138
139
  * @param {HashTreeMessage} message - The hash tree message to find the meeting for
139
140
  * @param {MeetingCollection} meetingCollection - The collection of meetings to search
140
- * @param {string} deviceUrl - The URL of the user's device
141
141
  * @returns {any} The meeting if found, otherwise undefined
142
142
  */
143
143
  export function findMeetingForHashTreeMessage(
144
- message: HashTreeMessage,
145
- meetingCollection: MeetingCollection,
146
- deviceUrl: string
144
+ message: HashTreeMessage | undefined,
145
+ meetingCollection: MeetingCollection
147
146
  ): any {
147
+ if (!message) {
148
+ return undefined;
149
+ }
148
150
  let foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, message.locusUrl);
149
151
 
150
152
  if (foundMeeting) {
@@ -154,7 +156,7 @@ export function findMeetingForHashTreeMessage(
154
156
  // if we haven't found anything, it may mean that message has a new locusUrl
155
157
  // check if it indicates that it replaces some existing current locusUrl (this is indicated in "self")
156
158
  const self = message.locusStateElements?.find((el) => isSelf(el))?.data;
157
- const replaces = getReplaceInfoFromSelf(self, deviceUrl);
159
+ const replaces = getReplaceInfoFromSelf(self, self?.deviceUrl);
158
160
 
159
161
  if (replaces?.locusUrl) {
160
162
  foundMeeting = findLocusUrlInAnyHashTreeParser(meetingCollection, replaces.locusUrl);
@@ -545,7 +547,7 @@ export default class LocusInfo extends EventsScope {
545
547
  dataSets: Array<DataSet>;
546
548
  locus: any;
547
549
  };
548
- metadata: Metadata;
550
+ metadata: Metadata | null;
549
551
  replacedAt?: string;
550
552
  }): HashTreeParser {
551
553
  const parser = new HashTreeParser({
@@ -553,7 +555,7 @@ export default class LocusInfo extends EventsScope {
553
555
  metadata,
554
556
  webexRequest: this.webex.request.bind(this.webex),
555
557
  locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
556
- debugId: `HT-${locusUrl.split('/').pop().substring(0, 4)}`,
558
+ debugId: `HT-${locusUrl.split('/')?.pop()?.substring(0, 4)}`,
557
559
  excludedDataSets: this.webex.config.meetings.locus?.excludedDataSets,
558
560
  });
559
561
 
@@ -580,6 +582,7 @@ export default class LocusInfo extends EventsScope {
580
582
 
581
583
  /**
582
584
  * @param {Object} data - data to initialize locus info with. It may be from a join or GET /loci response or from a Mercury event that triggers a creation of meeting object
585
+ * @param {Function} [onLocusSynced] - optional callback that will be called at the end of initial setup, when locus info is fully synced. It will be called with the full locus snapshot as an argument (which may be null if we haven't received any full locus DTOs during the initial setup, for example in case we receive only hash tree messages without full locus DTOs)
583
586
  * @returns {undefined}
584
587
  * @memberof LocusInfo
585
588
  */
@@ -599,8 +602,10 @@ export default class LocusInfo extends EventsScope {
599
602
  | {
600
603
  trigger: 'get-loci-response';
601
604
  locus?: LocusDTO;
602
- }
605
+ },
606
+ onLocusSynced?: (locus: LocusDTO) => void
603
607
  ) {
608
+ let initialFullLocus: LocusDTO | null = null;
604
609
  switch (data.trigger) {
605
610
  case 'locus-message':
606
611
  if (data.hashTreeMessage) {
@@ -648,6 +653,7 @@ export default class LocusInfo extends EventsScope {
648
653
  case 'join-response':
649
654
  this.updateLocusCache(data.locus);
650
655
  this.onFullLocus('join response', data.locus, undefined, data.dataSets, data.metadata);
656
+ initialFullLocus = data.locus;
651
657
  break;
652
658
  case 'get-loci-response':
653
659
  if (data.locus?.links?.resources?.visibleDataSets?.url) {
@@ -656,7 +662,7 @@ export default class LocusInfo extends EventsScope {
656
662
  );
657
663
  // first create the HashTreeParser, but don't initialize it with any data yet
658
664
  const hashTreeParser = this.createHashTreeParser({
659
- locusUrl: data.locus.url,
665
+ locusUrl: data.locus.url as string,
660
666
  initialLocus: {
661
667
  locus: null,
662
668
  dataSets: [], // empty, because we don't have them yet
@@ -670,52 +676,99 @@ export default class LocusInfo extends EventsScope {
670
676
  // "classic" Locus case, no hash trees involved
671
677
  this.updateLocusCache(data.locus);
672
678
  this.onFullLocus('classic get-loci-response', data.locus, undefined);
679
+ initialFullLocus = data.locus || null;
673
680
  }
674
681
  }
682
+
683
+ if (onLocusSynced) {
684
+ try {
685
+ onLocusSynced(initialFullLocus || this.getCurrentLocusSnapshot());
686
+ } catch (error) {
687
+ LoggerProxy.logger.warn(
688
+ `Locus-info:index#initialSetup --> onLocusSynced callback failed: ${error}`
689
+ );
690
+ }
691
+ }
692
+
675
693
  // Change it to true after it receives it first locus object
676
694
  this.emitChange = true;
677
695
  }
678
696
 
697
+ /**
698
+ * Builds a full locus DTO snapshot from current internal locus state.
699
+ *
700
+ * @returns {LocusDTO}
701
+ */
702
+ private getCurrentLocusSnapshot(): LocusDTO {
703
+ const locus: Record<string, any> = {};
704
+
705
+ LocusDtoTopLevelKeys.forEach((key) => {
706
+ const value = (this as Record<string, any>)[key];
707
+
708
+ if (value !== undefined && value !== null) {
709
+ locus[key] = cloneDeep(value);
710
+ }
711
+ });
712
+
713
+ if (!Array.isArray(locus.participants)) {
714
+ locus.participants = [];
715
+ }
716
+
717
+ return locus as LocusDTO;
718
+ }
719
+
679
720
  /**
680
721
  * Handles HTTP response from Locus API call.
681
722
  * @param {Meeting} meeting meeting object
682
723
  * @param {LocusApiResponseBody} responseBody body of the http response from Locus API call
683
724
  * @returns {void}
684
725
  */
685
- handleLocusAPIResponse(meeting, responseBody: LocusApiResponseBody): void {
726
+ handleLocusAPIResponse(meeting: any, responseBody: LocusApiResponseBody): void {
686
727
  const isWrapped = 'locus' in responseBody;
687
728
  const locusUrl = isWrapped ? responseBody.locus?.url : responseBody.url;
688
729
  const hashTreeParserEntry = locusUrl && this.hashTreeParsers.get(locusUrl);
689
- if (hashTreeParserEntry) {
690
- if (isWrapped) {
691
- if (!responseBody.dataSets) {
692
- this.sendClassicVsHashTreeMismatchMetric(
693
- meeting,
694
- `expected hash tree dataSets in API response but they are missing`
730
+ const locus = isWrapped
731
+ ? (responseBody as {locus: LocusDTO}).locus
732
+ : (responseBody as LocusDTO);
733
+
734
+ if (this.hashTreeParsers.size > 0) {
735
+ // We are in hash tree mode. Check if we need to create/reactivate a parser for this locusUrl.
736
+ if (!hashTreeParserEntry || hashTreeParserEntry.parser.state === 'stopped') {
737
+ if (!locusUrl) {
738
+ LoggerProxy.logger.warn(
739
+ 'Locus-info:index#handleLocusAPIResponse --> API response has no locusUrl, cannot handle hash tree parser switch'
695
740
  );
696
- // continuing as we can still manage without responseBody.dataSets, but this is very suspicious
741
+
742
+ return;
697
743
  }
698
- LoggerProxy.logger.info(
699
- 'Locus-info:index#handleLocusAPIResponse --> passing Locus API response to HashTreeParser: ',
700
- responseBody
701
- );
744
+
745
+ this.handleHashTreeParserSwitchForAPIResponse(locusUrl, locus);
746
+
747
+ return;
748
+ }
749
+
750
+ // Active parser found - pass the API response to it
751
+ if (isWrapped) {
702
752
  // update the data in our hash trees
703
753
  hashTreeParserEntry.parser.handleLocusUpdate(responseBody);
704
754
  } else {
705
- // LocusDTO without wrapper - pass it through as if it had no dataSets
755
+ // LocusDTO without wrapper - pass it through as if it had no dataSets nor metadata
706
756
  hashTreeParserEntry.parser.handleLocusUpdate({locus: responseBody});
707
757
  }
708
- } else {
709
- if (isWrapped && responseBody.dataSets) {
710
- this.sendClassicVsHashTreeMismatchMetric(
711
- meeting,
712
- `unexpected hash tree dataSets in API response`
713
- );
714
- }
715
- // classic Locus delta
716
- const locus = isWrapped ? responseBody.locus : responseBody;
717
- this.handleLocusDelta(locus, meeting);
758
+
759
+ return;
718
760
  }
761
+
762
+ // No hash tree parsers - classic Locus mode
763
+ if (isWrapped && responseBody.dataSets) {
764
+ this.sendClassicVsHashTreeMismatchMetric(
765
+ meeting,
766
+ `unexpected hash tree dataSets in API response`
767
+ );
768
+ }
769
+
770
+ // classic Locus delta
771
+ this.handleLocusDelta(locus, meeting);
719
772
  }
720
773
 
721
774
  /**
@@ -944,6 +997,114 @@ export default class LocusInfo extends EventsScope {
944
997
  }
945
998
  }
946
999
 
1000
+ /**
1001
+ * Helper that handles the common logic for reactivating a stopped HashTreeParser when
1002
+ * a newer "replaces" is detected. Used by both the message and API response parser switch methods.
1003
+ *
1004
+ * @param {string} callerName - name of the calling method, used in log messages
1005
+ * @param {string} locusUrl - the locus URL of the stopped parser
1006
+ * @param {HashTreeParserEntry} stoppedEntry - the stopped parser entry
1007
+ * @param {ReplacesInfo} replaces - replacement info extracted from self
1008
+ * @param {Function} resumeCallback - callback to invoke after reactivation to resume the parser
1009
+ * @returns {void}
1010
+ */
1011
+ private resumeStoppedParser(
1012
+ callerName: string,
1013
+ locusUrl: string,
1014
+ stoppedEntry: HashTreeParserEntry,
1015
+ replaces: ReplacesInfo | undefined,
1016
+ resumeCallback: () => void
1017
+ ): void {
1018
+ // this check is just for typescript, it should never happen, replaces should always be defined
1019
+ if (!replaces) {
1020
+ LoggerProxy.logger.info(
1021
+ `Locus-info:index#${callerName} --> received data for stopped HashTreeParser with locusUrl ${locusUrl}, but no replaces info provided, so not re-activating the parser`
1022
+ );
1023
+
1024
+ return;
1025
+ }
1026
+
1027
+ if (replaces.replacedAt <= (stoppedEntry.replacedAt || '')) {
1028
+ LoggerProxy.logger.info(
1029
+ `Locus-info:index#${callerName} --> received data for stopped HashTreeParser with locusUrl ${locusUrl}, but replaces info provided is not newer, so not re-activating the parser`
1030
+ );
1031
+
1032
+ return;
1033
+ }
1034
+
1035
+ LoggerProxy.logger.info(
1036
+ `Locus-info:index#${callerName} --> reactivating HashTreeParser for locusUrl=${locusUrl}, which replaces ${replaces.locusUrl}`
1037
+ );
1038
+
1039
+ const replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
1040
+
1041
+ if (replacedEntry) {
1042
+ replacedEntry.replacedAt = replaces.replacedAt;
1043
+ replacedEntry.parser.stop();
1044
+ } else {
1045
+ LoggerProxy.logger.warn(
1046
+ `Locus-info:index#${callerName} --> the parser that is supposed to be replaced with the currently reactivated parser is not found, locusUrl=${replaces.locusUrl}`
1047
+ );
1048
+ }
1049
+
1050
+ stoppedEntry.initializedFromHashTree = false;
1051
+ this.hashTreeObjectId2ParticipantId.clear();
1052
+
1053
+ resumeCallback();
1054
+ }
1055
+
1056
+ /**
1057
+ * Handles an API response whose locusUrl doesn't match any active HashTreeParser
1058
+ * (either no entry exists, or the existing entry is stopped).
1059
+ * Creates a new parser or reactivates a stopped one using initializeFromGetLociResponse.
1060
+ *
1061
+ * @param {string} locusUrl - the locus URL from the API response
1062
+ * @param {LocusDTO} locus - the locus DTO from the API response
1063
+ * @returns {void}
1064
+ */
1065
+ private handleHashTreeParserSwitchForAPIResponse(locusUrl: string, locus: LocusDTO): void {
1066
+ const entry = this.hashTreeParsers.get(locusUrl);
1067
+
1068
+ const replaces = getReplaceInfoFromSelf(
1069
+ locus.self,
1070
+ // @ts-ignore
1071
+ this.webex.internal.device.url
1072
+ );
1073
+
1074
+ if (!entry) {
1075
+ LoggerProxy.logger.info(
1076
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> no parser for locusUrl ${locusUrl}, creating a new one`
1077
+ );
1078
+
1079
+ const parser = this.createHashTreeParser({
1080
+ locusUrl,
1081
+ initialLocus: {locus: null, dataSets: []},
1082
+ metadata: null,
1083
+ replacedAt: replaces?.replacedAt,
1084
+ });
1085
+
1086
+ parser.initializeFromGetLociResponse(locus);
1087
+
1088
+ return;
1089
+ }
1090
+
1091
+ if (entry.parser.state !== 'stopped') {
1092
+ LoggerProxy.logger.warn(
1093
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> unexpected parser state "${entry.parser.state}" for locusUrl ${locusUrl}`
1094
+ );
1095
+
1096
+ return;
1097
+ }
1098
+
1099
+ this.resumeStoppedParser(
1100
+ 'handleHashTreeParserSwitchForAPIResponse',
1101
+ locusUrl,
1102
+ entry,
1103
+ replaces,
1104
+ () => entry.parser.resumeFromApiResponse(locus)
1105
+ );
1106
+ }
1107
+
947
1108
  /**
948
1109
  * Checks if the hash tree message should trigger a switch to a different HashTreeParser
949
1110
  *
@@ -965,7 +1126,7 @@ export default class LocusInfo extends EventsScope {
965
1126
  // but it's buried inside the message, we need to find it and pass it to HashTreeParser constructor
966
1127
  const metadata = message.locusStateElements?.find((el) => isMetadata(el));
967
1128
 
968
- if (metadata?.data?.visibleDataSets?.length > 0) {
1129
+ if (metadata && metadata.data?.visibleDataSets?.length > 0) {
969
1130
  LoggerProxy.logger.info(
970
1131
  `Locus-info:index#handleHashTreeParserSwitch --> no hash tree parser found for locusUrl ${message.locusUrl}, creating a new one`
971
1132
  );
@@ -992,36 +1153,12 @@ export default class LocusInfo extends EventsScope {
992
1153
  if (entry.parser.state === 'stopped') {
993
1154
  // the message matches a stopped parser, we need to check if maybe this is a new "replacement" and we need to re-activate the parser
994
1155
  // this happens when you move from breakout A -> breakout B -> back to breakout A
995
- if (replaces) {
996
- if (replaces.replacedAt > (entry.replacedAt || '')) {
997
- LoggerProxy.logger.info(
998
- `Locus-info:index#handleHashTreeParserSwitch --> resuming a HashTreeParser for locusUrl=${message.locusUrl}, which replaces ${replaces.locusUrl}`
999
- );
1000
- const replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
1001
-
1002
- if (replacedEntry) {
1003
- replacedEntry.replacedAt = replaces.replacedAt;
1004
- entry.initializedFromHashTree = false;
1005
- this.hashTreeObjectId2ParticipantId.clear();
1006
-
1007
- replacedEntry.parser.stop();
1008
- entry.parser.resume(message);
1009
- } else {
1010
- LoggerProxy.logger.warn(
1011
- `Locus-info:index#handleHashTreeParserSwitch --> the parser that is supposed to be replaced with the currently resumed parser is not found, locusUrl=${replaces.locusUrl}`
1012
- );
1013
- }
1014
- } else {
1015
- LoggerProxy.logger.info(
1016
- `Locus-info:index#handleHashTreeParserSwitch --> received message for stopped HashTreeParser with locusUrl ${message.locusUrl}, but replaces info provided is not newer, so not re-activating the parser`
1017
- );
1018
- }
1019
-
1020
- return true;
1021
- }
1022
-
1023
- LoggerProxy.logger.info(
1024
- `Locus-info:index#handleHashTreeParserSwitch --> received message for stopped HashTreeParser with locusUrl ${message.locusUrl}, but no replaces info provided, so not re-activating the parser`
1156
+ this.resumeStoppedParser(
1157
+ 'handleHashTreeParserSwitch',
1158
+ message.locusUrl,
1159
+ entry,
1160
+ replaces,
1161
+ () => entry.parser.resumeFromMessage(message)
1025
1162
  );
1026
1163
 
1027
1164
  return true;
@@ -1056,7 +1193,25 @@ export default class LocusInfo extends EventsScope {
1056
1193
 
1057
1194
  const entry = this.hashTreeParsers.get(message.locusUrl);
1058
1195
 
1059
- entry.parser.handleMessage(message);
1196
+ // the check is just for typescript, the case of no entry in hashTreeParsers is handled in handleHashTreeParserSwitch() above
1197
+ if (entry) {
1198
+ entry.parser.handleMessage(message);
1199
+ }
1200
+ }
1201
+
1202
+ /**
1203
+ * Triggers a sync of all hash tree datasets for all hash tree parsers associated with this meeting.
1204
+ * The syncs are executed sequentially within each parser.
1205
+ *
1206
+ * @returns {Promise<void>}
1207
+ */
1208
+ async syncAllHashTreeDatasets(): Promise<void> {
1209
+ for (const [, entry] of this.hashTreeParsers) {
1210
+ if (entry.parser) {
1211
+ // eslint-disable-next-line no-await-in-loop
1212
+ await entry.parser.syncAllDatasets();
1213
+ }
1214
+ }
1060
1215
  }
1061
1216
 
1062
1217
  /**
@@ -1064,16 +1219,11 @@ export default class LocusInfo extends EventsScope {
1064
1219
  * Updates our locus info based on the data parsed by the hash tree parser.
1065
1220
  *
1066
1221
  * @param {string} locusUrl - the locus URL for which the update is received
1067
- * @param {LocusInfoUpdateType} updateType - The type of update received.
1068
- * @param {Object} [data] - Additional data for the update, if applicable.
1222
+ * @param {LocusInfoUpdate} update - Details about the update.
1069
1223
  * @returns {void}
1070
1224
  */
1071
- private updateFromHashTree(
1072
- locusUrl: string,
1073
- updateType: LocusInfoUpdateType,
1074
- data?: {updatedObjects: HashTreeObject[]}
1075
- ) {
1076
- switch (updateType) {
1225
+ private updateFromHashTree(locusUrl: string, update: LocusInfoUpdate) {
1226
+ switch (update.updateType) {
1077
1227
  case LocusInfoUpdateType.OBJECTS_UPDATED: {
1078
1228
  // initialize our new locus
1079
1229
  let locus: LocusDTO = {
@@ -1087,7 +1237,7 @@ export default class LocusInfo extends EventsScope {
1087
1237
  // first go over all the updates and check what happens with the main locus object
1088
1238
  let locusObjectStateAfterUpdates: LocusObjectStateAfterUpdates =
1089
1239
  LocusObjectStateAfterUpdates.unchanged;
1090
- data.updatedObjects.forEach((object) => {
1240
+ update.updatedObjects.forEach((object) => {
1091
1241
  if (object.htMeta.elementId.type.toLowerCase() === ObjectType.locus) {
1092
1242
  if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.updated) {
1093
1243
  // this code doesn't supported it right now,
@@ -1116,6 +1266,14 @@ export default class LocusInfo extends EventsScope {
1116
1266
 
1117
1267
  const hashTreeParserEntry = this.hashTreeParsers.get(locusUrl);
1118
1268
 
1269
+ if (!hashTreeParserEntry) {
1270
+ LoggerProxy.logger.warn(
1271
+ `Locus-info:index#updateFromHashTree --> no HashTreeParser found for locusUrl ${locusUrl} when trying to apply updates from hash tree`
1272
+ );
1273
+
1274
+ return;
1275
+ }
1276
+
1119
1277
  if (!hashTreeParserEntry.initializedFromHashTree) {
1120
1278
  // this is the first time we're getting an update for this locusUrl,
1121
1279
  // so it's probably a move to/from breakout. We need to start from a clean state,
@@ -1124,7 +1282,8 @@ export default class LocusInfo extends EventsScope {
1124
1282
  `Locus-info:index#updateFromHashTree --> first INITIAL update for locusUrl ${locusUrl}, starting from empty state`
1125
1283
  );
1126
1284
  hashTreeParserEntry.initializedFromHashTree = true;
1127
- locus.jsSdkMeta.forceReplaceMembers = true;
1285
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1286
+ locus.jsSdkMeta!.forceReplaceMembers = true;
1128
1287
  } else if (
1129
1288
  // if Locus object is unchanged or removed, we need to keep using the existing locus
1130
1289
  // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
@@ -1137,7 +1296,7 @@ export default class LocusInfo extends EventsScope {
1137
1296
  // copy over all of existing locus except participants
1138
1297
  LocusDtoTopLevelKeys.forEach((key) => {
1139
1298
  if (key !== 'participants') {
1140
- locus[key] = cloneDeep(this[key]);
1299
+ (locus as Record<string, any>)[key] = cloneDeep((this as Record<string, any>)[key]);
1141
1300
  }
1142
1301
  });
1143
1302
  } else {
@@ -1145,14 +1304,16 @@ export default class LocusInfo extends EventsScope {
1145
1304
  // (except participants, which need to stay empty - that means "no participant changes")
1146
1305
  Object.values(ObjectTypeToLocusKeyMap).forEach((locusDtoKey) => {
1147
1306
  if (locusDtoKey !== 'participants') {
1148
- locus[locusDtoKey] = cloneDeep(this[locusDtoKey]);
1307
+ (locus as Record<string, any>)[locusDtoKey] = cloneDeep(
1308
+ (this as Record<string, any>)[locusDtoKey]
1309
+ );
1149
1310
  }
1150
1311
  });
1151
1312
  }
1152
1313
 
1153
1314
  LoggerProxy.logger.info(
1154
1315
  `Locus-info:index#updateFromHashTree --> LOCUS object is ${locusObjectStateAfterUpdates}, all updates: ${JSON.stringify(
1155
- data.updatedObjects.map((o) => ({
1316
+ update.updatedObjects.map((o) => ({
1156
1317
  type: o.htMeta.elementId.type,
1157
1318
  id: o.htMeta.elementId.id,
1158
1319
  hasData: !!o.data,
@@ -1160,7 +1321,7 @@ export default class LocusInfo extends EventsScope {
1160
1321
  )}`
1161
1322
  );
1162
1323
  // now apply all the updates from the hash tree onto the locus
1163
- data.updatedObjects.forEach((object) => {
1324
+ update.updatedObjects.forEach((object) => {
1164
1325
  locus = this.updateLocusFromHashTreeObject(object, locus);
1165
1326
  });
1166
1327
 
@@ -1179,6 +1340,21 @@ export default class LocusInfo extends EventsScope {
1179
1340
  );
1180
1341
  this.webex.meetings.destroy(meeting, MEETING_REMOVED_REASON.SELF_REMOVED);
1181
1342
  }
1343
+ break;
1344
+ }
1345
+
1346
+ case LocusInfoUpdateType.LOCUS_NOT_FOUND: {
1347
+ LoggerProxy.logger.info(
1348
+ `Locus-info:index#updateFromHashTree --> received LOCUS_NOT_FOUND for ${locusUrl}, triggering syncMeetings`
1349
+ );
1350
+ this.webex.meetings
1351
+ .syncMeetings({keepOnlyLocusMeetings: false, skipHashTreeSync: true})
1352
+ .catch((syncError) => {
1353
+ LoggerProxy.logger.error(
1354
+ `Locus-info:index#updateFromHashTree --> syncMeetings failed after LOCUS_NOT_FOUND: ${syncError}`
1355
+ );
1356
+ });
1357
+ break;
1182
1358
  }
1183
1359
  }
1184
1360
  }
@@ -1191,11 +1367,17 @@ export default class LocusInfo extends EventsScope {
1191
1367
  */
1192
1368
  parse(meeting: any, data: any) {
1193
1369
  if (this.hashTreeParsers.size > 0) {
1194
- this.handleHashTreeMessage(
1195
- meeting,
1196
- data.eventType,
1197
- data.stateElementsMessage as HashTreeMessage
1198
- );
1370
+ if (data.eventType === LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS) {
1371
+ // sync meetings response follows the format of "not wrapped" locus API responses,
1372
+ // so has no dataSets nor Metadata
1373
+ this.handleLocusAPIResponse(meeting, {...data.locus});
1374
+ } else {
1375
+ this.handleHashTreeMessage(
1376
+ meeting,
1377
+ data.eventType,
1378
+ data.stateElementsMessage as HashTreeMessage
1379
+ );
1380
+ }
1199
1381
  } else {
1200
1382
  const {eventType} = data;
1201
1383
 
@@ -1260,16 +1442,16 @@ export default class LocusInfo extends EventsScope {
1260
1442
  * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
1261
1443
  * @param {object} locus locus object
1262
1444
  * @param {object} metadata locus hash trees metadata
1263
- * @param {string} eventType locus event
1264
1445
  * @param {DataSet[]} dataSets
1446
+ * @param {string} eventType locus event
1265
1447
  * @returns {void}
1266
1448
  */
1267
1449
  private onFullLocusWithHashTrees(
1268
1450
  debugText: string,
1269
1451
  locus: any,
1270
1452
  metadata: Metadata,
1271
- eventType?: string,
1272
- dataSets?: Array<DataSet>
1453
+ dataSets: Array<DataSet>,
1454
+ eventType?: string
1273
1455
  ) {
1274
1456
  if (!this.hashTreeParsers.has(locus.url)) {
1275
1457
  LoggerProxy.logger.info(
@@ -1289,7 +1471,8 @@ export default class LocusInfo extends EventsScope {
1289
1471
  metadata,
1290
1472
  });
1291
1473
  // we have a full locus to start with, so we consider Locus info to be "initialized"
1292
- this.hashTreeParsers.get(locus.url).initializedFromHashTree = true;
1474
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1475
+ this.hashTreeParsers.get(locus.url)!.initializedFromHashTree = true;
1293
1476
  this.onFullLocusCommon(locus, eventType);
1294
1477
  } else {
1295
1478
  // in this case the Locus we're getting is not necessarily the full one
@@ -1351,7 +1534,7 @@ export default class LocusInfo extends EventsScope {
1351
1534
  );
1352
1535
  }
1353
1536
  // this is the new hashmap Locus DTO format (only applicable to webinars for now)
1354
- this.onFullLocusWithHashTrees(debugText, locus, metadata, eventType, dataSets);
1537
+ this.onFullLocusWithHashTrees(debugText, locus, metadata, dataSets, eventType);
1355
1538
  } else {
1356
1539
  this.onFullLocusClassic(debugText, locus, eventType);
1357
1540
  }
@@ -1495,7 +1678,7 @@ export default class LocusInfo extends EventsScope {
1495
1678
  * @memberof LocusInfo
1496
1679
  */
1497
1680
  updateLocusInfo(locus) {
1498
- if (locus.self?.reason === 'MOVED' && locus.self?.state === 'LEFT') {
1681
+ if (MeetingsUtil.isSelfMovedOrBreakoutEnded(locus)) {
1499
1682
  // When moved to a breakout session locus sends a message for the previous locus
1500
1683
  // indicating that we have been moved. It isn't helpful to continue parsing this
1501
1684
  // as it gets interpreted as if we have left the call
@@ -1648,14 +1831,9 @@ export default class LocusInfo extends EventsScope {
1648
1831
  );
1649
1832
  }
1650
1833
  } else if (this.parsedLocus.fullState?.type === _MEETING_) {
1651
- if (
1652
- this.fullState &&
1653
- (this.fullState.state === LOCUS.STATE.INACTIVE ||
1654
- // @ts-ignore
1655
- this.fullState.state === LOCUS.STATE.TERMINATING)
1656
- ) {
1834
+ if (this.fullState && MeetingsUtil.isWholeMeetingEnded(this.fullState)) {
1657
1835
  LoggerProxy.logger.warn(
1658
- 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive or terminating'
1836
+ 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive'
1659
1837
  );
1660
1838
 
1661
1839
  // @ts-ignore
@@ -1918,6 +2096,8 @@ export default class LocusInfo extends EventsScope {
1918
2096
  state,
1919
2097
  modifiedBy: current.record.modifiedBy,
1920
2098
  lastModified: current.record.lastModified,
2099
+ modifiedByServiceAppName: current.record.modifiedByServiceAppName,
2100
+ modifiedByServiceAppId: current.record.modifiedByServiceAppId,
1921
2101
  }
1922
2102
  );
1923
2103
  }
@@ -2587,6 +2767,7 @@ export default class LocusInfo extends EventsScope {
2587
2767
  {
2588
2768
  muted: parsedSelves.current.remoteMuted,
2589
2769
  unmuteAllowed: parsedSelves.current.unmuteAllowed,
2770
+ modifiedBy: parsedSelves.current.modifiedBy ?? null,
2590
2771
  }
2591
2772
  );
2592
2773
  }
@@ -2859,4 +3040,17 @@ export default class LocusInfo extends EventsScope {
2859
3040
  clearMainSessionLocusCache() {
2860
3041
  this.mainSessionLocusCache = null;
2861
3042
  }
3043
+
3044
+ /**
3045
+ * Cleans up all hash tree parsers and clears internal maps.
3046
+ * @returns {void}
3047
+ * @memberof LocusInfo
3048
+ */
3049
+ cleanUp() {
3050
+ this.hashTreeParsers.forEach((entry) => {
3051
+ entry.parser.cleanUp();
3052
+ });
3053
+ this.hashTreeParsers.clear();
3054
+ this.hashTreeObjectId2ParticipantId.clear();
3055
+ }
2862
3056
  }
@@ -1,15 +1,33 @@
1
+ import {Enum} from '../constants';
1
2
  import {HtMeta} from '../hashTree/types';
2
3
 
4
+ export const EndMeetingReason = {
5
+ maxMeetingDuration: 'MAX_MEETING_DURATION',
6
+ allParticipantsLeft: 'ALL_PARTICIPANTS_LEFT',
7
+ sipHostLeft: 'SIP_HOST_LEFT',
8
+ noHost: 'NO_HOST',
9
+ waitingForMpsEndMeetingTimeout: 'WAITING_FOR_MPS_END_MEETING_TIMEOUT',
10
+ fraudDetection: 'FRAUD_DETECTION',
11
+ meetingEndedByHost: 'MEETING_ENDED_BY_HOST',
12
+ meetingUpdated: 'MEETING_UPDATED', // Locus code has comment about EndMeetingIfPossible reason for this one
13
+ meetingCancelled: 'MEETING_CANCELLED', // Locus code has comment about EndMeetingIfPossible reason for this one
14
+ autoEndWithSingleParticipant: 'AUTO_END_WITH_SINGLE_PARTICIPANT',
15
+ breakoutEnded: 'BREAKOUT_ENDED', // indicates that only a breakout session ended, not the whole meeting
16
+ } as const;
17
+
18
+ export type EndMeetingReason = Enum<typeof EndMeetingReason>;
19
+
3
20
  export type LocusFullState = {
4
21
  active: boolean;
5
22
  count: number;
6
23
  lastActive: string;
7
24
  locked: boolean;
8
25
  sessionId: string;
9
- seessionIds: string[];
26
+ sessionIds: string[];
10
27
  startTime: number;
11
28
  state: string;
12
29
  type: string;
30
+ endMeetingReason?: EndMeetingReason;
13
31
  };
14
32
 
15
33
  export type Links = {
@@ -59,3 +77,9 @@ export type ReplacesInfo = {
59
77
  replacedAt: string;
60
78
  sessionId: string;
61
79
  };
80
+
81
+ export const LocusErrorCodes = {
82
+ LOCUS_INACTIVE: 2403004,
83
+ } as const;
84
+
85
+ export type LocusErrorCodes = Enum<typeof LocusErrorCodes>;