Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bindings/nodejs/dts-header.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type PolicyCursorTarget =
| { kind: 'matchValue'; id: string }
| { kind: 'decisionTableHead'; col: string }
| { kind: 'decisionTableCell'; row: string; col: string }
| { kind: 'decisionTableRow'; row: string }
| { kind: 'dataModelName' }
| { kind: 'dataModelProperty'; id: string }
| { kind: 'transformInput' };
Expand Down Expand Up @@ -73,9 +74,16 @@ export type PolicyDiagnosticCode =
| 'REPEATED_DERIVATION'
| 'PREFER_MATCH'
| 'PREFER_DICTIONARY'
| 'REDUNDANT_TABLE_ROW'
| 'NON_DISCRIMINATING_COLUMN'
| 'REDUNDANT_PARENTHESES';
| 'REDUNDANT_PARENTHESES'
| 'UNSATISFIABLE_CELL'
| 'UNREACHABLE_RULE'
| 'DUPLICATE_RULE'
| 'MISSING_CASES'
| 'COMPRESSIBLE_TABLE'
| 'TABLE_CHECKS_INCOMPLETE'
| 'CELL_COVERS_DOMAIN'
| 'OUTPUT_NEVER_PRODUCED';

export type PolicyVariableType =
| { type: 'any' }
Expand Down
17 changes: 15 additions & 2 deletions bindings/nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type PolicyCursorTarget =
| { kind: 'matchValue'; id: string }
| { kind: 'decisionTableHead'; col: string }
| { kind: 'decisionTableCell'; row: string; col: string }
| { kind: 'decisionTableRow'; row: string }
| { kind: 'dataModelName' }
| { kind: 'dataModelProperty'; id: string }
| { kind: 'transformInput' };
Expand Down Expand Up @@ -73,9 +74,16 @@ export type PolicyDiagnosticCode =
| 'REPEATED_DERIVATION'
| 'PREFER_MATCH'
| 'PREFER_DICTIONARY'
| 'REDUNDANT_TABLE_ROW'
| 'NON_DISCRIMINATING_COLUMN'
| 'REDUNDANT_PARENTHESES';
| 'REDUNDANT_PARENTHESES'
| 'UNSATISFIABLE_CELL'
| 'UNREACHABLE_RULE'
| 'DUPLICATE_RULE'
| 'MISSING_CASES'
| 'COMPRESSIBLE_TABLE'
| 'TABLE_CHECKS_INCOMPLETE'
| 'CELL_COVERS_DOMAIN'
| 'OUTPUT_NEVER_PRODUCED';

export type PolicyVariableType =
| { type: 'any' }
Expand Down Expand Up @@ -110,6 +118,10 @@ export type PolicySlotState =
| 'path';
export type PolicySlotRole = 'unary' | 'condition' | 'value' | 'path';
/** One enum value: `label` for display, `source` the ready-to-splice ZEN literal (null when unquotable). */
export interface PolicyChanges {
cursor: number
paths: Array<string>
}
export interface PolicyValueOption {
value: string;
label: string;
Expand Down Expand Up @@ -392,6 +404,7 @@ export declare class Workspace {
isGraph(path: string): boolean
uncheckedNodes(path: string): Array<string>
paths(): Array<string>
changesSince(cursor: number): PolicyChanges
updateBlock(req: PolicyUpdateBlockRequest): void
removeBlock(req: PolicyRemoveBlockRequest): boolean
diagnostics(policyPath: string, maxDiagnostics?: number | undefined | null): Array<PolicyDiagnostic>
Expand Down
15 changes: 15 additions & 0 deletions bindings/nodejs/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ use zen_engine::workspace;

type ResolverRef = FunctionRef<FnArgs<(String, Value)>, Option<String>>;

#[napi(object)]
pub struct PolicyChanges {
pub cursor: i64,
pub paths: Vec<String>,
}

#[napi(object)]
pub struct PolicyExpressionCursor {
pub policy_path: String,
Expand Down Expand Up @@ -626,6 +632,15 @@ impl Workspace {
.collect()
}

#[napi]
pub fn changes_since(&self, cursor: i64) -> PolicyChanges {
let (next, paths) = self.inner.changes_since(cursor.max(0) as u64);
PolicyChanges {
cursor: next as i64,
paths: paths.into_iter().map(|p| p.to_string()).collect(),
}
}

#[napi]
pub fn update_block(&mut self, req: PolicyUpdateBlockRequest) -> napi::Result<()> {
use zen_engine::policy::BlockDoc;
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/test/workspace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe('Workspace graph decision tables', () => {
hitPolicy: 'first',
inputs: [{ id: 'c1', name: 'Age', field: 'age' }],
outputs: [{ id: 'o1', name: 'Score', field: 'score', type: columnType }],
rules: cells.map((cell, i) => ({ _id: `r${i}`, c1: '', o1: cell })),
rules: cells.map((cell, i) => ({ _id: `r${i}`, c1: i === 0 ? '< 18' : '', o1: cell })),
},
},
{ id: 'out', name: 'out', type: 'outputNode', content: {} },
Expand Down
3 changes: 3 additions & 0 deletions core/engine/src/analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub(crate) mod nullable;
pub(crate) mod proof;
pub(crate) mod table;
Loading
Loading