@webex/plugin-meetings 3.12.0-webex-services-ready.4 → 3.13.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 (165) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +130 -4
  22. package/ai-docs/ARCHITECTURE.md +208 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/assets/README.md +28 -0
  40. package/assets/e2ee-0.0.1.js +2 -0
  41. package/assets/e2ee-0.0.1.wasm +0 -0
  42. package/dist/aiEnableRequest/index.js +1 -1
  43. package/dist/annotation/index.js +55 -19
  44. package/dist/annotation/index.js.map +1 -1
  45. package/dist/assets/e2ee-0.0.1.js +2 -0
  46. package/dist/assets/e2ee-0.0.1.wasm +0 -0
  47. package/dist/breakouts/breakout.js +1 -1
  48. package/dist/breakouts/index.js +39 -5
  49. package/dist/breakouts/index.js.map +1 -1
  50. package/dist/common/errors/webex-errors.js +7 -2
  51. package/dist/common/errors/webex-errors.js.map +1 -1
  52. package/dist/config.js +1 -0
  53. package/dist/config.js.map +1 -1
  54. package/dist/constants.js +6 -5
  55. package/dist/constants.js.map +1 -1
  56. package/dist/hashTree/hashTreeParser.js +101 -48
  57. package/dist/hashTree/hashTreeParser.js.map +1 -1
  58. package/dist/index.js +1 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/interceptors/dataChannelAuthToken.js +41 -59
  61. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  62. package/dist/interceptors/locusRetry.js +1 -1
  63. package/dist/interceptors/locusRetry.js.map +1 -1
  64. package/dist/interpretation/index.js +46 -12
  65. package/dist/interpretation/index.js.map +1 -1
  66. package/dist/interpretation/siLanguage.js +1 -1
  67. package/dist/locus-info/index.js +236 -80
  68. package/dist/locus-info/index.js.map +1 -1
  69. package/dist/locus-info/types.js +2 -1
  70. package/dist/locus-info/types.js.map +1 -1
  71. package/dist/media/MediaConnectionAwaiter.js +225 -175
  72. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  73. package/dist/meeting/index.js +355 -299
  74. package/dist/meeting/index.js.map +1 -1
  75. package/dist/meeting/util.js +8 -2
  76. package/dist/meeting/util.js.map +1 -1
  77. package/dist/meeting/voicea-meeting.js +2 -1
  78. package/dist/meeting/voicea-meeting.js.map +1 -1
  79. package/dist/meeting-info/meeting-info-v2.js +10 -3
  80. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  81. package/dist/meetings/index.js +72 -31
  82. package/dist/meetings/index.js.map +1 -1
  83. package/dist/multistream/remoteMediaManager.js +32 -4
  84. package/dist/multistream/remoteMediaManager.js.map +1 -1
  85. package/dist/multistream/sendSlotManager.js +11 -1
  86. package/dist/multistream/sendSlotManager.js.map +1 -1
  87. package/dist/types/annotation/index.d.ts +19 -0
  88. package/dist/types/common/errors/webex-errors.d.ts +6 -2
  89. package/dist/types/config.d.ts +1 -0
  90. package/dist/types/constants.d.ts +2 -1
  91. package/dist/types/hashTree/hashTreeParser.d.ts +12 -0
  92. package/dist/types/index.d.ts +1 -0
  93. package/dist/types/locus-info/index.d.ts +45 -1
  94. package/dist/types/locus-info/types.d.ts +1 -0
  95. package/dist/types/media/MediaConnectionAwaiter.d.ts +61 -53
  96. package/dist/types/meeting/index.d.ts +49 -12
  97. package/dist/types/meeting/util.d.ts +3 -1
  98. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  99. package/dist/types/meetings/index.d.ts +2 -1
  100. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  101. package/dist/types/multistream/sendSlotManager.d.ts +5 -1
  102. package/dist/webinar/index.js +298 -255
  103. package/dist/webinar/index.js.map +1 -1
  104. package/package.json +25 -23
  105. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  106. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  107. package/src/annotation/index.ts +61 -29
  108. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  109. package/src/breakouts/index.ts +35 -2
  110. package/src/common/errors/webex-errors.ts +8 -2
  111. package/src/config.ts +5 -1
  112. package/src/constants.ts +2 -1
  113. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  114. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  115. package/src/hashTree/hashTreeParser.ts +67 -3
  116. package/src/index.ts +1 -0
  117. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  118. package/src/interceptors/dataChannelAuthToken.ts +48 -77
  119. package/src/interceptors/locusRetry.ts +1 -1
  120. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  121. package/src/interpretation/index.ts +38 -1
  122. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  123. package/src/locus-info/index.ts +156 -35
  124. package/src/locus-info/types.ts +1 -0
  125. package/src/media/MediaConnectionAwaiter.ts +223 -207
  126. package/src/media/ai-docs/media-spec.md +267 -0
  127. package/src/meeting/ai-docs/meeting-spec.md +404 -0
  128. package/src/meeting/index.ts +332 -296
  129. package/src/meeting/util.ts +7 -4
  130. package/src/meeting/voicea-meeting.ts +1 -1
  131. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  132. package/src/meeting-info/meeting-info-v2.ts +7 -2
  133. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  134. package/src/meetings/index.ts +59 -23
  135. package/src/member/ai-docs/member-spec.md +196 -0
  136. package/src/members/ai-docs/members-spec.md +256 -0
  137. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  138. package/src/multistream/ai-docs/multistream-spec.md +295 -0
  139. package/src/multistream/remoteMediaManager.ts +23 -1
  140. package/src/multistream/sendSlotManager.ts +15 -1
  141. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  142. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  143. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  144. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  145. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  146. package/src/roap/ai-docs/roap-spec.md +241 -0
  147. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  148. package/src/webinar/index.ts +168 -188
  149. package/test/unit/spec/annotation/index.ts +214 -182
  150. package/test/unit/spec/breakouts/index.ts +145 -13
  151. package/test/unit/spec/hashTree/hashTreeParser.ts +212 -1
  152. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +81 -99
  153. package/test/unit/spec/interceptors/locusRetry.ts +29 -1
  154. package/test/unit/spec/interpretation/index.ts +93 -0
  155. package/test/unit/spec/locus-info/index.js +397 -0
  156. package/test/unit/spec/media/MediaConnectionAwaiter.ts +426 -19
  157. package/test/unit/spec/media/properties.ts +3 -3
  158. package/test/unit/spec/meeting/index.js +1219 -723
  159. package/test/unit/spec/meeting/utils.js +52 -18
  160. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  161. package/test/unit/spec/meeting-info/meetinginfov2.js +69 -1
  162. package/test/unit/spec/meetings/index.js +145 -43
  163. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  164. package/test/unit/spec/multistream/sendSlotManager.ts +30 -2
  165. package/test/unit/spec/webinar/index.ts +886 -718
@@ -192,6 +192,35 @@ describe('plugin-meetings', () => {
192
192
  });
193
193
  });
194
194
 
195
+ [
196
+ [429, WebexHttpError.TooManyRequests],
197
+ [503, WebexHttpError.ServiceUnavailable],
198
+ ].forEach(([statusCode, ErrorType]) => {
199
+ it(`rejects the HTTP ${statusCode} error after a locus retry is exhausted`, async () => {
200
+ const reason = new ErrorType({
201
+ statusCode,
202
+ options: {
203
+ headers: {trackingid: 'test', 'retry-after': 1000},
204
+ uri: options.uri,
205
+ },
206
+ body: {message: 'Locus request failed'},
207
+ });
208
+ const handleRetryStub = sinon
209
+ .stub(interceptor, 'handleRetryRequestLocusServiceError')
210
+ .resolves();
211
+
212
+ await interceptor.onResponseError(options, reason);
213
+
214
+ return interceptor.onResponseError(options, reason).then(
215
+ () => assert.fail('Expected promise to be rejected'),
216
+ (error) => {
217
+ expect(error).to.equal(reason);
218
+ handleRetryStub.restore();
219
+ }
220
+ );
221
+ });
222
+ });
223
+
195
224
  describe('URI parsing edge cases', () => {
196
225
  const make503Reason = (uri) =>
197
226
  new WebexHttpError.MethodNotAllowed({
@@ -330,4 +359,3 @@ describe('plugin-meetings', () => {
330
359
  });
331
360
  });
332
361
  });
333
-
@@ -159,6 +159,39 @@ describe('plugin-meetings', () => {
159
159
  interpretation.updateInterpretation({siLanguages: [{languageName: 'en', languageCode: 1}]});
160
160
  checkSILanguage(interpretation.siLanguages.en, {languageName: 'en', languageCode: 1});
161
161
  });
162
+ it('stores siEnabled from the interpretation control', () => {
163
+ interpretation.updateInterpretation({siEnabled: true, siLanguages: []});
164
+ assert.equal(interpretation.siEnabled, true);
165
+
166
+ interpretation.updateInterpretation({siEnabled: false, siLanguages: []});
167
+ assert.equal(interpretation.siEnabled, false);
168
+ });
169
+ it('preserves siEnabled when preserveSiEnabled is set (meeting-info path)', () => {
170
+ interpretation.updateInterpretation({siEnabled: true, siLanguages: []});
171
+ assert.equal(interpretation.siEnabled, true);
172
+
173
+ // The meeting-info path passes only siLanguages; siEnabled must survive.
174
+ interpretation.updateInterpretation(
175
+ {siLanguages: [{languageName: 'en', languageCode: 1}]},
176
+ {preserveSiEnabled: true}
177
+ );
178
+ assert.equal(interpretation.siEnabled, true);
179
+ });
180
+
181
+ it('resets siEnabled and siLanguages consistently for a delta without interpretation', () => {
182
+ interpretation.updateInterpretation({
183
+ siEnabled: true,
184
+ siLanguages: [{languageName: 'en', languageCode: 1}],
185
+ });
186
+ assert.equal(interpretation.siEnabled, true);
187
+ assert.equal(interpretation.siLanguages.length, 1);
188
+
189
+ // A locus delta carrying no interpretation resets both fields together, so we never
190
+ // land in the "SI on with zero languages" state.
191
+ interpretation.updateInterpretation(undefined);
192
+ assert.equal(interpretation.siEnabled, false);
193
+ assert.equal(interpretation.siLanguages.length, 0);
194
+ });
162
195
  });
163
196
 
164
197
  describe('#updateSelfInterpretation', () => {
@@ -361,6 +394,66 @@ describe('plugin-meetings', () => {
361
394
  });
362
395
  });
363
396
 
397
+ describe('#endSimultaneousInterpretation', () => {
398
+ it('makes the request as expected', async () => {
399
+ const mockResponse = {body: {locus: {url: 'locusUrl'}}};
400
+ webex.request.returns(Promise.resolve(mockResponse));
401
+
402
+ await interpretation.endSimultaneousInterpretation();
403
+ assert.calledOnceWithExactly(webex.request, {
404
+ method: 'PATCH',
405
+ uri: 'locusUrl/controls',
406
+ body: {
407
+ interpretation: {
408
+ siEnabled: false,
409
+ },
410
+ },
411
+ });
412
+ assert.calledOnceWithExactly(
413
+ mockMeeting.locusInfo.handleLocusAPIResponse,
414
+ mockMeeting,
415
+ mockResponse.body
416
+ );
417
+ });
418
+
419
+ it('rejects with error', async () => {
420
+ const mockError = new Error('something wrong');
421
+ webex.request.returns(Promise.reject(mockError));
422
+ LoggerProxy.logger.error = sinon.stub();
423
+
424
+ await assert.isRejected(
425
+ interpretation.endSimultaneousInterpretation(),
426
+ mockError,
427
+ 'something wrong'
428
+ );
429
+
430
+ assert.calledOnceWithExactly(
431
+ LoggerProxy.logger.error,
432
+ 'Meeting:interpretation#endSimultaneousInterpretation failed',
433
+ mockError
434
+ );
435
+ });
436
+
437
+ it('resolves without touching locusInfo when the meeting is not found', async () => {
438
+ webex.meetings.meetingCollection.getByKey.returns(undefined);
439
+ const mockResponse = {body: {locus: {url: 'locusUrl'}}};
440
+ webex.request.returns(Promise.resolve(mockResponse));
441
+
442
+ await interpretation.endSimultaneousInterpretation();
443
+
444
+ assert.calledOnceWithExactly(webex.request, {
445
+ method: 'PATCH',
446
+ uri: 'locusUrl/controls',
447
+ body: {
448
+ interpretation: {
449
+ siEnabled: false,
450
+ },
451
+ },
452
+ });
453
+ assert.notCalled(mockMeeting.locusInfo.handleLocusAPIResponse);
454
+ });
455
+ });
456
+
364
457
  describe('#changeDirection', () => {
365
458
  it('makes the request as expected', async () => {
366
459
  interpretation.set({
@@ -195,6 +195,38 @@ describe('plugin-meetings', () => {
195
195
  );
196
196
  });
197
197
 
198
+ it('passes an isLlmExpected callback that is true when current device is joined', async () => {
199
+ locusInfo.parsedLocus.self = {
200
+ state: 'LEFT',
201
+ joinedWith: {state: 'JOINED'},
202
+ };
203
+
204
+ await locusInfo.initialSetup({
205
+ trigger: 'locus-message',
206
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
207
+ });
208
+
209
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
210
+
211
+ assert.equal(isLlmExpected(), true);
212
+ });
213
+
214
+ it('passes an isLlmExpected callback that is false when self is joined but current device is not joined', async () => {
215
+ locusInfo.parsedLocus.self = {
216
+ state: 'JOINED',
217
+ joinedWith: {state: 'LEFT'},
218
+ };
219
+
220
+ await locusInfo.initialSetup({
221
+ trigger: 'locus-message',
222
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
223
+ });
224
+
225
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
226
+
227
+ assert.equal(isLlmExpected(), false);
228
+ });
229
+
198
230
  it('should not initialize the hash tree when triggered from a non-hash tree locus message', async () => {
199
231
  const locus = {url: 'http://locus-url.com', participants: []};
200
232
 
@@ -2023,6 +2055,53 @@ describe('plugin-meetings', () => {
2023
2055
  });
2024
2056
 
2025
2057
  describe('#updateSelf', () => {
2058
+ describe('LLM watchdog re-evaluation', () => {
2059
+ it('re-evaluates LLM watchdogs on all hash tree parsers when self transitions to joined', () => {
2060
+ const parserA = {reevaluateLlmWatchdogs: sinon.stub()};
2061
+ const parserB = {reevaluateLlmWatchdogs: sinon.stub()};
2062
+ locusInfo.hashTreeParsers.set('urlA', {parser: parserA});
2063
+ locusInfo.hashTreeParsers.set('urlB', {parser: parserB});
2064
+
2065
+ // start with LLM not expected (no self yet)
2066
+ locusInfo.parsedLocus.self = undefined;
2067
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2068
+
2069
+ // the self fixture's joined device has state JOINED -> isLlmExpected becomes true
2070
+ locusInfo.updateSelf(cloneDeep(self));
2071
+
2072
+ assert.calledOnceWithExactly(parserA.reevaluateLlmWatchdogs);
2073
+ assert.calledOnceWithExactly(parserB.reevaluateLlmWatchdogs);
2074
+ });
2075
+
2076
+ it('does not re-evaluate LLM watchdogs when LLM was already expected before the update', () => {
2077
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2078
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2079
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2080
+
2081
+ // first update establishes the JOINED state (LLM already expected)
2082
+ locusInfo.updateSelf(cloneDeep(self));
2083
+ parser.reevaluateLlmWatchdogs.resetHistory();
2084
+
2085
+ // second update while already joined must not re-trigger re-evaluation
2086
+ locusInfo.updateSelf(cloneDeep(self));
2087
+
2088
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2089
+ });
2090
+
2091
+ it('does not re-evaluate LLM watchdogs when the self update does not make LLM expected', () => {
2092
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2093
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2094
+
2095
+ locusInfo.parsedLocus.self = undefined;
2096
+ // device url does not match any of self's devices -> joinedWith is undefined -> not expected
2097
+ locusInfo.webex.internal.device.url = 'https://some-other-device-url.com';
2098
+
2099
+ locusInfo.updateSelf(cloneDeep(self));
2100
+
2101
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2102
+ });
2103
+ });
2104
+
2026
2105
  it('should trigger SELF_MEETING_BRB_CHANGED when brb state changed', () => {
2027
2106
  locusInfo.self = undefined;
2028
2107
 
@@ -2448,6 +2527,7 @@ describe('plugin-meetings', () => {
2448
2527
 
2449
2528
  selfWithLocalUnmuteRequired.controls.audio.muted = false;
2450
2529
  selfWithLocalUnmuteRequired.controls.audio.localAudioUnmuteRequired = true;
2530
+ selfWithLocalUnmuteRequired.controls.audio.meta = {modifiedBy: 'host-uuid-123'};
2451
2531
 
2452
2532
  locusInfo.emitScoped = sinon.stub();
2453
2533
  locusInfo.updateSelf(selfWithLocalUnmuteRequired);
@@ -2462,6 +2542,33 @@ describe('plugin-meetings', () => {
2462
2542
  {
2463
2543
  muted: false,
2464
2544
  unmuteAllowed: true,
2545
+ modifiedBy: 'host-uuid-123',
2546
+ }
2547
+ );
2548
+ });
2549
+
2550
+ it('should set modifiedBy to null on LOCAL_UNMUTE_REQUIRED when it is unavailable', () => {
2551
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2552
+ locusInfo.updateSelf(self);
2553
+ const selfWithLocalUnmuteRequired = cloneDeep(self);
2554
+
2555
+ selfWithLocalUnmuteRequired.controls.audio.muted = false;
2556
+ selfWithLocalUnmuteRequired.controls.audio.localAudioUnmuteRequired = true;
2557
+
2558
+ locusInfo.emitScoped = sinon.stub();
2559
+ locusInfo.updateSelf(selfWithLocalUnmuteRequired);
2560
+
2561
+ assert.calledWith(
2562
+ locusInfo.emitScoped,
2563
+ {
2564
+ file: 'locus-info',
2565
+ function: 'updateSelf',
2566
+ },
2567
+ LOCUSINFO.EVENTS.LOCAL_UNMUTE_REQUIRED,
2568
+ {
2569
+ muted: false,
2570
+ unmuteAllowed: true,
2571
+ modifiedBy: null,
2465
2572
  }
2466
2573
  );
2467
2574
  });
@@ -4234,6 +4341,296 @@ describe('plugin-meetings', () => {
4234
4341
  assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: fakeLocus.url});
4235
4342
  });
4236
4343
 
4344
+ describe('#sync', () => {
4345
+ it('pauses the parser and awaits the Locus sync for classic meetings when canSyncClassicLocus is true', async () => {
4346
+ const fakeFullLocusDto = {id: 'fake full locus dto'};
4347
+ const meeting = {
4348
+ meetingRequest: {
4349
+ getLocusDTO: sandbox.stub().resolves({body: fakeFullLocusDto}),
4350
+ },
4351
+ locusInfo: {
4352
+ onFullLocus: sandbox.stub(),
4353
+ },
4354
+ locusUrl: 'someLocusUrl',
4355
+ };
4356
+
4357
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4358
+ sandbox.stub(locusInfo.locusParser, 'pause');
4359
+ sandbox.stub(locusInfo.locusParser, 'resume');
4360
+
4361
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4362
+
4363
+ assert.calledOnce(locusInfo.locusParser.pause);
4364
+ assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: 'someLocusUrl'});
4365
+ // sync() must not resolve until the fetched DTO has been applied
4366
+ assert.calledOnceWithExactly(
4367
+ meeting.locusInfo.onFullLocus,
4368
+ 'classic Locus sync',
4369
+ fakeFullLocusDto
4370
+ );
4371
+ assert.calledOnce(locusInfo.locusParser.resume);
4372
+ });
4373
+
4374
+ it('does nothing for classic meetings when the meeting has no Locus URL', async () => {
4375
+ const meeting = {
4376
+ meetingRequest: {
4377
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4378
+ },
4379
+ locusUrl: undefined,
4380
+ };
4381
+
4382
+ locusInfo.locusParser.workingCopy = {};
4383
+ sandbox.stub(locusInfo.locusParser, 'pause');
4384
+
4385
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4386
+
4387
+ assert.notCalled(locusInfo.locusParser.pause);
4388
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4389
+ });
4390
+
4391
+ it('does nothing for classic meetings when canSyncClassicLocus is false', async () => {
4392
+ const meeting = {
4393
+ meetingRequest: {
4394
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4395
+ },
4396
+ locusUrl: 'someLocusUrl',
4397
+ };
4398
+
4399
+ locusInfo.locusParser.workingCopy = {};
4400
+ sandbox.stub(locusInfo.locusParser, 'pause');
4401
+
4402
+ await locusInfo.sync(meeting, {canSyncClassicLocus: false, canSyncHashTree: true});
4403
+
4404
+ assert.notCalled(locusInfo.locusParser.pause);
4405
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4406
+ });
4407
+
4408
+ it('syncs hash tree datasets and never does a classic Locus sync for hash tree based meetings', async () => {
4409
+ const parser = {syncAllDatasets: sandbox.stub().resolves()};
4410
+ const meeting = {
4411
+ meetingRequest: {
4412
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4413
+ },
4414
+ };
4415
+
4416
+ locusInfo.hashTreeParsers.set('someLocusUrl', {parser});
4417
+ sandbox.stub(locusInfo.locusParser, 'pause');
4418
+
4419
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4420
+
4421
+ assert.calledOnce(parser.syncAllDatasets);
4422
+ assert.notCalled(locusInfo.locusParser.pause);
4423
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4424
+ });
4425
+
4426
+ it('does not sync hash tree datasets when canSyncHashTree is false', async () => {
4427
+ const parser = {syncAllDatasets: sandbox.stub().resolves()};
4428
+ const meeting = {
4429
+ meetingRequest: {
4430
+ getLocusDTO: sandbox.stub().resolves({body: {}}),
4431
+ },
4432
+ };
4433
+
4434
+ locusInfo.hashTreeParsers.set('someLocusUrl', {parser});
4435
+ sandbox.stub(locusInfo.locusParser, 'pause');
4436
+
4437
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: false});
4438
+
4439
+ assert.notCalled(parser.syncAllDatasets);
4440
+ assert.notCalled(locusInfo.locusParser.pause);
4441
+ assert.notCalled(meeting.meetingRequest.getLocusDTO);
4442
+ });
4443
+
4444
+ it('preserves the meeting and rejects when the classic sync fails, so the caller can retry', async () => {
4445
+ const fetchError = new Error('transient failure');
4446
+ const meeting = {
4447
+ meetingRequest: {
4448
+ getLocusDTO: sandbox.stub().rejects(fetchError),
4449
+ },
4450
+ locusInfo: {
4451
+ onFullLocus: sandbox.stub(),
4452
+ },
4453
+ locusUrl: 'someLocusUrl',
4454
+ };
4455
+
4456
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4457
+ sandbox.stub(locusInfo.locusParser, 'pause');
4458
+ sandbox.stub(locusInfo.locusParser, 'resume');
4459
+ sandbox.stub(webex.meetings, 'destroy');
4460
+
4461
+ await assert.isRejected(
4462
+ locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true}),
4463
+ fetchError
4464
+ );
4465
+
4466
+ // the meeting must not be torn down on a transient reconnection sync failure
4467
+ assert.notCalled(webex.meetings.destroy);
4468
+ // the parser must still be resumed so it isn't left paused
4469
+ assert.calledOnce(locusInfo.locusParser.resume);
4470
+ });
4471
+
4472
+ it('destroys the meeting and resolves when the classic sync gets a terminal 403, so the caller does not retry', async () => {
4473
+ const fake403Error = new Error('meeting ended');
4474
+ fake403Error.statusCode = 403;
4475
+ const meeting = {
4476
+ correlationId: 'correlationId',
4477
+ meetingRequest: {
4478
+ getLocusDTO: sandbox.stub().rejects(fake403Error),
4479
+ },
4480
+ locusInfo: {
4481
+ onFullLocus: sandbox.stub(),
4482
+ },
4483
+ locusUrl: 'someLocusUrl',
4484
+ };
4485
+
4486
+ locusInfo.locusParser.workingCopy = {syncUrl: 'deltaSyncUrl'}; // delta sync -> 403 is terminal
4487
+ sandbox.stub(locusInfo.locusParser, 'pause');
4488
+ sandbox.stub(locusInfo.locusParser, 'resume');
4489
+ sandbox.stub(webex.meetings, 'destroy');
4490
+
4491
+ // a terminal 403 means the meeting has ended, so the sync must resolve (not reject),
4492
+ // otherwise the reconnection flow would retry indefinitely
4493
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4494
+
4495
+ assert.calledOnceWithExactly(webex.meetings.destroy, meeting, 'LOCUS_DTO_SYNC_FAILED');
4496
+ // meeting was destroyed, so the parser is not resumed
4497
+ assert.notCalled(locusInfo.locusParser.resume);
4498
+ });
4499
+
4500
+ it('destroys the meeting and resolves when the fallback full sync gets a terminal 403, so the caller does not retry', async () => {
4501
+ const fakeDeltaError = new Error('delta failed');
4502
+ fakeDeltaError.statusCode = 500;
4503
+ const fake403Error = new Error('meeting ended');
4504
+ fake403Error.statusCode = 403;
4505
+ const getLocusDTO = sandbox.stub();
4506
+ getLocusDTO.onCall(0).rejects(fakeDeltaError); // delta sync fails with non-403
4507
+ getLocusDTO.onCall(1).rejects(fake403Error); // fallback full sync fails with 403
4508
+ const meeting = {
4509
+ correlationId: 'correlationId',
4510
+ meetingRequest: {
4511
+ getLocusDTO,
4512
+ },
4513
+ locusInfo: {
4514
+ onFullLocus: sandbox.stub(),
4515
+ },
4516
+ locusUrl: 'someLocusUrl',
4517
+ };
4518
+
4519
+ locusInfo.locusParser.workingCopy = {syncUrl: 'deltaSyncUrl'}; // delta sync -> fallback to full sync
4520
+ sandbox.stub(locusInfo.locusParser, 'pause');
4521
+ sandbox.stub(locusInfo.locusParser, 'resume');
4522
+ sandbox.stub(webex.meetings, 'destroy');
4523
+
4524
+ // a terminal 403 from the fallback full sync means the meeting has ended, so the sync must
4525
+ // resolve (not reject), otherwise the reconnection flow would retry indefinitely
4526
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4527
+
4528
+ assert.calledTwice(getLocusDTO);
4529
+ assert.deepEqual(getLocusDTO.getCalls()[0].args, [{url: 'deltaSyncUrl'}]);
4530
+ assert.deepEqual(getLocusDTO.getCalls()[1].args, [{url: 'someLocusUrl'}]);
4531
+ assert.calledOnceWithExactly(webex.meetings.destroy, meeting, 'LOCUS_DTO_SYNC_FAILED');
4532
+ // meeting was destroyed, so the parser is not resumed
4533
+ assert.notCalled(locusInfo.locusParser.resume);
4534
+ });
4535
+
4536
+ it('destroys the meeting and resolves when the direct full sync (no delta syncUrl) gets a terminal 403, so the caller does not retry', async () => {
4537
+ const fake403Error = new Error('meeting ended');
4538
+ fake403Error.statusCode = 403;
4539
+ const meeting = {
4540
+ correlationId: 'correlationId',
4541
+ meetingRequest: {
4542
+ getLocusDTO: sandbox.stub().rejects(fake403Error),
4543
+ },
4544
+ locusInfo: {
4545
+ onFullLocus: sandbox.stub(),
4546
+ },
4547
+ locusUrl: 'someLocusUrl',
4548
+ };
4549
+
4550
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> direct full sync, 403 is terminal
4551
+ sandbox.stub(locusInfo.locusParser, 'pause');
4552
+ sandbox.stub(locusInfo.locusParser, 'resume');
4553
+ sandbox.stub(webex.meetings, 'destroy');
4554
+
4555
+ // a terminal 403 from the direct full sync means the meeting has ended, so the sync must
4556
+ // resolve (not reject), otherwise the reconnection flow would retry indefinitely
4557
+ await locusInfo.sync(meeting, {canSyncClassicLocus: true, canSyncHashTree: true});
4558
+
4559
+ assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: 'someLocusUrl'});
4560
+ assert.calledOnceWithExactly(webex.meetings.destroy, meeting, 'LOCUS_DTO_SYNC_FAILED');
4561
+ // meeting was destroyed, so the parser is not resumed
4562
+ assert.notCalled(locusInfo.locusParser.resume);
4563
+ });
4564
+ });
4565
+
4566
+ describe('#doLocusSync', () => {
4567
+ it('resolves without destroying the meeting when the DTO is fetched but applying it fails and destroyOnTransientFailure is true', async () => {
4568
+ const fakeFullLocusDto = {id: 'fake full locus dto'};
4569
+ const applyError = new Error('failed to apply DTO');
4570
+ const meeting = {
4571
+ correlationId: 'correlationId',
4572
+ meetingRequest: {
4573
+ getLocusDTO: sandbox.stub().resolves({body: fakeFullLocusDto}),
4574
+ },
4575
+ locusInfo: {
4576
+ onFullLocus: sandbox.stub().throws(applyError),
4577
+ },
4578
+ locusUrl: 'someLocusUrl',
4579
+ };
4580
+
4581
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4582
+ sandbox.stub(locusInfo.locusParser, 'resume');
4583
+ sandbox.stub(webex.meetings, 'destroy');
4584
+
4585
+ // destroyOnTransientFailure defaults to true: a successfully fetched DTO that then fails to
4586
+ // apply must not reject or destroy the meeting - doLocusSync just resumes the parser and
4587
+ // resolves (the returned promise must not reject)
4588
+ await locusInfo.doLocusSync(meeting, false, undefined);
4589
+
4590
+ assert.calledOnceWithExactly(
4591
+ meeting.locusInfo.onFullLocus,
4592
+ 'classic Locus sync',
4593
+ fakeFullLocusDto
4594
+ );
4595
+ assert.notCalled(webex.meetings.destroy);
4596
+ assert.calledOnce(locusInfo.locusParser.resume);
4597
+ });
4598
+
4599
+ it('resolves (does not reject) when the DTO is fetched but applying it fails even when destroyOnTransientFailure is false, so the sync is not retried indefinitely', async () => {
4600
+ const fakeFullLocusDto = {id: 'fake full locus dto'};
4601
+ const applyError = new Error('failed to apply DTO');
4602
+ const meeting = {
4603
+ correlationId: 'correlationId',
4604
+ meetingRequest: {
4605
+ getLocusDTO: sandbox.stub().resolves({body: fakeFullLocusDto}),
4606
+ },
4607
+ locusInfo: {
4608
+ onFullLocus: sandbox.stub().throws(applyError),
4609
+ },
4610
+ locusUrl: 'someLocusUrl',
4611
+ };
4612
+
4613
+ locusInfo.locusParser.workingCopy = {}; // no syncUrl -> full sync
4614
+ sandbox.stub(locusInfo.locusParser, 'resume');
4615
+ sandbox.stub(webex.meetings, 'destroy');
4616
+
4617
+ // Even on the caller-driven (reconnection) path (destroyOnTransientFailure: false), an
4618
+ // application failure must not reject: retrying would re-fetch and re-apply the same
4619
+ // unprocessable DTO, so doLocusSync just resumes the parser and resolves.
4620
+ await locusInfo.doLocusSync(meeting, false, undefined, {
4621
+ destroyOnTransientFailure: false,
4622
+ });
4623
+
4624
+ assert.calledOnceWithExactly(
4625
+ meeting.locusInfo.onFullLocus,
4626
+ 'classic Locus sync',
4627
+ fakeFullLocusDto
4628
+ );
4629
+ assert.notCalled(webex.meetings.destroy);
4630
+ assert.calledOnce(locusInfo.locusParser.resume);
4631
+ });
4632
+ });
4633
+
4237
4634
  describe('edge cases for sync failing', () => {
4238
4635
  const {DESYNC} = LocusDeltaParser.loci;
4239
4636
  const fakeFullLocusDto = {id: 'fake full locus dto'};