import { RDF , LDP , AS , SEC } from "./consts" ; import { TripleStore , nodes , node , anyText , englishText } from "./rdf" ; export interface Actor { id : string ; type ? : string ; preferredUsername ? : string ; inbox ? : string ; endpoints ? : string ; } export interface Endpoints { id : string ; sharedInbox ? : string ; } export interface Activity { id : string ; type ? : string ; actor ? : string ; object ? : string ; } export interface Object { id : string ; type ? : string ; attributedTo ? : string ; inReplyTo ? : string ; content ? : string ; tags : string [ ] ; } export interface Tag { id : string ; type ? : string ; href ? : string ; } export interface PublicKey { id : string ; owner ? : string ; publicKeyPem ? : string ; } export const getActor = ( store , id ) : Actor => store . with ( id , ( get ) => ( { id , type : get ( RDF ( "type" ) , node ) , preferredUsername : get ( AS ( "preferredUsername" ) , englishText ) , inbox : get ( LDP ( "inbox" ) , node ) , endpoints : get ( AS ( "endpoints" ) , node ) , } ) ) ; export const getEndpoints = ( store , id ) : Endpoints => store . with ( id , ( get ) => ( { id , sharedInbox : get ( AS ( "sharedInbox" ) , node ) , } ) ) ; export const getActivity = ( store , id ) : Activity => store . with ( id , ( get ) => ( { id , type : get ( RDF ( "type" ) , node ) , actor : get ( AS ( "actor" ) , node ) , object : get ( AS ( "object" ) , node ) , } ) ) ; export const getObject = ( store , id ) : Object => store . with ( id , ( get ) => ( { id , type : get ( RDF ( "type" ) , node ) , attributedTo : get ( AS ( "attributedTo" ) , node ) , inReplyTo : get ( AS ( "inReplyTo" ) , node ) , content : get ( AS ( "content" ) , englishText ) , tags : get ( AS ( "tag" ) , nodes ) , } ) ) ; export const getTag = ( store , id ) : Tag => store . with ( id , ( get ) => ( { id , type : get ( RDF ( "type" ) , node ) , href : get ( AS ( "href" ) , node ) , } ) ) ; export const getPublicKey = ( store , id ) : PublicKey => store . with ( id , ( get ) => ( { id , owner : get ( SEC ( "owner" ) , node ) , publicKeyPem : get ( SEC ( "publicKeyPem" ) , anyText ) , } ) ) ;