snow-flow 3.0.20 → 3.0.21

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.
@@ -502,7 +502,77 @@ class ServiceNowDeploymentMCP {
502
502
  if (!authResult.hasWriteScope) {
503
503
  this.logger.warn('⚠️ Token may lack write permissions, deployment might fail with 403');
504
504
  }
505
- this.logger.info('Deploying widget to ServiceNow', { name: args.name });
505
+ this.logger.info('Deploying widget to ServiceNow', { name: args.name, sys_id: args.sys_id });
506
+ // CHECK: If sys_id is provided, this is an UPDATE not a CREATE
507
+ if (args.sys_id) {
508
+ this.logger.info('🔄 UPDATE mode detected - updating existing widget', { sys_id: args.sys_id });
509
+ try {
510
+ // Update the existing widget
511
+ const updateResult = await this.client.updateRecord('sp_widget', args.sys_id, {
512
+ name: args.name || undefined,
513
+ title: args.title || undefined,
514
+ template: args.template || undefined,
515
+ css: args.css || undefined,
516
+ client_script: args.client_script || undefined,
517
+ server_script: args.server_script || undefined,
518
+ option_schema: args.option_schema || undefined,
519
+ demo_data: args.demo_data || undefined,
520
+ data: args.data || undefined,
521
+ description: args.description || undefined
522
+ });
523
+ if (updateResult.success) {
524
+ const credentials = await this.oauth.loadCredentials();
525
+ const widgetUrl = credentials?.instance ?
526
+ `https://${credentials.instance}/sp_config?id=widget_editor&sys_id=${args.sys_id}` :
527
+ 'ServiceNow instance URL not available';
528
+ return {
529
+ success: true,
530
+ sys_id: args.sys_id,
531
+ name: args.name,
532
+ content: [
533
+ {
534
+ type: 'text',
535
+ text: `✅ Widget updated successfully!
536
+
537
+ 🎯 Widget Details:
538
+ - Sys ID: ${args.sys_id}
539
+ - Name: ${args.name || 'Unchanged'}
540
+ - Deployment Context: ${args.config?.deployment_context || args.deployment_context || 'Widget update'}
541
+ - Method: Direct update via API
542
+
543
+ 🔗 Direct Links:
544
+ - Widget Editor: ${widgetUrl}
545
+ - Service Portal Designer: https://${credentials?.instance}/sp_config?id=designer
546
+
547
+ ⚡ **Widget Updated**
548
+ Your changes have been applied to the existing widget.`
549
+ }
550
+ ]
551
+ };
552
+ }
553
+ else {
554
+ return {
555
+ success: false,
556
+ error: updateResult.error || 'Failed to update widget',
557
+ content: [{
558
+ type: 'text',
559
+ text: `❌ Failed to update widget: ${updateResult.error || 'Unknown error'}`
560
+ }]
561
+ };
562
+ }
563
+ }
564
+ catch (updateError) {
565
+ this.logger.error('Widget update failed', updateError);
566
+ return {
567
+ success: false,
568
+ error: updateError.message || 'Update failed',
569
+ content: [{
570
+ type: 'text',
571
+ text: `❌ Widget update failed: ${updateError.message || 'Unknown error'}`
572
+ }]
573
+ };
574
+ }
575
+ }
506
576
  // ENHANCED: Mandatory Update Set management with auto-activation
507
577
  try {
508
578
  // Force Update Set creation/activation for all deployments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "3.0.20",
3
+ "version": "3.0.21",
4
4
  "description": "Snow-Flow v3.0.18: DIRECT API VERIFICATION! 🚀 Replaced unreliable searchRecords with direct API calls (snow_query_table style) for widget verification. All null/403 error recovery now uses GET /api/now/table/sp_widget with precise queries. NO MORE FALSE NEGATIVES - verification works consistently every time!",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",