diff --git a/src/services/workflow-service.js b/src/services/workflow-service.js index 2545205..df010f6 100644 --- a/src/services/workflow-service.js +++ b/src/services/workflow-service.js @@ -92,9 +92,12 @@ async function fetchAllWorkflows() { } /** - * Search workflows by query string - * @param {string} query - Search query (matches name, description, etc.) - * @param {string|null} category - Optional category filter + * Search workflows by query string. + * Real AD keys (lowercase, cf. D5): id, name, version, applicationName, + * commonInfo — no description/code/category field exists. + * @param {string} query - Search query (matches workflow name) + * @param {string|null} category - Optional applicationName filter (the only + * grouping the AD API provides) * @param {number} limit - Maximum results to return */ async function searchWorkflows(query, category = null, limit = 50) { @@ -107,21 +110,16 @@ async function searchWorkflows(query, category = null, limit = 50) { const lowerQuery = query.toLowerCase(); results = results.filter(w => { const name = (w.name || w.Name || '').toLowerCase(); - const description = (w.description || w.Description || '').toLowerCase(); - const code = (w.code || w.Code || '').toLowerCase(); - - return name.includes(lowerQuery) || - description.includes(lowerQuery) || - code.includes(lowerQuery); + return name.includes(lowerQuery); }); } - // Filter by category if provided + // Filter by applicationName if provided if (category) { const lowerCategory = category.toLowerCase(); results = results.filter(w => { - const wfCategory = (w.category || w.Category || '').toLowerCase(); - return wfCategory.includes(lowerCategory); + const applicationName = (w.applicationName || w.ApplicationName || '').toLowerCase(); + return applicationName.includes(lowerCategory); }); } @@ -156,17 +154,19 @@ async function getWorkflowDetails(workflowId) { } /** - * List all workflow categories + * List distinct applicationName values. + * Workflows have no category field — applicationName is the only grouping the + * AD API provides, and every workflow of the active application carries the + * same value (e.g. "EasyWMS"). */ async function listWorkflowCategories() { const workflows = await fetchAllWorkflows(); - // Extract unique categories (try both lowercase and uppercase) const categories = new Set(); workflows.forEach(w => { - const category = w.category || w.Category; - if (category) { - categories.add(category); + const applicationName = w.applicationName || w.ApplicationName; + if (applicationName) { + categories.add(applicationName); } }); @@ -181,10 +181,10 @@ async function getWorkflowStats() { const workflows = await fetchAllWorkflows(); const categories = await listWorkflowCategories(); - // Count workflows per category + // Count workflows per applicationName (the only grouping in the data) const categoryCounts = {}; workflows.forEach(w => { - const cat = w.category || w.Category || 'Uncategorized'; + const cat = w.applicationName || w.ApplicationName || '(unknown)'; categoryCounts[cat] = (categoryCounts[cat] || 0) + 1; }); diff --git a/src/tools/workflow-tools.js b/src/tools/workflow-tools.js index 1f36f14..2b12f76 100644 --- a/src/tools/workflow-tools.js +++ b/src/tools/workflow-tools.js @@ -18,11 +18,11 @@ function listTools() { properties: { query: { type: 'string', - description: 'Search query (searches in name, description, code)', + description: 'Search query (searches in workflow name)', }, category: { type: 'string', - description: 'Filter by workflow category/application', + description: 'Filter by applicationName — the only grouping the AD API provides (workflows have no category field). All workflows of the active application share the same value (e.g. "EasyWMS").', }, limit: { type: 'number', @@ -48,7 +48,7 @@ function listTools() { }, { name: 'list_workflow_categories', - description: 'List all available workflow categories', + description: 'List workflow groupings by applicationName. Workflows have no category field in the AD API — applicationName is the only grouping available, and all workflows of the active application share the same value.', inputSchema: { type: 'object', properties: {}, @@ -107,16 +107,20 @@ async function searchWorkflows(args) { text: JSON.stringify({ success: true, count: results.length, - workflows: results.map(w => ({ - id: w.Id, - code: w.Code, - name: w.Name, - category: w.Category, - description: w.Description, - version: w.Version, - created: w.Created, - modified: w.Modified - })) + // Clés réelles de l'API AD (minuscules, cf. D5) : id, name, version, + // applicationName, commonInfo. Pas de code/category/description. + workflows: results.map(w => { + const commonInfo = w.commonInfo || w.CommonInfo || {}; + return { + id: w.id || w.Id, + name: w.name || w.Name, + applicationName: w.applicationName || w.ApplicationName, + version: w.version || w.Version, + createdBy: commonInfo.createdBy, + createDate: commonInfo.createDate, + updateDate: commonInfo.updateDate + }; + }) }, null, 2) }] }; @@ -157,6 +161,7 @@ async function listWorkflowCategories(args) { type: 'text', text: JSON.stringify({ success: true, + note: 'Workflows have no category field in the AD API — these are the distinct applicationName values, the only grouping available. All workflows of the active application share the same value.', totalCategories: categories.length, categories, stats: {