1 import Base 2 import ./resource_field_binding.bend as Binding 3 import ./resource_field.bend as Field 4 import ./owner_product.bend as Product 5 import ./ordinary_schema.bend as Schema 6 import ./ordinary_query_declaration.bend as Query 7 import ./inspector.bend as Inspector 8 import ./capabilities.bend as Cap 9 10 # Identity and physical path come from the same ordinary generated binding. 11 # The closed view remains trusted and must return its supplied affine owner. 12 type Read<-S:Data,-P:Type,-identity:Schema.Resource,-H:Type,-V:Data> is Type: 13 Read{operation:Cap.ValueRead} 14 type Declaration<-S:Data,-H:Type,-Ops:Type> is Type: 15 Declaration{grant:Ops,clauses:List<&2,Query.Clause>} 16 def read_field(~S:Data,~P:Type,~identity:Schema.Resource,~H:Type,~V:Data,value:Read) -> H -> H & V: 17 match value: 18 case Read{operation}:Cap.value_read_field(~H,~V,operation) 19 def get(~S:Data,~P:Type,~identity:Schema.Resource,~H:Type,~V:Data,~value:Read,owner:H) -> H & V: 20 read_field(~S,~P,~identity,~H,~V,value)(owner) 21 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>>: 22 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{}}]} 23 def grant(~S:Data,~H:Type,~Ops:Type,value:Declaration) -> Ops: 24 match value: 25 case Declaration{grant,_}:grant 26 def clauses(~S:Data,~H:Type,~Ops:Type,value:Declaration) -> List<&2,Query.Clause>: 27 match value: 28 case Declaration{_,clauses}:clauses