notion-mcp-server 2.4.2 → 2.4.3
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/build/operations/files.js +14 -4
- package/package.json +1 -1
|
@@ -17,19 +17,29 @@ const SourceSchema = z.discriminatedUnion("type", [
|
|
|
17
17
|
url: z.url().describe("Public URL to fetch the file bytes from."),
|
|
18
18
|
}),
|
|
19
19
|
]);
|
|
20
|
+
// Returns Uint8Array<ArrayBuffer> — the DOM Blob constructor's BlobPart type
|
|
21
|
+
// rejects Uint8Array<ArrayBufferLike> under newer @types/node (it widens to
|
|
22
|
+
// include SharedArrayBuffer). Allocating fresh guarantees the concrete type.
|
|
20
23
|
async function resolveBytes(source) {
|
|
21
|
-
if (source.type === "base64")
|
|
22
|
-
|
|
24
|
+
if (source.type === "base64") {
|
|
25
|
+
const buf = Buffer.from(source.data, "base64");
|
|
26
|
+
const out = new Uint8Array(buf.byteLength);
|
|
27
|
+
out.set(buf);
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
23
30
|
const res = await fetch(source.url);
|
|
24
31
|
if (!res.ok) {
|
|
25
32
|
throw new Error(`Failed to fetch ${source.url}: ${res.status} ${res.statusText}`);
|
|
26
33
|
}
|
|
27
|
-
return
|
|
34
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
28
35
|
}
|
|
29
36
|
function splitIntoParts(buf, partSize = MAX_PART_BYTES) {
|
|
30
37
|
const parts = [];
|
|
31
38
|
for (let offset = 0; offset < buf.length; offset += partSize) {
|
|
32
|
-
|
|
39
|
+
const end = Math.min(offset + partSize, buf.length);
|
|
40
|
+
const part = new Uint8Array(end - offset);
|
|
41
|
+
part.set(buf.subarray(offset, end));
|
|
42
|
+
parts.push(part);
|
|
33
43
|
}
|
|
34
44
|
return parts;
|
|
35
45
|
}
|