@arabold/docs-mcp-server 2.0.4 → 2.1.1
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/README.md +57 -2
- package/db/migrations/012-add-source-content-type.sql +11 -0
- package/dist/assets/main.css +1 -1
- package/dist/assets/main.js +673 -630
- package/dist/assets/main.js.map +1 -1
- package/dist/index.js +7 -18952
- package/dist/index.js.map +1 -1
- package/dist/logger-CLtABTNb.js +99 -0
- package/dist/logger-CLtABTNb.js.map +1 -0
- package/dist/main-ntnRQ8Za.js +18182 -0
- package/dist/main-ntnRQ8Za.js.map +1 -0
- package/dist/utils-CZz1DsHw.js +1063 -0
- package/dist/utils-CZz1DsHw.js.map +1 -0
- package/package.json +48 -45
- package/public/assets/main.css +1 -1
- package/public/assets/main.js +673 -630
- package/public/assets/main.js.map +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
function normalizeEnvValue(value) {
|
|
2
|
+
const trimmed = value.trim();
|
|
3
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
4
|
+
return trimmed.slice(1, -1);
|
|
5
|
+
}
|
|
6
|
+
return trimmed;
|
|
7
|
+
}
|
|
8
|
+
function sanitizeEnvironment(env = process.env) {
|
|
9
|
+
const sanitizedKeys = [];
|
|
10
|
+
for (const [key, value] of Object.entries(env)) {
|
|
11
|
+
if (value === void 0) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const normalized = normalizeEnvValue(value);
|
|
15
|
+
if (normalized !== value) {
|
|
16
|
+
env[key] = normalized;
|
|
17
|
+
sanitizedKeys.push(key);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return sanitizedKeys;
|
|
21
|
+
}
|
|
22
|
+
const LogLevel = {
|
|
23
|
+
ERROR: 0,
|
|
24
|
+
WARN: 1,
|
|
25
|
+
INFO: 2,
|
|
26
|
+
DEBUG: 3
|
|
27
|
+
};
|
|
28
|
+
const LOG_LEVEL_MAP = {
|
|
29
|
+
ERROR: LogLevel.ERROR,
|
|
30
|
+
WARN: LogLevel.WARN,
|
|
31
|
+
INFO: LogLevel.INFO,
|
|
32
|
+
DEBUG: LogLevel.DEBUG
|
|
33
|
+
};
|
|
34
|
+
function suppressLogsInTests() {
|
|
35
|
+
return !!process.env.VITEST_WORKER_ID && process.env.ENABLE_TEST_LOGS !== "1";
|
|
36
|
+
}
|
|
37
|
+
function isInteractiveSession() {
|
|
38
|
+
return !!process.stdout.isTTY && !!process.stderr.isTTY;
|
|
39
|
+
}
|
|
40
|
+
function writeToStderr(message) {
|
|
41
|
+
process.stderr.write(message.endsWith("\n") ? message : `${message}
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
function getLogLevelFromEnv() {
|
|
45
|
+
const envLevel = process.env.LOG_LEVEL?.toUpperCase();
|
|
46
|
+
return envLevel && envLevel in LOG_LEVEL_MAP ? LOG_LEVEL_MAP[envLevel] : null;
|
|
47
|
+
}
|
|
48
|
+
let currentLogLevel = getLogLevelFromEnv() ?? (isInteractiveSession() ? LogLevel.INFO : LogLevel.ERROR);
|
|
49
|
+
function setLogLevel(level) {
|
|
50
|
+
currentLogLevel = level;
|
|
51
|
+
}
|
|
52
|
+
const logger = {
|
|
53
|
+
/**
|
|
54
|
+
* Logs a debug message if the current log level is DEBUG or higher.
|
|
55
|
+
* @param message - The message to log.
|
|
56
|
+
*/
|
|
57
|
+
debug: (message) => {
|
|
58
|
+
if (currentLogLevel >= LogLevel.DEBUG && !suppressLogsInTests()) {
|
|
59
|
+
writeToStderr(message);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Logs an info message if the current log level is INFO or higher.
|
|
64
|
+
* @param message - The message to log.
|
|
65
|
+
*/
|
|
66
|
+
info: (message) => {
|
|
67
|
+
if (currentLogLevel >= LogLevel.INFO && !suppressLogsInTests()) {
|
|
68
|
+
writeToStderr(message);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Logs a warning message if the current log level is WARN or higher.
|
|
73
|
+
* @param message - The message to log.
|
|
74
|
+
*/
|
|
75
|
+
warn: (message) => {
|
|
76
|
+
if (currentLogLevel >= LogLevel.WARN && !suppressLogsInTests()) {
|
|
77
|
+
writeToStderr(message);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Logs an error message if the current log level is ERROR or higher.
|
|
82
|
+
* Suppressed during test runs unless `ENABLE_TEST_LOGS=1` is set.
|
|
83
|
+
* @param message - The message to log.
|
|
84
|
+
*/
|
|
85
|
+
error: (message) => {
|
|
86
|
+
if (currentLogLevel >= LogLevel.ERROR && !suppressLogsInTests()) {
|
|
87
|
+
writeToStderr(message);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
LogLevel as L,
|
|
93
|
+
setLogLevel as a,
|
|
94
|
+
getLogLevelFromEnv as g,
|
|
95
|
+
logger as l,
|
|
96
|
+
normalizeEnvValue as n,
|
|
97
|
+
sanitizeEnvironment as s
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=logger-CLtABTNb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-CLtABTNb.js","sources":["../src/utils/env.ts","../src/utils/logger.ts"],"sourcesContent":["/**\n * Normalize a single environment variable value by trimming surrounding whitespace\n * and removing matching outer quotes. Internal quotes are preserved.\n */\nexport function normalizeEnvValue(value: string): string {\n const trimmed = value.trim();\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * Normalize all string values in process.env in place.\n * Returns the names of environment variables that changed.\n */\nexport function sanitizeEnvironment(env: NodeJS.ProcessEnv = process.env): string[] {\n const sanitizedKeys: string[] = [];\n\n for (const [key, value] of Object.entries(env)) {\n if (value === undefined) {\n continue;\n }\n\n const normalized = normalizeEnvValue(value);\n if (normalized !== value) {\n env[key] = normalized;\n sanitizedKeys.push(key);\n }\n }\n\n return sanitizedKeys;\n}\n","/**\n * Defines the available log levels.\n */\nexport const LogLevel = {\n ERROR: 0,\n WARN: 1,\n INFO: 2,\n DEBUG: 3,\n} as const;\n\nexport type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];\n\n/**\n * Maps string log level names to their numeric values.\n */\nconst LOG_LEVEL_MAP: Record<string, LogLevel> = {\n ERROR: LogLevel.ERROR,\n WARN: LogLevel.WARN,\n INFO: LogLevel.INFO,\n DEBUG: LogLevel.DEBUG,\n};\n\nfunction suppressLogsInTests(): boolean {\n return !!process.env.VITEST_WORKER_ID && process.env.ENABLE_TEST_LOGS !== \"1\";\n}\n\nfunction isInteractiveSession(): boolean {\n return !!process.stdout.isTTY && !!process.stderr.isTTY;\n}\n\nfunction writeToStderr(message: string): void {\n process.stderr.write(message.endsWith(\"\\n\") ? message : `${message}\\n`);\n}\n\n/**\n * Gets the log level from the `LOG_LEVEL` environment variable.\n * Returns the matching {@link LogLevel} value, or `null` if the variable\n * is unset or contains an unrecognised value.\n */\nexport function getLogLevelFromEnv(): LogLevel | null {\n const envLevel = process.env.LOG_LEVEL?.toUpperCase();\n return envLevel && envLevel in LOG_LEVEL_MAP ? LOG_LEVEL_MAP[envLevel] : null;\n}\n\nlet currentLogLevel: LogLevel =\n getLogLevelFromEnv() ?? (isInteractiveSession() ? LogLevel.INFO : LogLevel.ERROR);\n\n/**\n * Sets the current logging level for the application.\n */\nexport function setLogLevel(level: LogLevel): void {\n currentLogLevel = level;\n}\n\n/**\n * Returns the current logging level for the application.\n */\nexport function getLogLevel(): LogLevel {\n return currentLogLevel;\n}\n\n/**\n * Provides logging functionalities with level control.\n */\nexport const logger = {\n /**\n * Logs a debug message if the current log level is DEBUG or higher.\n * @param message - The message to log.\n */\n debug: (message: string) => {\n if (currentLogLevel >= LogLevel.DEBUG && !suppressLogsInTests()) {\n writeToStderr(message);\n }\n },\n /**\n * Logs an info message if the current log level is INFO or higher.\n * @param message - The message to log.\n */\n info: (message: string) => {\n if (currentLogLevel >= LogLevel.INFO && !suppressLogsInTests()) {\n writeToStderr(message);\n }\n },\n /**\n * Logs a warning message if the current log level is WARN or higher.\n * @param message - The message to log.\n */\n warn: (message: string) => {\n if (currentLogLevel >= LogLevel.WARN && !suppressLogsInTests()) {\n writeToStderr(message);\n }\n },\n /**\n * Logs an error message if the current log level is ERROR or higher.\n * Suppressed during test runs unless `ENABLE_TEST_LOGS=1` is set.\n * @param message - The message to log.\n */\n error: (message: string) => {\n if (currentLogLevel >= LogLevel.ERROR && !suppressLogsInTests()) {\n writeToStderr(message);\n }\n },\n};\n"],"names":[],"mappings":"AAIO,SAAS,kBAAkB,OAAuB;AACvD,QAAM,UAAU,MAAM,KAAA;AACtB,MACG,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,KAC/C,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GAChD;AACA,WAAO,QAAQ,MAAM,GAAG,EAAE;AAAA,EAC5B;AACA,SAAO;AACT;AAMO,SAAS,oBAAoB,MAAyB,QAAQ,KAAe;AAClF,QAAM,gBAA0B,CAAA;AAEhC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,QAAI,UAAU,QAAW;AACvB;AAAA,IACF;AAEA,UAAM,aAAa,kBAAkB,KAAK;AAC1C,QAAI,eAAe,OAAO;AACxB,UAAI,GAAG,IAAI;AACX,oBAAc,KAAK,GAAG;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;AChCO,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAOA,MAAM,gBAA0C;AAAA,EAC9C,OAAO,SAAS;AAAA,EAChB,MAAM,SAAS;AAAA,E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