You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So here is my interpretation of the interface described in this repo encoded in flow types
// https://github.com/ipld/interface-ipld-format#ipld-format-utilsinterfaceFormat<node>{serialize(node,Callback<Error,ArrayBuffer>):void;deserialize(ArrayBuffer,Callback<Error,node>):void;cid(node,Callback<Error,CID>):void;}// https://github.com/ipld/interface-ipld-format#local-resolver-methodsinterfaceResolver<value>{resolve(ArrayBuffer,Path,Callback<Error,Result<value>>):void;tree(ArrayBuffer,Callback<Error,Entry<value>[]>):void;tree(ArrayBuffer,{level:number,values?:boolean},Callback<Error,Entry<value>[]>):void;isLink(ArrayBuffer,Path,Callback<Error,Link>):void;}typePath=stringtypeLink={[Path]:CID}interfaceResult<value>{remainderPath:Path;value:Link|value;}typeEntry<value>={[Path]:value}// Details of CID aren't actually important in this contextinterfaceCID{}// Callbacks is a function that is either passed an error as first argument,// or passed just a second `value` argument if successful. interfaceCallback<error,value>{(error):void;(null|void,value):void;}
Some notes on my interpretation:
Format utils API spec refers to dagNode but it is unclear what is the type or a shape, or whether it has specific one. My understanding is that dagNode representation is specific to the resolver implementation which is why Format<node> has type parameter node to representing dagNode specific implementation would probably do something like
classGitFormatimplementsFormat<GitNode>{// ...}
Where GitNode will have a specefic type / shape.
Resolver API refers to resolved value but to me it's unclear what the type / shape of the value is. I assumed here as well that it is specefic to the resolver implementation which is why Resolver<value> uses generic type parameter value here I also assume that specific implementation would define the type / shape of the value.
Unknowns
resolver.resolve(binaryBlob, path, callback) mentions that result passed to callback has value that is "The value resolved or an IPLD link". How do I figure which on is it ? Presumably I know what the value type is and there for can figure out if it's that or a link, but then again I'm worried about the ambiguity here. I would much rather have result with type { value:value, remainderPath:Path } | { link:Link, remainderPath:Path } so it's clear which one I get back. Also is a link in this context a tuple with path and CID as described in isLink{'/': <CID> }
Can link contain multiple path to CID mapping or is it always one ? If it's always one why not use a data structure that would not require iteration ?
resolver.tree passes back array of tuples like [ { '/foo': 'bar' } ...] does that mean each item in that array contains object with single property where it's name represents a path ? If so why not just use a data structure that would not require iteration to access data ? Also my guess was that value in such a tuple is of the same type as one returned in resolve isn't it ?
I'm almost certain that given Resolver<value> and Format<node> there is some correlation between value and node type parameters but I can't figure it out. Maybe that relation is implementation detail of the actual resolver ?
So here is my interpretation of the interface described in this repo encoded in flow types
Some notes on my interpretation:
Format utils API spec refers to
dagNodebut it is unclear what is the type or a shape, or whether it has specific one. My understanding is thatdagNoderepresentation is specific to the resolver implementation which is whyFormat<node>has type parameternodeto representingdagNodespecific implementation would probably do something likeWhere
GitNodewill have a specefic type / shape.Resolver API refers to resolved
valuebut to me it's unclear what the type / shape of the value is. I assumed here as well that it is specefic to the resolver implementation which is whyResolver<value>uses generic type parametervaluehere I also assume that specific implementation would define the type / shape of the value.Unknowns
resolver.resolve(binaryBlob, path, callback)mentions thatresultpassed to callback hasvaluethat is "The value resolved or an IPLD link". How do I figure which on is it ? Presumably I know what thevaluetype is and there for can figure out if it's that or a link, but then again I'm worried about the ambiguity here. I would much rather have result with type{ value:value, remainderPath:Path } | { link:Link, remainderPath:Path }so it's clear which one I get back. Also is a link in this context a tuple with path and CID as described inisLink{'/': <CID> }resolver.treepasses back array of tuples like[ { '/foo': 'bar' } ...]does that mean each item in that array contains object with single property where it's name represents a path ? If so why not just use a data structure that would not require iteration to access data ? Also my guess was thatvaluein such a tuple is of the same type as one returned inresolveisn't it ?Resolver<value>andFormat<node>there is some correlation betweenvalueandnodetype parameters but I can't figure it out. Maybe that relation is implementation detail of the actual resolver ?