@hocuspocus/extension-sqlite 2.1.0-alpha.0 → 2.1.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-sqlite.cjs +46 -46
- package/dist/hocuspocus-sqlite.esm.js +46 -46
- package/dist/packages/common/src/CloseEvents.d.ts +29 -29
- package/dist/packages/common/src/auth.d.ts +6 -6
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +3 -3
- package/dist/packages/common/src/index.d.ts +4 -4
- package/dist/packages/common/src/types.d.ts +10 -10
- package/dist/packages/extension-database/src/Database.d.ts +30 -30
- package/dist/packages/extension-database/src/index.d.ts +1 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +67 -67
- package/dist/packages/extension-logger/src/index.d.ts +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +116 -95
- package/dist/packages/extension-redis/src/index.d.ts +1 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -26
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
- package/dist/packages/extension-throttle/src/index.d.ts +31 -31
- package/dist/packages/extension-webhook/src/index.d.ts +57 -57
- package/dist/packages/provider/src/EventEmitter.d.ts +9 -9
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +110 -110
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +115 -115
- package/dist/packages/provider/src/IncomingMessage.d.ts +16 -16
- package/dist/packages/provider/src/MessageReceiver.d.ts +13 -13
- package/dist/packages/provider/src/MessageSender.d.ts +10 -10
- package/dist/packages/provider/src/OutgoingMessage.d.ts +9 -9
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +7 -7
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +7 -7
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +7 -7
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +11 -11
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +11 -11
- package/dist/packages/provider/src/index.d.ts +5 -5
- package/dist/packages/provider/src/types.d.ts +84 -84
- package/dist/packages/server/src/Connection.d.ts +71 -71
- package/dist/packages/server/src/Debugger.d.ts +14 -14
- package/dist/packages/server/src/DirectConnection.d.ts +13 -0
- package/dist/packages/server/src/Document.d.ts +91 -88
- package/dist/packages/server/src/Hocuspocus.d.ts +111 -108
- package/dist/packages/server/src/IncomingMessage.d.ts +21 -21
- package/dist/packages/server/src/MessageReceiver.d.ts +12 -12
- package/dist/packages/server/src/OutgoingMessage.d.ts +20 -20
- package/dist/packages/server/src/index.d.ts +8 -8
- package/dist/packages/server/src/types.d.ts +266 -264
- package/dist/packages/transformer/src/Prosemirror.d.ts +11 -11
- package/dist/packages/transformer/src/Tiptap.d.ts +10 -10
- package/dist/packages/transformer/src/index.d.ts +3 -3
- package/dist/packages/transformer/src/types.d.ts +5 -5
- package/dist/playground/backend/src/default.d.ts +1 -1
- package/dist/playground/backend/src/express.d.ts +1 -1
- package/dist/playground/backend/src/koa.d.ts +1 -1
- package/dist/playground/backend/src/load-document.d.ts +1 -1
- package/dist/playground/backend/src/redis.d.ts +1 -1
- package/dist/playground/backend/src/slow.d.ts +1 -1
- package/dist/playground/backend/src/tiptapcollab.d.ts +1 -1
- package/dist/playground/backend/src/webhook.d.ts +1 -1
- package/dist/playground/frontend/src/main.d.ts +1 -1
- package/dist/playground/frontend/vite.config.d.ts +2 -2
- package/dist/tests/extension-database/fetch.d.ts +1 -1
- package/dist/tests/extension-logger/onListen.d.ts +1 -1
- package/dist/tests/extension-redis/closeConnections.d.ts +1 -1
- package/dist/tests/extension-redis/getConnectionCount.d.ts +1 -1
- package/dist/tests/extension-redis/getDocumentsCount.d.ts +1 -1
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +1 -1
- package/dist/tests/extension-redis/onChange.d.ts +1 -1
- package/dist/tests/extension-redis/onStateless.d.ts +1 -1
- package/dist/tests/extension-redis/onStoreDocument.d.ts +1 -1
- package/dist/tests/extension-throttle/banning.d.ts +1 -1
- package/dist/tests/extension-throttle/configuration.d.ts +1 -1
- package/dist/tests/provider/observe.d.ts +1 -1
- package/dist/tests/provider/observeDeep.d.ts +1 -1
- package/dist/tests/provider/onAuthenticated.d.ts +1 -1
- package/dist/tests/provider/onAuthenticationFailed.d.ts +1 -1
- package/dist/tests/provider/onAwarenessChange.d.ts +1 -1
- package/dist/tests/provider/onAwarenessUpdate.d.ts +1 -1
- package/dist/tests/provider/onClose.d.ts +1 -1
- package/dist/tests/provider/onConnect.d.ts +1 -1
- package/dist/tests/provider/onDisconnect.d.ts +1 -1
- package/dist/tests/provider/onMessage.d.ts +1 -1
- package/dist/tests/provider/onOpen.d.ts +1 -1
- package/dist/tests/provider/onStateless.d.ts +1 -1
- package/dist/tests/provider/onSynced.d.ts +1 -1
- package/dist/tests/providerwebsocket/configuration.d.ts +1 -1
- package/dist/tests/server/address.d.ts +1 -1
- package/dist/tests/server/afterStoreDocument.d.ts +1 -1
- package/dist/tests/server/beforeBroadcastStateless.d.ts +1 -1
- package/dist/tests/server/beforeHandleMessage.d.ts +1 -1
- package/dist/tests/server/closeConnections.d.ts +1 -1
- package/dist/tests/server/getConnectionsCount.d.ts +1 -1
- package/dist/tests/server/getDocumentsCount.d.ts +1 -1
- package/dist/tests/server/getMessageLogs.d.ts +1 -1
- package/dist/tests/server/listen.d.ts +1 -1
- package/dist/tests/server/onAuthenticate.d.ts +1 -1
- package/dist/tests/server/onAwarenessUpdate.d.ts +1 -1
- package/dist/tests/server/onChange.d.ts +1 -1
- package/dist/tests/server/onClose.d.ts +1 -1
- package/dist/tests/server/onConfigure.d.ts +1 -1
- package/dist/tests/server/onConnect.d.ts +1 -1
- package/dist/tests/server/onDestroy.d.ts +1 -1
- package/dist/tests/server/onDisconnect.d.ts +1 -1
- package/dist/tests/server/onListen.d.ts +1 -1
- package/dist/tests/server/onLoadDocument.d.ts +1 -1
- package/dist/tests/server/onRequest.d.ts +1 -1
- package/dist/tests/server/onStateless.d.ts +1 -1
- package/dist/tests/server/onStoreDocument.d.ts +1 -1
- package/dist/tests/server/onUpgrade.d.ts +1 -1
- package/dist/tests/server/openDirectConnection.d.ts +1 -0
- package/dist/tests/server/requiresAuthentication.d.ts +1 -1
- package/dist/tests/server/websocketError.d.ts +1 -1
- package/dist/tests/transformer/TiptapTransformer.d.ts +1 -1
- package/dist/tests/utils/createDirectory.d.ts +1 -1
- package/dist/tests/utils/flushRedis.d.ts +1 -1
- package/dist/tests/utils/index.d.ts +9 -9
- package/dist/tests/utils/newHocuspocus.d.ts +2 -2
- package/dist/tests/utils/newHocuspocusProvider.d.ts +3 -3
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +3 -3
- package/dist/tests/utils/randomInteger.d.ts +1 -1
- package/dist/tests/utils/redisConnectionSettings.d.ts +4 -4
- package/dist/tests/utils/removeDirectory.d.ts +1 -1
- package/dist/tests/utils/retryableAssertion.d.ts +2 -2
- package/dist/tests/utils/sleep.d.ts +1 -1
- package/package.json +4 -3
- package/src/index.ts +1 -1
|
@@ -1,95 +1,116 @@
|
|
|
1
|
-
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
private
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
1
|
+
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
|
|
2
|
+
import Redlock from 'redlock';
|
|
3
|
+
import { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
|
|
4
|
+
export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;
|
|
5
|
+
export interface Configuration {
|
|
6
|
+
/**
|
|
7
|
+
* Redis port
|
|
8
|
+
*/
|
|
9
|
+
port: number;
|
|
10
|
+
/**
|
|
11
|
+
* Redis host
|
|
12
|
+
*/
|
|
13
|
+
host: string;
|
|
14
|
+
/**
|
|
15
|
+
* Redis Cluster
|
|
16
|
+
*/
|
|
17
|
+
nodes?: ClusterNode[];
|
|
18
|
+
/**
|
|
19
|
+
* Duplicate from an existed Redis instance
|
|
20
|
+
*/
|
|
21
|
+
redis?: RedisInstance;
|
|
22
|
+
/**
|
|
23
|
+
* Redis instance creator
|
|
24
|
+
*/
|
|
25
|
+
createClient?: () => RedisInstance;
|
|
26
|
+
/**
|
|
27
|
+
* Options passed directly to Redis constructor
|
|
28
|
+
*
|
|
29
|
+
* https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
|
|
30
|
+
*/
|
|
31
|
+
options?: ClusterOptions | RedisOptions;
|
|
32
|
+
/**
|
|
33
|
+
* An unique instance name, required to filter messages in Redis.
|
|
34
|
+
* If none is provided an unique id is generated.
|
|
35
|
+
*/
|
|
36
|
+
identifier: string;
|
|
37
|
+
/**
|
|
38
|
+
* Namespace for Redis keys, if none is provided 'hocuspocus' is used
|
|
39
|
+
*/
|
|
40
|
+
prefix: string;
|
|
41
|
+
/**
|
|
42
|
+
* The maximum time for the Redis lock in ms (in case it can’t be released).
|
|
43
|
+
*/
|
|
44
|
+
lockTimeout: number;
|
|
45
|
+
/**
|
|
46
|
+
* A delay before onDisconnect is executed. This allows last minute updates'
|
|
47
|
+
* sync messages to be received by the subscription before it's closed.
|
|
48
|
+
*/
|
|
49
|
+
disconnectDelay: number;
|
|
50
|
+
}
|
|
51
|
+
export declare class Redis implements Extension {
|
|
52
|
+
/**
|
|
53
|
+
* Make sure to give that extension a higher priority, so
|
|
54
|
+
* the `onStoreDocument` hook is able to intercept the chain,
|
|
55
|
+
* before documents are stored to the database.
|
|
56
|
+
*/
|
|
57
|
+
priority: number;
|
|
58
|
+
configuration: Configuration;
|
|
59
|
+
pub: RedisInstance;
|
|
60
|
+
sub: RedisInstance;
|
|
61
|
+
instance: Hocuspocus;
|
|
62
|
+
redlock: Redlock;
|
|
63
|
+
locks: Map<string, Redlock.Lock>;
|
|
64
|
+
logger: Debugger;
|
|
65
|
+
constructor(configuration: Partial<Configuration>);
|
|
66
|
+
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
67
|
+
private getKey;
|
|
68
|
+
private pubKey;
|
|
69
|
+
private subKey;
|
|
70
|
+
private lockKey;
|
|
71
|
+
/**
|
|
72
|
+
* Once a document is laoded, subscribe to the channel in Redis.
|
|
73
|
+
*/
|
|
74
|
+
afterLoadDocument({ documentName, document }: afterLoadDocumentPayload): Promise<unknown>;
|
|
75
|
+
/**
|
|
76
|
+
* Publish the first sync step through Redis.
|
|
77
|
+
*/
|
|
78
|
+
private publishFirstSyncStep;
|
|
79
|
+
/**
|
|
80
|
+
* Let’s ask Redis who is connected already.
|
|
81
|
+
*/
|
|
82
|
+
private requestAwarenessFromOtherInstances;
|
|
83
|
+
/**
|
|
84
|
+
* Before the document is stored, make sure to set a lock in Redis.
|
|
85
|
+
* That’s meant to avoid conflicts with other instances trying to store the document.
|
|
86
|
+
*/
|
|
87
|
+
onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* Release the Redis lock, so other instances can store documents.
|
|
90
|
+
*/
|
|
91
|
+
afterStoreDocument({ documentName }: afterStoreDocumentPayload): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Handle awareness update messages received directly by this Hocuspocus instance.
|
|
94
|
+
*/
|
|
95
|
+
onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<number>;
|
|
96
|
+
/**
|
|
97
|
+
* Handle incoming messages published on all subscribed document channels.
|
|
98
|
+
* Note that this will also include messages from ourselves as it is not possible
|
|
99
|
+
* in Redis to filter these.
|
|
100
|
+
*/
|
|
101
|
+
private handleIncomingMessage;
|
|
102
|
+
/**
|
|
103
|
+
* if the ydoc changed, we'll need to inform other Hocuspocus servers about it.
|
|
104
|
+
*/
|
|
105
|
+
onChange(data: onChangePayload): Promise<any>;
|
|
106
|
+
/**
|
|
107
|
+
* Make sure to *not* listen for further changes, when there’s
|
|
108
|
+
* noone connected anymore.
|
|
109
|
+
*/
|
|
110
|
+
onDisconnect: ({ documentName }: onDisconnectPayload) => Promise<void>;
|
|
111
|
+
beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
|
|
112
|
+
/**
|
|
113
|
+
* Kill the Redlock connection immediately.
|
|
114
|
+
*/
|
|
115
|
+
onDestroy(): Promise<void>;
|
|
116
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Redis';
|
|
1
|
+
export * from './Redis.js';
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
|
|
2
|
-
import sqlite3 from 'sqlite3';
|
|
3
|
-
export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
|
|
4
|
-
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
5
|
-
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
6
|
-
export interface SQLiteConfiguration extends DatabaseConfiguration {
|
|
7
|
-
/**
|
|
8
|
-
* Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
|
|
9
|
-
* string for an anonymous disk-based database. Anonymous databases are not persisted and
|
|
10
|
-
* when closing the database handle, their contents are lost.
|
|
11
|
-
*
|
|
12
|
-
* https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
|
|
13
|
-
*/
|
|
14
|
-
database: string;
|
|
15
|
-
/**
|
|
16
|
-
* The database schema to create.
|
|
17
|
-
*/
|
|
18
|
-
schema: string;
|
|
19
|
-
}
|
|
20
|
-
export declare class SQLite extends Database {
|
|
21
|
-
db?: sqlite3.Database;
|
|
22
|
-
configuration: SQLiteConfiguration;
|
|
23
|
-
constructor(configuration?: Partial<SQLiteConfiguration>);
|
|
24
|
-
onConfigure(): Promise<void>;
|
|
25
|
-
onListen(): Promise<void>;
|
|
26
|
-
}
|
|
1
|
+
import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
|
|
2
|
+
import sqlite3 from 'sqlite3';
|
|
3
|
+
export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
|
|
4
|
+
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
5
|
+
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
6
|
+
export interface SQLiteConfiguration extends DatabaseConfiguration {
|
|
7
|
+
/**
|
|
8
|
+
* Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
|
|
9
|
+
* string for an anonymous disk-based database. Anonymous databases are not persisted and
|
|
10
|
+
* when closing the database handle, their contents are lost.
|
|
11
|
+
*
|
|
12
|
+
* https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
|
|
13
|
+
*/
|
|
14
|
+
database: string;
|
|
15
|
+
/**
|
|
16
|
+
* The database schema to create.
|
|
17
|
+
*/
|
|
18
|
+
schema: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class SQLite extends Database {
|
|
21
|
+
db?: sqlite3.Database;
|
|
22
|
+
configuration: SQLiteConfiguration;
|
|
23
|
+
constructor(configuration?: Partial<SQLiteConfiguration>);
|
|
24
|
+
onConfigure(): Promise<void>;
|
|
25
|
+
onListen(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './SQLite';
|
|
1
|
+
export * from './SQLite.js';
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Extension, onConnectPayload } from '@hocuspocus/server';
|
|
3
|
-
export interface ThrottleConfiguration {
|
|
4
|
-
throttle: number | null | false;
|
|
5
|
-
consideredSeconds: number;
|
|
6
|
-
banTime: number;
|
|
7
|
-
cleanupInterval: number;
|
|
8
|
-
}
|
|
9
|
-
export declare class Throttle implements Extension {
|
|
10
|
-
configuration: ThrottleConfiguration;
|
|
11
|
-
connectionsByIp: Map<string, Array<number>>;
|
|
12
|
-
bannedIps: Map<string, number>;
|
|
13
|
-
cleanupInterval?: NodeJS.Timer;
|
|
14
|
-
/**
|
|
15
|
-
* Constructor
|
|
16
|
-
*/
|
|
17
|
-
constructor(configuration?: Partial<ThrottleConfiguration>);
|
|
18
|
-
onDestroy(): Promise<void>;
|
|
19
|
-
clearMaps(): void;
|
|
20
|
-
isBanned(ip: string): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Throttle requests
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
private throttle;
|
|
26
|
-
/**
|
|
27
|
-
* onConnect hook
|
|
28
|
-
* @param data
|
|
29
|
-
*/
|
|
30
|
-
onConnect(data: onConnectPayload): Promise<any>;
|
|
31
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Extension, onConnectPayload } from '@hocuspocus/server';
|
|
3
|
+
export interface ThrottleConfiguration {
|
|
4
|
+
throttle: number | null | false;
|
|
5
|
+
consideredSeconds: number;
|
|
6
|
+
banTime: number;
|
|
7
|
+
cleanupInterval: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Throttle implements Extension {
|
|
10
|
+
configuration: ThrottleConfiguration;
|
|
11
|
+
connectionsByIp: Map<string, Array<number>>;
|
|
12
|
+
bannedIps: Map<string, number>;
|
|
13
|
+
cleanupInterval?: NodeJS.Timer;
|
|
14
|
+
/**
|
|
15
|
+
* Constructor
|
|
16
|
+
*/
|
|
17
|
+
constructor(configuration?: Partial<ThrottleConfiguration>);
|
|
18
|
+
onDestroy(): Promise<void>;
|
|
19
|
+
clearMaps(): void;
|
|
20
|
+
isBanned(ip: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Throttle requests
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
private throttle;
|
|
26
|
+
/**
|
|
27
|
+
* onConnect hook
|
|
28
|
+
* @param data
|
|
29
|
+
*/
|
|
30
|
+
onConnect(data: onConnectPayload): Promise<any>;
|
|
31
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
|
|
3
|
-
import { Doc } from 'yjs';
|
|
4
|
-
import { Transformer } from '@hocuspocus/transformer';
|
|
5
|
-
export declare enum Events {
|
|
6
|
-
onChange = "change",
|
|
7
|
-
onConnect = "connect",
|
|
8
|
-
onCreate = "create",
|
|
9
|
-
onDisconnect = "disconnect"
|
|
10
|
-
}
|
|
11
|
-
export interface Configuration {
|
|
12
|
-
debounce: number | false | null;
|
|
13
|
-
debounceMaxWait: number;
|
|
14
|
-
secret: string;
|
|
15
|
-
transformer: Transformer | {
|
|
16
|
-
toYdoc: (document: any) => Doc;
|
|
17
|
-
fromYdoc: (document: Doc) => any;
|
|
18
|
-
};
|
|
19
|
-
url: string;
|
|
20
|
-
events: Array<Events>;
|
|
21
|
-
}
|
|
22
|
-
export declare class Webhook implements Extension {
|
|
23
|
-
configuration: Configuration;
|
|
24
|
-
debounced: Map<string, {
|
|
25
|
-
timeout: NodeJS.Timeout;
|
|
26
|
-
start: number;
|
|
27
|
-
}>;
|
|
28
|
-
/**
|
|
29
|
-
* Constructor
|
|
30
|
-
*/
|
|
31
|
-
constructor(configuration?: Partial<Configuration>);
|
|
32
|
-
/**
|
|
33
|
-
* Create a signature for the response body
|
|
34
|
-
*/
|
|
35
|
-
createSignature(body: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* debounce the given function, using the given identifier
|
|
38
|
-
*/
|
|
39
|
-
debounce(id: string, func: Function): void;
|
|
40
|
-
/**
|
|
41
|
-
* Send a request to the given url containing the given data
|
|
42
|
-
*/
|
|
43
|
-
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
44
|
-
/**
|
|
45
|
-
* onChange hook
|
|
46
|
-
*/
|
|
47
|
-
onChange(data: onChangePayload): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* onLoadDocument hook
|
|
50
|
-
*/
|
|
51
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* onConnect hook
|
|
54
|
-
*/
|
|
55
|
-
onConnect(data: onConnectPayload): Promise<any>;
|
|
56
|
-
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
57
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
|
|
3
|
+
import { Doc } from 'yjs';
|
|
4
|
+
import { Transformer } from '@hocuspocus/transformer';
|
|
5
|
+
export declare enum Events {
|
|
6
|
+
onChange = "change",
|
|
7
|
+
onConnect = "connect",
|
|
8
|
+
onCreate = "create",
|
|
9
|
+
onDisconnect = "disconnect"
|
|
10
|
+
}
|
|
11
|
+
export interface Configuration {
|
|
12
|
+
debounce: number | false | null;
|
|
13
|
+
debounceMaxWait: number;
|
|
14
|
+
secret: string;
|
|
15
|
+
transformer: Transformer | {
|
|
16
|
+
toYdoc: (document: any) => Doc;
|
|
17
|
+
fromYdoc: (document: Doc) => any;
|
|
18
|
+
};
|
|
19
|
+
url: string;
|
|
20
|
+
events: Array<Events>;
|
|
21
|
+
}
|
|
22
|
+
export declare class Webhook implements Extension {
|
|
23
|
+
configuration: Configuration;
|
|
24
|
+
debounced: Map<string, {
|
|
25
|
+
timeout: NodeJS.Timeout;
|
|
26
|
+
start: number;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Constructor
|
|
30
|
+
*/
|
|
31
|
+
constructor(configuration?: Partial<Configuration>);
|
|
32
|
+
/**
|
|
33
|
+
* Create a signature for the response body
|
|
34
|
+
*/
|
|
35
|
+
createSignature(body: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* debounce the given function, using the given identifier
|
|
38
|
+
*/
|
|
39
|
+
debounce(id: string, func: Function): void;
|
|
40
|
+
/**
|
|
41
|
+
* Send a request to the given url containing the given data
|
|
42
|
+
*/
|
|
43
|
+
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
44
|
+
/**
|
|
45
|
+
* onChange hook
|
|
46
|
+
*/
|
|
47
|
+
onChange(data: onChangePayload): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* onLoadDocument hook
|
|
50
|
+
*/
|
|
51
|
+
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* onConnect hook
|
|
54
|
+
*/
|
|
55
|
+
onConnect(data: onConnectPayload): Promise<any>;
|
|
56
|
+
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
57
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default class EventEmitter {
|
|
2
|
-
callbacks: {
|
|
3
|
-
[key: string]: Function[];
|
|
4
|
-
};
|
|
5
|
-
on(event: string, fn: Function): this;
|
|
6
|
-
protected emit(event: string, ...args: any): this;
|
|
7
|
-
off(event: string, fn?: Function): this;
|
|
8
|
-
removeAllListeners(): void;
|
|
9
|
-
}
|
|
1
|
+
export default class EventEmitter {
|
|
2
|
+
callbacks: {
|
|
3
|
+
[key: string]: Function[];
|
|
4
|
+
};
|
|
5
|
+
on(event: string, fn: Function): this;
|
|
6
|
+
protected emit(event: string, ...args: any): this;
|
|
7
|
+
off(event: string, fn?: Function): this;
|
|
8
|
+
removeAllListeners(): void;
|
|
9
|
+
}
|