@hocuspocus/extension-webhook 1.0.0-alpha.62 → 1.0.0-alpha.63
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/packages/extension-redis/src/Redis.d.ts +87 -9
- package/dist/packages/extension-redis/src/index.d.ts +0 -1
- package/dist/packages/server/src/index.d.ts +3 -4
- package/dist/tests/{extension-redis-rewrite → extension-redis}/closeConnections.d.ts +0 -0
- package/dist/tests/{extension-redis-rewrite → extension-redis}/getConnectionCount.d.ts +0 -0
- package/dist/tests/{extension-redis-rewrite → extension-redis}/getDocumentsCount.d.ts +0 -0
- package/dist/tests/{extension-redis-rewrite → extension-redis}/onAwarenessChange.d.ts +0 -0
- package/dist/tests/{extension-redis-rewrite → extension-redis}/onChange.d.ts +0 -0
- package/dist/tests/{extension-redis-rewrite → extension-redis}/onStoreDocument.d.ts +0 -0
- package/package.json +3 -3
- package/dist/packages/extension-redis/src/RedisCluster.d.ts +0 -4
- package/dist/tests/extension-redis/onLoadDocument.d.ts +0 -1
- package/dist/tests/extension-redis/onSynced.d.ts +0 -1
|
@@ -1,16 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import RedisClient from 'ioredis';
|
|
2
|
+
import Redlock from 'redlock';
|
|
3
|
+
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, Debugger, onConfigurePayload } from '@hocuspocus/server';
|
|
3
4
|
export interface Configuration {
|
|
5
|
+
/**
|
|
6
|
+
* Redis port
|
|
7
|
+
*/
|
|
8
|
+
port: number;
|
|
9
|
+
/**
|
|
10
|
+
* Redis host
|
|
11
|
+
*/
|
|
12
|
+
host: string;
|
|
13
|
+
/**
|
|
14
|
+
* Options passed directly to Redis constructor
|
|
15
|
+
*
|
|
16
|
+
* https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
|
|
17
|
+
*/
|
|
18
|
+
options?: RedisClient.RedisOptions;
|
|
19
|
+
/**
|
|
20
|
+
* An unique instance name, required to filter messages in Redis.
|
|
21
|
+
* If none is provided an unique id is generated.
|
|
22
|
+
*/
|
|
23
|
+
identifier: string;
|
|
24
|
+
/**
|
|
25
|
+
* Namespace for Redis keys, if none is provided 'hocuspocus' is used
|
|
26
|
+
*/
|
|
27
|
+
prefix: string;
|
|
28
|
+
/**
|
|
29
|
+
* The maximum time for the Redis lock in ms (in case it can’t be released).
|
|
30
|
+
*/
|
|
31
|
+
lockTimeout: number;
|
|
4
32
|
}
|
|
5
33
|
export declare class Redis implements Extension {
|
|
34
|
+
/**
|
|
35
|
+
* Make sure to give that extension a higher priority, so
|
|
36
|
+
* the `onStoreDocument` hook is able to intercept the chain,
|
|
37
|
+
* before documents are stored to the database.
|
|
38
|
+
*/
|
|
39
|
+
priority: number;
|
|
6
40
|
configuration: Configuration;
|
|
7
|
-
|
|
8
|
-
|
|
41
|
+
pub: RedisClient.Redis;
|
|
42
|
+
sub: RedisClient.Redis;
|
|
43
|
+
documents: Map<string, Document>;
|
|
44
|
+
redlock: Redlock;
|
|
45
|
+
locks: Map<string, Redlock.Lock>;
|
|
46
|
+
logger: Debugger;
|
|
47
|
+
constructor(configuration: Partial<Configuration>);
|
|
48
|
+
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
49
|
+
onListen(): Promise<void>;
|
|
50
|
+
private getKey;
|
|
51
|
+
private pubKey;
|
|
52
|
+
private subKey;
|
|
53
|
+
private lockKey;
|
|
54
|
+
/**
|
|
55
|
+
* Once a document is laoded, subscribe to the channel in Redis.
|
|
56
|
+
*/
|
|
57
|
+
afterLoadDocument({ documentName, document }: afterLoadDocumentPayload): Promise<unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* Publish the first sync step through Redis.
|
|
60
|
+
*/
|
|
61
|
+
private publishFirstSyncStep;
|
|
62
|
+
/**
|
|
63
|
+
* Let’s ask Redis who is connected already.
|
|
64
|
+
*/
|
|
65
|
+
private requestAwarenessFromOtherInstances;
|
|
66
|
+
/**
|
|
67
|
+
* Before the document is stored, make sure to set a lock in Redis.
|
|
68
|
+
* That’s meant to avoid conflicts with other instances trying to store the document.
|
|
69
|
+
*/
|
|
70
|
+
onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Release the Redis lock, so other instances can store documents.
|
|
73
|
+
*/
|
|
74
|
+
afterStoreDocument({ documentName }: afterStoreDocumentPayload): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Handle awareness update messages received directly by this Hocuspocus instance.
|
|
77
|
+
*/
|
|
78
|
+
onAwarenessUpdate({ documentName, awareness }: onAwarenessUpdatePayload): Promise<number>;
|
|
79
|
+
/**
|
|
80
|
+
* Handle incoming messages published on all subscribed document channels.
|
|
81
|
+
* Note that this will also include messages from ourselves as it is not possible
|
|
82
|
+
* in Redis to filter these.
|
|
83
|
+
*/
|
|
84
|
+
private handleIncomingMessage;
|
|
85
|
+
/**
|
|
86
|
+
* Make sure to *not* listen for further changes, when there’s
|
|
87
|
+
* noone connected anymore.
|
|
88
|
+
*/
|
|
89
|
+
onDisconnect: ({ documentName, clientsCount }: onDisconnectPayload) => Promise<void>;
|
|
9
90
|
/**
|
|
10
|
-
*
|
|
91
|
+
* Kill the Redlock connection immediately.
|
|
11
92
|
*/
|
|
12
|
-
|
|
13
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<import("yjs").Doc | undefined>;
|
|
14
|
-
onConnect(data: onConnectPayload): Promise<void>;
|
|
15
|
-
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
93
|
+
onDestroy(): Promise<void>;
|
|
16
94
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export * from './Hocuspocus';
|
|
2
1
|
export * from './Connection';
|
|
2
|
+
export * from './Debugger';
|
|
3
3
|
export * from './Document';
|
|
4
|
+
export * from './Hocuspocus';
|
|
4
5
|
export * from './IncomingMessage';
|
|
6
|
+
export * from './MessageReceiver';
|
|
5
7
|
export * from './OutgoingMessage';
|
|
6
8
|
export * from './types';
|
|
7
|
-
export * from './MessageReceiver';
|
|
8
|
-
export * from './Document';
|
|
9
|
-
export * from './Connection';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-webhook",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.63",
|
|
4
4
|
"description": "hocuspocus webhook extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@hocuspocus/server": "^1.0.0-alpha.
|
|
32
|
+
"@hocuspocus/server": "^1.0.0-alpha.99",
|
|
33
33
|
"@hocuspocus/transformer": "^1.0.0-alpha.22",
|
|
34
34
|
"axios": "^0.26.1",
|
|
35
35
|
"yjs": "^13.5.29"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "e26a5eeaa9278b9587d4b475cec53bf14bc569b9"
|
|
38
38
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|