campus-security-mcp 1.0.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/dist/client/apiClient.js +101 -0
- package/dist/data/mockData.js +96 -0
- package/dist/data/types.js +2 -0
- package/dist/index.js +14 -0
- package/dist/mcp/index.js +39 -0
- package/dist/server.js +10 -0
- package/dist/tools/areaQuery.js +35 -0
- package/dist/tools/exampleTool.js +42 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/streetQuery.js +35 -0
- package/dist/tools/warningQuery.js +122 -0
- package/dist/utils/dateUtils.js +68 -0
- package/package.json +26 -0
- package/src/client/apiClient.ts +115 -0
- package/src/data/mockData.ts +109 -0
- package/src/data/types.ts +70 -0
- package/src/index.ts +10 -0
- package/src/mcp/index.ts +72 -0
- package/src/server.ts +10 -0
- package/src/tools/areaQuery.ts +35 -0
- package/src/tools/exampleTool.ts +42 -0
- package/src/tools/index.ts +6 -0
- package/src/tools/streetQuery.ts +35 -0
- package/src/tools/warningQuery.ts +138 -0
- package/src/utils/dateUtils.ts +72 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// 生成近7天的日期数组
|
|
2
|
+
// 返回格式: ['2026-04-06', '2026-04-07', ..., '2026-04-12']
|
|
3
|
+
export function getLast7Days(): string[] {
|
|
4
|
+
const days: string[] = [];
|
|
5
|
+
const today = new Date();
|
|
6
|
+
|
|
7
|
+
for (let i = 6; i >= 0; i--) {
|
|
8
|
+
const date = new Date(today);
|
|
9
|
+
date.setDate(today.getDate() - i);
|
|
10
|
+
days.push(formatDate(date));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return days;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 格式化日期为 YYYY-MM-DD 格式
|
|
17
|
+
export function formatDate(date: Date): string {
|
|
18
|
+
const year = date.getFullYear();
|
|
19
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
20
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
21
|
+
return `${year}-${month}-${day}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 格式化日期时间为 ISO 格式
|
|
25
|
+
export function formatDateTime(date: Date): string {
|
|
26
|
+
return date.toISOString();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 解析日期字符串为 Date 对象
|
|
30
|
+
export function parseDate(dateString: string): Date {
|
|
31
|
+
return new Date(dateString);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 检查日期是否在指定范围内
|
|
35
|
+
export function isDateInRange(date: Date, startDate?: string, endDate?: string): boolean {
|
|
36
|
+
if (!startDate && !endDate) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (startDate) {
|
|
41
|
+
const start = parseDate(startDate);
|
|
42
|
+
if (date < start) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (endDate) {
|
|
48
|
+
const end = parseDate(endDate);
|
|
49
|
+
// 设置为当天的结束时间
|
|
50
|
+
end.setHours(23, 59, 59, 999);
|
|
51
|
+
if (date > end) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 获取指定日期范围内的所有日期
|
|
60
|
+
export function getDateRange(startDate: string, endDate: string): string[] {
|
|
61
|
+
const start = parseDate(startDate);
|
|
62
|
+
const end = parseDate(endDate);
|
|
63
|
+
const dates: string[] = [];
|
|
64
|
+
|
|
65
|
+
const current = new Date(start);
|
|
66
|
+
while (current <= end) {
|
|
67
|
+
dates.push(formatDate(current));
|
|
68
|
+
current.setDate(current.getDate() + 1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return dates;
|
|
72
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2018",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"resolveJsonModule": true
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"src/**/*"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules"
|
|
19
|
+
]
|
|
20
|
+
}
|