This class is a nicer frontend for the Profile recipe.

A profile describes a persons identity in more detail. What is an identity in one? The identity used throughout ONE is the SHA256IdHash. The profile glues additional information to such an identity like:

  • how to contact this person (e-mail, telephone number, address, ...) - called "contact endpoint"
  • name, pictures ... - called "contact description"

Reasons for not using the Profile recipe directly:

  • Because this is a CRDT tracked type we need to track which version was loaded, so on which versions the modifications are based on. If we don't store it with the data we need to track it separately. Perhaps in the future we can find some common solution for all recipes. This is just the first test if having a separate data structure adds some value to the ui.
  • The endpoints and descriptions are links to ONE objects. If you want to use the recipe directly you would have to load them in the ui context asynchronously - which would result in a data structure very similar to this - so why not do it here directly?
  • Changes in the recipe can be represented on this level without breaking API changes.

There are alternative designs. I just want to try this approach because of the reasons mentioned above. This might be a start on how to represent CRDT managed types - but later in a generic way.

Constructors

Properties

communicationEndpoints: CommunicationEndpointTypes[] = []
idHash: SHA256IdHash<Profile>
isImageModified: boolean = false
isStatusModified: boolean = false
onUpdate: OEvent<(() => void)> = ...
personDescriptions: PersonDescriptionTypes[] = []

Accessors

Methods

  • Returns whether this model has data loaded.

    If this returns false, then the 'personId', 'profileId' and 'owner' properties will throw and endpoints and descriptions will be empty arrays (if they haven't been modified from the outside)

    Returns boolean

  • Save the profile to disk and load the latest version.

    Why is there no pure save() function? The cause are crdts. The object that is eventually written to disk might differ from the current state of this instance. This happens when new data was received via chum since the last load. This means that we don't have a hash representing the current state.

    TODO: It is possible to write the intermediary state and obtain a hash. So we can implement a pure save() function. But this requires the lower levels to write the top level object of the tree and return the corresponding hash to the caller. The storeVersionedObjectCRDT and the plan interfaces don't support that right now in a easy to grasp way.

    Returns Promise<void>

  • Parameters

    • personId: SHA256IdHash<Person>
    • owner: SHA256IdHash<Person>
    • profileId: string

    Returns Promise<default>

  • Create a profile if it does not exist.

    If you specify descriptions and / or endpoints here and a profile version already exists without those endpoints and / or descriptions it will add them again.

    Parameters

    Returns Promise<default>

    The latest version of the profile or an empty profile.