ordinary_declaration.bend

bendvy-ecs-core@0.1.0.0 · 17 lines · 0 definitions

1import Base
2# One nominal ordinary schema declaration shared by component grants and gates.
3# No storage/runtime imports and no user debug metadata adapter.
4# Schema-scoped component declaration binding a key to payload type P.
5# This Data value owns no component instance; keys must remain collision-free
6# within a validated schema. It is not a runtime entity/world authority.
7type Declaration<-S:Data,-P:Type> is Data:
8  Declaration{key:String}
9# Declare a component key for payload P in schema S. Does not create storage,
10# spawn entities or validate collisions; compose and validate the schema before
11# attaching an App. Example: examples/scheduled-health/registration.bend identities.
12def component(~S:Data,~P:Type,key:String) -> Declaration<S,P>:
13  Declaration{key}
14# Return the authored component key without accessing any world or payload.
15def key(~S:Data,~P:Type,declaration:Declaration<S,P>) -> String:
16  match declaration:
17    case Declaration{key}:key