@formant/data-sdk 1.75.0 → 1.76.0

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.
@@ -53,6 +53,32 @@ let FORMANT_API_URL = whichFormantApiUrl(
53
53
  const setFormantApiUrl = (e) => {
54
54
  FORMANT_API_URL = e;
55
55
  };
56
+ function addAccessTokenRefreshListener(e) {
57
+ function t(n) {
58
+ const r = n.data;
59
+ r.type === "auth_token" && e(r.token);
60
+ }
61
+ return window.addEventListener("message", t), () => {
62
+ window.removeEventListener("message", t);
63
+ };
64
+ }
65
+ function getCurrentModuleContext() {
66
+ return typeof window != "undefined" && window.location ? new URLSearchParams(window.location.search).get("module") : null;
67
+ }
68
+ function sendAppMessage(e) {
69
+ if (!(window && window.parent))
70
+ throw new Error("cannot send message to non-existent parent");
71
+ window.parent.postMessage(e, "*");
72
+ }
73
+ function refreshAuthToken() {
74
+ const e = getCurrentModuleContext();
75
+ if (!e)
76
+ throw new Error("No module context");
77
+ sendAppMessage({
78
+ type: "refresh_auth_token",
79
+ module: e
80
+ });
81
+ }
56
82
  var commonjsGlobal = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
57
83
  function getDefaultExportFromCjs(e) {
58
84
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -363,32 +389,6 @@ class AuthenticationStore {
363
389
  );
364
390
  }
365
391
  }
366
- function getCurrentModuleContext() {
367
- return typeof window != "undefined" && window.location ? new URLSearchParams(window.location.search).get("module") : null;
368
- }
369
- function sendAppMessage(e) {
370
- if (!(window && window.parent))
371
- throw new Error("cannot send message to non-existent parent");
372
- window.parent.postMessage(e, "*");
373
- }
374
- function refreshAuthToken() {
375
- const e = getCurrentModuleContext();
376
- if (!e)
377
- throw new Error("No module context");
378
- sendAppMessage({
379
- type: "refresh_auth_token",
380
- module: e
381
- });
382
- }
383
- function addAccessTokenRefreshListener(e) {
384
- function t(n) {
385
- const r = n.data;
386
- r.type === "auth_token" && e(r.token);
387
- }
388
- return window.addEventListener("message", t), () => {
389
- window.removeEventListener("message", t);
390
- };
391
- }
392
392
  const Authentication = new AuthenticationStore({
393
393
  apiUrl: FORMANT_API_URL,
394
394
  refreshAuthToken,
@@ -25444,6 +25444,49 @@ class User {
25444
25444
  });
25445
25445
  }
25446
25446
  }
25447
+ async function request(e, t) {
25448
+ if (!Authentication.token)
25449
+ throw new Error("Not authenticated");
25450
+ const n = await fetch(`${FORMANT_API_URL}/v1${e}`, {
25451
+ ...t,
25452
+ headers: {
25453
+ "Content-Type": "application/json",
25454
+ Authorization: `Bearer ${Authentication.token}`,
25455
+ ...t == null ? void 0 : t.headers
25456
+ }
25457
+ });
25458
+ if (!n.ok)
25459
+ throw new Error(`Error: ${n.statusText}`);
25460
+ return n.status === 204 || n.headers.get("content-length") === "0" ? null : await n.json();
25461
+ }
25462
+ async function fetchTeleopViews() {
25463
+ return (await request("/admin/teleop-views")).items;
25464
+ }
25465
+ async function getTeleopView(e) {
25466
+ return await request(`/admin/teleop-views/${e}`);
25467
+ }
25468
+ async function createTeleopView(e) {
25469
+ return await request("/admin/teleop-views", {
25470
+ method: "POST",
25471
+ body: JSON.stringify(e)
25472
+ });
25473
+ }
25474
+ async function updateTeleopView(e, t) {
25475
+ return await request(`/admin/teleop-views/${e}`, {
25476
+ method: "PATCH",
25477
+ body: JSON.stringify(t)
25478
+ });
25479
+ }
25480
+ async function deleteTeleopView(e) {
25481
+ await request(`/admin/teleop-views/${e}`, {
25482
+ method: "DELETE"
25483
+ });
25484
+ }
25485
+ class Views {
25486
+ constructor() {
25487
+ }
25488
+ }
25489
+ he(Views, "createTeleopView", createTeleopView), he(Views, "updateTeleopView", updateTeleopView), he(Views, "deleteTeleopView", deleteTeleopView), he(Views, "getTeleopView", getTeleopView), he(Views, "fetchTeleopViews", fetchTeleopViews);
25447
25490
  const viewer = "viewer", operator = "operator", administrator = "administrator", accessLevels = ["viewer", "operator", "administrator"], aggregateLevels = [
25448
25491
  "year",
25449
25492
  "month",
@@ -32876,6 +32919,7 @@ export {
32876
32919
  TelemetryUniverseData,
32877
32920
  TextRequestDataChannel,
32878
32921
  User,
32922
+ Views,
32879
32923
  accessLevels,
32880
32924
  administrator,
32881
32925
  aggregateByDateFunctions,