@atlaskit/collab-provider 10.3.4 → 10.4.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 (51) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/afm-cc/tsconfig.json +6 -0
  3. package/afm-jira/tsconfig.json +6 -0
  4. package/dist/cjs/analytics/analytics-helper.js +0 -2
  5. package/dist/cjs/api/api.js +26 -14
  6. package/dist/cjs/channel.js +0 -2
  7. package/dist/cjs/document/catchupv2.js +24 -10
  8. package/dist/cjs/document/document-service.js +35 -33
  9. package/dist/cjs/helpers/const.js +2 -1
  10. package/dist/cjs/helpers/utils.js +216 -2
  11. package/dist/cjs/participants/participants-service.js +0 -2
  12. package/dist/cjs/provider/commit-step.js +12 -1
  13. package/dist/cjs/provider/index.js +69 -33
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/es2019/analytics/analytics-helper.js +0 -2
  16. package/dist/es2019/api/api.js +13 -1
  17. package/dist/es2019/channel.js +0 -2
  18. package/dist/es2019/document/catchupv2.js +20 -6
  19. package/dist/es2019/document/document-service.js +8 -6
  20. package/dist/es2019/helpers/const.js +2 -1
  21. package/dist/es2019/helpers/utils.js +159 -1
  22. package/dist/es2019/participants/participants-service.js +0 -2
  23. package/dist/es2019/provider/commit-step.js +13 -1
  24. package/dist/es2019/provider/index.js +40 -17
  25. package/dist/es2019/version-wrapper.js +1 -1
  26. package/dist/esm/analytics/analytics-helper.js +0 -2
  27. package/dist/esm/api/api.js +26 -14
  28. package/dist/esm/channel.js +0 -2
  29. package/dist/esm/document/catchupv2.js +25 -11
  30. package/dist/esm/document/document-service.js +35 -33
  31. package/dist/esm/helpers/const.js +2 -1
  32. package/dist/esm/helpers/utils.js +212 -1
  33. package/dist/esm/participants/participants-service.js +0 -2
  34. package/dist/esm/provider/commit-step.js +12 -1
  35. package/dist/esm/provider/index.js +71 -35
  36. package/dist/esm/version-wrapper.js +1 -1
  37. package/dist/types/document/document-service.d.ts +1 -0
  38. package/dist/types/errors/custom-errors.d.ts +1 -1
  39. package/dist/types/helpers/const.d.ts +16 -2
  40. package/dist/types/helpers/utils.d.ts +49 -0
  41. package/dist/types/index.d.ts +1 -1
  42. package/dist/types/provider/commit-step.d.ts +2 -1
  43. package/dist/types/types.d.ts +3 -2
  44. package/dist/types-ts4.5/document/document-service.d.ts +1 -0
  45. package/dist/types-ts4.5/errors/custom-errors.d.ts +1 -1
  46. package/dist/types-ts4.5/helpers/const.d.ts +16 -2
  47. package/dist/types-ts4.5/helpers/utils.d.ts +49 -0
  48. package/dist/types-ts4.5/index.d.ts +1 -1
  49. package/dist/types-ts4.5/provider/commit-step.d.ts +2 -1
  50. package/dist/types-ts4.5/types.d.ts +3 -2
  51. package/package.json +16 -2
@@ -19,7 +19,8 @@ export declare enum EVENT_ACTION {
19
19
  PROVIDER_INITIALIZED = "providerInitialized",// https://data-portal.internal.atlassian.com/analytics/registry/54714
20
20
  RECONNECTION = "providerReconnection",// https://data-portal.internal.atlassian.com/analytics/registry/73992
21
21
  PROVIDER_SETUP = "providerSetup",// https://data-portal.internal.atlassian.com/analytics/registry/54715
22
- HAS_UNCONFIRMED_STEPS = "hasUnconfirmedSteps"
22
+ HAS_UNCONFIRMED_STEPS = "hasUnconfirmedSteps",// https://data-portal.internal.atlassian.com/analytics/registry/56141
23
+ OUT_OF_SYNC = "outOfSync"
23
24
  }
24
25
  export declare enum EVENT_STATUS {
25
26
  SUCCESS = "SUCCESS",
@@ -261,7 +262,20 @@ type ReconnectionAnalyticsEvent = {
261
262
  disconnectionPeriodSeconds: number;
262
263
  } & BaseActionAnalyticsEventAttributes;
263
264
  };
264
- export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent | WebsocketMessageVolumeMetricEvent | ProviderInitializedAnalyticsEvent | ProviderSetupAnalyticsEvent | ProviderHasUnconfirmedStepsAnalyticsEvent | UpdateDocumentAnalyticsEvent | ReconnectionAnalyticsEvent;
265
+ type OutOfSyncAnalyticsEvent = {
266
+ eventAction: EVENT_ACTION.OUT_OF_SYNC;
267
+ attributes: {
268
+ eventStatus: EVENT_STATUS.FAILURE;
269
+ obfuscatedSteps: {
270
+ [key: string]: number;
271
+ }[];
272
+ obfuscatedDoc: {
273
+ [key: string]: number;
274
+ };
275
+ catchupReason: CatchupEventReason | undefined;
276
+ } & BaseActionAnalyticsEventAttributes;
277
+ };
278
+ export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent | WebsocketMessageVolumeMetricEvent | ProviderInitializedAnalyticsEvent | ProviderSetupAnalyticsEvent | ProviderHasUnconfirmedStepsAnalyticsEvent | UpdateDocumentAnalyticsEvent | ReconnectionAnalyticsEvent | OutOfSyncAnalyticsEvent;
265
279
  export declare const ACK_MAX_TRY = 60;
266
280
  export declare const CONFLUENCE = "confluence";
267
281
  /** Enumerable for attaching a reason to catchup (v2) call(s) */
@@ -1,5 +1,10 @@
1
+ import { type ADFEntity } from '@atlaskit/adf-utils/types';
1
2
  import type { ProductInformation } from '../types';
2
3
  import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
4
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
+ import type { StepJson } from '@atlaskit/editor-common/collab';
6
+ import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
7
+ import { CustomError } from '../errors/custom-errors';
3
8
  export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
4
9
  export declare function sleep(ms: number): Promise<unknown>;
5
10
  export declare const isAIProviderID: (id: string) => boolean;
@@ -11,3 +16,47 @@ export type UGCFreeStepDetails = {
11
16
  stepSizeInBytes?: number;
12
17
  };
13
18
  export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
19
+ export declare const getStepTypes: (stepJson: StepJson) => {
20
+ type: string;
21
+ contentTypes: string | null;
22
+ };
23
+ export declare const getStepsAdfWithObfuscation: (stepJson: StepJson) => ADFEntity[] | null;
24
+ export declare const getDocAdfWithObfuscation: (doc: ProseMirrorNode) => ADFEntity | null;
25
+ export declare const getStepPositions: (stepJson: StepJson) => {
26
+ pos?: number | undefined;
27
+ insert?: number | undefined;
28
+ gapFrom?: number | undefined;
29
+ gapTo?: number | undefined;
30
+ from?: number | undefined;
31
+ to?: number | undefined;
32
+ };
33
+ export declare const getObfuscatedSteps: (steps: StepJson[], endIndex?: number | undefined) => {
34
+ stepType: {
35
+ type: string;
36
+ contentTypes: string | null;
37
+ };
38
+ stepContent: ADFEntity[] | null;
39
+ stepPositions: {
40
+ pos?: number | undefined;
41
+ insert?: number | undefined;
42
+ gapFrom?: number | undefined;
43
+ gapTo?: number | undefined;
44
+ from?: number | undefined;
45
+ to?: number | undefined;
46
+ };
47
+ stepMetadata: {
48
+ source?: string | undefined;
49
+ stepId?: string | undefined;
50
+ prevStepId?: string | undefined;
51
+ rebased?: boolean | undefined;
52
+ traceId?: string | undefined;
53
+ reqId?: string | undefined;
54
+ schemaVersion?: string | undefined;
55
+ unconfirmedStepAfterRecovery?: boolean | undefined;
56
+ } | undefined;
57
+ }[];
58
+ export declare function logObfuscatedSteps(oldState: EditorState | null, newState: EditorState): Promise<CustomError | {
59
+ stepsFromOldState: string;
60
+ stepsFromNewState: string;
61
+ }>;
62
+ export declare function toObfuscatedSteps(steps: readonly ProseMirrorStep[]): Promise<string>;
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
2
  export type { CollabEventDisconnectedData, Socket } from './types';
3
- export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabActivityData, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabPermissionEventPayload, CollabEventRemoteData, CollabEventPresenceData, CollabActivityJoinPayload, CollabActivityAckPayload, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, CollabEventLocalStepData, UserPermitType, } from '@atlaskit/editor-common/collab';
3
+ export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabActivityData, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabPermissionEventPayload, CollabEventRemoteData, CollabEventPresenceData, CollabActivityJoinPayload, CollabActivityAckPayload, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, CollabEventLocalStepData, UserPermitType, CollabNamespaceLockCheckPayload, } from '@atlaskit/editor-common/collab';
4
4
  export { PROVIDER_ERROR_CODE } from '@atlaskit/editor-common/collab';
@@ -5,7 +5,7 @@ import type AnalyticsHelper from '../analytics/analytics-helper';
5
5
  import type { InternalError } from '../errors/internal-errors';
6
6
  export declare let readyToCommit: boolean;
7
7
  export declare const RESET_READYTOCOMMIT_INTERVAL_MS = 5000;
8
- export declare const commitStepQueue: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, __livePage, }: {
8
+ export declare const commitStepQueue: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, __livePage, hasRecovered, }: {
9
9
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void;
10
10
  steps: readonly ProseMirrorStep[];
11
11
  version: number;
@@ -16,4 +16,5 @@ export declare const commitStepQueue: ({ broadcast, steps, version, userId, clie
16
16
  analyticsHelper?: AnalyticsHelper | undefined;
17
17
  emit: (evt: keyof CollabEvents, data: CollabCommitStatusEventPayload) => void;
18
18
  __livePage: boolean;
19
+ hasRecovered: boolean;
19
20
  }) => void;
@@ -1,4 +1,3 @@
1
- import type { Step } from '@atlaskit/editor-prosemirror/transform';
2
1
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
3
2
  import type { Manager, Socket as SocketIOSocket } from 'socket.io-client';
4
3
  import type { InternalError } from './errors/internal-errors';
@@ -7,6 +6,7 @@ import type { GetUserType } from './participants/participants-helper';
7
6
  import type AnalyticsHelper from './analytics/analytics-helper';
8
7
  import type { StepJson, CollabSendableSelection, Metadata, UserPermitType, Activity, PresenceActivity } from '@atlaskit/editor-common/collab';
9
8
  import { type CatchupEventReason } from './helpers/const';
9
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
10
10
  export interface CollabEventDisconnectedData {
11
11
  sid: string;
12
12
  reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
@@ -199,7 +199,7 @@ export type ChannelEvent = {
199
199
  status: NamespaceStatus;
200
200
  };
201
201
  export interface Catchupv2Response {
202
- steps?: Step[];
202
+ steps?: StepJson[];
203
203
  metadata?: Metadata;
204
204
  }
205
205
  export interface ReconcileResponse {
@@ -218,6 +218,7 @@ export interface Catchupv2Options {
218
218
  catchUpOutofSync: boolean;
219
219
  reason?: CatchupEventReason;
220
220
  onCatchupComplete?: (steps: StepJson[]) => void;
221
+ getState: (() => EditorState) | undefined;
221
222
  }
222
223
  export type ReconnectionMetadata = {
223
224
  unconfirmedStepsLength: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "10.3.4",
3
+ "version": "10.4.1",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,14 +32,16 @@
32
32
  "./version-wrapper": "./src/version-wrapper.ts"
33
33
  },
34
34
  "dependencies": {
35
+ "@atlaskit/adf-utils": "^19.17.0",
35
36
  "@atlaskit/analytics-gas-types": "^5.1.0",
36
37
  "@atlaskit/analytics-listeners": "^8.13.0",
37
- "@atlaskit/editor-common": "^99.0.0",
38
+ "@atlaskit/editor-common": "^99.5.0",
38
39
  "@atlaskit/editor-json-transformer": "^8.21.0",
39
40
  "@atlaskit/editor-prosemirror": "6.2.1",
40
41
  "@atlaskit/feature-gate-js-client": "^4.22.0",
41
42
  "@atlaskit/platform-feature-flags": "^0.3.0",
42
43
  "@atlaskit/prosemirror-collab": "^0.11.0",
44
+ "@atlaskit/react-ufo": "^2.12.0",
43
45
  "@atlaskit/ufo": "^0.3.0",
44
46
  "@atlaskit/util-service-support": "^6.2.0",
45
47
  "@babel/runtime": "^7.0.0",
@@ -71,11 +73,23 @@
71
73
  "platform.editor.live-pages-expand-divergence": {
72
74
  "type": "boolean"
73
75
  },
76
+ "platform_editor_log_obfuscated_steps": {
77
+ "type": "boolean"
78
+ },
74
79
  "platform_editor_merge_unconfirmed_steps": {
75
80
  "type": "boolean"
76
81
  },
77
82
  "restore_localstep_fallback_reconcile": {
78
83
  "type": "boolean"
84
+ },
85
+ "tag_unconfirmed_steps_after_recovery": {
86
+ "type": "boolean"
87
+ },
88
+ "platform_collab_provider_tracingheaders": {
89
+ "type": "boolean"
90
+ },
91
+ "log_obfuscated_steps_for_view_only": {
92
+ "type": "boolean"
79
93
  }
80
94
  }
81
95
  }