@@ -5036,7 +5036,7 @@ pub use tpe::*;
5036
5036
mod tpe {
5037
5037
use std:: collections:: { HashMap , HashSet } ;
5038
5038
5039
- use cedar_policy_core:: ast;
5039
+ use cedar_policy_core:: ast:: { self , PartialValueToValueError } ;
5040
5040
use cedar_policy_core:: authorizer:: Decision ;
5041
5041
use cedar_policy_core:: batched_evaluator:: is_authorized_batched;
5042
5042
use cedar_policy_core:: batched_evaluator:: {
@@ -5058,7 +5058,7 @@ mod tpe {
5058
5058
RequestValidationError , RestrictedExpression , Schema , TPEReauthorizationError ,
5059
5059
} ;
5060
5060
5061
- /// A partial [`EntityUid`]
5061
+ /// A partial [`EntityUid`].
5062
5062
/// That is, its [`EntityId`] could be unknown
5063
5063
#[ repr( transparent) ]
5064
5064
#[ derive( Debug , Clone , RefCast ) ]
@@ -5072,6 +5072,12 @@ mod tpe {
5072
5072
eid : id. map ( |id| <EntityId as AsRef < ast:: Eid > >:: as_ref ( & id) . clone ( ) ) ,
5073
5073
} )
5074
5074
}
5075
+
5076
+ /// Construct a [`PartialEntityUid`] from a concrete [`EntityUid`].
5077
+ pub fn from_concrete ( euid : EntityUid ) -> Self {
5078
+ let ( ty, eid) = euid. 0 . components ( ) ;
5079
+ Self ( tpe:: request:: PartialEntityUID { ty, eid : Some ( eid) } )
5080
+ }
5075
5081
}
5076
5082
5077
5083
/// A partial [`Request`]
@@ -5225,6 +5231,11 @@ mod tpe {
5225
5231
) -> Result < Self , tpe_err:: EntitiesError > {
5226
5232
tpe:: entities:: PartialEntities :: from_json_value ( value, & schema. 0 ) . map ( Self )
5227
5233
}
5234
+
5235
+ /// Construct `[PartialEntities]` given a fully concrete `[Entities]`
5236
+ pub fn from_concrete ( entities : Entities ) -> Result < Self , PartialValueToValueError > {
5237
+ tpe:: entities:: PartialEntities :: try_from ( entities. 0 ) . map ( Self )
5238
+ }
5228
5239
}
5229
5240
5230
5241
/// A partial version of [`crate::Response`].
@@ -5447,7 +5458,7 @@ mod tpe {
5447
5458
Some ( Decision :: Allow ) => Ok ( entities
5448
5459
. iter ( )
5449
5460
. filter ( |entity| {
5450
- entity. 0 . uid ( ) . entity_type ( ) == & request. 0 . 0 . get_resource_type ( )
5461
+ entity. 0 . uid ( ) . entity_type ( ) == & request. 0 . 0 . get_principal_type ( )
5451
5462
} )
5452
5463
. map ( super :: Entity :: uid)
5453
5464
. collect_vec ( )
0 commit comments