@formant/data-sdk 0.0.132 → 0.0.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-sdk.es.js +133 -4
- package/dist/data-sdk.umd.js +3 -3
- package/dist/types/data-sdk/src/Device.d.ts +16 -0
- package/dist/types/data-sdk/src/Fleet.d.ts +13 -2
- package/dist/types/data-sdk/src/main.d.ts +1 -0
- package/dist/types/data-sdk/src/model/AggregateLevel.d.ts +1 -1
- package/dist/types/data-sdk/src/utils/aggregateFunctionUtils.d.ts +11 -0
- package/package.json +1 -1
package/dist/data-sdk.es.js
CHANGED
|
@@ -4,6 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
+
import * as dateFns from "date-fns";
|
|
7
8
|
import { startOfMinute, addMinutes, roundToNearestMinutes, addSeconds } from "date-fns";
|
|
8
9
|
var dist = { exports: {} };
|
|
9
10
|
/*! For license information please see index.js.LICENSE.txt */
|
|
@@ -20626,6 +20627,25 @@ class Device {
|
|
|
20626
20627
|
const interventionResponse = await response.json();
|
|
20627
20628
|
return interventionResponse;
|
|
20628
20629
|
}
|
|
20630
|
+
async getAnnotationCount(query, tagKey) {
|
|
20631
|
+
return await Fleet.getAnnotationCount(
|
|
20632
|
+
{ ...query, deviceIds: [this.id] },
|
|
20633
|
+
tagKey
|
|
20634
|
+
);
|
|
20635
|
+
}
|
|
20636
|
+
async getAnnotationCountByIntervals(query, tagKey, aggregate) {
|
|
20637
|
+
return await Fleet.getAnnotationCountByIntervals(
|
|
20638
|
+
{ ...query, deviceIds: [this.id] },
|
|
20639
|
+
tagKey,
|
|
20640
|
+
aggregate
|
|
20641
|
+
);
|
|
20642
|
+
}
|
|
20643
|
+
async eventsCounter(eventTypes2, timeFrame, range, time, query) {
|
|
20644
|
+
return await Fleet.eventsCounter(eventTypes2, timeFrame, range, time, {
|
|
20645
|
+
...query,
|
|
20646
|
+
deviceIds: [this.id]
|
|
20647
|
+
});
|
|
20648
|
+
}
|
|
20629
20649
|
}
|
|
20630
20650
|
class PeerDevice {
|
|
20631
20651
|
constructor(peerUrl) {
|
|
@@ -21205,9 +21225,7 @@ const _Fleet = class {
|
|
|
21205
21225
|
});
|
|
21206
21226
|
return devices;
|
|
21207
21227
|
}
|
|
21208
|
-
static async getAnnotationCount(query) {
|
|
21209
|
-
const tagKey = query.tagKey;
|
|
21210
|
-
delete query.tagKey, delete query.aggregate;
|
|
21228
|
+
static async getAnnotationCount(query, tagKey) {
|
|
21211
21229
|
const annotations = await this.queryEvents({
|
|
21212
21230
|
...query,
|
|
21213
21231
|
eventTypes: ["annotation"]
|
|
@@ -21226,6 +21244,31 @@ const _Fleet = class {
|
|
|
21226
21244
|
}, {});
|
|
21227
21245
|
return annotationCounter;
|
|
21228
21246
|
}
|
|
21247
|
+
static async getAnnotationCountByIntervals(query, tagKey, aggregate) {
|
|
21248
|
+
const { end, start } = query;
|
|
21249
|
+
const dateFunctions = aggregateByDateFunctions[aggregate];
|
|
21250
|
+
const intervals = dateFunctions.interval({
|
|
21251
|
+
start: new Date(start),
|
|
21252
|
+
end: new Date(end)
|
|
21253
|
+
});
|
|
21254
|
+
const annotationsQuery = intervals.map((_, idx) => {
|
|
21255
|
+
const startDate = new Date(_).toISOString();
|
|
21256
|
+
const endDate = idx === intervals.length - 1 ? new Date(Date.now()).toISOString() : new Date(intervals[idx + 1]);
|
|
21257
|
+
return this.getAnnotationCount(
|
|
21258
|
+
{
|
|
21259
|
+
...query,
|
|
21260
|
+
start: startDate,
|
|
21261
|
+
end: endDate
|
|
21262
|
+
},
|
|
21263
|
+
tagKey
|
|
21264
|
+
);
|
|
21265
|
+
});
|
|
21266
|
+
const responses = await Promise.all(annotationsQuery);
|
|
21267
|
+
return intervals.map((_, idx) => ({
|
|
21268
|
+
date: new Date(_).toISOString(),
|
|
21269
|
+
annotations: responses[idx]
|
|
21270
|
+
}));
|
|
21271
|
+
}
|
|
21229
21272
|
static async getStreams() {
|
|
21230
21273
|
if (!Authentication.token) {
|
|
21231
21274
|
throw new Error("Not authenticated");
|
|
@@ -21259,6 +21302,33 @@ const _Fleet = class {
|
|
|
21259
21302
|
);
|
|
21260
21303
|
return await response.json();
|
|
21261
21304
|
}
|
|
21305
|
+
static async eventsCounter(eventTypes2, timeFrame, range, time, query) {
|
|
21306
|
+
const dateFunctions = aggregateByDateFunctions[timeFrame];
|
|
21307
|
+
return await Promise.all(
|
|
21308
|
+
Array(range).fill(0).map(async (_, dateOffset) => {
|
|
21309
|
+
const activePointInTimeLine = new Date(time);
|
|
21310
|
+
const startDate = dateFunctions.sub(
|
|
21311
|
+
dateFunctions.start(activePointInTimeLine),
|
|
21312
|
+
range - dateOffset - 1
|
|
21313
|
+
);
|
|
21314
|
+
const endDate = dateFunctions.sub(
|
|
21315
|
+
dateFunctions.end(activePointInTimeLine),
|
|
21316
|
+
range - dateOffset - 1
|
|
21317
|
+
);
|
|
21318
|
+
const date = formatTimeFrameText(
|
|
21319
|
+
startDate.toLocaleDateString(),
|
|
21320
|
+
endDate.toLocaleDateString()
|
|
21321
|
+
);
|
|
21322
|
+
const events = await _Fleet.queryEvents({
|
|
21323
|
+
...query,
|
|
21324
|
+
eventTypes: eventTypes2,
|
|
21325
|
+
start: new Date(startDate).toISOString(),
|
|
21326
|
+
end: new Date(endDate).toISOString()
|
|
21327
|
+
});
|
|
21328
|
+
return { date, events };
|
|
21329
|
+
})
|
|
21330
|
+
);
|
|
21331
|
+
}
|
|
21262
21332
|
};
|
|
21263
21333
|
let Fleet = _Fleet;
|
|
21264
21334
|
__publicField(Fleet, "defaultDeviceId");
|
|
@@ -21346,6 +21416,13 @@ class KeyValue {
|
|
|
21346
21416
|
}
|
|
21347
21417
|
}
|
|
21348
21418
|
}
|
|
21419
|
+
const aggregateFunctions = [
|
|
21420
|
+
"interval",
|
|
21421
|
+
"start",
|
|
21422
|
+
"end",
|
|
21423
|
+
"sub",
|
|
21424
|
+
"get"
|
|
21425
|
+
];
|
|
21349
21426
|
function getVariance(a2) {
|
|
21350
21427
|
if (a2.count < 2) {
|
|
21351
21428
|
return 0;
|
|
@@ -21378,6 +21455,58 @@ const aggregateFunctionMap = {
|
|
|
21378
21455
|
sum: getSum,
|
|
21379
21456
|
count: getCount
|
|
21380
21457
|
};
|
|
21458
|
+
const aggregateByDateFunctions = {
|
|
21459
|
+
day: {
|
|
21460
|
+
interval: dateFns.eachDayOfInterval,
|
|
21461
|
+
start: dateFns.startOfDay,
|
|
21462
|
+
end: dateFns.endOfDay,
|
|
21463
|
+
sub: dateFns.subDays,
|
|
21464
|
+
get: dateFns.getDay
|
|
21465
|
+
},
|
|
21466
|
+
week: {
|
|
21467
|
+
interval: dateFns.eachWeekOfInterval,
|
|
21468
|
+
start: dateFns.startOfWeek,
|
|
21469
|
+
end: dateFns.endOfWeek,
|
|
21470
|
+
sub: dateFns.subWeeks,
|
|
21471
|
+
get: dateFns.getWeek
|
|
21472
|
+
},
|
|
21473
|
+
month: {
|
|
21474
|
+
interval: dateFns.eachMonthOfInterval,
|
|
21475
|
+
start: dateFns.startOfMonth,
|
|
21476
|
+
end: dateFns.endOfMonth,
|
|
21477
|
+
sub: dateFns.subMonths,
|
|
21478
|
+
get: dateFns.getMonth
|
|
21479
|
+
},
|
|
21480
|
+
year: {
|
|
21481
|
+
interval: dateFns.eachYearOfInterval,
|
|
21482
|
+
start: dateFns.startOfYear,
|
|
21483
|
+
end: dateFns.endOfYear,
|
|
21484
|
+
sub: dateFns.subYears,
|
|
21485
|
+
get: dateFns.getYear
|
|
21486
|
+
},
|
|
21487
|
+
hour: {
|
|
21488
|
+
interval: dateFns.eachHourOfInterval,
|
|
21489
|
+
start: dateFns.startOfHour,
|
|
21490
|
+
end: dateFns.endOfHour,
|
|
21491
|
+
sub: dateFns.subHours,
|
|
21492
|
+
get: dateFns.getHours
|
|
21493
|
+
},
|
|
21494
|
+
minute: {
|
|
21495
|
+
interval: dateFns.eachMinuteOfInterval,
|
|
21496
|
+
start: dateFns.startOfMinute,
|
|
21497
|
+
end: dateFns.endOfMinute,
|
|
21498
|
+
sub: dateFns.subMinutes,
|
|
21499
|
+
get: dateFns.getMinutes
|
|
21500
|
+
},
|
|
21501
|
+
quarter: {
|
|
21502
|
+
interval: dateFns.eachQuarterOfInterval,
|
|
21503
|
+
start: dateFns.startOfQuarter,
|
|
21504
|
+
end: dateFns.endOfQuarter,
|
|
21505
|
+
sub: dateFns.subQuarters,
|
|
21506
|
+
get: dateFns.getQuarter
|
|
21507
|
+
}
|
|
21508
|
+
};
|
|
21509
|
+
const formatTimeFrameText = (start, end) => start.split("/")[0] + "/" + start.split("/")[1] + "\u2013" + end.split("/")[0] + "/" + end.split("/")[1];
|
|
21381
21510
|
function getZeroINumericSet() {
|
|
21382
21511
|
return {
|
|
21383
21512
|
min: Number.MAX_SAFE_INTEGER,
|
|
@@ -21620,4 +21749,4 @@ if (moduleName) {
|
|
|
21620
21749
|
var IRtcSendConfiguration = dist.exports.IRtcSendConfiguration;
|
|
21621
21750
|
var IRtcStreamMessage = dist.exports.IRtcStreamMessage;
|
|
21622
21751
|
var IRtcStreamPayload = dist.exports.IRtcStreamPayload;
|
|
21623
|
-
export { App, AudioPlayer, Authentication, BinaryRequestDataChannel, CaptureStream, DataChannel, Device, Fleet, IRtcSendConfiguration, IRtcStreamMessage, IRtcStreamPayload, KeyValue, Manipulator, PeerDevice, SessionType, TextRequestDataChannel, accessLevels, administrator, aggregateFunctionMap, aggregateLevels, annotationTypes, combineNumericAggregates, combineNumericSetAggregates, eventTypes, getAverage, getCount, getMax, getMin, getStandardDeviation, getSum, getVariance, getZeroINumericSet, healthStatuses, interventionTypes, operator, reduceNumericSetStreamAggregates, reduceNumericStreamAggregates, severities, videoMimeTypes, viewer };
|
|
21752
|
+
export { App, AudioPlayer, Authentication, BinaryRequestDataChannel, CaptureStream, DataChannel, Device, Fleet, IRtcSendConfiguration, IRtcStreamMessage, IRtcStreamPayload, KeyValue, Manipulator, PeerDevice, SessionType, TextRequestDataChannel, accessLevels, administrator, aggregateByDateFunctions, aggregateFunctionMap, aggregateFunctions, aggregateLevels, annotationTypes, combineNumericAggregates, combineNumericSetAggregates, eventTypes, formatTimeFrameText, getAverage, getCount, getMax, getMin, getStandardDeviation, getSum, getVariance, getZeroINumericSet, healthStatuses, interventionTypes, operator, reduceNumericSetStreamAggregates, reduceNumericStreamAggregates, severities, videoMimeTypes, viewer };
|