@hocuspocus/extension-s3 3.2.4 → 3.2.5
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-s3.cjs +5 -3
- package/dist/hocuspocus-s3.cjs.map +1 -1
- package/dist/hocuspocus-s3.esm.js +5 -3
- package/dist/hocuspocus-s3.esm.js.map +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +2 -2
- package/dist/packages/extension-webhook/src/index.d.ts +2 -2
- package/dist/packages/server/src/Document.d.ts +2 -0
- package/package.json +2 -2
- package/src/S3.ts +38 -19
- package/src/index.ts +1 -1
package/dist/hocuspocus-s3.cjs
CHANGED
|
@@ -44,7 +44,8 @@ class S3 extends extensionDatabase.Database {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
catch (error) {
|
|
47
|
-
if (error.name ===
|
|
47
|
+
if (error.name === "NoSuchKey" ||
|
|
48
|
+
((_a = error.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) === 404) {
|
|
48
49
|
// Document doesn't exist yet, return null
|
|
49
50
|
return null;
|
|
50
51
|
}
|
|
@@ -106,7 +107,7 @@ class S3 extends extensionDatabase.Database {
|
|
|
106
107
|
// 404 is expected for the test key, any other error indicates connection issues
|
|
107
108
|
if (((_a = error.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) !== 404) {
|
|
108
109
|
// Don't show credential errors as connection failures in development
|
|
109
|
-
if ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes(
|
|
110
|
+
if ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes("Could not load credentials")) {
|
|
110
111
|
console.warn(` ${kleur.yellow("S3 warning:")} ${error.message}`);
|
|
111
112
|
console.warn(` ${kleur.yellow("Note:")} Ensure AWS credentials are properly configured for production use`);
|
|
112
113
|
}
|
|
@@ -117,7 +118,8 @@ class S3 extends extensionDatabase.Database {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
async onListen() {
|
|
120
|
-
const endpoint = this.configuration.endpoint ||
|
|
121
|
+
const endpoint = this.configuration.endpoint ||
|
|
122
|
+
`https://s3.${this.configuration.region}.amazonaws.com`;
|
|
121
123
|
console.log(` ${kleur.green("S3 extension configured:")} bucket=${this.configuration.bucket}, endpoint=${endpoint}`);
|
|
122
124
|
if (this.configuration.prefix) {
|
|
123
125
|
console.log(` ${kleur.blue("S3 key prefix:")} ${this.configuration.prefix}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-s3.cjs","sources":["../src/S3.ts"],"sourcesContent":[null],"names":["Database","GetObjectCommand","PutObjectCommand","S3Client","HeadObjectCommand"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"hocuspocus-s3.cjs","sources":["../src/S3.ts"],"sourcesContent":[null],"names":["Database","GetObjectCommand","PutObjectCommand","S3Client","HeadObjectCommand"],"mappings":";;;;;;AA4CM,MAAO,EAAG,SAAQA,0BAAQ,CAAA;AAwE/B,IAAA,WAAA,CAAY,aAAuC,EAAA;QAClD,KAAK,CAAC,EAAE,CAAC;AAtEV,QAAA,IAAA,CAAA,aAAa,GAAoB;AAChC,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,MAAM,EAAE,EAAE;AACV,YAAA,MAAM,EAAE,uBAAuB;AAC/B,YAAA,cAAc,EAAE,KAAK;AACrB,YAAA,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAI;;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;AAE3C,gBAAA,IAAI;AACH,oBAAA,MAAM,OAAO,GAAG,IAAIC,yBAAgB,CAAC;AACpC,wBAAA,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;AACjC,wBAAA,GAAG,EAAE,GAAG;AACR,qBAAA,CAAC;oBAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAS,CAAC,IAAI,CAAC,OAAO,CAAC;AAEnD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V,KAAK,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA,CAAA,EAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAA,CAAE,CAChE;;;AAGH;;;;"}
|
|
@@ -42,7 +42,8 @@ class S3 extends Database {
|
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
catch (error) {
|
|
45
|
-
if (error.name ===
|
|
45
|
+
if (error.name === "NoSuchKey" ||
|
|
46
|
+
((_a = error.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) === 404) {
|
|
46
47
|
// Document doesn't exist yet, return null
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
@@ -104,7 +105,7 @@ class S3 extends Database {
|
|
|
104
105
|
// 404 is expected for the test key, any other error indicates connection issues
|
|
105
106
|
if (((_a = error.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) !== 404) {
|
|
106
107
|
// Don't show credential errors as connection failures in development
|
|
107
|
-
if ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes(
|
|
108
|
+
if ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes("Could not load credentials")) {
|
|
108
109
|
console.warn(` ${kleur.yellow("S3 warning:")} ${error.message}`);
|
|
109
110
|
console.warn(` ${kleur.yellow("Note:")} Ensure AWS credentials are properly configured for production use`);
|
|
110
111
|
}
|
|
@@ -115,7 +116,8 @@ class S3 extends Database {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
async onListen() {
|
|
118
|
-
const endpoint = this.configuration.endpoint ||
|
|
119
|
+
const endpoint = this.configuration.endpoint ||
|
|
120
|
+
`https://s3.${this.configuration.region}.amazonaws.com`;
|
|
119
121
|
console.log(` ${kleur.green("S3 extension configured:")} bucket=${this.configuration.bucket}, endpoint=${endpoint}`);
|
|
120
122
|
if (this.configuration.prefix) {
|
|
121
123
|
console.log(` ${kleur.blue("S3 key prefix:")} ${this.configuration.prefix}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-s3.esm.js","sources":["../src/S3.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"hocuspocus-s3.esm.js","sources":["../src/S3.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA4CM,MAAO,EAAG,SAAQ,QAAQ,CAAA;AAwE/B,IAAA,WAAA,CAAY,aAAuC,EAAA;QAClD,KAAK,CAAC,EAAE,CAAC;AAtEV,QAAA,IAAA,CAAA,aAAa,GAAoB;AAChC,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,MAAM,EAAE,EAAE;AACV,YAAA,MAAM,EAAE,uBAAuB;AAC/B,YAAA,cAAc,EAAE,KAAK;AACrB,YAAA,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,KAAI;;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;AAE3C,gBAAA,IAAI;AACH,oBAAA,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;AACpC,wBAAA,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;AACjC,wBAAA,GAAG,EAAE,GAAG;AACR,qBAAA,CAAC;oBAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAS,CAAC,IAAI,CAAC,OAAO,CAAC;AAEnD,oBAAA,IAAI,QAAQ,CAAC,IAAI,EAAE;;wBAElB,MAAM,MAAM,GAAiB,EAAE;wBAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,SAAS,EAAE;wBAE/D,OAAO,IAAI,EAAE;4BACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE;AAC3C,4BAAA,IAAI,IAAI;gCAAE;AACV,4BAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;;;wBAInB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAChC,CAAC,GAAG,EAAE,KAAK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,EAAE;AAC1D,oBAAA,OAAO,CAAC,IAAI,CAAC,CAAK,EAAA,EAAA,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;AACjE,oBAAA,OAAO,CAAC,IAAI,CACX,CAAA,EAAA,EAAK,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAoE,kEAAA,CAAA,CAC9F;;qBACK;AACN,oBAAA,OAAO,CAAC,KAAK,CACZ,CAAK,EAAA,EAAA,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,KAAK,CAAC,OAAO,CAAA,CAAE,CAC1D;;;;;AAML,IAAA,MAAM,QAAQ,GAAA;AACb,QAAA,MAAM,QAAQ,GACb,IAAI,CAAC,aAAa,CAAC,QAAQ;AAC3B,YAAA,CAAA,WAAA,EAAc,IAAI,CAAC,aAAa,CAAC,MAAM,gBAAgB;QACxD,OAAO,CAAC,GAAG,CACV,CAAA,EAAA,EAAK,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAAC,WAAW,IAAI,CAAC,aAAa,CAAC,MAAM,cAAc,QAAQ,CAAA,CAAE,CACxG;AAED,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;AAC9B,YAAA,OAAO,CAAC,GAAG,CACV,KAAK,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA,CAAA,EAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAA,CAAE,CAChE;;;AAGH;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Extension, Hocuspocus, afterLoadDocumentPayload, afterStoreDocumentPayload, beforeBroadcastStatelessPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, onDisconnectPayload, onStoreDocumentPayload } from "@hocuspocus/server";
|
|
2
|
-
import {
|
|
2
|
+
import { type ExecutionResult, type Lock, Redlock } from "@sesamecare-oss/redlock";
|
|
3
3
|
import type { Cluster, ClusterNode, ClusterOptions, RedisOptions } from "ioredis";
|
|
4
4
|
import RedisClient from "ioredis";
|
|
5
5
|
export type RedisInstance = RedisClient | Cluster;
|
|
@@ -101,7 +101,7 @@ export declare class Redis implements Extension {
|
|
|
101
101
|
/**
|
|
102
102
|
* Release the Redis lock, so other instances can store documents.
|
|
103
103
|
*/
|
|
104
|
-
afterStoreDocument({ documentName, socketId }: afterStoreDocumentPayload): Promise<void>;
|
|
104
|
+
afterStoreDocument({ documentName, socketId, }: afterStoreDocumentPayload): Promise<void>;
|
|
105
105
|
/**
|
|
106
106
|
* Handle awareness update messages received directly by this Hocuspocus instance.
|
|
107
107
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConnectPayload,
|
|
2
|
-
import type { Doc } from "yjs";
|
|
1
|
+
import type { Extension, onChangePayload, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload } from "@hocuspocus/server";
|
|
3
2
|
import type { Transformer } from "@hocuspocus/transformer";
|
|
3
|
+
import type { Doc } from "yjs";
|
|
4
4
|
export declare enum Events {
|
|
5
5
|
onChange = "change",
|
|
6
6
|
onConnect = "connect",
|
|
@@ -2,6 +2,7 @@ import type WebSocket from "ws";
|
|
|
2
2
|
import { Awareness } from "y-protocols/awareness";
|
|
3
3
|
import { Doc } from "yjs";
|
|
4
4
|
import type Connection from "./Connection.ts";
|
|
5
|
+
import { Mutex } from "async-mutex";
|
|
5
6
|
export declare class Document extends Doc {
|
|
6
7
|
awareness: Awareness;
|
|
7
8
|
callbacks: {
|
|
@@ -16,6 +17,7 @@ export declare class Document extends Doc {
|
|
|
16
17
|
name: string;
|
|
17
18
|
isLoading: boolean;
|
|
18
19
|
isDestroyed: boolean;
|
|
20
|
+
saveMutex: Mutex;
|
|
19
21
|
/**
|
|
20
22
|
* Constructor.
|
|
21
23
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-s3",
|
|
3
3
|
"description": "a S3-compatible persistence driver for Hocuspocus",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.5",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hocuspocus",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@aws-sdk/client-s3": "^3.0.0",
|
|
33
|
-
"@hocuspocus/extension-database": "^3.2.
|
|
33
|
+
"@hocuspocus/extension-database": "^3.2.5",
|
|
34
34
|
"kleur": "^4.1.4"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
package/src/S3.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { DatabaseConfiguration } from "@hocuspocus/extension-database";
|
|
2
2
|
import { Database } from "@hocuspocus/extension-database";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
S3Client,
|
|
5
|
+
GetObjectCommand,
|
|
6
|
+
PutObjectCommand,
|
|
7
|
+
HeadObjectCommand,
|
|
8
|
+
} from "@aws-sdk/client-s3";
|
|
4
9
|
import kleur from "kleur";
|
|
5
10
|
|
|
6
11
|
export interface S3Configuration extends DatabaseConfiguration {
|
|
@@ -47,7 +52,7 @@ export class S3 extends Database {
|
|
|
47
52
|
forcePathStyle: false,
|
|
48
53
|
fetch: async ({ documentName }) => {
|
|
49
54
|
const key = this.getObjectKey(documentName);
|
|
50
|
-
|
|
55
|
+
|
|
51
56
|
try {
|
|
52
57
|
const command = new GetObjectCommand({
|
|
53
58
|
Bucket: this.configuration.bucket,
|
|
@@ -55,34 +60,40 @@ export class S3 extends Database {
|
|
|
55
60
|
});
|
|
56
61
|
|
|
57
62
|
const response = await this.s3Client!.send(command);
|
|
58
|
-
|
|
63
|
+
|
|
59
64
|
if (response.Body) {
|
|
60
65
|
// Convert stream to Uint8Array
|
|
61
66
|
const chunks: Uint8Array[] = [];
|
|
62
67
|
const reader = response.Body.transformToWebStream().getReader();
|
|
63
|
-
|
|
68
|
+
|
|
64
69
|
while (true) {
|
|
65
70
|
const { done, value } = await reader.read();
|
|
66
71
|
if (done) break;
|
|
67
72
|
chunks.push(value);
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
|
|
70
75
|
// Combine all chunks into a single Uint8Array
|
|
71
|
-
const totalLength = chunks.reduce(
|
|
76
|
+
const totalLength = chunks.reduce(
|
|
77
|
+
(acc, chunk) => acc + chunk.length,
|
|
78
|
+
0,
|
|
79
|
+
);
|
|
72
80
|
const result = new Uint8Array(totalLength);
|
|
73
81
|
let offset = 0;
|
|
74
|
-
|
|
82
|
+
|
|
75
83
|
for (const chunk of chunks) {
|
|
76
84
|
result.set(chunk, offset);
|
|
77
85
|
offset += chunk.length;
|
|
78
86
|
}
|
|
79
|
-
|
|
87
|
+
|
|
80
88
|
return result;
|
|
81
89
|
}
|
|
82
|
-
|
|
90
|
+
|
|
83
91
|
return null;
|
|
84
92
|
} catch (error: any) {
|
|
85
|
-
if (
|
|
93
|
+
if (
|
|
94
|
+
error.name === "NoSuchKey" ||
|
|
95
|
+
error.$metadata?.httpStatusCode === 404
|
|
96
|
+
) {
|
|
86
97
|
// Document doesn't exist yet, return null
|
|
87
98
|
return null;
|
|
88
99
|
}
|
|
@@ -91,7 +102,7 @@ export class S3 extends Database {
|
|
|
91
102
|
},
|
|
92
103
|
store: async ({ documentName, state }) => {
|
|
93
104
|
const key = this.getObjectKey(documentName);
|
|
94
|
-
|
|
105
|
+
|
|
95
106
|
const command = new PutObjectCommand({
|
|
96
107
|
Bucket: this.configuration.bucket,
|
|
97
108
|
Key: key,
|
|
@@ -149,30 +160,38 @@ export class S3 extends Database {
|
|
|
149
160
|
Bucket: this.configuration.bucket,
|
|
150
161
|
Key: "test-connection", // This will likely return 404, but that's fine
|
|
151
162
|
});
|
|
152
|
-
|
|
163
|
+
|
|
153
164
|
await this.s3Client.send(command);
|
|
154
165
|
} catch (error: any) {
|
|
155
166
|
// 404 is expected for the test key, any other error indicates connection issues
|
|
156
167
|
if (error.$metadata?.httpStatusCode !== 404) {
|
|
157
168
|
// Don't show credential errors as connection failures in development
|
|
158
|
-
if (error.message?.includes(
|
|
169
|
+
if (error.message?.includes("Could not load credentials")) {
|
|
159
170
|
console.warn(` ${kleur.yellow("S3 warning:")} ${error.message}`);
|
|
160
|
-
console.warn(
|
|
171
|
+
console.warn(
|
|
172
|
+
` ${kleur.yellow("Note:")} Ensure AWS credentials are properly configured for production use`,
|
|
173
|
+
);
|
|
161
174
|
} else {
|
|
162
|
-
console.error(
|
|
175
|
+
console.error(
|
|
176
|
+
` ${kleur.red("S3 connection failed:")} ${error.message}`,
|
|
177
|
+
);
|
|
163
178
|
}
|
|
164
179
|
}
|
|
165
180
|
}
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
async onListen() {
|
|
169
|
-
const endpoint =
|
|
184
|
+
const endpoint =
|
|
185
|
+
this.configuration.endpoint ||
|
|
186
|
+
`https://s3.${this.configuration.region}.amazonaws.com`;
|
|
170
187
|
console.log(
|
|
171
188
|
` ${kleur.green("S3 extension configured:")} bucket=${this.configuration.bucket}, endpoint=${endpoint}`,
|
|
172
189
|
);
|
|
173
|
-
|
|
190
|
+
|
|
174
191
|
if (this.configuration.prefix) {
|
|
175
|
-
console.log(
|
|
192
|
+
console.log(
|
|
193
|
+
` ${kleur.blue("S3 key prefix:")} ${this.configuration.prefix}`,
|
|
194
|
+
);
|
|
176
195
|
}
|
|
177
196
|
}
|
|
178
|
-
}
|
|
197
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./S3.ts";
|
|
1
|
+
export * from "./S3.ts";
|