import type { Explain } from '../../core/explain' import type { AccessControl, IamPrimitives } from '../../core/types' import type { IamMetrics } from '../../observability/metrics' /** * Minimal engine surface the devtool relies on. Lets consumers pass any * concrete `Engine<...>` without variance issues. */ export interface IamIDevtoolsEngine { can( subjectId: string, action: string, resource: { type: string; id?: string; attributes?: Record }, environment?: Record, ): Promise explain( subjectId: string, action: string, resource: { type: string; id?: string; attributes?: Record }, environment?: Record, ): Promise stats(): Record resetStats(): void admin: { listPolicies(): Promise listRoles(): Promise getPolicy(id: string): Promise getRole(id: string): Promise assignRole(subjectId: string, roleId: string, scope?: string): Promise revokeRole(subjectId: string, roleId: string, scope?: string): Promise setAttributes(subjectId: string, attrs: IamPrimitives.Attributes): Promise getAttributes(subjectId: string): Promise export(): Promise } } export interface IamIDevtoolsMetrics { snapshot(): IamMetrics.ISnapshot reset(): void } export interface IamIDecisionInput { subjectId: string action: string resourceType: string resourceId: string attributesJson: string environmentJson: string scope: string } export type IamPanelKey = 'flow' | 'decision' | 'policies' | 'roles' | 'subjects' | 'metrics'