@hocuspocus/extension-database 1.0.0-alpha.1

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 (66) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +14 -0
  3. package/dist/hocuspocus-database.cjs +66 -0
  4. package/dist/hocuspocus-database.cjs.map +1 -0
  5. package/dist/hocuspocus-database.esm.js +42 -0
  6. package/dist/hocuspocus-database.esm.js.map +1 -0
  7. package/dist/packages/common/src/auth.d.ts +6 -0
  8. package/dist/packages/common/src/index.d.ts +1 -0
  9. package/dist/packages/extension-database/src/Database.d.ts +36 -0
  10. package/dist/packages/extension-database/src/index.d.ts +1 -0
  11. package/dist/packages/extension-logger/src/Logger.d.ts +62 -0
  12. package/dist/packages/extension-logger/src/index.d.ts +1 -0
  13. package/dist/packages/extension-monitor/src/Collector.d.ts +62 -0
  14. package/dist/packages/extension-monitor/src/Dashboard.d.ts +29 -0
  15. package/dist/packages/extension-monitor/src/Storage.d.ts +35 -0
  16. package/dist/packages/extension-monitor/src/index.d.ts +38 -0
  17. package/dist/packages/extension-redis/src/Redis.d.ts +16 -0
  18. package/dist/packages/extension-redis/src/RedisCluster.d.ts +4 -0
  19. package/dist/packages/extension-redis/src/index.d.ts +2 -0
  20. package/dist/packages/extension-rocksdb/src/index.d.ts +22 -0
  21. package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -0
  22. package/dist/packages/extension-sqlite/src/index.d.ts +1 -0
  23. package/dist/packages/extension-throttle/src/index.d.ts +20 -0
  24. package/dist/packages/extension-webhook/src/index.d.ts +59 -0
  25. package/dist/packages/provider/src/EventEmitter.d.ts +9 -0
  26. package/dist/packages/provider/src/HocuspocusCloudProvider.d.ts +10 -0
  27. package/dist/packages/provider/src/HocuspocusProvider.d.ts +158 -0
  28. package/dist/packages/provider/src/IncomingMessage.d.ts +14 -0
  29. package/dist/packages/provider/src/MessageReceiver.d.ts +13 -0
  30. package/dist/packages/provider/src/MessageSender.d.ts +10 -0
  31. package/dist/packages/provider/src/OutgoingMessage.d.ts +9 -0
  32. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +7 -0
  33. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +8 -0
  34. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +8 -0
  35. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +8 -0
  36. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +8 -0
  37. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +7 -0
  38. package/dist/packages/provider/src/index.d.ts +4 -0
  39. package/dist/packages/provider/src/types.d.ts +34 -0
  40. package/dist/packages/provider/src/utils/awarenessStatesToArray.d.ts +4 -0
  41. package/dist/packages/provider/src/utils/index.d.ts +1 -0
  42. package/dist/packages/server/src/CloseEvents.d.ts +4 -0
  43. package/dist/packages/server/src/Connection.d.ts +63 -0
  44. package/dist/packages/server/src/Debugger.d.ts +15 -0
  45. package/dist/packages/server/src/Document.d.ts +75 -0
  46. package/dist/packages/server/src/Hocuspocus.d.ts +89 -0
  47. package/dist/packages/server/src/IncomingMessage.d.ts +19 -0
  48. package/dist/packages/server/src/MessageReceiver.d.ts +10 -0
  49. package/dist/packages/server/src/OutgoingMessage.d.ts +16 -0
  50. package/dist/packages/server/src/index.d.ts +2 -0
  51. package/dist/packages/server/src/types.d.ts +158 -0
  52. package/dist/packages/transformer/src/Prosemirror.d.ts +11 -0
  53. package/dist/packages/transformer/src/Tiptap.d.ts +10 -0
  54. package/dist/packages/transformer/src/index.d.ts +3 -0
  55. package/dist/packages/transformer/src/types.d.ts +5 -0
  56. package/dist/playground/backend/src/default.d.ts +1 -0
  57. package/dist/playground/backend/src/express.d.ts +1 -0
  58. package/dist/playground/backend/src/koa.d.ts +1 -0
  59. package/dist/playground/backend/src/load-document.d.ts +1 -0
  60. package/dist/playground/backend/src/monitor.d.ts +1 -0
  61. package/dist/playground/backend/src/redis.d.ts +1 -0
  62. package/dist/playground/backend/src/slow.d.ts +1 -0
  63. package/dist/playground/backend/src/webhook.d.ts +1 -0
  64. package/package.json +36 -0
  65. package/src/Database.ts +60 -0
  66. package/src/index.ts +1 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021, überdosis GbR
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # @hocuspocus/extension-database
2
+ [![Version](https://img.shields.io/npm/v/@hocuspocus/extension-database.svg?label=version)](https://www.npmjs.com/package/@hocuspocus/extension-database)
3
+ [![Downloads](https://img.shields.io/npm/dm/@hocuspocus/extension-database.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
+ [![License](https://img.shields.io/npm/l/@hocuspocus/extension-database.svg)](https://www.npmjs.com/package/@hocuspocus/extension-database)
5
+ [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
+
7
+ ## Introduction
8
+ hocuspocus is an opinionated collaborative editing backend for [tiptap](https://github.com/ueberdosis/tiptap) – based on [Y.js](https://github.com/yjs/yjs), a CRDT framework with a powerful abstraction of shared data.
9
+
10
+ ## Offical Documentation
11
+ Documentation can be found in the [GitHub repository](https://github.com/ueberdosis/hocuspocus).
12
+
13
+ ## License
14
+ hocuspocus is open-sourced software licensed under the [MIT license](https://github.com/ueberdosis/hocuspocus/blob/main/LICENSE.md).
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Y = require('yjs');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var Y__namespace = /*#__PURE__*/_interopNamespace(Y);
26
+
27
+ class Database {
28
+ /**
29
+ * Constructor
30
+ */
31
+ constructor(configuration) {
32
+ /**
33
+ * Default configuration
34
+ */
35
+ this.configuration = {
36
+ fetchUpdates: async () => [],
37
+ storeUpdate: async () => null,
38
+ };
39
+ this.configuration = {
40
+ ...this.configuration,
41
+ ...configuration,
42
+ };
43
+ }
44
+ /**
45
+ * Get stored data from the database.
46
+ */
47
+ async onLoadDocument({ document, documentName }) {
48
+ const updates = await this.configuration.fetchUpdates({ documentName });
49
+ if (updates && updates.length) {
50
+ updates.forEach((update) => {
51
+ Y__namespace.applyUpdate(document, update);
52
+ });
53
+ }
54
+ return document;
55
+ }
56
+ /**
57
+ * Store new updates in the database.
58
+ */
59
+ async onChange({ document, documentName }) {
60
+ const update = Buffer.from(Y__namespace.encodeStateAsUpdate(document));
61
+ return this.configuration.storeUpdate({ update, documentName });
62
+ }
63
+ }
64
+
65
+ exports.Database = Database;
66
+ //# sourceMappingURL=hocuspocus-database.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hocuspocus-database.cjs","sources":["../src/Database.ts"],"sourcesContent":["import { Extension, onChangePayload, onLoadDocumentPayload } from '@hocuspocus/server'\nimport * as Y from 'yjs'\n\nexport interface DatabaseConfiguration {\n /**\n * Pass a Promise to retrieve updates from your database. The Promise should resolve to\n * an array of items with Y.js-compatible binary data.\n */\n fetchUpdates: ({ documentName }: { documentName: string}) => Promise<Uint8Array[]>,\n /**\n * Pass a function to store updates in your database.\n */\n storeUpdate: ({ update, documentName }: { update: Buffer, documentName: string}) => void,\n}\n\nexport class Database implements Extension {\n /**\n * Default configuration\n */\n configuration: DatabaseConfiguration = {\n fetchUpdates: async () => [],\n storeUpdate: async () => null,\n }\n\n /**\n * Constructor\n */\n constructor(configuration: Partial<DatabaseConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /**\n * Get stored data from the database.\n */\n async onLoadDocument({ document, documentName }: onLoadDocumentPayload): Promise<any> {\n const updates = await this.configuration.fetchUpdates({ documentName })\n\n if (updates && updates.length) {\n updates.forEach((update: any) => {\n Y.applyUpdate(document, update)\n })\n }\n\n return document\n }\n\n /**\n * Store new updates in the database.\n */\n async onChange({ document, documentName }: onChangePayload) {\n const update = Buffer.from(\n Y.encodeStateAsUpdate(document),\n )\n\n return this.configuration.storeUpdate({ update, documentName })\n }\n}\n"],"names":["Y"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;MAea,QAAQ;;;;IAYnB,YAAY,aAA6C;;;;QARzD,kBAAa,GAA0B;YACrC,YAAY,EAAE,YAAY,EAAE;YAC5B,WAAW,EAAE,YAAY,IAAI;SAC9B,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;;;;IAKD,MAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAyB;QACpE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;QAEvE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;YAC7B,OAAO,CAAC,OAAO,CAAC,CAAC,MAAW;gBAC1BA,YAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;aAChC,CAAC,CAAA;SACH;QAED,OAAO,QAAQ,CAAA;KAChB;;;;IAKD,MAAM,QAAQ,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAmB;QACxD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CACxBA,YAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAChC,CAAA;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;KAChE;;;;;"}
@@ -0,0 +1,42 @@
1
+ import * as Y from 'yjs';
2
+
3
+ class Database {
4
+ /**
5
+ * Constructor
6
+ */
7
+ constructor(configuration) {
8
+ /**
9
+ * Default configuration
10
+ */
11
+ this.configuration = {
12
+ fetchUpdates: async () => [],
13
+ storeUpdate: async () => null,
14
+ };
15
+ this.configuration = {
16
+ ...this.configuration,
17
+ ...configuration,
18
+ };
19
+ }
20
+ /**
21
+ * Get stored data from the database.
22
+ */
23
+ async onLoadDocument({ document, documentName }) {
24
+ const updates = await this.configuration.fetchUpdates({ documentName });
25
+ if (updates && updates.length) {
26
+ updates.forEach((update) => {
27
+ Y.applyUpdate(document, update);
28
+ });
29
+ }
30
+ return document;
31
+ }
32
+ /**
33
+ * Store new updates in the database.
34
+ */
35
+ async onChange({ document, documentName }) {
36
+ const update = Buffer.from(Y.encodeStateAsUpdate(document));
37
+ return this.configuration.storeUpdate({ update, documentName });
38
+ }
39
+ }
40
+
41
+ export { Database };
42
+ //# sourceMappingURL=hocuspocus-database.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hocuspocus-database.esm.js","sources":["../src/Database.ts"],"sourcesContent":["import { Extension, onChangePayload, onLoadDocumentPayload } from '@hocuspocus/server'\nimport * as Y from 'yjs'\n\nexport interface DatabaseConfiguration {\n /**\n * Pass a Promise to retrieve updates from your database. The Promise should resolve to\n * an array of items with Y.js-compatible binary data.\n */\n fetchUpdates: ({ documentName }: { documentName: string}) => Promise<Uint8Array[]>,\n /**\n * Pass a function to store updates in your database.\n */\n storeUpdate: ({ update, documentName }: { update: Buffer, documentName: string}) => void,\n}\n\nexport class Database implements Extension {\n /**\n * Default configuration\n */\n configuration: DatabaseConfiguration = {\n fetchUpdates: async () => [],\n storeUpdate: async () => null,\n }\n\n /**\n * Constructor\n */\n constructor(configuration: Partial<DatabaseConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /**\n * Get stored data from the database.\n */\n async onLoadDocument({ document, documentName }: onLoadDocumentPayload): Promise<any> {\n const updates = await this.configuration.fetchUpdates({ documentName })\n\n if (updates && updates.length) {\n updates.forEach((update: any) => {\n Y.applyUpdate(document, update)\n })\n }\n\n return document\n }\n\n /**\n * Store new updates in the database.\n */\n async onChange({ document, documentName }: onChangePayload) {\n const update = Buffer.from(\n Y.encodeStateAsUpdate(document),\n )\n\n return this.configuration.storeUpdate({ update, documentName })\n }\n}\n"],"names":[],"mappings":";;MAea,QAAQ;;;;IAYnB,YAAY,aAA6C;;;;QARzD,kBAAa,GAA0B;YACrC,YAAY,EAAE,YAAY,EAAE;YAC5B,WAAW,EAAE,YAAY,IAAI;SAC9B,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;;;;IAKD,MAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAyB;QACpE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;QAEvE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;YAC7B,OAAO,CAAC,OAAO,CAAC,CAAC,MAAW;gBAC1B,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;aAChC,CAAC,CAAA;SACH;QAED,OAAO,QAAQ,CAAA;KAChB;;;;IAKD,MAAM,QAAQ,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAmB;QACxD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CACxB,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAChC,CAAA;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;KAChE;;;;;"}
@@ -0,0 +1,6 @@
1
+ import * as encoding from 'lib0/encoding';
2
+ import * as decoding from 'lib0/decoding';
3
+ export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
4
+ export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
5
+ export declare const writeAuthenticated: (encoder: encoding.Encoder) => void;
6
+ export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: () => void) => void;
@@ -0,0 +1 @@
1
+ export * from './auth';
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ import { Extension, onChangePayload, onLoadDocumentPayload } from '@hocuspocus/server';
3
+ export interface DatabaseConfiguration {
4
+ /**
5
+ * Pass a Promise to retrieve updates from your database. The Promise should resolve to
6
+ * an array of items with Y.js-compatible binary data.
7
+ */
8
+ fetchUpdates: ({ documentName }: {
9
+ documentName: string;
10
+ }) => Promise<Uint8Array[]>;
11
+ /**
12
+ * Pass a function to store updates in your database.
13
+ */
14
+ storeUpdate: ({ update, documentName }: {
15
+ update: Buffer;
16
+ documentName: string;
17
+ }) => void;
18
+ }
19
+ export declare class Database implements Extension {
20
+ /**
21
+ * Default configuration
22
+ */
23
+ configuration: DatabaseConfiguration;
24
+ /**
25
+ * Constructor
26
+ */
27
+ constructor(configuration: Partial<DatabaseConfiguration>);
28
+ /**
29
+ * Get stored data from the database.
30
+ */
31
+ onLoadDocument({ document, documentName }: onLoadDocumentPayload): Promise<any>;
32
+ /**
33
+ * Store new updates in the database.
34
+ */
35
+ onChange({ document, documentName }: onChangePayload): Promise<void>;
36
+ }
@@ -0,0 +1 @@
1
+ export * from './Database';
@@ -0,0 +1,62 @@
1
+ import { 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 `onConnect` hook.
19
+ */
20
+ onConnect: boolean;
21
+ /**
22
+ * Whether to log something for the `onDisconnect` hook.
23
+ */
24
+ onDisconnect: boolean;
25
+ /**
26
+ * Whether to log something for the `onUpgrade` hook.
27
+ */
28
+ onUpgrade: boolean;
29
+ /**
30
+ * Whether to log something for the `onRequest` hook.
31
+ */
32
+ onRequest: boolean;
33
+ /**
34
+ * Whether to log something for the `onDestroy` hook.
35
+ */
36
+ onDestroy: boolean;
37
+ /**
38
+ * Whether to log something for the `onConfigure` hook.
39
+ */
40
+ onConfigure: boolean;
41
+ /**
42
+ * A log function, if none is provided output will go to console
43
+ */
44
+ log: (...args: any[]) => void;
45
+ }
46
+ export declare class Logger implements Extension {
47
+ name: string | null;
48
+ configuration: LoggerConfiguration;
49
+ /**
50
+ * Constructor
51
+ */
52
+ constructor(configuration?: Partial<LoggerConfiguration>);
53
+ onConfigure(data: onConfigurePayload): Promise<void>;
54
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
55
+ onChange(data: onChangePayload): Promise<void>;
56
+ onConnect(data: onConnectPayload): Promise<void>;
57
+ onDisconnect(data: onDisconnectPayload): Promise<void>;
58
+ onUpgrade(data: onUpgradePayload): Promise<void>;
59
+ onRequest(data: onRequestPayload): Promise<void>;
60
+ onDestroy(data: onDestroyPayload): Promise<void>;
61
+ private log;
62
+ }
@@ -0,0 +1 @@
1
+ export * from './Logger';
@@ -0,0 +1,62 @@
1
+ /// <reference types="node" />
2
+ import { Configuration, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload, onChangePayload } from '@hocuspocus/server';
3
+ export declare class Collector {
4
+ serverConfiguration: Partial<Configuration>;
5
+ version: string;
6
+ yjsVersion: string;
7
+ connections: {};
8
+ messages: {};
9
+ messageCounter: number;
10
+ memory(): Promise<{
11
+ free: number;
12
+ total: number;
13
+ usage: number;
14
+ }>;
15
+ cpu(): Promise<{
16
+ count: number;
17
+ model: string;
18
+ usage: number;
19
+ }>;
20
+ connect(data: onConnectPayload): {
21
+ action: string;
22
+ documentName: string;
23
+ socketId: string;
24
+ };
25
+ disconnect(data: onDisconnectPayload): {
26
+ action: string;
27
+ documentName: string;
28
+ socketId: string;
29
+ };
30
+ connectionCount(): {
31
+ count: string | number;
32
+ };
33
+ createDocument(data: onLoadDocumentPayload): {
34
+ action: string;
35
+ document: any;
36
+ documentName: string;
37
+ socketId: string;
38
+ };
39
+ changeDocument(data: onChangePayload): {
40
+ action: string;
41
+ document: any;
42
+ documentName: string;
43
+ socketId: string;
44
+ };
45
+ messageCount(): {
46
+ count: number;
47
+ };
48
+ documentCount(): {
49
+ count: number;
50
+ };
51
+ documents(): {};
52
+ info(): Promise<{
53
+ configuration: Partial<Configuration>;
54
+ ipAddress: string;
55
+ nodeVersion: string;
56
+ platform: NodeJS.Platform;
57
+ started: string;
58
+ version: string;
59
+ yjsVersion: string;
60
+ }>;
61
+ private static readableYDoc;
62
+ }
@@ -0,0 +1,29 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+ import WebSocket, { WebSocketServer } from 'ws';
4
+ import { Socket } from 'net';
5
+ import { Storage } from './Storage';
6
+ export interface Configuration {
7
+ password: string | undefined;
8
+ path: string;
9
+ port: number | undefined;
10
+ storage: Storage | undefined;
11
+ user: string | undefined;
12
+ }
13
+ export declare class Dashboard {
14
+ configuration: Configuration;
15
+ websocketServer: WebSocketServer;
16
+ connections: Map<WebSocket, any>;
17
+ /**
18
+ * Constructor
19
+ */
20
+ constructor(configuration?: Partial<Configuration>);
21
+ createServer(): void;
22
+ handleRequest(request: IncomingMessage, response: ServerResponse): boolean;
23
+ handleUpgrade(request: IncomingMessage, socket: Socket, head: any): boolean;
24
+ handleConnection(connection: WebSocket, request: IncomingMessage): void;
25
+ close(connection: WebSocket): void;
26
+ send(message: string): void;
27
+ private sendInitialDataToClient;
28
+ private basicAuth;
29
+ }
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ export declare class Storage extends EventEmitter {
4
+ timed: Map<string, any>;
5
+ constant: Map<string, any>;
6
+ /**
7
+ * Get all constant values.
8
+ */
9
+ all(): Promise<any>;
10
+ /**
11
+ * Get a constant value by the given key.
12
+ */
13
+ get(key: string, defaultValue?: any): Promise<any>;
14
+ /**
15
+ * Set a constant value by the given key.
16
+ */
17
+ set(key: string, value: any): Promise<any>;
18
+ /**
19
+ * Delete a constant value by the given key.
20
+ * @param key
21
+ */
22
+ delete(key: string): Promise<any>;
23
+ /**
24
+ * Get all timed values.
25
+ */
26
+ allTimed(): Promise<any>;
27
+ /**
28
+ * Add a timed value by the given key.
29
+ */
30
+ add(key: string, value: any): Promise<any>;
31
+ /**
32
+ * Remove a timed value by the given timestamp and key.
33
+ */
34
+ remove(key: string, timestamp: string): Promise<any>;
35
+ }
@@ -0,0 +1,38 @@
1
+ /// <reference types="node" />
2
+ import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
3
+ import { IncomingMessage, ServerResponse } from 'http';
4
+ import WebSocket from 'ws';
5
+ import { Storage } from './Storage';
6
+ import { Dashboard } from './Dashboard';
7
+ import { Collector } from './Collector';
8
+ export interface Configuration {
9
+ dashboardPath: string;
10
+ enableDashboard: boolean;
11
+ metricsInterval: number;
12
+ osMetricsInterval: number;
13
+ password: string | undefined;
14
+ port: number | undefined;
15
+ user: string | undefined;
16
+ }
17
+ export declare class Monitor implements Extension {
18
+ configuration: Configuration;
19
+ storage: Storage;
20
+ collector: Collector;
21
+ dashboard?: Dashboard;
22
+ /**
23
+ * Constructor
24
+ */
25
+ constructor(configuration?: Partial<Configuration>);
26
+ private collectOsMetrics;
27
+ private collectConnectionMetrics;
28
+ private cleanMetrics;
29
+ handleRequest(request: IncomingMessage, response: ServerResponse): boolean | undefined;
30
+ handleConnection(websocket: WebSocket, request: IncomingMessage): void | undefined;
31
+ onRequest({ request, response }: onRequestPayload): Promise<void>;
32
+ onUpgrade({ request, socket, head }: onUpgradePayload): Promise<void>;
33
+ onConnect(data: onConnectPayload): Promise<void>;
34
+ onDisconnect(data: onDisconnectPayload): Promise<void>;
35
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
36
+ onChange(data: onChangePayload): Promise<void>;
37
+ onConfigure(data: onConfigurePayload): Promise<void>;
38
+ }
@@ -0,0 +1,16 @@
1
+ import { RedisPersistence } from 'y-redis';
2
+ import { Extension, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
+ export interface Configuration {
4
+ }
5
+ export declare class Redis implements Extension {
6
+ configuration: Configuration;
7
+ cluster: boolean;
8
+ persistence: RedisPersistence | undefined;
9
+ /**
10
+ * Constructor
11
+ */
12
+ constructor(configuration?: Partial<Configuration>);
13
+ onLoadDocument(data: onLoadDocumentPayload): Promise<import("yjs").Doc | undefined>;
14
+ onConnect(data: onConnectPayload): Promise<void>;
15
+ onDisconnect(data: onDisconnectPayload): Promise<void>;
16
+ }
@@ -0,0 +1,4 @@
1
+ import { Redis } from './Redis';
2
+ export declare class RedisCluster extends Redis {
3
+ cluster: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Redis';
2
+ export * from './RedisCluster';
@@ -0,0 +1,22 @@
1
+ import { Extension, onLoadDocumentPayload } from '@hocuspocus/server';
2
+ import { LeveldbPersistence } from 'y-leveldb';
3
+ export interface Configuration {
4
+ options: object | undefined;
5
+ path: string;
6
+ }
7
+ export declare class RocksDB implements Extension {
8
+ configuration: Configuration;
9
+ provider: LeveldbPersistence;
10
+ /**
11
+ * Constructor
12
+ */
13
+ constructor(configuration?: Partial<Configuration>);
14
+ /**
15
+ * onLoadDocument hook
16
+ */
17
+ onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
18
+ /**
19
+ * store updates in y-leveldb persistence
20
+ */
21
+ store(documentName: string, update: Uint8Array): Promise<any>;
22
+ }
@@ -0,0 +1,26 @@
1
+ import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
2
+ import sqlite3 from 'sqlite3';
3
+ export interface SQLiteConfiguration extends DatabaseConfiguration {
4
+ /**
5
+ * Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
6
+ * string for an anonymous disk-based database. Anonymous databases are not persisted and
7
+ * when closing the database handle, their contents are lost.
8
+ *
9
+ * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
10
+ */
11
+ database: string;
12
+ /**
13
+ * The database schema to create.
14
+ */
15
+ schema: string;
16
+ }
17
+ export declare class SQLite extends Database {
18
+ db?: sqlite3.Database;
19
+ configuration: SQLiteConfiguration;
20
+ /**
21
+ * Constructor
22
+ */
23
+ constructor(configuration?: Partial<SQLiteConfiguration>);
24
+ onListen(): Promise<void>;
25
+ onConfigure(): Promise<void>;
26
+ }
@@ -0,0 +1 @@
1
+ export * from './SQLite';
@@ -0,0 +1,20 @@
1
+ import { Extension, onConnectPayload } from '@hocuspocus/server';
2
+ export interface Configuration {
3
+ throttle: number | null | false;
4
+ banTime: number;
5
+ }
6
+ export declare class Throttle implements Extension {
7
+ configuration: Configuration;
8
+ connectionsByIp: Map<string, Array<number>>;
9
+ bannedIps: Map<string, number>;
10
+ /**
11
+ * Throttle requests
12
+ * @private
13
+ */
14
+ private throttle;
15
+ /**
16
+ * onConnect hook
17
+ * @param data
18
+ */
19
+ onConnect(data: onConnectPayload): Promise<any>;
20
+ }
@@ -0,0 +1,59 @@
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
+ import { AxiosResponse } from 'axios';
6
+ import Timeout = NodeJS.Timeout;
7
+ export declare enum Events {
8
+ onChange = "change",
9
+ onConnect = "connect",
10
+ onCreate = "create",
11
+ onDisconnect = "disconnect"
12
+ }
13
+ export interface Configuration {
14
+ debounce: number | false | null;
15
+ debounceMaxWait: number;
16
+ secret: string;
17
+ transformer: Transformer | {
18
+ toYdoc: (document: any) => Doc;
19
+ fromYdoc: (document: Doc) => any;
20
+ };
21
+ url: string;
22
+ events: Array<Events>;
23
+ }
24
+ export declare class Webhook implements Extension {
25
+ configuration: Configuration;
26
+ debounced: Map<string, {
27
+ timeout: Timeout;
28
+ start: number;
29
+ }>;
30
+ /**
31
+ * Constructor
32
+ */
33
+ constructor(configuration?: Partial<Configuration>);
34
+ /**
35
+ * Create a signature for the response body
36
+ */
37
+ createSignature(body: string): string;
38
+ /**
39
+ * debounce the given function, using the given identifier
40
+ */
41
+ debounce(id: string, func: Function): void;
42
+ /**
43
+ * Send a request to the given url containing the given data
44
+ */
45
+ sendRequest(event: Events, payload: any): Promise<AxiosResponse<any, any>>;
46
+ /**
47
+ * onChange hook
48
+ */
49
+ onChange(data: onChangePayload): Promise<void>;
50
+ /**
51
+ * onLoadDocument hook
52
+ */
53
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
54
+ /**
55
+ * onConnect hook
56
+ */
57
+ onConnect(data: onConnectPayload): Promise<any>;
58
+ onDisconnect(data: onDisconnectPayload): Promise<void>;
59
+ }
@@ -0,0 +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
+ protected removeAllListeners(): void;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { HocuspocusProvider, HocuspocusProviderOptions } from './HocuspocusProvider';
2
+ export interface HocuspocusCloudProviderOptions extends HocuspocusProviderOptions {
3
+ /**
4
+ * A Hocuspocus Cloud key, get one here: https://hocuspocus.cloud/
5
+ */
6
+ key: string;
7
+ }
8
+ export declare class HocuspocusCloudProvider extends HocuspocusProvider {
9
+ constructor(options: HocuspocusCloudProviderOptions);
10
+ }