-
Notifications
You must be signed in to change notification settings - Fork 11
feat(governance): add Governance getPolicyTraces service #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
61b61d1
feat(governance): add Governance getPolicyEvaluationTraces service
ashishupadhyay88 540bcac
fix(governance): use camelCase traceId in test overrides
ashishupadhyay88 7c1976d
refactor(governance): rename getPolicyEvaluationTraces to getTraces
ashishupadhyay88 4797e91
refactor(governance): rename getTraces back to getPolicyTraces
ashishupadhyay88 bc0243f
chore(governance): drop misleading Snowflake-format mock constants
ashishupadhyay88 2054b86
refactor(governance): extract GovernanceFilterOptions base type
ashishupadhyay88 37b66bc
refactor(governance): rename PolicyTracesGetAllOptions to PolicyTrace…
ashishupadhyay88 121c015
refactor(governance): make raw startTime required and trim internal-t…
ashishupadhyay88 fb85aac
fix(governance): drop RawPolicyTracesResponse from test mock
ashishupadhyay88 95ececc
docs(governance): trim implementation detail from service JSDoc
ashishupadhyay88 740e8eb
docs(governance): clarify trace row description
ashishupadhyay88 8d3182d
docs(governance): trim implementation detail from service JSDoc
ashishupadhyay88 ae87c19
docs(governance): clarify filter value mapping
ashishupadhyay88 bd4b2e6
docs(governance): trim redundant trace row JSDoc
ashishupadhyay88 47a3c1d
docs(governance): clarify getPolicyTraces example comment
ashishupadhyay88 41080bc
docs(governance): clarify bare-minimum example comment
ashishupadhyay88 13715d0
refactor(governance): route getPolicyTraces through shared pagination…
ashishupadhyay88 8cc9711
docs(governance): expand getPolicyTraces JSDoc summary
ashishupadhyay88 1db3484
fix(governance): derive excludeFromPrefix from request keys
ashishupadhyay88 bb00ebf
docs(governance): clarify getPolicyTraces JSDoc and field descriptions
ashishupadhyay88 fb59b91
docs(governance): fix run-on sentence in getPolicyTraces JSDoc
ashishupadhyay88 4ace5e4
fix(governance): type policyEvaluationResult as string to match API c…
ashishupadhyay88 04b54b8
test(governance): fix misleading test names for getPolicyTraces
ashishupadhyay88 f21b77e
refactor(governance): prefix governance types and mocks with Governan…
ashishupadhyay88 1b5fef2
docs(governance): link to Automation Ops governance policies guide
ashishupadhyay88 fdf3c0d
docs(governance): add @default tag to fullOrganization
ashishupadhyay88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * Raw policy evaluation trace item as returned by API before transformation. | ||
| */ | ||
| export interface RawGovernancePolicyTraceItem { | ||
| tenantId?: string; | ||
| startTime: string; | ||
| finalEnforcement?: string; | ||
| policyId?: string; | ||
| policyEnforcement?: string; | ||
| policyEvaluationResult?: string; | ||
| policyName?: string; | ||
| policyStatus?: string; | ||
| policyEvaluationDetails?: string; | ||
| actorProcessId?: string; | ||
| actorProcessType?: string; | ||
| actorIdentityId?: string; | ||
| resourceId?: string; | ||
| resourceType?: string; | ||
| folderKey?: string; | ||
| traceId?: string; | ||
| processKey?: string; | ||
| jobKey?: string; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import type { | ||
| GovernancePolicyTrace, | ||
| GovernancePolicyTraceGetAllOptions, | ||
| } from './governance.types'; | ||
| import type { | ||
| PaginatedResponse, | ||
| NonPaginatedResponse, | ||
| HasPaginationOptions, | ||
| } from '../../utils/pagination'; | ||
|
|
||
| /** | ||
| * Service for inspecting governance policy enforcement on the UiPath platform. | ||
|
ashishupadhyay88 marked this conversation as resolved.
|
||
| * | ||
| * See [Define governance policies](https://docs.uipath.com/automation-ops/automation-cloud/latest/user-guide/define-governance-policies) | ||
| * for how governance policies are configured in Automation Ops. | ||
| * | ||
| * All methods require the caller to be an organization administrator. | ||
| * | ||
| * ### Usage | ||
| * | ||
| * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) | ||
| * | ||
| * ```typescript | ||
| * import { Governance } from '@uipath/uipath-typescript/governance'; | ||
| * | ||
| * const governance = new Governance(sdk); | ||
| * const traces = await governance.getPolicyTraces(new Date('2024-01-01')); | ||
| * ``` | ||
| */ | ||
| export interface GovernanceServiceModel { | ||
| /** | ||
| * Gets per-policy enforcement decisions across the requested time range. | ||
| * | ||
| * Each result row represents one policy's verdict within a single governance enforcement event. | ||
| * A single user action can produce multiple rows when multiple policies were consulted. | ||
| * Results are ordered by event start time, descending. | ||
| * | ||
| * @param startTime - Inclusive lower bound on the trace start time. | ||
| * @param options - Optional filters and pagination options | ||
| * @returns Promise resolving to {@link NonPaginatedResponse} of {@link GovernancePolicyTrace} | ||
| * without pagination options, or {@link PaginatedResponse} of | ||
| * {@link GovernancePolicyTrace} when pagination options are used. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { Governance, PolicyEvaluationResult } from '@uipath/uipath-typescript/governance'; | ||
| * | ||
| * const governance = new Governance(sdk); | ||
| * | ||
| * // Get all policy traces from the specified start time | ||
| * const recent = await governance.getPolicyTraces(new Date('2024-01-01')); | ||
| * console.log(recent.items.length); | ||
| * | ||
| * // Get all denied decisions across the whole organization | ||
| * const page1 = await governance.getPolicyTraces( | ||
| * new Date('2024-01-01'), | ||
| * { | ||
| * endTime: new Date(), | ||
| * evaluationResult: [PolicyEvaluationResult.Deny, PolicyEvaluationResult.SimulatedDeny], | ||
| * fullOrganization: true, | ||
| * pageSize: 25, | ||
| * }, | ||
| * ); | ||
| * | ||
| * if (page1.hasNextPage) { | ||
| * const page2 = await governance.getPolicyTraces( | ||
| * new Date('2024-01-01'), | ||
| * { cursor: page1.nextCursor }, | ||
| * ); | ||
| * } | ||
| * ``` | ||
| */ | ||
| getPolicyTraces<T extends GovernancePolicyTraceGetAllOptions = GovernancePolicyTraceGetAllOptions>( | ||
| startTime: Date, | ||
| options?: T, | ||
| ): Promise< | ||
| T extends HasPaginationOptions<T> | ||
| ? PaginatedResponse<GovernancePolicyTrace> | ||
| : NonPaginatedResponse<GovernancePolicyTrace> | ||
| >; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| /** | ||
| * Governance Service Types | ||
| * | ||
| * Public types exposed via `@uipath/uipath-typescript/governance`. | ||
| */ | ||
|
|
||
| import { PaginationOptions } from '../../utils/pagination/types'; | ||
|
|
||
| export enum PolicyEvaluationResult { | ||
| /** Active policy permitted the action. */ | ||
| Allow = 'Allow', | ||
| /** Active policy blocked the action. */ | ||
| Deny = 'Deny', | ||
| /** Simulated (NoOp) policy would have permitted the action. */ | ||
| SimulatedAllow = 'SimulatedAllow', | ||
| /** Simulated (NoOp) policy would have blocked the action. */ | ||
| SimulatedDeny = 'SimulatedDeny', | ||
| } | ||
|
|
||
| /** | ||
| * Each trace row represents one policy's verdict within a governance | ||
| * enforcement event. One enforcement event can produce multiple trace rows | ||
| * when multiple policies contributed to the final verdict. | ||
| */ | ||
| export interface GovernancePolicyTrace { | ||
| /** Tenant the trace was recorded in. Present even when `fullOrganization` is `true`. */ | ||
| tenantId?: string; | ||
|
ashishupadhyay88 marked this conversation as resolved.
|
||
| /** The start time of governance enforcement event. */ | ||
| startTime: string; | ||
| /** Final enforcement verdict for the parent governance event. */ | ||
| finalEnforcement?: string; | ||
| /** ID of the policy this trace row evaluates. */ | ||
| policyId?: string; | ||
|
Raina451 marked this conversation as resolved.
|
||
| /** This individual policy's enforcement contribution to the parent verdict. */ | ||
| policyEnforcement?: string; | ||
| /** The outcome of one policy evaluation — whether it allowed or denied the action, and whether that decision was actively enforced or just simulated (NoOp). */ | ||
| policyEvaluationResult?: string; | ||
|
ashishupadhyay88 marked this conversation as resolved.
|
||
| /** Display name of the policy. */ | ||
| policyName?: string; | ||
| /** Enforcement mode of the policy at the time of evaluation. */ | ||
| policyStatus?: string; | ||
|
ashishupadhyay88 marked this conversation as resolved.
ashishupadhyay88 marked this conversation as resolved.
|
||
| /** Opaque details payload describing the evaluation result. */ | ||
| policyEvaluationDetails?: string; | ||
| /** Process or executable that triggered the evaluation. */ | ||
| actorProcessId?: string; | ||
| /** Type of the actor process (e.g. coded agent, RPA process). */ | ||
| actorProcessType?: string; | ||
|
Raina451 marked this conversation as resolved.
|
||
| /** Identity (user/principal) that triggered the evaluation. */ | ||
| actorIdentityId?: string; | ||
| /** Resource being acted on. */ | ||
| resourceId?: string; | ||
| /** Type of the resource being acted on. */ | ||
| resourceType?: string; | ||
| /** Orchestrator folder key associated with the evaluation, if any. */ | ||
| folderKey?: string; | ||
| /** Distributed-tracing ID covering the governance enforcement event. */ | ||
| traceId?: string; | ||
| /** Process key associated with the evaluation, if any. */ | ||
| processKey?: string; | ||
| /** Job key associated with the evaluation, if any. */ | ||
| jobKey?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Common filter options shared across Governance APIs. | ||
| * | ||
| * Holds filters that are not specific to any single governance resource, so | ||
| * other governance endpoints can reuse them. | ||
| */ | ||
| export interface GovernanceFilterOptions { | ||
| /** | ||
| * Inclusive upper bound on trace start time. When omitted, the upper bound | ||
| * is open. | ||
| */ | ||
| endTime?: Date; | ||
| /** | ||
| * Whether to query the whole organization instead of just the current tenant. | ||
| * | ||
| * Defaults to tenant-scoped: | ||
| * - omitted → tenant-scoped (default) | ||
| * - `false` → tenant-scoped (explicit, same result) | ||
| * - `true` → org-wide across all tenants; requires an organization admin, | ||
| * otherwise the request returns 403 | ||
| * | ||
| * @default false | ||
| */ | ||
| fullOrganization?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Filter and pagination options for fetching policy traces. | ||
| * | ||
| * All filters combine with AND semantics. Array filters match any value in | ||
| * the array (OR within a single filter). | ||
| */ | ||
| export type GovernancePolicyTraceGetAllOptions = PaginationOptions & GovernanceFilterOptions & { | ||
| /** Filter by one or more policy evaluation results. */ | ||
|
ashishupadhyay88 marked this conversation as resolved.
|
||
| evaluationResult?: PolicyEvaluationResult[]; | ||
| /** Filter by one or more policy IDs. */ | ||
| policyId?: string[]; | ||
| /** Filter by one or more actor process IDs. */ | ||
| actorProcessId?: string[]; | ||
| /** Filter by one or more actor process types (e.g. coded agent, RPA process). */ | ||
| actorProcessType?: string[]; | ||
| /** Filter by one or more actor identity IDs. */ | ||
| actorIdentityId?: string[]; | ||
| /** Filter by one or more resource IDs. */ | ||
| resourceId?: string[]; | ||
| /** Filter by one or more resource types. */ | ||
| resourceType?: string[]; | ||
| /** Filter by one or more distributed-trace IDs. */ | ||
| traceId?: string[]; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * Governance Types | ||
| * | ||
| * Public type surface for the Governance service. | ||
| */ | ||
|
|
||
| export * from './governance.types'; | ||
| export * from './governance.models'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.