@hocuspocus/extension-webhook 3.4.4 → 3.4.6-rc.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-webhook.cjs +169 -168
- package/dist/hocuspocus-webhook.cjs.map +1 -1
- package/dist/hocuspocus-webhook.esm.js +140 -167
- package/dist/hocuspocus-webhook.esm.js.map +1 -1
- package/dist/index.d.ts +61 -0
- package/dist/index.js +142 -0
- package/package.json +6 -6
- package/dist/node_modules/@tiptap/pm/model/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/state/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/transform/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/view/index.d.ts +0 -1
- package/dist/packages/common/src/CloseEvents.d.ts +0 -29
- package/dist/packages/common/src/auth.d.ts +0 -13
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +0 -3
- package/dist/packages/common/src/index.d.ts +0 -4
- package/dist/packages/common/src/types.d.ts +0 -10
- package/dist/packages/extension-database/src/Database.d.ts +0 -30
- package/dist/packages/extension-database/src/index.d.ts +0 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +0 -67
- package/dist/packages/extension-logger/src/index.d.ts +0 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +0 -124
- package/dist/packages/extension-redis/src/index.d.ts +0 -1
- package/dist/packages/extension-s3/src/S3.d.ts +0 -44
- package/dist/packages/extension-s3/src/index.d.ts +0 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +0 -27
- package/dist/packages/extension-sqlite/src/index.d.ts +0 -1
- package/dist/packages/extension-throttle/src/index.d.ts +0 -30
- package/dist/packages/extension-webhook/src/index.d.ts +0 -56
- package/dist/packages/provider/src/EventEmitter.d.ts +0 -9
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +0 -116
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +0 -119
- package/dist/packages/provider/src/IncomingMessage.d.ts +0 -17
- package/dist/packages/provider/src/MessageReceiver.d.ts +0 -12
- package/dist/packages/provider/src/MessageSender.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +0 -8
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +0 -8
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +0 -8
- package/dist/packages/provider/src/index.d.ts +0 -3
- package/dist/packages/provider/src/types.d.ts +0 -93
- package/dist/packages/server/src/ClientConnection.d.ts +0 -63
- package/dist/packages/server/src/Connection.d.ts +0 -75
- package/dist/packages/server/src/DirectConnection.d.ts +0 -14
- package/dist/packages/server/src/Document.d.ts +0 -92
- package/dist/packages/server/src/Hocuspocus.d.ts +0 -80
- package/dist/packages/server/src/IncomingMessage.d.ts +0 -25
- package/dist/packages/server/src/MessageReceiver.d.ts +0 -11
- package/dist/packages/server/src/OutgoingMessage.d.ts +0 -23
- package/dist/packages/server/src/Server.d.ts +0 -32
- package/dist/packages/server/src/index.d.ts +0 -9
- package/dist/packages/server/src/types.d.ts +0 -342
- package/dist/packages/server/src/util/debounce.d.ts +0 -6
- package/dist/packages/server/src/util/getParameters.d.ts +0 -6
- package/dist/packages/transformer/src/Prosemirror.d.ts +0 -11
- package/dist/packages/transformer/src/Tiptap.d.ts +0 -10
- package/dist/packages/transformer/src/index.d.ts +0 -3
- package/dist/packages/transformer/src/types.d.ts +0 -5
- package/dist/playground/backend/src/default.d.ts +0 -1
- package/dist/playground/backend/src/deno.d.ts +0 -1
- package/dist/playground/backend/src/express.d.ts +0 -1
- package/dist/playground/backend/src/hono.d.ts +0 -1
- package/dist/playground/backend/src/koa.d.ts +0 -1
- package/dist/playground/backend/src/load-document.d.ts +0 -1
- package/dist/playground/backend/src/redis.d.ts +0 -1
- package/dist/playground/backend/src/s3-redis.d.ts +0 -1
- package/dist/playground/backend/src/s3.d.ts +0 -1
- package/dist/playground/backend/src/slow.d.ts +0 -1
- package/dist/playground/backend/src/tiptapcollab.d.ts +0 -1
- package/dist/playground/backend/src/webhook.d.ts +0 -1
- package/dist/playground/frontend/app/SocketContext1.d.ts +0 -2
- package/dist/playground/frontend/app/SocketContext2.d.ts +0 -2
- package/dist/playground/frontend/next.config.d.ts +0 -3
- package/dist/tests/extension-database/fetch.d.ts +0 -1
- package/dist/tests/extension-logger/onListen.d.ts +0 -1
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +0 -1
- package/dist/tests/extension-redis/onChange.d.ts +0 -1
- package/dist/tests/extension-redis/onStateless.d.ts +0 -1
- package/dist/tests/extension-redis/onStoreDocument.d.ts +0 -1
- package/dist/tests/extension-s3/fetch.d.ts +0 -1
- package/dist/tests/extension-throttle/banning.d.ts +0 -1
- package/dist/tests/extension-throttle/configuration.d.ts +0 -1
- package/dist/tests/provider/hasUnsyncedChanges.d.ts +0 -1
- package/dist/tests/provider/observe.d.ts +0 -1
- package/dist/tests/provider/observeDeep.d.ts +0 -1
- package/dist/tests/provider/onAuthenticated.d.ts +0 -1
- package/dist/tests/provider/onAuthenticationFailed.d.ts +0 -1
- package/dist/tests/provider/onAwarenessChange.d.ts +0 -1
- package/dist/tests/provider/onAwarenessUpdate.d.ts +0 -1
- package/dist/tests/provider/onClose.d.ts +0 -1
- package/dist/tests/provider/onConnect.d.ts +0 -1
- package/dist/tests/provider/onDisconnect.d.ts +0 -1
- package/dist/tests/provider/onMessage.d.ts +0 -1
- package/dist/tests/provider/onOpen.d.ts +0 -1
- package/dist/tests/provider/onStateless.d.ts +0 -1
- package/dist/tests/provider/onSynced.d.ts +0 -1
- package/dist/tests/providerwebsocket/configuration.d.ts +0 -1
- package/dist/tests/server/address.d.ts +0 -1
- package/dist/tests/server/afterLoadDocument.d.ts +0 -1
- package/dist/tests/server/afterStoreDocument.d.ts +0 -1
- package/dist/tests/server/afterUnloadDocument.d.ts +0 -1
- package/dist/tests/server/beforeBroadcastStateless.d.ts +0 -1
- package/dist/tests/server/beforeHandleMessage.d.ts +0 -1
- package/dist/tests/server/beforeSync.d.ts +0 -1
- package/dist/tests/server/beforeUnloadDocument.d.ts +0 -1
- package/dist/tests/server/closeConnections.d.ts +0 -1
- package/dist/tests/server/getConnectionsCount.d.ts +0 -1
- package/dist/tests/server/getDocumentsCount.d.ts +0 -1
- package/dist/tests/server/listen.d.ts +0 -1
- package/dist/tests/server/onAuthenticate.d.ts +0 -1
- package/dist/tests/server/onAwarenessUpdate.d.ts +0 -1
- package/dist/tests/server/onChange.d.ts +0 -1
- package/dist/tests/server/onClose.d.ts +0 -1
- package/dist/tests/server/onConfigure.d.ts +0 -1
- package/dist/tests/server/onConnect.d.ts +0 -1
- package/dist/tests/server/onDestroy.d.ts +0 -1
- package/dist/tests/server/onDisconnect.d.ts +0 -1
- package/dist/tests/server/onListen.d.ts +0 -1
- package/dist/tests/server/onLoadDocument.d.ts +0 -1
- package/dist/tests/server/onRequest.d.ts +0 -1
- package/dist/tests/server/onStateless.d.ts +0 -1
- package/dist/tests/server/onStoreDocument.d.ts +0 -1
- package/dist/tests/server/onTokenSync.d.ts +0 -1
- package/dist/tests/server/onUpgrade.d.ts +0 -1
- package/dist/tests/server/openDirectConnection.d.ts +0 -1
- package/dist/tests/server/websocketError.d.ts +0 -1
- package/dist/tests/transformer/TiptapTransformer.d.ts +0 -1
- package/dist/tests/utils/createDirectory.d.ts +0 -1
- package/dist/tests/utils/flushRedis.d.ts +0 -1
- package/dist/tests/utils/index.d.ts +0 -9
- package/dist/tests/utils/newHocuspocus.d.ts +0 -2
- package/dist/tests/utils/newHocuspocusProvider.d.ts +0 -3
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +0 -4
- package/dist/tests/utils/randomInteger.d.ts +0 -1
- package/dist/tests/utils/redisConnectionSettings.d.ts +0 -4
- package/dist/tests/utils/removeDirectory.d.ts +0 -1
- package/dist/tests/utils/retryableAssertion.d.ts +0 -2
- package/dist/tests/utils/sleep.d.ts +0 -1
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as encoding from "lib0/encoding";
|
|
2
|
-
import * as decoding from "lib0/decoding";
|
|
3
|
-
import type { AuthorizedScope } from "../../provider/src";
|
|
4
|
-
export declare enum AuthMessageType {
|
|
5
|
-
Token = 0,
|
|
6
|
-
PermissionDenied = 1,
|
|
7
|
-
Authenticated = 2
|
|
8
|
-
}
|
|
9
|
-
export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
|
|
10
|
-
export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
|
|
11
|
-
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: AuthorizedScope) => void;
|
|
12
|
-
export declare const writeTokenSyncRequest: (encoder: encoding.Encoder) => void;
|
|
13
|
-
export declare const readAuthMessage: (decoder: decoding.Decoder, sendToken: () => void, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from "@hocuspocus/server";
|
|
2
|
-
export interface DatabaseConfiguration {
|
|
3
|
-
/**
|
|
4
|
-
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
5
|
-
* an array of items with Y.js-compatible binary data.
|
|
6
|
-
*/
|
|
7
|
-
fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
|
|
8
|
-
/**
|
|
9
|
-
* Pass a function to store updates in your database.
|
|
10
|
-
*/
|
|
11
|
-
store: (data: storePayload) => Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export declare class Database implements Extension {
|
|
14
|
-
/**
|
|
15
|
-
* Default configuration
|
|
16
|
-
*/
|
|
17
|
-
configuration: DatabaseConfiguration;
|
|
18
|
-
/**
|
|
19
|
-
* Constructor
|
|
20
|
-
*/
|
|
21
|
-
constructor(configuration: Partial<DatabaseConfiguration>);
|
|
22
|
-
/**
|
|
23
|
-
* Get stored data from the database.
|
|
24
|
-
*/
|
|
25
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
|
|
26
|
-
/**
|
|
27
|
-
* Store new updates in the database.
|
|
28
|
-
*/
|
|
29
|
-
onStoreDocument(data: onChangePayload): Promise<void>;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Database.ts";
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from "@hocuspocus/server";
|
|
2
|
-
export interface LoggerConfiguration {
|
|
3
|
-
/**
|
|
4
|
-
* Prepend all logging message with a string.
|
|
5
|
-
*
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
prefix: null | string;
|
|
9
|
-
/**
|
|
10
|
-
* Whether to log something for the `onLoadDocument` hook.
|
|
11
|
-
*/
|
|
12
|
-
onLoadDocument: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Whether to log something for the `onChange` hook.
|
|
15
|
-
*/
|
|
16
|
-
onChange: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to log something for the `onStoreDocument` hook.
|
|
19
|
-
*/
|
|
20
|
-
onStoreDocument: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Whether to log something for the `onConnect` hook.
|
|
23
|
-
*/
|
|
24
|
-
onConnect: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Whether to log something for the `onDisconnect` hook.
|
|
27
|
-
*/
|
|
28
|
-
onDisconnect: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether to log something for the `onUpgrade` hook.
|
|
31
|
-
*/
|
|
32
|
-
onUpgrade: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Whether to log something for the `onRequest` hook.
|
|
35
|
-
*/
|
|
36
|
-
onRequest: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Whether to log something for the `onDestroy` hook.
|
|
39
|
-
*/
|
|
40
|
-
onDestroy: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Whether to log something for the `onConfigure` hook.
|
|
43
|
-
*/
|
|
44
|
-
onConfigure: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* A log function, if none is provided output will go to console
|
|
47
|
-
*/
|
|
48
|
-
log: (...args: any[]) => void;
|
|
49
|
-
}
|
|
50
|
-
export declare class Logger implements Extension {
|
|
51
|
-
name: string | null;
|
|
52
|
-
configuration: LoggerConfiguration;
|
|
53
|
-
/**
|
|
54
|
-
* Constructor
|
|
55
|
-
*/
|
|
56
|
-
constructor(configuration?: Partial<LoggerConfiguration>);
|
|
57
|
-
onConfigure(data: onConfigurePayload): Promise<void>;
|
|
58
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
59
|
-
onChange(data: onChangePayload): Promise<void>;
|
|
60
|
-
onStoreDocument(data: onDisconnectPayload): Promise<void>;
|
|
61
|
-
onConnect(data: onConnectPayload): Promise<void>;
|
|
62
|
-
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
63
|
-
onUpgrade(data: onUpgradePayload): Promise<void>;
|
|
64
|
-
onRequest(data: onRequestPayload): Promise<void>;
|
|
65
|
-
onDestroy(data: onDestroyPayload): Promise<void>;
|
|
66
|
-
private log;
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Logger.ts";
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Extension, Hocuspocus, afterLoadDocumentPayload, afterStoreDocumentPayload, afterUnloadDocumentPayload, beforeBroadcastStatelessPayload, beforeUnloadDocumentPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, onStoreDocumentPayload } from "@hocuspocus/server";
|
|
2
|
-
import { type ExecutionResult, type Lock, Redlock } from "@sesamecare-oss/redlock";
|
|
3
|
-
import type { Cluster, ClusterNode, ClusterOptions, RedisOptions } from "ioredis";
|
|
4
|
-
import RedisClient from "ioredis";
|
|
5
|
-
export type RedisInstance = RedisClient | Cluster;
|
|
6
|
-
export interface Configuration {
|
|
7
|
-
/**
|
|
8
|
-
* Redis port
|
|
9
|
-
*/
|
|
10
|
-
port: number;
|
|
11
|
-
/**
|
|
12
|
-
* Redis host
|
|
13
|
-
*/
|
|
14
|
-
host: string;
|
|
15
|
-
/**
|
|
16
|
-
* Redis Cluster
|
|
17
|
-
*/
|
|
18
|
-
nodes?: ClusterNode[];
|
|
19
|
-
/**
|
|
20
|
-
* Duplicate from an existed Redis instance
|
|
21
|
-
*/
|
|
22
|
-
redis?: RedisInstance;
|
|
23
|
-
/**
|
|
24
|
-
* Redis instance creator
|
|
25
|
-
*/
|
|
26
|
-
createClient?: () => RedisInstance;
|
|
27
|
-
/**
|
|
28
|
-
* Options passed directly to Redis constructor
|
|
29
|
-
*
|
|
30
|
-
* https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
|
|
31
|
-
*/
|
|
32
|
-
options?: ClusterOptions | RedisOptions;
|
|
33
|
-
/**
|
|
34
|
-
* An unique instance name, required to filter messages in Redis.
|
|
35
|
-
* If none is provided an unique id is generated.
|
|
36
|
-
*/
|
|
37
|
-
identifier: string;
|
|
38
|
-
/**
|
|
39
|
-
* Namespace for Redis keys, if none is provided 'hocuspocus' is used
|
|
40
|
-
*/
|
|
41
|
-
prefix: string;
|
|
42
|
-
/**
|
|
43
|
-
* The maximum time for the Redis lock in ms (in case it can’t be released).
|
|
44
|
-
*/
|
|
45
|
-
lockTimeout: number;
|
|
46
|
-
/**
|
|
47
|
-
* A delay before onDisconnect is executed. This allows last minute updates'
|
|
48
|
-
* sync messages to be received by the subscription before it's closed.
|
|
49
|
-
*/
|
|
50
|
-
disconnectDelay: number;
|
|
51
|
-
}
|
|
52
|
-
export declare class Redis implements Extension {
|
|
53
|
-
/**
|
|
54
|
-
* Make sure to give that extension a higher priority, so
|
|
55
|
-
* the `onStoreDocument` hook is able to intercept the chain,
|
|
56
|
-
* before documents are stored to the database.
|
|
57
|
-
*/
|
|
58
|
-
priority: number;
|
|
59
|
-
configuration: Configuration;
|
|
60
|
-
redisTransactionOrigin: string;
|
|
61
|
-
pub: RedisInstance;
|
|
62
|
-
sub: RedisInstance;
|
|
63
|
-
instance: Hocuspocus;
|
|
64
|
-
redlock: Redlock;
|
|
65
|
-
locks: Map<string, {
|
|
66
|
-
lock: Lock;
|
|
67
|
-
release?: Promise<ExecutionResult>;
|
|
68
|
-
}>;
|
|
69
|
-
messagePrefix: Buffer;
|
|
70
|
-
private pendingAfterStoreDocumentResolves;
|
|
71
|
-
constructor(configuration: Partial<Configuration>);
|
|
72
|
-
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
73
|
-
private getKey;
|
|
74
|
-
private pubKey;
|
|
75
|
-
private subKey;
|
|
76
|
-
private lockKey;
|
|
77
|
-
private encodeMessage;
|
|
78
|
-
private decodeMessage;
|
|
79
|
-
/**
|
|
80
|
-
* Once a document is loaded, subscribe to the channel in Redis.
|
|
81
|
-
*/
|
|
82
|
-
afterLoadDocument({ documentName, document, }: afterLoadDocumentPayload): Promise<unknown>;
|
|
83
|
-
/**
|
|
84
|
-
* Publish the first sync step through Redis.
|
|
85
|
-
*/
|
|
86
|
-
private publishFirstSyncStep;
|
|
87
|
-
/**
|
|
88
|
-
* Let’s ask Redis who is connected already.
|
|
89
|
-
*/
|
|
90
|
-
private requestAwarenessFromOtherInstances;
|
|
91
|
-
/**
|
|
92
|
-
* Before the document is stored, make sure to set a lock in Redis.
|
|
93
|
-
* That’s meant to avoid conflicts with other instances trying to store the document.
|
|
94
|
-
*/
|
|
95
|
-
onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<void>;
|
|
96
|
-
/**
|
|
97
|
-
* Release the Redis lock, so other instances can store documents.
|
|
98
|
-
*/
|
|
99
|
-
afterStoreDocument({ documentName, socketId, }: afterStoreDocumentPayload): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Handle awareness update messages received directly by this Hocuspocus instance.
|
|
102
|
-
*/
|
|
103
|
-
onAwarenessUpdate({ documentName, awareness, added, updated, removed, document, }: onAwarenessUpdatePayload): Promise<number | undefined>;
|
|
104
|
-
/**
|
|
105
|
-
* Handle incoming messages published on subscribed document channels.
|
|
106
|
-
* Note that this will also include messages from ourselves as it is not possible
|
|
107
|
-
* in Redis to filter these.
|
|
108
|
-
*/
|
|
109
|
-
private handleIncomingMessage;
|
|
110
|
-
/**
|
|
111
|
-
* if the ydoc changed, we'll need to inform other Hocuspocus servers about it.
|
|
112
|
-
*/
|
|
113
|
-
onChange(data: onChangePayload): Promise<any>;
|
|
114
|
-
/**
|
|
115
|
-
* Delay unloading to allow syncs to finish
|
|
116
|
-
*/
|
|
117
|
-
beforeUnloadDocument(data: beforeUnloadDocumentPayload): Promise<void>;
|
|
118
|
-
afterUnloadDocument(data: afterUnloadDocumentPayload): Promise<void>;
|
|
119
|
-
beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
|
|
120
|
-
/**
|
|
121
|
-
* Kill the Redlock connection immediately.
|
|
122
|
-
*/
|
|
123
|
-
onDestroy(): Promise<void>;
|
|
124
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Redis.ts";
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { DatabaseConfiguration } from "@hocuspocus/extension-database";
|
|
2
|
-
import { Database } from "@hocuspocus/extension-database";
|
|
3
|
-
import { S3Client } from "@aws-sdk/client-s3";
|
|
4
|
-
export interface S3Configuration extends DatabaseConfiguration {
|
|
5
|
-
/**
|
|
6
|
-
* AWS S3 region
|
|
7
|
-
*/
|
|
8
|
-
region?: string;
|
|
9
|
-
/**
|
|
10
|
-
* S3 bucket name
|
|
11
|
-
*/
|
|
12
|
-
bucket: string;
|
|
13
|
-
/**
|
|
14
|
-
* S3 key prefix for documents (optional)
|
|
15
|
-
*/
|
|
16
|
-
prefix?: string;
|
|
17
|
-
/**
|
|
18
|
-
* AWS credentials
|
|
19
|
-
*/
|
|
20
|
-
credentials?: {
|
|
21
|
-
accessKeyId: string;
|
|
22
|
-
secretAccessKey: string;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* S3 endpoint URL (for S3-compatible services like MinIO)
|
|
26
|
-
*/
|
|
27
|
-
endpoint?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Force path style URLs (required for MinIO)
|
|
30
|
-
*/
|
|
31
|
-
forcePathStyle?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Custom S3 client
|
|
34
|
-
*/
|
|
35
|
-
s3Client?: S3Client;
|
|
36
|
-
}
|
|
37
|
-
export declare class S3 extends Database {
|
|
38
|
-
private s3Client?;
|
|
39
|
-
configuration: S3Configuration;
|
|
40
|
-
constructor(configuration: Partial<S3Configuration>);
|
|
41
|
-
private getObjectKey;
|
|
42
|
-
onConfigure(): Promise<void>;
|
|
43
|
-
onListen(): Promise<void>;
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./S3.ts";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { DatabaseConfiguration } from "@hocuspocus/extension-database";
|
|
2
|
-
import { Database } from "@hocuspocus/extension-database";
|
|
3
|
-
import sqlite3 from "sqlite3";
|
|
4
|
-
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)";
|
|
5
|
-
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
6
|
-
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
7
|
-
export interface SQLiteConfiguration extends DatabaseConfiguration {
|
|
8
|
-
/**
|
|
9
|
-
* Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
|
|
10
|
-
* string for an anonymous disk-based database. Anonymous databases are not persisted and
|
|
11
|
-
* when closing the database handle, their contents are lost.
|
|
12
|
-
*
|
|
13
|
-
* https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
|
|
14
|
-
*/
|
|
15
|
-
database: string;
|
|
16
|
-
/**
|
|
17
|
-
* The database schema to create.
|
|
18
|
-
*/
|
|
19
|
-
schema: string;
|
|
20
|
-
}
|
|
21
|
-
export declare class SQLite extends Database {
|
|
22
|
-
db?: sqlite3.Database;
|
|
23
|
-
configuration: SQLiteConfiguration;
|
|
24
|
-
constructor(configuration?: Partial<SQLiteConfiguration>);
|
|
25
|
-
onConfigure(): Promise<void>;
|
|
26
|
-
onListen(): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./SQLite.ts";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Extension, onConnectPayload } from "@hocuspocus/server";
|
|
2
|
-
export interface ThrottleConfiguration {
|
|
3
|
-
throttle: number | null | false;
|
|
4
|
-
consideredSeconds: number;
|
|
5
|
-
banTime: number;
|
|
6
|
-
cleanupInterval: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class Throttle implements Extension {
|
|
9
|
-
configuration: ThrottleConfiguration;
|
|
10
|
-
connectionsByIp: Map<string, Array<number>>;
|
|
11
|
-
bannedIps: Map<string, number>;
|
|
12
|
-
cleanupInterval?: NodeJS.Timeout;
|
|
13
|
-
/**
|
|
14
|
-
* Constructor
|
|
15
|
-
*/
|
|
16
|
-
constructor(configuration?: Partial<ThrottleConfiguration>);
|
|
17
|
-
onDestroy(): Promise<void>;
|
|
18
|
-
clearMaps(): void;
|
|
19
|
-
isBanned(ip: string): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Throttle requests
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
|
-
private throttle;
|
|
25
|
-
/**
|
|
26
|
-
* onConnect hook
|
|
27
|
-
* @param data
|
|
28
|
-
*/
|
|
29
|
-
onConnect(data: onConnectPayload): Promise<any>;
|
|
30
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload } from "@hocuspocus/server";
|
|
2
|
-
import type { Transformer } from "@hocuspocus/transformer";
|
|
3
|
-
import type { Doc } from "yjs";
|
|
4
|
-
export declare enum Events {
|
|
5
|
-
onChange = "change",
|
|
6
|
-
onConnect = "connect",
|
|
7
|
-
onCreate = "create",
|
|
8
|
-
onDisconnect = "disconnect"
|
|
9
|
-
}
|
|
10
|
-
export interface Configuration {
|
|
11
|
-
debounce: number | false | null;
|
|
12
|
-
debounceMaxWait: number;
|
|
13
|
-
secret: string;
|
|
14
|
-
transformer: Transformer | {
|
|
15
|
-
toYdoc: (document: any) => Doc;
|
|
16
|
-
fromYdoc: (document: Doc) => any;
|
|
17
|
-
};
|
|
18
|
-
url: string;
|
|
19
|
-
events: Array<Events>;
|
|
20
|
-
}
|
|
21
|
-
export declare class Webhook implements Extension {
|
|
22
|
-
configuration: Configuration;
|
|
23
|
-
debounced: Map<string, {
|
|
24
|
-
timeout: NodeJS.Timeout;
|
|
25
|
-
start: number;
|
|
26
|
-
}>;
|
|
27
|
-
/**
|
|
28
|
-
* Constructor
|
|
29
|
-
*/
|
|
30
|
-
constructor(configuration?: Partial<Configuration>);
|
|
31
|
-
/**
|
|
32
|
-
* Create a signature for the response body
|
|
33
|
-
*/
|
|
34
|
-
createSignature(body: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* debounce the given function, using the given identifier
|
|
37
|
-
*/
|
|
38
|
-
debounce(id: string, func: Function): void;
|
|
39
|
-
/**
|
|
40
|
-
* Send a request to the given url containing the given data
|
|
41
|
-
*/
|
|
42
|
-
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
43
|
-
/**
|
|
44
|
-
* onChange hook
|
|
45
|
-
*/
|
|
46
|
-
onChange(data: onChangePayload): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* onLoadDocument hook
|
|
49
|
-
*/
|
|
50
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* onConnect hook
|
|
53
|
-
*/
|
|
54
|
-
onConnect(data: onConnectPayload): Promise<any>;
|
|
55
|
-
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
56
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { Event, MessageEvent } from "ws";
|
|
2
|
-
import { Awareness } from "y-protocols/awareness";
|
|
3
|
-
import * as Y from "yjs";
|
|
4
|
-
import EventEmitter from "./EventEmitter.ts";
|
|
5
|
-
import type { CompleteHocuspocusProviderWebsocketConfiguration } from "./HocuspocusProviderWebsocket.ts";
|
|
6
|
-
import { HocuspocusProviderWebsocket } from "./HocuspocusProviderWebsocket.ts";
|
|
7
|
-
import type { AuthorizedScope, ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters, onUnsyncedChangesParameters } from "./types.ts";
|
|
8
|
-
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, "name">> & Partial<CompleteHocuspocusProviderConfiguration> & ((Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">> & Partial<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "preserveTrailingSlash">>) | Required<Pick<CompleteHocuspocusProviderConfiguration, "websocketProvider">>);
|
|
9
|
-
export interface CompleteHocuspocusProviderConfiguration {
|
|
10
|
-
/**
|
|
11
|
-
* The identifier/name of your document
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* The actual Y.js document
|
|
16
|
-
*/
|
|
17
|
-
document: Y.Doc;
|
|
18
|
-
/**
|
|
19
|
-
* An Awareness instance to keep the presence state of all clients.
|
|
20
|
-
*
|
|
21
|
-
* You can disable sharing awareness information by passing `null`.
|
|
22
|
-
* Note that having no awareness information shared across all connections will break our ping checks
|
|
23
|
-
* and thus trigger reconnects. You should always have at least one Provider with enabled awareness per
|
|
24
|
-
* socket connection, or ensure that the Provider receives messages before running into `HocuspocusProviderWebsocket.messageReconnectTimeout`.
|
|
25
|
-
*/
|
|
26
|
-
awareness: Awareness | null;
|
|
27
|
-
/**
|
|
28
|
-
* A token that’s sent to the backend for authentication purposes.
|
|
29
|
-
*/
|
|
30
|
-
token: string | (() => string) | (() => Promise<string>) | null;
|
|
31
|
-
/**
|
|
32
|
-
* Hocuspocus websocket provider
|
|
33
|
-
*/
|
|
34
|
-
websocketProvider: HocuspocusProviderWebsocket;
|
|
35
|
-
/**
|
|
36
|
-
* Force syncing the document in the defined interval.
|
|
37
|
-
*/
|
|
38
|
-
forceSyncInterval: false | number;
|
|
39
|
-
onAuthenticated: (data: onAuthenticatedParameters) => void;
|
|
40
|
-
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
|
|
41
|
-
onOpen: (data: onOpenParameters) => void;
|
|
42
|
-
onConnect: () => void;
|
|
43
|
-
onStatus: (data: onStatusParameters) => void;
|
|
44
|
-
onMessage: (data: onMessageParameters) => void;
|
|
45
|
-
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
46
|
-
onSynced: (data: onSyncedParameters) => void;
|
|
47
|
-
onDisconnect: (data: onDisconnectParameters) => void;
|
|
48
|
-
onClose: (data: onCloseParameters) => void;
|
|
49
|
-
onDestroy: () => void;
|
|
50
|
-
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
|
|
51
|
-
onAwarenessChange: (data: onAwarenessChangeParameters) => void;
|
|
52
|
-
onStateless: (data: onStatelessParameters) => void;
|
|
53
|
-
onUnsyncedChanges: (data: onUnsyncedChangesParameters) => void;
|
|
54
|
-
}
|
|
55
|
-
export declare class AwarenessError extends Error {
|
|
56
|
-
code: number;
|
|
57
|
-
}
|
|
58
|
-
export declare class HocuspocusProvider extends EventEmitter {
|
|
59
|
-
configuration: CompleteHocuspocusProviderConfiguration;
|
|
60
|
-
isSynced: boolean;
|
|
61
|
-
unsyncedChanges: number;
|
|
62
|
-
isAuthenticated: boolean;
|
|
63
|
-
authorizedScope: AuthorizedScope | undefined;
|
|
64
|
-
manageSocket: boolean;
|
|
65
|
-
private _isAttached;
|
|
66
|
-
intervals: any;
|
|
67
|
-
constructor(configuration: HocuspocusProviderConfiguration);
|
|
68
|
-
boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
|
|
69
|
-
boundAwarenessUpdateHandler: ({ added, updated, removed }: any, origin: any) => void;
|
|
70
|
-
boundPageHide: () => void;
|
|
71
|
-
boundOnOpen: (event: Event) => Promise<void>;
|
|
72
|
-
boundOnClose: () => void;
|
|
73
|
-
forwardConnect: () => this;
|
|
74
|
-
forwardStatus: (e: onStatusParameters) => this;
|
|
75
|
-
forwardClose: (e: onCloseParameters) => this;
|
|
76
|
-
forwardDisconnect: (e: onDisconnectParameters) => this;
|
|
77
|
-
forwardDestroy: () => this;
|
|
78
|
-
setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void;
|
|
79
|
-
get document(): Y.Doc;
|
|
80
|
-
get isAttached(): boolean;
|
|
81
|
-
get awareness(): Awareness | null;
|
|
82
|
-
get hasUnsyncedChanges(): boolean;
|
|
83
|
-
private resetUnsyncedChanges;
|
|
84
|
-
incrementUnsyncedChanges(): void;
|
|
85
|
-
decrementUnsyncedChanges(): void;
|
|
86
|
-
forceSync(): void;
|
|
87
|
-
pageHide(): void;
|
|
88
|
-
registerEventListeners(): void;
|
|
89
|
-
sendStateless(payload: string): void;
|
|
90
|
-
sendToken(): Promise<void>;
|
|
91
|
-
documentUpdateHandler(update: Uint8Array, origin: any): void;
|
|
92
|
-
awarenessUpdateHandler({ added, updated, removed }: any, origin: any): void;
|
|
93
|
-
/**
|
|
94
|
-
* Indicates whether a first handshake with the server has been established
|
|
95
|
-
*
|
|
96
|
-
* Note: this does not mean all updates from the client have been persisted to the backend. For this,
|
|
97
|
-
* use `hasUnsyncedChanges`.
|
|
98
|
-
*/
|
|
99
|
-
get synced(): boolean;
|
|
100
|
-
set synced(state: boolean);
|
|
101
|
-
receiveStateless(payload: string): void;
|
|
102
|
-
connect(): Promise<unknown>;
|
|
103
|
-
disconnect(): void;
|
|
104
|
-
onOpen(event: Event): Promise<void>;
|
|
105
|
-
getToken(): Promise<string | null>;
|
|
106
|
-
startSync(): void;
|
|
107
|
-
send(message: ConstructableOutgoingMessage, args: any): void;
|
|
108
|
-
onMessage(event: MessageEvent): void;
|
|
109
|
-
onClose(): void;
|
|
110
|
-
destroy(): void;
|
|
111
|
-
detach(): void;
|
|
112
|
-
attach(): void;
|
|
113
|
-
permissionDeniedHandler(reason: string): void;
|
|
114
|
-
authenticatedHandler(scope: string): void;
|
|
115
|
-
setAwarenessField(key: string, value: any): void;
|
|
116
|
-
}
|