solarnetwork-api-core
    Preparing search index...

    Class DatumIdentifier

    A general datum identifier class.

    A datum identifier must be fully specified to be valid. A fully specified identifier must meet either of these requirements (in addition to having kind and timestamp values):

    • a streamId value
    • both objectId and sourceId values

    The objectId plus sourceId values together represent an alias for the streamId.

    The absence of an aggregation implies "no aggregation", or the None aggregation value.

    Create instances of this class like:

    import { Aggregations, DatumIdentifier } from "solarnetwork-api-core";

    const ts = new Date();
    const streamId = "7714f762-2361-4ec2-98ab-7e96807b32a6";
    const sourceId = "meter/1";
    const nodeId = 123;
    const agg = Aggregations.None;

    // create a node stream style identifier
    let ident = DatumIdentifier.nodeId(ts, streamId);

    // create a node and source style identifier
    let ident = DatumIdentifier.nodeId(ts, sourceId, nodeId);

    // create a full stream and node and source style identifier
    let ident = DatumIdentifier.nodeId(ts, sourceId, nodeId, agg, streamId);

    Implements

    Index

    Constructors

    • Construct a stream ID style identifier.

      Parameters

      • kind: DatumStreamType

        the datum kind, or kind key or name value

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • streamId: string

        the datum stream ID

      • Optionalaggregation: Aggregation

        the aggregation

      Returns DatumIdentifier

    • Construct an object and source ID style identifier.

      Parameters

      • kind: DatumStreamType

        the datum kind, or kind key or name value

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • sourceId: string

        the datum source ID

      • objectId: number

        the datum object ID

      • Optionalaggregation: Aggregation

        the aggregation

      Returns DatumIdentifier

    • Construct an object and source ID style identifier along with a stream ID.

      Parameters

      • kind: string | DatumStreamType

        the datum kind, or kind key or name value

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • sourceId: string

        the datum source ID

      • objectId: number

        the datum object ID

      • Optionalaggregation: Aggregation

        the aggregation

      • OptionalstreamId: string

        the datum stream ID

      Returns DatumIdentifier

    Properties

    aggregation?: Aggregation

    The aggregation.

    The datum stream kind (node, location).

    objectId?: number

    The object ID (node, location).

    sourceId?: string

    The source ID.

    streamId?: string

    The datum stream ID.

    timestamp: Date

    The datum creation/capture date.

    Methods

    • Test if this identifier is fully specified.

      A datum identifier is considered fully specified if all of the following are true:

      • the kind and timestamp properties are defined
      • the streamId property is defined, or both the objectId and sourceId properties are defined

      In essence, there are two styles of datum identifier:

      1. using a stream ID
      2. using an object and source ID pair

      An object and source ID pair are alises for a corresponding stream ID, but are often more convenient for people to use.

      Returns boolean

      true if this identifier if fully specified

    • Get this object in standard JSON form.

      An example result looks like this:

      {
      "kind": "n",
      "timestamp": "2025-02-01 12:00:00.000Z"
      "streamId": "7714f762-2361-4ec2-98ab-7e96807b32a6",
      "objectId": 123,
      "sourceId": "/power/1",
      "aggregation": "None"
      }

      Returns Record<string, any>

      an object, ready for JSON encoding

    • Create a location stream ID style identifier.

      Parameters

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • streamId: string

        the datum stream ID

      • Optionalaggregation: Aggregation

        the aggregation

      Returns DatumIdentifier

    • Create a location and source ID style identifier.

      Parameters

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • sourceId: string

        the datum source ID

      • locationId: number

        the datum location ID

      • Optionalaggregation: Aggregation

        the aggregation

      Returns DatumIdentifier

    • Create a location and source ID style identifier along with a stream ID.

      Parameters

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • sourceId: string

        the datum source ID

      • locationId: number

        the datum location ID

      • Optionalaggregation: Aggregation

        the aggregation

      • OptionalstreamId: string

        the datum stream ID

      Returns DatumIdentifier

    • Create a stream ID style identifier.

      Parameters

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • streamId: string

        the datum stream ID

      • Optionalaggregation: Aggregation

        the aggregation

      Returns DatumIdentifier

    • Create a node and source ID style identifier.

      Parameters

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • sourceId: string

        the datum source ID

      • nodeId: number

        the datum node ID

      • Optionalaggregation: Aggregation

        the aggregation

      Returns DatumIdentifier

    • Create a node and source ID style identifier along with a stream ID.

      Parameters

      • timestamp: string | number | Date

        the datum timestamp, either as a Date instance or a form suitable for constructing as new Date(ts)

      • sourceId: string

        the datum source ID

      • nodeId: number

        the datum node ID

      • Optionalaggregation: Aggregation

        the aggregation

      • OptionalstreamId: string

        the datum stream ID

      Returns DatumIdentifier