From 3a89c317e829ca8fe1252ba3ce4089132fcbe9b1 Mon Sep 17 00:00:00 2001 From: Arthur Ria Date: Mon, 24 Aug 2026 16:45:24 +0200 Subject: [PATCH] =?UTF-8?q?L1.3=20:=20aligne=20les=20projections=20des=20w?= =?UTF-8?q?orkflows=20sur=20les=20cl=C3=A9s=20r=C3=A9elles=20de=20l'AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les clés réelles d'un workflow AD (relevées en direct, minuscules, cf. D5) sont : id, name, version, applicationName, commonInfo, data… search_workflows projetait w.Id, w.Code, w.Name, w.Category, w.Description, w.Created, w.Modified — toutes undefined, supprimées par JSON.stringify : 50 objets vides pour un count pourtant correct. La projection porte désormais id, name, applicationName, version, et les équivalents réels de created/modified trouvés dans commonInfo (createdBy, createDate, updateDate). Code et Description n'existent dans aucune casse : non projetés. La notion de catégorie n'a aucun support dans les données : elle est mappée explicitement sur applicationName, seul regroupement fourni par l'API AD — assumé dans les descriptions d'outils et par une note dans la réponse de list_workflow_categories, qui renvoyait 0 catégorie et classait les 4012 workflows en « Uncategorized ». Le paramètre category de search_workflows filtre sur applicationName. Le filtre de recherche ne teste plus description/code, clés inexistantes. Vérifié contre le WMS réel : search_workflows("stacker") renvoie des objets peuplés (StackerCrane_…), list_workflow_categories renvoie EasyWMS avec 4012 workflows, get_workflow_details renvoie toujours l'objet brut complet (data 71 Ko). Co-Authored-By: Claude Opus 5 --- src/services/workflow-service.js | 38 ++++++++++++++++---------------- src/tools/workflow-tools.js | 31 +++++++++++++++----------- 2 files changed, 37 insertions(+), 32 deletions(-) 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: {