Skip to content

Sigchain Class API should provide paginated ordered claims by returning Array-POJO and indexed access #327

@CMCDragonkai

Description

@CMCDragonkai

Specification

The Sigchain API requires some rework as discovered here: #310 (comment)

  1. The ChainData and ChainDataEncoded types are record POJOs, which are not the right data type we should be returning to callers. Record POJOs do not preserve order, and when returning chain data, we would want to have the ability to iterate over the data, and it should be in the same order as the chain data (as ordered by the claim id).
  2. When fetching a collection of resources in JS, always return an Array. Record POJOs are not ordered. Alternatively to preserve both order and index access, a Map can be used. HOWEVER, Array and POJOs are pure data. The Map and Set are not. This is why by convention, we only use Map as a persistent rich construct, and when exchanging data between systems, we use arrays and POJOs.
  3. This means we need Sigchain.getChain and Sigchain.getChainEncoded. Both methods should be returning the type Array<Claim> and Array<ClaimEncoded> respectively. The encoded version is the base64ed JWT, but usually in our own application we would be working off the Claim structure. At the same time there should be obvious conversion functions from Claim to ClaimEncoded and back.
  4. These 2 functions should expose seek and limit parameters to enable cursor pagination. Note that seek needs to be type of the seek key. The seek key of Sigchain is the ClaimId. Which we know to be based on IdSortable which itself uses timestamps internally. Both parameters are optional. One should be able to synthetically construct a ClaimId to represent a point in time cursor as well. This is a secondary priority, do this after the main design works.
  5. For indexed access, we would not expect the user to acquire a collection, and then query their collection. Instead we would expect the user to directly call a getClaim which you can pass the ClaimId to acquire the Claim itself. If they want an encoded version, we can expose getClaimEncoded.
  6. The ChainData and ChainDataEncoded may no longer be necessary as types. Just use Array<Claim> and Array<ClaimEncoded>. However it is essential that one can iterate over these 2 arrays, and be able to use extractors/transformers/converters to be able to acquire the ClaimId. This means the ClaimId must always be acquirable given a Claim or ClaimEncoded, ideally efficiently.
  7. Remote users that call over GRPC, they should be able to pass pagination parameters in and acquire a collection of claims, they can then process it the way they want and do indexed access if so.
  8. We should endeavour to always be using ClaimId internally in our application and ClaimIdString only when using them as POJO keys. The ClaimIdEncoded is purely used for external reference. And the Claim should be using ClaimId, and ClaimEncoded can use ClaimIdEncoded since you have to have JSON anyway. Make sure to use the reviver and replacer pattern as we do inside the Status class.

Additional context

Tasks

  1. ...
  2. ...
  3. ...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions