@atlaskit/collab-provider 9.18.0 → 9.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics/analytics-helper.js +2 -2
  3. package/dist/cjs/channel.js +14 -12
  4. package/dist/cjs/document/document-service.js +7 -6
  5. package/dist/cjs/errors/{error-types.js → custom-errors.js} +1 -68
  6. package/dist/cjs/errors/error-code-mapper.js +27 -26
  7. package/dist/cjs/errors/internal-errors.js +40 -0
  8. package/dist/cjs/errors/ncs-errors.js +37 -0
  9. package/dist/cjs/provider/commit-step.js +3 -3
  10. package/dist/cjs/provider/index.js +14 -13
  11. package/dist/cjs/version-wrapper.js +1 -1
  12. package/dist/es2019/analytics/analytics-helper.js +1 -1
  13. package/dist/es2019/channel.js +3 -1
  14. package/dist/es2019/document/document-service.js +2 -1
  15. package/dist/es2019/errors/custom-errors.js +92 -0
  16. package/dist/es2019/errors/error-code-mapper.js +2 -2
  17. package/dist/es2019/errors/internal-errors.js +39 -0
  18. package/dist/es2019/errors/ncs-errors.js +34 -0
  19. package/dist/es2019/provider/commit-step.js +1 -1
  20. package/dist/es2019/provider/index.js +2 -1
  21. package/dist/es2019/version-wrapper.js +1 -1
  22. package/dist/esm/analytics/analytics-helper.js +1 -1
  23. package/dist/esm/channel.js +3 -1
  24. package/dist/esm/document/document-service.js +2 -1
  25. package/dist/esm/errors/{error-types.js → custom-errors.js} +0 -73
  26. package/dist/esm/errors/error-code-mapper.js +2 -2
  27. package/dist/esm/errors/internal-errors.js +39 -0
  28. package/dist/esm/errors/ncs-errors.js +34 -0
  29. package/dist/esm/provider/commit-step.js +1 -1
  30. package/dist/esm/provider/index.js +2 -1
  31. package/dist/esm/version-wrapper.js +1 -1
  32. package/dist/types/document/document-service.d.ts +1 -1
  33. package/dist/types/errors/custom-errors.d.ts +56 -0
  34. package/dist/types/errors/error-code-mapper.d.ts +2 -2
  35. package/dist/types/errors/internal-errors.d.ts +90 -0
  36. package/dist/types/errors/ncs-errors.d.ts +172 -0
  37. package/dist/types/provider/commit-step.d.ts +1 -1
  38. package/dist/types/types.d.ts +1 -1
  39. package/dist/types-ts4.5/document/document-service.d.ts +1 -1
  40. package/dist/types-ts4.5/errors/custom-errors.d.ts +56 -0
  41. package/dist/types-ts4.5/errors/error-code-mapper.d.ts +2 -2
  42. package/dist/types-ts4.5/errors/internal-errors.d.ts +90 -0
  43. package/dist/types-ts4.5/errors/ncs-errors.d.ts +172 -0
  44. package/dist/types-ts4.5/provider/commit-step.d.ts +1 -1
  45. package/dist/types-ts4.5/types.d.ts +1 -1
  46. package/package.json +2 -2
  47. package/dist/es2019/errors/error-types.js +0 -165
  48. package/dist/types/errors/error-types.d.ts +0 -315
  49. package/dist/types-ts4.5/errors/error-types.d.ts +0 -315
@@ -0,0 +1,56 @@
1
+ import type { CantSyncUpErrorAttributes, DocumentUpdateErrorAttributes } from '../helpers/const';
2
+ type ValidEventAttributeType = boolean | string | number;
3
+ export declare class CustomError extends Error {
4
+ extraEventAttributes?: {
5
+ [key: string]: ValidEventAttributeType;
6
+ };
7
+ constructor(message: string, error?: unknown, extraEventAttributes?: {
8
+ [key: string]: ValidEventAttributeType;
9
+ });
10
+ toJSON(): {
11
+ name: string;
12
+ message: string;
13
+ };
14
+ getExtraErrorEventAttributes: () => {
15
+ [key: string]: ValidEventAttributeType;
16
+ } | undefined;
17
+ }
18
+ export declare class NotConnectedError extends CustomError {
19
+ name: string;
20
+ }
21
+ export declare class NotInitializedError extends CustomError {
22
+ name: string;
23
+ }
24
+ export declare class ProviderInitialisationError extends CustomError {
25
+ name: string;
26
+ }
27
+ export declare class SendTransactionError extends CustomError {
28
+ name: string;
29
+ }
30
+ export declare class DestroyError extends CustomError {
31
+ name: string;
32
+ }
33
+ export declare class SetTitleError extends CustomError {
34
+ name: string;
35
+ }
36
+ export declare class SetEditorWidthError extends CustomError {
37
+ name: string;
38
+ }
39
+ export declare class SetMetadataError extends CustomError {
40
+ name: string;
41
+ }
42
+ export declare class GetCurrentStateError extends CustomError {
43
+ name: string;
44
+ }
45
+ export declare class GetFinalAcknowledgedStateError extends CustomError {
46
+ name: string;
47
+ }
48
+ export declare class UpdateDocumentError extends CustomError {
49
+ name: string;
50
+ constructor(message: string, extraAttributes: DocumentUpdateErrorAttributes);
51
+ }
52
+ export declare class CantSyncUpError extends CustomError {
53
+ name: string;
54
+ constructor(message: string, extraAttributes: CantSyncUpErrorAttributes);
55
+ }
56
+ export {};
@@ -1,3 +1,3 @@
1
- import { InternalError } from './error-types';
2
- import { ProviderError } from '@atlaskit/editor-common/collab';
1
+ import type { InternalError } from './internal-errors';
2
+ import type { ProviderError } from '@atlaskit/editor-common/collab';
3
3
  export declare const errorCodeMapper: (error: InternalError) => ProviderError | undefined;
@@ -0,0 +1,90 @@
1
+ import type { NCSErrors } from './ncs-errors';
2
+ export declare enum INTERNAL_ERROR_CODE {
3
+ TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
4
+ RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
5
+ CONNECTION_ERROR = "CONNECTION_ERROR",
6
+ RECONNECTION_ERROR = "RECONNECTION_ERROR",
7
+ DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
8
+ CATCHUP_FAILED = "CATCHUP_FAILED",
9
+ DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
10
+ ADD_STEPS_ERROR = "ADD_STEPS_ERROR",
11
+ DOCUMENT_UPDATE_ERROR = "DOCUMENT_UPDATE_ERROR"
12
+ }
13
+ type DocumentRecoveryError = {
14
+ message: string;
15
+ data: {
16
+ code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
17
+ status: number;
18
+ };
19
+ };
20
+ type AddStepsError = {
21
+ message: string;
22
+ data: {
23
+ code: INTERNAL_ERROR_CODE.ADD_STEPS_ERROR;
24
+ status: number;
25
+ };
26
+ };
27
+ export type CatchUpFailedError = {
28
+ message: string;
29
+ data: {
30
+ code: INTERNAL_ERROR_CODE.CATCHUP_FAILED;
31
+ status: number;
32
+ };
33
+ };
34
+ export type TokenPermissionError = {
35
+ message: string;
36
+ data: {
37
+ code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR;
38
+ status: number;
39
+ meta: {
40
+ originalError?: unknown;
41
+ reason?: string;
42
+ };
43
+ };
44
+ };
45
+ export type ReconnectionError = {
46
+ message: string;
47
+ data: {
48
+ code: INTERNAL_ERROR_CODE.RECONNECTION_ERROR;
49
+ status: number;
50
+ };
51
+ };
52
+ export type ConnectionError = {
53
+ message: string;
54
+ data: {
55
+ code: INTERNAL_ERROR_CODE.CONNECTION_ERROR;
56
+ };
57
+ };
58
+ export type ReconnectionNetworkError = {
59
+ message: string;
60
+ data: {
61
+ code: INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE;
62
+ };
63
+ };
64
+ export type DocumentNotFoundError = {
65
+ message: string;
66
+ data: {
67
+ code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND;
68
+ status: number;
69
+ };
70
+ };
71
+ /**
72
+ * When we try to apply state updates to the editor, if that fails to apply the user can enter an invalid state where no
73
+ * changes can be saved to NCS.
74
+ */
75
+ export type InternalDocumentUpdateFailure = {
76
+ message: 'The provider failed to apply changes to the editor';
77
+ data: {
78
+ code: INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR;
79
+ meta: {
80
+ newVersion?: number;
81
+ editorVersion?: number;
82
+ };
83
+ status: 500;
84
+ };
85
+ };
86
+ /**
87
+ * A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
88
+ */
89
+ export type InternalError = NCSErrors | DocumentRecoveryError | AddStepsError | CatchUpFailedError | TokenPermissionError | ReconnectionError | ConnectionError | ReconnectionNetworkError | DocumentNotFoundError | InternalDocumentUpdateFailure;
90
+ export {};
@@ -0,0 +1,172 @@
1
+ export declare enum NCS_ERROR_CODE {
2
+ HEAD_VERSION_UPDATE_FAILED = "HEAD_VERSION_UPDATE_FAILED",
3
+ VERSION_NUMBER_ALREADY_EXISTS = "VERSION_NUMBER_ALREADY_EXISTS",
4
+ INSUFFICIENT_EDITING_PERMISSION = "INSUFFICIENT_EDITING_PERMISSION",
5
+ FORBIDDEN_USER_TOKEN = "FORBIDDEN_USER_TOKEN",
6
+ DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
7
+ INIT_DATA_LOAD_FAILED = "INIT_DATA_LOAD_FAILED",
8
+ ERROR_MAPPING_ERROR = "ERROR_MAPPING_ERROR",
9
+ NAMESPACE_INVALID = "NAMESPACE_INVALID",
10
+ NAMESPACE_NOT_FOUND = "NAMESPACE_NOT_FOUND",
11
+ TENANT_INSTANCE_MAINTENANCE = "TENANT_INSTANCE_MAINTENANCE",
12
+ LOCKED_DOCUMENT = "LOCKED_DOCUMENT",
13
+ EMPTY_BROADCAST = "EMPTY_BROADCAST",
14
+ DYNAMO_ERROR = "DYNAMO_ERROR",
15
+ INVALID_ACTIVATION_ID = "INVALID_ACTIVATION_ID",
16
+ INVALID_DOCUMENT_ARI = "INVALID_DOCUMENT_ARI",
17
+ INVALID_CLOUD_ID = "INVALID_CLOUD_ID",
18
+ RATE_LIMIT_ERROR = "RATE_LIMIT_ERROR"
19
+ }
20
+ type HeadVersionUpdateFailedError = {
21
+ message: string;
22
+ data: {
23
+ code: NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED;
24
+ meta: {
25
+ currentVersion: any;
26
+ incomingVersion: number;
27
+ };
28
+ status: number;
29
+ };
30
+ };
31
+ type VersionAlreadyPresentInDynamoError = {
32
+ message: string;
33
+ data: {
34
+ code: NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS;
35
+ meta: string;
36
+ status: number;
37
+ };
38
+ };
39
+ type InsufficientEditingPermissionError = {
40
+ message: string;
41
+ data: {
42
+ code: NCS_ERROR_CODE.INSUFFICIENT_EDITING_PERMISSION;
43
+ meta: {
44
+ description: string;
45
+ reason?: string;
46
+ };
47
+ status: number;
48
+ };
49
+ };
50
+ type ForbiddenUserTokenError = {
51
+ message: string;
52
+ data: {
53
+ code: NCS_ERROR_CODE.FORBIDDEN_USER_TOKEN;
54
+ meta: string;
55
+ status: number;
56
+ };
57
+ };
58
+ type NCSDocumentNotFoundError = {
59
+ message: string;
60
+ data: {
61
+ code: NCS_ERROR_CODE.DOCUMENT_NOT_FOUND;
62
+ status: number;
63
+ };
64
+ };
65
+ type FailedToLoadInitDataError = {
66
+ message: string;
67
+ data: {
68
+ code: NCS_ERROR_CODE.INIT_DATA_LOAD_FAILED;
69
+ status: number;
70
+ };
71
+ };
72
+ type ErrorMappingError = {
73
+ message: string;
74
+ data: {
75
+ code: NCS_ERROR_CODE.ERROR_MAPPING_ERROR;
76
+ status: number;
77
+ };
78
+ };
79
+ type InvalidNamespaceDefinedError = {
80
+ message: string;
81
+ data: {
82
+ code: NCS_ERROR_CODE.NAMESPACE_INVALID;
83
+ meta: string;
84
+ status: number;
85
+ };
86
+ };
87
+ type SocketNamespaceNotFoundError = {
88
+ message: string;
89
+ data: {
90
+ code: NCS_ERROR_CODE.NAMESPACE_NOT_FOUND;
91
+ meta: string;
92
+ status: number;
93
+ };
94
+ };
95
+ type TenantInstanceMaintenanceError = {
96
+ message: string;
97
+ data: {
98
+ code: NCS_ERROR_CODE.TENANT_INSTANCE_MAINTENANCE;
99
+ meta: {
100
+ description: string;
101
+ reason: string;
102
+ };
103
+ status: number;
104
+ };
105
+ };
106
+ type NamespaceLockedError = {
107
+ message: string;
108
+ data: {
109
+ code: NCS_ERROR_CODE.LOCKED_DOCUMENT;
110
+ meta: string;
111
+ status: number;
112
+ };
113
+ };
114
+ type EmptyBroadcastError = {
115
+ message: string;
116
+ data: {
117
+ code: NCS_ERROR_CODE.EMPTY_BROADCAST;
118
+ meta: string;
119
+ status: number;
120
+ };
121
+ };
122
+ type DynamoError = {
123
+ message: string;
124
+ data: {
125
+ code: NCS_ERROR_CODE.DYNAMO_ERROR;
126
+ meta: string;
127
+ status: number;
128
+ };
129
+ };
130
+ type InvalidActivationIdError = {
131
+ message: string;
132
+ data: {
133
+ code: NCS_ERROR_CODE.INVALID_ACTIVATION_ID;
134
+ meta: string;
135
+ status: number;
136
+ };
137
+ };
138
+ type InvalidDocumentAriError = {
139
+ message: string;
140
+ data: {
141
+ code: NCS_ERROR_CODE.INVALID_DOCUMENT_ARI;
142
+ meta: string;
143
+ status: number;
144
+ };
145
+ };
146
+ type InvalidCloudIdError = {
147
+ message: string;
148
+ data: {
149
+ code: NCS_ERROR_CODE.INVALID_CLOUD_ID;
150
+ meta: string;
151
+ status: number;
152
+ };
153
+ };
154
+ /**
155
+ * The client is trying to send too many messages or messages that are too large. This not expected to be a standard
156
+ * operating condition and should only ever indicate a frontend bug.
157
+ */
158
+ export type RateLimitError = {
159
+ message: string;
160
+ data: {
161
+ code: NCS_ERROR_CODE.RATE_LIMIT_ERROR;
162
+ meta: {
163
+ rateLimitType: number;
164
+ maxStepSize: number;
165
+ stepSizeCounter: number;
166
+ stepCounter: number;
167
+ };
168
+ status: 500;
169
+ };
170
+ };
171
+ export type NCSErrors = HeadVersionUpdateFailedError | VersionAlreadyPresentInDynamoError | InsufficientEditingPermissionError | ForbiddenUserTokenError | NCSDocumentNotFoundError | FailedToLoadInitDataError | ErrorMappingError | InvalidNamespaceDefinedError | SocketNamespaceNotFoundError | TenantInstanceMaintenanceError | NamespaceLockedError | EmptyBroadcastError | DynamoError | InvalidActivationIdError | InvalidDocumentAriError | InvalidCloudIdError | RateLimitError;
172
+ export {};
@@ -3,7 +3,7 @@ import type { ChannelEvent, StepsPayload } from '../types';
3
3
  import type { CollabCommitStatusEventPayload, CollabEvents } from '@atlaskit/editor-common/collab';
4
4
  import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
5
5
  import type AnalyticsHelper from '../analytics/analytics-helper';
6
- import type { InternalError } from '../errors/error-types';
6
+ import type { InternalError } from '../errors/internal-errors';
7
7
  export declare const commitStepQueue: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, }: {
8
8
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
9
9
  steps: readonly ProseMirrorStep[];
@@ -1,7 +1,7 @@
1
1
  import type { Step } from '@atlaskit/editor-prosemirror/transform';
2
2
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
3
3
  import type { Manager } from 'socket.io-client';
4
- import type { InternalError } from './errors/error-types';
4
+ import type { InternalError } from './errors/internal-errors';
5
5
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
6
6
  import type { GetUserType } from './participants/participants-helper';
7
7
  import type AnalyticsHelper from './analytics/analytics-helper';
@@ -7,7 +7,7 @@ import type { MetadataService } from '../metadata/metadata-service';
7
7
  import type { CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
8
8
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { ParticipantsService } from '../participants/participants-service';
10
- import type { InternalError } from '../errors/error-types';
10
+ import type { InternalError } from '../errors/internal-errors';
11
11
  export declare class DocumentService {
12
12
  private participantsService;
13
13
  private analyticsHelper;
@@ -0,0 +1,56 @@
1
+ import type { CantSyncUpErrorAttributes, DocumentUpdateErrorAttributes } from '../helpers/const';
2
+ type ValidEventAttributeType = boolean | string | number;
3
+ export declare class CustomError extends Error {
4
+ extraEventAttributes?: {
5
+ [key: string]: ValidEventAttributeType;
6
+ };
7
+ constructor(message: string, error?: unknown, extraEventAttributes?: {
8
+ [key: string]: ValidEventAttributeType;
9
+ });
10
+ toJSON(): {
11
+ name: string;
12
+ message: string;
13
+ };
14
+ getExtraErrorEventAttributes: () => {
15
+ [key: string]: ValidEventAttributeType;
16
+ } | undefined;
17
+ }
18
+ export declare class NotConnectedError extends CustomError {
19
+ name: string;
20
+ }
21
+ export declare class NotInitializedError extends CustomError {
22
+ name: string;
23
+ }
24
+ export declare class ProviderInitialisationError extends CustomError {
25
+ name: string;
26
+ }
27
+ export declare class SendTransactionError extends CustomError {
28
+ name: string;
29
+ }
30
+ export declare class DestroyError extends CustomError {
31
+ name: string;
32
+ }
33
+ export declare class SetTitleError extends CustomError {
34
+ name: string;
35
+ }
36
+ export declare class SetEditorWidthError extends CustomError {
37
+ name: string;
38
+ }
39
+ export declare class SetMetadataError extends CustomError {
40
+ name: string;
41
+ }
42
+ export declare class GetCurrentStateError extends CustomError {
43
+ name: string;
44
+ }
45
+ export declare class GetFinalAcknowledgedStateError extends CustomError {
46
+ name: string;
47
+ }
48
+ export declare class UpdateDocumentError extends CustomError {
49
+ name: string;
50
+ constructor(message: string, extraAttributes: DocumentUpdateErrorAttributes);
51
+ }
52
+ export declare class CantSyncUpError extends CustomError {
53
+ name: string;
54
+ constructor(message: string, extraAttributes: CantSyncUpErrorAttributes);
55
+ }
56
+ export {};
@@ -1,3 +1,3 @@
1
- import { InternalError } from './error-types';
2
- import { ProviderError } from '@atlaskit/editor-common/collab';
1
+ import type { InternalError } from './internal-errors';
2
+ import type { ProviderError } from '@atlaskit/editor-common/collab';
3
3
  export declare const errorCodeMapper: (error: InternalError) => ProviderError | undefined;
@@ -0,0 +1,90 @@
1
+ import type { NCSErrors } from './ncs-errors';
2
+ export declare enum INTERNAL_ERROR_CODE {
3
+ TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
4
+ RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
5
+ CONNECTION_ERROR = "CONNECTION_ERROR",
6
+ RECONNECTION_ERROR = "RECONNECTION_ERROR",
7
+ DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
8
+ CATCHUP_FAILED = "CATCHUP_FAILED",
9
+ DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
10
+ ADD_STEPS_ERROR = "ADD_STEPS_ERROR",
11
+ DOCUMENT_UPDATE_ERROR = "DOCUMENT_UPDATE_ERROR"
12
+ }
13
+ type DocumentRecoveryError = {
14
+ message: string;
15
+ data: {
16
+ code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
17
+ status: number;
18
+ };
19
+ };
20
+ type AddStepsError = {
21
+ message: string;
22
+ data: {
23
+ code: INTERNAL_ERROR_CODE.ADD_STEPS_ERROR;
24
+ status: number;
25
+ };
26
+ };
27
+ export type CatchUpFailedError = {
28
+ message: string;
29
+ data: {
30
+ code: INTERNAL_ERROR_CODE.CATCHUP_FAILED;
31
+ status: number;
32
+ };
33
+ };
34
+ export type TokenPermissionError = {
35
+ message: string;
36
+ data: {
37
+ code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR;
38
+ status: number;
39
+ meta: {
40
+ originalError?: unknown;
41
+ reason?: string;
42
+ };
43
+ };
44
+ };
45
+ export type ReconnectionError = {
46
+ message: string;
47
+ data: {
48
+ code: INTERNAL_ERROR_CODE.RECONNECTION_ERROR;
49
+ status: number;
50
+ };
51
+ };
52
+ export type ConnectionError = {
53
+ message: string;
54
+ data: {
55
+ code: INTERNAL_ERROR_CODE.CONNECTION_ERROR;
56
+ };
57
+ };
58
+ export type ReconnectionNetworkError = {
59
+ message: string;
60
+ data: {
61
+ code: INTERNAL_ERROR_CODE.RECONNECTION_NETWORK_ISSUE;
62
+ };
63
+ };
64
+ export type DocumentNotFoundError = {
65
+ message: string;
66
+ data: {
67
+ code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND;
68
+ status: number;
69
+ };
70
+ };
71
+ /**
72
+ * When we try to apply state updates to the editor, if that fails to apply the user can enter an invalid state where no
73
+ * changes can be saved to NCS.
74
+ */
75
+ export type InternalDocumentUpdateFailure = {
76
+ message: 'The provider failed to apply changes to the editor';
77
+ data: {
78
+ code: INTERNAL_ERROR_CODE.DOCUMENT_UPDATE_ERROR;
79
+ meta: {
80
+ newVersion?: number;
81
+ editorVersion?: number;
82
+ };
83
+ status: 500;
84
+ };
85
+ };
86
+ /**
87
+ * A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
88
+ */
89
+ export type InternalError = NCSErrors | DocumentRecoveryError | AddStepsError | CatchUpFailedError | TokenPermissionError | ReconnectionError | ConnectionError | ReconnectionNetworkError | DocumentNotFoundError | InternalDocumentUpdateFailure;
90
+ export {};
@@ -0,0 +1,172 @@
1
+ export declare enum NCS_ERROR_CODE {
2
+ HEAD_VERSION_UPDATE_FAILED = "HEAD_VERSION_UPDATE_FAILED",
3
+ VERSION_NUMBER_ALREADY_EXISTS = "VERSION_NUMBER_ALREADY_EXISTS",
4
+ INSUFFICIENT_EDITING_PERMISSION = "INSUFFICIENT_EDITING_PERMISSION",
5
+ FORBIDDEN_USER_TOKEN = "FORBIDDEN_USER_TOKEN",
6
+ DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
7
+ INIT_DATA_LOAD_FAILED = "INIT_DATA_LOAD_FAILED",
8
+ ERROR_MAPPING_ERROR = "ERROR_MAPPING_ERROR",
9
+ NAMESPACE_INVALID = "NAMESPACE_INVALID",
10
+ NAMESPACE_NOT_FOUND = "NAMESPACE_NOT_FOUND",
11
+ TENANT_INSTANCE_MAINTENANCE = "TENANT_INSTANCE_MAINTENANCE",
12
+ LOCKED_DOCUMENT = "LOCKED_DOCUMENT",
13
+ EMPTY_BROADCAST = "EMPTY_BROADCAST",
14
+ DYNAMO_ERROR = "DYNAMO_ERROR",
15
+ INVALID_ACTIVATION_ID = "INVALID_ACTIVATION_ID",
16
+ INVALID_DOCUMENT_ARI = "INVALID_DOCUMENT_ARI",
17
+ INVALID_CLOUD_ID = "INVALID_CLOUD_ID",
18
+ RATE_LIMIT_ERROR = "RATE_LIMIT_ERROR"
19
+ }
20
+ type HeadVersionUpdateFailedError = {
21
+ message: string;
22
+ data: {
23
+ code: NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED;
24
+ meta: {
25
+ currentVersion: any;
26
+ incomingVersion: number;
27
+ };
28
+ status: number;
29
+ };
30
+ };
31
+ type VersionAlreadyPresentInDynamoError = {
32
+ message: string;
33
+ data: {
34
+ code: NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS;
35
+ meta: string;
36
+ status: number;
37
+ };
38
+ };
39
+ type InsufficientEditingPermissionError = {
40
+ message: string;
41
+ data: {
42
+ code: NCS_ERROR_CODE.INSUFFICIENT_EDITING_PERMISSION;
43
+ meta: {
44
+ description: string;
45
+ reason?: string;
46
+ };
47
+ status: number;
48
+ };
49
+ };
50
+ type ForbiddenUserTokenError = {
51
+ message: string;
52
+ data: {
53
+ code: NCS_ERROR_CODE.FORBIDDEN_USER_TOKEN;
54
+ meta: string;
55
+ status: number;
56
+ };
57
+ };
58
+ type NCSDocumentNotFoundError = {
59
+ message: string;
60
+ data: {
61
+ code: NCS_ERROR_CODE.DOCUMENT_NOT_FOUND;
62
+ status: number;
63
+ };
64
+ };
65
+ type FailedToLoadInitDataError = {
66
+ message: string;
67
+ data: {
68
+ code: NCS_ERROR_CODE.INIT_DATA_LOAD_FAILED;
69
+ status: number;
70
+ };
71
+ };
72
+ type ErrorMappingError = {
73
+ message: string;
74
+ data: {
75
+ code: NCS_ERROR_CODE.ERROR_MAPPING_ERROR;
76
+ status: number;
77
+ };
78
+ };
79
+ type InvalidNamespaceDefinedError = {
80
+ message: string;
81
+ data: {
82
+ code: NCS_ERROR_CODE.NAMESPACE_INVALID;
83
+ meta: string;
84
+ status: number;
85
+ };
86
+ };
87
+ type SocketNamespaceNotFoundError = {
88
+ message: string;
89
+ data: {
90
+ code: NCS_ERROR_CODE.NAMESPACE_NOT_FOUND;
91
+ meta: string;
92
+ status: number;
93
+ };
94
+ };
95
+ type TenantInstanceMaintenanceError = {
96
+ message: string;
97
+ data: {
98
+ code: NCS_ERROR_CODE.TENANT_INSTANCE_MAINTENANCE;
99
+ meta: {
100
+ description: string;
101
+ reason: string;
102
+ };
103
+ status: number;
104
+ };
105
+ };
106
+ type NamespaceLockedError = {
107
+ message: string;
108
+ data: {
109
+ code: NCS_ERROR_CODE.LOCKED_DOCUMENT;
110
+ meta: string;
111
+ status: number;
112
+ };
113
+ };
114
+ type EmptyBroadcastError = {
115
+ message: string;
116
+ data: {
117
+ code: NCS_ERROR_CODE.EMPTY_BROADCAST;
118
+ meta: string;
119
+ status: number;
120
+ };
121
+ };
122
+ type DynamoError = {
123
+ message: string;
124
+ data: {
125
+ code: NCS_ERROR_CODE.DYNAMO_ERROR;
126
+ meta: string;
127
+ status: number;
128
+ };
129
+ };
130
+ type InvalidActivationIdError = {
131
+ message: string;
132
+ data: {
133
+ code: NCS_ERROR_CODE.INVALID_ACTIVATION_ID;
134
+ meta: string;
135
+ status: number;
136
+ };
137
+ };
138
+ type InvalidDocumentAriError = {
139
+ message: string;
140
+ data: {
141
+ code: NCS_ERROR_CODE.INVALID_DOCUMENT_ARI;
142
+ meta: string;
143
+ status: number;
144
+ };
145
+ };
146
+ type InvalidCloudIdError = {
147
+ message: string;
148
+ data: {
149
+ code: NCS_ERROR_CODE.INVALID_CLOUD_ID;
150
+ meta: string;
151
+ status: number;
152
+ };
153
+ };
154
+ /**
155
+ * The client is trying to send too many messages or messages that are too large. This not expected to be a standard
156
+ * operating condition and should only ever indicate a frontend bug.
157
+ */
158
+ export type RateLimitError = {
159
+ message: string;
160
+ data: {
161
+ code: NCS_ERROR_CODE.RATE_LIMIT_ERROR;
162
+ meta: {
163
+ rateLimitType: number;
164
+ maxStepSize: number;
165
+ stepSizeCounter: number;
166
+ stepCounter: number;
167
+ };
168
+ status: 500;
169
+ };
170
+ };
171
+ export type NCSErrors = HeadVersionUpdateFailedError | VersionAlreadyPresentInDynamoError | InsufficientEditingPermissionError | ForbiddenUserTokenError | NCSDocumentNotFoundError | FailedToLoadInitDataError | ErrorMappingError | InvalidNamespaceDefinedError | SocketNamespaceNotFoundError | TenantInstanceMaintenanceError | NamespaceLockedError | EmptyBroadcastError | DynamoError | InvalidActivationIdError | InvalidDocumentAriError | InvalidCloudIdError | RateLimitError;
172
+ export {};
@@ -3,7 +3,7 @@ import type { ChannelEvent, StepsPayload } from '../types';
3
3
  import type { CollabCommitStatusEventPayload, CollabEvents } from '@atlaskit/editor-common/collab';
4
4
  import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
5
5
  import type AnalyticsHelper from '../analytics/analytics-helper';
6
- import type { InternalError } from '../errors/error-types';
6
+ import type { InternalError } from '../errors/internal-errors';
7
7
  export declare const commitStepQueue: ({ broadcast, steps, version, userId, clientId, onStepsAdded, onErrorHandled, analyticsHelper, emit, }: {
8
8
  broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
9
9
  steps: readonly ProseMirrorStep[];