@hocuspocus/provider 2.15.2 → 3.0.4-rc.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/dist/hocuspocus-provider.cjs +931 -1532
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +931 -1527
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-database/src/Database.d.ts +1 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +4 -3
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +2 -1
- package/dist/packages/extension-throttle/src/index.d.ts +2 -2
- package/dist/packages/extension-webhook/src/index.d.ts +3 -3
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +12 -45
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +5 -9
- package/dist/packages/provider/src/IncomingMessage.d.ts +3 -3
- package/dist/packages/provider/src/MessageReceiver.d.ts +2 -4
- package/dist/packages/provider/src/MessageSender.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +2 -1
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +2 -1
- package/dist/packages/provider/src/index.d.ts +0 -2
- package/dist/packages/provider/src/types.d.ts +12 -12
- package/dist/packages/server/src/ClientConnection.d.ts +19 -10
- package/dist/packages/server/src/Connection.d.ts +7 -23
- package/dist/packages/server/src/DirectConnection.d.ts +2 -2
- package/dist/packages/server/src/Document.d.ts +3 -7
- package/dist/packages/server/src/Hocuspocus.d.ts +7 -36
- package/dist/packages/server/src/IncomingMessage.d.ts +3 -3
- package/dist/packages/server/src/MessageReceiver.d.ts +4 -6
- package/dist/packages/server/src/OutgoingMessage.d.ts +4 -3
- package/dist/packages/server/src/Server.d.ts +23 -3
- package/dist/packages/server/src/index.d.ts +1 -1
- package/dist/packages/server/src/types.d.ts +15 -29
- package/dist/packages/server/src/util/getParameters.d.ts +1 -1
- package/dist/packages/transformer/src/Prosemirror.d.ts +1 -1
- package/dist/packages/transformer/src/Tiptap.d.ts +3 -3
- package/dist/packages/transformer/src/types.d.ts +1 -1
- package/dist/tests/utils/newHocuspocus.d.ts +2 -2
- package/dist/tests/utils/newHocuspocusProvider.d.ts +2 -2
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +4 -3
- package/dist/tests/utils/retryableAssertion.d.ts +1 -1
- package/package.json +2 -2
- package/src/EventEmitter.ts +3 -1
- package/src/HocuspocusProvider.ts +74 -200
- package/src/HocuspocusProviderWebsocket.ts +24 -75
- package/src/IncomingMessage.ts +5 -3
- package/src/MessageReceiver.ts +20 -19
- package/src/MessageSender.ts +3 -2
- package/src/OutgoingMessage.ts +3 -2
- package/src/OutgoingMessages/AuthenticationMessage.ts +2 -1
- package/src/OutgoingMessages/AwarenessMessage.ts +2 -1
- package/src/OutgoingMessages/CloseMessage.ts +2 -1
- package/src/OutgoingMessages/QueryAwarenessMessage.ts +2 -1
- package/src/OutgoingMessages/StatelessMessage.ts +2 -1
- package/src/OutgoingMessages/SyncStepOneMessage.ts +2 -1
- package/src/OutgoingMessages/SyncStepTwoMessage.ts +2 -1
- package/src/OutgoingMessages/UpdateMessage.ts +2 -1
- package/src/index.ts +0 -2
- package/src/types.ts +12 -12
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +0 -161
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +0 -19
- package/dist/packages/server/src/Debugger.d.ts +0 -14
- package/dist/tests/server/getMessageLogs.d.ts +0 -1
- package/dist/tests/server/requiresAuthentication.d.ts +0 -1
- package/src/TiptapCollabProvider.ts +0 -505
- package/src/TiptapCollabProviderWebsocket.ts +0 -38
package/src/IncomingMessage.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Decoder} from 'lib0/decoding'
|
|
1
3
|
import {
|
|
2
4
|
createDecoder,
|
|
3
5
|
peekVarString,
|
|
4
6
|
readVarUint,
|
|
5
7
|
readVarUint8Array,
|
|
6
8
|
readVarString,
|
|
7
|
-
Decoder,
|
|
8
9
|
} from 'lib0/decoding'
|
|
10
|
+
import type {
|
|
11
|
+
Encoder} from 'lib0/encoding'
|
|
9
12
|
import {
|
|
10
|
-
Encoder,
|
|
11
13
|
createEncoder,
|
|
12
14
|
writeVarUint,
|
|
13
15
|
writeVarUint8Array,
|
|
14
16
|
writeVarString,
|
|
15
17
|
length,
|
|
16
18
|
} from 'lib0/encoding'
|
|
17
|
-
import { MessageType } from './types.js'
|
|
19
|
+
import type { MessageType } from './types.js'
|
|
18
20
|
|
|
19
21
|
export class IncomingMessage {
|
|
20
22
|
|
package/src/MessageReceiver.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { readAuthMessage } from '@hocuspocus/common'
|
|
|
2
2
|
import { readVarInt, readVarString } from 'lib0/decoding'
|
|
3
3
|
import * as awarenessProtocol from 'y-protocols/awareness'
|
|
4
4
|
import { messageYjsSyncStep2, readSyncMessage } from 'y-protocols/sync'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import type { CloseEvent } from 'ws'
|
|
6
|
+
import type { HocuspocusProvider } from './HocuspocusProvider.js'
|
|
7
|
+
import type { IncomingMessage } from './IncomingMessage.js'
|
|
7
8
|
import { OutgoingMessage } from './OutgoingMessage.js'
|
|
8
9
|
import { MessageType } from './types.js'
|
|
9
10
|
|
|
@@ -11,18 +12,10 @@ export class MessageReceiver {
|
|
|
11
12
|
|
|
12
13
|
message: IncomingMessage
|
|
13
14
|
|
|
14
|
-
broadcasted = false
|
|
15
|
-
|
|
16
15
|
constructor(message: IncomingMessage) {
|
|
17
16
|
this.message = message
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
public setBroadcasted(value: boolean) {
|
|
21
|
-
this.broadcasted = value
|
|
22
|
-
|
|
23
|
-
return this
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
public apply(provider: HocuspocusProvider, emitSynced: boolean) {
|
|
27
20
|
const { message } = this
|
|
28
21
|
const type = message.readVarUint()
|
|
@@ -53,21 +46,29 @@ export class MessageReceiver {
|
|
|
53
46
|
case MessageType.SyncStatus:
|
|
54
47
|
this.applySyncStatusMessage(provider, readVarInt(message.decoder) === 1)
|
|
55
48
|
break
|
|
49
|
+
|
|
50
|
+
case MessageType.CLOSE:
|
|
51
|
+
// eslint-disable-next-line no-case-declarations
|
|
52
|
+
const event: CloseEvent = {
|
|
53
|
+
code: 1000,
|
|
54
|
+
reason: readVarString(message.decoder),
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
target: provider.configuration.websocketProvider.webSocket!,
|
|
57
|
+
type: 'close',
|
|
58
|
+
}
|
|
59
|
+
provider.onClose()
|
|
60
|
+
provider.configuration.onClose({ event })
|
|
61
|
+
provider.forwardClose(event)
|
|
62
|
+
break
|
|
63
|
+
|
|
56
64
|
default:
|
|
57
65
|
throw new Error(`Can’t apply message of unknown type: ${type}`)
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
// Reply
|
|
61
69
|
if (message.length() > emptyMessageLength + 1) { // length of documentName (considered in emptyMessageLength plus length of yjs sync type, set in applySyncMessage)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
provider.broadcast(OutgoingMessage, { encoder: message.encoder })
|
|
66
|
-
} else {
|
|
67
|
-
// TODO: Some weird TypeScript error
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
provider.send(OutgoingMessage, { encoder: message.encoder })
|
|
70
|
-
}
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
provider.send(OutgoingMessage, { encoder: message.encoder })
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
package/src/MessageSender.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Encoder
|
|
1
|
+
import type { Encoder} from 'lib0/encoding'
|
|
2
|
+
import { toUint8Array } from 'lib0/encoding'
|
|
2
3
|
import * as bc from 'lib0/broadcastchannel'
|
|
3
|
-
import { ConstructableOutgoingMessage } from './types.js'
|
|
4
|
+
import type { ConstructableOutgoingMessage } from './types.js'
|
|
4
5
|
|
|
5
6
|
export class MessageSender {
|
|
6
7
|
|
package/src/OutgoingMessage.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Encoder
|
|
2
|
-
import {
|
|
1
|
+
import type { Encoder} from 'lib0/encoding'
|
|
2
|
+
import { createEncoder, toUint8Array } from 'lib0/encoding'
|
|
3
|
+
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js'
|
|
3
4
|
|
|
4
5
|
export class OutgoingMessage implements OutgoingMessageInterface {
|
|
5
6
|
encoder: Encoder
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { writeVarString, writeVarUint } from 'lib0/encoding'
|
|
2
2
|
import { writeAuthentication } from '@hocuspocus/common'
|
|
3
|
-
import {
|
|
3
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
4
|
+
import { MessageType } from '../types.js'
|
|
4
5
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
5
6
|
|
|
6
7
|
export class AuthenticationMessage extends OutgoingMessage {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding'
|
|
2
2
|
import { encodeAwarenessUpdate } from 'y-protocols/awareness'
|
|
3
|
-
import {
|
|
3
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
4
|
+
import { MessageType } from '../types.js'
|
|
4
5
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
5
6
|
|
|
6
7
|
export class AwarenessMessage extends OutgoingMessage {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding'
|
|
2
|
-
import {
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
3
|
+
import { MessageType } from '../types.js'
|
|
3
4
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
4
5
|
|
|
5
6
|
export class CloseMessage extends OutgoingMessage {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding'
|
|
2
|
-
import {
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
3
|
+
import { MessageType } from '../types.js'
|
|
3
4
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
4
5
|
|
|
5
6
|
export class QueryAwarenessMessage extends OutgoingMessage {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { writeVarString, writeVarUint } from 'lib0/encoding'
|
|
2
|
-
import {
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
3
|
+
import { MessageType } from '../types.js'
|
|
3
4
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
4
5
|
|
|
5
6
|
export class StatelessMessage extends OutgoingMessage {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding'
|
|
2
2
|
import * as syncProtocol from 'y-protocols/sync'
|
|
3
|
-
import {
|
|
3
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
4
|
+
import { MessageType } from '../types.js'
|
|
4
5
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
5
6
|
|
|
6
7
|
export class SyncStepOneMessage extends OutgoingMessage {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding'
|
|
2
2
|
import * as syncProtocol from 'y-protocols/sync'
|
|
3
|
-
import {
|
|
3
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
4
|
+
import { MessageType } from '../types.js'
|
|
4
5
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
5
6
|
|
|
6
7
|
export class SyncStepTwoMessage extends OutgoingMessage {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { writeVarString, writeVarUint } from 'lib0/encoding'
|
|
2
2
|
import { writeUpdate } from 'y-protocols/sync'
|
|
3
|
-
import {
|
|
3
|
+
import type { OutgoingMessageArguments } from '../types.js'
|
|
4
|
+
import { MessageType } from '../types.js'
|
|
4
5
|
import { OutgoingMessage } from '../OutgoingMessage.js'
|
|
5
6
|
|
|
6
7
|
export class UpdateMessage extends OutgoingMessage {
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Encoder } from 'lib0/encoding'
|
|
1
|
+
import type { Encoder } from 'lib0/encoding'
|
|
2
2
|
import type { Event, MessageEvent } from 'ws'
|
|
3
|
-
import { Awareness } from 'y-protocols/awareness'
|
|
4
|
-
import * as Y from 'yjs'
|
|
5
|
-
import { CloseEvent } from '@hocuspocus/common'
|
|
6
|
-
import { IncomingMessage } from './IncomingMessage.js'
|
|
7
|
-
import { OutgoingMessage } from './OutgoingMessage.js'
|
|
8
|
-
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js'
|
|
9
|
-
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js'
|
|
10
|
-
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js'
|
|
11
|
-
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js'
|
|
12
|
-
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js'
|
|
13
|
-
import { UpdateMessage } from './OutgoingMessages/UpdateMessage.js'
|
|
3
|
+
import type { Awareness } from 'y-protocols/awareness'
|
|
4
|
+
import type * as Y from 'yjs'
|
|
5
|
+
import type { CloseEvent } from '@hocuspocus/common'
|
|
6
|
+
import type { IncomingMessage } from './IncomingMessage.js'
|
|
7
|
+
import type { OutgoingMessage } from './OutgoingMessage.js'
|
|
8
|
+
import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js'
|
|
9
|
+
import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js'
|
|
10
|
+
import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js'
|
|
11
|
+
import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js'
|
|
12
|
+
import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js'
|
|
13
|
+
import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.js'
|
|
14
14
|
|
|
15
15
|
export enum MessageType {
|
|
16
16
|
Sync = 0,
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import type { AbstractType, YArrayEvent } from 'yjs';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
|
|
4
|
-
import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js';
|
|
5
|
-
import { type DeleteCommentOptions, type DeleteThreadOptions, type GetThreadsOptions, type TCollabComment, type TCollabThread, type THistoryVersion } from './types.js';
|
|
6
|
-
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'baseUrl'>>) & Pick<AdditionalTiptapCollabProviderConfiguration, 'user'> & {
|
|
7
|
-
/**
|
|
8
|
-
* Pass `true` if you want to delete a thread when the first comment is deleted.
|
|
9
|
-
*/
|
|
10
|
-
deleteThreadOnFirstCommentDelete?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export interface AdditionalTiptapCollabProviderConfiguration {
|
|
13
|
-
/**
|
|
14
|
-
* A Hocuspocus Cloud App ID, get one here: https://cloud.tiptap.dev
|
|
15
|
-
*/
|
|
16
|
-
appId?: string;
|
|
17
|
-
/**
|
|
18
|
-
* If you are using the on-premise version of TiptapCollab, put your baseUrl here (e.g. https://collab.yourdomain.com)
|
|
19
|
-
*/
|
|
20
|
-
baseUrl?: string;
|
|
21
|
-
websocketProvider?: TiptapCollabProviderWebsocket;
|
|
22
|
-
user?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
25
|
-
tiptapCollabConfigurationPrefix: string;
|
|
26
|
-
userData?: Y.PermanentUserData;
|
|
27
|
-
constructor(configuration: TiptapCollabProviderConfiguration);
|
|
28
|
-
/**
|
|
29
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
30
|
-
*/
|
|
31
|
-
createVersion(name?: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
34
|
-
*/
|
|
35
|
-
revertToVersion(targetVersion: number): void;
|
|
36
|
-
/**
|
|
37
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
38
|
-
*
|
|
39
|
-
* The server will reply with a stateless message (THistoryVersionPreviewEvent)
|
|
40
|
-
*/
|
|
41
|
-
previewVersion(targetVersion: number): void;
|
|
42
|
-
/**
|
|
43
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
44
|
-
*/
|
|
45
|
-
getVersions(): THistoryVersion[];
|
|
46
|
-
watchVersions(callback: Parameters<AbstractType<YArrayEvent<THistoryVersion>>['observe']>[0]): void;
|
|
47
|
-
unwatchVersions(callback: Parameters<AbstractType<YArrayEvent<THistoryVersion>>['unobserve']>[0]): void;
|
|
48
|
-
isAutoVersioning(): boolean;
|
|
49
|
-
enableAutoVersioning(): 1;
|
|
50
|
-
disableAutoVersioning(): 0;
|
|
51
|
-
/**
|
|
52
|
-
* Returns all users in the document as Y.Map objects
|
|
53
|
-
* @returns An array of Y.Map objects
|
|
54
|
-
*/
|
|
55
|
-
private getYThreads;
|
|
56
|
-
/**
|
|
57
|
-
* Finds all threads in the document and returns them as JSON objects
|
|
58
|
-
* @options Options to control the output of the threads (e.g. include deleted threads)
|
|
59
|
-
* @returns An array of threads as JSON objects
|
|
60
|
-
*/
|
|
61
|
-
getThreads<Data, CommentData>(options?: GetThreadsOptions): TCollabThread<Data, CommentData>[];
|
|
62
|
-
/**
|
|
63
|
-
* Find the index of a thread by its id
|
|
64
|
-
* @param id The thread id
|
|
65
|
-
* @returns The index of the thread or null if not found
|
|
66
|
-
*/
|
|
67
|
-
private getThreadIndex;
|
|
68
|
-
/**
|
|
69
|
-
* Gets a single thread by its id
|
|
70
|
-
* @param id The thread id
|
|
71
|
-
* @returns The thread as a JSON object or null if not found
|
|
72
|
-
*/
|
|
73
|
-
getThread<Data, CommentData>(id: string): TCollabThread<Data, CommentData> | null;
|
|
74
|
-
/**
|
|
75
|
-
* Gets a single thread by its id as a Y.Map object
|
|
76
|
-
* @param id The thread id
|
|
77
|
-
* @returns The thread as a Y.Map object or null if not found
|
|
78
|
-
*/
|
|
79
|
-
private getYThread;
|
|
80
|
-
/**
|
|
81
|
-
* Create a new thread
|
|
82
|
-
* @param data The thread data
|
|
83
|
-
* @returns The created thread
|
|
84
|
-
*/
|
|
85
|
-
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'comments' | 'deletedComments'>): TCollabThread;
|
|
86
|
-
/**
|
|
87
|
-
* Update a specific thread
|
|
88
|
-
* @param id The thread id
|
|
89
|
-
* @param data New data for the thread
|
|
90
|
-
* @returns The updated thread or null if the thread is not found
|
|
91
|
-
*/
|
|
92
|
-
updateThread(id: TCollabThread['id'], data: Partial<Pick<TCollabThread, 'data'> & {
|
|
93
|
-
resolvedAt: TCollabThread['resolvedAt'] | null;
|
|
94
|
-
}>): TCollabThread;
|
|
95
|
-
/**
|
|
96
|
-
* Handle the deletion of a thread. By default, the thread and it's comments are not deleted, but marked as deleted
|
|
97
|
-
* via the `deletedAt` property. Forceful deletion can be enabled by setting the `force` option to `true`.
|
|
98
|
-
*
|
|
99
|
-
* If you only want to delete the comments of a thread, you can set the `deleteComments` option to `true`.
|
|
100
|
-
* @param id The thread id
|
|
101
|
-
* @param options A set of options that control how the thread is deleted
|
|
102
|
-
* @returns The deleted thread or null if the thread is not found
|
|
103
|
-
*/
|
|
104
|
-
deleteThread(id: TCollabThread['id'], options?: DeleteThreadOptions): TCollabThread | null | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* Tries to restore a deleted thread
|
|
107
|
-
* @param id The thread id
|
|
108
|
-
* @returns The restored thread or null if the thread is not found
|
|
109
|
-
*/
|
|
110
|
-
restoreThread(id: TCollabThread['id']): TCollabThread | null;
|
|
111
|
-
/**
|
|
112
|
-
* Returns comments from a thread, either deleted or not
|
|
113
|
-
* @param threadId The thread id
|
|
114
|
-
* @param includeDeleted If you want to include deleted comments, defaults to `false`
|
|
115
|
-
* @returns The comments or null if the thread is not found
|
|
116
|
-
*/
|
|
117
|
-
getThreadComments(threadId: TCollabThread['id'], includeDeleted?: boolean): TCollabComment[] | null;
|
|
118
|
-
/**
|
|
119
|
-
* Get a single comment from a specific thread
|
|
120
|
-
* @param threadId The thread id
|
|
121
|
-
* @param commentId The comment id
|
|
122
|
-
* @param includeDeleted If you want to include deleted comments in the search
|
|
123
|
-
* @returns The comment or null if not found
|
|
124
|
-
*/
|
|
125
|
-
getThreadComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], includeDeleted?: boolean): TCollabComment | null;
|
|
126
|
-
/**
|
|
127
|
-
* Adds a comment to a thread
|
|
128
|
-
* @param threadId The thread id
|
|
129
|
-
* @param data The comment data
|
|
130
|
-
* @returns The updated thread or null if the thread is not found
|
|
131
|
-
* @example addComment('123', { content: 'Hello world', data: { author: 'Maria Doe' } })
|
|
132
|
-
*/
|
|
133
|
-
addComment(threadId: TCollabThread['id'], data: Omit<TCollabComment, 'id' | 'updatedAt' | 'createdAt'>): TCollabThread;
|
|
134
|
-
/**
|
|
135
|
-
* Update a comment in a thread
|
|
136
|
-
* @param threadId The thread id
|
|
137
|
-
* @param commentId The comment id
|
|
138
|
-
* @param data The new comment data
|
|
139
|
-
* @returns The updated thread or null if the thread or comment is not found
|
|
140
|
-
* @example updateComment('123', { content: 'The new content', data: { attachments: ['file1.jpg'] }})
|
|
141
|
-
*/
|
|
142
|
-
updateComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], data: Partial<Pick<TCollabComment, 'data' | 'content'>>): TCollabThread;
|
|
143
|
-
/**
|
|
144
|
-
* Deletes a comment from a thread
|
|
145
|
-
* @param threadId The thread id
|
|
146
|
-
* @param commentId The comment id
|
|
147
|
-
* @param options A set of options that control how the comment is deleted
|
|
148
|
-
* @returns The updated thread or null if the thread or comment is not found
|
|
149
|
-
*/
|
|
150
|
-
deleteComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], options?: DeleteCommentOptions): TCollabThread | null | undefined;
|
|
151
|
-
/**
|
|
152
|
-
* Start watching threads for changes
|
|
153
|
-
* @param callback The callback function to be called when a thread changes
|
|
154
|
-
*/
|
|
155
|
-
watchThreads(callback: () => void): void;
|
|
156
|
-
/**
|
|
157
|
-
* Stop watching threads for changes
|
|
158
|
-
* @param callback The callback function to be removed
|
|
159
|
-
*/
|
|
160
|
-
unwatchThreads(callback: () => void): void;
|
|
161
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
|
|
2
|
-
export type TiptapCollabProviderWebsocketConfiguration = Partial<CompleteHocuspocusProviderWebsocketConfiguration> & AdditionalTiptapCollabProviderWebsocketConfiguration;
|
|
3
|
-
export interface AdditionalTiptapCollabProviderWebsocketConfiguration {
|
|
4
|
-
/**
|
|
5
|
-
* A Hocuspocus Cloud App ID, get one here: https://cloud.tiptap.dev
|
|
6
|
-
*/
|
|
7
|
-
appId?: string;
|
|
8
|
-
/**
|
|
9
|
-
* If you are using the on-premise version of TiptapCollab, put your baseUrl here (e.g. https://collab.yourdomain.com)
|
|
10
|
-
*/
|
|
11
|
-
baseUrl?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Only fill this if you are using Tiptap Collab HA.
|
|
14
|
-
*/
|
|
15
|
-
shardKey?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class TiptapCollabProviderWebsocket extends HocuspocusProviderWebsocket {
|
|
18
|
-
constructor(configuration: TiptapCollabProviderWebsocketConfiguration);
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|