# DBAOps Sovereign™ — Gold Master verification (build + optional smoke)
# Run from repository root. For smoke: start API first (e.g. npm run start:api), then:
#   $env:API_BASE = "http://127.0.0.1:3041"; .\scripts\verify-release.ps1 -Smoke

param(
    [switch]$Smoke
)

$ErrorActionPreference = "Stop"
$root = (Get-Item $PSScriptRoot).Parent.FullName
Set-Location $root

Write-Host "DBAOps Sovereign™ — Gold Master verification" -ForegroundColor Cyan

& "$PSScriptRoot\build.ps1"

if ($Smoke) {
    $api = if ($env:API_BASE) { $env:API_BASE } else { "http://127.0.0.1:3041" }
    Write-Host "Smoke: API_BASE=$api" -ForegroundColor Gray
    Set-Location "$root\src\api"
    $env:API_BASE = $api
    node .\scripts\smoke-verify.js
    if ($LASTEXITCODE -ne 0) { throw "Smoke verification failed" }
    Set-Location $root
}

Write-Host "Gold Master verification complete." -ForegroundColor Green
