@hocuspocus/extension-logger 2.1.0-alpha.0 → 2.2.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.
Files changed (127) hide show
  1. package/dist/hocuspocus-logger.cjs +82 -82
  2. package/dist/hocuspocus-logger.esm.js +82 -82
  3. package/dist/packages/common/src/CloseEvents.d.ts +29 -29
  4. package/dist/packages/common/src/auth.d.ts +6 -6
  5. package/dist/packages/common/src/awarenessStatesToArray.d.ts +3 -3
  6. package/dist/packages/common/src/index.d.ts +4 -4
  7. package/dist/packages/common/src/types.d.ts +10 -10
  8. package/dist/packages/extension-database/src/Database.d.ts +30 -30
  9. package/dist/packages/extension-database/src/index.d.ts +1 -1
  10. package/dist/packages/extension-logger/src/Logger.d.ts +67 -67
  11. package/dist/packages/extension-logger/src/index.d.ts +1 -1
  12. package/dist/packages/extension-redis/src/Redis.d.ts +116 -95
  13. package/dist/packages/extension-redis/src/index.d.ts +1 -1
  14. package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -26
  15. package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
  16. package/dist/packages/extension-throttle/src/index.d.ts +31 -31
  17. package/dist/packages/extension-webhook/src/index.d.ts +57 -57
  18. package/dist/packages/provider/src/EventEmitter.d.ts +9 -9
  19. package/dist/packages/provider/src/HocuspocusProvider.d.ts +110 -110
  20. package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +115 -115
  21. package/dist/packages/provider/src/IncomingMessage.d.ts +16 -16
  22. package/dist/packages/provider/src/MessageReceiver.d.ts +13 -13
  23. package/dist/packages/provider/src/MessageSender.d.ts +10 -10
  24. package/dist/packages/provider/src/OutgoingMessage.d.ts +9 -9
  25. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +7 -7
  26. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +8 -8
  27. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +8 -8
  28. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +8 -8
  29. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +7 -7
  30. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +8 -8
  31. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +8 -8
  32. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +7 -7
  33. package/dist/packages/provider/src/TiptapCollabProvider.d.ts +11 -11
  34. package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +11 -11
  35. package/dist/packages/provider/src/index.d.ts +5 -5
  36. package/dist/packages/provider/src/types.d.ts +84 -84
  37. package/dist/packages/server/src/ClientConnection.d.ts +56 -0
  38. package/dist/packages/server/src/Connection.d.ts +71 -71
  39. package/dist/packages/server/src/Debugger.d.ts +14 -14
  40. package/dist/packages/server/src/DirectConnection.d.ts +14 -0
  41. package/dist/packages/server/src/Document.d.ts +91 -88
  42. package/dist/packages/server/src/Hocuspocus.d.ts +103 -108
  43. package/dist/packages/server/src/IncomingMessage.d.ts +21 -21
  44. package/dist/packages/server/src/MessageReceiver.d.ts +12 -12
  45. package/dist/packages/server/src/OutgoingMessage.d.ts +20 -20
  46. package/dist/packages/server/src/index.d.ts +8 -8
  47. package/dist/packages/server/src/types.d.ts +270 -264
  48. package/dist/packages/server/src/util/getParameters.d.ts +8 -0
  49. package/dist/packages/transformer/src/Prosemirror.d.ts +11 -11
  50. package/dist/packages/transformer/src/Tiptap.d.ts +10 -10
  51. package/dist/packages/transformer/src/index.d.ts +3 -3
  52. package/dist/packages/transformer/src/types.d.ts +5 -5
  53. package/dist/playground/backend/src/default.d.ts +1 -1
  54. package/dist/playground/backend/src/express.d.ts +1 -1
  55. package/dist/playground/backend/src/koa.d.ts +1 -1
  56. package/dist/playground/backend/src/load-document.d.ts +1 -1
  57. package/dist/playground/backend/src/redis.d.ts +1 -1
  58. package/dist/playground/backend/src/slow.d.ts +1 -1
  59. package/dist/playground/backend/src/tiptapcollab.d.ts +1 -1
  60. package/dist/playground/backend/src/webhook.d.ts +1 -1
  61. package/dist/playground/frontend/src/main.d.ts +1 -1
  62. package/dist/playground/frontend/vite.config.d.ts +2 -2
  63. package/dist/tests/extension-database/fetch.d.ts +1 -1
  64. package/dist/tests/extension-logger/onListen.d.ts +1 -1
  65. package/dist/tests/extension-redis/closeConnections.d.ts +1 -1
  66. package/dist/tests/extension-redis/getConnectionCount.d.ts +1 -1
  67. package/dist/tests/extension-redis/getDocumentsCount.d.ts +1 -1
  68. package/dist/tests/extension-redis/onAwarenessChange.d.ts +1 -1
  69. package/dist/tests/extension-redis/onChange.d.ts +1 -1
  70. package/dist/tests/extension-redis/onStateless.d.ts +1 -1
  71. package/dist/tests/extension-redis/onStoreDocument.d.ts +1 -1
  72. package/dist/tests/extension-throttle/banning.d.ts +1 -1
  73. package/dist/tests/extension-throttle/configuration.d.ts +1 -1
  74. package/dist/tests/provider/observe.d.ts +1 -1
  75. package/dist/tests/provider/observeDeep.d.ts +1 -1
  76. package/dist/tests/provider/onAuthenticated.d.ts +1 -1
  77. package/dist/tests/provider/onAuthenticationFailed.d.ts +1 -1
  78. package/dist/tests/provider/onAwarenessChange.d.ts +1 -1
  79. package/dist/tests/provider/onAwarenessUpdate.d.ts +1 -1
  80. package/dist/tests/provider/onClose.d.ts +1 -1
  81. package/dist/tests/provider/onConnect.d.ts +1 -1
  82. package/dist/tests/provider/onDisconnect.d.ts +1 -1
  83. package/dist/tests/provider/onMessage.d.ts +1 -1
  84. package/dist/tests/provider/onOpen.d.ts +1 -1
  85. package/dist/tests/provider/onStateless.d.ts +1 -1
  86. package/dist/tests/provider/onSynced.d.ts +1 -1
  87. package/dist/tests/providerwebsocket/configuration.d.ts +1 -1
  88. package/dist/tests/server/address.d.ts +1 -1
  89. package/dist/tests/server/afterStoreDocument.d.ts +1 -1
  90. package/dist/tests/server/beforeBroadcastStateless.d.ts +1 -1
  91. package/dist/tests/server/beforeHandleMessage.d.ts +1 -1
  92. package/dist/tests/server/closeConnections.d.ts +1 -1
  93. package/dist/tests/server/getConnectionsCount.d.ts +1 -1
  94. package/dist/tests/server/getDocumentsCount.d.ts +1 -1
  95. package/dist/tests/server/getMessageLogs.d.ts +1 -1
  96. package/dist/tests/server/listen.d.ts +1 -1
  97. package/dist/tests/server/onAuthenticate.d.ts +1 -1
  98. package/dist/tests/server/onAwarenessUpdate.d.ts +1 -1
  99. package/dist/tests/server/onChange.d.ts +1 -1
  100. package/dist/tests/server/onClose.d.ts +1 -1
  101. package/dist/tests/server/onConfigure.d.ts +1 -1
  102. package/dist/tests/server/onConnect.d.ts +1 -1
  103. package/dist/tests/server/onDestroy.d.ts +1 -1
  104. package/dist/tests/server/onDisconnect.d.ts +1 -1
  105. package/dist/tests/server/onListen.d.ts +1 -1
  106. package/dist/tests/server/onLoadDocument.d.ts +1 -1
  107. package/dist/tests/server/onRequest.d.ts +1 -1
  108. package/dist/tests/server/onStateless.d.ts +1 -1
  109. package/dist/tests/server/onStoreDocument.d.ts +1 -1
  110. package/dist/tests/server/onUpgrade.d.ts +1 -1
  111. package/dist/tests/server/openDirectConnection.d.ts +1 -0
  112. package/dist/tests/server/requiresAuthentication.d.ts +1 -1
  113. package/dist/tests/server/websocketError.d.ts +1 -1
  114. package/dist/tests/transformer/TiptapTransformer.d.ts +1 -1
  115. package/dist/tests/utils/createDirectory.d.ts +1 -1
  116. package/dist/tests/utils/flushRedis.d.ts +1 -1
  117. package/dist/tests/utils/index.d.ts +9 -9
  118. package/dist/tests/utils/newHocuspocus.d.ts +2 -2
  119. package/dist/tests/utils/newHocuspocusProvider.d.ts +3 -3
  120. package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +3 -3
  121. package/dist/tests/utils/randomInteger.d.ts +1 -1
  122. package/dist/tests/utils/redisConnectionSettings.d.ts +4 -4
  123. package/dist/tests/utils/removeDirectory.d.ts +1 -1
  124. package/dist/tests/utils/retryableAssertion.d.ts +2 -2
  125. package/dist/tests/utils/sleep.d.ts +1 -1
  126. package/package.json +4 -3
  127. package/src/index.ts +1 -1
@@ -1,95 +1,116 @@
1
- import RedisClient, { ClusterNode, ClusterOptions, RedisOptions, Cluster as RedisClusterClient } from 'ioredis';
2
- import { Extension, afterLoadDocumentPayload, onDisconnectPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
3
- export type RedisInstance = RedisClient | RedisClusterClient;
4
- export interface Configuration {
5
- /**
6
- * Redis port
7
- */
8
- port: number;
9
- /**
10
- * Redis host
11
- */
12
- host: string;
13
- /**
14
- * Redis Cluster
15
- */
16
- nodes?: ClusterNode[];
17
- /**
18
- * Duplicate from an existed Redis instance
19
- */
20
- redis?: RedisInstance;
21
- /**
22
- * Redis instance creator
23
- */
24
- createClient?: () => RedisInstance;
25
- /**
26
- * Options passed directly to Redis constructor
27
- *
28
- * https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
29
- */
30
- options?: ClusterOptions | RedisOptions;
31
- /**
32
- * An unique instance name, required to filter messages in Redis.
33
- * If none is provided an unique id is generated.
34
- */
35
- identifier: string;
36
- /**
37
- * Namespace for Redis keys, if none is provided 'hocuspocus' is used
38
- */
39
- prefix: string;
40
- /**
41
- * A delay before onDisconnect is executed. This allows last minute updates'
42
- * sync messages to be received by the subscription before it's closed.
43
- */
44
- disconnectDelay: number;
45
- }
46
- export declare class Redis implements Extension {
47
- /**
48
- * Make sure to give that extension a higher priority, so
49
- * the `onStoreDocument` hook is able to intercept the chain,
50
- * before documents are stored to the database.
51
- */
52
- priority: number;
53
- configuration: Configuration;
54
- pub: RedisInstance;
55
- sub: RedisInstance;
56
- instance: Hocuspocus;
57
- logger: Debugger;
58
- constructor(configuration: Partial<Configuration>);
59
- onConfigure({ instance }: onConfigurePayload): Promise<void>;
60
- private getKey;
61
- private pubKey;
62
- private subKey;
63
- /**
64
- * Once a document is laoded, subscribe to the channel in Redis.
65
- */
66
- afterLoadDocument({ documentName, document }: afterLoadDocumentPayload): Promise<unknown>;
67
- /**
68
- * Publish the first sync step through Redis.
69
- */
70
- private publishFirstSyncStep;
71
- /**
72
- * Let’s ask Redis who is connected already.
73
- */
74
- private requestAwarenessFromOtherInstances;
75
- /**
76
- * Handle awareness update messages received directly by this Hocuspocus instance.
77
- */
78
- onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: 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
- * if the ydoc changed, we'll need to inform other Hocuspocus servers about it.
87
- */
88
- onChange(data: onChangePayload): Promise<any>;
89
- /**
90
- * Make sure to *not* listen for further changes, when there’s
91
- * noone connected anymore.
92
- */
93
- onDisconnect: ({ documentName }: onDisconnectPayload) => Promise<void>;
94
- beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
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
+ }