import { Enc, Path, Patp, Poke } from ".."; import { Contact, ContactEdit, ContactUpdateCreate, ContactUpdateEdit, ContactUpdateRemove } from "./index.d"; import { GroupPolicy, Resource } from "../groups/index.d" export const viewAction = (data: T): Poke => ({ app: 'contact-view', mark: 'json', json: data }); export const hookAction = (data: T): Poke => ({ app: 'contact-hook', mark: 'contact-action', json: data }); export const create = ( name: string, policy: Enc, title: string, description: string ): Poke => viewAction({ // TODO which type is correct? create: { name, policy, title, description } }); export const share = ( recipient: Patp, path: Patp, ship: Patp, contact: Contact ): Poke => viewAction({ // TODO type share: { recipient, path, ship, contact } }); export const remove = ( path: Path, ship: Patp ): Poke => viewAction({ remove: { path, ship } }); export const edit = ( path: Path, ship: Patp, editField: ContactEdit ): Poke => hookAction({ edit: { path, ship, 'edit-field': editField } }); export const invite = ( resource: Resource, ship: Patp, text: string = '' ): Poke => viewAction({ // TODO type invite: { resource, ship, text } }); export const join = ( resource: Resource ): Poke => viewAction({ // TODO type join: resource });