mcp-user-system 1.0.4 → 2.0.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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # mcp-user-system
2
2
 
3
- [MCP](https://modelcontextprotocol.io) server for token-user-system — wallet operations via Model Context Protocol.
3
+ [MCP](https://modelcontextprotocol.io) server for token-user-system — Console 前台全量查询接口 via Model Context Protocol.
4
4
 
5
- Supports: balance, consumption trend, transaction records, coupons, corporate transfer info.
5
+ Provides AI agents with authenticated access to the Console (前台) query APIs, covering user info, dashboard statistics, wallet, team management, token usage, invoices, and miscellaneous lookups.
6
+
7
+ Supports: user profiles, dashboard stats & trends, wallet overview, team & member management, token consumption, invoice queries, and more.
6
8
 
7
9
  ## Prerequisites
8
10
 
@@ -11,7 +13,13 @@ Supports: balance, consumption trend, transaction records, coupons, corporate tr
11
13
 
12
14
  ## Installation
13
15
 
14
- ### 1. Clone & Build
16
+ ### 1. Install globally
17
+
18
+ ```bash
19
+ npm install -g mcp-user-system
20
+ ```
21
+
22
+ Or clone & build manually:
15
23
 
16
24
  ```bash
17
25
  git clone https://github.com/shenda-ai/mcp-user-system.git
@@ -24,16 +32,18 @@ npm run build
24
32
 
25
33
  ```bash
26
34
  export TUS_BASE_URL=https://api.example.com
27
- export TUS_ACCESS_TOKEN=eyJhbGciOiJIUzUxMiJ9...
35
+ export TUS_ACCESS_TOKEN=your-jwt-access-token
28
36
  ```
29
37
 
30
38
  Or create a `.env` file (add to `.gitignore`):
31
39
 
32
40
  ```bash
33
41
  TUS_BASE_URL=https://api.example.com
34
- TUS_ACCESS_TOKEN=eyJhbGciOiJIUzUxMiJ9...
42
+ TUS_ACCESS_TOKEN=your-jwt-access-token
35
43
  ```
36
44
 
45
+ > **Access Token** is a JWT Bearer Token obtained after user login. Include it as `Authorization: Bearer <token>` in upstream requests.
46
+
37
47
  ### 3. Test Run
38
48
 
39
49
  ```bash
@@ -54,7 +64,7 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
54
64
  "args": ["/path/to/mcp-user-system/dist/index.js"],
55
65
  "env": {
56
66
  "TUS_BASE_URL": "https://api.example.com",
57
- "TUS_ACCESS_TOKEN": "eyJhbGciOiJIUzUxMiJ9..."
67
+ "TUS_ACCESS_TOKEN": "your-jwt-access-token"
58
68
  }
59
69
  }
60
70
  }
@@ -73,7 +83,7 @@ Add to settings (Cursor: `~/.cursor/mcp.json`, VS Code: settings.json):
73
83
  "args": ["/path/to/mcp-user-system/dist/index.js"],
74
84
  "env": {
75
85
  "TUS_BASE_URL": "https://api.example.com",
76
- "TUS_ACCESS_TOKEN": "eyJhbGciOiJIUzUxMiJ9..."
86
+ "TUS_ACCESS_TOKEN": "your-jwt-access-token"
77
87
  }
78
88
  }
79
89
  }
@@ -92,7 +102,7 @@ Add to `~/.claude/mcp.json`:
92
102
  "args": ["/path/to/mcp-user-system/dist/index.js"],
93
103
  "env": {
94
104
  "TUS_BASE_URL": "https://api.example.com",
95
- "TUS_ACCESS_TOKEN": "eyJhbGciOiJIUzUxMiJ9..."
105
+ "TUS_ACCESS_TOKEN": "your-jwt-access-token"
96
106
  }
97
107
  }
98
108
  }
@@ -101,13 +111,161 @@ Add to `~/.claude/mcp.json`:
101
111
 
102
112
  ## Available Tools
103
113
 
104
- | Tool | Description |
105
- |------|-------------|
106
- | `wallet_balance` | Get account wallet overview |
107
- | `wallet_trend` | Get consumption trend (`days` param) |
108
- | `wallet_transactions` | List transaction records (with filters) |
109
- | `wallet_coupons` | List cash coupons |
110
- | `wallet_corporate_info` | Get corporate transfer bank info |
114
+ **62 tools** organized by domain:
115
+
116
+ | Domain | Count | Description |
117
+ |--------|-------|-------------|
118
+ | **user** | 6 | User profile, preferences, and account info |
119
+ | **dashboard** | 10 | Dashboard statistics, trends, rankings, model usage, member usage |
120
+ | **wallet** | 8 | Wallet overview, transactions, balance history, recharge records |
121
+ | **team** | 14 | Team/department management, member CRUD, role & permission queries |
122
+ | **tokens** | 6 | Token consumption details, usage aggregation, billing records |
123
+ | **invoice** | 4 | Invoice list, invoice detail, red-punch status queries |
124
+ | **misc** | 14 | Refund management, resource rules, alert settings, message center |
125
+
126
+ ## Authentication
127
+
128
+ This MCP server uses **Access Token** (JWT Bearer Token) authentication. The token is obtained after user login and passed via the `TUS_ACCESS_TOKEN` environment variable. All upstream API requests include it as `Authorization: Bearer <token>`.
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ npm run dev # Watch mode
134
+ npm run build # Compile TypeScript
135
+ npm start # Run compiled server
136
+ ```
137
+
138
+ ## License
139
+
140
+ MIT
141
+ # mcp-user-system
142
+
143
+ [MCP](https://modelcontextprotocol.io) server for token-user-system — Console 前台全量查询接口 via Model Context Protocol.
144
+
145
+ Provides AI agents with authenticated access to the Console (前台) query APIs, covering user info, dashboard statistics, wallet, team management, token usage, invoices, and miscellaneous lookups.
146
+
147
+ Supports: user profiles, dashboard stats & trends, wallet overview, team & member management, token consumption, invoice queries, and more.
148
+
149
+ ## Prerequisites
150
+
151
+ - Node.js >= 18
152
+ - `TUS_BASE_URL` and `TUS_ACCESS_TOKEN` environment variables
153
+
154
+ ## Installation
155
+
156
+ ### 1. Install globally
157
+
158
+ ```bash
159
+ npm install -g mcp-user-system
160
+ ```
161
+
162
+ Or clone & build manually:
163
+
164
+ ```bash
165
+ git clone https://github.com/shenda-ai/mcp-user-system.git
166
+ cd mcp-user-system
167
+ npm install
168
+ npm run build
169
+ ```
170
+
171
+ ### 2. Configure Environment
172
+
173
+ ```bash
174
+ export TUS_BASE_URL=https://api.example.com
175
+ export TUS_ACCESS_TOKEN=your-jwt-access-token
176
+ ```
177
+
178
+ Or create a `.env` file (add to `.gitignore`):
179
+
180
+ ```bash
181
+ TUS_BASE_URL=https://api.example.com
182
+ TUS_ACCESS_TOKEN=your-jwt-access-token
183
+ ```
184
+
185
+ > **Access Token** is a JWT Bearer Token obtained after user login. Include it as `Authorization: Bearer <token>` in upstream requests.
186
+
187
+ ### 3. Test Run
188
+
189
+ ```bash
190
+ npm start
191
+ ```
192
+
193
+ ## MCP Client Configuration
194
+
195
+ ### Claude Desktop (macOS)
196
+
197
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
198
+
199
+ ```json
200
+ {
201
+ "mcpServers": {
202
+ "user-system": {
203
+ "command": "node",
204
+ "args": ["/path/to/mcp-user-system/dist/index.js"],
205
+ "env": {
206
+ "TUS_BASE_URL": "https://api.example.com",
207
+ "TUS_ACCESS_TOKEN": "your-jwt-access-token"
208
+ }
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ ### Cursor / VS Code
215
+
216
+ Add to settings (Cursor: `~/.cursor/mcp.json`, VS Code: settings.json):
217
+
218
+ ```json
219
+ {
220
+ "mcpServers": {
221
+ "user-system": {
222
+ "command": "node",
223
+ "args": ["/path/to/mcp-user-system/dist/index.js"],
224
+ "env": {
225
+ "TUS_BASE_URL": "https://api.example.com",
226
+ "TUS_ACCESS_TOKEN": "your-jwt-access-token"
227
+ }
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
233
+ ### Claude Code (CLI)
234
+
235
+ Add to `~/.claude/mcp.json`:
236
+
237
+ ```json
238
+ {
239
+ "mcpServers": {
240
+ "user-system": {
241
+ "command": "node",
242
+ "args": ["/path/to/mcp-user-system/dist/index.js"],
243
+ "env": {
244
+ "TUS_BASE_URL": "https://api.example.com",
245
+ "TUS_ACCESS_TOKEN": "your-jwt-access-token"
246
+ }
247
+ }
248
+ }
249
+ }
250
+ ```
251
+
252
+ ## Available Tools
253
+
254
+ **62 tools** organized by domain:
255
+
256
+ | Domain | Count | Description |
257
+ |--------|-------|-------------|
258
+ | **user** | 6 | User profile, preferences, and account info |
259
+ | **dashboard** | 10 | Dashboard statistics, trends, rankings, model usage, member usage |
260
+ | **wallet** | 8 | Wallet overview, transactions, balance history, recharge records |
261
+ | **team** | 14 | Team/department management, member CRUD, role & permission queries |
262
+ | **tokens** | 6 | Token consumption details, usage aggregation, billing records |
263
+ | **invoice** | 4 | Invoice list, invoice detail, red-punch status queries |
264
+ | **misc** | 14 | Model list, announcements, notifications, system config, and other lookups |
265
+
266
+ ## Authentication
267
+
268
+ This MCP server uses **Access Token** (JWT Bearer Token) authentication. The token is obtained after user login and passed via the `TUS_ACCESS_TOKEN` environment variable. All upstream API requests include it as `Authorization: Bearer <token>`.
111
269
 
112
270
  ## Development
113
271
 
package/dist/env.d.ts CHANGED
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export interface Config {
5
5
  baseUrl: string;
6
- apiKey: string;
6
+ accessToken: string;
7
7
  }
8
8
  export declare function loadConfig(): Config;
package/dist/env.js CHANGED
@@ -11,7 +11,7 @@ function requireEnv(name) {
11
11
  export function loadConfig() {
12
12
  return {
13
13
  baseUrl: requireEnv("TUS_BASE_URL"),
14
- apiKey: requireEnv("TUS_API_KEY"),
14
+ accessToken: requireEnv("TUS_ACCESS_TOKEN"),
15
15
  };
16
16
  }
17
17
  //# sourceMappingURL=env.js.map
package/dist/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,cAAc,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,aAAa,CAAC;KAClC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,cAAc,CAAC;QACnC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC;KAC5C,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * MCP Server for token-user-system
4
4
  *
5
- * Provides OpenAPI tools via Model Context Protocol.
6
- * Supports: wallet, dashboard stats, orders, users, model-stats, trend
5
+ * Provides tools via Model Context Protocol, organized by domain:
6
+ * user, dashboard, wallet, team, tokens, invoice, misc
7
7
  */
8
8
  export {};
package/dist/index.js CHANGED
@@ -2,252 +2,78 @@
2
2
  /**
3
3
  * MCP Server for token-user-system
4
4
  *
5
- * Provides OpenAPI tools via Model Context Protocol.
6
- * Supports: wallet, dashboard stats, orders, users, model-stats, trend
5
+ * Provides tools via Model Context Protocol, organized by domain:
6
+ * user, dashboard, wallet, team, tokens, invoice, misc
7
7
  */
8
8
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
9
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
10
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
11
- import { getWalletOverview, getDashboardStats, getDashboardOrders, getDashboardUsers, getDashboardModelStats, getDashboardTrend, } from "./tools/wallet.js";
11
+ import * as userTools from "./tools/user.js";
12
+ import * as dashboardTools from "./tools/dashboard.js";
13
+ import * as walletTools from "./tools/wallet.js";
14
+ import * as teamTools from "./tools/team.js";
15
+ import * as tokensTools from "./tools/tokens.js";
16
+ import * as invoiceTools from "./tools/invoice.js";
17
+ import * as miscTools from "./tools/misc.js";
18
+ // ── Merge all tool definitions ──
19
+ const allTools = [
20
+ ...userTools.tools,
21
+ ...dashboardTools.tools,
22
+ ...walletTools.tools,
23
+ ...teamTools.tools,
24
+ ...tokensTools.tools,
25
+ ...invoiceTools.tools,
26
+ ...miscTools.tools,
27
+ ];
12
28
  // ── MCP Server Setup ──
13
29
  const server = new Server({
14
30
  name: "mcp-user-system",
15
- version: "1.0.0",
31
+ version: "2.0.0",
16
32
  }, {
17
33
  capabilities: {
18
34
  tools: {},
19
35
  },
20
36
  });
21
- // ── Tool Definitions ──
22
- server.setRequestHandler(ListToolsRequestSchema, async () => {
23
- return {
24
- tools: [
25
- {
26
- name: "wallet_overview",
27
- description: "Get account wallet overview (balance, usable balance, voucher, credit limit, pending amount)",
28
- inputSchema: {
29
- type: "object",
30
- properties: {},
31
- },
32
- },
33
- {
34
- name: "dashboard_stats",
35
- description: "Get dashboard statistics (used quota, consumption, request count, active users, etc.)",
36
- inputSchema: {
37
- type: "object",
38
- properties: {
39
- timeRange: {
40
- type: "string",
41
- description: "Time range: 0=custom, 1=last 3 days, 2=last week, 3=last month, 4=this month, 5=last year, 6=today, 7=this week, 8=this year (default: 1)",
42
- },
43
- startDate: {
44
- type: "string",
45
- description: "Custom start date (yyyy-MM-dd, required when timeRange=0)",
46
- },
47
- endDate: {
48
- type: "string",
49
- description: "Custom end date (yyyy-MM-dd, required when timeRange=0)",
50
- },
51
- },
52
- },
53
- },
54
- {
55
- name: "dashboard_orders",
56
- description: "List API call detail records with optional filters",
57
- inputSchema: {
58
- type: "object",
59
- properties: {
60
- timeRange: {
61
- type: "string",
62
- description: "Time range: 0=custom, 1=last 3 days, 2=last week, 3=last month, 4=this month, 5=last year, 6=today, 7=this week, 8=this year (default: 1)",
63
- },
64
- startDate: {
65
- type: "string",
66
- description: "Custom start date (yyyy-MM-dd)",
67
- },
68
- endDate: {
69
- type: "string",
70
- description: "Custom end date (yyyy-MM-dd)",
71
- },
72
- type: {
73
- type: "string",
74
- description: "Bill type filter",
75
- },
76
- keyword: {
77
- type: "string",
78
- description: "Keyword filter (matches user name or team nickname)",
79
- },
80
- },
81
- },
82
- },
83
- {
84
- name: "dashboard_users",
85
- description: "Get user dropdown options for dashboard filtering",
86
- inputSchema: {
87
- type: "object",
88
- properties: {
89
- deptId: {
90
- type: "string",
91
- description: "Department ID to filter users",
92
- },
93
- },
94
- },
95
- },
96
- {
97
- name: "dashboard_model_stats",
98
- description: "Get model usage statistics (call count, token consumption, cost, etc.)",
99
- inputSchema: {
100
- type: "object",
101
- properties: {
102
- timeRange: {
103
- type: "string",
104
- description: "Time range: 0=custom, 1=last 3 days, 2=last week, 3=last month, 4=this month, 5=last year, 6=today, 7=this week, 8=this year (default: 1)",
105
- },
106
- startDate: {
107
- type: "string",
108
- description: "Custom start date (yyyy-MM-dd)",
109
- },
110
- endDate: {
111
- type: "string",
112
- description: "Custom end date (yyyy-MM-dd)",
113
- },
114
- sortBy: {
115
- type: "string",
116
- description: "Sort by: 'token' or 'amount' (default: amount)",
117
- },
118
- },
119
- },
120
- },
121
- {
122
- name: "dashboard_trend",
123
- description: "Get consumption trend data over time",
124
- inputSchema: {
125
- type: "object",
126
- properties: {
127
- timeRange: {
128
- type: "string",
129
- description: "Time range: 0=custom, 1=last 3 days, 2=last week, 3=last month, 4=this month, 5=last year, 6=today, 7=this week, 8=this year (default: 1)",
130
- },
131
- startDate: {
132
- type: "string",
133
- description: "Custom start date (yyyy-MM-dd)",
134
- },
135
- endDate: {
136
- type: "string",
137
- description: "Custom end date (yyyy-MM-dd)",
138
- },
139
- },
140
- },
141
- },
142
- ],
143
- };
144
- });
145
- // ── Tool Handlers ──
37
+ // ── Tool List Handler ──
38
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
39
+ tools: allTools,
40
+ }));
41
+ // ── Tool Call Router ──
146
42
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
147
43
  const { name, arguments: args } = request.params;
148
- try {
149
- switch (name) {
150
- case "wallet_overview": {
151
- const data = await getWalletOverview();
152
- return {
153
- content: [
154
- {
155
- type: "text",
156
- text: JSON.stringify(data, null, 2),
157
- },
158
- ],
159
- };
160
- }
161
- case "dashboard_stats": {
162
- const data = await getDashboardStats({
163
- timeRange: args?.timeRange || undefined,
164
- startDate: args?.startDate || undefined,
165
- endDate: args?.endDate || undefined,
166
- });
167
- return {
168
- content: [
169
- {
170
- type: "text",
171
- text: JSON.stringify(data, null, 2),
172
- },
173
- ],
174
- };
175
- }
176
- case "dashboard_orders": {
177
- const data = await getDashboardOrders({
178
- timeRange: args?.timeRange || undefined,
179
- startDate: args?.startDate || undefined,
180
- endDate: args?.endDate || undefined,
181
- type: args?.type || undefined,
182
- keyword: args?.keyword || undefined,
183
- });
44
+ const parsedArgs = (args ?? {});
45
+ // 构建域路由映射
46
+ const domains = [
47
+ { names: userTools.tools.map((t) => t.name), handler: userTools.handle },
48
+ { names: dashboardTools.tools.map((t) => t.name), handler: dashboardTools.handle },
49
+ { names: walletTools.tools.map((t) => t.name), handler: walletTools.handle },
50
+ { names: teamTools.tools.map((t) => t.name), handler: teamTools.handle },
51
+ { names: tokensTools.tools.map((t) => t.name), handler: tokensTools.handle },
52
+ { names: invoiceTools.tools.map((t) => t.name), handler: invoiceTools.handle },
53
+ { names: miscTools.tools.map((t) => t.name), handler: miscTools.handle },
54
+ ];
55
+ // 找到匹配的域并执行
56
+ for (const domain of domains) {
57
+ if (domain.names.includes(name)) {
58
+ try {
59
+ const data = await domain.handler(name, parsedArgs);
184
60
  return {
185
- content: [
186
- {
187
- type: "text",
188
- text: JSON.stringify(data, null, 2),
189
- },
190
- ],
61
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
191
62
  };
192
63
  }
193
- case "dashboard_users": {
194
- const data = await getDashboardUsers(args?.deptId || undefined);
64
+ catch (err) {
65
+ const message = err instanceof Error ? err.message : String(err);
195
66
  return {
196
- content: [
197
- {
198
- type: "text",
199
- text: JSON.stringify(data, null, 2),
200
- },
201
- ],
67
+ content: [{ type: "text", text: `Error: ${message}` }],
68
+ isError: true,
202
69
  };
203
70
  }
204
- case "dashboard_model_stats": {
205
- const data = await getDashboardModelStats({
206
- timeRange: args?.timeRange || undefined,
207
- startDate: args?.startDate || undefined,
208
- endDate: args?.endDate || undefined,
209
- sortBy: args?.sortBy || undefined,
210
- });
211
- return {
212
- content: [
213
- {
214
- type: "text",
215
- text: JSON.stringify(data, null, 2),
216
- },
217
- ],
218
- };
219
- }
220
- case "dashboard_trend": {
221
- const data = await getDashboardTrend({
222
- timeRange: args?.timeRange || undefined,
223
- startDate: args?.startDate || undefined,
224
- endDate: args?.endDate || undefined,
225
- });
226
- return {
227
- content: [
228
- {
229
- type: "text",
230
- text: JSON.stringify(data, null, 2),
231
- },
232
- ],
233
- };
234
- }
235
- default:
236
- throw new Error(`Unknown tool: ${name}`);
237
71
  }
238
72
  }
239
- catch (error) {
240
- const message = error instanceof Error ? error.message : String(error);
241
- return {
242
- content: [
243
- {
244
- type: "text",
245
- text: `Error: ${message}`,
246
- },
247
- ],
248
- isError: true,
249
- };
250
- }
73
+ return {
74
+ content: [{ type: "text", text: `Unknown tool: ${name}` }],
75
+ isError: true,
76
+ };
251
77
  });
252
78
  // ── Start Server ──
253
79
  async function main() {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,yBAAyB;AAEzB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB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发起 GET 请求
9
+ */
10
+ export declare function apiGet<T = unknown>(path: string, params?: Record<string, string | undefined>): Promise<T>;
11
+ /**
12
+ * 发起 GET 请求,返回分页数据(TableDataInfo 格式)
13
+ */
14
+ export declare function apiGetPage<T = unknown>(path: string, params?: Record<string, string | undefined>): Promise<TableDataInfo<T>>;
15
+ /**
16
+ * 发起 POST 请求
17
+ */
18
+ export declare function apiPost<T = unknown>(path: string, body?: unknown): Promise<T>;
19
+ export {};