worsoft-frontend-codegen-local-mcp 0.1.59 → 0.1.60
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/mcp_server.js +14 -3
- package/package.json +1 -1
package/mcp_server.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
7
|
const SERVER_NAME = 'worsoft-codegen-local';
|
|
8
|
-
const SERVER_VERSION = '0.1.
|
|
8
|
+
const SERVER_VERSION = '0.1.60';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const STYLE_CATALOG_PATH = path.join(__dirname, 'assets', 'style-catalog.json');
|
|
@@ -1450,7 +1450,7 @@ function normalizeExtraApis(inputExtraApis, currentTargetApiModule) {
|
|
|
1450
1450
|
if (!['get', 'post', 'put', 'delete'].includes(method)) {
|
|
1451
1451
|
throw new Error('extraApis[' + index + '].method must be one of get, post, put, delete');
|
|
1452
1452
|
}
|
|
1453
|
-
const url = String(item.url || '').trim();
|
|
1453
|
+
const url = normalizeExtraApiUrl(String(item.url || '').trim(), currentTargetApiModule);
|
|
1454
1454
|
if (!url) {
|
|
1455
1455
|
throw new Error('extraApis[' + index + '].url is required');
|
|
1456
1456
|
}
|
|
@@ -1474,7 +1474,7 @@ function normalizeExtraApis(inputExtraApis, currentTargetApiModule) {
|
|
|
1474
1474
|
return {
|
|
1475
1475
|
functionName,
|
|
1476
1476
|
description,
|
|
1477
|
-
url
|
|
1477
|
+
url,
|
|
1478
1478
|
method,
|
|
1479
1479
|
requestType,
|
|
1480
1480
|
targetApiModule,
|
|
@@ -1484,6 +1484,17 @@ function normalizeExtraApis(inputExtraApis, currentTargetApiModule) {
|
|
|
1484
1484
|
});
|
|
1485
1485
|
}
|
|
1486
1486
|
|
|
1487
|
+
function normalizeExtraApiUrl(rawUrl, currentTargetApiModule) {
|
|
1488
|
+
if (!rawUrl) return '';
|
|
1489
|
+
if (/^https?:\/\//i.test(rawUrl)) return rawUrl;
|
|
1490
|
+
let url = rawUrl.startsWith('/') ? rawUrl : '/' + rawUrl;
|
|
1491
|
+
const moduleRoot = String(currentTargetApiModule || '').split('/')[0] || '';
|
|
1492
|
+
if (moduleRoot && !url.startsWith('/' + moduleRoot + '/')) {
|
|
1493
|
+
url = '/' + moduleRoot + url;
|
|
1494
|
+
}
|
|
1495
|
+
return url;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1487
1498
|
function ensureFieldExists(fields, fieldName, tableName, role) {
|
|
1488
1499
|
const field = fields.find((item) => item.fieldName === fieldName);
|
|
1489
1500
|
if (!field) throw new Error(role + ' field "' + fieldName + '" was not found on table ' + tableName);
|
package/package.json
CHANGED