solarnetwork-api-core
    Preparing search index...

    Class DatumRangeFinder

    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.

    // 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();
    // 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();
    // 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();

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    The URL helper instance to use.

    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.

      • OptionalsignUrl: string

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

      • Optionaldelay: number

        an optional number of milliseconds to sleep before initiating the request

      Returns (cb: LoaderDataCallbackFn<V>) => void

      a function that accepts a callback argument