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
* @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;
});
+18 -13
View File
@@ -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: {