Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Entity<ACS>

Type parameters

Hierarchy

  • Entity

Index

Constructors

constructor

  • Creates a new Entity instance. The attrConfigSet defines the attributes available on the Entity instance. Values defined in attrConfigSet are trusted and therefore not sanitized, normalized nor validated. Data provided via data must be compatible with the data expected by [[Entity.fill()]] but, unlike [[Entity.fill()]], may also include values for immutable attributes.

    Parameters

    Returns Entity

Properties

Private #attrConfigSet

#attrConfigSet: ACS

Private #immutable

#immutable: ResolveImmutableAttrSet<ACS>

Private #modified

#modified: Set<AttrName> = new Set<ResolveMutableAttrName<ACS>>()

Private #mutable

#mutable: ResolveMutableAttrSet<ACS>

Methods

all

callable

clearModified

  • clearModified(): this
  • Clears the modified attribute state. Typically used after calling an update/save endpoint to signify that the instance is in sync with the upstream datasource.

    Returns this

fill

  • Sets multiple attribute values using the provided data. The incoming data is parsed into an attribute set using [[Entity.parseData()]], before being sanitized, normalized and validated.

    Parameters

    Returns this

hidden

immutable

many

modified

mutable

normalize

  • normalize<K, V>(name: K, value: V): V
  • Normalizes a value using the configured normalizer function for the attribute name. If the attribute does not have a normalizer function configured then that value is returned as-is. The function will have this scoped to the Entity instance.

    Type parameters

    Parameters

    • name: K
    • value: V

    Returns V

one

  • one<K>(name: K): ResolveAttrSet<ACS>[K]

parseData

  • parseData(data: unknown): AttrSet

sanitize

  • sanitize<K>(name: K, value: unknown): ResolveWritableAttrSet<ACS>[K]
  • Sanitizes a value using the configured sanitizer function for the attribute name. The function will have this scoped to the Entity instance.

    Type parameters

    Parameters

    • name: K
    • value: unknown

    Returns ResolveWritableAttrSet<ACS>[K]

set

  • set<K>(name: K, value: ResolveMutableAttrSet<ACS>[K]): this
  • Sets the value for the attribute name. Values can only be set for mutable, writable attributes. The value will be sanitized, normalized and validated.

    Type parameters

    Parameters

    • name: K
    • value: ResolveMutableAttrSet<ACS>[K]

    Returns this

toJSON

toString

  • toString(): string

validate

  • validate<K>(name: K, value: ResolveWritableAttrSet<ACS>[K]): boolean
  • Validates a value using the configured validator function for the attribute name. If the attribute does not have a validator function configured then that value is assumed valid. The function will have this scoped to the Entity instance.

    Type parameters

    Parameters

    • name: K
    • value: ResolveWritableAttrSet<ACS>[K]

    Returns boolean

visible

writable

Generated using TypeDoc