Class to find the available datum date range for a set of datum filters.

This is useful when generating reports or charts for a set of SolarNode datum streams, so the overall start/end dates can be determined before requesting the actual data. It returns an object starting and ending date related properties, for example:

{
"timeZone": "Pacific/Auckland",
"sDate": Date(1248668709972),
"startDate": "2009-07-27 16:25",
"startDateMillis": 1248668709972,
"eDate": Date(1379824746781),
"endDate": "2013-09-22 16:39",
"endDateMillis": 1379824746781
}

Additionally a ranges property is provided with an array of each filter's raw range result, so you can see each result individually if you need that.

Example

// the simple case, for just one node
const filter = new DatumFilter();
filter.nodeId = 123;
filter.sourceIds = ['a', 'b'];
const range = await new DatumRangeFinder(new SolarQueryApi(), filter).fetch();

Example

// more complex case, for multiple SolarNode / source ID combinations
const filter2 = new SolarQueryApi();
filter2.nodeId = 234;
filter2.sourceId = 'c';
const range2 = await new DatumRangeFinder(api, [filter, filter2]).fetch();

Example

// with authentication; note the authentication must be valid for all nodes!
const auth = new AuthorizationV2Builder('my-token');
auth.saveSigningKey('secret');
const range3 = await new DatumRangeFinder(api, [filter1, filter2], auth).fetch();

Version

2.0.0

Hierarchy (view full)

Implements

Constructors

  • Constructor.

    Parameters

    • api: default

      the API helper to use

    • filters: DatumFilter | DatumFilter[]

      the filter(s) to find the ranges for; each filter must provide at least one node ID

    • Optional authBuilder: AuthorizationV2Builder

      the auth builder to authenticate requests with; if not provided then only public data can be queried; when provided a pre-signed key must be available

    Returns DatumRangeFinder

Properties

#filters: DatumFilter[]
api: default

The API instance to use.

authBuilder?: AuthorizationV2Builder

An authorization builder to use to make authenticated HTTP requests.

Methods

  • Create a URL fetch requestor.

    The returned function can be passed to d3.queue or invoked directly.

    Type Parameters

    • V

    Parameters

    • url: string

      the URL to request.

    • Optional signUrl: string

      the URL to sign (might be different to url if a proxy is used)

    Returns ((cb) => void)

    a function that accepts a callback argument