@atlaskit/collab-provider 9.0.0 → 9.1.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 (46) hide show
  1. package/CHANGELOG.md +14 -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 +33 -17
  5. package/dist/cjs/helpers/const.js +5 -1
  6. package/dist/cjs/participants/participants-service.js +11 -5
  7. package/dist/cjs/provider/commit-step.js +22 -1
  8. package/dist/cjs/provider/index.js +20 -7
  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 +23 -8
  14. package/dist/es2019/helpers/const.js +5 -1
  15. package/dist/es2019/participants/participants-service.js +10 -6
  16. package/dist/es2019/provider/commit-step.js +22 -1
  17. package/dist/es2019/provider/index.js +13 -3
  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 +33 -17
  23. package/dist/esm/helpers/const.js +5 -1
  24. package/dist/esm/participants/participants-service.js +11 -5
  25. package/dist/esm/provider/commit-step.js +22 -1
  26. package/dist/esm/provider/index.js +20 -7
  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 +5 -2
  31. package/dist/types/helpers/const.d.ts +30 -4
  32. package/dist/types/participants/participants-helper.d.ts +3 -1
  33. package/dist/types/participants/participants-service.d.ts +4 -2
  34. package/dist/types/provider/commit-step.d.ts +5 -3
  35. package/dist/types/provider/index.d.ts +2 -0
  36. package/dist/types/types.d.ts +15 -1
  37. package/dist/types-ts4.5/channel.d.ts +1 -1
  38. package/dist/types-ts4.5/document/document-service.d.ts +5 -2
  39. package/dist/types-ts4.5/helpers/const.d.ts +30 -4
  40. package/dist/types-ts4.5/participants/participants-helper.d.ts +3 -1
  41. package/dist/types-ts4.5/participants/participants-service.d.ts +4 -2
  42. package/dist/types-ts4.5/provider/commit-step.d.ts +5 -3
  43. package/dist/types-ts4.5/provider/index.d.ts +2 -0
  44. package/dist/types-ts4.5/types.d.ts +15 -1
  45. package/package.json +3 -3
  46. package/report.api.md +9 -0
@@ -10,11 +10,15 @@ 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
+ SEND_STEPS_RETRY = "sendStepsRetry",
15
+ CATCHUP_AFTER_MAX_SEND_STEPS_RETRY = "catchupAfterMaxSendStepsRetry",
16
+ DROPPED_STEPS = "droppedStepInCatchup"
14
17
  }
15
18
  export declare enum EVENT_STATUS {
16
19
  SUCCESS = "SUCCESS",
17
- FAILURE = "FAILURE"
20
+ FAILURE = "FAILURE",
21
+ INFO = "INFO"
18
22
  }
19
23
  export declare enum ADD_STEPS_TYPE {
20
24
  ACCEPTED = "ACCEPTED",
@@ -110,6 +114,13 @@ type CatchUpFailureAnalyticsEvent = {
110
114
  latency?: number;
111
115
  };
112
116
  };
117
+ type CatchUpDroppedStepsEvent = {
118
+ eventAction: EVENT_ACTION.DROPPED_STEPS;
119
+ attributes: {
120
+ documentAri: string;
121
+ numOfDroppedSteps: number;
122
+ };
123
+ };
113
124
  type DocumentInitSuccessAnalyticsEvent = {
114
125
  eventAction: EVENT_ACTION.DOCUMENT_INIT;
115
126
  attributes: {
@@ -177,7 +188,22 @@ type GetCurrentStateFailureAnalyticsEvent = {
177
188
  latency?: number;
178
189
  };
179
190
  };
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;
191
+ type SendStepsRetryAnalyticsEvent = {
192
+ eventAction: EVENT_ACTION.SEND_STEPS_RETRY;
193
+ attributes: {
194
+ documentAri: string;
195
+ eventStatus: EVENT_STATUS.SUCCESS;
196
+ count: number;
197
+ };
198
+ };
199
+ type CatchupAfterMaxSendStepsRetryAnalyticsEvent = {
200
+ eventAction: EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY;
201
+ attributes: {
202
+ documentAri: string;
203
+ eventStatus: EVENT_STATUS.SUCCESS;
204
+ };
205
+ };
206
+ export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent;
207
+ export declare const ACK_MAX_TRY = 60;
182
208
  export declare const CONFLUENCE = "confluence";
183
209
  export {};
@@ -6,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
6
6
  };
7
7
  export type ParticipantsMap = Map<string, ProviderParticipant>;
8
8
  export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
9
- export declare const createParticipantFromPayload: (payload: PresencePayload & {
9
+ export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
10
+ timestamp: number;
11
+ } & {
10
12
  userId: string;
11
13
  }, getUser: GetUserType) => Promise<ProviderParticipant>;
@@ -1,5 +1,5 @@
1
1
  import AnalyticsHelper from '../analytics/analytics-helper';
2
- import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresencePayload, StepJson, TelepointerPayload } from '../types';
2
+ import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
3
3
  import { GetUserType } from './participants-helper';
4
4
  import { ParticipantsState } from './participants-state';
5
5
  /**
@@ -18,9 +18,11 @@ export declare class ParticipantsService {
18
18
  private getUser;
19
19
  private channelBroadcast;
20
20
  private sendPresenceJoined;
21
+ private getPresenceData;
22
+ private setUserId;
21
23
  private participantUpdateTimeout;
22
24
  private presenceUpdateTimeout;
23
- 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);
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);
24
26
  /**
25
27
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
26
28
  * @param payload Payload from incoming socket event
@@ -1,9 +1,9 @@
1
1
  /// <reference types="lodash" />
2
- import { ChannelEvent, StepsPayload } from '../types';
2
+ import { ChannelEvent, CollabCommitStatusEventPayload, CollabEvents, StepsPayload } from '../types';
3
3
  import type { Step as ProseMirrorStep } from 'prosemirror-transform';
4
4
  import AnalyticsHelper from '../analytics/analytics-helper';
5
5
  import type { InternalError } from '../errors/error-types';
6
- export declare const commitStep: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
6
+ export declare const commitStep: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, }: {
7
7
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
8
8
  steps: readonly ProseMirrorStep[];
9
9
  version: number;
@@ -12,8 +12,9 @@ export declare const commitStep: ({ broadcast, steps, version, userId, clientId,
12
12
  onStepsAdded: (data: StepsPayload) => void;
13
13
  onErrorHandled: (error: InternalError) => void;
14
14
  analyticsHelper?: AnalyticsHelper | undefined;
15
+ emit: (evt: keyof CollabEvents, data: CollabCommitStatusEventPayload) => void;
15
16
  }) => void;
16
- export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
17
+ export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, }: {
17
18
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
18
19
  steps: readonly ProseMirrorStep[];
19
20
  version: number;
@@ -22,4 +23,5 @@ export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broa
22
23
  onStepsAdded: (data: StepsPayload) => void;
23
24
  onErrorHandled: (error: InternalError) => void;
24
25
  analyticsHelper?: AnalyticsHelper | undefined;
26
+ emit: (evt: keyof CollabEvents, data: CollabCommitStatusEventPayload) => void;
25
27
  }) => void>;
@@ -33,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
33
33
  getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
34
34
  constructor(config: Config);
35
35
  private initializeChannel;
36
+ private setUserId;
37
+ private getPresenceData;
36
38
  /**
37
39
  * Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
38
40
  * @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
@@ -7,6 +7,7 @@ import type { InternalError } from './errors/error-types';
7
7
  import type { ProviderError } from './errors/error-types';
8
8
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
9
9
  import { ProviderParticipant } from './participants/participants-helper';
10
+ import AnalyticsHelper from './analytics/analytics-helper';
10
11
  export interface CollabParticipant {
11
12
  lastActive: number;
12
13
  sessionId: string;
@@ -89,6 +90,11 @@ export interface Config {
89
90
  */
90
91
  throwOnNotConnected?: boolean;
91
92
  initialDraft?: InitialDraft;
93
+ /**
94
+ * When a page is being published this number can control the number of failed steps until a catchup is triggered.
95
+ * The default value is MAX_STEP_REJECTED_ERROR (15).
96
+ */
97
+ failedStepLimitBeforeCatchupOnPublish?: number;
92
98
  }
93
99
  export interface InitAndAuthData {
94
100
  initialized: boolean;
@@ -134,6 +140,10 @@ export type CollabMetadataPayload = Metadata;
134
140
  export type CollabLocalStepsPayload = {
135
141
  steps: readonly Step[];
136
142
  };
143
+ export type CollabCommitStatusEventPayload = {
144
+ status: 'attempt' | 'success' | 'failure';
145
+ version: number;
146
+ };
137
147
  export interface CollabEvents {
138
148
  'metadata:changed': CollabMetadataPayload;
139
149
  init: CollabInitPayload;
@@ -146,6 +156,7 @@ export interface CollabEvents {
146
156
  error: ProviderError;
147
157
  entity: any;
148
158
  connecting: CollabConnectingPayload;
159
+ 'commit-status': CollabCommitStatusEventPayload;
149
160
  }
150
161
  export interface Metadata {
151
162
  [key: string]: string | number | boolean;
@@ -167,10 +178,12 @@ export type BroadcastIncomingPayload = {
167
178
  timestamp?: number;
168
179
  data: PresencePayload | TelepointerPayload | StepsPayload | any;
169
180
  };
170
- export type PresencePayload = {
181
+ export type PresenceData = {
171
182
  sessionId: string;
172
183
  userId: string | undefined;
173
184
  clientId: number | string;
185
+ };
186
+ export type PresencePayload = PresenceData & {
174
187
  timestamp: number;
175
188
  };
176
189
  export type TelepointerPayload = PresencePayload & {
@@ -270,6 +283,7 @@ export interface CatchupOptions {
270
283
  applyLocalSteps: (steps: Step[]) => void;
271
284
  updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
272
285
  updateMetadata: (metadata: Metadata | undefined) => void;
286
+ analyticsHelper: AnalyticsHelper | undefined;
273
287
  }
274
288
  export type ProductInformation = {
275
289
  product: string;
@@ -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
  }
@@ -16,10 +16,12 @@ export declare class DocumentService {
16
16
  private getUserId;
17
17
  private onErrorHandled;
18
18
  private metadataService;
19
+ private failedStepsBeforeCatchupOnPublish;
19
20
  private getState;
20
21
  private onSyncUpError?;
21
22
  private stepQueue;
22
23
  private stepRejectCounter;
24
+ private aggressiveCatchup;
23
25
  private clientId?;
24
26
  /**
25
27
  *
@@ -28,12 +30,13 @@ export declare class DocumentService {
28
30
  * @param analyticsHelper - Helper for analytics events
29
31
  * @param fetchCatchup - Function to fetch "catchup" data, data required to rebase current steps to the latest version.
30
32
  * @param providerEmitCallback - Callback for emitting events to listeners on the provider
31
- * @param broadcastMetadata - Callback for broadcasting metadata changes to other clients
32
33
  * @param broadcast - Callback for broadcasting events to other clients
33
34
  * @param getUserId - Callback to fetch the current user's ID
34
35
  * @param onErrorHandled - Callback to handle
36
+ * @param metadataService
37
+ * @param failedStepsBeforeCatchupOnPublish - Control MAX_STEP_REJECTED_ERROR during page publishes.
35
38
  */
36
- constructor(participantsService: ParticipantsService, analyticsHelper: AnalyticsHelper | undefined, fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>, providerEmitCallback: (evt: keyof CollabEvents, data: any) => void, broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, getUserId: () => string | undefined, onErrorHandled: (error: InternalError) => void, metadataService: MetadataService);
39
+ constructor(participantsService: ParticipantsService, analyticsHelper: AnalyticsHelper | undefined, fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>, providerEmitCallback: (evt: keyof CollabEvents, data: any) => void, broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, getUserId: () => string | undefined, onErrorHandled: (error: InternalError) => void, metadataService: MetadataService, failedStepsBeforeCatchupOnPublish?: number);
37
40
  /**
38
41
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
39
42
  */
@@ -10,11 +10,15 @@ 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
+ SEND_STEPS_RETRY = "sendStepsRetry",
15
+ CATCHUP_AFTER_MAX_SEND_STEPS_RETRY = "catchupAfterMaxSendStepsRetry",
16
+ DROPPED_STEPS = "droppedStepInCatchup"
14
17
  }
15
18
  export declare enum EVENT_STATUS {
16
19
  SUCCESS = "SUCCESS",
17
- FAILURE = "FAILURE"
20
+ FAILURE = "FAILURE",
21
+ INFO = "INFO"
18
22
  }
19
23
  export declare enum ADD_STEPS_TYPE {
20
24
  ACCEPTED = "ACCEPTED",
@@ -110,6 +114,13 @@ type CatchUpFailureAnalyticsEvent = {
110
114
  latency?: number;
111
115
  };
112
116
  };
117
+ type CatchUpDroppedStepsEvent = {
118
+ eventAction: EVENT_ACTION.DROPPED_STEPS;
119
+ attributes: {
120
+ documentAri: string;
121
+ numOfDroppedSteps: number;
122
+ };
123
+ };
113
124
  type DocumentInitSuccessAnalyticsEvent = {
114
125
  eventAction: EVENT_ACTION.DOCUMENT_INIT;
115
126
  attributes: {
@@ -177,7 +188,22 @@ type GetCurrentStateFailureAnalyticsEvent = {
177
188
  latency?: number;
178
189
  };
179
190
  };
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;
191
+ type SendStepsRetryAnalyticsEvent = {
192
+ eventAction: EVENT_ACTION.SEND_STEPS_RETRY;
193
+ attributes: {
194
+ documentAri: string;
195
+ eventStatus: EVENT_STATUS.SUCCESS;
196
+ count: number;
197
+ };
198
+ };
199
+ type CatchupAfterMaxSendStepsRetryAnalyticsEvent = {
200
+ eventAction: EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY;
201
+ attributes: {
202
+ documentAri: string;
203
+ eventStatus: EVENT_STATUS.SUCCESS;
204
+ };
205
+ };
206
+ export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent;
207
+ export declare const ACK_MAX_TRY = 60;
182
208
  export declare const CONFLUENCE = "confluence";
183
209
  export {};
@@ -6,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
6
6
  };
7
7
  export type ParticipantsMap = Map<string, ProviderParticipant>;
8
8
  export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
9
- export declare const createParticipantFromPayload: (payload: PresencePayload & {
9
+ export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
10
+ timestamp: number;
11
+ } & {
10
12
  userId: string;
11
13
  }, getUser: GetUserType) => Promise<ProviderParticipant>;
@@ -1,5 +1,5 @@
1
1
  import AnalyticsHelper from '../analytics/analytics-helper';
2
- import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresencePayload, StepJson, TelepointerPayload } from '../types';
2
+ import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
3
3
  import { GetUserType } from './participants-helper';
4
4
  import { ParticipantsState } from './participants-state';
5
5
  /**
@@ -18,9 +18,11 @@ export declare class ParticipantsService {
18
18
  private getUser;
19
19
  private channelBroadcast;
20
20
  private sendPresenceJoined;
21
+ private getPresenceData;
22
+ private setUserId;
21
23
  private participantUpdateTimeout;
22
24
  private presenceUpdateTimeout;
23
- 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);
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);
24
26
  /**
25
27
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
26
28
  * @param payload Payload from incoming socket event
@@ -1,9 +1,9 @@
1
1
  /// <reference types="lodash" />
2
- import { ChannelEvent, StepsPayload } from '../types';
2
+ import { ChannelEvent, CollabCommitStatusEventPayload, CollabEvents, StepsPayload } from '../types';
3
3
  import type { Step as ProseMirrorStep } from 'prosemirror-transform';
4
4
  import AnalyticsHelper from '../analytics/analytics-helper';
5
5
  import type { InternalError } from '../errors/error-types';
6
- export declare const commitStep: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
6
+ export declare const commitStep: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, }: {
7
7
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
8
8
  steps: readonly ProseMirrorStep[];
9
9
  version: number;
@@ -12,8 +12,9 @@ export declare const commitStep: ({ broadcast, steps, version, userId, clientId,
12
12
  onStepsAdded: (data: StepsPayload) => void;
13
13
  onErrorHandled: (error: InternalError) => void;
14
14
  analyticsHelper?: AnalyticsHelper | undefined;
15
+ emit: (evt: keyof CollabEvents, data: CollabCommitStatusEventPayload) => void;
15
16
  }) => void;
16
- export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
17
+ export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, }: {
17
18
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
18
19
  steps: readonly ProseMirrorStep[];
19
20
  version: number;
@@ -22,4 +23,5 @@ export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broa
22
23
  onStepsAdded: (data: StepsPayload) => void;
23
24
  onErrorHandled: (error: InternalError) => void;
24
25
  analyticsHelper?: AnalyticsHelper | undefined;
26
+ emit: (evt: keyof CollabEvents, data: CollabCommitStatusEventPayload) => void;
25
27
  }) => void>;
@@ -33,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
33
33
  getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
34
34
  constructor(config: Config);
35
35
  private initializeChannel;
36
+ private setUserId;
37
+ private getPresenceData;
36
38
  /**
37
39
  * Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
38
40
  * @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
@@ -7,6 +7,7 @@ import type { InternalError } from './errors/error-types';
7
7
  import type { ProviderError } from './errors/error-types';
8
8
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
9
9
  import { ProviderParticipant } from './participants/participants-helper';
10
+ import AnalyticsHelper from './analytics/analytics-helper';
10
11
  export interface CollabParticipant {
11
12
  lastActive: number;
12
13
  sessionId: string;
@@ -89,6 +90,11 @@ export interface Config {
89
90
  */
90
91
  throwOnNotConnected?: boolean;
91
92
  initialDraft?: InitialDraft;
93
+ /**
94
+ * When a page is being published this number can control the number of failed steps until a catchup is triggered.
95
+ * The default value is MAX_STEP_REJECTED_ERROR (15).
96
+ */
97
+ failedStepLimitBeforeCatchupOnPublish?: number;
92
98
  }
93
99
  export interface InitAndAuthData {
94
100
  initialized: boolean;
@@ -134,6 +140,10 @@ export type CollabMetadataPayload = Metadata;
134
140
  export type CollabLocalStepsPayload = {
135
141
  steps: readonly Step[];
136
142
  };
143
+ export type CollabCommitStatusEventPayload = {
144
+ status: 'attempt' | 'success' | 'failure';
145
+ version: number;
146
+ };
137
147
  export interface CollabEvents {
138
148
  'metadata:changed': CollabMetadataPayload;
139
149
  init: CollabInitPayload;
@@ -146,6 +156,7 @@ export interface CollabEvents {
146
156
  error: ProviderError;
147
157
  entity: any;
148
158
  connecting: CollabConnectingPayload;
159
+ 'commit-status': CollabCommitStatusEventPayload;
149
160
  }
150
161
  export interface Metadata {
151
162
  [key: string]: string | number | boolean;
@@ -167,10 +178,12 @@ export type BroadcastIncomingPayload = {
167
178
  timestamp?: number;
168
179
  data: PresencePayload | TelepointerPayload | StepsPayload | any;
169
180
  };
170
- export type PresencePayload = {
181
+ export type PresenceData = {
171
182
  sessionId: string;
172
183
  userId: string | undefined;
173
184
  clientId: number | string;
185
+ };
186
+ export type PresencePayload = PresenceData & {
174
187
  timestamp: number;
175
188
  };
176
189
  export type TelepointerPayload = PresencePayload & {
@@ -270,6 +283,7 @@ export interface CatchupOptions {
270
283
  applyLocalSteps: (steps: Step[]) => void;
271
284
  updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
272
285
  updateMetadata: (metadata: Metadata | undefined) => void;
286
+ analyticsHelper: AnalyticsHelper | undefined;
273
287
  }
274
288
  export type ProductInformation = {
275
289
  product: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -61,9 +61,9 @@
61
61
  }
62
62
  },
63
63
  "devDependencies": {
64
- "@atlaskit/adf-schema": "^25.7.0",
64
+ "@atlaskit/adf-schema": "^25.8.0",
65
65
  "@atlaskit/analytics-listeners": "^8.7.0",
66
- "@atlaskit/editor-test-helpers": "^18.4.0",
66
+ "@atlaskit/editor-test-helpers": "^18.5.0",
67
67
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
68
68
  "@types/prosemirror-model": "^1.11.0",
69
69
  "@types/prosemirror-state": "^1.2.0",
package/report.api.md CHANGED
@@ -31,6 +31,12 @@ type BaseEvents = Pick<
31
31
  'send' | 'sendMessage' | 'setup'
32
32
  >;
33
33
 
34
+ // @public (undocumented)
35
+ type CollabCommitStatusEventPayload = {
36
+ status: 'attempt' | 'failure' | 'success';
37
+ version: number;
38
+ };
39
+
34
40
  // @public (undocumented)
35
41
  export type CollabConnectedPayload = CollabEventConnectionData;
36
42
 
@@ -154,6 +160,8 @@ export interface CollabEventRemoteData {
154
160
 
155
161
  // @public (undocumented)
156
162
  export interface CollabEvents {
163
+ // (undocumented)
164
+ 'commit-status': CollabCommitStatusEventPayload;
157
165
  // (undocumented)
158
166
  'local-steps': CollabLocalStepsPayload;
159
167
  // (undocumented)
@@ -251,6 +259,7 @@ interface Config {
251
259
  ) => Socket;
252
260
  // (undocumented)
253
261
  documentAri: string;
262
+ failedStepLimitBeforeCatchupOnPublish?: number;
254
263
  // (undocumented)
255
264
  featureFlags?: {
256
265
  [key: string]: boolean;