L1.3 : aligne les projections des workflows sur les clés réelles de l'AD

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 <noreply@anthropic.com>
This commit is contained in:
Arthur Ria
2026-08-24 16:45:24 +02:00
parent e0bdc1707d
commit 3a89c317e8
2 changed files with 37 additions and 32 deletions
+19 -19
View File
@@ -92,9 +92,12 @@ async function fetchAllWorkflows() {
} }
/** /**
* Search workflows by query string * Search workflows by query string.
* @param {string} query - Search query (matches name, description, etc.) * Real AD keys (lowercase, cf. D5): id, name, version, applicationName,
* @param {string|null} category - Optional category filter * 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 * @param {number} limit - Maximum results to return
*/ */
async function searchWorkflows(query, category = null, limit = 50) { async function searchWorkflows(query, category = null, limit = 50) {
@@ -107,21 +110,16 @@ async function searchWorkflows(query, category = null, limit = 50) {
const lowerQuery = query.toLowerCase(); const lowerQuery = query.toLowerCase();
results = results.filter(w => { results = results.filter(w => {
const name = (w.name || w.Name || '').toLowerCase(); const name = (w.name || w.Name || '').toLowerCase();
const description = (w.description || w.Description || '').toLowerCase(); return name.includes(lowerQuery);
const code = (w.code || w.Code || '').toLowerCase();
return name.includes(lowerQuery) ||
description.includes(lowerQuery) ||
code.includes(lowerQuery);
}); });
} }
// Filter by category if provided // Filter by applicationName if provided
if (category) { if (category) {
const lowerCategory = category.toLowerCase(); const lowerCategory = category.toLowerCase();
results = results.filter(w => { results = results.filter(w => {
const wfCategory = (w.category || w.Category || '').toLowerCase(); const applicationName = (w.applicationName || w.ApplicationName || '').toLowerCase();
return wfCategory.includes(lowerCategory); 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() { async function listWorkflowCategories() {
const workflows = await fetchAllWorkflows(); const workflows = await fetchAllWorkflows();
// Extract unique categories (try both lowercase and uppercase)
const categories = new Set(); const categories = new Set();
workflows.forEach(w => { workflows.forEach(w => {
const category = w.category || w.Category; const applicationName = w.applicationName || w.ApplicationName;
if (category) { if (applicationName) {
categories.add(category); categories.add(applicationName);
} }
}); });
@@ -181,10 +181,10 @@ async function getWorkflowStats() {
const workflows = await fetchAllWorkflows(); const workflows = await fetchAllWorkflows();
const categories = await listWorkflowCategories(); const categories = await listWorkflowCategories();
// Count workflows per category // Count workflows per applicationName (the only grouping in the data)
const categoryCounts = {}; const categoryCounts = {};
workflows.forEach(w => { workflows.forEach(w => {
const cat = w.category || w.Category || 'Uncategorized'; const cat = w.applicationName || w.ApplicationName || '(unknown)';
categoryCounts[cat] = (categoryCounts[cat] || 0) + 1; categoryCounts[cat] = (categoryCounts[cat] || 0) + 1;
}); });
+18 -13
View File
@@ -18,11 +18,11 @@ function listTools() {
properties: { properties: {
query: { query: {
type: 'string', type: 'string',
description: 'Search query (searches in name, description, code)', description: 'Search query (searches in workflow name)',
}, },
category: { category: {
type: 'string', 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: { limit: {
type: 'number', type: 'number',
@@ -48,7 +48,7 @@ function listTools() {
}, },
{ {
name: 'list_workflow_categories', 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: { inputSchema: {
type: 'object', type: 'object',
properties: {}, properties: {},
@@ -107,16 +107,20 @@ async function searchWorkflows(args) {
text: JSON.stringify({ text: JSON.stringify({
success: true, success: true,
count: results.length, count: results.length,
workflows: results.map(w => ({ // Clés réelles de l'API AD (minuscules, cf. D5) : id, name, version,
id: w.Id, // applicationName, commonInfo. Pas de code/category/description.
code: w.Code, workflows: results.map(w => {
name: w.Name, const commonInfo = w.commonInfo || w.CommonInfo || {};
category: w.Category, return {
description: w.Description, id: w.id || w.Id,
version: w.Version, name: w.name || w.Name,
created: w.Created, applicationName: w.applicationName || w.ApplicationName,
modified: w.Modified version: w.version || w.Version,
})) createdBy: commonInfo.createdBy,
createDate: commonInfo.createDate,
updateDate: commonInfo.updateDate
};
})
}, null, 2) }, null, 2)
}] }]
}; };
@@ -157,6 +161,7 @@ async function listWorkflowCategories(args) {
type: 'text', type: 'text',
text: JSON.stringify({ text: JSON.stringify({
success: true, 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, totalCategories: categories.length,
categories, categories,
stats: { stats: {