worsoft-frontend-codegen-local-mcp 0.1.62 → 0.1.64
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 +79 -31
- 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.64';
|
|
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');
|
|
@@ -983,7 +983,7 @@ function normalizeStructuredFormType(value) {
|
|
|
983
983
|
if (!normalized) return '';
|
|
984
984
|
if (normalized === 'date') return 'date';
|
|
985
985
|
if (normalized === 'datetime') return 'datetime';
|
|
986
|
-
if (normalized === 'microme-operator') return '
|
|
986
|
+
if (normalized === 'microme-operator') return 'microme-operator';
|
|
987
987
|
if (normalized === 'upload') {
|
|
988
988
|
return 'upload';
|
|
989
989
|
}
|
|
@@ -1441,16 +1441,22 @@ function rejectSemanticStageInputs(input) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
|
|
1444
|
-
function validatePageTypeAndStyle(pageType, style) {
|
|
1445
|
-
if (!pageType) return;
|
|
1446
|
-
if (pageType === 'non_standard') {
|
|
1447
|
-
throw new Error('non_standard pages are not supported by worsoft_codegen_local_generate_frontend');
|
|
1448
|
-
}
|
|
1449
|
-
if (pageType
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1444
|
+
function validatePageTypeAndStyle(pageType, style) {
|
|
1445
|
+
if (!pageType) return;
|
|
1446
|
+
if (pageType === 'non_standard') {
|
|
1447
|
+
throw new Error('non_standard pages are not supported by worsoft_codegen_local_generate_frontend');
|
|
1448
|
+
}
|
|
1449
|
+
if (pageType === 'business') {
|
|
1450
|
+
if (style === 'single_table_dialog') {
|
|
1451
|
+
throw new Error('Business pages must use jump-based styles. pageType=business does not support style=single_table_dialog; use single_table_jump for single-table business pages or master_child_jump for master-child business pages.');
|
|
1452
|
+
}
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
if (pageType !== 'dict') return;
|
|
1456
|
+
if (style === 'single_table_jump' || style === 'master_child_jump') {
|
|
1457
|
+
throw new Error(`Dict pages must use dialog-based styles. pageType=dict does not support style=${style}`);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1454
1460
|
|
|
1455
1461
|
function hasRuntimeSupport(stylePreset) {
|
|
1456
1462
|
return Boolean(stylePreset.runtime && stylePreset.runtime.supported && stylePreset.runtime.templateDir);
|
|
@@ -1786,19 +1792,29 @@ function renderFormField(field) {
|
|
|
1786
1792
|
].join('\n');
|
|
1787
1793
|
}
|
|
1788
1794
|
|
|
1789
|
-
if (field.formType === 'number') {
|
|
1790
|
-
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
1791
|
-
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
1792
|
-
return [
|
|
1793
|
-
' <el-col :span="12" class="mb20">',
|
|
1795
|
+
if (field.formType === 'number') {
|
|
1796
|
+
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
1797
|
+
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
1798
|
+
return [
|
|
1799
|
+
' <el-col :span="12" class="mb20">',
|
|
1794
1800
|
` <el-form-item label="${label}" prop="${prop}">`,
|
|
1795
1801
|
` <el-input-number v-model="form.${prop}" :min="0"${max}${precision} :placeholder="${inputPlaceholderExpr}" style="width: 100%" />`,
|
|
1796
1802
|
' </el-form-item>',
|
|
1797
1803
|
' </el-col>',
|
|
1798
|
-
].join('\n');
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
if (field.formType === '
|
|
1804
|
+
].join('\n');
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
if (field.formType === 'microme-operator') {
|
|
1808
|
+
return [
|
|
1809
|
+
' <el-col :span="12" class="mb20">',
|
|
1810
|
+
` <el-form-item label="${label}" prop="${prop}">`,
|
|
1811
|
+
` <MicromeOperator v-model="form.${prop}"${renderMicromeFormatAttr(field)} :placeholder="${inputPlaceholderExpr}" />`,
|
|
1812
|
+
' </el-form-item>',
|
|
1813
|
+
' </el-col>',
|
|
1814
|
+
].join('\n');
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
if (field.formType === 'datetime' || field.formType === 'date') {
|
|
1802
1818
|
const pickerType = field.formType === 'datetime' ? 'datetime' : 'date';
|
|
1803
1819
|
const formatName = field.formType === 'datetime' ? 'dateTimeStr' : 'dateStr';
|
|
1804
1820
|
return [
|
|
@@ -1863,6 +1879,8 @@ function renderChildTableColumn(field, childListName) {
|
|
|
1863
1879
|
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
1864
1880
|
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
1865
1881
|
control = ` <el-input-number v-model="row.${field.attrName}" :min="0"${max}${precision} :placeholder="${inputPlaceholderExpr}" style="width: 100%"${disabledAttr} />`;
|
|
1882
|
+
} else if (field.formType === 'microme-operator') {
|
|
1883
|
+
control = ` <MicromeOperator v-model="row.${field.attrName}"${renderMicromeFormatAttr(field)} :placeholder="${inputPlaceholderExpr}"${disabledAttr} />`;
|
|
1866
1884
|
}
|
|
1867
1885
|
|
|
1868
1886
|
return [
|
|
@@ -1892,7 +1910,7 @@ function renderDefaultLine(field) {
|
|
|
1892
1910
|
if (field.attrName === 'billDate') return ` ${field.attrName}: moment(new Date()).format('YYYY-MM-DD'),`;
|
|
1893
1911
|
if (field.attrName === 'billStateId' || field.fieldName === 'bill_state_id') return ` ${field.attrName}: '0',`;
|
|
1894
1912
|
if (field.attrName === 'createTime') return ` ${field.attrName}: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),`;
|
|
1895
|
-
if (field.formType === 'number') return ` ${field.attrName}: 0,`;
|
|
1913
|
+
if (field.formType === 'number' || field.formType === 'microme-operator') return ` ${field.attrName}: 0,`;
|
|
1896
1914
|
return ` ${field.attrName}: '',`;
|
|
1897
1915
|
}
|
|
1898
1916
|
|
|
@@ -2088,6 +2106,14 @@ function renderDisabledBoolV2(field) {
|
|
|
2088
2106
|
return field.readonly ? 'true' : 'false';
|
|
2089
2107
|
}
|
|
2090
2108
|
|
|
2109
|
+
function renderMicromeFormatAttr(field) {
|
|
2110
|
+
const length = Number.parseInt(String(field.length || ''), 10);
|
|
2111
|
+
const scale = Number.parseInt(String(field.scale || ''), 10);
|
|
2112
|
+
if (!length || Number.isNaN(length) || Number.isNaN(scale) || scale < 0) return '';
|
|
2113
|
+
const integerLength = Math.max(length - scale, 1);
|
|
2114
|
+
return ` format="${integerLength}-${scale}"`;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2091
2117
|
function isAttachmentLikeField(field) {
|
|
2092
2118
|
const fieldName = String(field?.fieldName || field?.attrName || '').toLowerCase();
|
|
2093
2119
|
const comment = String(field?.comment || field?.description || '').toLowerCase();
|
|
@@ -2130,20 +2156,42 @@ function renderFormFieldV2(field) {
|
|
|
2130
2156
|
].join('\n');
|
|
2131
2157
|
}
|
|
2132
2158
|
|
|
2133
|
-
if (field.formType === 'number') {
|
|
2134
|
-
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
2135
|
-
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
2136
|
-
return [
|
|
2137
|
-
renderFieldCommentV2(field),
|
|
2159
|
+
if (field.formType === 'number') {
|
|
2160
|
+
const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
|
|
2161
|
+
const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
|
|
2162
|
+
return [
|
|
2163
|
+
renderFieldCommentV2(field),
|
|
2138
2164
|
` <el-col :span="12" class="mb20">`,
|
|
2139
2165
|
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
2140
2166
|
` <el-input-number v-model="form.${prop}" :min="0"${max}${precision} :placeholder="formInputPlaceholder(${labelExpr}, ${disabledBool})" style="width: 100%"${disabledAttr} />`,
|
|
2141
2167
|
' </el-form-item>',
|
|
2142
2168
|
' </el-col>',
|
|
2143
|
-
].join('\n');
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
if (field.formType === '
|
|
2169
|
+
].join('\n');
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
if (field.formType === 'microme-operator') {
|
|
2173
|
+
return [
|
|
2174
|
+
renderFieldCommentV2(field),
|
|
2175
|
+
` <el-col :span="12" class="mb20">`,
|
|
2176
|
+
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
2177
|
+
` <MicromeOperator v-model="form.${prop}"${renderMicromeFormatAttr(field)} :placeholder="formInputPlaceholder(${labelExpr}, ${disabledBool})"${disabledAttr} />`,
|
|
2178
|
+
' </el-form-item>',
|
|
2179
|
+
' </el-col>',
|
|
2180
|
+
].join('\n');
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
if (field.formType === 'microme-operator') {
|
|
2184
|
+
return [
|
|
2185
|
+
renderFieldCommentV2(field),
|
|
2186
|
+
' <el-col :span="12" class="mb20">',
|
|
2187
|
+
` <el-form-item :label="${labelExpr}" prop="${prop}">`,
|
|
2188
|
+
` <MicromeOperator v-model="form.${prop}"${renderMicromeFormatAttr(field)} :placeholder="formInputPlaceholder(${labelExpr}, ${disabledBool})"${disabledAttr} />`,
|
|
2189
|
+
' </el-form-item>',
|
|
2190
|
+
' </el-col>',
|
|
2191
|
+
].join('\n');
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
if (field.formType === 'datetime' || field.formType === 'date') {
|
|
2147
2195
|
const pickerType = field.formType === 'datetime' ? 'datetime' : 'date';
|
|
2148
2196
|
const formatName = field.formType === 'datetime' ? 'dateTimeStr' : 'dateStr';
|
|
2149
2197
|
return [
|
package/package.json
CHANGED