@atlaskit/collab-provider 8.9.1 → 9.0.1

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 (48) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/channel.js +6 -8
  3. package/dist/cjs/document/catchup.js +8 -1
  4. package/dist/cjs/document/document-service.js +3 -2
  5. package/dist/cjs/helpers/const.js +2 -1
  6. package/dist/cjs/participants/participants-service.js +11 -5
  7. package/dist/cjs/provider/index.js +20 -7
  8. package/dist/cjs/types.js +2 -3
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/channel.js +6 -6
  12. package/dist/es2019/document/catchup.js +8 -0
  13. package/dist/es2019/document/document-service.js +3 -2
  14. package/dist/es2019/helpers/const.js +2 -1
  15. package/dist/es2019/participants/participants-service.js +10 -6
  16. package/dist/es2019/provider/index.js +13 -3
  17. package/dist/es2019/types.js +4 -4
  18. package/dist/es2019/version-wrapper.js +1 -1
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/channel.js +6 -8
  21. package/dist/esm/document/catchup.js +8 -1
  22. package/dist/esm/document/document-service.js +3 -2
  23. package/dist/esm/helpers/const.js +2 -1
  24. package/dist/esm/participants/participants-service.js +11 -5
  25. package/dist/esm/provider/index.js +20 -7
  26. package/dist/esm/types.js +4 -4
  27. package/dist/esm/version-wrapper.js +1 -1
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/channel.d.ts +1 -1
  30. package/dist/types/document/document-service.d.ts +2 -3
  31. package/dist/types/helpers/const.d.ts +11 -3
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/participants/participants-helper.d.ts +4 -3
  34. package/dist/types/participants/participants-service.d.ts +4 -3
  35. package/dist/types/participants/telepointers-helper.d.ts +2 -2
  36. package/dist/types/provider/index.d.ts +6 -5
  37. package/dist/types/types.d.ts +58 -8
  38. package/dist/types-ts4.5/channel.d.ts +1 -1
  39. package/dist/types-ts4.5/document/document-service.d.ts +2 -3
  40. package/dist/types-ts4.5/helpers/const.d.ts +11 -3
  41. package/dist/types-ts4.5/index.d.ts +1 -1
  42. package/dist/types-ts4.5/participants/participants-helper.d.ts +4 -3
  43. package/dist/types-ts4.5/participants/participants-service.d.ts +4 -3
  44. package/dist/types-ts4.5/participants/telepointers-helper.d.ts +2 -2
  45. package/dist/types-ts4.5/provider/index.d.ts +6 -5
  46. package/dist/types-ts4.5/types.d.ts +58 -8
  47. package/package.json +3 -4
  48. package/report.api.md +105 -13
@@ -107,6 +107,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
107
107
  return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
108
108
  }).on('presence:joined', _this.participantsService.onPresenceJoined).on('presence', _this.participantsService.onPresence).on('participant:left', _this.participantsService.onParticipantLeft).on('participant:updated', _this.participantsService.onParticipantUpdated).on('disconnect', _this.onDisconnected.bind(_assertThisInitialized(_this))).on('error', _this.onErrorHandled).on('status', _this.namespaceService.onNamespaceStatusChanged).connect(shouldInitialize);
109
109
  });
110
+ _defineProperty(_assertThisInitialized(_this), "setUserId", function (id) {
111
+ _this.userId = id;
112
+ });
113
+ _defineProperty(_assertThisInitialized(_this), "getPresenceData", function () {
114
+ return {
115
+ sessionId: _this.sessionId,
116
+ userId: _this.userId,
117
+ clientId: _this.clientId
118
+ };
119
+ });
110
120
  /**
111
121
  * @param {InternalError} error The error to handle
112
122
  */
@@ -175,17 +185,20 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
175
185
  while (1) switch (_context2.prev = _context2.next) {
176
186
  case 0:
177
187
  _context2.prev = 0;
178
- return _context2.abrupt("return", _this.documentService.getFinalAcknowledgedState());
179
- case 4:
180
- _context2.prev = 4;
188
+ _context2.next = 3;
189
+ return _this.documentService.getFinalAcknowledgedState();
190
+ case 3:
191
+ return _context2.abrupt("return", _context2.sent);
192
+ case 6:
193
+ _context2.prev = 6;
181
194
  _context2.t0 = _context2["catch"](0);
182
195
  (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
183
196
  throw new GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
184
- case 8:
197
+ case 10:
185
198
  case "end":
186
199
  return _context2.stop();
187
200
  }
188
- }, _callee2, null, [[0, 4]]);
201
+ }, _callee2, null, [[0, 6]]);
189
202
  })));
190
203
  _defineProperty(_assertThisInitialized(_this), "getUnconfirmedSteps", function () {
191
204
  return _this.documentService.getUnconfirmedSteps();
@@ -204,7 +217,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
204
217
  _this.initialDraft = _this.config.initialDraft;
205
218
  _this.isProviderInitialized = false;
206
219
  _this.isPreinitializing = false;
207
- _this.participantsService = new ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined);
220
+ _this.participantsService = new ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined, _this.getPresenceData, _this.setUserId);
208
221
  _this.metadataService = new MetadataService(_this.emitCallback, _this.channel.sendMetadata);
209
222
  _this.documentService = new DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.emitCallback, _this.channel.broadcast, function () {
210
223
  return _this.userId;
@@ -324,7 +337,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
324
337
  /**
325
338
  * Send messages, such as telepointers, to NCS and other participants. Only used for telepointer data (text and node selections) in the editor and JWM. JWM does some weird serialisation stuff on the node selections.
326
339
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
327
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
340
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
328
341
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
329
342
  * @param {CollabSendableSelection} data.selection Object representing the selected element
330
343
  * @param {string} data.sessionId Identifier identifying the session
package/dist/esm/types.js CHANGED
@@ -1,8 +1,8 @@
1
- // Initial draft
1
+ // types from editor common
2
2
 
3
- /**
4
- * @deprecated Use ProviderError type instead
5
- */
3
+ // types from editor common end
4
+
5
+ // Initial draft
6
6
 
7
7
  // Channel
8
8
 
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "8.9.1";
2
+ export var version = "9.0.1";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "8.9.1",
3
+ "version": "9.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -41,7 +41,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
41
41
  * @throws {NotConnectedError} Channel not connected
42
42
  */
43
43
  sendMetadata: (metadata: Metadata) => void;
44
- sendPresenceJoined(): void;
44
+ sendPresenceJoined: () => void;
45
45
  onOnlineHandler: () => void;
46
46
  disconnect(): void;
47
47
  }
@@ -1,11 +1,10 @@
1
1
  /// <reference types="lodash" />
2
2
  import AnalyticsHelper from '../analytics/analytics-helper';
3
- import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, StepsPayload } from '../types';
3
+ import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, ResolvedEditorState, StepsPayload } from '../types';
4
4
  import type { Step as ProseMirrorStep } from 'prosemirror-transform';
5
5
  import type { MetadataService } from '../metadata/metadata-service';
6
- import { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
6
+ import { SyncUpErrorFunction } from '../types';
7
7
  import type { EditorState, Transaction } from 'prosemirror-state';
8
- import { ResolvedEditorState } from '@atlaskit/editor-common/collab';
9
8
  import { ParticipantsService } from '../participants/participants-service';
10
9
  import type { InternalError } from '../errors/error-types';
11
10
  export declare class DocumentService {
@@ -10,7 +10,8 @@ export declare enum EVENT_ACTION {
10
10
  ERROR = "error",
11
11
  PUBLISH_PAGE = "publishPage",
12
12
  GET_CURRENT_STATE = "getCurrentState",
13
- INVALIDATE_TOKEN = "invalidateToken"
13
+ INVALIDATE_TOKEN = "invalidateToken",
14
+ DROPPED_STEPS = "droppedStepInCatchup"
14
15
  }
15
16
  export declare enum EVENT_STATUS {
16
17
  SUCCESS = "SUCCESS",
@@ -110,6 +111,13 @@ type CatchUpFailureAnalyticsEvent = {
110
111
  latency?: number;
111
112
  };
112
113
  };
114
+ type CatchUpDroppedStepsEvent = {
115
+ eventAction: EVENT_ACTION.DROPPED_STEPS;
116
+ attributes: {
117
+ documentAri: string;
118
+ numOfDroppedSteps: number;
119
+ };
120
+ };
113
121
  type DocumentInitSuccessAnalyticsEvent = {
114
122
  eventAction: EVENT_ACTION.DOCUMENT_INIT;
115
123
  attributes: {
@@ -177,7 +185,7 @@ type GetCurrentStateFailureAnalyticsEvent = {
177
185
  latency?: number;
178
186
  };
179
187
  };
180
- export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
181
- export declare const ACK_MAX_TRY = 30;
188
+ export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | CatchUpDroppedStepsEvent;
189
+ export declare const ACK_MAX_TRY = 60;
182
190
  export declare const CONFLUENCE = "confluence";
183
191
  export {};
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, Socket, } from './types';
2
+ export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, } from './types';
3
3
  export type { ProviderError } from './errors/error-types';
4
4
  export { PROVIDER_ERROR_CODE } from './errors/error-types';
@@ -1,5 +1,4 @@
1
- import type { CollabParticipant } from '@atlaskit/editor-common/collab';
2
- import type { PresencePayload } from '../types';
1
+ import type { CollabParticipant, PresencePayload } from '../types';
3
2
  export declare const PARTICIPANT_UPDATE_INTERVAL: number;
4
3
  export type ProviderParticipant = CollabParticipant & {
5
4
  userId: string;
@@ -7,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
7
6
  };
8
7
  export type ParticipantsMap = Map<string, ProviderParticipant>;
9
8
  export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
10
- export declare const createParticipantFromPayload: (payload: PresencePayload & {
9
+ export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
10
+ timestamp: number;
11
+ } & {
11
12
  userId: string;
12
13
  }, getUser: GetUserType) => Promise<ProviderParticipant>;
@@ -1,6 +1,5 @@
1
- import type { CollabEventPresenceData, CollabEventDisconnectedData } from '@atlaskit/editor-common/collab';
2
1
  import AnalyticsHelper from '../analytics/analytics-helper';
3
- import type { ChannelEvent, CollabEventTelepointerData, PresencePayload, StepJson, TelepointerPayload } from '../types';
2
+ import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
4
3
  import { GetUserType } from './participants-helper';
5
4
  import { ParticipantsState } from './participants-state';
6
5
  /**
@@ -19,9 +18,11 @@ export declare class ParticipantsService {
19
18
  private getUser;
20
19
  private channelBroadcast;
21
20
  private sendPresenceJoined;
21
+ private getPresenceData;
22
+ private setUserId;
22
23
  private participantUpdateTimeout;
23
24
  private presenceUpdateTimeout;
24
- constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabEventTelepointerData | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void);
25
+ constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void, getPresenceData: () => PresenceData, setUserId: (id: string) => void);
25
26
  /**
26
27
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
27
28
  * @param payload Payload from incoming socket event
@@ -1,4 +1,4 @@
1
- import type { AcknowledgementPayload, CollabEventTelepointerData, StepJson } from '../types';
1
+ import type { AcknowledgementPayload, CollabTelepointerPayload, StepJson } from '../types';
2
2
  import { ProviderParticipant } from './participants-helper';
3
- export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabEventTelepointerData | undefined;
3
+ export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabTelepointerPayload | undefined;
4
4
  export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
@@ -1,9 +1,8 @@
1
1
  import type { EditorState, Transaction } from 'prosemirror-state';
2
2
  import type { Step as ProseMirrorStep } from 'prosemirror-transform';
3
3
  import { Emitter } from '../emitter';
4
- import type { ResolvedEditorState } from '@atlaskit/editor-common/collab';
5
- import type { CollabEditProvider, CollabEvents, CollabEventTelepointerData, Config, Metadata } from '../types';
6
- import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
4
+ import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, Config, Metadata, ResolvedEditorState } from '../types';
5
+ import type { SyncUpErrorFunction } from '../types';
7
6
  export declare const MAX_STEP_REJECTED_ERROR = 15;
8
7
  type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
9
8
  export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
@@ -34,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
34
33
  getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
35
34
  constructor(config: Config);
36
35
  private initializeChannel;
36
+ private setUserId;
37
+ private getPresenceData;
37
38
  /**
38
39
  * Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
39
40
  * @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
@@ -73,12 +74,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
73
74
  /**
74
75
  * Send messages, such as telepointers, to NCS and other participants. Only used for telepointer data (text and node selections) in the editor and JWM. JWM does some weird serialisation stuff on the node selections.
75
76
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
76
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
77
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
77
78
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
78
79
  * @param {CollabSendableSelection} data.selection Object representing the selected element
79
80
  * @param {string} data.sessionId Identifier identifying the session
80
81
  */
81
- sendMessage(data: CollabEventTelepointerData): void;
82
+ sendMessage(data: CollabTelepointerPayload): void;
82
83
  private onDisconnected;
83
84
  /**
84
85
  * "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
@@ -1,14 +1,57 @@
1
1
  import type { Step } from 'prosemirror-transform';
2
2
  import type { EditorState, Transaction } from 'prosemirror-state';
3
- import type { CollabEventConnectionData, CollabEventInitData, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, ResolvedEditorState } from '@atlaskit/editor-common/collab';
4
3
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
5
4
  import type { Manager } from 'socket.io-client';
6
5
  import type { DisconnectReason } from './disconnected-reason-mapper';
7
6
  import type { InternalError } from './errors/error-types';
8
7
  import type { ProviderError } from './errors/error-types';
9
- import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
10
8
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
11
9
  import { ProviderParticipant } from './participants/participants-helper';
10
+ import AnalyticsHelper from './analytics/analytics-helper';
11
+ export interface CollabParticipant {
12
+ lastActive: number;
13
+ sessionId: string;
14
+ avatar: string;
15
+ name: string;
16
+ cursorPos?: number;
17
+ }
18
+ export interface CollabEventInitData {
19
+ doc?: any;
20
+ json?: any;
21
+ version?: number;
22
+ sid?: string;
23
+ reserveCursor?: boolean;
24
+ }
25
+ export interface CollabEventRemoteData {
26
+ json?: any;
27
+ newState?: EditorState;
28
+ userIds?: (number | string)[];
29
+ }
30
+ export interface CollabEventConnectionData {
31
+ sid: string;
32
+ initial: boolean;
33
+ }
34
+ export interface CollabEventConnectingData {
35
+ initial: boolean;
36
+ }
37
+ export interface CollabEventDisconnectedData {
38
+ sid: string;
39
+ reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
40
+ }
41
+ export interface CollabEventPresenceData {
42
+ joined?: CollabParticipant[];
43
+ left?: {
44
+ sessionId: string;
45
+ }[];
46
+ }
47
+ export interface CollabEventLocalStepData {
48
+ steps: Array<Step>;
49
+ }
50
+ export type ResolvedEditorState<T = any> = {
51
+ content: JSONDocNode | T;
52
+ title: string | null;
53
+ stepVersion: number;
54
+ };
12
55
  export interface Storage {
13
56
  get(key: string): Promise<string>;
14
57
  set(key: string, value: string): Promise<void>;
@@ -75,10 +118,6 @@ export interface CollabDisconnectedPayload {
75
118
  reason: DisconnectReason;
76
119
  sid: string;
77
120
  }
78
- /**
79
- * @deprecated Use ProviderError type instead
80
- */
81
- export type CollabErrorPayload = ProviderError;
82
121
  export interface CollabInitPayload extends CollabEventInitData {
83
122
  doc: any;
84
123
  version: number;
@@ -105,7 +144,7 @@ export interface CollabEvents {
105
144
  telepointer: CollabTelepointerPayload;
106
145
  presence: CollabPresencePayload;
107
146
  'local-steps': CollabLocalStepsPayload;
108
- error: CollabErrorPayload;
147
+ error: ProviderError;
109
148
  entity: any;
110
149
  connecting: CollabConnectingPayload;
111
150
  }
@@ -129,10 +168,12 @@ export type BroadcastIncomingPayload = {
129
168
  timestamp?: number;
130
169
  data: PresencePayload | TelepointerPayload | StepsPayload | any;
131
170
  };
132
- export type PresencePayload = {
171
+ export type PresenceData = {
133
172
  sessionId: string;
134
173
  userId: string | undefined;
135
174
  clientId: number | string;
175
+ };
176
+ export type PresencePayload = PresenceData & {
136
177
  timestamp: number;
137
178
  };
138
179
  export type TelepointerPayload = PresencePayload & {
@@ -232,6 +273,7 @@ export interface CatchupOptions {
232
273
  applyLocalSteps: (steps: Step[]) => void;
233
274
  updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
234
275
  updateMetadata: (metadata: Metadata | undefined) => void;
276
+ analyticsHelper: AnalyticsHelper | undefined;
235
277
  }
236
278
  export type ProductInformation = {
237
279
  product: string;
@@ -262,4 +304,12 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
262
304
  } & Events[K]): void;
263
305
  getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
264
306
  }
307
+ export type NewCollabSyncUpErrorAttributes = {
308
+ lengthOfUnconfirmedSteps?: number;
309
+ tries: number;
310
+ maxRetries: number;
311
+ clientId?: number | string;
312
+ version: number;
313
+ };
314
+ export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
265
315
  export {};
@@ -41,7 +41,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
41
41
  * @throws {NotConnectedError} Channel not connected
42
42
  */
43
43
  sendMetadata: (metadata: Metadata) => void;
44
- sendPresenceJoined(): void;
44
+ sendPresenceJoined: () => void;
45
45
  onOnlineHandler: () => void;
46
46
  disconnect(): void;
47
47
  }
@@ -1,11 +1,10 @@
1
1
  /// <reference types="lodash" />
2
2
  import AnalyticsHelper from '../analytics/analytics-helper';
3
- import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, StepsPayload } from '../types';
3
+ import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, ResolvedEditorState, StepsPayload } from '../types';
4
4
  import type { Step as ProseMirrorStep } from 'prosemirror-transform';
5
5
  import type { MetadataService } from '../metadata/metadata-service';
6
- import { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
6
+ import { SyncUpErrorFunction } from '../types';
7
7
  import type { EditorState, Transaction } from 'prosemirror-state';
8
- import { ResolvedEditorState } from '@atlaskit/editor-common/collab';
9
8
  import { ParticipantsService } from '../participants/participants-service';
10
9
  import type { InternalError } from '../errors/error-types';
11
10
  export declare class DocumentService {
@@ -10,7 +10,8 @@ export declare enum EVENT_ACTION {
10
10
  ERROR = "error",
11
11
  PUBLISH_PAGE = "publishPage",
12
12
  GET_CURRENT_STATE = "getCurrentState",
13
- INVALIDATE_TOKEN = "invalidateToken"
13
+ INVALIDATE_TOKEN = "invalidateToken",
14
+ DROPPED_STEPS = "droppedStepInCatchup"
14
15
  }
15
16
  export declare enum EVENT_STATUS {
16
17
  SUCCESS = "SUCCESS",
@@ -110,6 +111,13 @@ type CatchUpFailureAnalyticsEvent = {
110
111
  latency?: number;
111
112
  };
112
113
  };
114
+ type CatchUpDroppedStepsEvent = {
115
+ eventAction: EVENT_ACTION.DROPPED_STEPS;
116
+ attributes: {
117
+ documentAri: string;
118
+ numOfDroppedSteps: number;
119
+ };
120
+ };
113
121
  type DocumentInitSuccessAnalyticsEvent = {
114
122
  eventAction: EVENT_ACTION.DOCUMENT_INIT;
115
123
  attributes: {
@@ -177,7 +185,7 @@ type GetCurrentStateFailureAnalyticsEvent = {
177
185
  latency?: number;
178
186
  };
179
187
  };
180
- export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
181
- export declare const ACK_MAX_TRY = 30;
188
+ export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | CatchUpDroppedStepsEvent;
189
+ export declare const ACK_MAX_TRY = 60;
182
190
  export declare const CONFLUENCE = "confluence";
183
191
  export {};
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, Socket, } from './types';
2
+ export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, } from './types';
3
3
  export type { ProviderError } from './errors/error-types';
4
4
  export { PROVIDER_ERROR_CODE } from './errors/error-types';
@@ -1,5 +1,4 @@
1
- import type { CollabParticipant } from '@atlaskit/editor-common/collab';
2
- import type { PresencePayload } from '../types';
1
+ import type { CollabParticipant, PresencePayload } from '../types';
3
2
  export declare const PARTICIPANT_UPDATE_INTERVAL: number;
4
3
  export type ProviderParticipant = CollabParticipant & {
5
4
  userId: string;
@@ -7,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
7
6
  };
8
7
  export type ParticipantsMap = Map<string, ProviderParticipant>;
9
8
  export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
10
- export declare const createParticipantFromPayload: (payload: PresencePayload & {
9
+ export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
10
+ timestamp: number;
11
+ } & {
11
12
  userId: string;
12
13
  }, getUser: GetUserType) => Promise<ProviderParticipant>;
@@ -1,6 +1,5 @@
1
- import type { CollabEventPresenceData, CollabEventDisconnectedData } from '@atlaskit/editor-common/collab';
2
1
  import AnalyticsHelper from '../analytics/analytics-helper';
3
- import type { ChannelEvent, CollabEventTelepointerData, PresencePayload, StepJson, TelepointerPayload } from '../types';
2
+ import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
4
3
  import { GetUserType } from './participants-helper';
5
4
  import { ParticipantsState } from './participants-state';
6
5
  /**
@@ -19,9 +18,11 @@ export declare class ParticipantsService {
19
18
  private getUser;
20
19
  private channelBroadcast;
21
20
  private sendPresenceJoined;
21
+ private getPresenceData;
22
+ private setUserId;
22
23
  private participantUpdateTimeout;
23
24
  private presenceUpdateTimeout;
24
- constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabEventTelepointerData | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void);
25
+ constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void, getPresenceData: () => PresenceData, setUserId: (id: string) => void);
25
26
  /**
26
27
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
27
28
  * @param payload Payload from incoming socket event
@@ -1,4 +1,4 @@
1
- import type { AcknowledgementPayload, CollabEventTelepointerData, StepJson } from '../types';
1
+ import type { AcknowledgementPayload, CollabTelepointerPayload, StepJson } from '../types';
2
2
  import { ProviderParticipant } from './participants-helper';
3
- export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabEventTelepointerData | undefined;
3
+ export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabTelepointerPayload | undefined;
4
4
  export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
@@ -1,9 +1,8 @@
1
1
  import type { EditorState, Transaction } from 'prosemirror-state';
2
2
  import type { Step as ProseMirrorStep } from 'prosemirror-transform';
3
3
  import { Emitter } from '../emitter';
4
- import type { ResolvedEditorState } from '@atlaskit/editor-common/collab';
5
- import type { CollabEditProvider, CollabEvents, CollabEventTelepointerData, Config, Metadata } from '../types';
6
- import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
4
+ import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, Config, Metadata, ResolvedEditorState } from '../types';
5
+ import type { SyncUpErrorFunction } from '../types';
7
6
  export declare const MAX_STEP_REJECTED_ERROR = 15;
8
7
  type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
9
8
  export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
@@ -34,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
34
33
  getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
35
34
  constructor(config: Config);
36
35
  private initializeChannel;
36
+ private setUserId;
37
+ private getPresenceData;
37
38
  /**
38
39
  * Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
39
40
  * @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
@@ -73,12 +74,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
73
74
  /**
74
75
  * Send messages, such as telepointers, to NCS and other participants. Only used for telepointer data (text and node selections) in the editor and JWM. JWM does some weird serialisation stuff on the node selections.
75
76
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
76
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
77
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
77
78
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
78
79
  * @param {CollabSendableSelection} data.selection Object representing the selected element
79
80
  * @param {string} data.sessionId Identifier identifying the session
80
81
  */
81
- sendMessage(data: CollabEventTelepointerData): void;
82
+ sendMessage(data: CollabTelepointerPayload): void;
82
83
  private onDisconnected;
83
84
  /**
84
85
  * "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
@@ -1,14 +1,57 @@
1
1
  import type { Step } from 'prosemirror-transform';
2
2
  import type { EditorState, Transaction } from 'prosemirror-state';
3
- import type { CollabEventConnectionData, CollabEventInitData, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, ResolvedEditorState } from '@atlaskit/editor-common/collab';
4
3
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
5
4
  import type { Manager } from 'socket.io-client';
6
5
  import type { DisconnectReason } from './disconnected-reason-mapper';
7
6
  import type { InternalError } from './errors/error-types';
8
7
  import type { ProviderError } from './errors/error-types';
9
- import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
10
8
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
11
9
  import { ProviderParticipant } from './participants/participants-helper';
10
+ import AnalyticsHelper from './analytics/analytics-helper';
11
+ export interface CollabParticipant {
12
+ lastActive: number;
13
+ sessionId: string;
14
+ avatar: string;
15
+ name: string;
16
+ cursorPos?: number;
17
+ }
18
+ export interface CollabEventInitData {
19
+ doc?: any;
20
+ json?: any;
21
+ version?: number;
22
+ sid?: string;
23
+ reserveCursor?: boolean;
24
+ }
25
+ export interface CollabEventRemoteData {
26
+ json?: any;
27
+ newState?: EditorState;
28
+ userIds?: (number | string)[];
29
+ }
30
+ export interface CollabEventConnectionData {
31
+ sid: string;
32
+ initial: boolean;
33
+ }
34
+ export interface CollabEventConnectingData {
35
+ initial: boolean;
36
+ }
37
+ export interface CollabEventDisconnectedData {
38
+ sid: string;
39
+ reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
40
+ }
41
+ export interface CollabEventPresenceData {
42
+ joined?: CollabParticipant[];
43
+ left?: {
44
+ sessionId: string;
45
+ }[];
46
+ }
47
+ export interface CollabEventLocalStepData {
48
+ steps: Array<Step>;
49
+ }
50
+ export type ResolvedEditorState<T = any> = {
51
+ content: JSONDocNode | T;
52
+ title: string | null;
53
+ stepVersion: number;
54
+ };
12
55
  export interface Storage {
13
56
  get(key: string): Promise<string>;
14
57
  set(key: string, value: string): Promise<void>;
@@ -75,10 +118,6 @@ export interface CollabDisconnectedPayload {
75
118
  reason: DisconnectReason;
76
119
  sid: string;
77
120
  }
78
- /**
79
- * @deprecated Use ProviderError type instead
80
- */
81
- export type CollabErrorPayload = ProviderError;
82
121
  export interface CollabInitPayload extends CollabEventInitData {
83
122
  doc: any;
84
123
  version: number;
@@ -105,7 +144,7 @@ export interface CollabEvents {
105
144
  telepointer: CollabTelepointerPayload;
106
145
  presence: CollabPresencePayload;
107
146
  'local-steps': CollabLocalStepsPayload;
108
- error: CollabErrorPayload;
147
+ error: ProviderError;
109
148
  entity: any;
110
149
  connecting: CollabConnectingPayload;
111
150
  }
@@ -129,10 +168,12 @@ export type BroadcastIncomingPayload = {
129
168
  timestamp?: number;
130
169
  data: PresencePayload | TelepointerPayload | StepsPayload | any;
131
170
  };
132
- export type PresencePayload = {
171
+ export type PresenceData = {
133
172
  sessionId: string;
134
173
  userId: string | undefined;
135
174
  clientId: number | string;
175
+ };
176
+ export type PresencePayload = PresenceData & {
136
177
  timestamp: number;
137
178
  };
138
179
  export type TelepointerPayload = PresencePayload & {
@@ -232,6 +273,7 @@ export interface CatchupOptions {
232
273
  applyLocalSteps: (steps: Step[]) => void;
233
274
  updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
234
275
  updateMetadata: (metadata: Metadata | undefined) => void;
276
+ analyticsHelper: AnalyticsHelper | undefined;
235
277
  }
236
278
  export type ProductInformation = {
237
279
  product: string;
@@ -262,4 +304,12 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
262
304
  } & Events[K]): void;
263
305
  getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
264
306
  }
307
+ export type NewCollabSyncUpErrorAttributes = {
308
+ lengthOfUnconfirmedSteps?: number;
309
+ tries: number;
310
+ maxRetries: number;
311
+ clientId?: number | string;
312
+ version: number;
313
+ };
314
+ export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
265
315
  export {};