Container for a context/contexts. Because contexts come from external code they must be thoroughly validated and then formed to comply with the type system.

Hierarchy

  • Context

Constructors

  • Contexts should be created using the static factory method Context.fromLDContext.

    Returns Context

Properties

_context?: any
_contextForKind: any
_contexts: any
_isMulti: any
_isUser: any
_privateAttributeReferences?: any
_wasLegacy: any
kind: string
message?: string
valid: boolean

Is this a valid context. If a valid context cannot be created, then this flag will be true. The validity of a context should be tested before it is used.

UserKind: string
_contextForError: any
_fromLegacyUser: any
_fromMultiKindContext: any
_fromSingleKindContext: any
_getValueFromContext: any

Accessors

  • get canonicalKey(): string
  • Get the canonical key for this context.

    Returns string

  • get isMultiKind(): boolean
  • True if this is a multi-kind context.

    Returns boolean

  • get kinds(): string[]
  • Get the kinds of this context.

    Returns string[]

  • get kindsAndKeys(): Record<string, string>
  • Get the kinds, and their keys, for this context.

    Returns Record<string, string>

  • get legacy(): boolean
  • Returns boolean

Methods

  • Get the underlying context objects from this context.

    This method is intended to be used in event generation.

    The returned objects should not be modified.

    Returns [string, LDContextCommon][]

  • Attempt to get a key for the specified kind.

    Parameters

    • Optional kind: string

      The kind to get a key for.

      Optional

    Returns undefined | string

    The key for the specified kind, or undefined.

  • Get the attribute references.

    Parameters

    • kind: string

    Returns AttributeReference[]

  • Attempt to get a value for the given context kind using the given reference.

    Parameters

    • reference: AttributeReference

      The reference to the value to get.

    • Optional kind: string

      The kind of the context to get the value for.

      Optional

    Returns any

    a value or undefined if one is not found.

  • Attempt to create a Context from an LDContext.

    Parameters

    • context: LDContext

      The input context to create a Context from.

    Returns Context

    a Context, if the context was not valid, then the returned contexts valid property will be false.

  • Creates a LDContext from a Context.

    Parameters

    Returns undefined | LDContext

    an LDContext if input was valid, otherwise undefined

Generated using TypeDoc