The main purpose of this document is to establish the API for version 1.0 of the library.
The structure of the models will be different than what it is today.
- The
activitypubmodule will be renamed tovocaband contain the vanilla types described in the Activity vocabulary specification. - The
processingmodule will become the newactivitypubmodule, and it will contain the state machine for processing client to server and server to server activities.- It will include subpackages for convenience functionality to interop with the wider Go ecosystem: HTTP handlers
- The
authorizationmodule moves as a subpackage here.
- The
clientmodule stays as is.
The vocabulary
Generating code should start from a Go struct with annotations.
The steps should be something like this:
Structure
We need to validate the struct’s compatibility with the Vanilla AP objects:
- the properties must match the position and type of one of the
Object,Actor,IntransitiveActivity,Activity,Link, etc. - the struct must validate against the JSON-LD contexts that the developer chooses for them.
Helper functions
Generate helper functions:
- Initializer function:
New<Type> - Generate functions:
On<StructName>, andTo<StructName> - Generate function type
With<Type>Fn - Generate
MarshalJSON/UnmarshalJSON,GobEncode/GobDecode - Add type switch cases to the
IsObject,IsActor,IsActivity,IsIntransitiveActivity,IsLink - Add type switch cases to the
ToObject,ToActor,ToActivity,ToIntransitiveActivity,ToLink - Add type switch cases to the
IsNilfunction.
Types
Accumulate types for generated objects and add their types to the slices for:
ActorTypes: struct has Inbox/Outbox propertiesActivityTypes: struct has Actor/Object propertiesIntransitiveActivityTypes: struct has Actor property but no Object propertyLinkTypes: no ID property, but has a Href property.ObjectTypes: what’s left?
Accumulate types into the interfaces that can be used by generic code (Actors, Objects, etc).