@hocuspocus/extension-throttle 1.0.0-alpha.9 → 1.0.0-beta.2
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-throttle.js → hocuspocus-throttle.cjs} +9 -18
- package/dist/hocuspocus-throttle.cjs.map +1 -0
- package/dist/hocuspocus-throttle.esm.js +8 -17
- package/dist/hocuspocus-throttle.esm.js.map +1 -1
- package/dist/packages/common/src/CloseEvents.d.ts +23 -0
- package/dist/packages/common/src/auth.d.ts +6 -0
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +3 -0
- package/dist/packages/common/src/index.d.ts +4 -0
- package/dist/packages/common/src/types.d.ts +10 -0
- package/dist/packages/extension-database/src/Database.d.ts +30 -0
- package/dist/packages/extension-database/src/index.d.ts +1 -0
- package/dist/packages/extension-logger/src/Logger.d.ts +67 -0
- package/dist/packages/extension-logger/src/index.d.ts +1 -0
- package/dist/packages/{monitor → extension-monitor}/src/Collector.d.ts +4 -5
- package/dist/packages/{monitor → extension-monitor}/src/Dashboard.d.ts +2 -2
- package/dist/packages/{monitor → extension-monitor}/src/Storage.d.ts +0 -0
- package/dist/packages/{monitor → extension-monitor}/src/index.d.ts +3 -5
- package/dist/packages/extension-redis/src/Redis.d.ts +98 -0
- package/dist/packages/extension-redis/src/index.d.ts +1 -0
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -0
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -0
- package/dist/packages/extension-throttle/src/index.d.ts +24 -0
- package/dist/packages/{webhook → extension-webhook}/src/index.d.ts +5 -11
- package/dist/packages/provider/src/EventEmitter.d.ts +9 -0
- package/dist/packages/provider/src/HocuspocusCloudProvider.d.ts +11 -0
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +163 -0
- package/dist/packages/provider/src/IncomingMessage.d.ts +14 -0
- package/dist/packages/provider/src/MessageReceiver.d.ts +13 -0
- package/dist/packages/provider/src/MessageSender.d.ts +10 -0
- package/dist/packages/provider/src/OutgoingMessage.d.ts +9 -0
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +7 -0
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +8 -0
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +8 -0
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +8 -0
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +8 -0
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +7 -0
- package/dist/packages/provider/src/index.d.ts +3 -0
- package/dist/packages/provider/src/types.d.ts +77 -0
- package/dist/packages/server/src/Connection.d.ts +27 -7
- package/dist/packages/server/src/Debugger.d.ts +14 -0
- package/dist/packages/server/src/Document.d.ts +11 -5
- package/dist/packages/server/src/Hocuspocus.d.ts +63 -17
- package/dist/packages/server/src/IncomingMessage.d.ts +11 -7
- package/dist/packages/server/src/MessageReceiver.d.ts +13 -0
- package/dist/packages/server/src/OutgoingMessage.d.ts +6 -0
- package/dist/packages/server/src/index.d.ts +6 -0
- package/dist/packages/server/src/types.d.ts +181 -23
- package/dist/{demos/server/src/create-document.d.ts → playground/backend/src/default.d.ts} +0 -0
- package/dist/{demos/server → playground/backend}/src/express.d.ts +0 -0
- package/dist/{demos/server/src/minimal.d.ts → playground/backend/src/koa.d.ts} +0 -0
- package/dist/{demos/server/src/monitor.d.ts → playground/backend/src/load-document.d.ts} +0 -0
- package/dist/{demos/server/src/webhook.d.ts → playground/backend/src/monitor.d.ts} +0 -0
- package/dist/playground/backend/src/redis.d.ts +1 -0
- package/dist/playground/backend/src/slow.d.ts +1 -0
- package/dist/playground/backend/src/webhook.d.ts +1 -0
- package/dist/tests/extension-database/fetch.d.ts +1 -0
- package/dist/tests/extension-logger/onListen.d.ts +1 -0
- package/dist/tests/extension-redis/closeConnections.d.ts +1 -0
- package/dist/tests/extension-redis/getConnectionCount.d.ts +1 -0
- package/dist/tests/extension-redis/getDocumentsCount.d.ts +1 -0
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +1 -0
- package/dist/tests/extension-redis/onChange.d.ts +1 -0
- package/dist/tests/extension-redis/onStoreDocument.d.ts +1 -0
- package/dist/tests/extension-throttle/configuration.d.ts +1 -0
- package/dist/tests/provider/configuration.d.ts +1 -0
- package/dist/tests/provider/observe.d.ts +1 -0
- package/dist/tests/provider/observeDeep.d.ts +1 -0
- package/dist/tests/provider/onAuthenticated.d.ts +1 -0
- package/dist/tests/provider/onAuthenticationFailed.d.ts +1 -0
- package/dist/tests/provider/onAwarenessChange.d.ts +1 -0
- package/dist/tests/provider/onAwarenessUpdate.d.ts +1 -0
- package/dist/tests/provider/onClose.d.ts +1 -0
- package/dist/tests/provider/onConnect.d.ts +1 -0
- package/dist/tests/provider/onDisconnect.d.ts +1 -0
- package/dist/tests/provider/onMessage.d.ts +1 -0
- package/dist/tests/provider/onOpen.d.ts +1 -0
- package/dist/tests/provider/onSynced.d.ts +1 -0
- package/dist/tests/server/address.d.ts +1 -0
- package/dist/tests/server/afterStoreDocument.d.ts +1 -0
- package/dist/tests/server/beforeHandleMessage.d.ts +1 -0
- package/dist/tests/server/closeConnections.d.ts +1 -0
- package/dist/tests/server/getConnectionsCount.d.ts +1 -0
- package/dist/tests/server/getDocumentName.d.ts +1 -0
- package/dist/tests/server/getDocumentsCount.d.ts +1 -0
- package/dist/tests/server/getMessageLogs.d.ts +1 -0
- package/dist/tests/server/listen.d.ts +1 -0
- package/dist/tests/server/onAuthenticate.d.ts +1 -0
- package/dist/tests/server/onAwarenessUpdate.d.ts +1 -0
- package/dist/tests/server/onChange.d.ts +1 -0
- package/dist/tests/server/onConfigure.d.ts +1 -0
- package/dist/tests/server/onConnect.d.ts +1 -0
- package/dist/tests/server/onDestroy.d.ts +1 -0
- package/dist/tests/server/onDisconnect.d.ts +1 -0
- package/dist/tests/server/onListen.d.ts +1 -0
- package/dist/tests/server/onLoadDocument.d.ts +1 -0
- package/dist/tests/server/onRequest.d.ts +1 -0
- package/dist/tests/server/onStoreDocument.d.ts +1 -0
- package/dist/tests/server/onUpgrade.d.ts +1 -0
- package/dist/tests/server/requiresAuthentication.d.ts +1 -0
- package/dist/tests/server/websocketError.d.ts +1 -0
- package/dist/tests/transformer/TiptapTransformer.d.ts +1 -0
- package/dist/tests/utils/createDirectory.d.ts +1 -0
- package/dist/tests/utils/flushRedis.d.ts +1 -0
- package/dist/tests/utils/index.d.ts +8 -0
- package/dist/tests/utils/newHocuspocus.d.ts +2 -0
- package/dist/tests/utils/newHocuspocusProvider.d.ts +3 -0
- package/dist/tests/utils/randomInteger.d.ts +1 -0
- package/dist/tests/utils/redisConnectionSettings.d.ts +4 -0
- package/dist/tests/utils/removeDirectory.d.ts +1 -0
- package/dist/tests/utils/retryableAssertion.d.ts +2 -0
- package/dist/tests/utils/sleep.d.ts +1 -0
- package/package.json +13 -8
- package/src/index.ts +12 -33
- package/CHANGELOG.md +0 -67
- package/dist/hocuspocus-throttle.js.map +0 -1
- package/dist/packages/logger/src/index.d.ts +0 -13
- package/dist/packages/redis/src/Redis.d.ts +0 -22
- package/dist/packages/redis/src/RedisCluster.d.ts +0 -4
- package/dist/packages/redis/src/index.d.ts +0 -2
- package/dist/packages/rocksdb/src/index.d.ts +0 -30
- package/dist/packages/throttle/src/index.d.ts +0 -28
|
@@ -1,70 +1,223 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { URLSearchParams } from 'url';
|
|
4
|
-
import {
|
|
4
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
5
5
|
import Document from './Document';
|
|
6
|
-
|
|
6
|
+
import { Hocuspocus } from './Hocuspocus';
|
|
7
|
+
export declare enum MessageType {
|
|
8
|
+
Unknown = -1,
|
|
7
9
|
Sync = 0,
|
|
8
|
-
Awareness = 1
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Closed = 3
|
|
10
|
+
Awareness = 1,
|
|
11
|
+
Auth = 2,
|
|
12
|
+
QueryAwareness = 3,
|
|
13
|
+
SyncReply = 4
|
|
13
14
|
}
|
|
14
15
|
export interface AwarenessUpdate {
|
|
15
16
|
added: Array<any>;
|
|
16
17
|
updated: Array<any>;
|
|
17
18
|
removed: Array<any>;
|
|
18
19
|
}
|
|
20
|
+
export interface ConnectionConfiguration {
|
|
21
|
+
readOnly: boolean;
|
|
22
|
+
requiresAuthentication: boolean;
|
|
23
|
+
isAuthenticated: boolean;
|
|
24
|
+
}
|
|
19
25
|
export interface Extension {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
priority?: number;
|
|
27
|
+
onConfigure?(data: onConfigurePayload): Promise<any>;
|
|
28
|
+
onListen?(data: onListenPayload): Promise<any>;
|
|
29
|
+
onUpgrade?(data: onUpgradePayload): Promise<any>;
|
|
30
|
+
onConnect?(data: onConnectPayload): Promise<any>;
|
|
31
|
+
connected?(data: connectedPayload): Promise<any>;
|
|
32
|
+
onAuthenticate?(data: onAuthenticatePayload): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
35
|
+
*/
|
|
36
|
+
onCreateDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
37
|
+
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
38
|
+
afterLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
39
|
+
beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>;
|
|
40
|
+
onChange?(data: onChangePayload): Promise<any>;
|
|
41
|
+
onStoreDocument?(data: onStoreDocumentPayload): Promise<any>;
|
|
42
|
+
afterStoreDocument?(data: afterStoreDocumentPayload): Promise<any>;
|
|
43
|
+
onAwarenessUpdate?(data: onAwarenessUpdatePayload): Promise<any>;
|
|
44
|
+
onRequest?(data: onRequestPayload): Promise<any>;
|
|
45
|
+
onDisconnect?(data: onDisconnectPayload): Promise<any>;
|
|
46
|
+
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
29
47
|
}
|
|
48
|
+
export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' |
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
51
|
+
*/
|
|
52
|
+
'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
|
|
53
|
+
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload;
|
|
30
54
|
export interface Configuration extends Extension {
|
|
55
|
+
/**
|
|
56
|
+
* A name for the instance, used for logging.
|
|
57
|
+
*/
|
|
58
|
+
name: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* A list of hocuspocus extenions.
|
|
61
|
+
*/
|
|
31
62
|
extensions: Array<Extension>;
|
|
63
|
+
/**
|
|
64
|
+
* The port which the server listens on.
|
|
65
|
+
*/
|
|
32
66
|
port: number | null;
|
|
67
|
+
/**
|
|
68
|
+
* Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.
|
|
69
|
+
*/
|
|
33
70
|
timeout: number;
|
|
71
|
+
/**
|
|
72
|
+
* Debounces the call of the `onStoreDocument` hook for the given amount of time in ms.
|
|
73
|
+
* Otherwise every single update would be persisted.
|
|
74
|
+
*/
|
|
75
|
+
debounce: number;
|
|
76
|
+
/**
|
|
77
|
+
* Makes sure to call `onStoreDocument` at least in the given amount of time (ms).
|
|
78
|
+
*/
|
|
79
|
+
maxDebounce: number;
|
|
80
|
+
/**
|
|
81
|
+
* By default, the servers show a start screen. If passed false, the server will start quietly.
|
|
82
|
+
*/
|
|
83
|
+
quiet: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* options to pass to the ydoc document
|
|
86
|
+
*/
|
|
87
|
+
yDocOptions: {
|
|
88
|
+
gc: boolean;
|
|
89
|
+
gcFilter: () => boolean;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Function which returns the (customized) document name based on the request
|
|
93
|
+
*/
|
|
94
|
+
getDocumentName?(data: getDocumentNamePayload): string | Promise<string>;
|
|
95
|
+
}
|
|
96
|
+
export interface getDocumentNamePayload {
|
|
97
|
+
documentName: string;
|
|
98
|
+
request: IncomingMessage;
|
|
99
|
+
requestParameters: URLSearchParams;
|
|
100
|
+
}
|
|
101
|
+
export interface onAuthenticatePayload {
|
|
102
|
+
documentName: string;
|
|
103
|
+
instance: Hocuspocus;
|
|
104
|
+
requestHeaders: IncomingHttpHeaders;
|
|
105
|
+
requestParameters: URLSearchParams;
|
|
106
|
+
socketId: string;
|
|
107
|
+
token: string;
|
|
108
|
+
connection: ConnectionConfiguration;
|
|
34
109
|
}
|
|
35
110
|
export interface onConnectPayload {
|
|
36
111
|
documentName: string;
|
|
112
|
+
instance: Hocuspocus;
|
|
37
113
|
request: IncomingMessage;
|
|
38
114
|
requestHeaders: IncomingHttpHeaders;
|
|
39
115
|
requestParameters: URLSearchParams;
|
|
40
116
|
socketId: string;
|
|
41
|
-
connection:
|
|
42
|
-
|
|
43
|
-
|
|
117
|
+
connection: ConnectionConfiguration;
|
|
118
|
+
}
|
|
119
|
+
export interface connectedPayload {
|
|
120
|
+
documentName: string;
|
|
121
|
+
instance: Hocuspocus;
|
|
122
|
+
request: IncomingMessage;
|
|
123
|
+
requestHeaders: IncomingHttpHeaders;
|
|
124
|
+
requestParameters: URLSearchParams;
|
|
125
|
+
socketId: string;
|
|
126
|
+
connection: ConnectionConfiguration;
|
|
127
|
+
}
|
|
128
|
+
export interface onLoadDocumentPayload {
|
|
129
|
+
context: any;
|
|
130
|
+
document: Document;
|
|
131
|
+
documentName: string;
|
|
132
|
+
instance: Hocuspocus;
|
|
133
|
+
requestHeaders: IncomingHttpHeaders;
|
|
134
|
+
requestParameters: URLSearchParams;
|
|
135
|
+
socketId: string;
|
|
136
|
+
connection: ConnectionConfiguration;
|
|
44
137
|
}
|
|
45
|
-
export interface
|
|
138
|
+
export interface afterLoadDocumentPayload {
|
|
46
139
|
context: any;
|
|
47
140
|
document: Document;
|
|
48
141
|
documentName: string;
|
|
142
|
+
instance: Hocuspocus;
|
|
49
143
|
requestHeaders: IncomingHttpHeaders;
|
|
50
144
|
requestParameters: URLSearchParams;
|
|
51
145
|
socketId: string;
|
|
146
|
+
connection: ConnectionConfiguration;
|
|
52
147
|
}
|
|
53
148
|
export interface onChangePayload {
|
|
54
149
|
clientsCount: number;
|
|
55
150
|
context: any;
|
|
56
151
|
document: Document;
|
|
57
152
|
documentName: string;
|
|
153
|
+
instance: Hocuspocus;
|
|
154
|
+
requestHeaders: IncomingHttpHeaders;
|
|
155
|
+
requestParameters: URLSearchParams;
|
|
156
|
+
update: Uint8Array;
|
|
157
|
+
socketId: string;
|
|
158
|
+
}
|
|
159
|
+
export interface beforeHandleMessagePayload {
|
|
160
|
+
clientsCount: number;
|
|
161
|
+
context: any;
|
|
162
|
+
document: Document;
|
|
163
|
+
documentName: string;
|
|
164
|
+
instance: Hocuspocus;
|
|
165
|
+
requestHeaders: IncomingHttpHeaders;
|
|
166
|
+
requestParameters: URLSearchParams;
|
|
167
|
+
update: Uint8Array;
|
|
168
|
+
socketId: string;
|
|
169
|
+
}
|
|
170
|
+
export interface onStoreDocumentPayload {
|
|
171
|
+
clientsCount: number;
|
|
172
|
+
context: any;
|
|
173
|
+
document: Document;
|
|
174
|
+
documentName: string;
|
|
175
|
+
instance: Hocuspocus;
|
|
176
|
+
requestHeaders: IncomingHttpHeaders;
|
|
177
|
+
requestParameters: URLSearchParams;
|
|
178
|
+
socketId: string;
|
|
179
|
+
}
|
|
180
|
+
export interface afterStoreDocumentPayload extends onStoreDocumentPayload {
|
|
181
|
+
}
|
|
182
|
+
export interface onAwarenessUpdatePayload {
|
|
183
|
+
clientsCount: number;
|
|
184
|
+
context: any;
|
|
185
|
+
document: Document;
|
|
186
|
+
documentName: string;
|
|
187
|
+
instance: Hocuspocus;
|
|
58
188
|
requestHeaders: IncomingHttpHeaders;
|
|
59
189
|
requestParameters: URLSearchParams;
|
|
60
190
|
update: Uint8Array;
|
|
61
191
|
socketId: string;
|
|
192
|
+
added: number[];
|
|
193
|
+
updated: number[];
|
|
194
|
+
removed: number[];
|
|
195
|
+
awareness: Awareness;
|
|
196
|
+
states: StatesArray;
|
|
197
|
+
}
|
|
198
|
+
export declare type StatesArray = {
|
|
199
|
+
clientId: number;
|
|
200
|
+
[key: string | number]: any;
|
|
201
|
+
}[];
|
|
202
|
+
export interface fetchPayload {
|
|
203
|
+
context: any;
|
|
204
|
+
document: Document;
|
|
205
|
+
documentName: string;
|
|
206
|
+
instance: Hocuspocus;
|
|
207
|
+
requestHeaders: IncomingHttpHeaders;
|
|
208
|
+
requestParameters: URLSearchParams;
|
|
209
|
+
socketId: string;
|
|
210
|
+
connection: ConnectionConfiguration;
|
|
211
|
+
}
|
|
212
|
+
export interface storePayload extends onStoreDocumentPayload {
|
|
213
|
+
state: Buffer;
|
|
62
214
|
}
|
|
63
215
|
export interface onDisconnectPayload {
|
|
64
216
|
clientsCount: number;
|
|
65
217
|
context: any;
|
|
66
218
|
document: Document;
|
|
67
219
|
documentName: string;
|
|
220
|
+
instance: Hocuspocus;
|
|
68
221
|
requestHeaders: IncomingHttpHeaders;
|
|
69
222
|
requestParameters: URLSearchParams;
|
|
70
223
|
socketId: string;
|
|
@@ -72,19 +225,24 @@ export interface onDisconnectPayload {
|
|
|
72
225
|
export interface onRequestPayload {
|
|
73
226
|
request: IncomingMessage;
|
|
74
227
|
response: ServerResponse;
|
|
228
|
+
instance: Hocuspocus;
|
|
75
229
|
}
|
|
76
230
|
export interface onUpgradePayload {
|
|
77
|
-
head: any;
|
|
78
231
|
request: IncomingMessage;
|
|
79
|
-
socket:
|
|
232
|
+
socket: any;
|
|
233
|
+
head: any;
|
|
234
|
+
instance: Hocuspocus;
|
|
80
235
|
}
|
|
81
236
|
export interface onListenPayload {
|
|
237
|
+
instance: Hocuspocus;
|
|
238
|
+
configuration: Configuration;
|
|
82
239
|
port: number;
|
|
83
240
|
}
|
|
84
241
|
export interface onDestroyPayload {
|
|
242
|
+
instance: Hocuspocus;
|
|
85
243
|
}
|
|
86
244
|
export interface onConfigurePayload {
|
|
245
|
+
instance: Hocuspocus;
|
|
87
246
|
configuration: Configuration;
|
|
88
247
|
version: string;
|
|
89
|
-
yjsVersion: string;
|
|
90
248
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createDirectory: (dir: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const flushRedis: () => Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './createDirectory';
|
|
2
|
+
export * from './flushRedis';
|
|
3
|
+
export * from './newHocuspocus';
|
|
4
|
+
export * from './newHocuspocusProvider';
|
|
5
|
+
export * from './randomInteger';
|
|
6
|
+
export * from './redisConnectionSettings';
|
|
7
|
+
export * from './removeDirectory';
|
|
8
|
+
export * from './sleep';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { HocuspocusProvider, HocuspocusProviderConfiguration } from '@hocuspocus/provider';
|
|
2
|
+
import { Hocuspocus } from '@hocuspocus/server';
|
|
3
|
+
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<Omit<HocuspocusProviderConfiguration, 'url'>>) => HocuspocusProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const randomInteger: (min: number, max: number) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const removeDirectory: (dir: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (time: number) => Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-throttle",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"description": "hocuspocus throttle extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hocuspocus",
|
|
8
|
-
"tiptap",
|
|
9
8
|
"throttle",
|
|
10
9
|
"yjs"
|
|
11
10
|
],
|
|
11
|
+
"license": "MIT",
|
|
12
12
|
"type": "module",
|
|
13
|
-
"main": "dist/hocuspocus-throttle.
|
|
13
|
+
"main": "dist/hocuspocus-throttle.cjs",
|
|
14
14
|
"module": "dist/hocuspocus-throttle.esm.js",
|
|
15
|
-
"types": "dist/packages/throttle/src/index.d.ts",
|
|
15
|
+
"types": "dist/packages/extension-throttle/src/index.d.ts",
|
|
16
16
|
"exports": {
|
|
17
|
-
"
|
|
18
|
-
|
|
17
|
+
"source": {
|
|
18
|
+
"import": "./src"
|
|
19
|
+
},
|
|
20
|
+
"default": {
|
|
21
|
+
"import": "./dist/hocuspocus-throttle.esm.js",
|
|
22
|
+
"require": "./dist/hocuspocus-throttle.cjs"
|
|
23
|
+
}
|
|
19
24
|
},
|
|
20
25
|
"files": [
|
|
21
26
|
"src",
|
|
22
27
|
"dist"
|
|
23
28
|
],
|
|
24
29
|
"dependencies": {
|
|
25
|
-
"@hocuspocus/server": "^1.0.0-
|
|
30
|
+
"@hocuspocus/server": "^1.0.0-beta.2"
|
|
26
31
|
},
|
|
27
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
|
|
28
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Extension,
|
|
3
|
-
onChangePayload,
|
|
4
|
-
onConfigurePayload,
|
|
5
3
|
onConnectPayload,
|
|
6
|
-
onCreateDocumentPayload,
|
|
7
|
-
onDestroyPayload,
|
|
8
|
-
onDisconnectPayload,
|
|
9
|
-
onListenPayload,
|
|
10
|
-
onRequestPayload,
|
|
11
|
-
onUpgradePayload,
|
|
12
4
|
} from '@hocuspocus/server'
|
|
13
5
|
|
|
14
|
-
export interface
|
|
6
|
+
export interface ThrottleConfiguration {
|
|
15
7
|
throttle: number | null | false,
|
|
16
8
|
banTime: number,
|
|
17
9
|
}
|
|
18
10
|
|
|
19
11
|
export class Throttle implements Extension {
|
|
20
12
|
|
|
21
|
-
configuration:
|
|
13
|
+
configuration: ThrottleConfiguration = {
|
|
22
14
|
throttle: 15,
|
|
23
15
|
banTime: 5,
|
|
24
16
|
}
|
|
@@ -27,6 +19,16 @@ export class Throttle implements Extension {
|
|
|
27
19
|
|
|
28
20
|
bannedIps: Map<string, number> = new Map()
|
|
29
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Constructor
|
|
24
|
+
*/
|
|
25
|
+
constructor(configuration?: Partial<ThrottleConfiguration>) {
|
|
26
|
+
this.configuration = {
|
|
27
|
+
...this.configuration,
|
|
28
|
+
...configuration,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
30
32
|
/**
|
|
31
33
|
* Throttle requests
|
|
32
34
|
* @private
|
|
@@ -79,27 +81,4 @@ export class Throttle implements Extension {
|
|
|
79
81
|
return this.throttle(<string> ip) ? Promise.reject() : Promise.resolve()
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
83
|
-
async onCreateDocument(data: onCreateDocumentPayload) {}
|
|
84
|
-
|
|
85
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
86
|
-
async onChange(data: onChangePayload) {}
|
|
87
|
-
|
|
88
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
89
|
-
async onDisconnect(data: onDisconnectPayload) {}
|
|
90
|
-
|
|
91
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
92
|
-
async onUpgrade(data: onUpgradePayload) {}
|
|
93
|
-
|
|
94
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
95
|
-
async onRequest(data: onRequestPayload) {}
|
|
96
|
-
|
|
97
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
98
|
-
async onListen(data: onListenPayload) {}
|
|
99
|
-
|
|
100
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
101
|
-
async onDestroy(data: onDestroyPayload) {}
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line no-empty-function,@typescript-eslint/no-empty-function
|
|
104
|
-
async onConfigure(data: onConfigurePayload) {}
|
|
105
84
|
}
|