UNPKG

@siren-js/client

Version:
48 lines (47 loc) 1.53 kB
import { SirenElementVisitor } from '../visitor'; import { Field } from './field'; import { SirenElement } from './siren-element'; /** * Represents available behavior exposed by an `Entity`. */ export declare class Action implements SirenElement { /** * List of strings describing the nature of the `Action` based on the current representation. Possible values are * implementation-dependent and should be documented. */ class: string[]; /** * Input controls of the `Action`. */ fields: Field[]; /** * URI of the action */ href: string; /** * Protocol method used when submitting the `Action`. When missing, the default is assumed to be `'GET'`. */ method: string; /** * Name identifying the action to be performed. Must be unique within an `Entity`'s `actions`. */ name: string; /** * Descriptive text about the `Action`. */ title?: string; /** * Encoding type indicating how `fields` are serialized when submitting the `Action`. When missing, the default is * assumed to be `'application/x-www-form-urlencoded'`. */ type: string; [extensions: string]: unknown; /** * Visits this action's {@linkcode fields} followed by the action itself. */ accept(visitor: SirenElementVisitor): Promise<void>; /** * Returns the `Field` in `fields` with the given `name`, if it exists. Otherwise, returns `undefined`. */ getField(name: string): Field | undefined; }