Home Identifier Source Repository
import Siren from 'super-siren/lib/Siren.js'
public class | source

Siren

You can directly use instance of this class. siren

Static Member Summary

Static Public Members
public static get

empty: Siren: *

Returns an empty siren representation.

Static Method Summary

Static Public Methods
public static

fromJson(obj: Object, baseUrl: String): Siren

Parses a JSON representation of a Siren entity

public static

get(href: String): superagent-promise

Returns a Superagent Promise instance which will perform an HTTP Get against

Constructor Summary

Public Constructor
public

constructor(args: *)

Member Summary

Public Members
public get

embeddedEntities: Immutable.Set: *

Returns the sub-entities on this Siren object which are embedded sub-entities.

public get

linkedEntities: Immutable.Set: *

Returns the sub-entities on the Siren object which are linked sub-entities.

public get

Returns the self link for this entity

Method Summary

Public Methods
public

embeddedEntitiesByRel(rel: String): Immutable.Set

Returns the sub-entities on this Siren object which are embedded sub-entities.

public

Finds the @see SirenAction referenced by the provided rel.

public

findEntitiesByRel(rel: String): Immutable.Set

Finds the @See EmbeddedSubEntity|LinkedSubEntity entities referenced by the provided rel.

public

Finds the first @See SirenLink referenced by the provided rel.

public

linkedEntitiesByRel(rel: String): Immutable.Set

Returns the set of linked sub-entities on the Siren object which match the requested rel.

Static Public Members

public static get empty: Siren: * source

Returns an empty siren representation. This Siren entity contains no afforances.

Return:

Siren

Empty siren structure

Static Public Methods

public static fromJson(obj: Object, baseUrl: String): Siren source

Parses a JSON representation of a Siren entity and returns the Siren representation.

Params:

NameTypeAttributeDescription
obj Object
  • optional

The JSON object to be parsed as Siren

baseUrl String
  • optional
  • default: null

Optional base URL to use for relative URL parsing

Return:

Siren

Parsed Siren entity

public static get(href: String): superagent-promise source

Returns a Superagent Promise instance which will perform an HTTP Get against the provided href returning the response as a SuperAgent response. If the response is Siren ('application/vnd.siren+json'), then the body should be a Siren instance.

Params:

NameTypeAttributeDescription
href String

The URL to perform an HTTP get against

Return:

superagent-promise

Superagent Promise Object

Public Constructors

public constructor(args: *) source

Params:

NameTypeAttributeDescription
args *

Public Members

public get embeddedEntities: Immutable.Set: * source

Returns the sub-entities on this Siren object which are embedded sub-entities.

Return:

Immutable.Set

Set of embedded sub-entities.

public get linkedEntities: Immutable.Set: * source

Returns the sub-entities on the Siren object which are linked sub-entities.

Return:

Immutable.Set

Set of linked sub-entities on this Siren object.

Returns the self link for this entity

Return:

SirenLink

link represented by the self rel, null if no self link is found.

Public Methods

public embeddedEntitiesByRel(rel: String): Immutable.Set source

Returns the sub-entities on this Siren object which are embedded sub-entities.

Params:

NameTypeAttributeDescription
rel String

Only entities with a relation to the parent siren matching this should be returned.

Return:

Immutable.Set

Set of embedded sub-entities which match thes provided rel.

public findActionByName(name: String): SirenAction source

Finds the @see SirenAction referenced by the provided rel.

Params:

NameTypeAttributeDescription
name String

The name of the action to find.

Return:

SirenAction

SirenAction matching the requested name. null if none is found.

public findEntitiesByRel(rel: String): Immutable.Set source

Finds the @See EmbeddedSubEntity|LinkedSubEntity entities referenced by the provided rel.

Params:

NameTypeAttributeDescription
rel String

The relation to this Siren entity for the requested sub-entity.

Return:

Immutable.Set

Set of sub-entities matching the requested rel.

public findLinkByRel(rel: String): SirenLink source

Finds the first @See SirenLink referenced by the provided rel.

Params:

NameTypeAttributeDescription
rel String

The relation to this Siren entity for the requested link.

Return:

SirenLink

SirenLink matching the requested rel. null if none is found.

public linkedEntitiesByRel(rel: String): Immutable.Set source

Returns the set of linked sub-entities on the Siren object which match the requested rel.

Params:

NameTypeAttributeDescription
rel String

Only entities with this relation to the parent siren should be returned.

Return:

Immutable.Set

Set of linked sub-entities which match the provided rel.