snow-flow 3.4.7 → 3.4.8
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.
|
@@ -559,6 +559,37 @@ class ServiceNowDeploymentMCP {
|
|
|
559
559
|
let updateSetId = null;
|
|
560
560
|
let updateSetName = 'No Update Set';
|
|
561
561
|
try {
|
|
562
|
+
// CRITICAL: Validate required fields FIRST for clear error messages
|
|
563
|
+
if (!args.name) {
|
|
564
|
+
return {
|
|
565
|
+
success: false,
|
|
566
|
+
error: 'Widget name is required',
|
|
567
|
+
content: [{
|
|
568
|
+
type: 'text',
|
|
569
|
+
text: `❌ Widget deployment failed: Missing required field\n\n**Error:** Widget name is required\n\n**Required fields for widget deployment:**\n• name: Internal identifier for the widget (e.g., "my_dashboard_widget")\n• title: Display title shown in Service Portal (e.g., "My Dashboard")\n• template: HTML template for the widget\n\n**Example usage:**\n\`\`\`javascript\nsnow_deploy({\n type: "widget",\n config: {\n name: "my_widget",\n title: "My Widget Title",\n template: "<div>{{data.message}}</div>",\n server_script: "data.message = 'Hello World';",\n client_script: "function() { var c = this; }"\n }\n})\n\`\`\``
|
|
570
|
+
}]
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (!args.title) {
|
|
574
|
+
return {
|
|
575
|
+
success: false,
|
|
576
|
+
error: 'Widget title is required',
|
|
577
|
+
content: [{
|
|
578
|
+
type: 'text',
|
|
579
|
+
text: `❌ Widget deployment failed: Missing required field\n\n**Error:** Widget title is required for display in Service Portal\n\n**Required fields for widget deployment:**\n• name: Internal identifier for the widget\n• title: Display title shown in Service Portal ← MISSING\n• template: HTML template for the widget\n\n**Why title is required:**\nThe title is displayed in Service Portal widget picker and page designer.\nIt's what users see when selecting widgets to add to pages.\n\n**Example:**\n\`\`\`javascript\nconfig: {\n name: "incident_list",\n title: "Active Incidents", // ← This is what users will see\n template: "<div>...</div>"\n}\n\`\`\``
|
|
580
|
+
}]
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
if (!args.template && !args.html_template) {
|
|
584
|
+
return {
|
|
585
|
+
success: false,
|
|
586
|
+
error: 'Widget template (HTML) is required',
|
|
587
|
+
content: [{
|
|
588
|
+
type: 'text',
|
|
589
|
+
text: `❌ Widget deployment failed: Missing required field\n\n**Error:** Widget template (HTML) is required\n\n**Required fields for widget deployment:**\n• name: Internal identifier for the widget\n• title: Display title shown in Service Portal\n• template: HTML template for the widget ← MISSING\n\n**Template defines the widget's visual structure:**\n\`\`\`html\n<div class="my-widget">\n <h3>{{data.title}}</h3>\n <ul>\n <li ng-repeat="item in data.items">\n {{item.name}}\n </li>\n </ul>\n</div>\n\`\`\`\n\n**Note:** Use either 'template' or 'html_template' parameter.`
|
|
590
|
+
}]
|
|
591
|
+
};
|
|
592
|
+
}
|
|
562
593
|
// Enhanced authentication check with token refresh for deployment
|
|
563
594
|
const authResult = await this.deploymentAuthManager.ensureDeploymentAuth();
|
|
564
595
|
if (!authResult.isValid) {
|
|
@@ -6614,11 +6645,17 @@ Use individual deployment tools like \`snow_deploy_${args.type}\` with manual co
|
|
|
6614
6645
|
}
|
|
6615
6646
|
// For widgets, delegate to widget composer
|
|
6616
6647
|
if (type === 'widget') {
|
|
6648
|
+
const widgetName = this.extractNameFromInstruction(instruction);
|
|
6649
|
+
// Ensure title is always valid and user-friendly
|
|
6650
|
+
const widgetTitle = widgetName
|
|
6651
|
+
.replace(/_/g, ' ')
|
|
6652
|
+
.replace(/\b\w/g, l => l.toUpperCase())
|
|
6653
|
+
|| 'Auto Generated Widget';
|
|
6617
6654
|
return {
|
|
6618
|
-
name:
|
|
6619
|
-
title:
|
|
6655
|
+
name: widgetName,
|
|
6656
|
+
title: widgetTitle, // Always ensure a valid display title
|
|
6620
6657
|
description: instruction,
|
|
6621
|
-
template: this.generateWidgetTemplate(instruction),
|
|
6658
|
+
template: this.generateWidgetTemplate(instruction) || '<div>{{data.message}}</div>', // Ensure template is never empty
|
|
6622
6659
|
css: this.generateWidgetCss(instruction),
|
|
6623
6660
|
server_script: this.generateWidgetServerScript(instruction),
|
|
6624
6661
|
client_script: this.generateWidgetClientScript(instruction),
|
|
@@ -6638,8 +6675,9 @@ Use individual deployment tools like \`snow_deploy_${args.type}\` with manual co
|
|
|
6638
6675
|
// Simple name extraction - could be enhanced with NLP
|
|
6639
6676
|
const words = instruction.toLowerCase().split(/\s+/);
|
|
6640
6677
|
const name = words.filter(word => word.length > 2 &&
|
|
6641
|
-
!['the', 'and', 'for', 'with', 'that', 'will', 'can', 'should'].includes(word)).slice(0, 3).join('_');
|
|
6642
|
-
return
|
|
6678
|
+
!['the', 'and', 'for', 'with', 'that', 'will', 'can', 'should', 'create', 'make', 'build', 'new'].includes(word)).slice(0, 3).join('_');
|
|
6679
|
+
// Ensure we always return a valid name
|
|
6680
|
+
return name || `auto_generated_${Date.now().toString().slice(-6)}`;
|
|
6643
6681
|
}
|
|
6644
6682
|
/**
|
|
6645
6683
|
* Generate HTML template based on widget requirements
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.8",
|
|
4
4
|
"description": "ServiceNow development framework with MCP server integration. Executes background scripts using ES5 JavaScript only (ServiceNow Rhino engine requirement). Provides 12 MCP servers for ServiceNow operations including widget deployment with coherence validation, table operations, script execution, and system property management.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|