#!/bin/bash
# check-memory-table.sh - Test NocoDB memory table access
# Uses vault cache for fast token retrieval

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/../vault-env.sh"

NOCODB_TOKEN=$(vault_nocodb_token)

if [ -z "$NOCODB_TOKEN" ]; then
    echo "Error: Could not retrieve NocoDB token from vault cache"
    echo "Run: ${SCRIPT_DIR}/../vault-cache.sh sync"
    exit 1
fi

echo "Token: ${NOCODB_TOKEN:0:20}..."

# Test ai_data_Memory table
echo "=== Test ai_data_Memory table (mx149yctebfwvys) ==="
curl -s "http://192.168.25.5:8080/api/v2/tables/mx149yctebfwvys/records" \
  -H "xc-token: $NOCODB_TOKEN"
