1- import jsonLogic , { RulesLogic } from "json-logic-js" ;
1+ import jsonLogic from "json-logic-js" ;
2+ import pathExists from "just-has" ;
23import { PolicyStatementStore } from "./store/types" ;
34import { JsonLogicParser , PolicyDocument , PolicyStatement } from "./types" ;
45import {
56 ParsedPolicyStatement ,
67 parsePolicyStatement ,
78} from "./parsed-policy-statement" ;
8- import { pathExists } from "./utils/obj" ;
99import { PolicyDocumentValidator } from "./validator" ;
1010import { CachedStatementsStore } from "./store/cached-statements-store" ;
11- import { IndexedStatementsStore } from "./store/indexed-statements-store" ;
1211
1312interface ResourceActionResolverOptions {
1413 parser ?: JsonLogicParser ;
@@ -27,7 +26,7 @@ function hasAllPaths(statement: ParsedPolicyStatement, ctx: unknown) {
2726 return false ;
2827 }
2928 return statement . contextPaths . every ( ( path ) =>
30- pathExists ( ctx as Record < string , unknown > , path )
29+ pathExists ( ctx , path )
3130 ) ;
3231}
3332
@@ -78,7 +77,7 @@ export class PolicyResolver {
7877 this . #cache. set ( action , this . #compileAction( action ) ) ;
7978 }
8079
81- return this . #cache. get ( action ) ! . can ( context ) ;
80+ return this . #cache. get ( action ) ? .can ( context ) ?? false ;
8281 }
8382
8483 /**
@@ -94,7 +93,7 @@ export class PolicyResolver {
9493 this . #cache. set ( action , this . #compileAction( action ) ) ;
9594 }
9695
97- return this . #cache. get ( action ) ! . explain ( context ) ;
96+ return this . #cache. get ( action ) ? .explain ( context ) ?? [ ] ;
9897 }
9998
10099 #compileAction< TContext > ( action : string ) : CompiledFns < TContext > {
0 commit comments