@formant/data-sdk 0.0.134 → 0.0.136

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.
Files changed (26) hide show
  1. package/dist/data-sdk.es.js +173 -24
  2. package/dist/data-sdk.umd.js +18 -18
  3. package/dist/types/data-sdk/src/Device.d.ts +2 -0
  4. package/dist/types/data-sdk/src/Fleet.d.ts +121 -0
  5. package/dist/types/data-sdk/src/main.d.ts +13 -0
  6. package/dist/types/data-sdk/src/model/AggregateLevel.d.ts +1 -1
  7. package/dist/types/data-sdk/src/model/AnalyticsAggregateType.d.ts +2 -0
  8. package/dist/types/data-sdk/src/model/AnalyticsChartType.d.ts +2 -0
  9. package/dist/types/data-sdk/src/model/IAggregateRow.d.ts +8 -0
  10. package/dist/types/data-sdk/src/model/IAnalyticsModule.d.ts +15 -0
  11. package/dist/types/data-sdk/src/model/IAnalyticsModuleConfiguration.d.ts +6 -0
  12. package/dist/types/data-sdk/src/model/IScopeFilter.d.ts +6 -0
  13. package/dist/types/data-sdk/src/model/IShare.d.ts +16 -0
  14. package/dist/types/data-sdk/src/model/ISqlColumn.d.ts +6 -0
  15. package/dist/types/data-sdk/src/model/ISqlQuery.d.ts +21 -0
  16. package/dist/types/data-sdk/src/model/ISqlResult.d.ts +12 -0
  17. package/dist/types/data-sdk/src/model/ISqlRow.d.ts +5 -0
  18. package/dist/types/data-sdk/src/model/IStreamColumn.d.ts +7 -0
  19. package/dist/types/data-sdk/src/model/ITaskReportColumn.d.ts +7 -0
  20. package/dist/types/data-sdk/src/model/IView.d.ts +15 -0
  21. package/dist/types/data-sdk/src/model/analyticsAggregteTypes.d.ts +1 -0
  22. package/dist/types/data-sdk/src/model/analyticsChartTypes.d.ts +1 -0
  23. package/dist/types/data-sdk/src/utils/aggregateFunctionUtils.d.ts +4 -3
  24. package/dist/types/data-sdk/src/utils/index.d.ts +1 -0
  25. package/dist/types/data-sdk/src/utils/timeout.d.ts +1 -0
  26. package/package.json +2 -1
@@ -19269,14 +19269,14 @@ function fork(_) {
19269
19269
  class StoreCache {
19270
19270
  constructor({
19271
19271
  capacity,
19272
- timeout
19272
+ timeout: timeout2
19273
19273
  } = {}) {
19274
19274
  __publicField(this, "entries", /* @__PURE__ */ new Map());
19275
19275
  __publicField(this, "metadata", /* @__PURE__ */ new Map());
19276
19276
  __publicField(this, "capacity");
19277
19277
  __publicField(this, "timeout");
19278
19278
  this.capacity = capacity || 1e4;
19279
- this.timeout = timeout || duration.minute;
19279
+ this.timeout = timeout2 || duration.minute;
19280
19280
  }
19281
19281
  get(key, generator) {
19282
19282
  const cacheKey = this.keyToCacheKey(key);
@@ -19910,12 +19910,12 @@ class Manipulator {
19910
19910
  }
19911
19911
  }
19912
19912
  class RequestDataChannel {
19913
- constructor(device, channel_name, timeout) {
19913
+ constructor(device, channel_name, timeout2) {
19914
19914
  __publicField(this, "channel");
19915
19915
  __publicField(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
19916
19916
  this.device = device;
19917
19917
  this.channel_name = channel_name;
19918
- this.timeout = timeout;
19918
+ this.timeout = timeout2;
19919
19919
  }
19920
19920
  addOpenListener(listener) {
19921
19921
  defined(this.channel, "channel not initalized").addOpenListener(listener);
@@ -19979,14 +19979,14 @@ class BinaryRequestDataChannel extends RequestDataChannel {
19979
19979
  if (!this.channel) {
19980
19980
  throw new Error("Failed to create channel");
19981
19981
  }
19982
- const { channel, requestIdToResponseMap, timeout } = this;
19982
+ const { channel, requestIdToResponseMap, timeout: timeout2 } = this;
19983
19983
  await channel.waitTilReady();
19984
19984
  const binaryId = this.generateBinaryId();
19985
19985
  const id = binaryId.toString();
19986
19986
  requestIdToResponseMap.set(id, true);
19987
19987
  channel.sendBinary(new Uint8Array([...binaryId, ...data]));
19988
19988
  const start = new Date().getTime();
19989
- while (new Date().getTime() < start + timeout) {
19989
+ while (new Date().getTime() < start + timeout2) {
19990
19990
  await delay(50);
19991
19991
  if (requestIdToResponseMap.has(id)) {
19992
19992
  const response = requestIdToResponseMap.get(id);
@@ -20009,7 +20009,7 @@ class BinaryRequestDataChannel extends RequestDataChannel {
20009
20009
  requestIdToResponseMap.delete(id);
20010
20010
  console.error({
20011
20011
  name: "TimeoutError",
20012
- message: `Request timed out after ${timeout / 1e3} seconds`
20012
+ message: `Request timed out after ${timeout2 / 1e3} seconds`
20013
20013
  });
20014
20014
  throw new Error("Binary request data channel request timed out");
20015
20015
  }
@@ -20041,7 +20041,7 @@ class TextRequestDataChannel extends RequestDataChannel {
20041
20041
  if (!this.channel) {
20042
20042
  throw new Error("Failed to create channel");
20043
20043
  }
20044
- const { channel, requestIdToResponseMap, timeout } = this;
20044
+ const { channel, requestIdToResponseMap, timeout: timeout2 } = this;
20045
20045
  await channel.waitTilReady();
20046
20046
  const id = this.generateTextId();
20047
20047
  requestIdToResponseMap.set(id, true);
@@ -20052,7 +20052,7 @@ class TextRequestDataChannel extends RequestDataChannel {
20052
20052
  })
20053
20053
  );
20054
20054
  const start = new Date().getTime();
20055
- while (new Date().getTime() < start + timeout) {
20055
+ while (new Date().getTime() < start + timeout2) {
20056
20056
  await delay(50);
20057
20057
  if (requestIdToResponseMap.has(id)) {
20058
20058
  const response = requestIdToResponseMap.get(id);
@@ -20075,7 +20075,7 @@ class TextRequestDataChannel extends RequestDataChannel {
20075
20075
  requestIdToResponseMap.delete(id);
20076
20076
  console.error({
20077
20077
  name: "TimeoutError",
20078
- message: `Request timed out after ${timeout / 1e3} seconds`
20078
+ message: `Request timed out after ${timeout2 / 1e3} seconds`
20079
20079
  });
20080
20080
  throw new Error("Text request datachannel request timed out");
20081
20081
  }
@@ -20459,14 +20459,10 @@ class Device {
20459
20459
  if (!command) {
20460
20460
  throw new Error(`Could not find command with name "${name}"`);
20461
20461
  }
20462
- let d;
20462
+ let d = "";
20463
20463
  if (data === void 0) {
20464
20464
  if (command.parameterEnabled && command.parameterValue) {
20465
20465
  d = command.parameterValue;
20466
- } else {
20467
- throw new Error(
20468
- "Command has no default parameter value, you must provide one"
20469
- );
20470
20466
  }
20471
20467
  } else {
20472
20468
  d = data;
@@ -20524,11 +20520,11 @@ class Device {
20524
20520
  await p.waitTilReady();
20525
20521
  return p;
20526
20522
  }
20527
- createCustomRequestDataChannel(channelName, timeout = 3e3) {
20528
- return new TextRequestDataChannel(this, channelName, timeout);
20523
+ createCustomRequestDataChannel(channelName, timeout2 = 3e3) {
20524
+ return new TextRequestDataChannel(this, channelName, timeout2);
20529
20525
  }
20530
- createCustomBinaryRequestDataChannel(channelName, timeout = 3e3) {
20531
- return new BinaryRequestDataChannel(this, channelName, timeout);
20526
+ createCustomBinaryRequestDataChannel(channelName, timeout2 = 3e3) {
20527
+ return new BinaryRequestDataChannel(this, channelName, timeout2);
20532
20528
  }
20533
20529
  async createCaptureStream(streamName) {
20534
20530
  const result = await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions`, {
@@ -20646,6 +20642,20 @@ class Device {
20646
20642
  deviceIds: [this.id]
20647
20643
  });
20648
20644
  }
20645
+ async createShareLink(params) {
20646
+ if (!Authentication.token) {
20647
+ throw new Error("Not authenticated");
20648
+ }
20649
+ const response = await fetch(`${FORMANT_API_URL}/v1/admin/shares`, {
20650
+ method: "POST",
20651
+ body: JSON.stringify({ ...params, deviceIds: [this.id] }),
20652
+ headers: {
20653
+ "Content-Type": "application/json",
20654
+ Authorization: "Bearer " + Authentication.token
20655
+ }
20656
+ });
20657
+ return await response.json();
20658
+ }
20649
20659
  }
20650
20660
  class PeerDevice {
20651
20661
  constructor(peerUrl) {
@@ -20886,11 +20896,11 @@ class PeerDevice {
20886
20896
  await p.waitTilReady();
20887
20897
  return p;
20888
20898
  }
20889
- createCustomRequestDataChannel(channelName, timeout = 3e3) {
20890
- return new TextRequestDataChannel(this, channelName, timeout);
20899
+ createCustomRequestDataChannel(channelName, timeout2 = 3e3) {
20900
+ return new TextRequestDataChannel(this, channelName, timeout2);
20891
20901
  }
20892
- createCustomBinaryRequestDataChannel(channelName, timeout = 3e3) {
20893
- return new BinaryRequestDataChannel(this, channelName, timeout);
20902
+ createCustomBinaryRequestDataChannel(channelName, timeout2 = 3e3) {
20903
+ return new BinaryRequestDataChannel(this, channelName, timeout2);
20894
20904
  }
20895
20905
  }
20896
20906
  const _Fleet = class {
@@ -21302,6 +21312,37 @@ const _Fleet = class {
21302
21312
  );
21303
21313
  return await response.json();
21304
21314
  }
21315
+ static async getViews() {
21316
+ if (!Authentication.token) {
21317
+ throw new Error("Not authenticated");
21318
+ }
21319
+ const response = await fetch(`${FORMANT_API_URL}/v1/admin/views`, {
21320
+ method: "GET",
21321
+ headers: {
21322
+ "Content-Type": "application/json",
21323
+ Authorization: "Bearer " + Authentication.token
21324
+ }
21325
+ });
21326
+ const views = await response.json();
21327
+ return views.items;
21328
+ }
21329
+ static async patchView(view) {
21330
+ if (!Authentication.token) {
21331
+ throw new Error("Not authenticated");
21332
+ }
21333
+ const response = await fetch(
21334
+ `${FORMANT_API_URL}/v1/admin/views/${view.id}`,
21335
+ {
21336
+ method: "PATCH",
21337
+ body: JSON.stringify(view),
21338
+ headers: {
21339
+ "Content-Type": "application/json",
21340
+ Authorization: "Bearer " + Authentication.token
21341
+ }
21342
+ }
21343
+ );
21344
+ return await response.json();
21345
+ }
21305
21346
  static async eventsCounter(eventTypes2, timeFrame, range, time, query) {
21306
21347
  const dateFunctions = aggregateByDateFunctions[timeFrame];
21307
21348
  return await Promise.all(
@@ -21329,6 +21370,102 @@ const _Fleet = class {
21329
21370
  })
21330
21371
  );
21331
21372
  }
21373
+ static async getAnalyticsModules() {
21374
+ if (!Authentication.token) {
21375
+ throw new Error("Not authenticated");
21376
+ }
21377
+ const response = await fetch(
21378
+ `${FORMANT_API_URL}/v1/admin/analytics-modules`,
21379
+ {
21380
+ method: "GET",
21381
+ headers: {
21382
+ "Content-Type": "application/json",
21383
+ Authorization: "Bearer " + Authentication.token
21384
+ }
21385
+ }
21386
+ );
21387
+ return (await response.json()).items;
21388
+ }
21389
+ static async getAnalyticStreams() {
21390
+ if (!Authentication.token) {
21391
+ throw new Error("Not authenticated");
21392
+ }
21393
+ const response = await fetch(
21394
+ `${FORMANT_API_URL}/v1/queries/analytics/streams`,
21395
+ {
21396
+ method: "GET",
21397
+ headers: {
21398
+ "Content-Type": "application/json",
21399
+ Authorization: "Bearer " + Authentication.token
21400
+ }
21401
+ }
21402
+ );
21403
+ return (await response.json()).items;
21404
+ }
21405
+ static async getTaskReportTables() {
21406
+ if (!Authentication.token) {
21407
+ throw new Error("Not authenticated");
21408
+ }
21409
+ const response = await fetch(
21410
+ `${FORMANT_API_URL}/v1/queries/analytics/task-reports`,
21411
+ {
21412
+ method: "GET",
21413
+ headers: {
21414
+ "Content-Type": "application/json",
21415
+ Authorization: "Bearer " + Authentication.token
21416
+ }
21417
+ }
21418
+ );
21419
+ return (await response.json()).items;
21420
+ }
21421
+ static async queryAnalytics(query) {
21422
+ if (!Authentication.token) {
21423
+ throw new Error("Not authenticated");
21424
+ }
21425
+ const response = await fetch(`${FORMANT_API_URL}/v1/queries/analytics`, {
21426
+ method: "POST",
21427
+ body: JSON.stringify(query),
21428
+ headers: {
21429
+ "Content-Type": "application/json",
21430
+ Authorization: "Bearer " + Authentication.token
21431
+ }
21432
+ });
21433
+ return await response.json();
21434
+ }
21435
+ static async getAnalyticsRows(query) {
21436
+ if (!Authentication.token) {
21437
+ throw new Error("Not authenticated");
21438
+ }
21439
+ const response = await fetch(
21440
+ `${FORMANT_API_URL}/v1/queries/analytics/rows`,
21441
+ {
21442
+ method: "POST",
21443
+ body: JSON.stringify(query),
21444
+ headers: {
21445
+ "Content-Type": "application/json",
21446
+ Authorization: "Bearer " + Authentication.token
21447
+ }
21448
+ }
21449
+ );
21450
+ return await response.json();
21451
+ }
21452
+ static async getTaskReportRows(query) {
21453
+ if (!Authentication.token) {
21454
+ throw new Error("Not authenticated");
21455
+ }
21456
+ const response = await fetch(
21457
+ `${FORMANT_API_URL}/v1/queries/analytics/task-report-rows`,
21458
+ {
21459
+ method: "POST",
21460
+ body: JSON.stringify(query),
21461
+ headers: {
21462
+ "Content-Type": "application/json",
21463
+ Authorization: "Bearer " + Authentication.token
21464
+ }
21465
+ }
21466
+ );
21467
+ return await response.json();
21468
+ }
21332
21469
  };
21333
21470
  let Fleet = _Fleet;
21334
21471
  __publicField(Fleet, "defaultDeviceId");
@@ -21416,6 +21553,15 @@ class KeyValue {
21416
21553
  }
21417
21554
  }
21418
21555
  }
21556
+ const vailableAggregationIntervals = [
21557
+ "day",
21558
+ "week",
21559
+ "month",
21560
+ "year",
21561
+ "hour",
21562
+ "minute",
21563
+ "quarter"
21564
+ ];
21419
21565
  const aggregateFunctions = [
21420
21566
  "interval",
21421
21567
  "start",
@@ -21556,6 +21702,9 @@ function combineNumericSetAggregates(e1, e2) {
21556
21702
  };
21557
21703
  }, {});
21558
21704
  }
21705
+ const timeout = (s) => {
21706
+ return new Promise((resolve) => setTimeout(resolve, s * 1e3));
21707
+ };
21559
21708
  function stringToArrayBuffer(input) {
21560
21709
  return Uint8Array.from(atob(input), (_) => _.charCodeAt(0));
21561
21710
  }
@@ -21749,4 +21898,4 @@ if (moduleName) {
21749
21898
  var IRtcSendConfiguration = dist.exports.IRtcSendConfiguration;
21750
21899
  var IRtcStreamMessage = dist.exports.IRtcStreamMessage;
21751
21900
  var IRtcStreamPayload = dist.exports.IRtcStreamPayload;
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 };
21901
+ 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, timeout, vailableAggregationIntervals, videoMimeTypes, viewer };