@atlaskit/collab-provider 9.7.0 → 9.7.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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/disconnected-reason-mapper.js +8 -17
- package/dist/cjs/errors/error-code-mapper.js +13 -12
- package/dist/cjs/errors/error-types.js +2 -95
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/types.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/disconnected-reason-mapper.js +2 -9
- package/dist/es2019/errors/error-code-mapper.js +2 -1
- package/dist/es2019/errors/error-types.js +0 -94
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/types.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/disconnected-reason-mapper.js +2 -9
- package/dist/esm/errors/error-code-mapper.js +2 -1
- package/dist/esm/errors/error-types.js +0 -94
- package/dist/esm/index.js +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/channel.d.ts +2 -1
- package/dist/types/disconnected-reason-mapper.d.ts +1 -8
- package/dist/types/document/document-service.d.ts +3 -2
- package/dist/types/errors/error-code-mapper.d.ts +2 -1
- package/dist/types/errors/error-types.d.ts +0 -190
- package/dist/types/helpers/const.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/metadata/metadata-service.d.ts +1 -1
- package/dist/types/participants/participants-helper.d.ts +2 -6
- package/dist/types/participants/participants-service.d.ts +3 -2
- package/dist/types/participants/participants-state.d.ts +2 -1
- package/dist/types/participants/telepointers-helper.d.ts +2 -2
- package/dist/types/provider/commit-step.d.ts +2 -1
- package/dist/types/provider/index.d.ts +3 -3
- package/dist/types/socket-io-provider.d.ts +1 -1
- package/dist/types/types.d.ts +2 -149
- package/dist/types-ts4.5/channel.d.ts +2 -1
- package/dist/types-ts4.5/disconnected-reason-mapper.d.ts +1 -8
- package/dist/types-ts4.5/document/document-service.d.ts +3 -2
- package/dist/types-ts4.5/errors/error-code-mapper.d.ts +2 -1
- package/dist/types-ts4.5/errors/error-types.d.ts +0 -190
- package/dist/types-ts4.5/helpers/const.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +3 -3
- package/dist/types-ts4.5/metadata/metadata-service.d.ts +1 -1
- package/dist/types-ts4.5/participants/participants-helper.d.ts +2 -6
- package/dist/types-ts4.5/participants/participants-service.d.ts +3 -2
- package/dist/types-ts4.5/participants/participants-state.d.ts +2 -1
- package/dist/types-ts4.5/participants/telepointers-helper.d.ts +2 -2
- package/dist/types-ts4.5/provider/commit-step.d.ts +2 -1
- package/dist/types-ts4.5/provider/index.d.ts +3 -3
- package/dist/types-ts4.5/socket-io-provider.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -149
- package/package.json +2 -1
- package/report.api.md +49 -390
- package/tmp/api-report-tmp.d.ts +257 -0
package/dist/esm/version.json
CHANGED
package/dist/types/channel.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Emitter } from './emitter';
|
|
2
|
-
import type { Config, ChannelEvent, CatchupResponse
|
|
2
|
+
import type { Config, ChannelEvent, CatchupResponse } from './types';
|
|
3
3
|
import type { Socket } from 'socket.io-client';
|
|
4
4
|
import AnalyticsHelper from './analytics/analytics-helper';
|
|
5
|
+
import type { Metadata } from '@atlaskit/editor-common/collab';
|
|
5
6
|
export declare class Channel extends Emitter<ChannelEvent> {
|
|
6
7
|
private connected;
|
|
7
8
|
private config;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DisconnectReason } from '@atlaskit/editor-common/collab';
|
|
1
2
|
export declare const socketIOReasons: {
|
|
2
3
|
IO_CLIENT_DISCONNECT: string;
|
|
3
4
|
IO_SERVER_DISCONNECT: string;
|
|
@@ -5,12 +6,4 @@ export declare const socketIOReasons: {
|
|
|
5
6
|
TRANSPORT_ERROR: string;
|
|
6
7
|
PING_TIMEOUT: string;
|
|
7
8
|
};
|
|
8
|
-
export declare enum DisconnectReason {
|
|
9
|
-
CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
|
|
10
|
-
SERVER_DISCONNECT = "SERVER_DISCONNECT",
|
|
11
|
-
SOCKET_CLOSED = "SOCKET_CLOSED",
|
|
12
|
-
SOCKET_ERROR = "SOCKET_ERROR",
|
|
13
|
-
SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
|
|
14
|
-
UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
|
|
15
|
-
}
|
|
16
9
|
export declare const disconnectedReasonMapper: (reason: string) => DisconnectReason;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import { CatchupResponse, ChannelEvent,
|
|
3
|
+
import { CatchupResponse, ChannelEvent, StepsPayload } from '../types';
|
|
4
|
+
import type { SyncUpErrorFunction, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
5
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
5
6
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
|
-
import {
|
|
7
|
+
import type { CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
7
8
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
8
9
|
import { ParticipantsService } from '../participants/participants-service';
|
|
9
10
|
import type { InternalError } from '../errors/error-types';
|
|
@@ -240,196 +240,6 @@ export type InternalDocumentUpdateFailure = {
|
|
|
240
240
|
* A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
|
|
241
241
|
*/
|
|
242
242
|
export type InternalError = NCSErrors | DocumentRecoveryError | AddStepsError | CatchUpFailedError | TokenPermissionError | ReconnectionError | ConnectionError | ReconnectionNetworkError | DocumentNotFoundError | InternalDocumentUpdateFailure;
|
|
243
|
-
export declare enum PROVIDER_ERROR_CODE {
|
|
244
|
-
NO_PERMISSION_ERROR = "NO_PERMISSION_ERROR",
|
|
245
|
-
INVALID_USER_TOKEN = "INVALID_USER_TOKEN",
|
|
246
|
-
DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
|
|
247
|
-
LOCKED = "LOCKED",
|
|
248
|
-
FAIL_TO_SAVE = "FAIL_TO_SAVE",
|
|
249
|
-
DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
|
|
250
|
-
INITIALISATION_ERROR = "INITIALISATION_ERROR",
|
|
251
|
-
NETWORK_ISSUE = "NETWORK_ISSUE",
|
|
252
|
-
INVALID_PROVIDER_CONFIGURATION = "INVALID_PROVIDER_CONFIGURATION",
|
|
253
|
-
INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR",
|
|
254
|
-
DOCUMENT_UPDATE_ERROR = "DOCUMENT_UPDATE_ERROR"
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* This occurs when the provided user token is considered invalid for the given document ARI.
|
|
258
|
-
* It happens during initialisation of the provider.
|
|
259
|
-
* It could mean the document has been deleted (hence not found).
|
|
260
|
-
* @message Message returned to editor, i.e User does not have permissions to access this document or document is not found
|
|
261
|
-
* @recoverable It is recoverable, as we will try to refresh the token.
|
|
262
|
-
*/
|
|
263
|
-
type InsufficientEditingPermission = {
|
|
264
|
-
code: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR;
|
|
265
|
-
message: string;
|
|
266
|
-
recoverable: boolean;
|
|
267
|
-
reason?: string;
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
270
|
-
*/
|
|
271
|
-
status?: number;
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Similiar to InsufficientEditingPermission, but the user token is invalid because it has expired or been revoked.
|
|
275
|
-
* It may also be an invalid token format.
|
|
276
|
-
* This error is given to the provider by NCS.
|
|
277
|
-
* @message Message returned to editor, i.e. The user token was invalid
|
|
278
|
-
* @recoverable It is recoverable, as we will try to refresh the token.
|
|
279
|
-
*/
|
|
280
|
-
type InvalidUserToken = {
|
|
281
|
-
code: PROVIDER_ERROR_CODE.INVALID_USER_TOKEN;
|
|
282
|
-
message: string;
|
|
283
|
-
recoverable: boolean;
|
|
284
|
-
/**
|
|
285
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
286
|
-
*/
|
|
287
|
-
status?: number;
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Document not found error, thrown when the provider is unable to find a document with the given ARI and user token.
|
|
291
|
-
* It occurs during fetchCatchup, a function that fetches the latest document state during catchup.
|
|
292
|
-
* We need to recieve a 404 from the document service to throw this error.
|
|
293
|
-
* @message Message returned to editor, i.e. The requested document is not found
|
|
294
|
-
* @recoverable It is recoverable, as the provider can try again later.
|
|
295
|
-
*/
|
|
296
|
-
type DocumentNotFound = {
|
|
297
|
-
code: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND;
|
|
298
|
-
message: string;
|
|
299
|
-
recoverable: boolean;
|
|
300
|
-
/**
|
|
301
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
302
|
-
*/
|
|
303
|
-
status?: number;
|
|
304
|
-
};
|
|
305
|
-
/**
|
|
306
|
-
* This error is thrown when the document is locked by another user.
|
|
307
|
-
* The error is passed to us by NCS.
|
|
308
|
-
* @message Message returned to editor, i.e. The document is currently not available, please try again later
|
|
309
|
-
* @recoverable It is recoverable, as the provider can try again later.
|
|
310
|
-
*/
|
|
311
|
-
type Locked = {
|
|
312
|
-
code: PROVIDER_ERROR_CODE.LOCKED;
|
|
313
|
-
message: string;
|
|
314
|
-
recoverable: boolean;
|
|
315
|
-
status?: number;
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* This error is thrown when the provider is unable to save the document.
|
|
319
|
-
* This can happen when the connection to dynamoDB is lost, or when we do not have sufficient permissions (DYNAMO ERROR).
|
|
320
|
-
* This error is given to us by NCS.
|
|
321
|
-
* @message Message returned to editor, i.e. Collab service is not able to save changes
|
|
322
|
-
* @recoverable It is not recoverable, as we don't want the user to continue editing a document that is not being saved.
|
|
323
|
-
*/
|
|
324
|
-
type FailToSave = {
|
|
325
|
-
code: PROVIDER_ERROR_CODE.FAIL_TO_SAVE;
|
|
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
|
-
* This error is thrown when the provider is unable to restore the document.
|
|
335
|
-
* It occurs during onRestore, a function that restores the document to a previous version and reapplies unconfirmed steps.
|
|
336
|
-
* onRestore is called when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
337
|
-
* It could mean we failed to update the page metadata, or we failed to reapply unconfirmed steps.
|
|
338
|
-
* @message Message returned to editor, i.e. Collab service unable to restore document
|
|
339
|
-
* @recoverable It is not recoverable, as the provider has no further options after this.
|
|
340
|
-
* The user will need to refresh the page to try again.
|
|
341
|
-
*/
|
|
342
|
-
type DocumentNotRestore = {
|
|
343
|
-
code: PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
|
|
344
|
-
message: string;
|
|
345
|
-
recoverable: boolean;
|
|
346
|
-
/**
|
|
347
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
348
|
-
*/
|
|
349
|
-
status?: number;
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* The initial document couldn't be loaded from the collab service.
|
|
353
|
-
* This error is given to us by NCS.
|
|
354
|
-
* It could indicate either a network issue, or an internal service error in NCS.
|
|
355
|
-
* @message Message returned to editor, i.e. The initial document couldn't be loaded from the collab service
|
|
356
|
-
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
357
|
-
* The user will need to refresh the page to try again.
|
|
358
|
-
*/
|
|
359
|
-
type InitialisationError = {
|
|
360
|
-
code: PROVIDER_ERROR_CODE.INITIALISATION_ERROR;
|
|
361
|
-
message: string;
|
|
362
|
-
recoverable: boolean;
|
|
363
|
-
/**
|
|
364
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
365
|
-
*/
|
|
366
|
-
status?: number;
|
|
367
|
-
};
|
|
368
|
-
/**
|
|
369
|
-
* Couldn't reconnect to the collab service (NCS) due to network issues.
|
|
370
|
-
* 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.
|
|
371
|
-
* Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
372
|
-
* @message Message returned to editor, i.e. Couldn't reconnect to the collab service due to network issues
|
|
373
|
-
* @recoverable It is recoverable, as the provider will try to reconnect.
|
|
374
|
-
*/
|
|
375
|
-
type NetworkIssue = {
|
|
376
|
-
code: PROVIDER_ERROR_CODE.NETWORK_ISSUE;
|
|
377
|
-
message: string;
|
|
378
|
-
recoverable: boolean;
|
|
379
|
-
/**
|
|
380
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
381
|
-
*/
|
|
382
|
-
status?: number;
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* This error is thrown when the provider has an invalid configuration.
|
|
386
|
-
* It could happen due to these errors from NCS:
|
|
387
|
-
* NAMESPACE_INVALID
|
|
388
|
-
INVALID_ACTIVATION_ID
|
|
389
|
-
INVALID_DOCUMENT_ARI
|
|
390
|
-
INVALID_CLOUD_ID
|
|
391
|
-
* @message Message returned to editor, i.e. Invalid provider configuration
|
|
392
|
-
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
393
|
-
* The service using the provider will need to fix the configuration.
|
|
394
|
-
*/
|
|
395
|
-
type InvalidProviderConfiguration = {
|
|
396
|
-
code: PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION;
|
|
397
|
-
message: string;
|
|
398
|
-
recoverable: boolean;
|
|
399
|
-
reason: string;
|
|
400
|
-
/**
|
|
401
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
402
|
-
*/
|
|
403
|
-
status?: number;
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* This error is thrown when the provider encounters an internal service error, not otherwise accounted for.
|
|
407
|
-
* @message Message returned to editor, i.e. Collab Provider experienced an unrecoverable error
|
|
408
|
-
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
409
|
-
*/
|
|
410
|
-
type InternalServiceError = {
|
|
411
|
-
code: PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR;
|
|
412
|
-
message: string;
|
|
413
|
-
recoverable: boolean;
|
|
414
|
-
reason: string;
|
|
415
|
-
/**
|
|
416
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
417
|
-
*/
|
|
418
|
-
status?: number;
|
|
419
|
-
};
|
|
420
|
-
type ProviderDocumentUpdateError = {
|
|
421
|
-
code: PROVIDER_ERROR_CODE.DOCUMENT_UPDATE_ERROR;
|
|
422
|
-
message: 'The provider failed to apply changes to the editor';
|
|
423
|
-
recoverable: boolean;
|
|
424
|
-
/**
|
|
425
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
426
|
-
*/
|
|
427
|
-
status?: number;
|
|
428
|
-
};
|
|
429
|
-
/**
|
|
430
|
-
* A union of all possible provider errors that can be emitted back to the editor.
|
|
431
|
-
*/
|
|
432
|
-
export type ProviderError = InsufficientEditingPermission | InvalidUserToken | DocumentNotFound | Locked | FailToSave | DocumentNotRestore | InitialisationError | NetworkIssue | InvalidProviderConfiguration | InternalServiceError | ProviderDocumentUpdateError;
|
|
433
243
|
type ValidEventAttributeType = boolean | string | number;
|
|
434
244
|
export declare class CustomError extends Error {
|
|
435
245
|
extraEventAttributes?: {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
|
-
export type {
|
|
3
|
-
export type { ProviderError } from '
|
|
4
|
-
export { PROVIDER_ERROR_CODE } from '
|
|
2
|
+
export type { CollabEventDisconnectedData, CollabEventLocalStepData, Socket, } from './types';
|
|
3
|
+
export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, } from '@atlaskit/editor-common/collab';
|
|
4
|
+
export { PROVIDER_ERROR_CODE } from '@atlaskit/editor-common/collab';
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PresencePayload } from '../types';
|
|
2
|
+
import type { ProviderParticipant } from '@atlaskit/editor-common/collab';
|
|
2
3
|
export declare const PARTICIPANT_UPDATE_INTERVAL: number;
|
|
3
|
-
export type ProviderParticipant = CollabParticipant & {
|
|
4
|
-
userId: string;
|
|
5
|
-
clientId: number | string;
|
|
6
|
-
email: string;
|
|
7
|
-
};
|
|
8
4
|
export type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
9
5
|
export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId' | 'email'>>) | undefined;
|
|
10
6
|
export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
2
|
-
import type { CollabEventDisconnectedData,
|
|
2
|
+
import type { CollabEventDisconnectedData, ChannelEvent, PresenceData, PresencePayload, TelepointerPayload } from '../types';
|
|
3
|
+
import { CollabEventPresenceData, CollabTelepointerPayload, StepJson } from '@atlaskit/editor-common/collab';
|
|
3
4
|
import { GetUserType } from './participants-helper';
|
|
4
5
|
import { ParticipantsState } from './participants-state';
|
|
5
6
|
/**
|
|
@@ -95,5 +96,5 @@ export declare class ParticipantsService {
|
|
|
95
96
|
/**
|
|
96
97
|
*
|
|
97
98
|
*/
|
|
98
|
-
getParticipants: () => import("
|
|
99
|
+
getParticipants: () => import("@atlaskit/editor-common/collab").ProviderParticipant[];
|
|
99
100
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ParticipantsMap
|
|
1
|
+
import { ParticipantsMap } from './participants-helper';
|
|
2
|
+
import type { ProviderParticipant } from '@atlaskit/editor-common/collab';
|
|
2
3
|
export declare class ParticipantsState {
|
|
3
4
|
private participants;
|
|
4
5
|
constructor(baseParticipants?: ParticipantsMap);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AcknowledgementPayload
|
|
2
|
-
import { ProviderParticipant } from '
|
|
1
|
+
import type { AcknowledgementPayload } from '../types';
|
|
2
|
+
import type { CollabTelepointerPayload, StepJson, ProviderParticipant } from '@atlaskit/editor-common/collab';
|
|
3
3
|
export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabTelepointerPayload | undefined;
|
|
4
4
|
export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
-
import { ChannelEvent,
|
|
2
|
+
import { ChannelEvent, StepsPayload } from '../types';
|
|
3
|
+
import type { CollabCommitStatusEventPayload, CollabEvents } from '@atlaskit/editor-common/collab';
|
|
3
4
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
4
5
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
5
6
|
import type { InternalError } from '../errors/error-types';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
3
3
|
import { Emitter } from '../emitter';
|
|
4
|
-
import type {
|
|
5
|
-
import type { SyncUpErrorFunction } from '
|
|
4
|
+
import type { Config } from '../types';
|
|
5
|
+
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, ResolvedEditorState, Metadata, SyncUpErrorFunction } from '@atlaskit/editor-common/collab';
|
|
6
6
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
7
7
|
type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
8
8
|
export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
@@ -158,6 +158,6 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
158
158
|
/**
|
|
159
159
|
*
|
|
160
160
|
*/
|
|
161
|
-
getParticipants: () => import("
|
|
161
|
+
getParticipants: () => import("@atlaskit/editor-common/collab").ProviderParticipant[];
|
|
162
162
|
}
|
|
163
163
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Provider } from './provider';
|
|
2
2
|
import { Socket } from 'socket.io-client';
|
|
3
|
-
import { Config, ProductInformation, InitAndAuthData, AuthCallback } from './types';
|
|
3
|
+
import type { Config, ProductInformation, InitAndAuthData, AuthCallback } from './types';
|
|
4
4
|
export declare function createSocketIOSocket(url: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation): Socket;
|
|
5
5
|
export declare function createSocketIOCollabProvider(config: Omit<Config, 'createSocket'>): Provider;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,59 +1,19 @@
|
|
|
1
1
|
import type { Step } from 'prosemirror-transform';
|
|
2
|
-
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
2
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
4
3
|
import type { Manager } from 'socket.io-client';
|
|
5
|
-
import type { DisconnectReason } from './disconnected-reason-mapper';
|
|
6
4
|
import type { InternalError } from './errors/error-types';
|
|
7
|
-
import type { ProviderError } from './errors/error-types';
|
|
8
5
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
9
6
|
import { GetUserType } from './participants/participants-helper';
|
|
10
7
|
import AnalyticsHelper from './analytics/analytics-helper';
|
|
11
|
-
import type {
|
|
12
|
-
export {
|
|
13
|
-
export interface CollabParticipant {
|
|
14
|
-
lastActive: number;
|
|
15
|
-
sessionId: string;
|
|
16
|
-
avatar: string;
|
|
17
|
-
name: string;
|
|
18
|
-
cursorPos?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface CollabEventInitData {
|
|
21
|
-
doc?: any;
|
|
22
|
-
json?: any;
|
|
23
|
-
version?: number;
|
|
24
|
-
sid?: string;
|
|
25
|
-
reserveCursor?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface CollabEventRemoteData {
|
|
28
|
-
json?: any;
|
|
29
|
-
newState?: EditorState;
|
|
30
|
-
userIds?: (number | string)[];
|
|
31
|
-
}
|
|
32
|
-
export interface CollabEventConnectionData {
|
|
33
|
-
sid: string;
|
|
34
|
-
initial: boolean;
|
|
35
|
-
}
|
|
36
|
-
export interface CollabEventConnectingData {
|
|
37
|
-
initial: boolean;
|
|
38
|
-
}
|
|
8
|
+
import type { CollabInitPayload, StepJson, CollabSendableSelection, Metadata } from '@atlaskit/editor-common/collab';
|
|
9
|
+
export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventPresenceData, ResolvedEditorState, CollabConnectedPayload, CollabConnectingPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabCommitStatusEventPayload, CollabEvents, Metadata, StepJson, CollabEventTelepointerData, CollabSendableSelection, CollabEditProvider, NewCollabSyncUpErrorAttributes, SyncUpErrorFunction, } from '@atlaskit/editor-common/collab';
|
|
39
10
|
export interface CollabEventDisconnectedData {
|
|
40
11
|
sid: string;
|
|
41
12
|
reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
|
|
42
13
|
}
|
|
43
|
-
export interface CollabEventPresenceData {
|
|
44
|
-
joined?: ProviderParticipant[];
|
|
45
|
-
left?: {
|
|
46
|
-
sessionId: string;
|
|
47
|
-
}[];
|
|
48
|
-
}
|
|
49
14
|
export interface CollabEventLocalStepData {
|
|
50
15
|
steps: Array<Step>;
|
|
51
16
|
}
|
|
52
|
-
export type ResolvedEditorState<T = any> = {
|
|
53
|
-
content: JSONDocNode | T;
|
|
54
|
-
title: string | null;
|
|
55
|
-
stepVersion: number;
|
|
56
|
-
};
|
|
57
17
|
export interface Storage {
|
|
58
18
|
get(key: string): Promise<string>;
|
|
59
19
|
set(key: string, value: string): Promise<void>;
|
|
@@ -125,50 +85,6 @@ export type EventHandler = () => void;
|
|
|
125
85
|
export interface Lifecycle {
|
|
126
86
|
on(event: LifecycleEvents, handler: EventHandler): void;
|
|
127
87
|
}
|
|
128
|
-
export type CollabConnectedPayload = CollabEventConnectionData;
|
|
129
|
-
export type CollabConnectingPayload = CollabEventConnectingData;
|
|
130
|
-
export interface CollabDisconnectedPayload {
|
|
131
|
-
reason: DisconnectReason;
|
|
132
|
-
sid: string;
|
|
133
|
-
}
|
|
134
|
-
export interface CollabInitPayload extends CollabEventInitData {
|
|
135
|
-
doc: any;
|
|
136
|
-
version: number;
|
|
137
|
-
metadata?: Metadata;
|
|
138
|
-
reserveCursor?: boolean;
|
|
139
|
-
}
|
|
140
|
-
export interface CollabDataPayload extends CollabEventRemoteData {
|
|
141
|
-
version: number;
|
|
142
|
-
json: StepJson[];
|
|
143
|
-
userIds: (number | string)[];
|
|
144
|
-
}
|
|
145
|
-
export type CollabTelepointerPayload = CollabEventTelepointerData;
|
|
146
|
-
export type CollabPresencePayload = CollabEventPresenceData;
|
|
147
|
-
export type CollabMetadataPayload = Metadata;
|
|
148
|
-
export type CollabLocalStepsPayload = {
|
|
149
|
-
steps: readonly Step[];
|
|
150
|
-
};
|
|
151
|
-
export type CollabCommitStatusEventPayload = {
|
|
152
|
-
status: 'attempt' | 'success' | 'failure';
|
|
153
|
-
version: number;
|
|
154
|
-
};
|
|
155
|
-
export interface CollabEvents {
|
|
156
|
-
'metadata:changed': CollabMetadataPayload;
|
|
157
|
-
init: CollabInitPayload;
|
|
158
|
-
connected: CollabConnectedPayload;
|
|
159
|
-
disconnected: CollabDisconnectedPayload;
|
|
160
|
-
data: CollabDataPayload;
|
|
161
|
-
telepointer: CollabTelepointerPayload;
|
|
162
|
-
presence: CollabPresencePayload;
|
|
163
|
-
'local-steps': CollabLocalStepsPayload;
|
|
164
|
-
error: ProviderError;
|
|
165
|
-
entity: any;
|
|
166
|
-
connecting: CollabConnectingPayload;
|
|
167
|
-
'commit-status': CollabCommitStatusEventPayload;
|
|
168
|
-
}
|
|
169
|
-
export interface Metadata {
|
|
170
|
-
[key: string]: string | number | boolean;
|
|
171
|
-
}
|
|
172
88
|
export type InitPayload = {
|
|
173
89
|
doc: any;
|
|
174
90
|
version: number;
|
|
@@ -197,36 +113,6 @@ export type PresencePayload = PresenceData & {
|
|
|
197
113
|
export type TelepointerPayload = PresencePayload & {
|
|
198
114
|
selection: CollabSendableSelection;
|
|
199
115
|
};
|
|
200
|
-
type MarkJson = {
|
|
201
|
-
type: string;
|
|
202
|
-
attrs: {
|
|
203
|
-
[key: string]: any;
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
type NodeJson = {
|
|
207
|
-
type: string;
|
|
208
|
-
attrs: {
|
|
209
|
-
[key: string]: any;
|
|
210
|
-
};
|
|
211
|
-
content: NodeJson[];
|
|
212
|
-
marks: MarkJson[];
|
|
213
|
-
text?: string;
|
|
214
|
-
};
|
|
215
|
-
type SliceJson = {
|
|
216
|
-
content: NodeJson[];
|
|
217
|
-
openStart: number;
|
|
218
|
-
openEnd: number;
|
|
219
|
-
};
|
|
220
|
-
export type StepJson = {
|
|
221
|
-
stepType?: string;
|
|
222
|
-
from?: number;
|
|
223
|
-
to?: number;
|
|
224
|
-
slice?: SliceJson;
|
|
225
|
-
clientId: number | string;
|
|
226
|
-
userId: string;
|
|
227
|
-
createdAt?: number;
|
|
228
|
-
structure?: boolean;
|
|
229
|
-
};
|
|
230
116
|
export declare enum AcknowledgementResponseTypes {
|
|
231
117
|
SUCCESS = "SUCCESS",
|
|
232
118
|
ERROR = "ERROR"
|
|
@@ -297,36 +183,3 @@ export type ProductInformation = {
|
|
|
297
183
|
product: string;
|
|
298
184
|
subProduct?: string;
|
|
299
185
|
};
|
|
300
|
-
export interface CollabEventTelepointerData {
|
|
301
|
-
type: 'telepointer';
|
|
302
|
-
selection: CollabSendableSelection;
|
|
303
|
-
sessionId: string;
|
|
304
|
-
}
|
|
305
|
-
export interface CollabSendableSelection {
|
|
306
|
-
type: 'textSelection' | 'nodeSelection';
|
|
307
|
-
anchor?: number | string;
|
|
308
|
-
head?: number | string;
|
|
309
|
-
}
|
|
310
|
-
export interface CollabEditProvider<Events extends CollabEvents = CollabEvents> {
|
|
311
|
-
initialize(getState: () => any, createStep: (json: object) => Step): this;
|
|
312
|
-
setup(props: {
|
|
313
|
-
getState?: () => EditorState;
|
|
314
|
-
onSyncUpError?: SyncUpErrorFunction;
|
|
315
|
-
}): this;
|
|
316
|
-
send(tr: Transaction, oldState: EditorState, newState: EditorState): void;
|
|
317
|
-
on(evt: keyof Events, handler: (...args: any) => void): this;
|
|
318
|
-
off(evt: keyof Events, handler: (...args: any) => void): this;
|
|
319
|
-
unsubscribeAll(evt: keyof Events): this;
|
|
320
|
-
sendMessage<K extends keyof Events>(data: {
|
|
321
|
-
type: K;
|
|
322
|
-
} & Events[K]): void;
|
|
323
|
-
getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
|
|
324
|
-
}
|
|
325
|
-
export type NewCollabSyncUpErrorAttributes = {
|
|
326
|
-
lengthOfUnconfirmedSteps?: number;
|
|
327
|
-
tries: number;
|
|
328
|
-
maxRetries: number;
|
|
329
|
-
clientId?: number | string;
|
|
330
|
-
version: number;
|
|
331
|
-
};
|
|
332
|
-
export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Emitter } from './emitter';
|
|
2
|
-
import type { Config, ChannelEvent, CatchupResponse
|
|
2
|
+
import type { Config, ChannelEvent, CatchupResponse } from './types';
|
|
3
3
|
import type { Socket } from 'socket.io-client';
|
|
4
4
|
import AnalyticsHelper from './analytics/analytics-helper';
|
|
5
|
+
import type { Metadata } from '@atlaskit/editor-common/collab';
|
|
5
6
|
export declare class Channel extends Emitter<ChannelEvent> {
|
|
6
7
|
private connected;
|
|
7
8
|
private config;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DisconnectReason } from '@atlaskit/editor-common/collab';
|
|
1
2
|
export declare const socketIOReasons: {
|
|
2
3
|
IO_CLIENT_DISCONNECT: string;
|
|
3
4
|
IO_SERVER_DISCONNECT: string;
|
|
@@ -5,12 +6,4 @@ export declare const socketIOReasons: {
|
|
|
5
6
|
TRANSPORT_ERROR: string;
|
|
6
7
|
PING_TIMEOUT: string;
|
|
7
8
|
};
|
|
8
|
-
export declare enum DisconnectReason {
|
|
9
|
-
CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
|
|
10
|
-
SERVER_DISCONNECT = "SERVER_DISCONNECT",
|
|
11
|
-
SOCKET_CLOSED = "SOCKET_CLOSED",
|
|
12
|
-
SOCKET_ERROR = "SOCKET_ERROR",
|
|
13
|
-
SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
|
|
14
|
-
UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
|
|
15
|
-
}
|
|
16
9
|
export declare const disconnectedReasonMapper: (reason: string) => DisconnectReason;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import { CatchupResponse, ChannelEvent,
|
|
3
|
+
import { CatchupResponse, ChannelEvent, StepsPayload } from '../types';
|
|
4
|
+
import type { SyncUpErrorFunction, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
5
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
5
6
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
|
-
import {
|
|
7
|
+
import type { CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
7
8
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
8
9
|
import { ParticipantsService } from '../participants/participants-service';
|
|
9
10
|
import type { InternalError } from '../errors/error-types';
|