@webex/plugin-meetings 3.12.0-next.5 → 3.12.0-next.50

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 (136) 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 +6 -2
  5. package/dist/breakouts/breakout.js.map +1 -1
  6. package/dist/breakouts/index.js +1 -1
  7. package/dist/config.js +1 -0
  8. package/dist/config.js.map +1 -1
  9. package/dist/constants.js +6 -3
  10. package/dist/constants.js.map +1 -1
  11. package/dist/controls-options-manager/constants.js +11 -1
  12. package/dist/controls-options-manager/constants.js.map +1 -1
  13. package/dist/controls-options-manager/index.js +38 -24
  14. package/dist/controls-options-manager/index.js.map +1 -1
  15. package/dist/controls-options-manager/util.js +91 -0
  16. package/dist/controls-options-manager/util.js.map +1 -1
  17. package/dist/hashTree/constants.js +10 -1
  18. package/dist/hashTree/constants.js.map +1 -1
  19. package/dist/hashTree/hashTreeParser.js +593 -358
  20. package/dist/hashTree/hashTreeParser.js.map +1 -1
  21. package/dist/hashTree/utils.js +22 -0
  22. package/dist/hashTree/utils.js.map +1 -1
  23. package/dist/index.js +7 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/interceptors/locusRetry.js +23 -8
  26. package/dist/interceptors/locusRetry.js.map +1 -1
  27. package/dist/interpretation/index.js +10 -1
  28. package/dist/interpretation/index.js.map +1 -1
  29. package/dist/interpretation/siLanguage.js +1 -1
  30. package/dist/locus-info/controlsUtils.js +4 -1
  31. package/dist/locus-info/controlsUtils.js.map +1 -1
  32. package/dist/locus-info/index.js +277 -86
  33. package/dist/locus-info/index.js.map +1 -1
  34. package/dist/locus-info/types.js +16 -0
  35. package/dist/locus-info/types.js.map +1 -1
  36. package/dist/media/properties.js +1 -0
  37. package/dist/media/properties.js.map +1 -1
  38. package/dist/meeting/in-meeting-actions.js +3 -1
  39. package/dist/meeting/in-meeting-actions.js.map +1 -1
  40. package/dist/meeting/index.js +842 -521
  41. package/dist/meeting/index.js.map +1 -1
  42. package/dist/meeting/util.js +19 -2
  43. package/dist/meeting/util.js.map +1 -1
  44. package/dist/meetings/index.js +199 -77
  45. package/dist/meetings/index.js.map +1 -1
  46. package/dist/meetings/meetings.types.js +6 -1
  47. package/dist/meetings/meetings.types.js.map +1 -1
  48. package/dist/meetings/request.js +39 -0
  49. package/dist/meetings/request.js.map +1 -1
  50. package/dist/meetings/util.js +67 -5
  51. package/dist/meetings/util.js.map +1 -1
  52. package/dist/member/index.js +10 -0
  53. package/dist/member/index.js.map +1 -1
  54. package/dist/member/types.js.map +1 -1
  55. package/dist/member/util.js +3 -0
  56. package/dist/member/util.js.map +1 -1
  57. package/dist/metrics/constants.js +2 -1
  58. package/dist/metrics/constants.js.map +1 -1
  59. package/dist/recording-controller/index.js +1 -3
  60. package/dist/recording-controller/index.js.map +1 -1
  61. package/dist/types/config.d.ts +1 -0
  62. package/dist/types/constants.d.ts +2 -0
  63. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  64. package/dist/types/controls-options-manager/index.d.ts +10 -0
  65. package/dist/types/hashTree/constants.d.ts +1 -0
  66. package/dist/types/hashTree/hashTreeParser.d.ts +61 -15
  67. package/dist/types/hashTree/utils.d.ts +11 -0
  68. package/dist/types/index.d.ts +2 -0
  69. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  70. package/dist/types/locus-info/index.d.ts +46 -6
  71. package/dist/types/locus-info/types.d.ts +17 -1
  72. package/dist/types/media/properties.d.ts +1 -0
  73. package/dist/types/meeting/in-meeting-actions.d.ts +2 -0
  74. package/dist/types/meeting/index.d.ts +70 -1
  75. package/dist/types/meeting/util.d.ts +8 -0
  76. package/dist/types/meetings/index.d.ts +18 -1
  77. package/dist/types/meetings/meetings.types.d.ts +15 -0
  78. package/dist/types/meetings/request.d.ts +14 -0
  79. package/dist/types/member/index.d.ts +1 -0
  80. package/dist/types/member/types.d.ts +1 -0
  81. package/dist/types/member/util.d.ts +1 -0
  82. package/dist/types/metrics/constants.d.ts +1 -0
  83. package/dist/webinar/index.js +361 -235
  84. package/dist/webinar/index.js.map +1 -1
  85. package/package.json +22 -22
  86. package/src/aiEnableRequest/index.ts +16 -0
  87. package/src/breakouts/breakout.ts +2 -1
  88. package/src/config.ts +1 -0
  89. package/src/constants.ts +5 -1
  90. package/src/controls-options-manager/constants.ts +14 -1
  91. package/src/controls-options-manager/index.ts +47 -24
  92. package/src/controls-options-manager/util.ts +81 -1
  93. package/src/hashTree/constants.ts +9 -0
  94. package/src/hashTree/hashTreeParser.ts +306 -160
  95. package/src/hashTree/utils.ts +17 -0
  96. package/src/index.ts +5 -0
  97. package/src/interceptors/locusRetry.ts +25 -4
  98. package/src/interpretation/index.ts +25 -8
  99. package/src/locus-info/controlsUtils.ts +3 -1
  100. package/src/locus-info/index.ts +276 -93
  101. package/src/locus-info/types.ts +19 -1
  102. package/src/media/properties.ts +1 -0
  103. package/src/meeting/in-meeting-actions.ts +4 -0
  104. package/src/meeting/index.ts +315 -26
  105. package/src/meeting/util.ts +20 -2
  106. package/src/meetings/index.ts +104 -43
  107. package/src/meetings/meetings.types.ts +19 -0
  108. package/src/meetings/request.ts +43 -0
  109. package/src/meetings/util.ts +80 -1
  110. package/src/member/index.ts +10 -0
  111. package/src/member/types.ts +1 -0
  112. package/src/member/util.ts +3 -0
  113. package/src/metrics/constants.ts +1 -0
  114. package/src/recording-controller/index.ts +1 -2
  115. package/src/webinar/index.ts +162 -21
  116. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  117. package/test/unit/spec/breakouts/breakout.ts +7 -3
  118. package/test/unit/spec/controls-options-manager/index.js +140 -29
  119. package/test/unit/spec/controls-options-manager/util.js +165 -0
  120. package/test/unit/spec/hashTree/hashTreeParser.ts +1294 -191
  121. package/test/unit/spec/hashTree/utils.ts +88 -1
  122. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  123. package/test/unit/spec/interpretation/index.ts +26 -4
  124. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  125. package/test/unit/spec/locus-info/index.js +443 -81
  126. package/test/unit/spec/meeting/in-meeting-actions.ts +2 -0
  127. package/test/unit/spec/meeting/index.js +836 -41
  128. package/test/unit/spec/meeting/muteState.js +3 -0
  129. package/test/unit/spec/meeting/utils.js +33 -0
  130. package/test/unit/spec/meetings/index.js +275 -10
  131. package/test/unit/spec/meetings/request.js +141 -0
  132. package/test/unit/spec/meetings/utils.js +161 -0
  133. package/test/unit/spec/member/index.js +7 -0
  134. package/test/unit/spec/member/util.js +24 -0
  135. package/test/unit/spec/recording-controller/index.js +9 -8
  136. 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,31 +676,79 @@ 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
  }
744
+
745
+ this.handleHashTreeParserSwitchForAPIResponse(locusUrl, locus);
746
+
747
+ return;
748
+ }
749
+
750
+ // Active parser found - pass the API response to it
751
+ if (isWrapped) {
698
752
  LoggerProxy.logger.info(
699
753
  'Locus-info:index#handleLocusAPIResponse --> passing Locus API response to HashTreeParser: ',
700
754
  responseBody
@@ -702,20 +756,23 @@ export default class LocusInfo extends EventsScope {
702
756
  // update the data in our hash trees
703
757
  hashTreeParserEntry.parser.handleLocusUpdate(responseBody);
704
758
  } else {
705
- // LocusDTO without wrapper - pass it through as if it had no dataSets
759
+ // LocusDTO without wrapper - pass it through as if it had no dataSets nor metadata
706
760
  hashTreeParserEntry.parser.handleLocusUpdate({locus: responseBody});
707
761
  }
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);
762
+
763
+ return;
718
764
  }
765
+
766
+ // No hash tree parsers - classic Locus mode
767
+ if (isWrapped && responseBody.dataSets) {
768
+ this.sendClassicVsHashTreeMismatchMetric(
769
+ meeting,
770
+ `unexpected hash tree dataSets in API response`
771
+ );
772
+ }
773
+
774
+ // classic Locus delta
775
+ this.handleLocusDelta(locus, meeting);
719
776
  }
720
777
 
721
778
  /**
@@ -944,6 +1001,114 @@ export default class LocusInfo extends EventsScope {
944
1001
  }
945
1002
  }
946
1003
 
1004
+ /**
1005
+ * Helper that handles the common logic for reactivating a stopped HashTreeParser when
1006
+ * a newer "replaces" is detected. Used by both the message and API response parser switch methods.
1007
+ *
1008
+ * @param {string} callerName - name of the calling method, used in log messages
1009
+ * @param {string} locusUrl - the locus URL of the stopped parser
1010
+ * @param {HashTreeParserEntry} stoppedEntry - the stopped parser entry
1011
+ * @param {ReplacesInfo} replaces - replacement info extracted from self
1012
+ * @param {Function} resumeCallback - callback to invoke after reactivation to resume the parser
1013
+ * @returns {void}
1014
+ */
1015
+ private resumeStoppedParser(
1016
+ callerName: string,
1017
+ locusUrl: string,
1018
+ stoppedEntry: HashTreeParserEntry,
1019
+ replaces: ReplacesInfo | undefined,
1020
+ resumeCallback: () => void
1021
+ ): void {
1022
+ // this check is just for typescript, it should never happen, replaces should always be defined
1023
+ if (!replaces) {
1024
+ LoggerProxy.logger.info(
1025
+ `Locus-info:index#${callerName} --> received data for stopped HashTreeParser with locusUrl ${locusUrl}, but no replaces info provided, so not re-activating the parser`
1026
+ );
1027
+
1028
+ return;
1029
+ }
1030
+
1031
+ if (replaces.replacedAt <= (stoppedEntry.replacedAt || '')) {
1032
+ LoggerProxy.logger.info(
1033
+ `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`
1034
+ );
1035
+
1036
+ return;
1037
+ }
1038
+
1039
+ LoggerProxy.logger.info(
1040
+ `Locus-info:index#${callerName} --> reactivating HashTreeParser for locusUrl=${locusUrl}, which replaces ${replaces.locusUrl}`
1041
+ );
1042
+
1043
+ const replacedEntry = this.hashTreeParsers.get(replaces.locusUrl);
1044
+
1045
+ if (replacedEntry) {
1046
+ replacedEntry.replacedAt = replaces.replacedAt;
1047
+ replacedEntry.parser.stop();
1048
+ } else {
1049
+ LoggerProxy.logger.warn(
1050
+ `Locus-info:index#${callerName} --> the parser that is supposed to be replaced with the currently reactivated parser is not found, locusUrl=${replaces.locusUrl}`
1051
+ );
1052
+ }
1053
+
1054
+ stoppedEntry.initializedFromHashTree = false;
1055
+ this.hashTreeObjectId2ParticipantId.clear();
1056
+
1057
+ resumeCallback();
1058
+ }
1059
+
1060
+ /**
1061
+ * Handles an API response whose locusUrl doesn't match any active HashTreeParser
1062
+ * (either no entry exists, or the existing entry is stopped).
1063
+ * Creates a new parser or reactivates a stopped one using initializeFromGetLociResponse.
1064
+ *
1065
+ * @param {string} locusUrl - the locus URL from the API response
1066
+ * @param {LocusDTO} locus - the locus DTO from the API response
1067
+ * @returns {void}
1068
+ */
1069
+ private handleHashTreeParserSwitchForAPIResponse(locusUrl: string, locus: LocusDTO): void {
1070
+ const entry = this.hashTreeParsers.get(locusUrl);
1071
+
1072
+ const replaces = getReplaceInfoFromSelf(
1073
+ locus.self,
1074
+ // @ts-ignore
1075
+ this.webex.internal.device.url
1076
+ );
1077
+
1078
+ if (!entry) {
1079
+ LoggerProxy.logger.info(
1080
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> no parser for locusUrl ${locusUrl}, creating a new one`
1081
+ );
1082
+
1083
+ const parser = this.createHashTreeParser({
1084
+ locusUrl,
1085
+ initialLocus: {locus: null, dataSets: []},
1086
+ metadata: null,
1087
+ replacedAt: replaces?.replacedAt,
1088
+ });
1089
+
1090
+ parser.initializeFromGetLociResponse(locus);
1091
+
1092
+ return;
1093
+ }
1094
+
1095
+ if (entry.parser.state !== 'stopped') {
1096
+ LoggerProxy.logger.warn(
1097
+ `Locus-info:index#handleHashTreeParserSwitchForAPIResponse --> unexpected parser state "${entry.parser.state}" for locusUrl ${locusUrl}`
1098
+ );
1099
+
1100
+ return;
1101
+ }
1102
+
1103
+ this.resumeStoppedParser(
1104
+ 'handleHashTreeParserSwitchForAPIResponse',
1105
+ locusUrl,
1106
+ entry,
1107
+ replaces,
1108
+ () => entry.parser.resumeFromApiResponse(locus)
1109
+ );
1110
+ }
1111
+
947
1112
  /**
948
1113
  * Checks if the hash tree message should trigger a switch to a different HashTreeParser
949
1114
  *
@@ -965,7 +1130,7 @@ export default class LocusInfo extends EventsScope {
965
1130
  // but it's buried inside the message, we need to find it and pass it to HashTreeParser constructor
966
1131
  const metadata = message.locusStateElements?.find((el) => isMetadata(el));
967
1132
 
968
- if (metadata?.data?.visibleDataSets?.length > 0) {
1133
+ if (metadata && metadata.data?.visibleDataSets?.length > 0) {
969
1134
  LoggerProxy.logger.info(
970
1135
  `Locus-info:index#handleHashTreeParserSwitch --> no hash tree parser found for locusUrl ${message.locusUrl}, creating a new one`
971
1136
  );
@@ -992,36 +1157,12 @@ export default class LocusInfo extends EventsScope {
992
1157
  if (entry.parser.state === 'stopped') {
993
1158
  // 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
1159
  // 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`
1160
+ this.resumeStoppedParser(
1161
+ 'handleHashTreeParserSwitch',
1162
+ message.locusUrl,
1163
+ entry,
1164
+ replaces,
1165
+ () => entry.parser.resumeFromMessage(message)
1025
1166
  );
1026
1167
 
1027
1168
  return true;
@@ -1056,7 +1197,25 @@ export default class LocusInfo extends EventsScope {
1056
1197
 
1057
1198
  const entry = this.hashTreeParsers.get(message.locusUrl);
1058
1199
 
1059
- entry.parser.handleMessage(message);
1200
+ // the check is just for typescript, the case of no entry in hashTreeParsers is handled in handleHashTreeParserSwitch() above
1201
+ if (entry) {
1202
+ entry.parser.handleMessage(message);
1203
+ }
1204
+ }
1205
+
1206
+ /**
1207
+ * Triggers a sync of all hash tree datasets for all hash tree parsers associated with this meeting.
1208
+ * The syncs are executed sequentially within each parser.
1209
+ *
1210
+ * @returns {Promise<void>}
1211
+ */
1212
+ async syncAllHashTreeDatasets(): Promise<void> {
1213
+ for (const [, entry] of this.hashTreeParsers) {
1214
+ if (entry.parser) {
1215
+ // eslint-disable-next-line no-await-in-loop
1216
+ await entry.parser.syncAllDatasets();
1217
+ }
1218
+ }
1060
1219
  }
1061
1220
 
1062
1221
  /**
@@ -1064,16 +1223,11 @@ export default class LocusInfo extends EventsScope {
1064
1223
  * Updates our locus info based on the data parsed by the hash tree parser.
1065
1224
  *
1066
1225
  * @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.
1226
+ * @param {LocusInfoUpdate} update - Details about the update.
1069
1227
  * @returns {void}
1070
1228
  */
1071
- private updateFromHashTree(
1072
- locusUrl: string,
1073
- updateType: LocusInfoUpdateType,
1074
- data?: {updatedObjects: HashTreeObject[]}
1075
- ) {
1076
- switch (updateType) {
1229
+ private updateFromHashTree(locusUrl: string, update: LocusInfoUpdate) {
1230
+ switch (update.updateType) {
1077
1231
  case LocusInfoUpdateType.OBJECTS_UPDATED: {
1078
1232
  // initialize our new locus
1079
1233
  let locus: LocusDTO = {
@@ -1087,7 +1241,7 @@ export default class LocusInfo extends EventsScope {
1087
1241
  // first go over all the updates and check what happens with the main locus object
1088
1242
  let locusObjectStateAfterUpdates: LocusObjectStateAfterUpdates =
1089
1243
  LocusObjectStateAfterUpdates.unchanged;
1090
- data.updatedObjects.forEach((object) => {
1244
+ update.updatedObjects.forEach((object) => {
1091
1245
  if (object.htMeta.elementId.type.toLowerCase() === ObjectType.locus) {
1092
1246
  if (locusObjectStateAfterUpdates === LocusObjectStateAfterUpdates.updated) {
1093
1247
  // this code doesn't supported it right now,
@@ -1116,6 +1270,14 @@ export default class LocusInfo extends EventsScope {
1116
1270
 
1117
1271
  const hashTreeParserEntry = this.hashTreeParsers.get(locusUrl);
1118
1272
 
1273
+ if (!hashTreeParserEntry) {
1274
+ LoggerProxy.logger.warn(
1275
+ `Locus-info:index#updateFromHashTree --> no HashTreeParser found for locusUrl ${locusUrl} when trying to apply updates from hash tree`
1276
+ );
1277
+
1278
+ return;
1279
+ }
1280
+
1119
1281
  if (!hashTreeParserEntry.initializedFromHashTree) {
1120
1282
  // this is the first time we're getting an update for this locusUrl,
1121
1283
  // so it's probably a move to/from breakout. We need to start from a clean state,
@@ -1124,7 +1286,8 @@ export default class LocusInfo extends EventsScope {
1124
1286
  `Locus-info:index#updateFromHashTree --> first INITIAL update for locusUrl ${locusUrl}, starting from empty state`
1125
1287
  );
1126
1288
  hashTreeParserEntry.initializedFromHashTree = true;
1127
- locus.jsSdkMeta.forceReplaceMembers = true;
1289
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1290
+ locus.jsSdkMeta!.forceReplaceMembers = true;
1128
1291
  } else if (
1129
1292
  // if Locus object is unchanged or removed, we need to keep using the existing locus
1130
1293
  // because the rest of the locusInfo code expects locus to always be present (with at least some of the fields)
@@ -1137,7 +1300,7 @@ export default class LocusInfo extends EventsScope {
1137
1300
  // copy over all of existing locus except participants
1138
1301
  LocusDtoTopLevelKeys.forEach((key) => {
1139
1302
  if (key !== 'participants') {
1140
- locus[key] = cloneDeep(this[key]);
1303
+ (locus as Record<string, any>)[key] = cloneDeep((this as Record<string, any>)[key]);
1141
1304
  }
1142
1305
  });
1143
1306
  } else {
@@ -1145,14 +1308,16 @@ export default class LocusInfo extends EventsScope {
1145
1308
  // (except participants, which need to stay empty - that means "no participant changes")
1146
1309
  Object.values(ObjectTypeToLocusKeyMap).forEach((locusDtoKey) => {
1147
1310
  if (locusDtoKey !== 'participants') {
1148
- locus[locusDtoKey] = cloneDeep(this[locusDtoKey]);
1311
+ (locus as Record<string, any>)[locusDtoKey] = cloneDeep(
1312
+ (this as Record<string, any>)[locusDtoKey]
1313
+ );
1149
1314
  }
1150
1315
  });
1151
1316
  }
1152
1317
 
1153
1318
  LoggerProxy.logger.info(
1154
1319
  `Locus-info:index#updateFromHashTree --> LOCUS object is ${locusObjectStateAfterUpdates}, all updates: ${JSON.stringify(
1155
- data.updatedObjects.map((o) => ({
1320
+ update.updatedObjects.map((o) => ({
1156
1321
  type: o.htMeta.elementId.type,
1157
1322
  id: o.htMeta.elementId.id,
1158
1323
  hasData: !!o.data,
@@ -1160,7 +1325,7 @@ export default class LocusInfo extends EventsScope {
1160
1325
  )}`
1161
1326
  );
1162
1327
  // now apply all the updates from the hash tree onto the locus
1163
- data.updatedObjects.forEach((object) => {
1328
+ update.updatedObjects.forEach((object) => {
1164
1329
  locus = this.updateLocusFromHashTreeObject(object, locus);
1165
1330
  });
1166
1331
 
@@ -1191,11 +1356,17 @@ export default class LocusInfo extends EventsScope {
1191
1356
  */
1192
1357
  parse(meeting: any, data: any) {
1193
1358
  if (this.hashTreeParsers.size > 0) {
1194
- this.handleHashTreeMessage(
1195
- meeting,
1196
- data.eventType,
1197
- data.stateElementsMessage as HashTreeMessage
1198
- );
1359
+ if (data.eventType === LOCUSEVENT.SDK_LOCUS_FROM_SYNC_MEETINGS) {
1360
+ // sync meetings response follows the format of "not wrapped" locus API responses,
1361
+ // so has no dataSets nor Metadata
1362
+ this.handleLocusAPIResponse(meeting, {...data.locus});
1363
+ } else {
1364
+ this.handleHashTreeMessage(
1365
+ meeting,
1366
+ data.eventType,
1367
+ data.stateElementsMessage as HashTreeMessage
1368
+ );
1369
+ }
1199
1370
  } else {
1200
1371
  const {eventType} = data;
1201
1372
 
@@ -1260,16 +1431,16 @@ export default class LocusInfo extends EventsScope {
1260
1431
  * @param {string} debugText string explaining the trigger for this call, added to logs for debugging purposes
1261
1432
  * @param {object} locus locus object
1262
1433
  * @param {object} metadata locus hash trees metadata
1263
- * @param {string} eventType locus event
1264
1434
  * @param {DataSet[]} dataSets
1435
+ * @param {string} eventType locus event
1265
1436
  * @returns {void}
1266
1437
  */
1267
1438
  private onFullLocusWithHashTrees(
1268
1439
  debugText: string,
1269
1440
  locus: any,
1270
1441
  metadata: Metadata,
1271
- eventType?: string,
1272
- dataSets?: Array<DataSet>
1442
+ dataSets: Array<DataSet>,
1443
+ eventType?: string
1273
1444
  ) {
1274
1445
  if (!this.hashTreeParsers.has(locus.url)) {
1275
1446
  LoggerProxy.logger.info(
@@ -1289,7 +1460,8 @@ export default class LocusInfo extends EventsScope {
1289
1460
  metadata,
1290
1461
  });
1291
1462
  // we have a full locus to start with, so we consider Locus info to be "initialized"
1292
- this.hashTreeParsers.get(locus.url).initializedFromHashTree = true;
1463
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1464
+ this.hashTreeParsers.get(locus.url)!.initializedFromHashTree = true;
1293
1465
  this.onFullLocusCommon(locus, eventType);
1294
1466
  } else {
1295
1467
  // in this case the Locus we're getting is not necessarily the full one
@@ -1351,7 +1523,7 @@ export default class LocusInfo extends EventsScope {
1351
1523
  );
1352
1524
  }
1353
1525
  // this is the new hashmap Locus DTO format (only applicable to webinars for now)
1354
- this.onFullLocusWithHashTrees(debugText, locus, metadata, eventType, dataSets);
1526
+ this.onFullLocusWithHashTrees(debugText, locus, metadata, dataSets, eventType);
1355
1527
  } else {
1356
1528
  this.onFullLocusClassic(debugText, locus, eventType);
1357
1529
  }
@@ -1495,7 +1667,7 @@ export default class LocusInfo extends EventsScope {
1495
1667
  * @memberof LocusInfo
1496
1668
  */
1497
1669
  updateLocusInfo(locus) {
1498
- if (locus.self?.reason === 'MOVED' && locus.self?.state === 'LEFT') {
1670
+ if (MeetingsUtil.isSelfMovedOrBreakoutEnded(locus)) {
1499
1671
  // When moved to a breakout session locus sends a message for the previous locus
1500
1672
  // indicating that we have been moved. It isn't helpful to continue parsing this
1501
1673
  // as it gets interpreted as if we have left the call
@@ -1648,14 +1820,9 @@ export default class LocusInfo extends EventsScope {
1648
1820
  );
1649
1821
  }
1650
1822
  } 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
- ) {
1823
+ if (this.fullState && MeetingsUtil.isWholeMeetingEnded(this.fullState)) {
1657
1824
  LoggerProxy.logger.warn(
1658
- 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive or terminating'
1825
+ 'Locus-info:index#isMeetingActive --> Meeting is ending due to inactive'
1659
1826
  );
1660
1827
 
1661
1828
  // @ts-ignore
@@ -1918,6 +2085,8 @@ export default class LocusInfo extends EventsScope {
1918
2085
  state,
1919
2086
  modifiedBy: current.record.modifiedBy,
1920
2087
  lastModified: current.record.lastModified,
2088
+ modifiedByServiceAppName: current.record.modifiedByServiceAppName,
2089
+ modifiedByServiceAppId: current.record.modifiedByServiceAppId,
1921
2090
  }
1922
2091
  );
1923
2092
  }
@@ -2587,6 +2756,7 @@ export default class LocusInfo extends EventsScope {
2587
2756
  {
2588
2757
  muted: parsedSelves.current.remoteMuted,
2589
2758
  unmuteAllowed: parsedSelves.current.unmuteAllowed,
2759
+ modifiedBy: parsedSelves.current.modifiedBy ?? null,
2590
2760
  }
2591
2761
  );
2592
2762
  }
@@ -2859,4 +3029,17 @@ export default class LocusInfo extends EventsScope {
2859
3029
  clearMainSessionLocusCache() {
2860
3030
  this.mainSessionLocusCache = null;
2861
3031
  }
3032
+
3033
+ /**
3034
+ * Cleans up all hash tree parsers and clears internal maps.
3035
+ * @returns {void}
3036
+ * @memberof LocusInfo
3037
+ */
3038
+ cleanUp() {
3039
+ this.hashTreeParsers.forEach((entry) => {
3040
+ entry.parser.cleanUp();
3041
+ });
3042
+ this.hashTreeParsers.clear();
3043
+ this.hashTreeObjectId2ParticipantId.clear();
3044
+ }
2862
3045
  }
@@ -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 = {
@@ -43,6 +43,7 @@ export default class MediaProperties {
43
43
  shareAudioStream?: LocalSystemAudioStream;
44
44
  videoDeviceId: any;
45
45
  videoStream?: LocalCameraStream;
46
+ srtpCipher: string | undefined;
46
47
  namespace = MEETINGS;
47
48
  mediaIssueCounters: {[key: string]: number} = {};
48
49
  throttledSendMediaIssueMetric: ReturnType<typeof throttle>;