Documentation
¶
Overview ¶
Package cli implements the Coggo command-line interface.
All subcommands share a Runtime built by Setup, which opens the peer registry, the SQLite store, the auth store, the schema resolver, and the federation router, then registers a StoreHandler per peer. Type definitions previously stored as EntityTypeDefinition entities are rehydrated into the resolver so user-defined types survive restarts.
Index ¶
- Variables
- func AddPeerToRuntime(ctx context.Context, rt *Runtime, p *types.Peer, clientID string) error
- func App() *cli.Command
- func CreateEntity(ctx context.Context, rt *Runtime, peerDID, typ string, fields map[string]any, ...) (*types.Entity, error)
- func CreateRelation(ctx context.Context, rt *Runtime, peerDID, from, to, typ string, ...) (*types.Relation, error)
- func DefineType(ctx context.Context, rt *Runtime, peerDID, name, description string, ...) error
- func FedCall(ctx context.Context, rt *Runtime, peerDID, msgType, op string, args any) (json.RawMessage, error)
- func GetEntity(ctx context.Context, rt *Runtime, peerDID, id string) (*types.Entity, error)
- func QueryEntities(ctx context.Context, rt *Runtime, peerDID string, q types.EntityQuery) ([]*types.Entity, error)
- func UpdateEntity(ctx context.Context, rt *Runtime, peerDID, id string, fields map[string]any, ...) (*types.Entity, error)
- type Runtime
Constants ¶
This section is empty.
Variables ¶
var Version = "0.1.0-dev"
Version reported by `coggo version`. Overridable at build time via `-ldflags "-X github.com/lunguini/coggo/internal/cli.Version=<v>"`.
Functions ¶
func AddPeerToRuntime ¶
AddPeerToRuntime registers a freshly created peer with the resolver and router, also persisting its seed types into the store as EntityTypeDefinition / RelationshipTypeDefinition entities so they survive restarts.
func App ¶
App returns the root cli.Command. Wired with global flags (--config, --peer) and all subcommands. Running with no subcommand is `serve`.
func CreateEntity ¶
func CreateEntity(ctx context.Context, rt *Runtime, peerDID, typ string, fields map[string]any, clientID string) (*types.Entity, error)
CreateEntity is a convenience wrapper around the entity.create op.
func CreateRelation ¶
func CreateRelation(ctx context.Context, rt *Runtime, peerDID, from, to, typ string, data map[string]any, clientID string) (*types.Relation, error)
CreateRelation wraps relation.create.
func DefineType ¶
func DefineType(ctx context.Context, rt *Runtime, peerDID, name, description string, fields []types.FieldDef, isRel, directional bool, clientID string) error
DefineType wraps type.define.
func FedCall ¶
func FedCall(ctx context.Context, rt *Runtime, peerDID, msgType, op string, args any) (json.RawMessage, error)
FedCall sends a federation message to the named peer (op + args -> response payload). On error response, returns an error built from the payload.
Types ¶
type Runtime ¶
type Runtime struct {
Cfg *config.Config
Registry *peer.Registry
Store types.Store
Auth types.Authority
Router types.Router
Resolver *schema.Resolver
// contains filtered or unexported fields
}
Runtime bundles the substrate every CLI command needs.