@insync-stageplayer/measurements 0.5.37 → 0.6.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.
Files changed (113) hide show
  1. package/lib/AsyncSubject.d.ts +23 -23
  2. package/lib/AsyncSubject.js +64 -64
  3. package/lib/client/MeasurementDataClient.d.ts +135 -130
  4. package/lib/client/MeasurementDataClient.d.ts.map +1 -1
  5. package/lib/client/MeasurementDataClient.js +99 -99
  6. package/lib/client/MeasurementDataClient.js.map +1 -1
  7. package/lib/client/OnlineMeasurementDataClient.d.ts +44 -44
  8. package/lib/client/OnlineMeasurementDataClient.d.ts.map +1 -1
  9. package/lib/client/OnlineMeasurementDataClient.js +211 -211
  10. package/lib/client/OnlineMeasurementDataClient.js.map +1 -1
  11. package/lib/client/debug.d.ts +1 -1
  12. package/lib/client/debug.js +4 -4
  13. package/lib/client/index.d.ts +3 -3
  14. package/lib/client/index.js +3 -3
  15. package/lib/client/offline/OfflineMeasurementDataClient.d.ts +16 -16
  16. package/lib/client/offline/OfflineMeasurementDataClient.js +47 -47
  17. package/lib/client/offline/offline.d.ts +16 -16
  18. package/lib/client/offline/offline.js +82 -82
  19. package/lib/client/sbf.d.ts +35 -35
  20. package/lib/client/sbf.js +88 -88
  21. package/lib/client/signalviewer/SignalViewerDataClient.d.ts +37 -37
  22. package/lib/client/signalviewer/SignalViewerDataClient.d.ts.map +1 -1
  23. package/lib/client/signalviewer/SignalViewerDataClient.js +163 -164
  24. package/lib/client/signalviewer/SignalViewerDataClient.js.map +1 -1
  25. package/lib/client/signalviewer/SignalViewerDataClient.worker.d.ts +79 -73
  26. package/lib/client/signalviewer/SignalViewerDataClient.worker.d.ts.map +1 -1
  27. package/lib/client/signalviewer/SignalViewerDataClient.worker.js +342 -211
  28. package/lib/client/signalviewer/SignalViewerDataClient.worker.js.map +1 -1
  29. package/lib/components/Icon/CloseIcon.d.ts +6 -6
  30. package/lib/components/Icon/CloseIcon.js +24 -24
  31. package/lib/components/Icon/Icon.test.d.ts +1 -1
  32. package/lib/components/Icon/Icon.test.js +11 -11
  33. package/lib/components/MeasurementsChooser.d.ts +38 -38
  34. package/lib/components/MeasurementsChooser.d.ts.map +1 -1
  35. package/lib/components/MeasurementsChooser.js +178 -181
  36. package/lib/components/MeasurementsChooser.js.map +1 -1
  37. package/lib/components/MeasurementsModuleProvider.d.ts +34 -34
  38. package/lib/components/MeasurementsModuleProvider.d.ts.map +1 -1
  39. package/lib/components/MeasurementsModuleProvider.js +100 -79
  40. package/lib/components/MeasurementsModuleProvider.js.map +1 -1
  41. package/lib/components/MeasurementsTable/CheckboxCell.d.ts +35 -35
  42. package/lib/components/MeasurementsTable/CheckboxCell.js +28 -28
  43. package/lib/components/MeasurementsTable/ColorCell.d.ts +29 -29
  44. package/lib/components/MeasurementsTable/ColorCell.d.ts.map +1 -1
  45. package/lib/components/MeasurementsTable/ColorCell.js +58 -58
  46. package/lib/components/MeasurementsTable/ColorPicker.d.ts +6 -3
  47. package/lib/components/MeasurementsTable/ColorPicker.d.ts.map +1 -1
  48. package/lib/components/MeasurementsTable/ColorPicker.js +10 -10
  49. package/lib/components/MeasurementsTable/ColumnResizer.d.ts +4 -4
  50. package/lib/components/MeasurementsTable/ColumnResizer.js +5 -5
  51. package/lib/components/MeasurementsTable/ColumnSorting.d.ts +13 -13
  52. package/lib/components/MeasurementsTable/ColumnSorting.d.ts.map +1 -1
  53. package/lib/components/MeasurementsTable/ColumnSorting.js +10 -10
  54. package/lib/components/MeasurementsTable/MeasurementsTable.d.ts +72 -72
  55. package/lib/components/MeasurementsTable/MeasurementsTable.d.ts.map +1 -1
  56. package/lib/components/MeasurementsTable/MeasurementsTable.js +229 -217
  57. package/lib/components/MeasurementsTable/MeasurementsTable.js.map +1 -1
  58. package/lib/components/MeasurementsTable/MeasurementsTable.test.d.ts +1 -1
  59. package/lib/components/MeasurementsTable/MeasurementsTable.test.js +102 -102
  60. package/lib/components/MeasurementsTable/MeasurementsTableNoldus.d.ts +72 -72
  61. package/lib/components/MeasurementsTable/MeasurementsTableNoldus.d.ts.map +1 -1
  62. package/lib/components/MeasurementsTable/MeasurementsTableNoldus.js +193 -193
  63. package/lib/components/MeasurementsTable/SelectedContext.d.ts +10 -10
  64. package/lib/components/MeasurementsTable/SelectedContext.js +10 -10
  65. package/lib/components/MeasurementsTable/TextColumnFilter.d.ts +8 -8
  66. package/lib/components/MeasurementsTable/TextColumnFilter.d.ts.map +1 -1
  67. package/lib/components/MeasurementsTable/TextColumnFilter.js +15 -15
  68. package/lib/components/MeasurementsTable/filters.d.ts +3 -3
  69. package/lib/components/MeasurementsTable/filters.js +9 -9
  70. package/lib/components/MeasurementsTable/index.d.ts +2 -2
  71. package/lib/components/MeasurementsTable/index.js +2 -2
  72. package/lib/components/ModalMeasurementChooser.d.ts +19 -19
  73. package/lib/components/ModalMeasurementChooser.js +35 -35
  74. package/lib/conversion/UnitConversion.d.ts +13 -0
  75. package/lib/conversion/UnitConversion.d.ts.map +1 -0
  76. package/lib/conversion/UnitConversion.js +266 -0
  77. package/lib/conversion/UnitConversion.js.map +1 -0
  78. package/lib/hooks/useMarkerData.d.ts +6 -4
  79. package/lib/hooks/useMarkerData.d.ts.map +1 -1
  80. package/lib/hooks/useMarkerData.js +93 -63
  81. package/lib/hooks/useMarkerData.js.map +1 -1
  82. package/lib/hooks/useMeasurement.d.ts +41 -17
  83. package/lib/hooks/useMeasurement.d.ts.map +1 -1
  84. package/lib/hooks/useMeasurement.js +41 -41
  85. package/lib/hooks/useMeasurements.d.ts +11 -11
  86. package/lib/hooks/useMeasurements.js +22 -22
  87. package/lib/hooks/useMeasurementsModule.d.ts +20 -20
  88. package/lib/hooks/useMeasurementsModule.js +12 -12
  89. package/lib/hooks/useOverlayMeasurementData.d.ts +1 -1
  90. package/lib/hooks/useOverlayMeasurementData.js +23 -23
  91. package/lib/hooks/useTimedMeasurementData.d.ts +26 -26
  92. package/lib/hooks/useTimedMeasurementData.d.ts.map +1 -1
  93. package/lib/hooks/useTimedMeasurementData.js +125 -125
  94. package/lib/hooks/useTimedMeasurementData.js.map +1 -1
  95. package/lib/hooks/useWindowedMeasurementData.d.ts +25 -25
  96. package/lib/hooks/useWindowedMeasurementData.d.ts.map +1 -1
  97. package/lib/hooks/useWindowedMeasurementData.js +120 -120
  98. package/lib/hooks/useWindowedMeasurementData.js.map +1 -1
  99. package/lib/index.d.ts +15 -14
  100. package/lib/index.d.ts.map +1 -1
  101. package/lib/index.js +15 -14
  102. package/lib/index.js.map +1 -1
  103. package/lib/redux/measurements.slice.d.ts +75 -122
  104. package/lib/redux/measurements.slice.d.ts.map +1 -1
  105. package/lib/redux/measurements.slice.js +90 -89
  106. package/lib/redux/measurements.slice.js.map +1 -1
  107. package/lib/redux/reducer.d.ts +3 -10
  108. package/lib/redux/reducer.d.ts.map +1 -1
  109. package/lib/redux/reducer.js +2 -2
  110. package/lib/redux/reducer.js.map +1 -1
  111. package/lib/types.d.ts +93 -93
  112. package/lib/types.js +51 -51
  113. package/package.json +7 -10
@@ -1,17 +1,17 @@
1
- export function fetchMetadata(path: string): Promise<any>;
2
- export function fetchData(options: FetchDataOptions): Promise<{
3
- [key: string]: [number, number][];
4
- }>;
5
- export type FetchDataOptions = {
6
- /**
7
- * The measurement we're retrieving data for.
8
- */
9
- measurements: Measurement[];
10
- offset: number;
11
- limit: number;
12
- /**
13
- * The file we're retrieving data for.
14
- */
15
- file: string;
16
- };
1
+ export function fetchMetadata(path: string): Promise<any>;
2
+ export function fetchData(options: FetchDataOptions): Promise<{
3
+ [key: string]: [number, number][];
4
+ }>;
5
+ export type FetchDataOptions = {
6
+ /**
7
+ * The measurement we're retrieving data for.
8
+ */
9
+ measurements: Measurement[];
10
+ offset: number;
11
+ limit: number;
12
+ /**
13
+ * The file we're retrieving data for.
14
+ */
15
+ file: string;
16
+ };
17
17
  //# sourceMappingURL=offline.d.ts.map
@@ -1,83 +1,83 @@
1
- /**
2
- * Contains functions that use [sbfreader](https://www.npmjs.com/package/sbfreader) to connect to native HDF5/SBF lib.
3
- *
4
- * This is used in the offline stageplayer.
5
- */
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
- var __rest = (this && this.__rest) || function (s, e) {
16
- var t = {};
17
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18
- t[p] = s[p];
19
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
20
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
21
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
22
- t[p[i]] = s[p[i]];
23
- }
24
- return t;
25
- };
26
- // Wrapper around sbfreader, catches errors thrown when HDF5 is not installed.
27
- const getReader = (() => {
28
- let module;
29
- let error;
30
- try {
31
- // eslint-disable-next-line global-require
32
- module = require("sbfreader");
33
- }
34
- catch (err) {
35
- error = new Error("Could not load data reader, please make sure HDF5 1.10.2 is installed.");
36
- }
37
- return () => {
38
- if (error) {
39
- throw error;
40
- }
41
- return module;
42
- };
43
- })();
44
- /**
45
- * Fetches metadata for a HDF/SBF file.
46
- * @param {string} path The file we're retrieving data from.
47
- */
48
- export const fetchMetadata = (path) => __awaiter(void 0, void 0, void 0, function* () {
49
- const fixedPath = path.replace("file://", "");
50
- const response = yield getReader().getDataInfo(fixedPath);
51
- const { datasets = [] } = response;
52
- const result = datasets.map((s) => (Object.assign(Object.assign({}, s), { id: s.name, file: s.hdf5, index: s.index.split("/") })));
53
- return result;
54
- });
55
- /**
56
- * @typedef {Object} FetchDataOptions
57
- * @property {Measurement[]} measurements The measurement we're retrieving data for.
58
- * @property {number} offset
59
- * @property {number} limit
60
- * @property {string} file The file we're retrieving data for.
61
- */
62
- /**
63
- * Fetches data from a measurement file. Contains some hacks to be compatible with sbfreader.
64
- * @param {FetchDataOptions} options
65
- * @returns {Promise<{[key: string]: [number, number][]}>}
66
- */
67
- export const fetchData = (options) => __awaiter(void 0, void 0, void 0, function* () {
68
- const { measurements, offset, limit = 0, file, rows } = options, rest = __rest(options, ["measurements", "offset", "limit", "file", "rows"]);
69
- const measurementIds = measurements.map((measurement) => {
70
- measurement.index.join("/");
71
- });
72
- const libArgs = Object.assign(Object.assign({}, rest), { file: file.replace("file://", ""), streams: measurementIds.map((id) => ({ id })), resolution: rows === 1 ? undefined : rows, start: offset / 1000,
73
- // sbfreader doesn't like limit of 0.
74
- end: (offset + (limit <= 0 ? 1000000 : limit)) / 1000 });
75
- return getReader()
76
- .getData(libArgs)
77
- .then(({ streams }) => {
78
- return streams.reduce((acc, { name, data }) => (Object.assign(Object.assign({}, acc), { [name]: data
79
- .filter(([x, y]) => !!y)
80
- .map((entry) => [entry[0] * 1000, entry[1]]) })), {});
81
- });
82
- });
1
+ /**
2
+ * Contains functions that use [sbfreader](https://www.npmjs.com/package/sbfreader) to connect to native HDF5/SBF lib.
3
+ *
4
+ * This is used in the offline stageplayer.
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __rest = (this && this.__rest) || function (s, e) {
16
+ var t = {};
17
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18
+ t[p] = s[p];
19
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
20
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
21
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
22
+ t[p[i]] = s[p[i]];
23
+ }
24
+ return t;
25
+ };
26
+ // Wrapper around sbfreader, catches errors thrown when HDF5 is not installed.
27
+ const getReader = (() => {
28
+ let module;
29
+ let error;
30
+ try {
31
+ // eslint-disable-next-line global-require
32
+ module = require("sbfreader");
33
+ }
34
+ catch (err) {
35
+ error = new Error("Could not load data reader, please make sure HDF5 1.10.2 is installed.");
36
+ }
37
+ return () => {
38
+ if (error) {
39
+ throw error;
40
+ }
41
+ return module;
42
+ };
43
+ })();
44
+ /**
45
+ * Fetches metadata for a HDF/SBF file.
46
+ * @param {string} path The file we're retrieving data from.
47
+ */
48
+ export const fetchMetadata = (path) => __awaiter(void 0, void 0, void 0, function* () {
49
+ const fixedPath = path.replace("file://", "");
50
+ const response = yield getReader().getDataInfo(fixedPath);
51
+ const { datasets = [] } = response;
52
+ const result = datasets.map((s) => (Object.assign(Object.assign({}, s), { id: s.name, file: s.hdf5, index: s.index.split("/") })));
53
+ return result;
54
+ });
55
+ /**
56
+ * @typedef {Object} FetchDataOptions
57
+ * @property {Measurement[]} measurements The measurement we're retrieving data for.
58
+ * @property {number} offset
59
+ * @property {number} limit
60
+ * @property {string} file The file we're retrieving data for.
61
+ */
62
+ /**
63
+ * Fetches data from a measurement file. Contains some hacks to be compatible with sbfreader.
64
+ * @param {FetchDataOptions} options
65
+ * @returns {Promise<{[key: string]: [number, number][]}>}
66
+ */
67
+ export const fetchData = (options) => __awaiter(void 0, void 0, void 0, function* () {
68
+ const { measurements, offset, limit = 0, file, rows } = options, rest = __rest(options, ["measurements", "offset", "limit", "file", "rows"]);
69
+ const measurementIds = measurements.map((measurement) => {
70
+ measurement.index.join("/");
71
+ });
72
+ const libArgs = Object.assign(Object.assign({}, rest), { file: file.replace("file://", ""), streams: measurementIds.map((id) => ({ id })), resolution: rows === 1 ? undefined : rows, start: offset / 1000,
73
+ // sbfreader doesn't like limit of 0.
74
+ end: (offset + (limit <= 0 ? 1000000 : limit)) / 1000 });
75
+ return getReader()
76
+ .getData(libArgs)
77
+ .then(({ streams }) => {
78
+ return streams.reduce((acc, { name, data }) => (Object.assign(Object.assign({}, acc), { [name]: data
79
+ .filter(([x, y]) => !!y)
80
+ .map((entry) => [entry[0] * 1000, entry[1]]) })), {});
81
+ });
82
+ });
83
83
  //# sourceMappingURL=offline.js.map
@@ -1,36 +1,36 @@
1
- import { MeasurementsTypes } from "../types";
2
- /**
3
- * Fetches measurement metadata for a given SBF.
4
- *
5
- * @param endpoint Endpoint to send request to.
6
- * @param file File to return measurement metadata from.
7
- * @returns
8
- */
9
- export declare const fetchDataMetadata: (endpoint: string, file: string) => Promise<{
10
- name: string;
11
- index: string[];
12
- unit: string;
13
- min: number;
14
- max: number;
15
- yaxisLeftPos: string;
16
- frequency: number;
17
- dataScale: number;
18
- file: string;
19
- id: string;
20
- }[]>;
21
- export declare type FetchDataOptions = {
22
- file: string;
23
- offset: number;
24
- limit?: number;
25
- rows?: number;
26
- measurements: string[];
27
- };
28
- /**
29
- * Fetch measurement data from a SBF.
30
- *
31
- * @param endpoint The endpoint to retrieve SBF data from.
32
- * @param options The options for retrieving data.
33
- * @returns
34
- */
35
- export declare const fetchData: (endpoint: string, options: FetchDataOptions) => Promise<MeasurementsTypes.DataMap>;
1
+ import { MeasurementsTypes } from "../types";
2
+ /**
3
+ * Fetches measurement metadata for a given SBF.
4
+ *
5
+ * @param endpoint Endpoint to send request to.
6
+ * @param file File to return measurement metadata from.
7
+ * @returns
8
+ */
9
+ export declare const fetchDataMetadata: (endpoint: string, file: string) => Promise<{
10
+ name: string;
11
+ index: string[];
12
+ unit: string;
13
+ min: number;
14
+ max: number;
15
+ yaxisLeftPos: string;
16
+ frequency: number;
17
+ dataScale: number;
18
+ file: string;
19
+ id: string;
20
+ }[]>;
21
+ export declare type FetchDataOptions = {
22
+ file: string;
23
+ offset: number;
24
+ limit?: number;
25
+ rows?: number;
26
+ measurements: string[];
27
+ };
28
+ /**
29
+ * Fetch measurement data from a SBF.
30
+ *
31
+ * @param endpoint The endpoint to retrieve SBF data from.
32
+ * @param options The options for retrieving data.
33
+ * @returns
34
+ */
35
+ export declare const fetchData: (endpoint: string, options: FetchDataOptions) => Promise<MeasurementsTypes.DataMap>;
36
36
  //# sourceMappingURL=sbf.d.ts.map
package/lib/client/sbf.js CHANGED
@@ -1,89 +1,89 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- /**
11
- * This takes the result from the fetch() call and throws an error if the response not ok.
12
- * @param r A response from fetch()
13
- * @returns
14
- */
15
- const handleDataServerResponse = (r) => {
16
- if (!r.ok)
17
- throw new Error(`Got HTTP error: "${r.status}: ${r.statusText}"`);
18
- return r.json();
19
- };
20
- /**
21
- * Fetches measurement metadata for a given SBF.
22
- *
23
- * @param endpoint Endpoint to send request to.
24
- * @param file File to return measurement metadata from.
25
- * @returns
26
- */
27
- export const fetchDataMetadata = (endpoint, file) => __awaiter(void 0, void 0, void 0, function* () {
28
- var _a;
29
- const args = {
30
- headers: {
31
- Accept: "application/json",
32
- "Content-Type": "application/json",
33
- "X-Files": file,
34
- },
35
- method: "POST",
36
- credentials: "include",
37
- body: JSON.stringify({
38
- getMeta: {
39
- files: [file],
40
- },
41
- }),
42
- };
43
- const response = yield fetch(endpoint, args);
44
- const json = (yield handleDataServerResponse(response));
45
- const measurements = ((_a = json.metadata[0]) === null || _a === void 0 ? void 0 : _a.streams) || [];
46
- return measurements.map((m) => (Object.assign({ file, id: m.name }, m)));
47
- });
48
- /**
49
- * Fetch measurement data from a SBF.
50
- *
51
- * @param endpoint The endpoint to retrieve SBF data from.
52
- * @param options The options for retrieving data.
53
- * @returns
54
- */
55
- export const fetchData = (endpoint, options) => __awaiter(void 0, void 0, void 0, function* () {
56
- var _b;
57
- // We don't support fetching a single point in SBF's. We return an empty result instead.
58
- if (!options.limit === undefined) {
59
- return options.measurements.reduce((acc, c) => (Object.assign(Object.assign({}, acc), { [c]: [[options.offset, "NaN"]] })), {});
60
- }
61
- const sbfArgs = {
62
- getData: {
63
- file: options.file,
64
- start: options.offset,
65
- end: options.offset + (options.limit || 0),
66
- streams: options.measurements,
67
- resolution: options.rows,
68
- },
69
- };
70
- const body = JSON.stringify([sbfArgs]);
71
- const fetchArgs = {
72
- headers: {
73
- Accept: "application/json",
74
- "Content-Type": "application/json",
75
- "X-Files": options.file,
76
- },
77
- credentials: "include",
78
- method: "POST",
79
- body,
80
- };
81
- const response = yield fetch(endpoint, fetchArgs);
82
- const allMeasurements = (yield handleDataServerResponse(response));
83
- const measurements = ((_b = allMeasurements[0]) === null || _b === void 0 ? void 0 : _b.streams) || [];
84
- return measurements.reduce((acc, c) => {
85
- const { name, data } = c;
86
- return Object.assign(Object.assign({}, acc), { [name]: data });
87
- }, {});
88
- });
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * This takes the result from the fetch() call and throws an error if the response not ok.
12
+ * @param r A response from fetch()
13
+ * @returns
14
+ */
15
+ const handleDataServerResponse = (r) => {
16
+ if (!r.ok)
17
+ throw new Error(`Got HTTP error: "${r.status}: ${r.statusText}"`);
18
+ return r.json();
19
+ };
20
+ /**
21
+ * Fetches measurement metadata for a given SBF.
22
+ *
23
+ * @param endpoint Endpoint to send request to.
24
+ * @param file File to return measurement metadata from.
25
+ * @returns
26
+ */
27
+ export const fetchDataMetadata = (endpoint, file) => __awaiter(void 0, void 0, void 0, function* () {
28
+ var _a;
29
+ const args = {
30
+ headers: {
31
+ Accept: "application/json",
32
+ "Content-Type": "application/json",
33
+ "X-Files": file,
34
+ },
35
+ method: "POST",
36
+ credentials: "include",
37
+ body: JSON.stringify({
38
+ getMeta: {
39
+ files: [file],
40
+ },
41
+ }),
42
+ };
43
+ const response = yield fetch(endpoint, args);
44
+ const json = (yield handleDataServerResponse(response));
45
+ const measurements = ((_a = json.metadata[0]) === null || _a === void 0 ? void 0 : _a.streams) || [];
46
+ return measurements.map((m) => (Object.assign({ file, id: m.name }, m)));
47
+ });
48
+ /**
49
+ * Fetch measurement data from a SBF.
50
+ *
51
+ * @param endpoint The endpoint to retrieve SBF data from.
52
+ * @param options The options for retrieving data.
53
+ * @returns
54
+ */
55
+ export const fetchData = (endpoint, options) => __awaiter(void 0, void 0, void 0, function* () {
56
+ var _b;
57
+ // We don't support fetching a single point in SBF's. We return an empty result instead.
58
+ if (!options.limit === undefined) {
59
+ return options.measurements.reduce((acc, c) => (Object.assign(Object.assign({}, acc), { [c]: [[options.offset, "NaN"]] })), {});
60
+ }
61
+ const sbfArgs = {
62
+ getData: {
63
+ file: options.file,
64
+ start: options.offset,
65
+ end: options.offset + (options.limit || 0),
66
+ streams: options.measurements,
67
+ resolution: options.rows,
68
+ },
69
+ };
70
+ const body = JSON.stringify([sbfArgs]);
71
+ const fetchArgs = {
72
+ headers: {
73
+ Accept: "application/json",
74
+ "Content-Type": "application/json",
75
+ "X-Files": options.file,
76
+ },
77
+ credentials: "include",
78
+ method: "POST",
79
+ body,
80
+ };
81
+ const response = yield fetch(endpoint, fetchArgs);
82
+ const allMeasurements = (yield handleDataServerResponse(response));
83
+ const measurements = ((_b = allMeasurements[0]) === null || _b === void 0 ? void 0 : _b.streams) || [];
84
+ return measurements.reduce((acc, c) => {
85
+ const { name, data } = c;
86
+ return Object.assign(Object.assign({}, acc), { [name]: data });
87
+ }, {});
88
+ });
89
89
  //# sourceMappingURL=sbf.js.map
@@ -1,38 +1,38 @@
1
- import { AbstractMeasurementDataClient, FetchMeasurementDataArgs } from "../MeasurementDataClient";
2
- declare type SignalViewerDataClientOptions = {
3
- /**
4
- * Endpoint (URL) to send requests for HDF files.
5
- */
6
- hdfEndpoint: string;
7
- /**
8
- * Endpoint (URL) to send requests for SBF files.
9
- */
10
- sbfEndpoint: string;
11
- };
12
- /**
13
- * Implementation of MeasurementDataClient for the online environment.
14
- *
15
- * This either uses websockets for HDF5 files, or sends HTTP requests to the SBF server depending on which files we're
16
- * retrieving for.
17
- *
18
- * SBF files are considered legacy, and there is no support for retrieving measurement data using websockets.
19
- */
20
- export declare class SignalViewerDataClient extends AbstractMeasurementDataClient {
21
- private hdfEndpoint;
22
- private sbfEndpoint;
23
- private cId;
24
- private promises;
25
- constructor({ hdfEndpoint, sbfEndpoint }: SignalViewerDataClientOptions);
26
- /**
27
- * Returns a number and increments the cId. Used for "tagging" requests to the endpoint so we can recognise matching response.
28
- * @returns number
29
- */
30
- private nextId;
31
- fetchMetadata: (file: string) => Promise<any>;
32
- fetchMeasurementData: (args: FetchMeasurementDataArgs) => Promise<any>;
33
- fetchOverlayData: (args: any) => Promise<any>;
34
- fetchReqData: (args: any) => Promise<any>;
35
- destroy(): void;
36
- }
37
- export {};
1
+ import { AbstractMeasurementDataClient, FetchMeasurementDataArgs } from "../MeasurementDataClient";
2
+ declare type SignalViewerDataClientOptions = {
3
+ /**
4
+ * Endpoint (URL) to send requests for HDF files.
5
+ */
6
+ hdfEndpoint: string;
7
+ /**
8
+ * Endpoint (URL) to send requests for SBF files.
9
+ */
10
+ sbfEndpoint: string;
11
+ };
12
+ /**
13
+ * Implementation of MeasurementDataClient for the online environment.
14
+ *
15
+ * This either uses websockets for HDF5 files, or sends HTTP requests to the SBF server depending on which files we're
16
+ * retrieving for.
17
+ *
18
+ * SBF files are considered legacy, and there is no support for retrieving measurement data using websockets.
19
+ */
20
+ export declare class SignalViewerDataClient extends AbstractMeasurementDataClient {
21
+ private hdfEndpoint;
22
+ private sbfEndpoint;
23
+ private cId;
24
+ private promises;
25
+ constructor({ hdfEndpoint, sbfEndpoint }: SignalViewerDataClientOptions);
26
+ /**
27
+ * Returns a number and increments the cId. Used for "tagging" requests to the endpoint so we can recognise matching response.
28
+ * @returns number
29
+ */
30
+ private nextId;
31
+ fetchMetadata: (file: string) => Promise<any>;
32
+ fetchMeasurementData: (args: FetchMeasurementDataArgs) => Promise<any>;
33
+ fetchOverlayData: (args: any) => Promise<any>;
34
+ fetchReqData: (args: any) => Promise<any>;
35
+ destroy(): void;
36
+ }
37
+ export {};
38
38
  //# sourceMappingURL=SignalViewerDataClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignalViewerDataClient.d.ts","sourceRoot":"","sources":["../../../src/client/signalviewer/SignalViewerDataClient.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAmBlC,aAAK,6BAA6B,GAAG;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAIF;;;;;;;GAOG;AACH,qBAAa,sBAAuB,SAAQ,6BAA6B;IACvE,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,QAAQ,CAIP;gBAEG,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,6BAA6B;IAsBvE;;;OAGG;IACH,OAAO,CAAC,MAAM;IAMd,aAAa,SAAgB,MAAM,kBAoBjC;IAEF,oBAAoB,SAAgB,wBAAwB,kBA6C1D;IAEF,gBAAgB,SAAgB,GAAG,kBAqBjC;IAEF,YAAY,SAAgB,GAAG,kBAqB7B;IAEK,OAAO;CAOf"}
1
+ {"version":3,"file":"SignalViewerDataClient.d.ts","sourceRoot":"","sources":["../../../src/client/signalviewer/SignalViewerDataClient.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAGlC,aAAK,6BAA6B,GAAG;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAIF;;;;;;;GAOG;AACH,qBAAa,sBAAuB,SAAQ,6BAA6B;IACvE,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,QAAQ,CAIP;gBAEG,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,6BAA6B;IA+BvE;;;OAGG;IACH,OAAO,CAAC,MAAM;IAMd,aAAa,SAAgB,MAAM,kBAoBjC;IAEF,oBAAoB,SAAgB,wBAAwB,kBAsD1D;IAEF,gBAAgB,SAAgB,GAAG,kBAqBjC;IAEF,YAAY,SAAgB,GAAG,kBAqB7B;IAEK,OAAO;CAOf"}