#!/bin/bash set -euo pipefail cd /opt/ai-fresh-delivery/server TOKEN=$(curl -sS -m 10 -X POST 'http://127.0.0.1:3001/api/auth/token' \ -H 'Content-Type: application/json' \ --data-raw "$(printf '{"email":"%s","password":"%s"}' "${SUPERADMIN_EMAIL:-superadmin@meoo.local}" "$SUPERADMIN_PASSWORD")" | node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).access_token") ID=$(curl -sS -m 10 "http://127.0.0.1:3001/api/data/query" \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ --data-raw '{"table":"system_configs","action":"select","select":"id,config_key,config_value","filters":[{"column":"config_key","op":"eq","value":"loss_threshold_default"}],"single":true}' \ | node -pe "JSON.parse(require('fs').readFileSync(0,'utf8')).data.id") echo "id=$ID" echo "update test:" curl -sS -m 10 "http://127.0.0.1:3001/api/data/query" \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ --data-raw "{\"table\":\"system_configs\",\"action\":\"update\",\"updateData\":{\"config_value\":{\"value\":6.5},\"updated_at\":\"2026-06-07T10:00:00.000Z\"},\"filters\":[{\"column\":\"id\",\"op\":\"eq\",\"value\":\"$ID\"}],\"single\":true}" echo echo "read back:" curl -sS -m 10 "http://127.0.0.1:3001/api/data/query" \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ --data-raw "{\"table\":\"system_configs\",\"action\":\"select\",\"select\":\"config_value\",\"filters\":[{\"column\":\"id\",\"op\":\"eq\",\"value\":\"$ID\"}],\"single\":true}" echo