# Randomized KVK scrape -> global_companies_registry via Athena (Dexter client).
# Uses the dexter-sentinel Rust binary `dexter-scrape` (not Python).
# Usage: set ATHENA_API_KEY, repo root as cwd, then:
#   pwsh -File scripts/example_kvk_nl_randomized.ps1

$ErrorActionPreference = "Stop"
$scriptDir = $PSScriptRoot
$root = Split-Path -Parent $scriptDir

if (-not $env:ATHENA_API_KEY) {
    Write-Error "Set ATHENA_API_KEY (or pass a key via pipeline env)."
    exit 1
}

Push-Location $root
try {
    cargo run --release --bin dexter-scrape -- `
        --athena-url="https://cluster.athena-db.com" `
        --athena-key="$env:ATHENA_API_KEY" `
        --athena-client="dexter" `
        --country-code="NL" `
        --search-engine="kvk" `
        --randomize-query `
        --max-query-length="3"
}
finally {
    Pop-Location
}
