feat: add msglib readonly sidecar
This commit is contained in:
81
scripts/verify-msglib-sidecar.ps1
Normal file
81
scripts/verify-msglib-sidecar.ps1
Normal file
@@ -0,0 +1,81 @@
|
||||
param(
|
||||
[string]$SidecarExe = "runs/msglib-sidecar/MsgLibReadSidecar.exe",
|
||||
[string]$SQLiteDllPath = $env:ISPHERE_MSGLIB_SQLITE_DLL,
|
||||
[string]$DbPath = $env:ISPHERE_MSGLIB_DB,
|
||||
[switch]$SkipBuild
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
||||
$sidecarPath = Join-Path $repo $SidecarExe
|
||||
|
||||
function Invoke-SidecarJson([hashtable]$Request) {
|
||||
$json = $Request | ConvertTo-Json -Depth 10 -Compress
|
||||
$output = $json | & $sidecarPath
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "sidecar exited with code $LASTEXITCODE"
|
||||
}
|
||||
try {
|
||||
return $output | ConvertFrom-Json
|
||||
}
|
||||
catch {
|
||||
throw "sidecar output was not JSON: $output"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $SkipBuild) {
|
||||
& powershell -NoProfile -ExecutionPolicy Bypass -File (Join-Path $repo "scripts\build-msglib-sidecar.ps1") | Out-Host
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "build-msglib-sidecar.ps1 failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sidecarPath)) {
|
||||
throw "sidecar not found: $sidecarPath"
|
||||
}
|
||||
|
||||
$self = Invoke-SidecarJson @{
|
||||
protocol = "isphere.msglib.v1"
|
||||
request_id = "verify-self-check"
|
||||
op = "self_check"
|
||||
args = @{}
|
||||
}
|
||||
if (-not $self.ok -or $self.data.sidecar_name -ne "MsgLibReadSidecar" -or $self.data.process_bits -ne 32) {
|
||||
throw "self_check failed: $($self | ConvertTo-Json -Depth 8 -Compress)"
|
||||
}
|
||||
|
||||
$providerChecked = $false
|
||||
$displaySources = $null
|
||||
if ($SQLiteDllPath -and $DbPath) {
|
||||
if (-not (Test-Path -LiteralPath $SQLiteDllPath)) {
|
||||
throw "SQLite DLL not found: $SQLiteDllPath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $DbPath)) {
|
||||
throw "MsgLib DB not found: $DbPath"
|
||||
}
|
||||
$displaySources = Invoke-SidecarJson @{
|
||||
protocol = "isphere.msglib.v1"
|
||||
request_id = "verify-display-sources"
|
||||
op = "display_sources"
|
||||
args = @{
|
||||
sqlite_dll_path = $SQLiteDllPath
|
||||
db_path = $DbPath
|
||||
password = "123"
|
||||
include_counts = $true
|
||||
max_tables = 64
|
||||
}
|
||||
}
|
||||
if (-not $displaySources.ok -or -not $displaySources.data.metadata_only -or $displaySources.data.message_body_values_returned) {
|
||||
throw "display_sources failed: $($displaySources | ConvertTo-Json -Depth 12 -Compress)"
|
||||
}
|
||||
$providerChecked = $true
|
||||
}
|
||||
|
||||
[ordered]@{
|
||||
ok = $true
|
||||
sidecar = (Resolve-Path -LiteralPath $sidecarPath).Path
|
||||
version = $self.data.sidecar_version
|
||||
process_bits = $self.data.process_bits
|
||||
provider_checked = $providerChecked
|
||||
display_source_count = if ($displaySources) { $displaySources.data.display_sources.Count } else { 0 }
|
||||
} | ConvertTo-Json -Depth 6 -Compress
|
||||
Reference in New Issue
Block a user