import Base import ./resource_field_binding.bend as Binding import ./resource_field.bend as Field import ./owner_product.bend as Product import ./ordinary_schema.bend as Schema import ./ordinary_query_declaration.bend as Query import ./inspector.bend as Inspector import ./capabilities.bend as Cap # Identity and physical path come from the same ordinary generated binding. # The closed view remains trusted and must return its supplied affine owner. type Read<-S:Data,-P:Type,-identity:Schema.Resource,-H:Type,-V:Data> is Type: Read{operation:Cap.ValueRead} type Declaration<-S:Data,-H:Type,-Ops:Type> is Type: Declaration{grant:Ops,clauses:List<&2,Query.Clause>} def read_field(~S:Data,~P:Type,~identity:Schema.Resource,~H:Type,~V:Data,value:Read) -> H -> H & V: match value: case Read{operation}:Cap.value_read_field(~H,~V,operation) def get(~S:Data,~P:Type,~identity:Schema.Resource,~H:Type,~V:Data,~value:Read,owner:H) -> H & V: read_field(~S,~P,~identity,~H,~V,value)(owner) def bind(~S:Data,~C:Type,~R:Type,~E:Data,~P:Type,~Rest:Type,~V:Data,~lens:Product.Lens,~identity:Schema.Resource,~binding:Binding.Binding,~view:P -> P & V) -> Declaration,Read,V>>: Declaration{Read{Inspector.read_resource(~S,~C,~R,~E,~V,~Field.project(~R,~P,~Rest,~V,~lens,~view))},[Query.Clause{Schema.resource_key(~S,~P,identity),Query.Read{}}]} def grant(~S:Data,~H:Type,~Ops:Type,value:Declaration) -> Ops: match value: case Declaration{grant,_}:grant def clauses(~S:Data,~H:Type,~Ops:Type,value:Declaration) -> List<&2,Query.Clause>: match value: case Declaration{_,clauses}:clauses