@atlaskit/collab-provider 9.1.0 → 9.2.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.
@@ -0,0 +1,564 @@
1
+ ## API Report File for "@atlaskit/collab-provider"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
8
+ import type { EditorState } from 'prosemirror-state';
9
+ import { JSONDocNode } from '@atlaskit/editor-json-transformer';
10
+ import type { Manager } from 'socket.io-client';
11
+ import type { Step } from 'prosemirror-transform';
12
+ import type { Transaction } from 'prosemirror-state';
13
+
14
+ // @public (undocumented)
15
+ type AuthCallback = (cb: (data: InitAndAuthData) => void) => void;
16
+
17
+ // @public (undocumented)
18
+ type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'send' | 'sendMessage' | 'setup'>;
19
+
20
+ // @public (undocumented)
21
+ type CollabCommitStatusEventPayload = {
22
+ status: 'attempt' | 'failure' | 'success';
23
+ version: number;
24
+ };
25
+
26
+ // @public (undocumented)
27
+ export type CollabConnectedPayload = CollabEventConnectionData;
28
+
29
+ // @public (undocumented)
30
+ type CollabConnectingPayload = CollabEventConnectingData;
31
+
32
+ // @public (undocumented)
33
+ export interface CollabDataPayload extends CollabEventRemoteData {
34
+ // (undocumented)
35
+ json: StepJson[];
36
+ // (undocumented)
37
+ userIds: (number | string)[];
38
+ // (undocumented)
39
+ version: number;
40
+ }
41
+
42
+ // @public (undocumented)
43
+ export interface CollabDisconnectedPayload {
44
+ // (undocumented)
45
+ reason: DisconnectReason;
46
+ // (undocumented)
47
+ sid: string;
48
+ }
49
+
50
+ // @public (undocumented)
51
+ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents> {
52
+ // (undocumented)
53
+ getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
54
+ // (undocumented)
55
+ initialize(getState: () => any, createStep: (json: object) => Step): this;
56
+ // (undocumented)
57
+ off(evt: keyof Events, handler: (...args: any) => void): this;
58
+ // (undocumented)
59
+ on(evt: keyof Events, handler: (...args: any) => void): this;
60
+ // (undocumented)
61
+ send(tr: Transaction, oldState: EditorState, newState: EditorState): void;
62
+ // (undocumented)
63
+ sendMessage<K extends keyof Events>(data: {
64
+ type: K;
65
+ } & Events[K]): void;
66
+ // (undocumented)
67
+ setup(props: {
68
+ getState?: () => EditorState;
69
+ onSyncUpError?: SyncUpErrorFunction;
70
+ }): this;
71
+ // (undocumented)
72
+ unsubscribeAll(evt: keyof Events): this;
73
+ }
74
+
75
+ // @public (undocumented)
76
+ export interface CollabEventConnectingData {
77
+ // (undocumented)
78
+ initial: boolean;
79
+ }
80
+
81
+ // @public (undocumented)
82
+ export interface CollabEventConnectionData {
83
+ // (undocumented)
84
+ initial: boolean;
85
+ // (undocumented)
86
+ sid: string;
87
+ }
88
+
89
+ // @public (undocumented)
90
+ export interface CollabEventDisconnectedData {
91
+ // (undocumented)
92
+ reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
93
+ // (undocumented)
94
+ sid: string;
95
+ }
96
+
97
+ // @public (undocumented)
98
+ export interface CollabEventInitData {
99
+ // (undocumented)
100
+ doc?: any;
101
+ // (undocumented)
102
+ json?: any;
103
+ // (undocumented)
104
+ reserveCursor?: boolean;
105
+ // (undocumented)
106
+ sid?: string;
107
+ // (undocumented)
108
+ version?: number;
109
+ }
110
+
111
+ // @public (undocumented)
112
+ export interface CollabEventLocalStepData {
113
+ // (undocumented)
114
+ steps: Array<Step>;
115
+ }
116
+
117
+ // @public (undocumented)
118
+ export interface CollabEventPresenceData {
119
+ // (undocumented)
120
+ joined?: CollabParticipant[];
121
+ // (undocumented)
122
+ left?: {
123
+ sessionId: string;
124
+ }[];
125
+ }
126
+
127
+ // @public (undocumented)
128
+ export interface CollabEventRemoteData {
129
+ // (undocumented)
130
+ json?: any;
131
+ // (undocumented)
132
+ newState?: EditorState;
133
+ // (undocumented)
134
+ userIds?: (number | string)[];
135
+ }
136
+
137
+ // @public (undocumented)
138
+ export interface CollabEvents {
139
+ // (undocumented)
140
+ 'commit-status': CollabCommitStatusEventPayload;
141
+ // (undocumented)
142
+ 'local-steps': CollabLocalStepsPayload;
143
+ // (undocumented)
144
+ 'metadata:changed': CollabMetadataPayload;
145
+ // (undocumented)
146
+ connected: CollabConnectedPayload;
147
+ // (undocumented)
148
+ connecting: CollabConnectingPayload;
149
+ // (undocumented)
150
+ data: CollabDataPayload;
151
+ // (undocumented)
152
+ disconnected: CollabDisconnectedPayload;
153
+ // (undocumented)
154
+ entity: any;
155
+ // (undocumented)
156
+ error: ProviderError;
157
+ // (undocumented)
158
+ init: CollabInitPayload;
159
+ // (undocumented)
160
+ presence: CollabPresencePayload;
161
+ // (undocumented)
162
+ telepointer: CollabTelepointerPayload;
163
+ }
164
+
165
+ // @public (undocumented)
166
+ export interface CollabEventTelepointerData {
167
+ // (undocumented)
168
+ selection: CollabSendableSelection;
169
+ // (undocumented)
170
+ sessionId: string;
171
+ // (undocumented)
172
+ type: 'telepointer';
173
+ }
174
+
175
+ // @public (undocumented)
176
+ export interface CollabInitPayload extends CollabEventInitData {
177
+ // (undocumented)
178
+ doc: any;
179
+ // (undocumented)
180
+ metadata?: Metadata_2;
181
+ // (undocumented)
182
+ reserveCursor?: boolean;
183
+ // (undocumented)
184
+ version: number;
185
+ }
186
+
187
+ // @public (undocumented)
188
+ export type CollabLocalStepsPayload = {
189
+ steps: readonly Step[];
190
+ };
191
+
192
+ // @public (undocumented)
193
+ export type CollabMetadataPayload = Metadata_2;
194
+
195
+ // @public (undocumented)
196
+ export interface CollabParticipant {
197
+ // (undocumented)
198
+ avatar: string;
199
+ // (undocumented)
200
+ cursorPos?: number;
201
+ // (undocumented)
202
+ lastActive: number;
203
+ // (undocumented)
204
+ name: string;
205
+ // (undocumented)
206
+ sessionId: string;
207
+ }
208
+
209
+ // @public (undocumented)
210
+ export type CollabPresencePayload = CollabEventPresenceData;
211
+
212
+ // @public (undocumented)
213
+ export interface CollabSendableSelection {
214
+ // (undocumented)
215
+ anchor?: number | string;
216
+ // (undocumented)
217
+ head?: number | string;
218
+ // (undocumented)
219
+ type: 'nodeSelection' | 'textSelection';
220
+ }
221
+
222
+ // @public (undocumented)
223
+ export type CollabTelepointerPayload = CollabEventTelepointerData;
224
+
225
+ // @public (undocumented)
226
+ interface Config {
227
+ analyticsClient?: AnalyticsWebClient;
228
+ // (undocumented)
229
+ cacheToken?: boolean;
230
+ // (undocumented)
231
+ createSocket: (path: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation) => Socket;
232
+ // (undocumented)
233
+ documentAri: string;
234
+ failedStepLimitBeforeCatchupOnPublish?: number;
235
+ // (undocumented)
236
+ featureFlags?: {
237
+ [key: string]: boolean;
238
+ };
239
+ // (undocumented)
240
+ getAnalyticsWebClient?: Promise<AnalyticsWebClient>;
241
+ // (undocumented)
242
+ getUser?(userId: string): Promise<Pick<ProviderParticipant, 'avatar' | 'name' | 'userId'>>;
243
+ // (undocumented)
244
+ initialDraft?: InitialDraft;
245
+ // (undocumented)
246
+ lifecycle?: Lifecycle;
247
+ // (undocumented)
248
+ need404?: boolean;
249
+ permissionTokenRefresh?: () => Promise<null | string>;
250
+ // (undocumented)
251
+ productInfo?: ProductInformation;
252
+ // (undocumented)
253
+ storage?: Storage_2;
254
+ throwOnNotConnected?: boolean;
255
+ // (undocumented)
256
+ url: string;
257
+ }
258
+
259
+ // @public (undocumented)
260
+ enum DisconnectReason {
261
+ // (undocumented)
262
+ CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
263
+ // (undocumented)
264
+ SERVER_DISCONNECT = "SERVER_DISCONNECT",
265
+ // (undocumented)
266
+ SOCKET_CLOSED = "SOCKET_CLOSED",
267
+ // (undocumented)
268
+ SOCKET_ERROR = "SOCKET_ERROR",
269
+ // (undocumented)
270
+ SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
271
+ // (undocumented)
272
+ UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
273
+ }
274
+
275
+ // @public
276
+ type DocumentNotFound = {
277
+ code: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND;
278
+ message: string;
279
+ recoverable: boolean;
280
+ status?: number;
281
+ };
282
+
283
+ // @public
284
+ type DocumentNotRestore = {
285
+ code: PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
286
+ message: string;
287
+ recoverable: boolean;
288
+ status?: number;
289
+ };
290
+
291
+ // @public (undocumented)
292
+ class Emitter<T = any> {
293
+ protected emit<K extends keyof T>(evt: K, data: T[K]): this;
294
+ off<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
295
+ on<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
296
+ unsubscribeAll<K extends keyof T>(evt?: K): this;
297
+ }
298
+
299
+ // @public (undocumented)
300
+ type EventHandler = () => void;
301
+
302
+ // @public
303
+ type FailToSave = {
304
+ code: PROVIDER_ERROR_CODE.FAIL_TO_SAVE;
305
+ message: string;
306
+ recoverable: boolean;
307
+ status?: number;
308
+ };
309
+
310
+ // @public (undocumented)
311
+ interface InitAndAuthData {
312
+ // (undocumented)
313
+ initialized: boolean;
314
+ // (undocumented)
315
+ need404?: boolean;
316
+ // (undocumented)
317
+ token?: string;
318
+ }
319
+
320
+ // @public (undocumented)
321
+ interface InitialDraft {
322
+ // (undocumented)
323
+ document: JSONDocNode;
324
+ // (undocumented)
325
+ metadata?: Metadata_2;
326
+ // (undocumented)
327
+ timestamp?: number;
328
+ // (undocumented)
329
+ version: number;
330
+ }
331
+
332
+ // @public
333
+ type InitialisationError = {
334
+ code: PROVIDER_ERROR_CODE.INITIALISATION_ERROR;
335
+ message: string;
336
+ recoverable: boolean;
337
+ status?: number;
338
+ };
339
+
340
+ // @public
341
+ type InsufficientEditingPermission = {
342
+ code: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR;
343
+ message: string;
344
+ recoverable: boolean;
345
+ reason?: string;
346
+ status?: number;
347
+ };
348
+
349
+ // @public
350
+ type InternalServiceError = {
351
+ code: PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR;
352
+ message: string;
353
+ recoverable: boolean;
354
+ reason: string;
355
+ status?: number;
356
+ };
357
+
358
+ // @public
359
+ type InvalidProviderConfiguration = {
360
+ code: PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION;
361
+ message: string;
362
+ recoverable: boolean;
363
+ reason: string;
364
+ status?: number;
365
+ };
366
+
367
+ // @public
368
+ type InvalidUserToken = {
369
+ code: PROVIDER_ERROR_CODE.INVALID_USER_TOKEN;
370
+ message: string;
371
+ recoverable: boolean;
372
+ status?: number;
373
+ };
374
+
375
+ // @public (undocumented)
376
+ interface Lifecycle {
377
+ // (undocumented)
378
+ on(event: LifecycleEvents, handler: EventHandler): void;
379
+ }
380
+
381
+ // @public (undocumented)
382
+ type LifecycleEvents = 'restore' | 'save';
383
+
384
+ // @public
385
+ type Locked = {
386
+ code: PROVIDER_ERROR_CODE.LOCKED;
387
+ message: string;
388
+ recoverable: boolean;
389
+ status?: number;
390
+ };
391
+
392
+ // @public (undocumented)
393
+ type MarkJson = {
394
+ type: string;
395
+ attrs: {
396
+ [key: string]: any;
397
+ };
398
+ };
399
+
400
+ // @public (undocumented)
401
+ interface Metadata_2 {
402
+ // (undocumented)
403
+ [key: string]: boolean | number | string;
404
+ }
405
+
406
+ // @public
407
+ type NetworkIssue = {
408
+ code: PROVIDER_ERROR_CODE.NETWORK_ISSUE;
409
+ message: string;
410
+ recoverable: boolean;
411
+ status?: number;
412
+ };
413
+
414
+ // @public (undocumented)
415
+ export type NewCollabSyncUpErrorAttributes = {
416
+ lengthOfUnconfirmedSteps?: number;
417
+ tries: number;
418
+ maxRetries: number;
419
+ clientId?: number | string;
420
+ version: number;
421
+ };
422
+
423
+ // @public (undocumented)
424
+ type NodeJson = {
425
+ type: string;
426
+ attrs: {
427
+ [key: string]: any;
428
+ };
429
+ content: NodeJson[];
430
+ marks: MarkJson[];
431
+ text?: string;
432
+ };
433
+
434
+ // @public (undocumented)
435
+ type ProductInformation = {
436
+ product: string;
437
+ subProduct?: string;
438
+ };
439
+
440
+ // @public (undocumented)
441
+ export class Provider extends Emitter<CollabEvents> implements BaseEvents {
442
+ constructor(config: Config);
443
+ destroy(): this;
444
+ // @deprecated
445
+ disconnect(): this;
446
+ getCurrentState: () => Promise<ResolvedEditorState>;
447
+ getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
448
+ getMetadata: () => Metadata_2;
449
+ // (undocumented)
450
+ getStatePromiseResolve: (value: PromiseLike<void> | void) => void;
451
+ // (undocumented)
452
+ getUnconfirmedSteps: () => readonly Step[] | undefined;
453
+ // @deprecated
454
+ initialize(getState: () => EditorState): this;
455
+ send(_tr: Transaction | null, _oldState: EditorState | null, newState: EditorState): void;
456
+ sendMessage(data: CollabTelepointerPayload): void;
457
+ // @deprecated
458
+ setEditorWidth(editorWidth: string, broadcast?: boolean): void;
459
+ setMetadata(metadata: Metadata_2): void;
460
+ // @deprecated
461
+ setTitle(title: string, broadcast?: boolean): void;
462
+ setup({ getState, onSyncUpError, }: {
463
+ getState?: () => EditorState;
464
+ onSyncUpError?: SyncUpErrorFunction;
465
+ }): this;
466
+ // @deprecated
467
+ unsubscribeAll(): this;
468
+ }
469
+
470
+ // @public (undocumented)
471
+ export enum PROVIDER_ERROR_CODE {
472
+ // (undocumented)
473
+ DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
474
+ // (undocumented)
475
+ DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
476
+ // (undocumented)
477
+ FAIL_TO_SAVE = "FAIL_TO_SAVE",
478
+ // (undocumented)
479
+ INITIALISATION_ERROR = "INITIALISATION_ERROR",
480
+ // (undocumented)
481
+ INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR",
482
+ // (undocumented)
483
+ INVALID_PROVIDER_CONFIGURATION = "INVALID_PROVIDER_CONFIGURATION",
484
+ // (undocumented)
485
+ INVALID_USER_TOKEN = "INVALID_USER_TOKEN",
486
+ // (undocumented)
487
+ LOCKED = "LOCKED",
488
+ // (undocumented)
489
+ NETWORK_ISSUE = "NETWORK_ISSUE",
490
+ // (undocumented)
491
+ NO_PERMISSION_ERROR = "NO_PERMISSION_ERROR"
492
+ }
493
+
494
+ // @public
495
+ export type ProviderError = DocumentNotFound | DocumentNotRestore | FailToSave | InitialisationError | InsufficientEditingPermission | InternalServiceError | InvalidProviderConfiguration | InvalidUserToken | Locked | NetworkIssue;
496
+
497
+ // @public (undocumented)
498
+ type ProviderParticipant = CollabParticipant & {
499
+ userId: string;
500
+ clientId: number | string;
501
+ };
502
+
503
+ // @public (undocumented)
504
+ export type ResolvedEditorState<T = any> = {
505
+ content: JSONDocNode | T;
506
+ title: null | string;
507
+ stepVersion: number;
508
+ };
509
+
510
+ // @public (undocumented)
511
+ interface SimpleEventEmitter {
512
+ // (undocumented)
513
+ on(event: string, fn: Function): SimpleEventEmitter;
514
+ }
515
+
516
+ // @public (undocumented)
517
+ type SliceJson = {
518
+ content: NodeJson[];
519
+ openStart: number;
520
+ openEnd: number;
521
+ };
522
+
523
+ // @public (undocumented)
524
+ export interface Socket extends SimpleEventEmitter {
525
+ // (undocumented)
526
+ close(): Socket;
527
+ // (undocumented)
528
+ connect(): Socket;
529
+ // (undocumented)
530
+ emit(event: string, ...args: any[]): Socket;
531
+ // (undocumented)
532
+ id: string;
533
+ // (undocumented)
534
+ io?: Manager;
535
+ }
536
+
537
+ // @public (undocumented)
538
+ type StepJson = {
539
+ stepType?: string;
540
+ from?: number;
541
+ to?: number;
542
+ slice?: SliceJson;
543
+ clientId: number | string;
544
+ userId: string;
545
+ createdAt?: number;
546
+ structure?: boolean;
547
+ };
548
+
549
+ // @public (undocumented)
550
+ interface Storage_2 {
551
+ // (undocumented)
552
+ delete(key: string): Promise<void>;
553
+ // (undocumented)
554
+ get(key: string): Promise<string>;
555
+ // (undocumented)
556
+ set(key: string, value: string): Promise<void>;
557
+ }
558
+
559
+ // @public (undocumented)
560
+ export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
561
+
562
+ // (No @packageDocumentation comment for this package)
563
+
564
+ ```