@samatawy/rules
    Preparing search index...

    Class ScopeContext

    A context implementation internally used by functions (including lambda functions). This isolates changes made while the function is being executed, keeping the parent context clean. It does not cache values or return logs. You should not need to use this class directly.

    Implements

    Index

    Constructors

    Properties

    cacheMetrics: { sets: number; hits: number; misses: number } = ...

    Methods

    • Read data from the context using the given key or path. This method will first attempt to retrieve the value from the context's data. If the value is not found in the data, it will then attempt to retrieve it from the context's constants. Nested keys can be accessed using dot notation (e.g., "user.name").

      Parameters

      • key: string

        the key to look up in the context.

      Returns any

      the value associated with the key, or undefined if the key is not found.

    • Check if the context contains data for the given key or path. Nested keys can be accessed using dot notation (e.g., "user.name").

      Parameters

      • key: string

        the key to check in the context.

      Returns boolean

      true if the key exists in the context, false otherwise.

    • Get a constant value from the context using the given key. Nested keys are not allowed.

      Parameters

      • key: string

        the key to look up in the constants.

      Returns any

      the constant value associated with the key, or undefined if the key is not found.

    • Check if the context contains a constant for the given key. Nested keys are not allowed.

      Parameters

      • key: string

        the key to check in the constants.

      Returns boolean

      true if the constant exists, false otherwise.

    • Get the root-level keys of the context. This can be useful for determining what data is available in the context and for debugging purposes.

      Returns string[]

      an array of root-level keys in the context.

    • Get the value kept under a given identifer.

      Parameters

      • id: string

        the identifer to look for.

      Returns undefined

      the value kept under that identifer, or undefined if the id was not found.

    • Keep a value under a given identifier.

      Parameters

      • id: string

        the identifier to set,

      • value: any

        the value to keep for the identifier.

      Returns void

    • Delete a single identifier and its value, or entirely delete all values.

      Parameters

      • Optionalid: string

        the identifier to delete. If not provided, the entire cache will be cleared.

      Returns void

    • Retrieve metrics for this cache instance. This is mainly a debugging/monitoring method.

      Returns { sets: number; hits: number; misses: number }

      a metrics object containing sets, hits, and misses.

    • Set an output value in the context with the given key.

      Parameters

      • key: string

        the key to associate with the output value.

      • value: any

        the value to set for the given key.

      Returns void

    • Get an output value from the context using the given key, excluding any shared data. Nested keys can be accessed using dot notation (e.g., "result.value"). If no key is provided, all output data will be returned.

      Parameters

      • Optionalkey: string

        the key to look up in the outputs.

      Returns any

      the output value associated with the key, or undefined if the key is not found.