@formant/data-sdk 0.0.133 → 0.0.135
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 +96 -15
- package/dist/data-sdk.umd.js +3 -3
- package/dist/types/data-sdk/src/Device.d.ts +7 -2
- package/dist/types/data-sdk/src/Fleet.d.ts +10 -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/model/IView.d.ts +15 -0
- package/dist/types/data-sdk/src/utils/aggregateFunctionUtils.d.ts +5 -5
- package/package.json +1 -1
package/dist/data-sdk.es.js
CHANGED
|
@@ -20627,21 +20627,25 @@ class Device {
|
|
|
20627
20627
|
const interventionResponse = await response.json();
|
|
20628
20628
|
return interventionResponse;
|
|
20629
20629
|
}
|
|
20630
|
-
async getAnnotationCount(query,
|
|
20630
|
+
async getAnnotationCount(query, tagKey) {
|
|
20631
20631
|
return await Fleet.getAnnotationCount(
|
|
20632
20632
|
{ ...query, deviceIds: [this.id] },
|
|
20633
|
-
annotationName,
|
|
20634
20633
|
tagKey
|
|
20635
20634
|
);
|
|
20636
20635
|
}
|
|
20637
|
-
async getAnnotationCountByIntervals(query,
|
|
20636
|
+
async getAnnotationCountByIntervals(query, tagKey, aggregate) {
|
|
20638
20637
|
return await Fleet.getAnnotationCountByIntervals(
|
|
20639
20638
|
{ ...query, deviceIds: [this.id] },
|
|
20640
|
-
annotationName,
|
|
20641
20639
|
tagKey,
|
|
20642
20640
|
aggregate
|
|
20643
20641
|
);
|
|
20644
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
|
+
}
|
|
20645
20649
|
}
|
|
20646
20650
|
class PeerDevice {
|
|
20647
20651
|
constructor(peerUrl) {
|
|
@@ -21221,10 +21225,9 @@ const _Fleet = class {
|
|
|
21221
21225
|
});
|
|
21222
21226
|
return devices;
|
|
21223
21227
|
}
|
|
21224
|
-
static async getAnnotationCount(query,
|
|
21228
|
+
static async getAnnotationCount(query, tagKey) {
|
|
21225
21229
|
const annotations = await this.queryEvents({
|
|
21226
21230
|
...query,
|
|
21227
|
-
message: annotationName,
|
|
21228
21231
|
eventTypes: ["annotation"]
|
|
21229
21232
|
});
|
|
21230
21233
|
const validAnnotations = annotations.filter(
|
|
@@ -21241,7 +21244,7 @@ const _Fleet = class {
|
|
|
21241
21244
|
}, {});
|
|
21242
21245
|
return annotationCounter;
|
|
21243
21246
|
}
|
|
21244
|
-
static async getAnnotationCountByIntervals(query,
|
|
21247
|
+
static async getAnnotationCountByIntervals(query, tagKey, aggregate) {
|
|
21245
21248
|
const { end, start } = query;
|
|
21246
21249
|
const dateFunctions = aggregateByDateFunctions[aggregate];
|
|
21247
21250
|
const intervals = dateFunctions.interval({
|
|
@@ -21257,7 +21260,6 @@ const _Fleet = class {
|
|
|
21257
21260
|
start: startDate,
|
|
21258
21261
|
end: endDate
|
|
21259
21262
|
},
|
|
21260
|
-
annotationName,
|
|
21261
21263
|
tagKey
|
|
21262
21264
|
);
|
|
21263
21265
|
});
|
|
@@ -21300,6 +21302,64 @@ const _Fleet = class {
|
|
|
21300
21302
|
);
|
|
21301
21303
|
return await response.json();
|
|
21302
21304
|
}
|
|
21305
|
+
static async getViews() {
|
|
21306
|
+
if (!Authentication.token) {
|
|
21307
|
+
throw new Error("Not authenticated");
|
|
21308
|
+
}
|
|
21309
|
+
const response = await fetch(`${FORMANT_API_URL}/v1/admin/views`, {
|
|
21310
|
+
method: "GET",
|
|
21311
|
+
headers: {
|
|
21312
|
+
"Content-Type": "application/json",
|
|
21313
|
+
Authorization: "Bearer " + Authentication.token
|
|
21314
|
+
}
|
|
21315
|
+
});
|
|
21316
|
+
const views = await response.json();
|
|
21317
|
+
return views.items;
|
|
21318
|
+
}
|
|
21319
|
+
static async patchView(view) {
|
|
21320
|
+
if (!Authentication.token) {
|
|
21321
|
+
throw new Error("Not authenticated");
|
|
21322
|
+
}
|
|
21323
|
+
const response = await fetch(
|
|
21324
|
+
`${FORMANT_API_URL}/v1/admin/views/${view.id}`,
|
|
21325
|
+
{
|
|
21326
|
+
method: "PATCH",
|
|
21327
|
+
body: JSON.stringify(view),
|
|
21328
|
+
headers: {
|
|
21329
|
+
"Content-Type": "application/json",
|
|
21330
|
+
Authorization: "Bearer " + Authentication.token
|
|
21331
|
+
}
|
|
21332
|
+
}
|
|
21333
|
+
);
|
|
21334
|
+
return await response.json();
|
|
21335
|
+
}
|
|
21336
|
+
static async eventsCounter(eventTypes2, timeFrame, range, time, query) {
|
|
21337
|
+
const dateFunctions = aggregateByDateFunctions[timeFrame];
|
|
21338
|
+
return await Promise.all(
|
|
21339
|
+
Array(range).fill(0).map(async (_, dateOffset) => {
|
|
21340
|
+
const activePointInTimeLine = new Date(time);
|
|
21341
|
+
const startDate = dateFunctions.sub(
|
|
21342
|
+
dateFunctions.start(activePointInTimeLine),
|
|
21343
|
+
range - dateOffset - 1
|
|
21344
|
+
);
|
|
21345
|
+
const endDate = dateFunctions.sub(
|
|
21346
|
+
dateFunctions.end(activePointInTimeLine),
|
|
21347
|
+
range - dateOffset - 1
|
|
21348
|
+
);
|
|
21349
|
+
const date = formatTimeFrameText(
|
|
21350
|
+
startDate.toLocaleDateString(),
|
|
21351
|
+
endDate.toLocaleDateString()
|
|
21352
|
+
);
|
|
21353
|
+
const events = await _Fleet.queryEvents({
|
|
21354
|
+
...query,
|
|
21355
|
+
eventTypes: eventTypes2,
|
|
21356
|
+
start: new Date(startDate).toISOString(),
|
|
21357
|
+
end: new Date(endDate).toISOString()
|
|
21358
|
+
});
|
|
21359
|
+
return { date, events };
|
|
21360
|
+
})
|
|
21361
|
+
);
|
|
21362
|
+
}
|
|
21303
21363
|
};
|
|
21304
21364
|
let Fleet = _Fleet;
|
|
21305
21365
|
__publicField(Fleet, "defaultDeviceId");
|
|
@@ -21387,6 +21447,13 @@ class KeyValue {
|
|
|
21387
21447
|
}
|
|
21388
21448
|
}
|
|
21389
21449
|
}
|
|
21450
|
+
const aggregateFunctions = [
|
|
21451
|
+
"interval",
|
|
21452
|
+
"start",
|
|
21453
|
+
"end",
|
|
21454
|
+
"sub",
|
|
21455
|
+
"get"
|
|
21456
|
+
];
|
|
21390
21457
|
function getVariance(a2) {
|
|
21391
21458
|
if (a2.count < 2) {
|
|
21392
21459
|
return 0;
|
|
@@ -21424,39 +21491,53 @@ const aggregateByDateFunctions = {
|
|
|
21424
21491
|
interval: dateFns.eachDayOfInterval,
|
|
21425
21492
|
start: dateFns.startOfDay,
|
|
21426
21493
|
end: dateFns.endOfDay,
|
|
21427
|
-
sub: dateFns.subDays
|
|
21494
|
+
sub: dateFns.subDays,
|
|
21495
|
+
get: dateFns.getDay
|
|
21428
21496
|
},
|
|
21429
21497
|
week: {
|
|
21430
21498
|
interval: dateFns.eachWeekOfInterval,
|
|
21431
21499
|
start: dateFns.startOfWeek,
|
|
21432
21500
|
end: dateFns.endOfWeek,
|
|
21433
|
-
sub: dateFns.subWeeks
|
|
21501
|
+
sub: dateFns.subWeeks,
|
|
21502
|
+
get: dateFns.getWeek
|
|
21434
21503
|
},
|
|
21435
21504
|
month: {
|
|
21436
21505
|
interval: dateFns.eachMonthOfInterval,
|
|
21437
21506
|
start: dateFns.startOfMonth,
|
|
21438
21507
|
end: dateFns.endOfMonth,
|
|
21439
|
-
sub: dateFns.subMonths
|
|
21508
|
+
sub: dateFns.subMonths,
|
|
21509
|
+
get: dateFns.getMonth
|
|
21440
21510
|
},
|
|
21441
21511
|
year: {
|
|
21442
21512
|
interval: dateFns.eachYearOfInterval,
|
|
21443
21513
|
start: dateFns.startOfYear,
|
|
21444
21514
|
end: dateFns.endOfYear,
|
|
21445
|
-
sub: dateFns.subYears
|
|
21515
|
+
sub: dateFns.subYears,
|
|
21516
|
+
get: dateFns.getYear
|
|
21446
21517
|
},
|
|
21447
21518
|
hour: {
|
|
21448
21519
|
interval: dateFns.eachHourOfInterval,
|
|
21449
21520
|
start: dateFns.startOfHour,
|
|
21450
21521
|
end: dateFns.endOfHour,
|
|
21451
|
-
sub: dateFns.subHours
|
|
21522
|
+
sub: dateFns.subHours,
|
|
21523
|
+
get: dateFns.getHours
|
|
21452
21524
|
},
|
|
21453
21525
|
minute: {
|
|
21454
21526
|
interval: dateFns.eachMinuteOfInterval,
|
|
21455
21527
|
start: dateFns.startOfMinute,
|
|
21456
21528
|
end: dateFns.endOfMinute,
|
|
21457
|
-
sub: dateFns.subMinutes
|
|
21529
|
+
sub: dateFns.subMinutes,
|
|
21530
|
+
get: dateFns.getMinutes
|
|
21531
|
+
},
|
|
21532
|
+
quarter: {
|
|
21533
|
+
interval: dateFns.eachQuarterOfInterval,
|
|
21534
|
+
start: dateFns.startOfQuarter,
|
|
21535
|
+
end: dateFns.endOfQuarter,
|
|
21536
|
+
sub: dateFns.subQuarters,
|
|
21537
|
+
get: dateFns.getQuarter
|
|
21458
21538
|
}
|
|
21459
21539
|
};
|
|
21540
|
+
const formatTimeFrameText = (start, end) => start.split("/")[0] + "/" + start.split("/")[1] + "\u2013" + end.split("/")[0] + "/" + end.split("/")[1];
|
|
21460
21541
|
function getZeroINumericSet() {
|
|
21461
21542
|
return {
|
|
21462
21543
|
min: Number.MAX_SAFE_INTEGER,
|
|
@@ -21699,4 +21780,4 @@ if (moduleName) {
|
|
|
21699
21780
|
var IRtcSendConfiguration = dist.exports.IRtcSendConfiguration;
|
|
21700
21781
|
var IRtcStreamMessage = dist.exports.IRtcStreamMessage;
|
|
21701
21782
|
var IRtcStreamPayload = dist.exports.IRtcStreamPayload;
|
|
21702
|
-
export { App, AudioPlayer, Authentication, BinaryRequestDataChannel, CaptureStream, DataChannel, Device, Fleet, IRtcSendConfiguration, IRtcStreamMessage, IRtcStreamPayload, KeyValue, Manipulator, PeerDevice, SessionType, TextRequestDataChannel, accessLevels, administrator, aggregateByDateFunctions, aggregateFunctionMap, aggregateLevels, annotationTypes, combineNumericAggregates, combineNumericSetAggregates, eventTypes, getAverage, getCount, getMax, getMin, getStandardDeviation, getSum, getVariance, getZeroINumericSet, healthStatuses, interventionTypes, operator, reduceNumericSetStreamAggregates, reduceNumericStreamAggregates, severities, videoMimeTypes, viewer };
|
|
21783
|
+
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 };
|