Commit becb52b
feat(governance): add Governance getPolicyTraces service (#464)
* feat(governance): add Governance getPolicyEvaluationTraces service
Onboards the first method on a new modular Governance service surfacing
the Insights Real-Time Dashboards policy evaluation traces endpoint.
Exposed via `@uipath/uipath-typescript/governance`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(governance): use camelCase traceId in test overrides
`createMockRawPolicyEvaluationTrace({ TraceId: ... })` was a silent no-op
— the `RawPolicyEvaluationTraceItem` field is `traceId` (camelCase),
matching the live API. The PascalCase override was dropped at runtime,
so every item in the "exactly full page" and "round-trip cursor" tests
shared the default `traceId` instead of having a unique one per row.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(governance): rename getPolicyEvaluationTraces to getTraces
Per code review feedback, shorten the public method name. Inside the
`governance` namespace, `getTraces` reads naturally. Cascades the
rename through the type system to keep everything symmetric:
getPolicyEvaluationTraces -> getTraces
PolicyEvaluationTrace -> Trace
PolicyEvaluationTracesGetAllOptions -> TracesGetAllOptions
RawPolicyEvaluationTraceItem -> RawTraceItem
RawPolicyEvaluationTracesResponse -> RawTracesResponse
`PolicyEvaluationResult` (the filter enum) is unchanged — its values
are owned by the AuthZ contract package, not by the SDK naming.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(governance): rename getTraces back to getPolicyTraces
Per follow-up review feedback, `getPolicyTraces` is the agreed name —
shorter than the original `getPolicyEvaluationTraces` but still carries
the 'policy' qualifier so it (a) doesn't collide with the OpenTelemetry
meaning of 'trace' (each row already exposes a `traceId` field) and
(b) leaves room for symmetric `getPolicySummary` / `getOperationSummary`
naming on the remaining two governance endpoints.
Cascades the rename through the type system to keep the surface
symmetric:
getTraces -> getPolicyTraces
Trace -> PolicyTrace
TracesGetAllOptions -> PolicyTracesGetAllOptions
RawTraceItem -> RawPolicyTraceItem
RawTracesResponse -> RawPolicyTracesResponse
`PolicyEvaluationResult` (filter enum) and PascalCase `TraceId`
assertions in tests are unchanged — the former is owned by the AuthZ
contract, the latter is a literal API field name we intentionally
assert is absent.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(governance): drop misleading Snowflake-format mock constants
The mock used `EVALUATION_RESULT_ACTIVE_DENY: 'Active_Deny'`, which is
the *Snowflake column key* (per the request → SQL mapping in the spec),
not anything the API actually returns in the response. The C# DTO is
`string?` with no enum constraint, and the OpenAPI response schema is
just `type: string` with no documented values — so the response value
is genuinely unknown until we can pull live data.
Renames the one used constant to `EVALUATION_RESULT_DENY: 'Deny'`,
which is the most plausible response shape (matches the request-side
`PolicyEvaluationResult` enum that the API does document). Removes
the unused `EVALUATION_RESULT_ACTIVE_ALLOW` constant (zero references).
No assertions depend on this value — the change is cosmetic and
removes a misleading breadcrumb for future readers.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(governance): extract GovernanceFilterOptions base type
Pull endTime and fullOrganization into a shared GovernanceFilterOptions
interface so other governance endpoints can reuse them, and compose it
into PolicyTracesGetAllOptions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(governance): rename PolicyTracesGetAllOptions to PolicyTraceGetAllOptions
Use the singular entity prefix to match the SDK options-type convention
({Entity}GetAllOptions), consistent with TaskGetAllOptions and QueueGetAllOptions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(governance): make raw startTime required and trim internal-types JSDoc
* fix(governance): drop RawPolicyTracesResponse from test mock
Align the mock with the service after removing the named envelope type;
createMockRawPolicyTracesResponse now returns the inline { items } shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(governance): trim implementation detail from service JSDoc
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(governance): clarify trace row description
* docs(governance): trim implementation detail from service JSDoc
* docs(governance): clarify filter value mapping
* docs(governance): trim redundant trace row JSDoc
* docs(governance): clarify getPolicyTraces example comment
* docs(governance): clarify bare-minimum example comment
* refactor(governance): route getPolicyTraces through shared pagination helper
Replace hand-rolled offset pagination in getPolicyTraces with
PaginationHelpers.getAll(), adding a zeroBased offset option to the
shared OFFSET path for 0-based page-number APIs. Type the response
cast as the declared return type instead of `as any`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(governance): expand getPolicyTraces JSDoc summary
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(governance): derive excludeFromPrefix from request keys
Replace the hardcoded POLICY_TRACE_BODY_KEYS list with
Object.keys(apiOptions) so every non-OData body field is exempt from
the $ prefix automatically, with no list to keep in sync.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(governance): clarify getPolicyTraces JSDoc and field descriptions
Describe per-policy row semantics and result ordering, and tighten the
finalEnforcement/policyStatus field docs. Keep service-class and
ServiceModel JSDoc in sync.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(governance): fix run-on sentence in getPolicyTraces JSDoc
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(governance): type policyEvaluationResult as string to match API contract
The API contract defines policyEvaluationResult as a free-form string, so
typing the PolicyTrace response field as the PolicyEvaluationResult enum
over-asserted a shape the contract does not guarantee. The enum is retained
for the evaluationResult filter input, where the constrained value set is
appropriate.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(governance): fix misleading test names for getPolicyTraces
getPolicyTraces passes no transformFn to PaginationHelpers.getAll, so items
flow through untouched (the governance API already returns camelCase).
- Remove the "should transform API fields" integration test: it asserted
PascalCase absence, which passed trivially off the API's native shape rather
than any SDK transform. The honestly-named unit test already covers the real
guarantee (camelCase preserved, no transform).
- Rename three validation unit tests from "should throw ValidationError" to
"should throw error" for pageSize/jumpToPage/cursor — those are thrown as a
plain Error by the pagination helper, not ValidationError. Only the startTime
check throws a real ValidationError, matching the convention in
tests/unit/utils/pagination/helpers.test.ts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(governance): prefix governance types and mocks with Governance, clarify fullOrganization
Namespace the governance surface consistently:
- PolicyTrace -> GovernancePolicyTrace (public)
- PolicyTraceGetAllOptions -> GovernancePolicyTraceGetAllOptions (public)
- RawPolicyTraceItem -> RawGovernancePolicyTraceItem (internal)
- createMockRawPolicyTrace -> createMockRawGovernancePolicyTrace (test mock)
- createMockRawPolicyTracesResponse -> createMockRawGovernancePolicyTracesResponse (test mock)
Also expand the fullOrganization JSDoc to document the tenant-scoped default
and the org-admin/403 behavior for each value (omitted / false / true).
The renamed public types are unreleased (service still in review), so no
backward-compat shim is needed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(governance): link to Automation Ops governance policies guide
Add a reference from the GovernanceServiceModel docs to the Automation Ops
"Define governance policies" guide so users can see how the policies the
service inspects are configured.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(governance): add @default tag to fullOrganization
Document the default value (false — tenant-scoped) with a @default tag so it
renders as a Default Value entry on the GovernanceFilterOptions docs page.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 389671b commit becb52b
25 files changed
Lines changed: 813 additions & 2 deletions
File tree
- docs
- src
- models/governance
- services
- governance
- utils
- constants
- endpoints
- pagination
- tests
- integration
- config
- unit/services/governance
- utils
- constants
- mocks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
197 | 203 | | |
198 | 204 | | |
199 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
178 | 188 | | |
179 | 189 | | |
180 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
211 | 216 | | |
212 | 217 | | |
213 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments