/** * Martian embassy */ // an urbit style path rendered as string export type Path = string; // patp including leading sig export type Patp = string; // patp excluding leading sig export type PatpNoSig = string; // @uvH encoded string export type Serial = string; // jug from hoon export type Jug = Map>; // name of app export type AppName = 'chat' | 'link' | 'contacts' | 'publish' | 'graph'; export function getTagFromFrond(frond: O): keyof O { const tags = Object.keys(frond) as Array; const tag = tags[0]; if(!tag) { throw new Error("bad frond"); } return tag; } export type ShipRank = 'czar' | 'king' | 'duke' | 'earl' | 'pawn'; export type Action = 'poke' | 'subscribe' | 'ack' | 'unsubscribe' | 'delete'; export type SetElement = S extends Set<(infer T)> ? T : never; export type MapKey = M extends Map<(infer K), any> ? K : never; export type MapValue = M extends Map ? V : never; /** * Turns sets into arrays and maps into objects so we can send them over the wire */ export type Enc = S extends Set ? Enc>[] : S extends Map ? { [s: string]: Enc> } : S extends object ? { [K in keyof S]: Enc } : S; export type Mark = string; export interface Poke { ship?: string; // This should be handled by the http library, but is part of the spec app: string; mark: Mark; json: Action; } export interface Thread { inputMark: string; outputMark: string; threadName: string; body: Action; }