worsoft-frontend-codegen-local-mcp 0.1.32 → 0.1.33
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 +51 -19
- 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.33';
|
|
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');
|
|
@@ -149,10 +149,15 @@ const TOOL_SCHEMA = {
|
|
|
149
149
|
type: 'object',
|
|
150
150
|
properties: {
|
|
151
151
|
featureTitle: { type: 'string', description: 'Feature title from structured metadata.' },
|
|
152
|
-
tableName: { type: 'string', description: 'Target main table name from the structured feature metadata.' },
|
|
153
|
-
tableComment: { type: 'string', description: 'Main table comment or feature label for menu/title generation.' },
|
|
152
|
+
tableName: { type: 'string', description: 'Target main table name from the structured feature metadata.' },
|
|
153
|
+
tableComment: { type: 'string', description: 'Main table comment or feature label for menu/title generation.' },
|
|
154
154
|
apiPath: { type: 'string', description: 'Backend API base path from structured metadata, for example iwmEmpOutsourcePerson.' },
|
|
155
|
-
|
|
155
|
+
pageType: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
enum: ['feature', 'dictionary', 'non_standard', 'business', 'dict'],
|
|
158
|
+
description: 'Structured page type from parseResult. Dictionary pages are restricted to dialog-based templates.',
|
|
159
|
+
},
|
|
160
|
+
style: { type: 'string', enum: Object.keys(STYLE_CATALOG), description: 'Style id from assets/style-catalog.json.' },
|
|
156
161
|
fields: {
|
|
157
162
|
type: 'array',
|
|
158
163
|
description: 'Structured main-table field metadata provided by the caller.',
|
|
@@ -1207,12 +1212,32 @@ function normalizeLevelsInput(inputLevels) {
|
|
|
1207
1212
|
return levels;
|
|
1208
1213
|
}
|
|
1209
1214
|
|
|
1210
|
-
function getStylePreset(styleId) {
|
|
1211
|
-
const preset = STYLE_CATALOG[styleId];
|
|
1212
|
-
if (!preset) throw new Error('Unsupported style: ' + styleId);
|
|
1213
|
-
return preset;
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1215
|
+
function getStylePreset(styleId) {
|
|
1216
|
+
const preset = STYLE_CATALOG[styleId];
|
|
1217
|
+
if (!preset) throw new Error('Unsupported style: ' + styleId);
|
|
1218
|
+
return preset;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
function normalizePageTypeInput(pageType) {
|
|
1222
|
+
if (pageType === undefined || pageType === null || pageType === '') return '';
|
|
1223
|
+
const normalized = String(pageType).trim();
|
|
1224
|
+
if (normalized === 'dict') return 'dictionary';
|
|
1225
|
+
if (normalized === 'business') return 'feature';
|
|
1226
|
+
if (['feature', 'dictionary', 'non_standard'].includes(normalized)) return normalized;
|
|
1227
|
+
throw new Error('Unsupported pageType: ' + normalized);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function validatePageTypeAndStyle(pageType, style) {
|
|
1231
|
+
if (!pageType) return;
|
|
1232
|
+
if (pageType === 'non_standard') {
|
|
1233
|
+
throw new Error('non_standard pages are not supported by worsoft_codegen_local_generate_frontend');
|
|
1234
|
+
}
|
|
1235
|
+
if (pageType !== 'dictionary') return;
|
|
1236
|
+
if (style === 'single_table_jump' || style === 'master_child_jump') {
|
|
1237
|
+
throw new Error(`Dictionary pages must use dialog-based styles. pageType=dictionary does not support style=${style}`);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1216
1241
|
function hasRuntimeSupport(stylePreset) {
|
|
1217
1242
|
return Boolean(stylePreset.runtime && stylePreset.runtime.supported && stylePreset.runtime.templateDir);
|
|
1218
1243
|
}
|
|
@@ -1322,9 +1347,10 @@ function buildMultiLevelDictModel(safeArgs) {
|
|
|
1322
1347
|
|
|
1323
1348
|
return {
|
|
1324
1349
|
featureTitle: safeArgs.featureTitle || safeArgs.tableComment || parentModule.tableComment,
|
|
1325
|
-
tableName: safeArgs.tableName,
|
|
1350
|
+
tableName: safeArgs.tableName,
|
|
1326
1351
|
tableComment: safeArgs.tableComment || parentModule.tableComment,
|
|
1327
1352
|
apiPath: safeArgs.apiPath || parentModule.apiPath,
|
|
1353
|
+
pageType: safeArgs.pageType || 'dictionary',
|
|
1328
1354
|
className: toPascalCase(safeArgs.tableName || parentModule.tableName),
|
|
1329
1355
|
functionName: resolvedTargets.functionName,
|
|
1330
1356
|
moduleName: resolvedTargets.moduleName,
|
|
@@ -1419,6 +1445,7 @@ function buildModel(safeArgs) {
|
|
|
1419
1445
|
tableName: safeArgs.tableName,
|
|
1420
1446
|
tableComment: safeArgs.tableComment || safeArgs.featureTitle || safeArgs.tableName,
|
|
1421
1447
|
apiPath,
|
|
1448
|
+
pageType: safeArgs.pageType || '',
|
|
1422
1449
|
className: toPascalCase(safeArgs.tableName),
|
|
1423
1450
|
functionName: resolvedTargets.functionName,
|
|
1424
1451
|
moduleName: resolvedTargets.moduleName,
|
|
@@ -2597,9 +2624,11 @@ function ensureArguments(input) {
|
|
|
2597
2624
|
if (input[key] === undefined || input[key] === null || input[key] === '') throw new Error(key + ' is required');
|
|
2598
2625
|
}
|
|
2599
2626
|
|
|
2600
|
-
const style = String(input.style);
|
|
2601
|
-
|
|
2602
|
-
|
|
2627
|
+
const style = String(input.style);
|
|
2628
|
+
const pageType = normalizePageTypeInput(input.pageType);
|
|
2629
|
+
getStylePreset(style);
|
|
2630
|
+
validatePageTypeAndStyle(pageType, style);
|
|
2631
|
+
const isMultiLevelDict = style === 'multi_level_dict';
|
|
2603
2632
|
const fields = isMultiLevelDict ? [] : normalizeStructuredFieldArray(input.fields, 'fields');
|
|
2604
2633
|
const levels = isMultiLevelDict ? normalizeLevelsInput(input.levels) : [];
|
|
2605
2634
|
|
|
@@ -2616,7 +2645,8 @@ function ensureArguments(input) {
|
|
|
2616
2645
|
tableName: String(input.tableName),
|
|
2617
2646
|
tableComment: input.tableComment ? String(input.tableComment) : '',
|
|
2618
2647
|
apiPath: normalizeApiPath(input.apiPath),
|
|
2619
|
-
|
|
2648
|
+
pageType,
|
|
2649
|
+
style,
|
|
2620
2650
|
fields,
|
|
2621
2651
|
levels,
|
|
2622
2652
|
children: normalizeChildrenInput(input.children),
|
|
@@ -2659,6 +2689,7 @@ function buildManifest(model, safeArgs, stylePreset, files, note) {
|
|
|
2659
2689
|
return {
|
|
2660
2690
|
mode: 'local-template',
|
|
2661
2691
|
style: safeArgs.style,
|
|
2692
|
+
pageType: model.pageType || '',
|
|
2662
2693
|
styleLabel: stylePreset.label,
|
|
2663
2694
|
runtimeSupported: hasRuntimeSupport(stylePreset),
|
|
2664
2695
|
tableName: model.tableName,
|
|
@@ -2712,10 +2743,11 @@ function buildManifest(model, safeArgs, stylePreset, files, note) {
|
|
|
2712
2743
|
}));
|
|
2713
2744
|
const selectedList = relations.map((relation) => formatRelationCandidate(relation));
|
|
2714
2745
|
|
|
2715
|
-
return {
|
|
2716
|
-
mode: 'local-template',
|
|
2717
|
-
style: safeArgs.style,
|
|
2718
|
-
|
|
2746
|
+
return {
|
|
2747
|
+
mode: 'local-template',
|
|
2748
|
+
style: safeArgs.style,
|
|
2749
|
+
pageType: model.pageType || '',
|
|
2750
|
+
styleLabel: stylePreset.label,
|
|
2719
2751
|
runtimeSupported: hasRuntimeSupport(stylePreset),
|
|
2720
2752
|
tableName: model.tableName,
|
|
2721
2753
|
tableComment: model.tableComment,
|
package/package.json
CHANGED