@hocuspocus/provider 3.2.3 → 3.2.4
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-provider.cjs +8 -2
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +8 -2
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-s3/src/S3.d.ts +44 -0
- package/dist/packages/extension-s3/src/index.d.ts +1 -0
- package/dist/packages/extension-webhook/src/index.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +7 -5
- package/dist/playground/backend/src/s3-redis.d.ts +1 -0
- package/dist/playground/backend/src/s3.d.ts +1 -0
- package/dist/tests/extension-s3/fetch.d.ts +1 -0
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +22 -4
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./S3.ts";
|
|
@@ -39,7 +39,7 @@ export declare class Webhook implements Extension {
|
|
|
39
39
|
/**
|
|
40
40
|
* Send a request to the given url containing the given data
|
|
41
41
|
*/
|
|
42
|
-
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
42
|
+
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
43
43
|
/**
|
|
44
44
|
* onChange hook
|
|
45
45
|
*/
|
|
@@ -4,7 +4,7 @@ import * as Y from "yjs";
|
|
|
4
4
|
import EventEmitter from "./EventEmitter.ts";
|
|
5
5
|
import type { CompleteHocuspocusProviderWebsocketConfiguration } from "./HocuspocusProviderWebsocket.ts";
|
|
6
6
|
import { HocuspocusProviderWebsocket } from "./HocuspocusProviderWebsocket.ts";
|
|
7
|
-
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters, onUnsyncedChangesParameters } from "./types.ts";
|
|
7
|
+
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters, onUnsyncedChangesParameters } from "./types.ts";
|
|
8
8
|
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, "name">> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">> | Required<Pick<CompleteHocuspocusProviderConfiguration, "websocketProvider">>);
|
|
9
9
|
export interface CompleteHocuspocusProviderConfiguration {
|
|
10
10
|
/**
|
|
@@ -40,6 +40,7 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
40
40
|
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
|
|
41
41
|
onOpen: (data: onOpenParameters) => void;
|
|
42
42
|
onConnect: () => void;
|
|
43
|
+
onStatus: (data: onStatusParameters) => void;
|
|
43
44
|
onMessage: (data: onMessageParameters) => void;
|
|
44
45
|
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
45
46
|
onSynced: (data: onSyncedParameters) => void;
|
|
@@ -69,10 +70,11 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
69
70
|
boundPageHide: () => void;
|
|
70
71
|
boundOnOpen: (event: Event) => Promise<void>;
|
|
71
72
|
boundOnClose: () => void;
|
|
72
|
-
forwardConnect: (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
forwardConnect: () => this;
|
|
74
|
+
forwardStatus: (e: onStatusParameters) => this;
|
|
75
|
+
forwardClose: (e: onCloseParameters) => this;
|
|
76
|
+
forwardDisconnect: (e: onDisconnectParameters) => this;
|
|
77
|
+
forwardDestroy: () => this;
|
|
76
78
|
setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void;
|
|
77
79
|
get document(): Y.Doc;
|
|
78
80
|
get isAttached(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@hocuspocus/common": "^3.2.
|
|
32
|
+
"@hocuspocus/common": "^3.2.4",
|
|
33
33
|
"@lifeomic/attempt": "^3.0.2",
|
|
34
34
|
"lib0": "^0.2.87",
|
|
35
35
|
"ws": "^8.17.1"
|
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
onOpenParameters,
|
|
26
26
|
onOutgoingMessageParameters,
|
|
27
27
|
onStatelessParameters,
|
|
28
|
+
onStatusParameters,
|
|
28
29
|
onSyncedParameters,
|
|
29
30
|
onUnsyncedChangesParameters,
|
|
30
31
|
} from "./types.ts";
|
|
@@ -79,6 +80,7 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
79
80
|
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
|
|
80
81
|
onOpen: (data: onOpenParameters) => void;
|
|
81
82
|
onConnect: () => void;
|
|
83
|
+
onStatus: (data: onStatusParameters) => void;
|
|
82
84
|
onMessage: (data: onMessageParameters) => void;
|
|
83
85
|
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
84
86
|
onSynced: (data: onSyncedParameters) => void;
|
|
@@ -111,6 +113,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
111
113
|
onMessage: () => null,
|
|
112
114
|
onOutgoingMessage: () => null,
|
|
113
115
|
onSynced: () => null,
|
|
116
|
+
onStatus: () => null,
|
|
114
117
|
onDisconnect: () => null,
|
|
115
118
|
onClose: () => null,
|
|
116
119
|
onDestroy: () => null,
|
|
@@ -204,13 +207,15 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
204
207
|
|
|
205
208
|
boundOnClose = this.onClose.bind(this);
|
|
206
209
|
|
|
207
|
-
forwardConnect = (
|
|
210
|
+
forwardConnect = () => this.emit("connect");
|
|
208
211
|
|
|
209
|
-
|
|
212
|
+
forwardStatus = (e: onStatusParameters) => this.emit("status", e);
|
|
210
213
|
|
|
211
|
-
|
|
214
|
+
forwardClose = (e: onCloseParameters) => this.emit("close", e);
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
forwardDisconnect = (e: onDisconnectParameters) => this.emit("disconnect", e);
|
|
217
|
+
|
|
218
|
+
forwardDestroy = () => this.emit("destroy");
|
|
214
219
|
|
|
215
220
|
public setConfiguration(
|
|
216
221
|
configuration: Partial<HocuspocusProviderConfiguration> = {},
|
|
@@ -489,6 +494,13 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
489
494
|
this.configuration.onConnect,
|
|
490
495
|
);
|
|
491
496
|
this.configuration.websocketProvider.off("connect", this.forwardConnect);
|
|
497
|
+
|
|
498
|
+
this.configuration.websocketProvider.off("status", this.forwardStatus);
|
|
499
|
+
this.configuration.websocketProvider.off(
|
|
500
|
+
"status",
|
|
501
|
+
this.configuration.onStatus,
|
|
502
|
+
);
|
|
503
|
+
|
|
492
504
|
this.configuration.websocketProvider.off("open", this.boundOnOpen);
|
|
493
505
|
this.configuration.websocketProvider.off("close", this.boundOnClose);
|
|
494
506
|
this.configuration.websocketProvider.off(
|
|
@@ -524,6 +536,12 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
524
536
|
);
|
|
525
537
|
this.configuration.websocketProvider.on("connect", this.forwardConnect);
|
|
526
538
|
|
|
539
|
+
this.configuration.websocketProvider.on(
|
|
540
|
+
"status",
|
|
541
|
+
this.configuration.onStatus,
|
|
542
|
+
);
|
|
543
|
+
this.configuration.websocketProvider.on("status", this.forwardStatus);
|
|
544
|
+
|
|
527
545
|
this.configuration.websocketProvider.on("open", this.boundOnOpen);
|
|
528
546
|
|
|
529
547
|
this.configuration.websocketProvider.on("close", this.boundOnClose);
|