@notionhq/notion-mcp-server 1.7.0 → 1.8.0
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/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import OpenAPIClientAxios from 'openapi-client-axios'
|
|
|
3
3
|
import type { AxiosInstance } from 'axios'
|
|
4
4
|
import FormData from 'form-data'
|
|
5
5
|
import fs from 'fs'
|
|
6
|
+
import { Headers } from './polyfill-headers'
|
|
6
7
|
import { isFileUploadParameter } from '../openapi/file-upload'
|
|
7
8
|
|
|
8
9
|
export type HttpClientConfig = {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The Headers class was supported in Node.js starting with version 18, which was released on April 19, 2022.
|
|
3
|
+
* We need to have a polyfill ready to work for old Node versions.
|
|
4
|
+
* See more at https://github.com/makenotion/notion-mcp-server/issues/32
|
|
5
|
+
* */
|
|
6
|
+
class PolyfillHeaders {
|
|
7
|
+
private headers: Map<string, string[]> = new Map();
|
|
8
|
+
|
|
9
|
+
constructor(init?: Record<string, string>) {
|
|
10
|
+
if (init) {
|
|
11
|
+
Object.entries(init).forEach(([key, value]) => {
|
|
12
|
+
this.append(key, value);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public append(name: string, value: string): void {
|
|
18
|
+
const key = name.toLowerCase();
|
|
19
|
+
|
|
20
|
+
if (!this.headers.has(key)) {
|
|
21
|
+
this.headers.set(key, []);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.headers.get(key)!.push(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public get(name: string): string | null {
|
|
28
|
+
const key = name.toLowerCase();
|
|
29
|
+
|
|
30
|
+
if (!this.headers.has(key)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this.headers.get(key)!.join(', ');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const GlobalHeaders = typeof global !== 'undefined' && 'Headers' in global
|
|
39
|
+
? (global as any).Headers
|
|
40
|
+
: undefined;
|
|
41
|
+
|
|
42
|
+
export const Headers = (GlobalHeaders || PolyfillHeaders);
|