@atlaskit/collab-provider 8.2.0 → 8.4.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 +49 -0
- package/dist/cjs/analytics/index.js +67 -9
- package/dist/cjs/analytics/performance.js +46 -35
- package/dist/cjs/analytics/ufo.js +33 -0
- package/dist/cjs/channel.js +307 -162
- package/dist/cjs/connectivity/network.js +53 -0
- package/dist/cjs/connectivity/reconnect-helper.js +48 -0
- package/dist/cjs/connectivity/singleton.js +15 -0
- package/dist/cjs/disconnected-reason-mapper.js +19 -2
- package/dist/cjs/{error-code-mapper.js → errors/error-code-mapper.js} +17 -2
- package/dist/cjs/errors/error-types.js +43 -0
- package/dist/cjs/helpers/const.js +4 -11
- package/dist/cjs/provider/catchup.js +8 -12
- package/dist/cjs/provider/commit-step.js +70 -0
- package/dist/cjs/provider/index.js +503 -566
- package/dist/cjs/provider/telepointers.js +78 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +58 -8
- package/dist/es2019/analytics/performance.js +47 -35
- package/dist/es2019/analytics/ufo.js +22 -0
- package/dist/es2019/channel.js +192 -93
- package/dist/es2019/connectivity/network.js +34 -0
- package/dist/es2019/connectivity/reconnect-helper.js +29 -0
- package/dist/es2019/connectivity/singleton.js +7 -0
- package/dist/es2019/disconnected-reason-mapper.js +17 -1
- package/dist/es2019/{error-code-mapper.js → errors/error-code-mapper.js} +17 -2
- package/dist/es2019/errors/error-types.js +13 -0
- package/dist/es2019/helpers/const.js +3 -8
- package/dist/es2019/provider/catchup.js +5 -12
- package/dist/es2019/provider/commit-step.js +57 -0
- package/dist/es2019/provider/index.js +428 -515
- package/dist/es2019/provider/telepointers.js +65 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +68 -9
- package/dist/esm/analytics/performance.js +47 -35
- package/dist/esm/analytics/ufo.js +25 -0
- package/dist/esm/channel.js +308 -165
- package/dist/esm/connectivity/network.js +45 -0
- package/dist/esm/connectivity/reconnect-helper.js +42 -0
- package/dist/esm/connectivity/singleton.js +7 -0
- package/dist/esm/disconnected-reason-mapper.js +17 -1
- package/dist/esm/{error-code-mapper.js → errors/error-code-mapper.js} +17 -2
- package/dist/esm/errors/error-types.js +34 -0
- package/dist/esm/helpers/const.js +3 -8
- package/dist/esm/provider/catchup.js +8 -12
- package/dist/esm/provider/commit-step.js +62 -0
- package/dist/esm/provider/index.js +504 -567
- package/dist/esm/provider/telepointers.js +69 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/index.d.ts +8 -2
- package/dist/types/analytics/performance.d.ts +6 -5
- package/dist/types/analytics/ufo.d.ts +3 -0
- package/dist/types/channel.d.ts +16 -5
- package/dist/types/connectivity/network.d.ts +17 -0
- package/dist/types/connectivity/reconnect-helper.d.ts +8 -0
- package/dist/types/connectivity/singleton.d.ts +3 -0
- package/dist/types/disconnected-reason-mapper.d.ts +1 -0
- package/dist/types/{error-code-mapper.d.ts → errors/error-code-mapper.d.ts} +6 -2
- package/dist/types/errors/error-types.d.ts +8 -0
- package/dist/types/helpers/const.d.ts +133 -26
- package/dist/types/provider/commit-step.d.ts +14 -0
- package/dist/types/provider/index.d.ts +24 -6
- package/dist/types/provider/telepointers.d.ts +5 -0
- package/dist/types/socket-io-provider.d.ts +3 -2
- package/dist/types/types.d.ts +44 -12
- package/package.json +5 -6
- package/report.api.md +49 -3
- package/.vscode/settings.json +0 -3
- package/error-code-mapper/package.json +0 -15
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import { createLogger } from '../helpers/utils';
|
|
4
|
+
import { ExperiencePerformanceTypes, ExperienceTypes, UFOExperience } from '@atlaskit/ufo';
|
|
5
|
+
import { AcknowledgementResponseTypes } from '../types';
|
|
6
|
+
var logger = createLogger('Telepointer', 'green');
|
|
7
|
+
export var telepointersFromStep = function telepointersFromStep(participants, step) {
|
|
8
|
+
var _Array$from$filter = Array.from(participants.values()).filter(function (p) {
|
|
9
|
+
return p.clientId === step.clientId;
|
|
10
|
+
}),
|
|
11
|
+
_Array$from$filter2 = _slicedToArray(_Array$from$filter, 1),
|
|
12
|
+
participant = _Array$from$filter2[0];
|
|
13
|
+
if (participant) {
|
|
14
|
+
var _node$text;
|
|
15
|
+
var stepType = step.stepType,
|
|
16
|
+
to = step.to,
|
|
17
|
+
from = step.from,
|
|
18
|
+
_step$slice = step.slice,
|
|
19
|
+
slice = _step$slice === void 0 ? {
|
|
20
|
+
content: []
|
|
21
|
+
} : _step$slice;
|
|
22
|
+
var _slice$content = _slicedToArray(slice.content, 1),
|
|
23
|
+
node = _slice$content[0];
|
|
24
|
+
if (to && from && stepType === 'replace' && to === from && slice.content.length === 1 && (node === null || node === void 0 ? void 0 : node.type) === 'text' && (node === null || node === void 0 ? void 0 : (_node$text = node.text) === null || _node$text === void 0 ? void 0 : _node$text.length) === 1) {
|
|
25
|
+
return {
|
|
26
|
+
sessionId: participant.sessionId,
|
|
27
|
+
selection: {
|
|
28
|
+
type: 'textSelection',
|
|
29
|
+
anchor: from + 1,
|
|
30
|
+
head: to + 1
|
|
31
|
+
},
|
|
32
|
+
type: 'telepointer'
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export var telepointerCallback = function telepointerCallback(documentAri) {
|
|
38
|
+
var telepointerExperience = new UFOExperience('collab-provider.telepointer', {
|
|
39
|
+
type: ExperienceTypes.Operation,
|
|
40
|
+
performanceType: ExperiencePerformanceTypes.Custom,
|
|
41
|
+
performanceConfig: {
|
|
42
|
+
histogram: _defineProperty({}, ExperiencePerformanceTypes.Custom, {
|
|
43
|
+
duration: '250_500_1000_1500_2000_3000_4000'
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
telepointerExperience.addMetadata({
|
|
48
|
+
documentAri: documentAri
|
|
49
|
+
});
|
|
50
|
+
telepointerExperience.start();
|
|
51
|
+
return function (response) {
|
|
52
|
+
if (response.type === AcknowledgementResponseTypes.SUCCESS) {
|
|
53
|
+
telepointerExperience.success();
|
|
54
|
+
} else if (response.type === AcknowledgementResponseTypes.ERROR) {
|
|
55
|
+
var errorMessage = response.error;
|
|
56
|
+
telepointerExperience.addMetadata({
|
|
57
|
+
error: errorMessage
|
|
58
|
+
});
|
|
59
|
+
logger('Error from collab service with telepointer broadcast', errorMessage);
|
|
60
|
+
telepointerExperience.failure();
|
|
61
|
+
} else {
|
|
62
|
+
logger('Invalid ACK from collab service with telepointer broadcast');
|
|
63
|
+
telepointerExperience.addMetadata({
|
|
64
|
+
error: 'Invalid ACK from collab service with telepointer broadcast'
|
|
65
|
+
});
|
|
66
|
+
telepointerExperience.failure();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
2
|
+
import type { ActionAnalyticsEvent, EVENT_STATUS } from '../helpers/const';
|
|
3
|
+
export default class AnalyticsHelper {
|
|
4
|
+
analyticsClient: AnalyticsWebClient | undefined;
|
|
5
|
+
documentAri: string;
|
|
6
|
+
constructor(documentAri: string, analyticsClient?: AnalyticsWebClient);
|
|
7
|
+
sendErrorEvent(error: unknown, errorMessage: string): void;
|
|
8
|
+
sendActionEvent(action: ActionAnalyticsEvent['eventAction'], status: EVENT_STATUS, attributes?: Omit<ActionAnalyticsEvent['attributes'], 'documentAri' | 'eventStatus'>): void;
|
|
9
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import AnalyticsHelper from '.';
|
|
1
2
|
export declare enum MEASURE_NAME {
|
|
2
3
|
SOCKET_CONNECT = "socketConnect",
|
|
3
4
|
DOCUMENT_INIT = "documentInit",
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
COMMIT_UNCONFIRMED_STEPS = "commitUnconfirmedSteps",
|
|
6
|
+
PUBLISH_PAGE = "publishPage",
|
|
7
|
+
GET_CURRENT_STATE = "getCurrentState"
|
|
6
8
|
}
|
|
7
|
-
export declare function startMeasure(measureName: MEASURE_NAME): void;
|
|
8
|
-
export declare function stopMeasure(measureName: MEASURE_NAME, onMeasureComplete?: (duration: number, startTime: number) => void): {
|
|
9
|
+
export declare function startMeasure(measureName: MEASURE_NAME, analyticsHelper: AnalyticsHelper | undefined): void;
|
|
10
|
+
export declare function stopMeasure(measureName: MEASURE_NAME, analyticsHelper: AnalyticsHelper | undefined, onMeasureComplete?: (duration: number, startTime: number) => void): {
|
|
9
11
|
duration: number;
|
|
10
12
|
startTime: number;
|
|
11
13
|
} | undefined;
|
|
12
|
-
export declare function clearMeasure(measureName: string): void;
|
package/dist/types/channel.d.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import { Emitter } from './emitter';
|
|
2
|
-
import type { Config,
|
|
2
|
+
import type { Config, ChannelEvent, CatchupResponse, Metadata } from './types';
|
|
3
|
+
import type { Socket } from 'socket.io-client';
|
|
4
|
+
import AnalyticsHelper from './analytics';
|
|
3
5
|
export declare class Channel extends Emitter<ChannelEvent> {
|
|
4
6
|
private connected;
|
|
5
7
|
private config;
|
|
6
8
|
private socket;
|
|
9
|
+
private reconnectHelper?;
|
|
7
10
|
private initialized;
|
|
8
|
-
private
|
|
9
|
-
private initExperience
|
|
10
|
-
|
|
11
|
+
private analyticsHelper?;
|
|
12
|
+
private initExperience?;
|
|
13
|
+
private token?;
|
|
14
|
+
private network;
|
|
15
|
+
constructor(config: Config, analyticsHelper: AnalyticsHelper);
|
|
11
16
|
getInitialized: () => boolean;
|
|
12
17
|
getConnected: () => boolean;
|
|
13
|
-
getSocket: () => Socket | null;
|
|
18
|
+
getSocket: () => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null;
|
|
19
|
+
getToken: () => string | undefined;
|
|
20
|
+
private setToken;
|
|
21
|
+
private unsetToken;
|
|
14
22
|
/**
|
|
15
23
|
* Connect to collab service using websockets
|
|
16
24
|
*/
|
|
17
25
|
connect(): void;
|
|
26
|
+
private handlePermissionInvalidateToken;
|
|
18
27
|
private onConnectError;
|
|
28
|
+
private onReconnectError;
|
|
19
29
|
private onConnect;
|
|
20
30
|
private onReceiveData;
|
|
21
31
|
fetchCatchup(fromVersion: number): Promise<CatchupResponse>;
|
|
@@ -25,5 +35,6 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
25
35
|
broadcast<K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function): void;
|
|
26
36
|
sendMetadata(metadata: Metadata): void;
|
|
27
37
|
sendPresenceJoined(): void;
|
|
38
|
+
onOnlineHandler: () => void;
|
|
28
39
|
disconnect(): void;
|
|
29
40
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum NetworkStatus {
|
|
2
|
+
ONLINE = "ONLINE",
|
|
3
|
+
OFFLINE = "OFFLINE"
|
|
4
|
+
}
|
|
5
|
+
export interface NetworkProps {
|
|
6
|
+
initialStatus?: NetworkStatus;
|
|
7
|
+
onlineCallback?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export default class Network {
|
|
10
|
+
status?: NetworkStatus;
|
|
11
|
+
onlineCallback?: () => void;
|
|
12
|
+
constructor(props?: NetworkProps);
|
|
13
|
+
private offlineHandler;
|
|
14
|
+
private onlineHandler;
|
|
15
|
+
getStatus(): NetworkStatus | null;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollabErrorPayload, ErrorPayload } from '
|
|
1
|
+
import type { CollabErrorPayload, ErrorPayload } from '../types';
|
|
2
2
|
export declare const ErrorCodeMapper: {
|
|
3
3
|
noPermissionError: {
|
|
4
4
|
code: string;
|
|
@@ -24,9 +24,13 @@ export declare const ErrorCodeMapper: {
|
|
|
24
24
|
code: string;
|
|
25
25
|
message: string;
|
|
26
26
|
};
|
|
27
|
+
restoreError: {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
27
31
|
internalError: {
|
|
28
32
|
code: string;
|
|
29
33
|
message: string;
|
|
30
34
|
};
|
|
31
35
|
};
|
|
32
|
-
export declare const errorCodeMapper: (error: ErrorPayload) => CollabErrorPayload;
|
|
36
|
+
export declare const errorCodeMapper: (error: ErrorPayload) => CollabErrorPayload | undefined;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { CollabErrorPayload
|
|
2
|
-
export declare const EVENT_SUBJECT = "collab";
|
|
3
|
-
export declare enum COLLAB_SERVICE {
|
|
4
|
-
NCS = "ncs",
|
|
5
|
-
SYNCHRONY = "synchrony"
|
|
6
|
-
}
|
|
1
|
+
import type { CollabErrorPayload } from '../types';
|
|
7
2
|
export declare enum EVENT_ACTION {
|
|
8
3
|
CONNECTION = "connection",
|
|
9
4
|
CATCHUP = "catchup",
|
|
10
5
|
DOCUMENT_INIT = "documentInit",
|
|
11
6
|
ADD_STEPS = "addSteps",
|
|
12
|
-
CONVERT_PM_TO_ADF = "convertPMToADF",
|
|
13
7
|
UPDATE_PARTICIPANTS = "updateParticipants",
|
|
14
8
|
COMMIT_UNCONFIRMED_STEPS = "commitUnconfirmedSteps",
|
|
15
9
|
REINITIALISE_DOCUMENT = "reinitialiseDocument",
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
ERROR = "error",
|
|
11
|
+
PUBLISH_PAGE = "publishPage",
|
|
12
|
+
GET_CURRENT_STATE = "getCurrentState",
|
|
13
|
+
INVALIDATE_TOKEN = "invalidateToken"
|
|
18
14
|
}
|
|
19
15
|
export declare enum EVENT_STATUS {
|
|
20
16
|
SUCCESS = "SUCCESS",
|
|
@@ -25,12 +21,32 @@ export declare enum ADD_STEPS_TYPE {
|
|
|
25
21
|
REJECTED = "REJECTED",
|
|
26
22
|
ERROR = "ERROR"
|
|
27
23
|
}
|
|
24
|
+
export declare type ErrorAnalyticsEvent = {
|
|
25
|
+
eventAction: EVENT_ACTION.ERROR;
|
|
26
|
+
attributes: {
|
|
27
|
+
errorMessage: string;
|
|
28
|
+
errorName?: string;
|
|
29
|
+
documentAri?: string;
|
|
30
|
+
mappedError?: CollabErrorPayload;
|
|
31
|
+
};
|
|
32
|
+
nonPrivacySafeAttributes: {
|
|
33
|
+
error: unknown;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
declare type InvalidateTokenAnalyticsEvent = {
|
|
37
|
+
eventAction: EVENT_ACTION.INVALIDATE_TOKEN;
|
|
38
|
+
attributes: {
|
|
39
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
40
|
+
reason?: string;
|
|
41
|
+
usedCachedToken?: boolean;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
28
44
|
declare type AddStepsSuccessAnalyticsEvent = {
|
|
29
45
|
eventAction: EVENT_ACTION.ADD_STEPS;
|
|
30
46
|
attributes: {
|
|
47
|
+
documentAri: string;
|
|
31
48
|
eventStatus: EVENT_STATUS.SUCCESS;
|
|
32
49
|
type: ADD_STEPS_TYPE.ACCEPTED;
|
|
33
|
-
documentAri: string;
|
|
34
50
|
latency?: number;
|
|
35
51
|
stepType?: {
|
|
36
52
|
[key: string]: number;
|
|
@@ -40,38 +56,129 @@ declare type AddStepsSuccessAnalyticsEvent = {
|
|
|
40
56
|
declare type AddStepsFailureAnalyticsEvent = {
|
|
41
57
|
eventAction: EVENT_ACTION.ADD_STEPS;
|
|
42
58
|
attributes: {
|
|
59
|
+
documentAri: string;
|
|
43
60
|
eventStatus: EVENT_STATUS.FAILURE;
|
|
44
61
|
type: ADD_STEPS_TYPE.REJECTED | ADD_STEPS_TYPE.ERROR;
|
|
62
|
+
latency?: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
declare type ReInitDocFailAnalyticsEvent = {
|
|
66
|
+
eventAction: EVENT_ACTION.REINITIALISE_DOCUMENT;
|
|
67
|
+
attributes: {
|
|
45
68
|
documentAri: string;
|
|
69
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
70
|
+
numUnconfirmedSteps: number;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
declare type ReInitDocSuccessAnalyticsEvent = {
|
|
74
|
+
eventAction: EVENT_ACTION.REINITIALISE_DOCUMENT;
|
|
75
|
+
attributes: {
|
|
76
|
+
documentAri: string;
|
|
77
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
78
|
+
numUnconfirmedSteps: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
declare type ConnectionSuccessAnalyticsEvent = {
|
|
82
|
+
eventAction: EVENT_ACTION.CONNECTION;
|
|
83
|
+
attributes: {
|
|
84
|
+
documentAri: string;
|
|
85
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
46
86
|
latency?: number;
|
|
47
|
-
error: ErrorPayload;
|
|
48
87
|
};
|
|
49
88
|
};
|
|
50
|
-
declare type
|
|
51
|
-
eventAction: EVENT_ACTION.
|
|
89
|
+
declare type ConnectionFailureAnalyticsEvent = {
|
|
90
|
+
eventAction: EVENT_ACTION.CONNECTION;
|
|
52
91
|
attributes: {
|
|
53
|
-
attemptedAction?: EVENT_ACTION;
|
|
54
92
|
documentAri: string;
|
|
55
|
-
|
|
93
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
94
|
+
latency?: number;
|
|
56
95
|
};
|
|
57
|
-
|
|
58
|
-
|
|
96
|
+
};
|
|
97
|
+
declare type CatchUpSuccessAnalyticsEvent = {
|
|
98
|
+
eventAction: EVENT_ACTION.CATCHUP;
|
|
99
|
+
attributes: {
|
|
100
|
+
documentAri: string;
|
|
101
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
102
|
+
latency?: number;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
declare type CatchUpFailureAnalyticsEvent = {
|
|
106
|
+
eventAction: EVENT_ACTION.CATCHUP;
|
|
107
|
+
attributes: {
|
|
108
|
+
documentAri: string;
|
|
109
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
110
|
+
latency?: number;
|
|
59
111
|
};
|
|
60
112
|
};
|
|
61
|
-
|
|
62
|
-
eventAction: EVENT_ACTION.
|
|
113
|
+
declare type DocumentInitSuccessAnalyticsEvent = {
|
|
114
|
+
eventAction: EVENT_ACTION.DOCUMENT_INIT;
|
|
115
|
+
attributes: {
|
|
116
|
+
documentAri: string;
|
|
117
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
118
|
+
latency?: number;
|
|
119
|
+
resetReason?: string;
|
|
120
|
+
ttlEnabled?: boolean;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
declare type UpdateParticipantsSuccessAnalyticsEvent = {
|
|
124
|
+
eventAction: EVENT_ACTION.UPDATE_PARTICIPANTS;
|
|
63
125
|
attributes: {
|
|
64
126
|
documentAri?: string;
|
|
65
|
-
eventStatus
|
|
66
|
-
|
|
127
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
128
|
+
participants: number;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
declare type CommitUnconfirmedStepsSuccessAnalyticsEvent = {
|
|
132
|
+
eventAction: EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS;
|
|
133
|
+
attributes: {
|
|
134
|
+
documentAri: string;
|
|
135
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
67
136
|
latency?: number;
|
|
68
|
-
error?: ErrorPayload;
|
|
69
|
-
participants?: number;
|
|
70
137
|
numUnconfirmedSteps?: number;
|
|
71
|
-
requiredPageRecovery?: boolean;
|
|
72
|
-
ttlEnabled?: boolean;
|
|
73
138
|
};
|
|
74
|
-
}
|
|
139
|
+
};
|
|
140
|
+
declare type CommitUnconfirmedStepsFailureAnalyticsEvent = {
|
|
141
|
+
eventAction: EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS;
|
|
142
|
+
attributes: {
|
|
143
|
+
documentAri: string;
|
|
144
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
145
|
+
latency?: number;
|
|
146
|
+
numUnconfirmedSteps?: number;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
declare type PublishPageSuccessAnalyticsEvent = {
|
|
150
|
+
eventAction: EVENT_ACTION.PUBLISH_PAGE;
|
|
151
|
+
attributes: {
|
|
152
|
+
documentAri: string;
|
|
153
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
154
|
+
latency?: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
declare type PublishPageFailureAnalyticsEvent = {
|
|
158
|
+
eventAction: EVENT_ACTION.PUBLISH_PAGE;
|
|
159
|
+
attributes: {
|
|
160
|
+
documentAri: string;
|
|
161
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
162
|
+
latency?: number;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
declare type GetCurrentStateSuccessAnalyticsEvent = {
|
|
166
|
+
eventAction: EVENT_ACTION.GET_CURRENT_STATE;
|
|
167
|
+
attributes: {
|
|
168
|
+
documentAri: string;
|
|
169
|
+
eventStatus: EVENT_STATUS.SUCCESS;
|
|
170
|
+
latency?: number;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
declare type GetCurrentStateFailureAnalyticsEvent = {
|
|
174
|
+
eventAction: EVENT_ACTION.GET_CURRENT_STATE;
|
|
175
|
+
attributes: {
|
|
176
|
+
documentAri: string;
|
|
177
|
+
eventStatus: EVENT_STATUS.FAILURE;
|
|
178
|
+
latency?: number;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export declare type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
|
|
75
182
|
export declare const ACK_MAX_TRY = 30;
|
|
76
183
|
export declare const CONFLUENCE = "confluence";
|
|
77
184
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ErrorPayload, StepsPayload } from '../types';
|
|
2
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
3
|
+
import type { Channel } from '../channel';
|
|
4
|
+
import AnalyticsHelper from '../analytics';
|
|
5
|
+
export declare const commitStep: ({ channel, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
|
|
6
|
+
channel: Channel;
|
|
7
|
+
steps: readonly ProseMirrorStep[];
|
|
8
|
+
version: number;
|
|
9
|
+
userId: string;
|
|
10
|
+
clientId: number | string;
|
|
11
|
+
onStepsAdded: (data: StepsPayload) => void;
|
|
12
|
+
onErrorHandled: (error: ErrorPayload) => void;
|
|
13
|
+
analyticsHelper?: AnalyticsHelper | undefined;
|
|
14
|
+
}) => void;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
1
2
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
4
|
import { Emitter } from '../emitter';
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
5
|
+
import { Channel } from '../channel';
|
|
6
|
+
import type { CollabEditProvider, CollabParticipant, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
7
|
+
import type { CollabEvents, Config, ErrorPayload, Metadata, StepsPayload } from '../types';
|
|
8
|
+
import AnalyticsHelper from '../analytics';
|
|
5
9
|
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
6
|
-
export declare const CATCHUP_THROTTLE: number;
|
|
7
10
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
11
|
+
export declare const throttledCommitStep: import("lodash").DebouncedFunc<({ channel, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, }: {
|
|
12
|
+
channel: Channel;
|
|
13
|
+
steps: readonly ProseMirrorStep<any>[];
|
|
14
|
+
version: number;
|
|
15
|
+
userId: string;
|
|
16
|
+
clientId: string | number;
|
|
17
|
+
onStepsAdded: (data: StepsPayload) => void;
|
|
18
|
+
onErrorHandled: (error: ErrorPayload) => void;
|
|
19
|
+
analyticsHelper?: AnalyticsHelper | undefined;
|
|
20
|
+
}) => void>;
|
|
8
21
|
declare type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
22
|
+
export declare type ParticipantsMap = Map<string, CollabParticipant & {
|
|
23
|
+
userId: string;
|
|
24
|
+
clientId: number | string;
|
|
25
|
+
}>;
|
|
9
26
|
export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
10
27
|
private participants;
|
|
11
28
|
private channel;
|
|
@@ -13,7 +30,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
13
30
|
private getState;
|
|
14
31
|
private metadata;
|
|
15
32
|
private stepRejectCounter;
|
|
16
|
-
private
|
|
33
|
+
private analyticsHelper?;
|
|
17
34
|
private isChannelInitialized;
|
|
18
35
|
private isNamespaceLocked;
|
|
19
36
|
private onSyncUpError?;
|
|
@@ -58,6 +75,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
58
75
|
private applyLocalSteps;
|
|
59
76
|
private getCurrentPmVersion;
|
|
60
77
|
private getUnconfirmedSteps;
|
|
78
|
+
private getUnconfirmedStepsOrigins;
|
|
61
79
|
/**
|
|
62
80
|
* Called when:
|
|
63
81
|
* * session established(offline -> online)
|
|
@@ -66,7 +84,6 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
66
84
|
private catchup;
|
|
67
85
|
/**
|
|
68
86
|
* @param error - The error to handle
|
|
69
|
-
* @param disableAnalytics - If analytics is already dispatched for this error, re-sending it here can be disabled
|
|
70
87
|
*/
|
|
71
88
|
private onErrorHandled;
|
|
72
89
|
private pauseQueue?;
|
|
@@ -115,13 +132,14 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
115
132
|
*/
|
|
116
133
|
private updateParticipants;
|
|
117
134
|
private emitTelepointersFromSteps;
|
|
118
|
-
private disconnectedReasonMapper;
|
|
119
135
|
private onDisconnected;
|
|
120
136
|
destroy(): this;
|
|
121
137
|
disconnect(): this;
|
|
122
138
|
setTitle(title: string, broadcast?: boolean): void;
|
|
123
139
|
setEditorWidth(editorWidth: string, broadcast?: boolean): void;
|
|
124
140
|
setMetadata(metadata: Metadata): void;
|
|
141
|
+
getCurrentState: () => Promise<ResolvedEditorState>;
|
|
142
|
+
private commitUnconfirmedSteps;
|
|
125
143
|
getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
|
|
126
144
|
/**
|
|
127
145
|
* Unsubscribe from all events emitted by this provider.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CollabEventTelepointerData } from '@atlaskit/editor-common/collab';
|
|
2
|
+
import { AcknowledgementPayload, StepJson } from '../types';
|
|
3
|
+
import { ParticipantsMap } from './index';
|
|
4
|
+
export declare const telepointersFromStep: (participants: ParticipantsMap, step: StepJson) => CollabEventTelepointerData | undefined;
|
|
5
|
+
export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Provider } from './provider';
|
|
2
|
-
import { Socket
|
|
3
|
-
|
|
2
|
+
import { Socket } from 'socket.io-client';
|
|
3
|
+
import { Config, ProductInformation, InitAndAuthData, AuthCallback } from './types';
|
|
4
|
+
export declare function createSocketIOSocket(url: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation): Socket;
|
|
4
5
|
export declare function createSocketIOCollabProvider(config: Omit<Config, 'createSocket'>): Provider;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
|
+
import type { Transaction as ProseMirrorTransaction } from 'prosemirror-state';
|
|
3
3
|
import type { CollabParticipant, CollabEventTelepointerData, CollabEventConnectionData, CollabEventInitData, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData } from '@atlaskit/editor-common/collab';
|
|
4
4
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
5
5
|
import type { Manager } from 'socket.io-client';
|
|
@@ -15,7 +15,7 @@ export interface Config {
|
|
|
15
15
|
lifecycle?: Lifecycle;
|
|
16
16
|
storage?: Storage;
|
|
17
17
|
need404?: boolean;
|
|
18
|
-
createSocket: (path: string, auth?:
|
|
18
|
+
createSocket: (path: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation) => Socket;
|
|
19
19
|
analyticsClient?: AnalyticsWebClient;
|
|
20
20
|
featureFlags?: {
|
|
21
21
|
[key: string]: boolean;
|
|
@@ -23,9 +23,24 @@ export interface Config {
|
|
|
23
23
|
getUser?(userId: string): Promise<Pick<CollabParticipant, 'avatar' | 'email' | 'name'> & {
|
|
24
24
|
userId: string;
|
|
25
25
|
}>;
|
|
26
|
+
/**
|
|
27
|
+
* If provided, permissionTokenRefresh is called whenever a new JWT token is required.
|
|
28
|
+
*/
|
|
26
29
|
permissionTokenRefresh?: () => Promise<string | null>;
|
|
30
|
+
cacheToken?: boolean;
|
|
27
31
|
productInfo?: ProductInformation;
|
|
32
|
+
/**
|
|
33
|
+
* Throws errors when trying to send data to collab but the client is not offline.
|
|
34
|
+
* This can lead to potential dataloss and retrying should be considered. Without this flag the provider silently drops the requests.
|
|
35
|
+
*/
|
|
36
|
+
throwOnNotConnected?: boolean;
|
|
28
37
|
}
|
|
38
|
+
export interface InitAndAuthData {
|
|
39
|
+
initialized: boolean;
|
|
40
|
+
need404?: boolean;
|
|
41
|
+
token?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare type AuthCallback = (cb: (data: InitAndAuthData) => void) => void;
|
|
29
44
|
interface SimpleEventEmitter {
|
|
30
45
|
on(event: string, fn: Function): SimpleEventEmitter;
|
|
31
46
|
}
|
|
@@ -69,7 +84,7 @@ export declare type CollabTelepointerPayload = CollabEventTelepointerData;
|
|
|
69
84
|
export declare type CollabPresencePayload = CollabEventPresenceData;
|
|
70
85
|
export declare type CollabMetadataPayload = Metadata;
|
|
71
86
|
export declare type CollabLocalStepsPayload = {
|
|
72
|
-
steps: readonly
|
|
87
|
+
steps: readonly ProseMirrorStep[];
|
|
73
88
|
};
|
|
74
89
|
export interface CollabEvents {
|
|
75
90
|
'metadata:changed': CollabMetadataPayload;
|
|
@@ -106,10 +121,31 @@ export declare type TelepointerPayload = PresencePayload & {
|
|
|
106
121
|
head: number;
|
|
107
122
|
};
|
|
108
123
|
};
|
|
124
|
+
declare type MarkJson = {
|
|
125
|
+
type: string;
|
|
126
|
+
attrs: {
|
|
127
|
+
[key: string]: any;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
declare type NodeJson = {
|
|
131
|
+
type: string;
|
|
132
|
+
attrs: {
|
|
133
|
+
[key: string]: any;
|
|
134
|
+
};
|
|
135
|
+
content: NodeJson[];
|
|
136
|
+
marks: MarkJson[];
|
|
137
|
+
text?: string;
|
|
138
|
+
};
|
|
139
|
+
declare type SliceJson = {
|
|
140
|
+
content: NodeJson[];
|
|
141
|
+
openStart: number;
|
|
142
|
+
openEnd: number;
|
|
143
|
+
};
|
|
109
144
|
export declare type StepJson = {
|
|
145
|
+
stepType?: string;
|
|
110
146
|
from?: number;
|
|
111
147
|
to?: number;
|
|
112
|
-
|
|
148
|
+
slice?: SliceJson;
|
|
113
149
|
clientId: number | string;
|
|
114
150
|
userId: string;
|
|
115
151
|
createdAt?: number;
|
|
@@ -186,14 +222,10 @@ export interface CatchupOptions {
|
|
|
186
222
|
getCurrentPmVersion: () => number;
|
|
187
223
|
fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>;
|
|
188
224
|
filterQueue: (condition: (stepsPayload: StepsPayload) => boolean) => void;
|
|
189
|
-
getUnconfirmedSteps: () =>
|
|
190
|
-
|
|
191
|
-
steps: readonly Step<any>[];
|
|
192
|
-
clientID: string | number;
|
|
193
|
-
origins: readonly Transaction<any>[];
|
|
194
|
-
} | null | undefined;
|
|
225
|
+
getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
|
|
226
|
+
getUnconfirmedStepsOrigins: () => readonly ProseMirrorTransaction[] | undefined;
|
|
195
227
|
updateDocumentWithMetadata: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
196
|
-
applyLocalSteps: (steps:
|
|
228
|
+
applyLocalSteps: (steps: ProseMirrorStep[]) => void;
|
|
197
229
|
}
|
|
198
230
|
export declare type ProductInformation = {
|
|
199
231
|
product: string;
|