Options
All
  • Public
  • Public/Protected
  • All
Menu
description

Module to export all public core APIs.

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

CommunicationBindingStatic

CommunicationBindingStatic<T, O>: new (options: O) => T

Type parameters

Type declaration

    • new (options: O): T
    • Defines static constructor signature for communication binding types that extend and implement the abstract CommunicationBinding class.

      Parameters

      • options: O

      Returns T

CommunicationBindingWithOptions

CommunicationBindingWithOptions<T, O>: { options: O; type: CommunicationBindingStatic<T, O> }

A utility type used to specify a value for the CommunicationOptions.binding property in the agent container configuration.

Type parameters

Type declaration

CoreType

CoreType: "CoatyObject" | "User" | "Annotation" | "Task" | "IoContext" | "IoNode" | "IoSource" | "IoActor" | "Identity" | "Log" | "Location" | "Snapshot"

Type alias for all framework core types. This type is used for the coreType property of objects based on the CoatyObject interface.

ObjectFilterConditions

ObjectFilterConditions: { and?: ObjectFilterCondition[]; or?: ObjectFilterCondition[] }

Defines a set of conditions for filtering objects. Filter conditions can be combined by logical AND or OR as follows:

{
and: ObjectFilterCondition[],
}
{
or: ObjectFilterCondition[],
}

Type declaration

  • Optional and?: ObjectFilterCondition[]

    Multiple filter conditions combined by logical AND. Specify either the and or the or property, or none, but never both.

    An object filter condition is defined as a tuple specifying the name of an object property and a filter expression. The filter expression must evaluate to true when applied to the property's value for the condition to become true.

    The object property to be applied for filtering is specified either in dot notation or array notation. In dot notation, the name of the object property is specified as a string (e.g. "objectId"). It may include dots (.) to access nested properties of subobjects (e.g. "message.name"). If a single property name contains dots itself, you obviously cannot use dot notation. Instead, specify the property or nested properties as an array of strings (e.g. ["property.with.dots", "subproperty.with.dots"]).

    A filter expression is a tuple consisting of a filter operator and an operator-specific number of filter operands. You should use one of the typesafe filterOp functions to specify a filter expression.

  • Optional or?: ObjectFilterCondition[]

    Multiple filter conditions combined by logical OR. Specify either the and or the or property, or none, but never both.

    An object filter condition is defined as a tuple specifying the name of an object property and a filter expression. The filter expression must evaluate to true when applied to the property's value for the condition to become true.

    The object property to be applied for filtering is specified either in dot notation or array notation. In dot notation, the name of the object property is specified as a string (e.g. "objectId"). It may include dots (.) to access nested properties of subobjects (e.g. "message.name"). If a single property name contains dots itself, you obviously cannot use dot notation. Instead, specify the property or nested properties as an array of strings (e.g. ["property.with.dots", "subproperty.with.dots"]).

    A filter expression is a tuple consisting of a filter operator and an operator-specific number of filter operands. You should use one of the typesafe filterOp functions to specify a filter expression.

ObjectFilterProperties

ObjectFilterProperties: string | string[]

Defines the format of nested properties used in ObjectFilter conditions and orderByProperties clauses. Both dot notation ("property.subproperty.subsubproperty") and array notation (["property", "subproperty", "subsubproperty"]) are supported for naming nested properties. Note that dot notation cannot be used if one of the properties contains a dot (.) in its name. In such cases, array notation must be used.

Uuid

Uuid: string

Type alias for RFC4122 V4 UUIDs represented as strings.

Variables

filterOp

filterOp: { between: (value1: string | number, value2: string | number) => [ObjectFilterOperator, string | number, string | number]; contains: (values: any) => [ObjectFilterOperator, any]; equals: (value: any) => [ObjectFilterOperator, any]; exists: () => [ObjectFilterOperator]; greaterThan: (value: string | number) => [ObjectFilterOperator, string | number]; greaterThanOrEqual: (value: string | number) => [ObjectFilterOperator, string | number]; in: (values: any[]) => [ObjectFilterOperator, any[]]; lessThan: (value: string | number) => [ObjectFilterOperator, string | number]; lessThanOrEqual: (value: string | number) => [ObjectFilterOperator, string | number]; like: (pattern: string) => [ObjectFilterOperator, string]; notBetween: (value1: string | number, value2: string | number) => [ObjectFilterOperator, string | number, string | number]; notContains: (values: any) => [ObjectFilterOperator, any]; notEquals: (value: any) => [ObjectFilterOperator, any]; notExists: () => [ObjectFilterOperator]; notIn: (values: any[]) => [ObjectFilterOperator, any[]] } = ...

Defines filter operator functions that yield object filter expressions.

Type declaration

  • between: (value1: string | number, value2: string | number) => [ObjectFilterOperator, string | number, string | number]
      • (value1: string | number, value2: string | number): [ObjectFilterOperator, string | number, string | number]
      • Checks if the filter property is between the given values, i.e. prop >= value1 AND prop <= value2.

        If the first argument value1 is not less than or equal to the second argument value2, those two arguments are automatically swapped. For string comparison, a default lexical ordering is used. Note: Do not compare a number with a string, as the result is not defined.

        Parameters

        • value1: string | number
        • value2: string | number

        Returns [ObjectFilterOperator, string | number, string | number]

  • contains: (values: any) => [ObjectFilterOperator, any]
      • Checks if the filter property value (usually an object or array) contains the given values.

        Primitive value types (number, string, boolean, null) contain only the identical value. Object properties match if all the key-value pairs of the specified object are contained in them. Array properties match if all the specified array elements are contained in them.

        The general principle is that the contained object must match the containing object as to structure and data contents recursively on all levels, possibly after discarding some non-matching array elements or object key/value pairs from the containing object. But remember that the order of array elements is not significant when doing a containment match, and duplicate array elements are effectively considered only once.

        As a special exception to the general principle that the structures must match, an array on toplevel may contain a primitive value:

        contains([1, 2, 3], [3]) => true
        contains([1, 2, 3], 3) => true

        Parameters

        • values: any

        Returns [ObjectFilterOperator, any]

  • equals: (value: any) => [ObjectFilterOperator, any]
      • Checks if the filter property is deep equal to the given value according to a recursive equality algorithm.

        Note: do not check for undefined value as it is converted to null implicitely by JSON. Use the notExists operator instead.

        Parameters

        • value: any

        Returns [ObjectFilterOperator, any]

  • exists: () => [ObjectFilterOperator]
  • greaterThan: (value: string | number) => [ObjectFilterOperator, string | number]
      • Checks if the filter property is greater than the given value.

        For string comparison, a default lexical ordering is used. Note: Do not compare a number with a string, as the result is not defined.

        Parameters

        • value: string | number

        Returns [ObjectFilterOperator, string | number]

  • greaterThanOrEqual: (value: string | number) => [ObjectFilterOperator, string | number]
      • Checks if the filter property is greater than or equal to the given value.

        For string comparison, a default lexical ordering is used. Note: Do not compare a number with a string, as the result is not defined.

        Parameters

        • value: string | number

        Returns [ObjectFilterOperator, string | number]

  • in: (values: any[]) => [ObjectFilterOperator, any[]]
      • Checks if the filter property value is included on toplevel in the given operand array of values which may be primitive types (number, string, boolean, null) or object types compared using the deep equality operator.

        For example:

        in(47, [1, 46, 47, "foo"]) => true
        in(47, [1, 46, "47", "foo"]) => false
        in({ "foo": 47 }, [1, 46, { "foo": 47 }, "foo"]) => true
        in({ "foo": 47 }, [1, 46, { "foo": 47, "bar": 42 }, "foo"]) => false

        Parameters

        • values: any[]

        Returns [ObjectFilterOperator, any[]]

  • lessThan: (value: string | number) => [ObjectFilterOperator, string | number]
      • Checks if the filter property is less than the given value.

        For string comparison, a default lexical ordering is used. Note: Do not compare a number with a string, as the result is not defined.

        Parameters

        • value: string | number

        Returns [ObjectFilterOperator, string | number]

  • lessThanOrEqual: (value: string | number) => [ObjectFilterOperator, string | number]
      • Checks if the filter property is less than or equal to the given value.

        For string comparison, a default lexical ordering is used. Note: Do not compare a number with a string, as the result is not defined.

        Parameters

        • value: string | number

        Returns [ObjectFilterOperator, string | number]

  • like: (pattern: string) => [ObjectFilterOperator, string]
      • Checks if the filter property string matches the given pattern.

        If pattern does not contain percent signs or underscores, then the pattern only represents the string itself; in that case LIKE acts like the equals operator (but less performant). An underscore (_) in pattern stands for (matches) any single character; a percent sign (%) matches any sequence of zero or more characters.

        LIKE pattern matching always covers the entire string. Therefore, if it's desired to match a sequence anywhere within a string, the pattern must start and end with a percent sign.

        To match a literal underscore or percent sign without matching other characters, the respective character in pattern must be preceded by the escape character. The default escape character is the backslash. To match the escape character itself, write two escape characters.

        For example, the pattern string %a_c\\d\_ matches abc\d_ in hello abc\d_ and acc\d_ in acc\d_, but nothing in hello abc\d_world. Note that in programming languages like JavaScript, Java, or C#, where the backslash character is used as escape character for certain special characters you have to double backslashes in literal string constants. Thus, for the example above the pattern string literal would look like "%a_c\\\\d\\_".

        Parameters

        • pattern: string

        Returns [ObjectFilterOperator, string]

  • notBetween: (value1: string | number, value2: string | number) => [ObjectFilterOperator, string | number, string | number]
      • (value1: string | number, value2: string | number): [ObjectFilterOperator, string | number, string | number]
      • Checks if the filter property is not between the given values, i.e. prop < value1 OR prop > value2.

        If the first argument value1 is not less than or equal to the second argument value2, those two arguments are automatically swapped. For string comparison, a default lexical ordering is used. Note: Do not compare a number with a string, as the result is not defined.

        Parameters

        • value1: string | number
        • value2: string | number

        Returns [ObjectFilterOperator, string | number, string | number]

  • notContains: (values: any) => [ObjectFilterOperator, any]
      • Checks if the filter property value (usually an object or array) does not contain the given values.

        Primitive value types (number, string, boolean, null) contain only the identical value. Object properties match if all the key-value pairs of the specified object are not contained in them. Array properties match if all the specified array elements are not contained in them.

        The general principle is that the contained object must match the containing object as to structure and data contents recursively on all levels, possibly after discarding some non-matching array elements or object key/value pairs from the containing object. But remember that the order of array elements is not significant when doing a containment match, and duplicate array elements are effectively considered only once.

        As a special exception to the general principle that the structures must match, an array on toplevel may contain a primitive value:

        notContains([1, 2, 3], [3]) => false
        notContains([1, 2, 3], 3) => false

        Parameters

        • values: any

        Returns [ObjectFilterOperator, any]

  • notEquals: (value: any) => [ObjectFilterOperator, any]
      • Checks if the filter property is not deep equal to the given value according to a recursive equality algorithm.

        Note: do not check for undefined value as it is converted to null implicitely by JSON. Use the Exists operator instead.

        Parameters

        • value: any

        Returns [ObjectFilterOperator, any]

  • notExists: () => [ObjectFilterOperator]
  • notIn: (values: any[]) => [ObjectFilterOperator, any[]]
      • Checks if the filter property value is not included on toplevel in the given operand array of values which may be primitive types (number, string, boolean, null) or object types compared using the deep equality operator.

        For example:

        notIn(47, [1, 46, 47, "foo"]) => false
        notIn(47, [1, 46, "47", "foo"]) => true
        notIn({ "foo": 47 }, [1, 46, { "foo": 47 }, "foo"]) => false
        notIn({ "foo": 47 }, [1, 46, { "foo": 47, "bar": 42 }, "foo"]) => true

        Parameters

        • values: any[]

        Returns [ObjectFilterOperator, any[]]

Functions

areObjectJoinConditionsValid

binaryInsert

  • binaryInsert<T>(source: T[], item: T, compareFn: (a: T, b: T) => number): void
  • Inserts the item into the sorted Array<T> using the given compare function on the item.

    The Array<T> must already be sorted according to the compare function implementation; otherwise, the result is incorrect.

    The compare function returns a value indicating whether the first argument is less than (return value < 0), equal to (return value === 0), or greater than (return value > 0) the second argument. The first argument is an item from the source array, the second argument is always the given item.

    Type parameters

    • T

    Parameters

    • source: T[]

      The sorted source array

    • item: T

      The value to insert.

    • compareFn: (a: T, b: T) => number

      The function to use when comparing elements.

        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns void

binarySearch

  • binarySearch<T>(source: T[], value: T, compareFn: (a: T, b: T) => number, startIndex?: number, endIndex?: number): number
  • Searches the entire sorted Array<T> for an element using the specified compare function and returns the zero-based index of the element.

    Returns the zero-based index of item in the sorted Array<T>, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of the array length.

    The Array<T> must already be sorted according to the compare function implementation; otherwise, the result is incorrect.

    The compare function returns a value indicating whether the first argument is less than (return value < 0), equal to (return value === 0), or greater than (return value > 0) the second argument. The first argument is an item from the source array, the second argument is always the given value.

    If the Array<T> contains more than one element with the same value, the function returns only one of the occurrences, and it might return any one of the occurrences, not necessarily the first one.

    Type parameters

    • T

    Parameters

    • source: T[]

      The sorted source array

    • value: T

      The value to locate.

    • compareFn: (a: T, b: T) => number

      The function to use when comparing elements.

        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    • startIndex: number = 0

      The zero-based starting index of the range to search (optional).

    • endIndex: number = ...

      The zero-based ending index (inclusive) of the range to search (optional).

    Returns number

clone

  • clone(obj: any): any
  • Deep copies a given value that can be represented as a JSON value. Behaves identical to JSON.parse(JSON.stringify(obj))., i.e. it throws an exception when a circular structure is detected, and copies a Date object into its ISO date string. All (own and inherited) enumerable properties of objects are copied.

    Parameters

    • obj: any

      any value that can be represented as a JSON value

    Returns any

contains

  • contains(a: any, b: any): boolean
  • Checks if a JavaScript value (usually an object or array) contains other values. Primitive value types (number, string, boolean, null,undefined) contain only the identical value. Object properties match if all the key-value pairs of the specified object are contained in them. Array properties match if all the specified array elements are contained in them.

    The general principle is that the contained object must match the containing object as to structure and data contents recursively on all levels, possibly after discarding some non-matching array elements or object key/value pairs from the containing object. But remember that the order of array elements is not significant when doing a containment match, and duplicate array elements are effectively considered only once.

    As a special exception to the general principle that the structures must match, an array on toplevel may contain a primitive value:

    contains([1, 2, 3], [3]) => true
    contains([1, 2, 3], 3) => true

    Note that the strict equality operator === is used to compare primitive values. For checking the containment of properties in objects the hasOwnProperty operator is used, i.e. only properties defined on the object directly (not inherited) are considered.

    For example:

    import { contains } from "@coaty/core";

    contains("foo" , "foo") => true

    contains([1, 2, 3] , []) => true
    contains([1, 2, 3] , [3, 1]) => true
    contains([1, 2, 3] , [3, 1, 3, 1]) => true
    contains([1, 2, 3] , [3, 1, 5]) => false
    contains([1, [2, 3, 4], 3] , [3, [3, 2]]) => true
    contains([1, [2, 3, 4], 3] , [3, [3, 1]]) => false

    contains{( "foo": 1, "bar": 2 } , { "bar": 2 }) => true
    contains({ "foo": 1, "bar": 2 } , { "bar": 2, "foo": 1 }) => true
    contains({ "foo": 1, "bar": 2 } , { "bar": 2, "foo": 2 }) => false
    contains({ "foo": { "bar": "baz" }}, { "foo": {} }) => true
    contains({ "foo": { "bar": "baz" }}, { "bar": "baz" }) => false

    contains([1, { "foo": [{ "bar": [1, 2, 3] }, 2, 3] }], [{ "foo": [{ "bar": [3] }] }]) => true

    Parameters

    • a: any

      a JavaScript value containing another value

    • b: any

      a JavaScript value to be contained in another value

    Returns boolean

equals

  • equals(a: any, b: any): boolean
  • Determines whether two JavaScript values, typically objects or arrays, are structurally equal (aka. deep equal) according to a recursive equality algorithm.

    Note that the strict equality operator === is used to compare leaf values. For checking the containment of properties in objects the hasOwnProperty operator is used, i.e. only properties defined on the object directly (not inherited) are considered.

    For example:

    import { equals } from "@coaty/core";

    equals({ a : [ 2, 3 ], b : [ 4 ] }, { a : [ 2, 3 ], b : [ 4 ] })) => true
    equals({ x : 5, y : [6] }, { x : 5, y : 6 })) => false

    Parameters

    • a: any

      a JavaScript value

    • b: any

      a JavaScript value

    Returns boolean

includes

  • includes(a: any[], b: any): boolean
  • Checks if a value is included on toplevel in the given operand array of values which may be primitive types (number, string, boolean, null) or object types compared using the equals deep equality operator.

    For example:

    import { includes } from "@coaty/core";

    includes([1, 46, 47, "foo"], 47) => true
    includes([1, 46, "47", "foo"], 47) => false
    includes([1, 46, { "foo": 47 }, "foo"], { "foo": 47 }) => true
    includes([1, 46, { "foo": 47, "bar": 42 }, "foo"], { "foo": 47 }) => false

    Parameters

    • a: any[]

      a JavaScript value to be contained on toplevel in an array

    • b: any

      a JavaScript array containing another value on toplevel

    Returns boolean

isContextFilterValid

isObjectFilterValid

isPlainObject

  • isPlainObject(value: any): boolean
  • Checks if value is a plain JavaScript object, that is, an object created by an object literal, the Object constructor, or one with a prototype of null, i.e. Object.create(null).

    Parameters

    • value: any

      the value to check.

    Returns boolean

    true if value is a plain object, else false

isTimeInterval

  • isTimeInterval(obj: any): boolean

isValidTimeInterval

mergeConfigurations

  • Returns a new Coaty container configuration object as a result of merging the two given (partial) primary and secondary configurations.

    For each sub-configuration object (common, communication, etc.) the value of a property specified in primary overrides the value specified in secondary. In other words, the value of a secondary sub-configuration property is only taken if this property is not defined in primary. Note that merging only considers direct properties on the subconfiguration object level, not sub-levels thereof.

    throws

    if merged configuration misses required sub-configuration options.

    Parameters

    • primary: Partial<Configuration>

      the (partial) primary configuration

    • secondary: Partial<Configuration>

      the (partial) secondary configuration to be merged

    Returns Configuration

toDurationIsoString

  • toDurationIsoString(duration: number): string
  • Returns a string in ISO 8601 format for a duration.

    Parameters

    • duration: number

      a duration given in milliseconds

    Returns string

toLocalIntervalIsoString

  • toLocalIntervalIsoString(interval: TimeInterval, includeMillis?: boolean): string
  • Returns a string in ISO 8601 format for a time interval including timezone offset information.

    Parameters

    • interval: TimeInterval

      a TimeInterval object

    • includeMillis: boolean = false

      whether to include milliseconds in the string (defaults to false)

    Returns string

toLocalIsoString

  • toLocalIsoString(date: Date, includeMillis?: boolean): string
  • Returns a string in ISO 8601 format including timezone offset information.

    Parameters

    • date: Date

      a Date object

    • includeMillis: boolean = false

      whether to include milliseconds in the string (defaults to false)

    Returns string

Generated using TypeDoc