@atlaskit/collab-provider 11.3.0 → 11.3.2

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 (29) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/afm-cc/tsconfig.json +2 -2
  3. package/dist/cjs/document/document-service.js +9 -2
  4. package/dist/cjs/version-wrapper.js +1 -1
  5. package/dist/es2019/document/document-service.js +7 -1
  6. package/dist/es2019/version-wrapper.js +1 -1
  7. package/dist/esm/document/document-service.js +9 -2
  8. package/dist/esm/version-wrapper.js +1 -1
  9. package/dist/types/document/document-service.d.ts +5 -5
  10. package/dist/types/document/interface-document-service.d.ts +20 -20
  11. package/dist/types/errors/internal-errors.d.ts +14 -14
  12. package/dist/types/errors/ncs-errors.d.ts +20 -20
  13. package/dist/types/helpers/const.d.ts +58 -58
  14. package/dist/types/helpers/utils.d.ts +4 -4
  15. package/dist/types/participants/participants-service.d.ts +4 -4
  16. package/dist/types/provider/commit-step.d.ts +7 -7
  17. package/dist/types/provider/index.d.ts +1 -1
  18. package/dist/types/types.d.ts +86 -86
  19. package/dist/types-ts4.5/document/document-service.d.ts +5 -5
  20. package/dist/types-ts4.5/document/interface-document-service.d.ts +20 -20
  21. package/dist/types-ts4.5/errors/internal-errors.d.ts +14 -14
  22. package/dist/types-ts4.5/errors/ncs-errors.d.ts +20 -20
  23. package/dist/types-ts4.5/helpers/const.d.ts +58 -58
  24. package/dist/types-ts4.5/helpers/utils.d.ts +4 -4
  25. package/dist/types-ts4.5/participants/participants-service.d.ts +4 -4
  26. package/dist/types-ts4.5/provider/commit-step.d.ts +7 -7
  27. package/dist/types-ts4.5/provider/index.d.ts +1 -1
  28. package/dist/types-ts4.5/types.d.ts +86 -86
  29. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 11.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0fdcb6f2f96fd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0fdcb6f2f96fd) -
8
+ Sorted type and interface props to improve Atlaskit docs
9
+ - Updated dependencies
10
+
11
+ ## 11.3.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`e860af1658f2d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e860af1658f2d) -
16
+ Ensure we are always sending the latest state while step merging
17
+ - Updated dependencies
18
+
3
19
  ## 11.3.0
4
20
 
5
21
  ### Minor Changes
@@ -3,9 +3,9 @@
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
- "composite": true,
7
6
  "outDir": "../../../../../confluence/tsDist/@atlaskit__collab-provider",
8
- "rootDir": "../"
7
+ "rootDir": "../",
8
+ "composite": true
9
9
  },
10
10
  "include": [
11
11
  "../src/**/*.ts",
@@ -1013,11 +1013,18 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
1013
1013
  * @param reason
1014
1014
  * @example
1015
1015
  */
1016
- function send(tr, _oldState, newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
1016
+ function send(tr, _oldState, _newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
1017
1017
  ) {
1018
- var _this3 = this;
1018
+ var _this$getState1,
1019
+ _this$getState10,
1020
+ _this3 = this;
1019
1021
  var offlineEditingEnabled = (0, _experiments.editorExperiment)('platform_editor_offline_editing_web', true);
1020
1022
  var onlineStepMergingEnabled = (0, _expValEquals.expValEquals)('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
1023
+ // We don't trust `_newState` not to be stale
1024
+ // ED-29051 - the `onEditorViewStateUpdated` can have a stale state in edge cases. We need
1025
+ // to always ensure we're sending the latest state and unconfirmed steps so we use the state
1026
+ // from editorView directly (via getState).
1027
+ var newState = onlineStepMergingEnabled ? (_this$getState1 = (_this$getState10 = this.getState) === null || _this$getState10 === void 0 ? void 0 : _this$getState10.call(this)) !== null && _this$getState1 !== void 0 ? _this$getState1 : _newState : _newState;
1021
1028
 
1022
1029
  // Don't send any steps before we're ready.
1023
1030
  if (offlineEditingEnabled || onlineStepMergingEnabled) {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "11.2.4";
8
+ var version = exports.version = "11.3.1";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -880,10 +880,16 @@ export class DocumentService {
880
880
  * @param reason
881
881
  * @example
882
882
  */
883
- send(tr, _oldState, newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
883
+ send(tr, _oldState, _newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
884
884
  ) {
885
+ var _this$getState1, _this$getState10;
885
886
  const offlineEditingEnabled = editorExperiment('platform_editor_offline_editing_web', true);
886
887
  const onlineStepMergingEnabled = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
888
+ // We don't trust `_newState` not to be stale
889
+ // ED-29051 - the `onEditorViewStateUpdated` can have a stale state in edge cases. We need
890
+ // to always ensure we're sending the latest state and unconfirmed steps so we use the state
891
+ // from editorView directly (via getState).
892
+ const newState = onlineStepMergingEnabled ? (_this$getState1 = (_this$getState10 = this.getState) === null || _this$getState10 === void 0 ? void 0 : _this$getState10.call(this)) !== null && _this$getState1 !== void 0 ? _this$getState1 : _newState : _newState;
887
893
 
888
894
  // Don't send any steps before we're ready.
889
895
  if (offlineEditingEnabled || onlineStepMergingEnabled) {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "11.2.4";
2
+ export const version = "11.3.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1006,11 +1006,18 @@ export var DocumentService = /*#__PURE__*/function () {
1006
1006
  * @param reason
1007
1007
  * @example
1008
1008
  */
1009
- function send(tr, _oldState, newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
1009
+ function send(tr, _oldState, _newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
1010
1010
  ) {
1011
- var _this3 = this;
1011
+ var _this$getState1,
1012
+ _this$getState10,
1013
+ _this3 = this;
1012
1014
  var offlineEditingEnabled = editorExperiment('platform_editor_offline_editing_web', true);
1013
1015
  var onlineStepMergingEnabled = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
1016
+ // We don't trust `_newState` not to be stale
1017
+ // ED-29051 - the `onEditorViewStateUpdated` can have a stale state in edge cases. We need
1018
+ // to always ensure we're sending the latest state and unconfirmed steps so we use the state
1019
+ // from editorView directly (via getState).
1020
+ var newState = onlineStepMergingEnabled ? (_this$getState1 = (_this$getState10 = this.getState) === null || _this$getState10 === void 0 ? void 0 : _this$getState10.call(this)) !== null && _this$getState1 !== void 0 ? _this$getState1 : _newState : _newState;
1014
1021
 
1015
1022
  // Don't send any steps before we're ready.
1016
1023
  if (offlineEditingEnabled || onlineStepMergingEnabled) {
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "11.2.4";
2
+ export var version = "11.3.1";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -117,13 +117,13 @@ export declare class DocumentService implements DocumentServiceInterface {
117
117
  to?: number | undefined;
118
118
  };
119
119
  stepMetadata: {
120
- source?: string;
121
- stepId?: string;
122
120
  prevStepId?: string;
123
121
  rebased?: boolean;
124
- traceId?: string;
125
122
  reqId?: string;
126
123
  schemaVersion?: string;
124
+ source?: string;
125
+ stepId?: string;
126
+ traceId?: string;
127
127
  unconfirmedStepAfterRecovery?: boolean;
128
128
  } | undefined;
129
129
  }[];
@@ -155,9 +155,9 @@ export declare class DocumentService implements DocumentServiceInterface {
155
155
  * @example
156
156
  */
157
157
  setup({ getState, onSyncUpError, clientId, }: {
158
+ clientId: number | string | undefined;
158
159
  getState: () => EditorState;
159
160
  onSyncUpError?: SyncUpErrorFunction;
160
- clientId: number | string | undefined;
161
161
  }): this;
162
162
  /**
163
163
  * We can use this function to throttle/delay
@@ -188,5 +188,5 @@ export declare class DocumentService implements DocumentServiceInterface {
188
188
  * @param reason
189
189
  * @example
190
190
  */
191
- send(tr: Transaction | null, _oldState: EditorState | null, newState: EditorState, sendAnalyticsEvent?: boolean, reason?: GetResolvedEditorStateReason): void;
191
+ send(tr: Transaction | null, _oldState: EditorState | null, _newState: EditorState, sendAnalyticsEvent?: boolean, reason?: GetResolvedEditorStateReason): void;
192
192
  }
@@ -4,34 +4,34 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
4
4
  import type { InternalError } from '../errors/internal-errors';
5
5
  import type { GetResolvedEditorStateReason } from '@atlaskit/editor-common/types';
6
6
  export interface DocumentServiceInterface {
7
- setup: (params: {
8
- getState: () => EditorState;
9
- onSyncUpError?: SyncUpErrorFunction;
10
- clientId: number | string | undefined;
11
- }) => this;
12
- updateDocument: (params: {
13
- doc: any;
14
- version: number;
15
- metadata: any;
16
- reserveCursor?: boolean;
17
- }) => void;
7
+ getCurrentPmVersion: () => number;
8
+ getCurrentState: () => Promise<ResolvedEditorState>;
9
+ getFinalAcknowledgedState: (reason: GetResolvedEditorStateReason) => Promise<ResolvedEditorState>;
10
+ getIsNamespaceLocked: () => boolean;
11
+ getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
12
+ onErrorHandled: (error: InternalError) => void;
18
13
  onRestore: (params: {
19
14
  doc: any;
20
- version: number;
21
15
  metadata: any;
16
+ version: number;
22
17
  }) => void;
18
+ onStepRejectedError: () => void;
23
19
  onStepsAdded: (data: {
24
- version: number;
25
20
  steps: any[];
21
+ version: number;
26
22
  }) => void;
27
- onStepRejectedError: () => void;
28
23
  send: (tr: Transaction | null, oldState: EditorState | null, newState: EditorState, sendAnalyticsEvent?: boolean) => void;
29
24
  sendStepsFromCurrentState: (sendAnalyticsEvent?: boolean, reason?: GetResolvedEditorStateReason) => void;
25
+ setup: (params: {
26
+ clientId: number | string | undefined;
27
+ getState: () => EditorState;
28
+ onSyncUpError?: SyncUpErrorFunction;
29
+ }) => this;
30
30
  throttledCatchupv2: () => void;
31
- getCurrentState: () => Promise<ResolvedEditorState>;
32
- getFinalAcknowledgedState: (reason: GetResolvedEditorStateReason) => Promise<ResolvedEditorState>;
33
- getIsNamespaceLocked: () => boolean;
34
- getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
35
- getCurrentPmVersion: () => number;
36
- onErrorHandled: (error: InternalError) => void;
31
+ updateDocument: (params: {
32
+ doc: any;
33
+ metadata: any;
34
+ reserveCursor?: boolean;
35
+ version: number;
36
+ }) => void;
37
37
  }
@@ -13,95 +13,95 @@ export declare enum INTERNAL_ERROR_CODE {
13
13
  OUT_OF_SYNC_CLIENT_DATA_LOSS_EVENT = "OUT_OF_SYNC_CLIENT_DATA_LOSS_EVENT"
14
14
  }
15
15
  type DocumentRecoveryError = {
16
- message: string;
17
16
  data: {
18
17
  code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
19
18
  status: number;
20
19
  };
20
+ message: string;
21
21
  };
22
22
  type AddStepsError = {
23
- message: string;
24
23
  data: {
25
24
  code: INTERNAL_ERROR_CODE.ADD_STEPS_ERROR;
26
25
  status: number;
27
26
  };
27
+ message: string;
28
28
  };
29
29
  type OutOfSyncClientDatalossEvent = {
30
- message: string;
31
30
  data: {
31
+ code: INTERNAL_ERROR_CODE.OUT_OF_SYNC_CLIENT_DATA_LOSS_EVENT;
32
32
  meta: {
33
33
  reason?: string;
34
34
  };
35
- code: INTERNAL_ERROR_CODE.OUT_OF_SYNC_CLIENT_DATA_LOSS_EVENT;
36
35
  };
36
+ message: string;
37
37
  };
38
38
  export type CatchUpFailedError = {
39
- message: string;
40
39
  data: {
41
40
  code: INTERNAL_ERROR_CODE.CATCHUP_FAILED;
42
41
  status: number;
43
42
  };
43
+ message: string;
44
44
  };
45
45
  export type TokenPermissionError = {
46
- message: string;
47
46
  data: {
48
47
  code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR;
49
- status: number;
50
48
  meta: {
51
49
  originalError?: unknown;
52
50
  reason?: string;
53
51
  };
52
+ status: number;
54
53
  };
54
+ message: string;
55
55
  };
56
56
  export type ReconnectionError = {
57
- message: string;
58
57
  data: {
59
58
  code: INTERNAL_ERROR_CODE.RECONNECTION_ERROR;
60
59
  status: number;
61
60
  };
61
+ message: string;
62
62
  };
63
63
  export type ConnectionError = {
64
- message: string;
65
64
  data: {
66
65
  code: INTERNAL_ERROR_CODE.CONNECTION_ERROR;
67
66
  };
67
+ message: string;
68
68
  };
69
69
  export type ReconnectionNetworkError = {
70
- message: string;
71
70
  data: {
72
71
  code: INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE;
73
72
  };
73
+ message: string;
74
74
  };
75
75
  export type DocumentNotFoundError = {
76
- message: string;
77
76
  data: {
78
77
  code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND;
79
78
  status: number;
80
79
  };
80
+ message: string;
81
81
  };
82
82
  /**
83
83
  * When we try to apply state updates to the editor, if that fails to apply the user can enter an invalid state where no
84
84
  * changes can be saved to NCS.
85
85
  */
86
86
  export type InternalDocumentUpdateFailure = {
87
- message: 'The provider failed to apply changes to the editor';
88
87
  data: {
89
88
  code: INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR;
90
89
  meta: {
91
- newVersion?: number;
92
90
  editorVersion?: number;
91
+ newVersion?: number;
93
92
  };
94
93
  status: 500;
95
94
  };
95
+ message: 'The provider failed to apply changes to the editor';
96
96
  };
97
97
  /**
98
98
  * When in view only mode, we should not generate any steps whatsoever.
99
99
  */
100
100
  export type ViewOnlyStepsError = {
101
- message: 'Attempted to send steps in view only mode';
102
101
  data: {
103
102
  code: INTERNAL_ERROR_CODE.VIEW_ONLY_STEPS_ERROR;
104
103
  };
104
+ message: 'Attempted to send steps in view only mode';
105
105
  };
106
106
  /**
107
107
  * A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
@@ -19,7 +19,6 @@ export declare enum NCS_ERROR_CODE {
19
19
  PROSEMIRROR_SCHEMA_VALIDATION_ERROR = "PROSEMIRROR_SCHEMA_VALIDATION_ERROR"
20
20
  }
21
21
  type HeadVersionUpdateFailedError = {
22
- message: string;
23
22
  data: {
24
23
  code: NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED;
25
24
  meta: {
@@ -28,17 +27,17 @@ type HeadVersionUpdateFailedError = {
28
27
  };
29
28
  status: number;
30
29
  };
30
+ message: string;
31
31
  };
32
32
  type VersionAlreadyPresentInDynamoError = {
33
- message: string;
34
33
  data: {
35
34
  code: NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS;
36
35
  meta: string;
37
36
  status: number;
38
37
  };
38
+ message: string;
39
39
  };
40
40
  type InsufficientEditingPermissionError = {
41
- message: string;
42
41
  data: {
43
42
  code: NCS_ERROR_CODE.INSUFFICIENT_EDITING_PERMISSION;
44
43
  meta: {
@@ -47,65 +46,65 @@ type InsufficientEditingPermissionError = {
47
46
  };
48
47
  status: number;
49
48
  };
49
+ message: string;
50
50
  };
51
51
  type ForbiddenUserTokenError = {
52
- message: string;
53
52
  data: {
54
53
  code: NCS_ERROR_CODE.FORBIDDEN_USER_TOKEN;
55
54
  meta: string;
56
55
  status: number;
57
56
  };
57
+ message: string;
58
58
  };
59
59
  type NCSDocumentNotFoundError = {
60
- message: string;
61
60
  data: {
62
61
  code: NCS_ERROR_CODE.DOCUMENT_NOT_FOUND;
63
62
  status: number;
64
63
  };
64
+ message: string;
65
65
  };
66
66
  type FailedToLoadInitDataError = {
67
- message: string;
68
67
  data: {
69
68
  code: NCS_ERROR_CODE.INIT_DATA_LOAD_FAILED;
70
69
  status: number;
71
70
  };
71
+ message: string;
72
72
  };
73
73
  /**
74
74
  * The backend has retrieved the document successfully, as ADF, but failed to convert it to Prosemirror.
75
75
  * This might be because invalid ADF has been written to a document, as it was not validated correctly.
76
76
  */
77
77
  type ProsemirrorSchemaValidationError = {
78
- message: string;
79
78
  data: {
80
79
  code: NCS_ERROR_CODE.PROSEMIRROR_SCHEMA_VALIDATION_ERROR;
81
80
  status: number;
82
81
  };
82
+ message: string;
83
83
  };
84
84
  type ErrorMappingError = {
85
- message: string;
86
85
  data: {
87
86
  code: NCS_ERROR_CODE.ERROR_MAPPING_ERROR;
88
87
  status: number;
89
88
  };
89
+ message: string;
90
90
  };
91
91
  type InvalidNamespaceDefinedError = {
92
- message: string;
93
92
  data: {
94
93
  code: NCS_ERROR_CODE.NAMESPACE_INVALID;
95
94
  meta: string;
96
95
  status: number;
97
96
  };
97
+ message: string;
98
98
  };
99
99
  type SocketNamespaceNotFoundError = {
100
- message: string;
101
100
  data: {
102
101
  code: NCS_ERROR_CODE.NAMESPACE_NOT_FOUND;
103
102
  meta: string;
104
103
  status: number;
105
104
  };
105
+ message: string;
106
106
  };
107
107
  type TenantInstanceMaintenanceError = {
108
- message: string;
109
108
  data: {
110
109
  code: NCS_ERROR_CODE.TENANT_INSTANCE_MAINTENANCE;
111
110
  meta: {
@@ -114,71 +113,72 @@ type TenantInstanceMaintenanceError = {
114
113
  };
115
114
  status: number;
116
115
  };
116
+ message: string;
117
117
  };
118
118
  type NamespaceLockedError = {
119
- message: string;
120
119
  data: {
121
120
  code: NCS_ERROR_CODE.LOCKED_DOCUMENT;
122
121
  meta: string;
123
122
  status: number;
124
123
  };
124
+ message: string;
125
125
  };
126
126
  type EmptyBroadcastError = {
127
- message: string;
128
127
  data: {
129
128
  code: NCS_ERROR_CODE.EMPTY_BROADCAST;
130
129
  meta: string;
131
130
  status: number;
132
131
  };
132
+ message: string;
133
133
  };
134
134
  type DynamoError = {
135
- message: string;
136
135
  data: {
137
136
  code: NCS_ERROR_CODE.DYNAMO_ERROR;
138
137
  meta: string;
139
138
  status: number;
140
139
  };
140
+ message: string;
141
141
  };
142
142
  type InvalidActivationIdError = {
143
- message: string;
144
143
  data: {
145
144
  code: NCS_ERROR_CODE.INVALID_ACTIVATION_ID;
146
145
  meta: string;
147
146
  status: number;
148
147
  };
148
+ message: string;
149
149
  };
150
150
  type InvalidDocumentAriError = {
151
- message: string;
152
151
  data: {
153
152
  code: NCS_ERROR_CODE.INVALID_DOCUMENT_ARI;
154
153
  meta: string;
155
154
  status: number;
156
155
  };
156
+ message: string;
157
157
  };
158
158
  type InvalidCloudIdError = {
159
- message: string;
160
159
  data: {
161
160
  code: NCS_ERROR_CODE.INVALID_CLOUD_ID;
162
161
  meta: string;
163
162
  status: number;
164
163
  };
164
+ message: string;
165
165
  };
166
166
  /**
167
167
  * The client is trying to send too many messages or messages that are too large. This not expected to be a standard
168
168
  * operating condition and should only ever indicate a frontend bug.
169
169
  */
170
170
  export type RateLimitError = {
171
- message: string;
172
171
  data: {
173
172
  code: NCS_ERROR_CODE.RATE_LIMIT_ERROR;
174
173
  meta: {
175
- rateLimitType: number;
176
174
  maxStepSize: number;
177
- stepSizeCounter: number;
175
+ rateLimitType: number;
178
176
  stepCounter: number;
177
+ stepSizeCounter: number;
179
178
  };
180
179
  status: 500;
181
180
  };
181
+ message: string;
182
182
  };
183
183
  export type NCSErrors = HeadVersionUpdateFailedError | VersionAlreadyPresentInDynamoError | InsufficientEditingPermissionError | ForbiddenUserTokenError | NCSDocumentNotFoundError | FailedToLoadInitDataError | ErrorMappingError | InvalidNamespaceDefinedError | SocketNamespaceNotFoundError | TenantInstanceMaintenanceError | NamespaceLockedError | EmptyBroadcastError | DynamoError | InvalidActivationIdError | InvalidDocumentAriError | InvalidCloudIdError | RateLimitError | ProsemirrorSchemaValidationError;
184
184
  export {};