Specification
The Sigchain API requires some rework as discovered here: #310 (comment)
- 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).
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- ...
- ...
- ...
Specification
The
SigchainAPI requires some rework as discovered here: #310 (comment)ChainDataandChainDataEncodedtypes 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).Array. Record POJOs are not ordered. Alternatively to preserve both order and index access, aMapcan be used. HOWEVER,Arrayand POJOs are pure data. TheMapandSetare not. This is why by convention, we only useMapas a persistent rich construct, and when exchanging data between systems, we use arrays and POJOs.Sigchain.getChainandSigchain.getChainEncoded. Both methods should be returning the typeArray<Claim>andArray<ClaimEncoded>respectively. The encoded version is the base64ed JWT, but usually in our own application we would be working off theClaimstructure. At the same time there should be obvious conversion functions fromClaimtoClaimEncodedand back.seekandlimitparameters to enable cursor pagination. Note thatseekneeds to be type of the seek key. The seek key ofSigchainis theClaimId. Which we know to be based onIdSortablewhich itself uses timestamps internally. Both parameters are optional. One should be able to synthetically construct aClaimIdto represent a point in time cursor as well. This is a secondary priority, do this after the main design works.getClaimwhich you can pass theClaimIdto acquire theClaimitself. If they want an encoded version, we can exposegetClaimEncoded.ChainDataandChainDataEncodedmay no longer be necessary as types. Just useArray<Claim>andArray<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 theClaimId. This means theClaimIdmust always be acquirable given aClaimorClaimEncoded, ideally efficiently.ClaimIdinternally in our application andClaimIdStringonly when using them as POJO keys. TheClaimIdEncodedis purely used for external reference. And theClaimshould be usingClaimId, andClaimEncodedcan useClaimIdEncodedsince you have to have JSON anyway. Make sure to use the reviver and replacer pattern as we do inside theStatusclass.Additional context
NodeManagertoNodeConnectionManager#310 (comment) - Discussion about SigchainClaimId,ClaimIdString,ClaimIdEncodedSigchainTasks