/* auto-generated by NAPI-RS */ /* eslint-disable */ export type PolicyPropertyKind = 'input' | 'computed'; export type PolicyFieldKind = 'scalar' | 'enum' | 'relationship' | 'reference'; export type PolicySeverity = 'error' | 'warning' | 'hint'; /** Text range, `[start, end)` byte offsets. */ export type PolicySpan = [number, number]; /** Rename target — a top-level entity, an entity field, or a global property. */ export type PolicyRenameTarget = | { kind: 'entity'; name: string } | { kind: 'field'; entity: string; field: string } | { kind: 'global'; name: string }; /** What kind of span a cursor is sitting in, with any disambiguation. */ export type PolicyCursorTarget = | { kind: 'expression'; id: string } | { kind: 'assertionOutput' } | { kind: 'expressionKey' } | { kind: 'matchTarget' } | { kind: 'matchValue'; id: string } | { kind: 'decisionTableHead'; col: string } | { kind: 'decisionTableCell'; row: string; col: string } | { kind: 'dataModelName' } | { kind: 'dataModelProperty'; id: string }; /** * How an entity field came into existence — declared by a DataModel * (`schema`) or produced by a rule block (`computed`). Computed fields * whose value provably consists of entity instances (identity preserved * through filter / index / slice) carry `instanceOf`. */ export type PolicyFieldOrigin = | { origin: 'schema'; source: string; fieldKind: PolicyFieldKindInfo } | { origin: 'computed'; writtenBy: PolicyPropertyWriter; instanceOf?: PolicyInstanceOf }; export type PolicyDiagnosticCode = | 'UNDEFINED_VARIABLE' | 'TYPE_MISMATCH' | 'INVALID_EXPRESSION' | 'PARSE_ERROR' | 'MISSING_DEFAULT_BRANCH' | 'EMPTY_BLOCK' | 'MIXED_SCOPE' | 'CYCLIC_DEPENDENCY' | 'DUPLICATE_WRITER' | 'INVALID_WRITE_PATH' | 'INPUT_OVERRIDE' | 'SELF_REFERENCING_WRITE' | 'UNREACHABLE_ENTITY_READ' | 'PARTIAL_OBJECT_WRITE' | 'DATA_MODEL_COLLISION' | 'UNKNOWN_DATA_MODEL_TARGET' | 'DUPLICATE_PROPERTY' | 'DUPLICATE_ENUM_VALUE' | 'INVALID_NAME' | 'MAX_DEPTH_EXCEEDED' | 'IMPORT_NOT_FOUND' | 'CIRCULAR_IMPORT' | 'REDUNDANT_NULLISH' | 'REPEATED_DERIVATION' | 'PREFER_MATCH' | 'REDUNDANT_TABLE_ROW' | 'NON_DISCRIMINATING_COLUMN' | 'REDUNDANT_PARENTHESES'; export type PolicyVariableType = | { type: 'any' } | { type: 'null' } | { type: 'bool' } | { type: 'string' } | { type: 'number' } | { type: 'date' } | { type: 'interval' } | { type: 'const'; value: string } | { type: 'enum'; name: string | null; values: string[] } | { type: 'array'; items: PolicyVariableType } | { type: 'object'; fields: Record } | { type: 'nullable'; inner: PolicyVariableType }; /** * Wire-format block — the same shape passed into `setPolicy` / `updateBlock`. * The engine emits these inside `replaceBlock` / `insertBlock` edits so a * host can swap them in by id without text-span surgery. */ export interface PolicyWireBlock { id: string; type: string; props: { dataJson?: string; schemaJson?: string }; } /** * Block-level edit emitted by code-mod operations (rename today; cascade * delete / code-actions / extract-refactor planned). Hosts apply each by * id-keyed swap (same path as `updateBlock` / `removeBlock`). * * - `replaceBlock` — overwrite an existing block's wire content. * - `deleteBlock` — remove a block by id. * - `insertBlock` — append a new block (after `afterBlockId` if given). */ export type PolicyEngineEdit = | { kind: 'replaceBlock'; policyPath: string; blockId: string; newBlock: PolicyWireBlock; } | { kind: 'deleteBlock'; policyPath: string; blockId: string } | { kind: 'insertBlock'; policyPath: string; afterBlockId?: string; newBlock: PolicyWireBlock; }; /** * What kind of usage site a `PolicyReferenceSite` represents. * * - `expressionRead` — a read in an expression body (assertion condition, * decision-table cell, decision-tree statement value). * - `writeKey` — an `entity.field` write target (assertion output, DT * column head, tree statement key). * - `dataModel` — a declaration site in a data-model block (entity name, * property name, or relationship/reference target). */ export type PolicyReferenceKind = 'expressionRead' | 'writeKey' | 'dataModel'; /** * One usage site of a `PolicyRenameTarget` in the workspace, returned by * `references()`. Carries enough context to navigate to the site or render * a "find references" panel. */ export interface PolicyReferenceSite { policyPath: string; blockId: string; expressionId?: string; /** The full original source string this site lives in. */ source: string; /** Character offsets within `source` (LSP-style). */ span: PolicySpan; kind: PolicyReferenceKind; } /** * One node in the transitive dependency tree returned by `dependencies()`. * Each node names a property; `writtenBy` is the block that produces it * (absent for inputs — those are leaves). `deps` is the next layer of the * dependency tree, recursively. Cycles in the dep graph (cut by the * engine's self-edge skip) are protected here too — any revisited node has * empty `deps`. */ export interface PolicyDependencyNode { property: string; writtenBy?: PolicyPropertyWriter; unresolved?: boolean; resolvedType: PolicyVariableType; deps: PolicyDependencyNode[]; } export interface PolicyEvaluationResult { output?: unknown; /** Evaluation duration in microseconds. */ duration?: number; trace?: PolicyTrace; /** Present when a block failed mid-evaluation; `trace` then holds the partial trace up to the failure. */ error?: PolicyEvaluationFailure; } export interface PolicyEvaluationFailure { policyPath: string; blockId: string; expression: string; message: string; } export interface PolicyTrace { engineVersion: string; properties: Record; executions: PolicyBlockExecution[]; } export interface PolicyBlockExecution { blockId: string; policyPath?: string; instancePath?: string; trace: PolicyBlockTrace; operandValues?: Record; writes?: PolicyWriteTrace[]; reads?: string[]; } export interface PolicyWriteTrace { path: string; value: unknown; } export interface PolicyDecisionTableExtras { inputPass: string; } export type PolicyBlockTrace = | { kind: 'assertion'; result: boolean; conditions: { id: string; result: boolean }[]; } | { kind: 'decisionTable'; matchedRows: number[]; evaluations: Record[]; extras?: PolicyDecisionTableExtras; } | { kind: 'expression'; property: string; value: unknown; } | { kind: 'match'; matchedArm?: string; value: unknown; arms: { id: string; result: boolean }[]; };