feat(cli): compact table projection for audit-config query (register row 57)
The command passed no `tableProjector`, so `--format table` handed the renderer
an `AuditLogQueryResult` OBJECT. That takes the generic Property/Value branch,
which printed the entire `entries` array as raw JSON inside a single cell. JSON
output was and remains correct, and is the primary format for this command.
Adds `AuditConfigTableProjection`, mirroring `TemplateTableProjection`:
string->string over the raw body, applied only on the table path, returning the
input verbatim when it is not JSON or not a recognised shape so the renderer's
own fallbacks still apply. It unwraps the envelope to a row array — id,
timestamp, user, action, entityType, entityName, entityId — and drops
`afterStateJson`, the full post-change entity snapshot, which is the audit
analogue of template's fat child arrays: one per row fills a terminal.
`bundleImportId` is dropped as mostly-null noise.
`totalCount` would be lost by a plain unwrap, so a truncated page gains a single
trailing row with a `note` cell ("showing 50 of 137 — use --page / --page-size
for the rest"). When the page IS the whole result set the column is not emitted
at all, so a small query's table stays exactly as narrow as its data, and the
note row carries no `id` so it cannot be mistaken for an entry.
A `--detail` flag skips the projection and renders the raw payload, matching
`template list` / `template get` — that plus `--format json` is how to reach
`afterStateJson`. A bare array root is also accepted, so the projection does not
regress if the payload is ever unwrapped upstream or the deprecated `audit-log`
alias meets an older server.
Tests build their fixtures by serialising the REAL AuditLogQueryResult /
AuditLogEntry types, so renaming a server property fails the test instead of
silently blanking a column. CLI README + Component-CLI.md document the table
shape, the omitted fields, and --detail.
This commit is contained in:
@@ -238,7 +238,7 @@ record of admin edits). `audit-log` is a deprecated alias that still works but e
|
||||
warning; migrate scripts to `audit-config`.
|
||||
|
||||
```
|
||||
scadabridge audit-config query [--user <username>] [--entity-type <type>] [--action <action>] [--from <date>] [--to <date>] [--page <n>] [--page-size <n>]
|
||||
scadabridge audit-config query [--user <username>] [--entity-type <type>] [--action <action>] [--from <date>] [--to <date>] [--page <n>] [--page-size <n>] [--detail]
|
||||
```
|
||||
|
||||
The response is an `AuditLogQueryResult` — `{ "entries": [ … ], "totalCount": <n> }`, where
|
||||
@@ -248,6 +248,16 @@ because the handler must not return the repository's `(Entries, TotalCount)` Val
|
||||
`{}` and every query looks empty regardless of how many rows matched. `ManagementActor.SerializeResult`
|
||||
now rejects tuple results outright so the failure mode cannot recur silently.
|
||||
|
||||
JSON is the primary format here and is never altered by the table path. `--format table`
|
||||
applies a compact projection (`AuditConfigTableProjection`) that unwraps the envelope into
|
||||
one row per entry — `id`, `timestamp`, `user`, `action`, `entityType`, `entityName`,
|
||||
`entityId` — and drops `afterStateJson`, the full post-change entity snapshot, since a
|
||||
single one fills the terminal. Without a projector the renderer took its object branch and
|
||||
printed the whole `entries` array as raw JSON inside one `Property`/`Value` cell (register
|
||||
row 57). `totalCount` survives the unwrap as a trailing `note` row, emitted only when the
|
||||
page is a strict subset of the matches. `--detail` skips the projection and renders the
|
||||
raw payload, mirroring `template list`/`template get`.
|
||||
|
||||
The new centralized Audit Log component (#23) is exposed via the `scadabridge audit` group below.
|
||||
|
||||
### Centralized Audit Commands
|
||||
|
||||
Reference in New Issue
Block a user