@atlaskit/collab-provider 10.2.1 → 10.3.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.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/analytics/analytics-helper.js +1 -2
- package/dist/cjs/api/api.js +5 -7
- package/dist/cjs/api/null-api.js +1 -2
- package/dist/cjs/channel.js +34 -37
- package/dist/cjs/connectivity/network.js +1 -2
- package/dist/cjs/connectivity/reconnect-helper.js +1 -2
- package/dist/cjs/document/document-service.js +75 -49
- package/dist/cjs/document/null-document-service.js +1 -2
- package/dist/cjs/document/step-queue-state.js +1 -2
- package/dist/cjs/emitter.js +1 -2
- package/dist/cjs/errors/custom-errors.js +54 -69
- package/dist/cjs/metadata/metadata-service.js +1 -2
- package/dist/cjs/participants/participants-service.js +21 -26
- package/dist/cjs/provider/index.js +37 -34
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/document/document-service.js +67 -46
- package/dist/es2019/participants/participants-service.js +18 -22
- package/dist/es2019/provider/index.js +5 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/analytics/analytics-helper.js +1 -2
- package/dist/esm/api/api.js +5 -7
- package/dist/esm/api/null-api.js +1 -2
- package/dist/esm/channel.js +34 -37
- package/dist/esm/connectivity/network.js +1 -2
- package/dist/esm/connectivity/reconnect-helper.js +1 -2
- package/dist/esm/document/document-service.js +75 -49
- package/dist/esm/document/null-document-service.js +1 -2
- package/dist/esm/document/step-queue-state.js +1 -2
- package/dist/esm/emitter.js +1 -2
- package/dist/esm/errors/custom-errors.js +54 -69
- package/dist/esm/metadata/metadata-service.js +1 -2
- package/dist/esm/participants/participants-service.js +21 -26
- package/dist/esm/provider/index.js +37 -34
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +1 -2
- package/dist/types-ts4.5/document/document-service.d.ts +1 -2
- package/package.json +5 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
3
4
|
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
4
5
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
@@ -264,9 +265,9 @@ export class DocumentService {
|
|
|
264
265
|
// We can then reconcile the document with the preserved state.
|
|
265
266
|
const unconfirmedSteps = this.getUnconfirmedSteps();
|
|
266
267
|
const currentState = await this.getCurrentState();
|
|
267
|
-
|
|
268
|
+
let useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && currentState && !targetClientId);
|
|
268
269
|
try {
|
|
269
|
-
var _this$
|
|
270
|
+
var _this$analyticsHelper14;
|
|
270
271
|
// Reset the editor,
|
|
271
272
|
// - Replace the document, keep in sync with the server
|
|
272
273
|
// - Replace the version number, so editor is in sync with NCS server and can commit new changes.
|
|
@@ -280,16 +281,36 @@ export class DocumentService {
|
|
|
280
281
|
reserveCursor: true
|
|
281
282
|
});
|
|
282
283
|
this.metadataService.updateMetadata(metadata);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
284
|
+
if (fg('restore_localstep_fallback_reconcile')) {
|
|
285
|
+
try {
|
|
286
|
+
var _this$analyticsHelper12;
|
|
287
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
288
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
289
|
+
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
290
|
+
clientId: this.clientId,
|
|
291
|
+
targetClientId,
|
|
292
|
+
triggeredByCatchup: targetClientId ? true : false
|
|
293
|
+
});
|
|
294
|
+
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
295
|
+
this.applyLocalSteps(unconfirmedSteps);
|
|
296
|
+
}
|
|
297
|
+
} catch (applyLocalStepsError) {
|
|
298
|
+
var _this$analyticsHelper13;
|
|
299
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(applyLocalStepsError, `Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile`);
|
|
300
|
+
useReconcile = true;
|
|
301
|
+
await this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
// If there are unconfirmed steps, attempt to reconcile our current state with with recovered document
|
|
305
|
+
if (useReconcile && currentState) {
|
|
306
|
+
await this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
307
|
+
} else if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
308
|
+
// we don't want to use reconcile for restore triggered by catchup client out of sync (when targetClientId is provided)
|
|
309
|
+
// as this results in all changes made while the client was out of sync being lost
|
|
310
|
+
this.applyLocalSteps(unconfirmedSteps);
|
|
311
|
+
}
|
|
291
312
|
}
|
|
292
|
-
(_this$
|
|
313
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
293
314
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
294
315
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
295
316
|
useReconcile,
|
|
@@ -298,15 +319,15 @@ export class DocumentService {
|
|
|
298
319
|
triggeredByCatchup: targetClientId ? true : false
|
|
299
320
|
});
|
|
300
321
|
} catch (restoreError) {
|
|
301
|
-
var _this$
|
|
302
|
-
(_this$
|
|
322
|
+
var _this$analyticsHelper15, _this$analyticsHelper16;
|
|
323
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
|
|
303
324
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
304
325
|
useReconcile,
|
|
305
326
|
clientId: this.clientId,
|
|
306
327
|
targetClientId,
|
|
307
328
|
triggeredByCatchup: targetClientId ? true : false
|
|
308
329
|
});
|
|
309
|
-
(_this$
|
|
330
|
+
(_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
|
|
310
331
|
this.onErrorHandled({
|
|
311
332
|
message: 'Caught error while trying to recover the document',
|
|
312
333
|
data: {
|
|
@@ -320,7 +341,7 @@ export class DocumentService {
|
|
|
320
341
|
_defineProperty(this, "getFinalAcknowledgedState", async () => {
|
|
321
342
|
this.aggressiveCatchup = true;
|
|
322
343
|
try {
|
|
323
|
-
var _this$
|
|
344
|
+
var _this$analyticsHelper17;
|
|
324
345
|
startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
325
346
|
let finalAcknowledgedState;
|
|
326
347
|
try {
|
|
@@ -337,19 +358,19 @@ export class DocumentService {
|
|
|
337
358
|
};
|
|
338
359
|
}
|
|
339
360
|
const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
340
|
-
(_this$
|
|
361
|
+
(_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
341
362
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
342
363
|
});
|
|
343
364
|
this.aggressiveCatchup = false;
|
|
344
365
|
return finalAcknowledgedState;
|
|
345
366
|
} catch (error) {
|
|
346
|
-
var _this$
|
|
367
|
+
var _this$analyticsHelper18, _this$analyticsHelper19;
|
|
347
368
|
this.aggressiveCatchup = false;
|
|
348
369
|
const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
349
|
-
(_this$
|
|
370
|
+
(_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
350
371
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
351
372
|
});
|
|
352
|
-
(_this$
|
|
373
|
+
(_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
|
|
353
374
|
throw error; // Reject the promise so the consumer can react to it failing
|
|
354
375
|
}
|
|
355
376
|
});
|
|
@@ -375,7 +396,7 @@ export class DocumentService {
|
|
|
375
396
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
376
397
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
377
398
|
if (updatedVersion < version) {
|
|
378
|
-
var _doc$content, _this$
|
|
399
|
+
var _doc$content, _this$analyticsHelper20;
|
|
379
400
|
const error = new UpdateDocumentError('Failed to update the document', {
|
|
380
401
|
newVersion: version,
|
|
381
402
|
editorVersion: updatedVersion,
|
|
@@ -383,7 +404,7 @@ export class DocumentService {
|
|
|
383
404
|
docHasContent: (doc === null || doc === void 0 ? void 0 : (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
|
|
384
405
|
isDocContentValid
|
|
385
406
|
});
|
|
386
|
-
(_this$
|
|
407
|
+
(_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
387
408
|
if (this.enableErrorOnFailedDocumentApply) {
|
|
388
409
|
this.onErrorHandled({
|
|
389
410
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -400,8 +421,8 @@ export class DocumentService {
|
|
|
400
421
|
}
|
|
401
422
|
// Otherwise just fail silently for now
|
|
402
423
|
} else {
|
|
403
|
-
var _this$
|
|
404
|
-
(_this$
|
|
424
|
+
var _this$analyticsHelper21, _doc$content2;
|
|
425
|
+
(_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
405
426
|
newVersion: version,
|
|
406
427
|
editorVersion: updatedVersion,
|
|
407
428
|
isDocTruthy: !!doc,
|
|
@@ -414,8 +435,8 @@ export class DocumentService {
|
|
|
414
435
|
try {
|
|
415
436
|
var _this$getState5;
|
|
416
437
|
if (!((_this$getState5 = this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(this))) {
|
|
417
|
-
var _this$
|
|
418
|
-
(_this$
|
|
438
|
+
var _this$analyticsHelper22;
|
|
439
|
+
(_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
419
440
|
}
|
|
420
441
|
const state = this.getState();
|
|
421
442
|
const content = (doc.content || []).map(child => state.schema.nodeFromJSON(child));
|
|
@@ -439,7 +460,7 @@ export class DocumentService {
|
|
|
439
460
|
const unconfirmedSteps = this.getUnconfirmedSteps();
|
|
440
461
|
try {
|
|
441
462
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
442
|
-
var _this$getState6, _this$
|
|
463
|
+
var _this$getState6, _this$analyticsHelper24;
|
|
443
464
|
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
444
465
|
let count = 0;
|
|
445
466
|
// We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
@@ -450,8 +471,8 @@ export class DocumentService {
|
|
|
450
471
|
const lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
451
472
|
let isLastTrConfirmed = false;
|
|
452
473
|
if (!((_this$getState6 = this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(this))) {
|
|
453
|
-
var _this$
|
|
454
|
-
(_this$
|
|
474
|
+
var _this$analyticsHelper23;
|
|
475
|
+
(_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
455
476
|
}
|
|
456
477
|
while (!isLastTrConfirmed) {
|
|
457
478
|
this.sendStepsFromCurrentState();
|
|
@@ -484,35 +505,35 @@ export class DocumentService {
|
|
|
484
505
|
}
|
|
485
506
|
}
|
|
486
507
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
487
|
-
(_this$
|
|
508
|
+
(_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
488
509
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
489
510
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
490
511
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
491
512
|
});
|
|
492
513
|
}
|
|
493
514
|
} catch (error) {
|
|
494
|
-
var _this$
|
|
515
|
+
var _this$analyticsHelper25, _this$analyticsHelper26;
|
|
495
516
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
496
|
-
(_this$
|
|
517
|
+
(_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
497
518
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
498
519
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
499
520
|
});
|
|
500
|
-
(_this$
|
|
521
|
+
(_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendErrorEvent(error, 'Error while committing unconfirmed steps');
|
|
501
522
|
throw error;
|
|
502
523
|
}
|
|
503
524
|
});
|
|
504
525
|
_defineProperty(this, "onStepRejectedError", () => {
|
|
505
|
-
var _this$
|
|
526
|
+
var _this$analyticsHelper27;
|
|
506
527
|
this.stepRejectCounter++;
|
|
507
528
|
logger(`Steps rejected (tries=${this.stepRejectCounter})`);
|
|
508
|
-
(_this$
|
|
529
|
+
(_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
509
530
|
count: this.stepRejectCounter
|
|
510
531
|
});
|
|
511
532
|
let maxRetries = this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
|
|
512
533
|
if (this.stepRejectCounter >= maxRetries) {
|
|
513
|
-
var _this$
|
|
534
|
+
var _this$analyticsHelper28;
|
|
514
535
|
logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
|
|
515
|
-
(_this$
|
|
536
|
+
(_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
516
537
|
this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
|
|
517
538
|
} else {
|
|
518
539
|
// If committing steps failed try again automatically in 1s
|
|
@@ -539,15 +560,15 @@ export class DocumentService {
|
|
|
539
560
|
getVersionFromCollabState(state, resource) {
|
|
540
561
|
const collabState = getCollabState(state);
|
|
541
562
|
if (!collabState) {
|
|
542
|
-
var _this$
|
|
543
|
-
(_this$
|
|
563
|
+
var _this$analyticsHelper29;
|
|
564
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
|
|
544
565
|
return 0;
|
|
545
566
|
}
|
|
546
567
|
|
|
547
568
|
// This should not happen in usual, just add error event in case it happens
|
|
548
569
|
if (collabState.version === undefined) {
|
|
549
|
-
var _this$
|
|
550
|
-
(_this$
|
|
570
|
+
var _this$analyticsHelper30;
|
|
571
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
|
|
551
572
|
return 0;
|
|
552
573
|
}
|
|
553
574
|
return collabState.version;
|
|
@@ -595,11 +616,11 @@ export class DocumentService {
|
|
|
595
616
|
setTimeout(() => this.sendStepsFromCurrentState(), 100);
|
|
596
617
|
}
|
|
597
618
|
} catch (error) {
|
|
598
|
-
var _this$
|
|
619
|
+
var _this$analyticsHelper31;
|
|
599
620
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
600
621
|
let userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
601
622
|
logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
|
|
602
|
-
(_this$
|
|
623
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(error, userIdMatch ? `Error while processing steps with new clientId` : `Error while processing steps`);
|
|
603
624
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
604
625
|
}
|
|
605
626
|
}
|
|
@@ -629,8 +650,8 @@ export class DocumentService {
|
|
|
629
650
|
var _this$getState7;
|
|
630
651
|
const state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
631
652
|
if (!state) {
|
|
632
|
-
var _this$
|
|
633
|
-
(_this$
|
|
653
|
+
var _this$analyticsHelper32;
|
|
654
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
634
655
|
return;
|
|
635
656
|
}
|
|
636
657
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -652,8 +673,8 @@ export class DocumentService {
|
|
|
652
673
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
653
674
|
// sent once on connection (as opposed to on every step)
|
|
654
675
|
if (sendAnalyticsEvent) {
|
|
655
|
-
var _this$
|
|
656
|
-
(_this$
|
|
676
|
+
var _this$analyticsHelper33;
|
|
677
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 ? void 0 : _this$analyticsHelper33.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
657
678
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
658
679
|
});
|
|
659
680
|
}
|
|
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import { disconnectedReasonMapper } from '../disconnected-reason-mapper';
|
|
3
3
|
import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
4
4
|
import { telepointerFromStep } from './telepointers-helper';
|
|
5
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
6
5
|
import { createParticipantFromPayload as enrichParticipant, PARTICIPANT_UPDATE_INTERVAL } from './participants-helper';
|
|
7
6
|
import { ParticipantsState } from './participants-state';
|
|
8
7
|
import { createLogger, isAIProviderID } from '../helpers/utils';
|
|
@@ -21,8 +20,7 @@ const SEND_PRESENCE_INTERVAL = 150 * 1000; // 150 seconds
|
|
|
21
20
|
export class ParticipantsService {
|
|
22
21
|
constructor(analyticsHelper, participantsState = new ParticipantsState(), emit, getUser, channelBroadcast, sendPresenceJoined, getPresenceData, setUserId, getAIProviderActiveIds) {
|
|
23
22
|
_defineProperty(this, "sendAIProviderChanged", payload => {
|
|
24
|
-
|
|
25
|
-
if (isFacepileExperimentEnabled && payload.providerId) {
|
|
23
|
+
if (payload.providerId) {
|
|
26
24
|
for (const propKey in payload.permit) {
|
|
27
25
|
if (payload.permit.hasOwnProperty(propKey)) {
|
|
28
26
|
payload.permit[propKey] = false;
|
|
@@ -111,27 +109,25 @@ export class ParticipantsService {
|
|
|
111
109
|
* We emit the `presence` event to update the active avatars in the editor.
|
|
112
110
|
*/
|
|
113
111
|
_defineProperty(this, "onParticipantLeft", payload => {
|
|
112
|
+
var _payload$data;
|
|
114
113
|
let sessionId = payload.sessionId;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
userId: undefined,
|
|
131
|
-
clientId: ''
|
|
132
|
-
});
|
|
114
|
+
|
|
115
|
+
// When an agent leaves a session, the backend service returns the original user's
|
|
116
|
+
// session ID accompanied by a payload containing the agent's session ID.
|
|
117
|
+
// If the user session leaves, we also want to remove all agent sessions associated.
|
|
118
|
+
if (payload !== null && payload !== void 0 && (_payload$data = payload.data) !== null && _payload$data !== void 0 && _payload$data.sessionId && isAIProviderID(payload.data.sessionId)) {
|
|
119
|
+
sessionId = payload.data.sessionId;
|
|
120
|
+
} else {
|
|
121
|
+
const associatedAgents = this.getAIProviderParticipants().filter(ap => ap.sessionId.endsWith(sessionId));
|
|
122
|
+
associatedAgents.forEach(agent => {
|
|
123
|
+
this.onParticipantLeft({
|
|
124
|
+
sessionId,
|
|
125
|
+
timestamp: payload.timestamp,
|
|
126
|
+
data: agent,
|
|
127
|
+
userId: undefined,
|
|
128
|
+
clientId: ''
|
|
133
129
|
});
|
|
134
|
-
}
|
|
130
|
+
});
|
|
135
131
|
}
|
|
136
132
|
this.participantsState.removeBySessionId(sessionId);
|
|
137
133
|
this.emitPresence({
|
|
@@ -275,6 +275,7 @@ export class Provider extends Emitter {
|
|
|
275
275
|
this.documentService.sendStepsFromCurrentState(true);
|
|
276
276
|
}, 5000);
|
|
277
277
|
}
|
|
278
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
278
279
|
/**
|
|
279
280
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
280
281
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -465,6 +466,7 @@ export class Provider extends Emitter {
|
|
|
465
466
|
return this.unsubscribeAll();
|
|
466
467
|
}
|
|
467
468
|
|
|
469
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
468
470
|
/**
|
|
469
471
|
* Disconnect the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
|
470
472
|
* Used by Confluence to disable the provider when a user doesn't have access to a resource.
|
|
@@ -475,6 +477,7 @@ export class Provider extends Emitter {
|
|
|
475
477
|
return this.unsubscribeAll();
|
|
476
478
|
}
|
|
477
479
|
|
|
480
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
478
481
|
/**
|
|
479
482
|
* Disconnect the provider's connection to the back-end service and unsubscribe from all events emitted by this provider. Kept to keep roughly aligned to Synchrony API, which you need to call for each event.
|
|
480
483
|
* @deprecated use destroy instead, it does the same thing
|
|
@@ -497,6 +500,7 @@ export class Provider extends Emitter {
|
|
|
497
500
|
return this;
|
|
498
501
|
}
|
|
499
502
|
|
|
503
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
500
504
|
/**
|
|
501
505
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
502
506
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -517,6 +521,7 @@ export class Provider extends Emitter {
|
|
|
517
521
|
}
|
|
518
522
|
}
|
|
519
523
|
|
|
524
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
520
525
|
/**
|
|
521
526
|
* Set editor width, not used any more
|
|
522
527
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -67,7 +67,7 @@ var AnalyticsHelper = /*#__PURE__*/function () {
|
|
|
67
67
|
this.analyticsClient = analyticsClient;
|
|
68
68
|
this.getAnalyticsClient = getAnalyticsClient;
|
|
69
69
|
}
|
|
70
|
-
_createClass(AnalyticsHelper, [{
|
|
70
|
+
return _createClass(AnalyticsHelper, [{
|
|
71
71
|
key: "sendErrorEvent",
|
|
72
72
|
value: function sendErrorEvent(error, errorMessage) {
|
|
73
73
|
var _data$code, _data, _data$status, _data2;
|
|
@@ -167,6 +167,5 @@ var AnalyticsHelper = /*#__PURE__*/function () {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}]);
|
|
170
|
-
return AnalyticsHelper;
|
|
171
170
|
}();
|
|
172
171
|
export { AnalyticsHelper as default };
|
package/dist/esm/api/api.js
CHANGED
|
@@ -2,29 +2,28 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
8
|
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
11
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
function
|
|
12
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import { getProduct, getSubProduct, createLogger } from '../helpers/utils';
|
|
15
15
|
var logger = createLogger('Api', 'blue');
|
|
16
16
|
var AddCommentError = /*#__PURE__*/function (_Error) {
|
|
17
|
-
_inherits(AddCommentError, _Error);
|
|
18
|
-
var _super = _createSuper(AddCommentError);
|
|
19
17
|
function AddCommentError(message, status, meta) {
|
|
20
18
|
var _this;
|
|
21
19
|
_classCallCheck(this, AddCommentError);
|
|
22
|
-
_this =
|
|
20
|
+
_this = _callSuper(this, AddCommentError, [message]);
|
|
23
21
|
_this.name = 'AddCommentError';
|
|
24
22
|
_this.status = status;
|
|
25
23
|
_this.meta = meta;
|
|
26
24
|
return _this;
|
|
27
25
|
}
|
|
26
|
+
_inherits(AddCommentError, _Error);
|
|
28
27
|
return _createClass(AddCommentError);
|
|
29
28
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
30
29
|
/**
|
|
@@ -104,7 +103,7 @@ export var Api = /*#__PURE__*/function () {
|
|
|
104
103
|
this.documentService = documentService;
|
|
105
104
|
this.channel = channel;
|
|
106
105
|
}
|
|
107
|
-
_createClass(Api, [{
|
|
106
|
+
return _createClass(Api, [{
|
|
108
107
|
key: "addComment",
|
|
109
108
|
value: function () {
|
|
110
109
|
var _addComment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(steps) {
|
|
@@ -165,5 +164,4 @@ export var Api = /*#__PURE__*/function () {
|
|
|
165
164
|
return addComment;
|
|
166
165
|
}()
|
|
167
166
|
}]);
|
|
168
|
-
return Api;
|
|
169
167
|
}();
|
package/dist/esm/api/null-api.js
CHANGED
|
@@ -7,7 +7,7 @@ export var NullApi = /*#__PURE__*/function () {
|
|
|
7
7
|
function NullApi() {
|
|
8
8
|
_classCallCheck(this, NullApi);
|
|
9
9
|
}
|
|
10
|
-
_createClass(NullApi, [{
|
|
10
|
+
return _createClass(NullApi, [{
|
|
11
11
|
key: "addComment",
|
|
12
12
|
value: function () {
|
|
13
13
|
var _addComment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -27,5 +27,4 @@ export var NullApi = /*#__PURE__*/function () {
|
|
|
27
27
|
return addComment;
|
|
28
28
|
}()
|
|
29
29
|
}]);
|
|
30
|
-
return NullApi;
|
|
31
30
|
}();
|