snow-flow 8.4.42 → 8.4.44
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/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +56 -60
- package/dist/cli/auth.js.map +1 -1
- package/dist/utils/snow-oauth.d.ts +10 -5
- package/dist/utils/snow-oauth.d.ts.map +1 -1
- package/dist/utils/snow-oauth.js +223 -86
- package/dist/utils/snow-oauth.js.map +1 -1
- package/package.json +1 -1
- package/THEMES.md +0 -223
- package/dist/mcp/servicenow-mcp-unified/config/tool-definitions.json +0 -3935
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_automation_discover.js +0 -164
- package/dist/mcp/servicenow-mcp-unified/tools/deployment/snow_artifact_transfer.js +0 -282
- package/dist/mcp/servicenow-mcp-unified/tools/filters/snow_build_filter.js +0 -171
- package/dist/mcp/servicenow-mcp-unified/tools/formatters/snow_format_value.js +0 -164
- package/dist/mcp/servicenow-mcp-unified/tools/knowledge/index.js.bak +0 -45
- package/dist/mcp/servicenow-mcp-unified/tools/local-sync/snow_artifact_sync.js +0 -172
- package/dist/mcp/servicenow-mcp-unified/tools/system-properties/index.js +0 -36
- package/dist/mcp/servicenow-mcp-unified/tools/ui-builder/snow_discover_uib.js +0 -296
- package/dist/mcp/servicenow-mcp-unified/tools/workspace/snow_create_ux_component.js +0 -292
- package/dist/memory/session-memory.d.ts +0 -80
- package/dist/memory/session-memory.d.ts.map +0 -1
- package/dist/memory/session-memory.js +0 -468
- package/dist/memory/session-memory.js.map +0 -1
- package/dist/templates/opencode-agents-template.d.ts +0 -2
- package/dist/templates/opencode-agents-template.d.ts.map +0 -1
- package/dist/templates/opencode-agents-template.js +0 -469
- package/dist/templates/opencode-agents-template.js.map +0 -1
- package/dist/utils/opencode-output-interceptor.d.ts +0 -40
- package/dist/utils/opencode-output-interceptor.d.ts.map +0 -1
- package/dist/utils/opencode-output-interceptor.js +0 -258
- package/dist/utils/opencode-output-interceptor.js.map +0 -1
- package/scripts/bulk-optimize-tools.js +0 -486
- package/scripts/optimize-mcp-tools.ts +0 -410
- package/themes/README.md +0 -83
- package/themes/servicenow.json +0 -117
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* snow_automation_discover - Unified Automation Discovery
|
|
4
|
-
*
|
|
5
|
-
* Replaces: snow_discover_automation_jobs, snow_discover_events, snow_discover_schedules
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.author = exports.version = exports.toolDefinition = void 0;
|
|
9
|
-
exports.execute = execute;
|
|
10
|
-
const auth_js_1 = require("../../shared/auth.js");
|
|
11
|
-
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
12
|
-
|
|
13
|
-
exports.toolDefinition = {
|
|
14
|
-
name: 'snow_automation_discover',
|
|
15
|
-
description: 'Discover automation: jobs, events, schedules',
|
|
16
|
-
category: 'automation',
|
|
17
|
-
subcategory: 'script-execution',
|
|
18
|
-
use_cases: ['automation', 'monitoring', 'discovery'],
|
|
19
|
-
complexity: 'beginner',
|
|
20
|
-
frequency: 'high',
|
|
21
|
-
related_tools: ['snow_execute_script_with_output', 'snow_get_logs'],
|
|
22
|
-
inputSchema: {
|
|
23
|
-
type: 'object',
|
|
24
|
-
properties: {
|
|
25
|
-
action: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
enum: ['jobs', 'events', 'schedules'],
|
|
28
|
-
description: 'Discovery type: jobs, events, or schedules'
|
|
29
|
-
},
|
|
30
|
-
active: { type: 'boolean', description: 'Filter by active status (jobs only)' },
|
|
31
|
-
table: { type: 'string', description: 'Filter by table name (events only)' },
|
|
32
|
-
type: { type: 'string', description: 'Filter by type (schedules only)' },
|
|
33
|
-
nameContains: { type: 'string', description: 'Search by name pattern' },
|
|
34
|
-
limit: { type: 'number', description: 'Maximum results', default: 50 }
|
|
35
|
-
},
|
|
36
|
-
required: ['action']
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
async function execute(args, context) {
|
|
41
|
-
const { action, active, table, type, nameContains, limit = 50 } = args;
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const client = await (0, auth_js_1.getAuthenticatedClient)(context);
|
|
45
|
-
|
|
46
|
-
switch (action) {
|
|
47
|
-
case 'jobs':
|
|
48
|
-
return await discoverJobs(client, active, nameContains, limit);
|
|
49
|
-
case 'events':
|
|
50
|
-
return await discoverEvents(client, table, nameContains, limit);
|
|
51
|
-
case 'schedules':
|
|
52
|
-
return await discoverSchedules(client, type, nameContains, limit);
|
|
53
|
-
default:
|
|
54
|
-
return (0, error_handler_js_1.createErrorResult)(`Unknown action: ${action}`);
|
|
55
|
-
}
|
|
56
|
-
} catch (error) {
|
|
57
|
-
return (0, error_handler_js_1.createErrorResult)(error instanceof error_handler_js_1.SnowFlowError
|
|
58
|
-
? error
|
|
59
|
-
: new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.UNKNOWN_ERROR, error.message, { originalError: error }));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function discoverJobs(client, active, nameContains, limit) {
|
|
64
|
-
const queryParts = [];
|
|
65
|
-
if (active !== undefined) {
|
|
66
|
-
queryParts.push(`active=${active}`);
|
|
67
|
-
}
|
|
68
|
-
if (nameContains) {
|
|
69
|
-
queryParts.push(`nameLIKE${nameContains}`);
|
|
70
|
-
}
|
|
71
|
-
const query = queryParts.join('^');
|
|
72
|
-
|
|
73
|
-
const response = await client.get(`/api/now/table/sysauto_script?sysparm_query=${query}&sysparm_limit=${limit}&sysparm_display_value=true`);
|
|
74
|
-
const jobs = response.data.result;
|
|
75
|
-
|
|
76
|
-
const formattedJobs = jobs.map((job) => ({
|
|
77
|
-
sys_id: job.sys_id,
|
|
78
|
-
name: job.name,
|
|
79
|
-
description: job.description,
|
|
80
|
-
active: job.active === 'true',
|
|
81
|
-
run_type: job.run_type,
|
|
82
|
-
run_start: job.run_start,
|
|
83
|
-
run_dayofweek: job.run_dayofweek,
|
|
84
|
-
run_time: job.run_time,
|
|
85
|
-
script: job.script ? '(script present)' : null,
|
|
86
|
-
created_on: job.sys_created_on,
|
|
87
|
-
updated_on: job.sys_updated_on
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
91
|
-
action: 'jobs',
|
|
92
|
-
found: true,
|
|
93
|
-
count: formattedJobs.length,
|
|
94
|
-
jobs: formattedJobs
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function discoverEvents(client, table, nameContains, limit) {
|
|
99
|
-
const queryParts = [];
|
|
100
|
-
if (table) {
|
|
101
|
-
queryParts.push(`table=${table}`);
|
|
102
|
-
}
|
|
103
|
-
if (nameContains) {
|
|
104
|
-
queryParts.push(`event_nameLIKE${nameContains}`);
|
|
105
|
-
}
|
|
106
|
-
const query = queryParts.join('^');
|
|
107
|
-
|
|
108
|
-
const response = await client.get(`/api/now/table/sysevent_register?sysparm_query=${query}&sysparm_limit=${limit}&sysparm_display_value=true`);
|
|
109
|
-
const events = response.data.result;
|
|
110
|
-
|
|
111
|
-
const formattedEvents = events.map((event) => ({
|
|
112
|
-
sys_id: event.sys_id,
|
|
113
|
-
event_name: event.event_name,
|
|
114
|
-
table: event.table || null,
|
|
115
|
-
description: event.description,
|
|
116
|
-
queue: event.queue,
|
|
117
|
-
claimed_by: event.claimed_by || null,
|
|
118
|
-
state: event.state,
|
|
119
|
-
created_on: event.sys_created_on
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
123
|
-
action: 'events',
|
|
124
|
-
found: true,
|
|
125
|
-
count: formattedEvents.length,
|
|
126
|
-
events: formattedEvents
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function discoverSchedules(client, type, nameContains, limit) {
|
|
131
|
-
const queryParts = [];
|
|
132
|
-
if (type) {
|
|
133
|
-
queryParts.push(`type=${type}`);
|
|
134
|
-
}
|
|
135
|
-
if (nameContains) {
|
|
136
|
-
queryParts.push(`nameLIKE${nameContains}`);
|
|
137
|
-
}
|
|
138
|
-
const query = queryParts.join('^');
|
|
139
|
-
|
|
140
|
-
const response = await client.get(`/api/now/table/cmn_schedule?sysparm_query=${query}&sysparm_limit=${limit}&sysparm_display_value=true`);
|
|
141
|
-
const schedules = response.data.result;
|
|
142
|
-
|
|
143
|
-
const formattedSchedules = schedules.map((schedule) => ({
|
|
144
|
-
sys_id: schedule.sys_id,
|
|
145
|
-
name: schedule.name,
|
|
146
|
-
description: schedule.description,
|
|
147
|
-
type: schedule.type,
|
|
148
|
-
time_zone: schedule.time_zone,
|
|
149
|
-
parent_schedule: schedule.parent?.display_value || null,
|
|
150
|
-
created_on: schedule.sys_created_on,
|
|
151
|
-
updated_on: schedule.sys_updated_on
|
|
152
|
-
}));
|
|
153
|
-
|
|
154
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
155
|
-
action: 'schedules',
|
|
156
|
-
found: true,
|
|
157
|
-
count: formattedSchedules.length,
|
|
158
|
-
schedules: formattedSchedules
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
exports.version = '1.0.0';
|
|
163
|
-
exports.author = 'Snow-Flow MCP Optimization';
|
|
164
|
-
//# sourceMappingURL=snow_automation_discover.js.map
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* snow_artifact_transfer - Unified Artifact Import/Export
|
|
4
|
-
*
|
|
5
|
-
* Replaces: snow_export_artifact, snow_import_artifact
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.author = exports.version = exports.toolDefinition = void 0;
|
|
42
|
-
exports.execute = execute;
|
|
43
|
-
const auth_js_1 = require("../../shared/auth.js");
|
|
44
|
-
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
45
|
-
const fs = __importStar(require("fs/promises"));
|
|
46
|
-
|
|
47
|
-
exports.toolDefinition = {
|
|
48
|
-
name: 'snow_artifact_transfer',
|
|
49
|
-
description: 'Transfer artifacts: export to JSON/XML, import from files',
|
|
50
|
-
category: 'development',
|
|
51
|
-
subcategory: 'deployment',
|
|
52
|
-
use_cases: ['deployment', 'backup', 'migration', 'version-control'],
|
|
53
|
-
complexity: 'intermediate',
|
|
54
|
-
frequency: 'high',
|
|
55
|
-
related_tools: ['snow_deploy', 'snow_update', 'snow_validate_deployment'],
|
|
56
|
-
inputSchema: {
|
|
57
|
-
type: 'object',
|
|
58
|
-
properties: {
|
|
59
|
-
action: {
|
|
60
|
-
type: 'string',
|
|
61
|
-
enum: ['export', 'import'],
|
|
62
|
-
description: 'Transfer action: export or import'
|
|
63
|
-
},
|
|
64
|
-
type: {
|
|
65
|
-
type: 'string',
|
|
66
|
-
enum: ['widget', 'application', 'script', 'business_rule', 'table'],
|
|
67
|
-
description: 'Artifact type'
|
|
68
|
-
},
|
|
69
|
-
sys_id: {
|
|
70
|
-
type: 'string',
|
|
71
|
-
description: 'Sys ID (required for export)'
|
|
72
|
-
},
|
|
73
|
-
file_path: {
|
|
74
|
-
type: 'string',
|
|
75
|
-
description: 'File path (required for import)'
|
|
76
|
-
},
|
|
77
|
-
format: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
enum: ['json', 'xml', 'update_set'],
|
|
80
|
-
default: 'json',
|
|
81
|
-
description: 'Export/import format'
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
required: ['action', 'type']
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
async function execute(args, context) {
|
|
89
|
-
const { action, type, sys_id, file_path, format = 'json' } = args;
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
const client = await (0, auth_js_1.getAuthenticatedClient)(context);
|
|
93
|
-
|
|
94
|
-
switch (action) {
|
|
95
|
-
case 'export':
|
|
96
|
-
if (!sys_id) {
|
|
97
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, 'sys_id is required for export action', { retryable: false });
|
|
98
|
-
}
|
|
99
|
-
return await exportArtifact(client, type, sys_id, format);
|
|
100
|
-
case 'import':
|
|
101
|
-
if (!file_path) {
|
|
102
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, 'file_path is required for import action', { retryable: false });
|
|
103
|
-
}
|
|
104
|
-
return await importArtifact(client, type, file_path, format);
|
|
105
|
-
default:
|
|
106
|
-
return (0, error_handler_js_1.createErrorResult)(`Unknown action: ${action}`);
|
|
107
|
-
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
return (0, error_handler_js_1.createErrorResult)(error instanceof error_handler_js_1.SnowFlowError
|
|
110
|
-
? error
|
|
111
|
-
: new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.NETWORK_ERROR, `Transfer failed: ${error.message}`, { originalError: error }));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function exportArtifact(client, type, sys_id, format) {
|
|
116
|
-
const tableMap = {
|
|
117
|
-
widget: 'sp_widget',
|
|
118
|
-
application: 'sys_app',
|
|
119
|
-
script: 'sys_script_include',
|
|
120
|
-
business_rule: 'sys_script',
|
|
121
|
-
table: 'sys_db_object'
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const tableName = tableMap[type];
|
|
125
|
-
if (!tableName) {
|
|
126
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, `Unsupported artifact type: ${type}`, { retryable: false });
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const response = await client.get(`/api/now/table/${tableName}/${sys_id}`);
|
|
130
|
-
const artifact = response.data.result;
|
|
131
|
-
|
|
132
|
-
if (!artifact) {
|
|
133
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.RESOURCE_NOT_FOUND, `Artifact not found: ${sys_id}`, { retryable: false });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
let exportedData;
|
|
137
|
-
switch (format) {
|
|
138
|
-
case 'json':
|
|
139
|
-
exportedData = {
|
|
140
|
-
type,
|
|
141
|
-
sys_id: artifact.sys_id,
|
|
142
|
-
name: artifact.name || artifact.id,
|
|
143
|
-
exported_at: new Date().toISOString(),
|
|
144
|
-
data: artifact
|
|
145
|
-
};
|
|
146
|
-
break;
|
|
147
|
-
case 'xml':
|
|
148
|
-
exportedData = artifactToXML(artifact, type);
|
|
149
|
-
break;
|
|
150
|
-
case 'update_set':
|
|
151
|
-
const updateSetResponse = await client.get('/api/now/table/sys_update_xml', {
|
|
152
|
-
params: {
|
|
153
|
-
sysparm_query: `target_name=${artifact.sys_id}`,
|
|
154
|
-
sysparm_limit: 10
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
exportedData = {
|
|
158
|
-
type,
|
|
159
|
-
sys_id: artifact.sys_id,
|
|
160
|
-
name: artifact.name || artifact.id,
|
|
161
|
-
update_sets: updateSetResponse.data.result
|
|
162
|
-
};
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, `Unsupported format: ${format}`, { retryable: false });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
169
|
-
action: 'export',
|
|
170
|
-
artifact: exportedData,
|
|
171
|
-
format,
|
|
172
|
-
table: tableName,
|
|
173
|
-
sys_id,
|
|
174
|
-
name: artifact.name || artifact.id,
|
|
175
|
-
message: `✅ Artifact exported successfully (${type}, ${format})`
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async function importArtifact(client, type, file_path, format) {
|
|
180
|
-
const fileContent = await fs.readFile(file_path, 'utf-8');
|
|
181
|
-
let artifactData;
|
|
182
|
-
|
|
183
|
-
switch (format) {
|
|
184
|
-
case 'json':
|
|
185
|
-
artifactData = JSON.parse(fileContent);
|
|
186
|
-
if (artifactData.data) {
|
|
187
|
-
artifactData = artifactData.data;
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case 'xml':
|
|
191
|
-
artifactData = parseSimpleXML(fileContent);
|
|
192
|
-
break;
|
|
193
|
-
case 'update_set':
|
|
194
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, 'Update set import requires XML format and should use snow_import_update_set tool', { retryable: false });
|
|
195
|
-
default:
|
|
196
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, `Unsupported format: ${format}`, { retryable: false });
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const tableMap = {
|
|
200
|
-
widget: 'sp_widget',
|
|
201
|
-
application: 'sys_app',
|
|
202
|
-
script: 'sys_script_include',
|
|
203
|
-
business_rule: 'sys_script',
|
|
204
|
-
table: 'sys_db_object'
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const tableName = tableMap[type];
|
|
208
|
-
if (!tableName) {
|
|
209
|
-
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.INVALID_REQUEST, `Unsupported artifact type: ${type}`, { retryable: false });
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const cleanedData = { ...artifactData };
|
|
213
|
-
delete cleanedData.sys_id;
|
|
214
|
-
delete cleanedData.sys_created_on;
|
|
215
|
-
delete cleanedData.sys_created_by;
|
|
216
|
-
delete cleanedData.sys_updated_on;
|
|
217
|
-
delete cleanedData.sys_updated_by;
|
|
218
|
-
delete cleanedData.sys_mod_count;
|
|
219
|
-
|
|
220
|
-
const existingResponse = await client.get(`/api/now/table/${tableName}`, {
|
|
221
|
-
params: {
|
|
222
|
-
sysparm_query: `name=${cleanedData.name || cleanedData.id}`,
|
|
223
|
-
sysparm_limit: 1
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
let result;
|
|
228
|
-
if (existingResponse.data.result.length > 0) {
|
|
229
|
-
const existingSysId = existingResponse.data.result[0].sys_id;
|
|
230
|
-
const updateResponse = await client.put(`/api/now/table/${tableName}/${existingSysId}`, cleanedData);
|
|
231
|
-
result = {
|
|
232
|
-
action: 'import',
|
|
233
|
-
operation: 'updated',
|
|
234
|
-
sys_id: existingSysId,
|
|
235
|
-
artifact: updateResponse.data.result,
|
|
236
|
-
message: `✅ Artifact updated successfully (${type})`
|
|
237
|
-
};
|
|
238
|
-
} else {
|
|
239
|
-
const createResponse = await client.post(`/api/now/table/${tableName}`, cleanedData);
|
|
240
|
-
result = {
|
|
241
|
-
action: 'import',
|
|
242
|
-
operation: 'created',
|
|
243
|
-
sys_id: createResponse.data.result.sys_id,
|
|
244
|
-
artifact: createResponse.data.result,
|
|
245
|
-
message: `✅ Artifact created successfully (${type})`
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return (0, error_handler_js_1.createSuccessResult)(result);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function artifactToXML(artifact, type) {
|
|
253
|
-
const xmlParts = ['<?xml version="1.0" encoding="UTF-8"?>'];
|
|
254
|
-
xmlParts.push(`<${type}>`);
|
|
255
|
-
for (const [key, value] of Object.entries(artifact)) {
|
|
256
|
-
if (value !== null && value !== undefined) {
|
|
257
|
-
const escaped = String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
258
|
-
xmlParts.push(` <${key}>${escaped}</${key}>`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
xmlParts.push(`</${type}>`);
|
|
262
|
-
return xmlParts.join('\n');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function parseSimpleXML(xml) {
|
|
266
|
-
const result = {};
|
|
267
|
-
const tagRegex = /<(\w+)>([^<]*)<\/\1>/g;
|
|
268
|
-
let match;
|
|
269
|
-
while ((match = tagRegex.exec(xml)) !== null) {
|
|
270
|
-
const key = match[1];
|
|
271
|
-
const value = match[2]
|
|
272
|
-
.replace(/</g, '<')
|
|
273
|
-
.replace(/>/g, '>')
|
|
274
|
-
.replace(/&/g, '&');
|
|
275
|
-
result[key] = value;
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
exports.version = '1.0.0';
|
|
281
|
-
exports.author = 'Snow-Flow MCP Optimization';
|
|
282
|
-
//# sourceMappingURL=snow_artifact_transfer.js.map
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* snow_build_filter - Build ServiceNow query filters
|
|
4
|
-
*
|
|
5
|
-
* Unified tool for building encoded query filters: date filters, field filters, and complex queries.
|
|
6
|
-
* Replaces: snow_date_filter, snow_field_filter, snow_query_filter
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.author = exports.version = exports.toolDefinition = void 0;
|
|
10
|
-
exports.execute = execute;
|
|
11
|
-
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
12
|
-
exports.toolDefinition = {
|
|
13
|
-
name: 'snow_build_filter',
|
|
14
|
-
description: 'Build ServiceNow query filters: date, field, complex queries',
|
|
15
|
-
// Metadata for tool discovery (not sent to LLM)
|
|
16
|
-
category: 'utilities',
|
|
17
|
-
subcategory: 'query-building',
|
|
18
|
-
use_cases: ["query-building", "filtering", "data-retrieval"],
|
|
19
|
-
complexity: 'beginner',
|
|
20
|
-
frequency: 'very-high',
|
|
21
|
-
inputSchema: {
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: {
|
|
24
|
-
filter_type: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
enum: ['date', 'field', 'query'],
|
|
27
|
-
description: 'Filter type: date, field, or query'
|
|
28
|
-
},
|
|
29
|
-
// Common
|
|
30
|
-
field: {
|
|
31
|
-
type: 'string',
|
|
32
|
-
description: 'Field name (date/field filters)'
|
|
33
|
-
},
|
|
34
|
-
// Date filter-specific
|
|
35
|
-
relative: {
|
|
36
|
-
type: 'string',
|
|
37
|
-
enum: ['today', 'yesterday', 'thisWeek', 'lastWeek', 'thisMonth', 'lastMonth'],
|
|
38
|
-
description: 'Relative date (date filter only)'
|
|
39
|
-
},
|
|
40
|
-
start_date: {
|
|
41
|
-
type: 'string',
|
|
42
|
-
description: 'Start date YYYY-MM-DD (date filter only)'
|
|
43
|
-
},
|
|
44
|
-
end_date: {
|
|
45
|
-
type: 'string',
|
|
46
|
-
description: 'End date YYYY-MM-DD (date filter only)'
|
|
47
|
-
},
|
|
48
|
-
// Field filter-specific
|
|
49
|
-
values: {
|
|
50
|
-
type: 'array',
|
|
51
|
-
items: { type: 'string' },
|
|
52
|
-
description: 'Values to filter (field filter only)'
|
|
53
|
-
},
|
|
54
|
-
match_type: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
enum: ['exact', 'contains', 'startsWith', 'endsWith'],
|
|
57
|
-
description: 'Match type (field filter only)',
|
|
58
|
-
default: 'exact'
|
|
59
|
-
},
|
|
60
|
-
// Query filter-specific
|
|
61
|
-
conditions: {
|
|
62
|
-
type: 'array',
|
|
63
|
-
items: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: {
|
|
66
|
-
field: { type: 'string' },
|
|
67
|
-
operator: { type: 'string', enum: ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'IN', 'STARTSWITH', 'ENDSWITH'] },
|
|
68
|
-
value: { type: 'string' }
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
description: 'Filter conditions (query filter only)'
|
|
72
|
-
},
|
|
73
|
-
logic: {
|
|
74
|
-
type: 'string',
|
|
75
|
-
enum: ['AND', 'OR'],
|
|
76
|
-
description: 'Condition logic (query filter only)',
|
|
77
|
-
default: 'AND'
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
required: ['filter_type']
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
async function execute(args, context) {
|
|
84
|
-
const { filter_type } = args;
|
|
85
|
-
try {
|
|
86
|
-
switch (filter_type) {
|
|
87
|
-
case 'date':
|
|
88
|
-
return buildDateFilter(args);
|
|
89
|
-
case 'field':
|
|
90
|
-
return buildFieldFilter(args);
|
|
91
|
-
case 'query':
|
|
92
|
-
return buildQueryFilter(args);
|
|
93
|
-
default:
|
|
94
|
-
return (0, error_handler_js_1.createErrorResult)(`Invalid filter_type: ${filter_type}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
return (0, error_handler_js_1.createErrorResult)(error.message);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function buildDateFilter(args) {
|
|
102
|
-
const { field, relative, start_date, end_date } = args;
|
|
103
|
-
if (!field) {
|
|
104
|
-
return (0, error_handler_js_1.createErrorResult)('field is required for date filter');
|
|
105
|
-
}
|
|
106
|
-
let query = '';
|
|
107
|
-
if (relative) {
|
|
108
|
-
const relativeQueries = {
|
|
109
|
-
'today': `${field}ON Today`,
|
|
110
|
-
'yesterday': `${field}ON Yesterday`,
|
|
111
|
-
'thisWeek': `${field}ON This week`,
|
|
112
|
-
'lastWeek': `${field}ON Last week`,
|
|
113
|
-
'thisMonth': `${field}ON This month`,
|
|
114
|
-
'lastMonth': `${field}ON Last month`
|
|
115
|
-
};
|
|
116
|
-
query = relativeQueries[relative] || '';
|
|
117
|
-
}
|
|
118
|
-
else if (start_date && end_date) {
|
|
119
|
-
query = `${field}BETWEEN${start_date}@${end_date}`;
|
|
120
|
-
}
|
|
121
|
-
else if (start_date) {
|
|
122
|
-
query = `${field}>=${start_date}`;
|
|
123
|
-
}
|
|
124
|
-
else if (end_date) {
|
|
125
|
-
query = `${field}<=${end_date}`;
|
|
126
|
-
}
|
|
127
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
128
|
-
query,
|
|
129
|
-
field,
|
|
130
|
-
type: relative ? 'relative' : 'absolute'
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
function buildFieldFilter(args) {
|
|
134
|
-
const { field, values, match_type = 'exact' } = args;
|
|
135
|
-
if (!field) {
|
|
136
|
-
return (0, error_handler_js_1.createErrorResult)('field is required for field filter');
|
|
137
|
-
}
|
|
138
|
-
if (!values || values.length === 0) {
|
|
139
|
-
return (0, error_handler_js_1.createErrorResult)('values are required for field filter');
|
|
140
|
-
}
|
|
141
|
-
const operatorMap = {
|
|
142
|
-
'exact': '=',
|
|
143
|
-
'contains': 'LIKE',
|
|
144
|
-
'startsWith': 'STARTSWITH',
|
|
145
|
-
'endsWith': 'ENDSWITH'
|
|
146
|
-
};
|
|
147
|
-
const operator = operatorMap[match_type];
|
|
148
|
-
const query = values.map(val => `${field}${operator}${val}`).join('^OR');
|
|
149
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
150
|
-
query,
|
|
151
|
-
field,
|
|
152
|
-
match_type,
|
|
153
|
-
value_count: values.length
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
function buildQueryFilter(args) {
|
|
157
|
-
const { conditions, logic = 'AND' } = args;
|
|
158
|
-
if (!conditions || conditions.length === 0) {
|
|
159
|
-
return (0, error_handler_js_1.createErrorResult)('conditions are required for query filter');
|
|
160
|
-
}
|
|
161
|
-
const separator = logic === 'AND' ? '^' : '^OR';
|
|
162
|
-
const query = conditions.map((cond) => `${cond.field}${cond.operator}${cond.value}`).join(separator);
|
|
163
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
164
|
-
query,
|
|
165
|
-
conditions: conditions.length,
|
|
166
|
-
logic
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
exports.version = '1.0.0';
|
|
170
|
-
exports.author = 'Snow-Flow v8.2.0';
|
|
171
|
-
//# sourceMappingURL=snow_build_filter.js.map
|