@hocuspocus/extension-database
Advanced tools
Comparing version 1.0.0-alpha.12 to 1.0.0-alpha.13
export * from './Redis'; | ||
export * from './RedisCluster'; |
@@ -1,16 +0,94 @@ | ||
import { RedisPersistence } from 'y-redis'; | ||
import { Extension, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server'; | ||
import RedisClient from 'ioredis'; | ||
import Redlock from 'redlock'; | ||
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, Debugger, onConfigurePayload } from '@hocuspocus/server'; | ||
export interface Configuration { | ||
/** | ||
* Redis port | ||
*/ | ||
port: number; | ||
/** | ||
* Redis host | ||
*/ | ||
host: string; | ||
/** | ||
* Options passed directly to Redis constructor | ||
* | ||
* https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options | ||
*/ | ||
options?: RedisClient.RedisOptions; | ||
/** | ||
* An unique instance name, required to filter messages in Redis. | ||
* If none is provided an unique id is generated. | ||
*/ | ||
identifier: string; | ||
/** | ||
* Namespace for Redis keys, if none is provided 'hocuspocus' is used | ||
*/ | ||
prefix: string; | ||
/** | ||
* The maximum time for the Redis lock in ms (in case it can’t be released). | ||
*/ | ||
lockTimeout: number; | ||
} | ||
export declare class Redis implements Extension { | ||
/** | ||
* Make sure to give that extension a higher priority, so | ||
* the `onStoreDocument` hook is able to intercept the chain, | ||
* before documents are stored to the database. | ||
*/ | ||
priority: number; | ||
configuration: Configuration; | ||
cluster: boolean; | ||
persistence: RedisPersistence | undefined; | ||
pub: RedisClient.Redis; | ||
sub: RedisClient.Redis; | ||
documents: Map<string, Document>; | ||
redlock: Redlock; | ||
locks: Map<string, Redlock.Lock>; | ||
logger: Debugger; | ||
constructor(configuration: Partial<Configuration>); | ||
onConfigure({ instance }: onConfigurePayload): Promise<void>; | ||
onListen(): Promise<void>; | ||
private getKey; | ||
private pubKey; | ||
private subKey; | ||
private lockKey; | ||
/** | ||
* Constructor | ||
* Once a document is laoded, subscribe to the channel in Redis. | ||
*/ | ||
constructor(configuration?: Partial<Configuration>); | ||
onLoadDocument(data: onLoadDocumentPayload): Promise<import("yjs").Doc | undefined>; | ||
onConnect(data: onConnectPayload): Promise<void>; | ||
onDisconnect(data: onDisconnectPayload): Promise<void>; | ||
afterLoadDocument({ documentName, document }: afterLoadDocumentPayload): Promise<unknown>; | ||
/** | ||
* Publish the first sync step through Redis. | ||
*/ | ||
private publishFirstSyncStep; | ||
/** | ||
* Let’s ask Redis who is connected already. | ||
*/ | ||
private requestAwarenessFromOtherInstances; | ||
/** | ||
* Before the document is stored, make sure to set a lock in Redis. | ||
* That’s meant to avoid conflicts with other instances trying to store the document. | ||
*/ | ||
onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<unknown>; | ||
/** | ||
* Release the Redis lock, so other instances can store documents. | ||
*/ | ||
afterStoreDocument({ documentName }: afterStoreDocumentPayload): Promise<void>; | ||
/** | ||
* Handle awareness update messages received directly by this Hocuspocus instance. | ||
*/ | ||
onAwarenessUpdate({ documentName, awareness }: onAwarenessUpdatePayload): Promise<number>; | ||
/** | ||
* Handle incoming messages published on all subscribed document channels. | ||
* Note that this will also include messages from ourselves as it is not possible | ||
* in Redis to filter these. | ||
*/ | ||
private handleIncomingMessage; | ||
/** | ||
* Make sure to *not* listen for further changes, when there’s | ||
* noone connected anymore. | ||
*/ | ||
onDisconnect: ({ documentName, clientsCount }: onDisconnectPayload) => Promise<void>; | ||
/** | ||
* Kill the Redlock connection immediately. | ||
*/ | ||
onDestroy(): Promise<void>; | ||
} |
@@ -1,9 +0,8 @@ | ||
export * from './Hocuspocus'; | ||
export * from './Connection'; | ||
export * from './Debugger'; | ||
export * from './Document'; | ||
export * from './Hocuspocus'; | ||
export * from './IncomingMessage'; | ||
export * from './MessageReceiver'; | ||
export * from './OutgoingMessage'; | ||
export * from './types'; | ||
export * from './MessageReceiver'; | ||
export * from './Document'; | ||
export * from './Connection'; |
{ | ||
"name": "@hocuspocus/extension-database", | ||
"description": "a generic Hocuspocus persistence driver for the database", | ||
"version": "1.0.0-alpha.12", | ||
"version": "1.0.0-alpha.13", | ||
"homepage": "https://hocuspocus.dev", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@hocuspocus/server": "^1.0.0-alpha.98", | ||
"@hocuspocus/server": "^1.0.0-alpha.99", | ||
"yjs": "^13.5.29" | ||
@@ -36,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "1fc2a6cff1b5fd626b8dd7c486755111965da20d" | ||
"gitHead": "e26a5eeaa9278b9587d4b475cec53bf14bc569b9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63799
1674
117