9b95e15cbc
Fichiers hors périmètre ou dupliqués : - suppression des 5 .md dupliqués à la racine (copies md5-identiques de docs/api/ et docs/entities/) - suppression de JANITOR_main.js / JANITOR_entities.json (application Electron sans lien avec le serveur MCP) - suppression de temp/*.json (dumps de workflows versionnés par accident) et ajout de temp/ au .gitignore - suppression de claude_desktop_config_ssh.json : mots de passe en clair et variables ORACLE_* d'une architecture abandonnée - AD_API_TEST_RESULTS.md -> docs/ad-api-validation.md (credentials du snippet remplacés par des variables d'environnement) - suppression d'IMPLEMENTATION_SUMMARY.md, doublon du précédent - queries api.php -> docs/reference-queries-api.php (renommage seul) Code mort : - suppression de src/resources/documentation.js : la resource docs:// n'a jamais été branchée dans src/index.js - suppression de src/config/constants.js : module entièrement inutilisé, requis par wms-query-service.js mais dont aucune constante n'était lue. Emporte RESOURCE_URIS.WORKFLOWS_CATEGORIES, URI déclarée jamais servie. - log-service.js : suppression de findRecentErrors, readFullLog et getLogStats, exportées mais exposées par aucun outil MCP - suppression de LOG_FILE_PATTERN (lue depuis .env, jamais appliquée : le scan filtre sur .log en dur), y compris dans .env.example - log-service.js : préfixe [Logs] sur les messages, comme les autres modules Secrets : - test-ad-api.ps1 -> scripts/test-ad-api.ps1, credentials passés en paramètres ou par WMS_USERNAME / WMS_PASSWORD au lieu d'être en dur Build et test : - @yao-pkg/pkg en devDependency, cible node22-win-x64 : npm run build échouait faute de pkg, et node20 n'a pas de binaire prébuilt (bascule sur une compilation de Node qui échoue sans toolchain MSVC) - index.js : le .env est lu à côté de l'exécutable quand le serveur est packagé. Avec un chemin statique, pkg embarquait le .env dans le snapshot, figeant les credentials dans le binaire. - scripts/test-connection.js : npm test pointait sur un fichier absent. Smoke test en lecture seule (OAuth, QueryExecute, QueryScalarExecute, API AD), par profil ou sur tous. Vérifié après nettoyage : 23 outils et 6 resources répondent au handshake MCP, npm test passe 4/4 contre le WMS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
228 lines
6.8 KiB
PHP
228 lines
6.8 KiB
PHP
<?php
|
|
session_start();
|
|
if(!isset($_SESSION['token']))
|
|
{
|
|
echo "logout";
|
|
exit();
|
|
}
|
|
// -- TOKEN REFRESH -- //
|
|
|
|
function token_refresh()
|
|
{
|
|
|
|
$delta = time() - $_SESSION['token_start_time'];
|
|
if ($delta > 1000) // SI DELTA OK POUR REFRESH, REFRESH SINON DEMANDER NOUVEAU TOKEN ET RECOPIER DANS INDEX.PHP !!!!!!!!!!!!!!!!!!
|
|
{
|
|
$ch = curl_init();
|
|
|
|
if($delta < 1190)
|
|
$post_data="grant_type=refresh_token&refresh_token=".$_SESSION['refresh_token'];
|
|
else
|
|
$post_data="grant_type=password&tenant_code=".$_SESSION['tenant']."&username=".$_SESSION['user']."&password=".$_SESSION['pass'];
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, "https://".$_SESSION['ip']."/EasySTS/OAuth/Token");
|
|
curl_setopt($ch, CURLOPT_POST, TRUE);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded' , 'Authorization: Basic R05BOklFNGU3aXFoZHQ='));
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
|
|
|
$data = curl_exec($ch);
|
|
$tab = json_decode($data, true);
|
|
|
|
if(!empty($tab))
|
|
{
|
|
|
|
if(isset($tab["refresh_token"]))
|
|
{
|
|
$refresh_token = $tab["refresh_token"];
|
|
$token = $tab["access_token"];
|
|
}
|
|
else
|
|
{
|
|
if ( ($tab["error"] == "") or empty($tab["error"]) )
|
|
$error = "inconnue";
|
|
else
|
|
$error = $tab["error"];
|
|
header('Location: login.php?fail=true&desc='.urlencode($error));
|
|
exit();
|
|
}
|
|
|
|
if(!empty($refresh_token))
|
|
{
|
|
$_SESSION['refresh_token'] = $refresh_token;
|
|
$_SESSION['token'] = $token;
|
|
$_SESSION['token_start_time'] = time();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// --- DELETE --- //
|
|
|
|
$ch = curl_init();
|
|
|
|
if ($_GET["delete"] == "true") {
|
|
|
|
$action = $_GET['action'];
|
|
//sleep(2);
|
|
|
|
// Préparation query
|
|
|
|
$type = $_GET['type'];
|
|
|
|
if ($type == "Containers") {
|
|
$component = "ComponentId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.ContainerRemoveCommand";
|
|
}
|
|
|
|
if ($type == "Stocks") {
|
|
$component = "StockId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Contracts.Commands.StockRemoveCommand";
|
|
}
|
|
|
|
if ($type == "ProductLocations") {
|
|
$component = "ProductLocationId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Expeditions.Contracts.Commands.ProductLocationRemoveCommand";
|
|
}
|
|
|
|
if ($type== "Tasks") {
|
|
$component = "TaskId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Contracts.Commands.TaskRemoveCommand";
|
|
}
|
|
|
|
if ($type== "Products") {
|
|
$component = "ProductId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.ProductRemoveCommand";
|
|
}
|
|
|
|
if ($type== "Accounts") {
|
|
$component = "AccountId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.AccountRemoveCommand";
|
|
}
|
|
|
|
if ($type== "Suppliers") {
|
|
$component = "SupplierId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.SupplierRemoveCommand";
|
|
}
|
|
|
|
if ($type== "Kits") {
|
|
$component = "KitId";
|
|
if($action == 1)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.KitDeleteCommand";
|
|
if($action == 5)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.KitDisableCommand";
|
|
}
|
|
|
|
if ($type== "Aliases") {
|
|
$component = "AliasId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.AliasRemoveCommand";
|
|
}
|
|
|
|
if ($type== "InboundOrders") {
|
|
$component = "InboundOrderId";
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Receptions.Contracts.Commands.InboundOrderCancelCommandV2";
|
|
|
|
}
|
|
|
|
if ($type== "Receptions") {
|
|
$component = "ReceptionId";
|
|
if($action == 1)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Receptions.Contracts.Commands.ReceptionCancelCommandV2";
|
|
if($action == 2)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Receptions.Contracts.Commands.ReceptionClosingCommandV2";
|
|
if($action == 3)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Receptions.Contracts.Commands.ReceptionRemoveCommand";
|
|
}
|
|
|
|
if ($type== "OutboundOrders") {
|
|
$component = "OutboundOrderId";
|
|
if($action == 1)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Expeditions.Contracts.Commands.OutboundOrderCancelCommand";
|
|
if($action == 2)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Expeditions.Contracts.Commands.OutboundOrderForceCloseCommand";
|
|
if($action == 3)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Expeditions.Contracts.Commands.OutboundOrderArchiveCommand";
|
|
if($action == 4)
|
|
$cmd_name = "Mecalux.ITSW.EasyWMS.Modules.Expeditions.Contracts.Commands.OutboundOrderUnsetCurrentOperationCommand";
|
|
}
|
|
|
|
|
|
|
|
// Récupérer id
|
|
|
|
$query = '{
|
|
"Application": "EasyWMS",
|
|
"QueryType": 1,
|
|
"Expression" : "Context.'.$type.'.Select(z => z.Id)"
|
|
}';
|
|
|
|
|
|
token_refresh();
|
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, "https://".$_SESSION['ip']."/ApplicationService/api/QueryExecute"
|
|
);
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"Content-Type: application/json",
|
|
"Authorization: Bearer " . $_SESSION["token"],
|
|
]);
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
|
|
|
|
$data = curl_exec($ch);
|
|
$tab_data = json_decode($data, true);
|
|
// echo($tab_data['Table']['Rows'][0]['Values']['Column']);
|
|
|
|
|
|
// Commande Delete en boucle
|
|
|
|
curl_setopt(
|
|
$ch, CURLOPT_URL, "https://".$_SESSION['ip']."/ApplicationService/api/CommandExecute"
|
|
);
|
|
token_refresh();
|
|
|
|
foreach ($tab_data["Table"]["Rows"] as $key => $value) {
|
|
|
|
//echo $value["Values"]["Column"]."<br>";
|
|
$cmd_delete =
|
|
'[{
|
|
"Name": "'.$cmd_name.', Mecalux.ITSW.EasyWMS.Modules.Contracts",
|
|
"Properties": {
|
|
"'.$component.'": "' .
|
|
$value["Values"]["Column"] .
|
|
'",
|
|
"ForceDeletionOfEmptyHolderContainer": true
|
|
}
|
|
}]';
|
|
//echo "value : ".$value["Values"]["Column"];
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $cmd_delete);
|
|
|
|
$data_delete = curl_exec($ch);
|
|
$logs[] = $data_delete;
|
|
if($logs)
|
|
{
|
|
foreach ($logs as $key => $value) {
|
|
$pos1 = strpos($logs[$key], '"Message":"');
|
|
$msg = $logs[$key];
|
|
if (!empty($pos1))
|
|
{
|
|
$msg = substr($logs[$key], $pos1+11);
|
|
$pos2 = strpos($msg, '","');
|
|
$msg = substr($msg, 0, $pos2)."\n";
|
|
echo $msg;
|
|
|
|
}
|
|
}
|
|
echo($erreurs);
|
|
}
|
|
}
|
|
}
|
|
?>
|