UNPKG

siren-types

Version:

A bunch of Siren types defined in TypeScript plus some useful functions

27 lines (26 loc) 813 B
import { Siren, Field } from "./types"; interface Builder<T> { asJSON(): Siren<T>; } export interface PartialLink { class?: string[]; title?: string; type?: string; } export interface PartialAction { class?: string[]; method?: "GET" | "PUT" | "POST" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS"; title?: string; type?: string; fields?: Field[]; } export declare class SirenResponse<T> implements Builder<T> { private resp; constructor(def: T, prev?: Siren<T>); addProperty<K extends keyof T>(key: K, val: T[K]): SirenResponse<T>; properties(props: T): SirenResponse<T>; link(rel: string[], href: string, rest?: PartialLink): SirenResponse<T>; action(name: string, href: string, rest?: PartialAction): SirenResponse<T>; asJSON(): Siren<T>; } export {};