@atlaskit/collab-provider 8.4.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/dist/cjs/analytics/analytics-helper.js +135 -0
- package/dist/cjs/analytics/performance.js +6 -5
- package/dist/cjs/channel.js +242 -223
- package/dist/cjs/document/catchup.js +142 -0
- package/dist/cjs/document/document-service.js +587 -0
- package/dist/cjs/document/step-queue-state.js +56 -0
- package/dist/cjs/errors/error-code-mapper.js +86 -67
- package/dist/cjs/errors/error-types.js +329 -21
- package/dist/cjs/helpers/utils.js +1 -12
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/metadata/metadata-service.js +82 -0
- package/dist/cjs/participants/participants-helper.js +52 -0
- package/dist/cjs/participants/participants-service.js +259 -0
- package/dist/cjs/participants/participants-state.js +56 -0
- package/dist/cjs/{provider/telepointers.js → participants/telepointers-helper.js} +6 -6
- package/dist/cjs/provider/commit-step.js +14 -6
- package/dist/cjs/provider/index.js +291 -780
- package/dist/cjs/types.js +6 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/{index.js → analytics-helper.js} +15 -4
- package/dist/es2019/analytics/performance.js +5 -6
- package/dist/es2019/channel.js +140 -113
- package/dist/es2019/{provider → document}/catchup.js +6 -4
- package/dist/es2019/document/document-service.js +472 -0
- package/dist/es2019/document/step-queue-state.js +35 -0
- package/dist/es2019/errors/error-code-mapper.js +87 -63
- package/dist/es2019/errors/error-types.js +221 -5
- package/dist/es2019/helpers/utils.js +0 -10
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/metadata/metadata-service.js +61 -0
- package/dist/es2019/participants/participants-helper.js +25 -0
- package/dist/es2019/participants/participants-service.js +207 -0
- package/dist/es2019/participants/participants-state.js +30 -0
- package/dist/es2019/{provider/telepointers.js → participants/telepointers-helper.js} +2 -2
- package/dist/es2019/provider/commit-step.js +12 -5
- package/dist/es2019/provider/index.js +240 -640
- package/dist/es2019/types.js +8 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/analytics-helper.js +128 -0
- package/dist/esm/analytics/performance.js +5 -6
- package/dist/esm/channel.js +243 -224
- package/dist/esm/document/catchup.js +133 -0
- package/dist/esm/document/document-service.js +579 -0
- package/dist/esm/document/step-queue-state.js +48 -0
- package/dist/esm/errors/error-code-mapper.js +87 -64
- package/dist/esm/errors/error-types.js +321 -18
- package/dist/esm/helpers/utils.js +0 -10
- package/dist/esm/index.js +2 -1
- package/dist/esm/metadata/metadata-service.js +74 -0
- package/dist/esm/participants/participants-helper.js +44 -0
- package/dist/esm/participants/participants-service.js +251 -0
- package/dist/esm/participants/participants-state.js +48 -0
- package/dist/esm/{provider/telepointers.js → participants/telepointers-helper.js} +4 -4
- package/dist/esm/provider/commit-step.js +12 -5
- package/dist/esm/provider/index.js +291 -779
- package/dist/esm/types.js +8 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/{index.d.ts → analytics-helper.d.ts} +3 -1
- package/dist/types/analytics/performance.d.ts +3 -1
- package/dist/types/analytics/ufo.d.ts +1 -1
- package/dist/types/channel.d.ts +13 -6
- package/dist/types/document/document-service.d.ts +86 -0
- package/dist/types/document/step-queue-state.d.ts +16 -0
- package/dist/types/errors/error-code-mapper.d.ts +2 -36
- package/dist/types/errors/error-types.d.ts +439 -4
- package/dist/types/helpers/const.d.ts +2 -2
- package/dist/types/helpers/utils.d.ts +0 -6
- package/dist/types/index.d.ts +3 -1
- package/dist/types/metadata/metadata-service.d.ts +25 -0
- package/dist/types/participants/participants-helper.d.ts +15 -0
- package/dist/types/participants/participants-service.d.ts +74 -0
- package/dist/types/participants/participants-state.d.ts +13 -0
- package/dist/types/participants/telepointers-helper.d.ts +4 -0
- package/dist/types/provider/commit-step.d.ts +17 -6
- package/dist/types/provider/index.d.ts +81 -78
- package/dist/types/types.d.ts +56 -31
- package/package.json +6 -6
- package/report.api.md +187 -21
- package/dist/cjs/analytics/index.js +0 -95
- package/dist/cjs/provider/catchup.js +0 -139
- package/dist/esm/analytics/index.js +0 -88
- package/dist/esm/provider/catchup.js +0 -130
- package/dist/types/provider/telepointers.d.ts +0 -5
- /package/dist/types/{provider → document}/catchup.d.ts +0 -0
|
@@ -1,8 +1,443 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare enum INTERNAL_ERROR_CODE {
|
|
2
|
+
TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
|
|
3
|
+
RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
|
|
4
|
+
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
5
|
+
RECONNECTION_ERROR = "RECONNECTION_ERROR",
|
|
6
|
+
DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
|
|
7
|
+
CATCHUP_FAILED = "CATCHUP_FAILED",
|
|
8
|
+
DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
|
|
9
|
+
ADD_STEPS_ERROR = "ADD_STEPS_ERROR"
|
|
10
|
+
}
|
|
11
|
+
export declare enum NCS_ERROR_CODE {
|
|
12
|
+
HEAD_VERSION_UPDATE_FAILED = "HEAD_VERSION_UPDATE_FAILED",
|
|
13
|
+
VERSION_NUMBER_ALREADY_EXISTS = "VERSION_NUMBER_ALREADY_EXISTS",
|
|
14
|
+
INSUFFICIENT_EDITING_PERMISSION = "INSUFFICIENT_EDITING_PERMISSION",
|
|
15
|
+
FORBIDDEN_USER_TOKEN = "FORBIDDEN_USER_TOKEN",
|
|
16
|
+
DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
|
|
17
|
+
INIT_DATA_LOAD_FAILED = "INIT_DATA_LOAD_FAILED",
|
|
18
|
+
ERROR_MAPPING_ERROR = "ERROR_MAPPING_ERROR",
|
|
19
|
+
NAMESPACE_INVALID = "NAMESPACE_INVALID",
|
|
20
|
+
NAMESPACE_NOT_FOUND = "NAMESPACE_NOT_FOUND",
|
|
21
|
+
TENANT_INSTANCE_MAINTENANCE = "TENANT_INSTANCE_MAINTENANCE",
|
|
22
|
+
LOCKED_DOCUMENT = "LOCKED_DOCUMENT",
|
|
23
|
+
EMPTY_BROADCAST = "EMPTY_BROADCAST",
|
|
24
|
+
DYNAMO_ERROR = "DYNAMO_ERROR",
|
|
25
|
+
INVALID_ACTIVATION_ID = "INVALID_ACTIVATION_ID",
|
|
26
|
+
INVALID_DOCUMENT_ARI = "INVALID_DOCUMENT_ARI",
|
|
27
|
+
INVALID_CLOUD_ID = "INVALID_CLOUD_ID"
|
|
28
|
+
}
|
|
29
|
+
declare type HeadVersionUpdateFailedError = {
|
|
30
|
+
message: string;
|
|
31
|
+
data: {
|
|
32
|
+
code: NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED;
|
|
33
|
+
meta: {
|
|
34
|
+
currentVersion: any;
|
|
35
|
+
incomingVersion: number;
|
|
36
|
+
};
|
|
37
|
+
status: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
declare type VersionAlreadyPresentInDynamoError = {
|
|
41
|
+
message: string;
|
|
42
|
+
data: {
|
|
43
|
+
code: NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS;
|
|
44
|
+
meta: string;
|
|
45
|
+
status: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
declare type InsufficientEditingPermissionError = {
|
|
49
|
+
message: string;
|
|
50
|
+
data: {
|
|
51
|
+
code: NCS_ERROR_CODE.INSUFFICIENT_EDITING_PERMISSION;
|
|
52
|
+
meta: {
|
|
53
|
+
description: string;
|
|
54
|
+
reason?: string;
|
|
55
|
+
};
|
|
56
|
+
status: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
declare type ForbiddenUserTokenError = {
|
|
60
|
+
message: string;
|
|
61
|
+
data: {
|
|
62
|
+
code: NCS_ERROR_CODE.FORBIDDEN_USER_TOKEN;
|
|
63
|
+
meta: string;
|
|
64
|
+
status: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
declare type NCSDocumentNotFoundError = {
|
|
68
|
+
message: string;
|
|
69
|
+
data: {
|
|
70
|
+
code: NCS_ERROR_CODE.DOCUMENT_NOT_FOUND;
|
|
71
|
+
status: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
declare type FailedToLoadInitDataError = {
|
|
75
|
+
message: string;
|
|
76
|
+
data: {
|
|
77
|
+
code: NCS_ERROR_CODE.INIT_DATA_LOAD_FAILED;
|
|
78
|
+
status: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
declare type ErrorMappingError = {
|
|
82
|
+
message: string;
|
|
83
|
+
data: {
|
|
84
|
+
code: NCS_ERROR_CODE.ERROR_MAPPING_ERROR;
|
|
85
|
+
status: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
declare type InvalidNamespaceDefinedError = {
|
|
89
|
+
message: string;
|
|
90
|
+
data: {
|
|
91
|
+
code: NCS_ERROR_CODE.NAMESPACE_INVALID;
|
|
92
|
+
meta: string;
|
|
93
|
+
status: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
declare type SocketNamespaceNotFoundError = {
|
|
97
|
+
message: string;
|
|
98
|
+
data: {
|
|
99
|
+
code: NCS_ERROR_CODE.NAMESPACE_NOT_FOUND;
|
|
100
|
+
meta: string;
|
|
101
|
+
status: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
declare type TenantInstanceMaintenanceError = {
|
|
105
|
+
message: string;
|
|
106
|
+
data: {
|
|
107
|
+
code: NCS_ERROR_CODE.TENANT_INSTANCE_MAINTENANCE;
|
|
108
|
+
meta: {
|
|
109
|
+
description: string;
|
|
110
|
+
reason: string;
|
|
111
|
+
};
|
|
112
|
+
status: number;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
declare type NamespaceLockedError = {
|
|
116
|
+
message: string;
|
|
117
|
+
data: {
|
|
118
|
+
code: NCS_ERROR_CODE.LOCKED_DOCUMENT;
|
|
119
|
+
meta: string;
|
|
120
|
+
status: number;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
declare type EmptyBroadcastError = {
|
|
124
|
+
message: string;
|
|
125
|
+
data: {
|
|
126
|
+
code: NCS_ERROR_CODE.EMPTY_BROADCAST;
|
|
127
|
+
meta: string;
|
|
128
|
+
status: number;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
declare type DynamoError = {
|
|
132
|
+
message: string;
|
|
133
|
+
data: {
|
|
134
|
+
code: NCS_ERROR_CODE.DYNAMO_ERROR;
|
|
135
|
+
meta: string;
|
|
136
|
+
status: number;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
declare type InvalidActivationIdError = {
|
|
140
|
+
message: string;
|
|
141
|
+
data: {
|
|
142
|
+
code: NCS_ERROR_CODE.INVALID_ACTIVATION_ID;
|
|
143
|
+
meta: string;
|
|
144
|
+
status: number;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
declare type InvalidDocumentAriError = {
|
|
148
|
+
message: string;
|
|
149
|
+
data: {
|
|
150
|
+
code: NCS_ERROR_CODE.INVALID_DOCUMENT_ARI;
|
|
151
|
+
meta: string;
|
|
152
|
+
status: number;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
declare type InvalidCloudIdError = {
|
|
156
|
+
message: string;
|
|
157
|
+
data: {
|
|
158
|
+
code: NCS_ERROR_CODE.INVALID_CLOUD_ID;
|
|
159
|
+
meta: string;
|
|
160
|
+
status: number;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
declare type NCSErrors = HeadVersionUpdateFailedError | VersionAlreadyPresentInDynamoError | InsufficientEditingPermissionError | ForbiddenUserTokenError | NCSDocumentNotFoundError | FailedToLoadInitDataError | ErrorMappingError | InvalidNamespaceDefinedError | SocketNamespaceNotFoundError | TenantInstanceMaintenanceError | NamespaceLockedError | EmptyBroadcastError | DynamoError | InvalidActivationIdError | InvalidDocumentAriError | InvalidCloudIdError;
|
|
164
|
+
declare type DocumentRecoveryError = {
|
|
165
|
+
message: string;
|
|
166
|
+
data: {
|
|
167
|
+
code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
|
|
168
|
+
status: number;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
declare type AddStepsError = {
|
|
172
|
+
message: string;
|
|
173
|
+
data: {
|
|
174
|
+
code: INTERNAL_ERROR_CODE.ADD_STEPS_ERROR;
|
|
175
|
+
status: number;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export declare type CatchUpFailedError = {
|
|
179
|
+
message: string;
|
|
180
|
+
data: {
|
|
181
|
+
code: INTERNAL_ERROR_CODE.CATCHUP_FAILED;
|
|
182
|
+
status: number;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
export declare type TokenPermissionError = {
|
|
186
|
+
message: string;
|
|
187
|
+
data: {
|
|
188
|
+
code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR;
|
|
189
|
+
status: number;
|
|
190
|
+
meta: {
|
|
191
|
+
originalError?: unknown;
|
|
192
|
+
reason?: string;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
export declare type ReconnectionError = {
|
|
197
|
+
message: string;
|
|
198
|
+
data: {
|
|
199
|
+
code: INTERNAL_ERROR_CODE.RECONNECTION_ERROR;
|
|
200
|
+
status: number;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
export declare type ConnectionError = {
|
|
204
|
+
message: string;
|
|
205
|
+
data: {
|
|
206
|
+
code: INTERNAL_ERROR_CODE.CONNECTION_ERROR;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
export declare type ReconnectionNetworkError = {
|
|
210
|
+
message: string;
|
|
211
|
+
data: {
|
|
212
|
+
code: INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export declare type DocumentNotFoundError = {
|
|
216
|
+
message: string;
|
|
217
|
+
data: {
|
|
218
|
+
code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND;
|
|
219
|
+
status: number;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
|
|
224
|
+
*/
|
|
225
|
+
export declare type InternalError = NCSErrors | DocumentRecoveryError | AddStepsError | CatchUpFailedError | TokenPermissionError | ReconnectionError | ConnectionError | ReconnectionNetworkError | DocumentNotFoundError;
|
|
226
|
+
export declare enum PROVIDER_ERROR_CODE {
|
|
227
|
+
NO_PERMISSION_ERROR = "NO_PERMISSION_ERROR",
|
|
228
|
+
INVALID_USER_TOKEN = "INVALID_USER_TOKEN",
|
|
229
|
+
DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
|
|
230
|
+
LOCKED = "LOCKED",
|
|
231
|
+
FAIL_TO_SAVE = "FAIL_TO_SAVE",
|
|
232
|
+
DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
|
|
233
|
+
INITIALISATION_ERROR = "INITIALISATION_ERROR",
|
|
234
|
+
NETWORK_ISSUE = "NETWORK_ISSUE",
|
|
235
|
+
INVALID_PROVIDER_CONFIGURATION = "INVALID_PROVIDER_CONFIGURATION",
|
|
236
|
+
INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR"
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* This occurs when the provided user token is considered invalid for the given document ARI.
|
|
240
|
+
* It happens during initialisation of the provider.
|
|
241
|
+
* It could mean the document has been deleted (hence not found).
|
|
242
|
+
* @message Message returned to editor, i.e User does not have permissions to access this document or document is not found
|
|
243
|
+
* @recoverable It is recoverable, as we will try to refresh the token.
|
|
244
|
+
*/
|
|
245
|
+
declare type InsufficientEditingPermission = {
|
|
246
|
+
code: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR;
|
|
247
|
+
message: string;
|
|
248
|
+
recoverable: boolean;
|
|
249
|
+
reason?: string;
|
|
250
|
+
/**
|
|
251
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
252
|
+
*/
|
|
253
|
+
status?: number;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Similiar to InsufficientEditingPermission, but the user token is invalid because it has expired or been revoked.
|
|
257
|
+
* It may also be an invalid token format.
|
|
258
|
+
* This error is given to the provider by NCS.
|
|
259
|
+
* @message Message returned to editor, i.e. The user token was invalid
|
|
260
|
+
* @recoverable It is recoverable, as we will try to refresh the token.
|
|
261
|
+
*/
|
|
262
|
+
declare type InvalidUserToken = {
|
|
263
|
+
code: PROVIDER_ERROR_CODE.INVALID_USER_TOKEN;
|
|
264
|
+
message: string;
|
|
265
|
+
recoverable: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
268
|
+
*/
|
|
269
|
+
status?: number;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Document not found error, thrown when the provider is unable to find a document with the given ARI and user token.
|
|
273
|
+
* It occurs during fetchCatchup, a function that fetches the latest document state during catchup.
|
|
274
|
+
* We need to recieve a 404 from the document service to throw this error.
|
|
275
|
+
* @message Message returned to editor, i.e. The requested document is not found
|
|
276
|
+
* @recoverable It is recoverable, as the provider can try again later.
|
|
277
|
+
*/
|
|
278
|
+
declare type DocumentNotFound = {
|
|
279
|
+
code: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND;
|
|
280
|
+
message: string;
|
|
281
|
+
recoverable: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
284
|
+
*/
|
|
285
|
+
status?: number;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* This error is thrown when the document is locked by another user.
|
|
289
|
+
* The error is passed to us by NCS.
|
|
290
|
+
* @message Message returned to editor, i.e. The document is currently not available, please try again later
|
|
291
|
+
* @recoverable It is recoverable, as the provider can try again later.
|
|
292
|
+
*/
|
|
293
|
+
declare type Locked = {
|
|
294
|
+
code: PROVIDER_ERROR_CODE.LOCKED;
|
|
295
|
+
message: string;
|
|
296
|
+
recoverable: boolean;
|
|
297
|
+
status?: number;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* This error is thrown when the provider is unable to save the document.
|
|
301
|
+
* This can happen when the connection to dynamoDB is lost, or when we do not have sufficient permissions (DYNAMO ERROR).
|
|
302
|
+
* This error is given to us by NCS.
|
|
303
|
+
* @message Message returned to editor, i.e. Collab service is not able to save changes
|
|
304
|
+
* @recoverable It is not recoverable, as we don't want the user to continue editing a document that is not being saved.
|
|
305
|
+
*/
|
|
306
|
+
declare type FailToSave = {
|
|
307
|
+
code: PROVIDER_ERROR_CODE.FAIL_TO_SAVE;
|
|
308
|
+
message: string;
|
|
309
|
+
recoverable: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
312
|
+
*/
|
|
313
|
+
status?: number;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* This error is thrown when the provider is unable to restore the document.
|
|
317
|
+
* It occurs during onRestore, a function that restores the document to a previous version and reapplies unconfirmed steps.
|
|
318
|
+
* onRestore is called when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
319
|
+
* It could mean we failed to update the page metadata, or we failed to reapply unconfirmed steps.
|
|
320
|
+
* @message Message returned to editor, i.e. Collab service unable to restore document
|
|
321
|
+
* @recoverable It is not recoverable, as the provider has no further options after this.
|
|
322
|
+
* The user will need to refresh the page to try again.
|
|
323
|
+
*/
|
|
324
|
+
declare type DocumentNotRestore = {
|
|
325
|
+
code: PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
|
|
326
|
+
message: string;
|
|
327
|
+
recoverable: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
330
|
+
*/
|
|
331
|
+
status?: number;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* The initial document couldn't be loaded from the collab service.
|
|
335
|
+
* This error is given to us by NCS.
|
|
336
|
+
* It could indicate either a network issue, or an internal service error in NCS.
|
|
337
|
+
* @message Message returned to editor, i.e. The initial document couldn't be loaded from the collab service
|
|
338
|
+
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
339
|
+
* The user will need to refresh the page to try again.
|
|
340
|
+
*/
|
|
341
|
+
declare type InitialisationError = {
|
|
342
|
+
code: PROVIDER_ERROR_CODE.INITIALISATION_ERROR;
|
|
343
|
+
message: string;
|
|
344
|
+
recoverable: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
347
|
+
*/
|
|
348
|
+
status?: number;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Couldn't reconnect to the collab service (NCS) due to network issues.
|
|
352
|
+
* NCS could be down, or the user could be offline. It's also possible the url is incorrect, or the user is behind a proxy blocking the connection.
|
|
353
|
+
* Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
354
|
+
* @message Message returned to editor, i.e. Couldn't reconnect to the collab service due to network issues
|
|
355
|
+
* @recoverable It is recoverable, as the provider will try to reconnect.
|
|
356
|
+
*/
|
|
357
|
+
declare type NetworkIssue = {
|
|
358
|
+
code: PROVIDER_ERROR_CODE.NETWORK_ISSUE;
|
|
359
|
+
message: string;
|
|
360
|
+
recoverable: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
363
|
+
*/
|
|
364
|
+
status?: number;
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* This error is thrown when the provider has an invalid configuration.
|
|
368
|
+
* It could happen due to these errors from NCS:
|
|
369
|
+
* NAMESPACE_INVALID
|
|
370
|
+
INVALID_ACTIVATION_ID
|
|
371
|
+
INVALID_DOCUMENT_ARI
|
|
372
|
+
INVALID_CLOUD_ID
|
|
373
|
+
* @message Message returned to editor, i.e. Invalid provider configuration
|
|
374
|
+
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
375
|
+
* The service using the provider will need to fix the configuration.
|
|
376
|
+
*/
|
|
377
|
+
declare type InvalidProviderConfiguration = {
|
|
378
|
+
code: PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION;
|
|
379
|
+
message: string;
|
|
380
|
+
recoverable: boolean;
|
|
381
|
+
reason: string;
|
|
382
|
+
/**
|
|
383
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
384
|
+
*/
|
|
385
|
+
status?: number;
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* This error is thrown when the provider encounters an internal service error, not otherwise accounted for.
|
|
389
|
+
* @message Message returned to editor, i.e. Collab Provider experienced an unrecoverable error
|
|
390
|
+
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
391
|
+
*/
|
|
392
|
+
declare type InternalServiceError = {
|
|
393
|
+
code: PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR;
|
|
394
|
+
message: string;
|
|
395
|
+
recoverable: boolean;
|
|
396
|
+
reason: string;
|
|
397
|
+
/**
|
|
398
|
+
* @deprecated switch to using either the error code or the recoverable flag
|
|
399
|
+
*/
|
|
400
|
+
status?: number;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* A union of all possible provider errors that can be emitted back to the editor.
|
|
404
|
+
*/
|
|
405
|
+
export declare type ProviderError = InsufficientEditingPermission | InvalidUserToken | DocumentNotFound | Locked | FailToSave | DocumentNotRestore | InitialisationError | NetworkIssue | InvalidProviderConfiguration | InternalServiceError;
|
|
406
|
+
declare class CustomError extends Error {
|
|
407
|
+
constructor(message: string, error?: unknown);
|
|
408
|
+
toJSON(): {
|
|
409
|
+
name: string;
|
|
410
|
+
message: string;
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
export declare class NotConnectedError extends CustomError {
|
|
414
|
+
name: string;
|
|
415
|
+
}
|
|
416
|
+
export declare class NotInitializedError extends CustomError {
|
|
417
|
+
name: string;
|
|
418
|
+
}
|
|
419
|
+
export declare class ProviderInitialisationError extends CustomError {
|
|
420
|
+
name: string;
|
|
421
|
+
}
|
|
422
|
+
export declare class SendTransactionError extends CustomError {
|
|
423
|
+
name: string;
|
|
424
|
+
}
|
|
425
|
+
export declare class DestroyError extends CustomError {
|
|
426
|
+
name: string;
|
|
427
|
+
}
|
|
428
|
+
export declare class SetTitleError extends CustomError {
|
|
429
|
+
name: string;
|
|
430
|
+
}
|
|
431
|
+
export declare class SetEditorWidthError extends CustomError {
|
|
432
|
+
name: string;
|
|
433
|
+
}
|
|
434
|
+
export declare class SetMetadataError extends CustomError {
|
|
435
|
+
name: string;
|
|
436
|
+
}
|
|
437
|
+
export declare class GetCurrentStateError extends CustomError {
|
|
2
438
|
name: string;
|
|
3
|
-
constructor(message: string);
|
|
4
439
|
}
|
|
5
|
-
export declare class
|
|
440
|
+
export declare class GetFinalAcknowledgedStateError extends CustomError {
|
|
6
441
|
name: string;
|
|
7
|
-
constructor(message: string);
|
|
8
442
|
}
|
|
443
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderError } from '../errors/error-types';
|
|
2
2
|
export declare enum EVENT_ACTION {
|
|
3
3
|
CONNECTION = "connection",
|
|
4
4
|
CATCHUP = "catchup",
|
|
@@ -27,7 +27,7 @@ export declare type ErrorAnalyticsEvent = {
|
|
|
27
27
|
errorMessage: string;
|
|
28
28
|
errorName?: string;
|
|
29
29
|
documentAri?: string;
|
|
30
|
-
mappedError?:
|
|
30
|
+
mappedError?: ProviderError;
|
|
31
31
|
};
|
|
32
32
|
nonPrivacySafeAttributes: {
|
|
33
33
|
error: unknown;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ProductInformation } from '../types';
|
|
2
2
|
export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
|
|
3
|
-
export declare const getParticipant: (userId: string) => {
|
|
4
|
-
userId: string;
|
|
5
|
-
name: string;
|
|
6
|
-
avatar: string;
|
|
7
|
-
email: string;
|
|
8
|
-
};
|
|
9
3
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
10
4
|
export declare const getProduct: (productInfo?: ProductInformation | undefined) => string;
|
|
11
5
|
export declare const getSubProduct: (productInfo?: ProductInformation | undefined) => string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
|
-
export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, Socket, } from './types';
|
|
2
|
+
export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, Socket, } from './types';
|
|
3
|
+
export type { ProviderError } from './errors/error-types';
|
|
4
|
+
export { PROVIDER_ERROR_CODE } from './errors/error-types';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Metadata, CollabEvents } from '../types';
|
|
2
|
+
export declare class MetadataService {
|
|
3
|
+
private providerEmitCallback;
|
|
4
|
+
private broadcastMetadata;
|
|
5
|
+
private metadata;
|
|
6
|
+
constructor(providerEmitCallback: (evt: keyof CollabEvents, data: any) => void, broadcastMetadata: (metadata: Metadata) => void);
|
|
7
|
+
getMetaData: () => Metadata;
|
|
8
|
+
getTitle: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Called when a metadata is changed externally from other clients/backend.
|
|
11
|
+
*/
|
|
12
|
+
onMetadataChanged: (metadata?: Metadata | undefined) => void;
|
|
13
|
+
setTitle(title: string, broadcast?: boolean): void;
|
|
14
|
+
setEditorWidth(editorWidth: string, broadcast?: boolean): void;
|
|
15
|
+
/**
|
|
16
|
+
* Updates the local metadata and broadcasts the metadata to other clients/backend.
|
|
17
|
+
* @param metadata
|
|
18
|
+
*/
|
|
19
|
+
setMetadata(metadata: Metadata): void;
|
|
20
|
+
/**
|
|
21
|
+
* Emits a change in document's metadata
|
|
22
|
+
* @param metadata
|
|
23
|
+
*/
|
|
24
|
+
updateMetadata: (metadata: Metadata | undefined) => void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CollabEventPresenceData, CollabParticipant } from '@atlaskit/editor-common/collab';
|
|
2
|
+
import type { CollabEventTelepointerData, PresencePayload } from '../types';
|
|
3
|
+
export declare const PARTICIPANT_UPDATE_INTERVAL: number;
|
|
4
|
+
export declare type ProviderParticipant = CollabParticipant & {
|
|
5
|
+
userId: string;
|
|
6
|
+
clientId: number | string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
9
|
+
export declare type PresenceEmit = (evt: 'presence', data: CollabEventPresenceData) => void;
|
|
10
|
+
export declare type TelepointerEmit = (evt: 'telepointer', data: CollabEventTelepointerData) => void;
|
|
11
|
+
export declare const createParticipantFromPayload: (payload: PresencePayload & {
|
|
12
|
+
userId: string;
|
|
13
|
+
}, getUser: ((userId: string) => Promise<Pick<CollabParticipant, "avatar" | "email" | "name"> & {
|
|
14
|
+
userId: string;
|
|
15
|
+
}>) | undefined) => Promise<ProviderParticipant>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CollabEventPresenceData, CollabParticipant, CollabEventDisconnectedData } from '@atlaskit/editor-common/collab';
|
|
2
|
+
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
+
import type { CollabEventTelepointerData, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
4
|
+
import { TelepointerEmit } from './participants-helper';
|
|
5
|
+
import type { PresenceEmit } from './participants-helper';
|
|
6
|
+
import { ParticipantsState } from './participants-state';
|
|
7
|
+
export declare class ParticipantsService {
|
|
8
|
+
private participantsState;
|
|
9
|
+
private participantUpdateTimeout;
|
|
10
|
+
private analyticsHelper;
|
|
11
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState?: ParticipantsState);
|
|
12
|
+
/**
|
|
13
|
+
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
14
|
+
* @param payload Payload from incoming socket event
|
|
15
|
+
* @param getUser Function to get user data from confluence
|
|
16
|
+
* @param emit Function to execute emit from provider socket
|
|
17
|
+
* @returns Awaitable Promise, due to getUser
|
|
18
|
+
*/
|
|
19
|
+
updateParticipant: (payload: PresencePayload, getUser: ((userId: string) => Promise<Pick<CollabParticipant, "avatar" | "email" | "name"> & {
|
|
20
|
+
userId: string;
|
|
21
|
+
}>) | undefined, emit: PresenceEmit) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Called when a participant leaves the session.
|
|
24
|
+
*
|
|
25
|
+
* We emit the `presence` event to update the active avatars in the editor.
|
|
26
|
+
*/
|
|
27
|
+
participantLeft: ({ sessionId }: PresencePayload, emit: PresenceEmit) => void;
|
|
28
|
+
disconnect: (reason: string, sessionId: string | undefined, emit: (evt: 'presence' | 'disconnected', data: CollabEventPresenceData | CollabEventDisconnectedData) => void) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Updates when users were last active
|
|
31
|
+
* @param userIds Users in most recent steps
|
|
32
|
+
*/
|
|
33
|
+
updateLastActive: (userIds?: string[]) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Called on receiving steps, emits each step's telepointer
|
|
36
|
+
* @param steps Steps to extract telepointers from
|
|
37
|
+
* @param emit Provider emit function
|
|
38
|
+
*/
|
|
39
|
+
emitTelepointersFromSteps(steps: StepJson[], emit: TelepointerEmit): void;
|
|
40
|
+
/**
|
|
41
|
+
* Called when we receive a telepointer update from another
|
|
42
|
+
* participant.
|
|
43
|
+
*/
|
|
44
|
+
participantTelepointer: (payload: TelepointerPayload, thisSessionId: string | undefined, getUser: ((userId: string) => Promise<Pick<CollabParticipant, "avatar" | "email" | "name"> & {
|
|
45
|
+
userId: string;
|
|
46
|
+
}>) | undefined, emit: (evt: 'telepointer' | 'presence', data: CollabEventTelepointerData | CollabEventPresenceData) => void) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Every 5 minutes (PARTICIPANT_UPDATE_INTERVAL), removes inactive participants and emits the update to other participants.
|
|
49
|
+
* Needs to be kicked off in the Provider.
|
|
50
|
+
* @param sessionId SessionId from provider's connection
|
|
51
|
+
* @param emit Function to execute emit from provider socket
|
|
52
|
+
*/
|
|
53
|
+
removeInactiveParticipants: (sessionId: string | undefined, emit: PresenceEmit) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Keep list of participants up to date. Filter out inactive users etc.
|
|
56
|
+
*/
|
|
57
|
+
private filterInactive;
|
|
58
|
+
/**
|
|
59
|
+
* Wrapper function to emit with error handling and analytics
|
|
60
|
+
* @param data Data to emit
|
|
61
|
+
* @param emit Emit function from Provider
|
|
62
|
+
*/
|
|
63
|
+
private emitPresence;
|
|
64
|
+
/**
|
|
65
|
+
* Wrapper function to emit with error handling and analytics
|
|
66
|
+
* @param data Data to emit
|
|
67
|
+
* @param emit Emit function from Provider
|
|
68
|
+
*/
|
|
69
|
+
private emitTelepointer;
|
|
70
|
+
/**
|
|
71
|
+
* Used when the provider is disconnected or destroyed to prevent perpetual timers from continuously running
|
|
72
|
+
*/
|
|
73
|
+
clearTimers: () => void;
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ParticipantsMap, ProviderParticipant } from './participants-helper';
|
|
2
|
+
export declare class ParticipantsState {
|
|
3
|
+
private participants;
|
|
4
|
+
constructor(baseParticipants?: ParticipantsMap);
|
|
5
|
+
getBySessionId: (sessionId: string) => ProviderParticipant | undefined;
|
|
6
|
+
setBySessionId: (sessionId: string, participant: ProviderParticipant) => void;
|
|
7
|
+
getParticipants: () => ProviderParticipant[];
|
|
8
|
+
removeBySessionId: (sessionId: string) => boolean;
|
|
9
|
+
clear: () => void;
|
|
10
|
+
doesntHave: (sessionId: string) => boolean;
|
|
11
|
+
size: () => number;
|
|
12
|
+
updateLastActive: (now: number, userIds: string[]) => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AcknowledgementPayload, CollabEventTelepointerData, StepJson } from '../types';
|
|
2
|
+
import { ProviderParticipant } from './participants-helper';
|
|
3
|
+
export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabEventTelepointerData | undefined;
|
|
4
|
+
export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import { ChannelEvent, StepsPayload } from '../types';
|
|
2
3
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
export declare const commitStep: ({
|
|
6
|
-
|
|
4
|
+
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
5
|
+
import type { InternalError } from '../errors/error-types';
|
|
6
|
+
export declare const commitStep: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
|
|
7
|
+
broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function | undefined) => void;
|
|
7
8
|
steps: readonly ProseMirrorStep[];
|
|
8
9
|
version: number;
|
|
9
10
|
userId: string;
|
|
10
11
|
clientId: number | string;
|
|
11
12
|
onStepsAdded: (data: StepsPayload) => void;
|
|
12
|
-
onErrorHandled: (error:
|
|
13
|
+
onErrorHandled: (error: InternalError) => void;
|
|
13
14
|
analyticsHelper?: AnalyticsHelper | undefined;
|
|
14
15
|
}) => void;
|
|
16
|
+
export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
|
|
17
|
+
broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function | undefined) => void;
|
|
18
|
+
steps: readonly ProseMirrorStep[];
|
|
19
|
+
version: number;
|
|
20
|
+
userId: string;
|
|
21
|
+
clientId: number | string;
|
|
22
|
+
onStepsAdded: (data: StepsPayload) => void;
|
|
23
|
+
onErrorHandled: (error: InternalError) => void;
|
|
24
|
+
analyticsHelper?: AnalyticsHelper | undefined;
|
|
25
|
+
}) => void>;
|