@hocuspocus/extension-webhook 2.5.0 → 2.6.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.
|
@@ -4,6 +4,9 @@ import { Event } from 'ws';
|
|
|
4
4
|
import EventEmitter from './EventEmitter.js';
|
|
5
5
|
import { HocuspocusProvider } from './HocuspocusProvider.js';
|
|
6
6
|
import { WebSocketStatus, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js';
|
|
7
|
+
export type HocusPocusWebSocket = WebSocket & {
|
|
8
|
+
identifier: string;
|
|
9
|
+
};
|
|
7
10
|
export type HocuspocusProviderWebsocketConfiguration = Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> & Partial<CompleteHocuspocusProviderWebsocketConfiguration>;
|
|
8
11
|
export interface CompleteHocuspocusProviderWebsocketConfiguration {
|
|
9
12
|
/**
|
|
@@ -79,10 +82,14 @@ export declare class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
79
82
|
private messageQueue;
|
|
80
83
|
configuration: CompleteHocuspocusProviderWebsocketConfiguration;
|
|
81
84
|
subscribedToBroadcastChannel: boolean;
|
|
82
|
-
webSocket:
|
|
85
|
+
webSocket: HocusPocusWebSocket | null;
|
|
86
|
+
webSocketHandlers: {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
};
|
|
83
89
|
shouldConnect: boolean;
|
|
84
90
|
status: WebSocketStatus;
|
|
85
91
|
lastMessageReceived: number;
|
|
92
|
+
identifier: number;
|
|
86
93
|
mux: mutex.mutex;
|
|
87
94
|
intervals: any;
|
|
88
95
|
connectionAttempt: {
|
|
@@ -100,6 +107,8 @@ export declare class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
100
107
|
boundConnect: () => Promise<unknown>;
|
|
101
108
|
cancelWebsocketRetry?: () => void;
|
|
102
109
|
connect(): Promise<unknown>;
|
|
110
|
+
attachWebSocketListeners(ws: HocusPocusWebSocket, reject: Function): void;
|
|
111
|
+
cleanupWebSocket(): void;
|
|
103
112
|
createWebSocketConnection(): Promise<unknown>;
|
|
104
113
|
onMessage(event: MessageEvent): void;
|
|
105
114
|
resolveConnectionAttempt(): void;
|
|
@@ -107,7 +116,6 @@ export declare class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
107
116
|
rejectConnectionAttempt(): void;
|
|
108
117
|
closeTries: number;
|
|
109
118
|
checkConnection(): void;
|
|
110
|
-
registerEventListeners(): void;
|
|
111
119
|
get serverUrl(): string;
|
|
112
120
|
get url(): string;
|
|
113
121
|
disconnect(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AbstractType, YArrayEvent } from 'yjs';
|
|
2
2
|
import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
|
|
3
3
|
import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js';
|
|
4
|
+
import type { THistoryVersion } from './types';
|
|
4
5
|
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>>);
|
|
5
6
|
export interface AdditionalTiptapCollabProviderConfiguration {
|
|
6
7
|
/**
|
|
@@ -9,19 +10,29 @@ export interface AdditionalTiptapCollabProviderConfiguration {
|
|
|
9
10
|
appId?: string;
|
|
10
11
|
websocketProvider?: TiptapCollabProviderWebsocket;
|
|
11
12
|
}
|
|
12
|
-
export type AuditHistoryVersion = {
|
|
13
|
-
name?: string;
|
|
14
|
-
version: number;
|
|
15
|
-
date: number;
|
|
16
|
-
};
|
|
17
13
|
export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
18
14
|
tiptapCollabConfigurationPrefix: string;
|
|
19
15
|
constructor(configuration: TiptapCollabProviderConfiguration);
|
|
16
|
+
/**
|
|
17
|
+
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
18
|
+
*/
|
|
20
19
|
createVersion(name?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
22
|
+
*/
|
|
21
23
|
revertToVersion(targetVersion: number): void;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
26
|
+
*
|
|
27
|
+
* The server will reply with a stateless message (THistoryVersionPreviewEvent)
|
|
28
|
+
*/
|
|
29
|
+
previewVersion(targetVersion: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
32
|
+
*/
|
|
33
|
+
getVersions(): THistoryVersion[];
|
|
34
|
+
watchVersions(callback: Parameters<AbstractType<YArrayEvent<THistoryVersion>>['observe']>[0]): void;
|
|
35
|
+
unwatchVersions(callback: Parameters<AbstractType<YArrayEvent<THistoryVersion>>['unobserve']>[0]): void;
|
|
25
36
|
isAutoVersioning(): boolean;
|
|
26
37
|
enableAutoVersioning(): 1;
|
|
27
38
|
disableAutoVersioning(): 0;
|
|
@@ -84,3 +84,48 @@ export type StatesArray = {
|
|
|
84
84
|
clientId: number;
|
|
85
85
|
[key: string | number]: any;
|
|
86
86
|
}[];
|
|
87
|
+
export type THistoryVersion = {
|
|
88
|
+
name?: string;
|
|
89
|
+
version: number;
|
|
90
|
+
date: number;
|
|
91
|
+
};
|
|
92
|
+
export type THistoryConfiguration = {
|
|
93
|
+
autoVersioning: boolean;
|
|
94
|
+
currentVersion: number;
|
|
95
|
+
stateCaptured: number;
|
|
96
|
+
};
|
|
97
|
+
export type THistoryAction = THistoryDocumentRevertAction | THistoryVersionCreateAction | THistoryVersionPreviewAction;
|
|
98
|
+
export type THistoryDocumentRevertAction = {
|
|
99
|
+
action: 'document.revert';
|
|
100
|
+
/**
|
|
101
|
+
* if changes havent been persisted to a version yet, we'll create one with the specified name,
|
|
102
|
+
* expect when `false` is passed.
|
|
103
|
+
*/
|
|
104
|
+
currentVersionName?: string | false;
|
|
105
|
+
/**
|
|
106
|
+
* Name of the version that is created after the revert. Pass `false` to avoid generating a new version.
|
|
107
|
+
*/
|
|
108
|
+
newVersionName?: string | false;
|
|
109
|
+
};
|
|
110
|
+
export type THistoryVersionCreateAction = {
|
|
111
|
+
action: 'version.create';
|
|
112
|
+
name?: string;
|
|
113
|
+
};
|
|
114
|
+
export type THistoryVersionPreviewAction = {
|
|
115
|
+
action: 'version.preview';
|
|
116
|
+
version: number;
|
|
117
|
+
};
|
|
118
|
+
export type THistoryEvent = THistoryVersionPreviewEvent | THistoryVersionCreatedEvent | THistoryDocumentRevertedEvent;
|
|
119
|
+
export type THistoryVersionCreatedEvent = {
|
|
120
|
+
event: 'version.created';
|
|
121
|
+
version: number;
|
|
122
|
+
};
|
|
123
|
+
export type THistoryVersionPreviewEvent = {
|
|
124
|
+
event: 'version.preview';
|
|
125
|
+
version: number;
|
|
126
|
+
ydoc: string;
|
|
127
|
+
};
|
|
128
|
+
export type THistoryDocumentRevertedEvent = {
|
|
129
|
+
event: 'document.reverted';
|
|
130
|
+
version: number;
|
|
131
|
+
};
|
|
@@ -39,7 +39,7 @@ export interface Extension {
|
|
|
39
39
|
connected?(data: connectedPayload): Promise<any>;
|
|
40
40
|
onAuthenticate?(data: onAuthenticatePayload): Promise<any>;
|
|
41
41
|
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
42
|
-
afterLoadDocument?(data:
|
|
42
|
+
afterLoadDocument?(data: afterLoadDocumentPayload): Promise<any>;
|
|
43
43
|
beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>;
|
|
44
44
|
beforeBroadcastStateless?(data: beforeBroadcastStatelessPayload): Promise<any>;
|
|
45
45
|
onStateless?(payload: onStatelessPayload): Promise<any>;
|
|
@@ -49,7 +49,7 @@ export interface Extension {
|
|
|
49
49
|
onAwarenessUpdate?(data: onAwarenessUpdatePayload): Promise<any>;
|
|
50
50
|
onRequest?(data: onRequestPayload): Promise<any>;
|
|
51
51
|
onDisconnect?(data: onDisconnectPayload): Promise<any>;
|
|
52
|
-
afterUnloadDocument?(data:
|
|
52
|
+
afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
|
|
53
53
|
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
54
54
|
}
|
|
55
55
|
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy';
|
|
@@ -61,7 +61,7 @@ export type HookPayloadByName = {
|
|
|
61
61
|
connected: connectedPayload;
|
|
62
62
|
onAuthenticate: onAuthenticatePayload;
|
|
63
63
|
onLoadDocument: onLoadDocumentPayload;
|
|
64
|
-
afterLoadDocument:
|
|
64
|
+
afterLoadDocument: afterLoadDocumentPayload;
|
|
65
65
|
beforeHandleMessage: beforeHandleMessagePayload;
|
|
66
66
|
beforeBroadcastStateless: beforeBroadcastStatelessPayload;
|
|
67
67
|
onStateless: onStatelessPayload;
|
|
@@ -140,6 +140,7 @@ export interface onAuthenticatePayload {
|
|
|
140
140
|
connection: ConnectionConfiguration;
|
|
141
141
|
}
|
|
142
142
|
export interface onConnectPayload {
|
|
143
|
+
context: any;
|
|
143
144
|
documentName: string;
|
|
144
145
|
instance: Hocuspocus;
|
|
145
146
|
request: IncomingMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-webhook",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "hocuspocus webhook extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@hocuspocus/common": "^2.
|
|
34
|
-
"@hocuspocus/server": "^2.
|
|
35
|
-
"@hocuspocus/transformer": "^2.
|
|
33
|
+
"@hocuspocus/common": "^2.6.1",
|
|
34
|
+
"@hocuspocus/server": "^2.6.1",
|
|
35
|
+
"@hocuspocus/transformer": "^2.6.1",
|
|
36
36
|
"axios": "^1.2.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|