@uwrl/qc-utils 0.0.17 → 0.0.19

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 (40) hide show
  1. package/README.md +56 -0
  2. package/dist/index.js +2149 -893
  3. package/dist/index.umd.cjs +15 -5
  4. package/package.json +61 -56
  5. package/dist/index.d.ts +0 -4
  6. package/dist/models/dataSource.d.ts +0 -173
  7. package/dist/models/index.d.ts +0 -2
  8. package/dist/models/payload.d.ts +0 -24
  9. package/dist/models/settings.d.ts +0 -65
  10. package/dist/models/timestamp.d.ts +0 -150
  11. package/dist/services/__tests__/createPatchObject.spec.d.ts +0 -1
  12. package/dist/services/__tests__/requestInterceptor.spec.d.ts +0 -1
  13. package/dist/services/__tests__/responseInterceptor.spec.d.ts +0 -1
  14. package/dist/services/api.d.ts +0 -147
  15. package/dist/services/apiMethods.d.ts +0 -8
  16. package/dist/services/createPatchObject.d.ts +0 -17
  17. package/dist/services/getCSRFToken.d.ts +0 -1
  18. package/dist/services/index.d.ts +0 -6
  19. package/dist/services/requestInterceptor.d.ts +0 -12
  20. package/dist/services/responseInterceptor.d.ts +0 -2
  21. package/dist/types/index.d.ts +0 -350
  22. package/dist/utils/__tests__/ellapsed-time.spec.d.ts +0 -1
  23. package/dist/utils/__tests__/format.spec.d.ts +0 -1
  24. package/dist/utils/__tests__/notifications.spec.d.ts +0 -1
  25. package/dist/utils/__tests__/observations.spec.d.ts +0 -1
  26. package/dist/utils/ellapsed-time.d.ts +0 -4
  27. package/dist/utils/format.d.ts +0 -5
  28. package/dist/utils/index.d.ts +0 -5
  29. package/dist/utils/notifications.d.ts +0 -46
  30. package/dist/utils/observations.d.ts +0 -5
  31. package/dist/utils/plotting/__tests__/delete-data.worker.spec.d.ts +0 -1
  32. package/dist/utils/plotting/__tests__/mock.d.ts +0 -4
  33. package/dist/utils/plotting/__tests__/observation-record.spec.d.ts +0 -1
  34. package/dist/utils/plotting/add-data.worker.d.ts +0 -0
  35. package/dist/utils/plotting/delete-data.worker.d.ts +0 -0
  36. package/dist/utils/plotting/drift-correction.worker.d.ts +0 -0
  37. package/dist/utils/plotting/fill-gaps.worker.d.ts +0 -0
  38. package/dist/utils/plotting/interpolate.worker.d.ts +0 -0
  39. package/dist/utils/plotting/observation-record.d.ts +0 -155
  40. package/dist/utils/plotting/shift-datetimes.worker.d.ts +0 -0
@@ -1,350 +0,0 @@
1
- import { DataSource } from '@/models';
2
- import { ObservationRecord } from '@/utils/plotting/observation-record';
3
- export type EnumDictionary<T extends string | symbol | number, U> = {
4
- [K in T]: U;
5
- };
6
- export declare enum TimeUnit {
7
- SECOND = "s",
8
- MINUTE = "m",
9
- HOUR = "h",
10
- DAY = "D",
11
- WEEK = "W",
12
- MONTH = "M",
13
- YEAR = "Y"
14
- }
15
- export declare enum EnumEditOperations {
16
- ADD_POINTS = "ADD_POINTS",
17
- CHANGE_VALUES = "CHANGE_VALUES",
18
- DELETE_POINTS = "DELETE_POINTS",
19
- DRIFT_CORRECTION = "DRIFT_CORRECTION",
20
- INTERPOLATE = "INTERPOLATE",
21
- SHIFT_DATETIMES = "SHIFT_DATETIMES",
22
- FILL_GAPS = "FILL_GAPS"
23
- }
24
- export declare enum EnumFilterOperations {
25
- FIND_GAPS = "FIND_GAPS",
26
- PERSISTENCE = "PERSISTENCE",
27
- CHANGE = "CHANGE",
28
- RATE_OF_CHANGE = "RATE_OF_CHANGE",
29
- VALUE_THRESHOLD = "VALUE_THRESHOLD"
30
- }
31
- export declare enum FilterOperation {
32
- LT = "Less than",
33
- LTE = "Less than or equal to",
34
- GT = "Greater than",
35
- GTE = "Greater than or equal to",
36
- E = "Equal",
37
- START = "Start datetime",
38
- END = "End datetime"
39
- }
40
- export declare const FilterOperationFn: EnumDictionary<FilterOperation, (value: number, toCompare: number) => boolean>;
41
- export declare enum Operator {
42
- ADD = "ADD",
43
- SUB = "SUB",
44
- MULT = "MULT",
45
- DIV = "DIV",
46
- ASSIGN = "ASSIGN"
47
- }
48
- export declare enum LogicalOperation {
49
- LT = "Less than",
50
- LTE = "Less than or equal to",
51
- GT = "Greater than",
52
- GTE = "Greater than or equal to",
53
- E = "Equal"
54
- }
55
- export declare const LogicalComparator: EnumDictionary<LogicalOperation, (value: number, toCompare: number) => boolean>;
56
- export type HistoryItem = {
57
- method: EnumEditOperations;
58
- icon: string;
59
- isLoading: boolean;
60
- args?: any[];
61
- duration?: number;
62
- status?: 'success' | 'failed';
63
- };
64
- export type DataPoint = {
65
- date: Date;
66
- value: number;
67
- };
68
- export type DataArray = [string, number][];
69
- export interface GraphSeries {
70
- id: string;
71
- name: string;
72
- data: ObservationRecord;
73
- yAxisLabel: string;
74
- seriesOption: any;
75
- }
76
- export type TimeSpacingUnit = 'seconds' | 'minutes' | 'hours' | 'days';
77
- export interface Tag {
78
- key: string;
79
- value: string;
80
- }
81
- export type Frequency = 'daily' | 'weekly' | 'monthly' | null;
82
- export declare class HydroShareArchive {
83
- id: string;
84
- thingId: string;
85
- link: string;
86
- frequency: Frequency;
87
- path: string;
88
- datastreamIds: string[];
89
- publicResource: boolean;
90
- constructor();
91
- }
92
- export declare class PostHydroShareArchive extends HydroShareArchive {
93
- resourceTitle?: string;
94
- resourceAbstract?: string;
95
- resourceKeywords?: string[];
96
- constructor();
97
- }
98
- export declare class Location {
99
- latitude?: number | '';
100
- longitude?: number | '';
101
- elevation_m?: number | '';
102
- elevationDatum: string;
103
- state: string;
104
- county: string;
105
- country: string;
106
- constructor();
107
- }
108
- export declare class Thing {
109
- id: string;
110
- workspaceId: string;
111
- name: string;
112
- location: Location;
113
- tags: Tag[];
114
- hydroShareArchive?: HydroShareArchive | null;
115
- siteType: string;
116
- samplingFeatureCode: string;
117
- isPrivate: boolean;
118
- description: string;
119
- samplingFeatureType: string;
120
- dataDisclaimer: string;
121
- constructor();
122
- }
123
- export interface ThingWithColor extends Thing {
124
- color?: {
125
- borderColor: string;
126
- background: string;
127
- glyphColor: string;
128
- };
129
- tagValue?: string;
130
- }
131
- export declare class Datastream {
132
- id: string;
133
- workspaceId: string;
134
- name: string;
135
- description: string;
136
- thingId: string;
137
- observationType: string;
138
- resultType?: string;
139
- status?: string;
140
- sampledMedium: string;
141
- noDataValue: number;
142
- aggregationStatistic: string;
143
- unitId: string;
144
- observedPropertyId: string;
145
- sensorId: string;
146
- processingLevelId: string;
147
- isPrivate: boolean;
148
- isVisible: boolean;
149
- phenomenonBeginTime?: string | null;
150
- phenomenonEndTime?: string | null;
151
- intendedTimeSpacing?: number;
152
- intendedTimeSpacingUnit?: TimeSpacingUnit | null;
153
- timeAggregationInterval: number | null;
154
- timeAggregationIntervalUnit: TimeSpacingUnit;
155
- dataSourceId?: string | null;
156
- valueCount: number;
157
- constructor(thingId?: string);
158
- }
159
- export interface DatastreamExtended {
160
- id: string;
161
- name: string;
162
- description: string;
163
- observationType: string;
164
- resultType?: string;
165
- status?: string;
166
- sampledMedium: string;
167
- noDataValue: number;
168
- aggregationStatistic: string;
169
- isPrivate: boolean;
170
- isVisible: boolean;
171
- phenomenonBeginTime?: string | null;
172
- phenomenonEndTime?: string | null;
173
- intendedTimeSpacing?: number;
174
- intendedTimeSpacingUnit?: TimeSpacingUnit | null;
175
- timeAggregationInterval: number | null;
176
- timeAggregationIntervalUnit: TimeSpacingUnit;
177
- dataSourceId?: string | null;
178
- valueCount: number;
179
- thing: Thing;
180
- workspace: Workspace;
181
- unit: Unit;
182
- observedProperty: ObservedProperty;
183
- sensor: Sensor;
184
- processingLevel: ProcessingLevel;
185
- dataSource: DataSource;
186
- }
187
- export declare class Unit {
188
- id: string;
189
- workspaceId: string;
190
- name: string;
191
- symbol: string;
192
- definition: string;
193
- type: string;
194
- constructor();
195
- }
196
- export declare class Sensor {
197
- id: string;
198
- workspaceId: string;
199
- name: string;
200
- description: string;
201
- manufacturer: string;
202
- model: string;
203
- methodType: string;
204
- methodCode: string;
205
- methodLink: string;
206
- encodingType: string;
207
- modelLink: string;
208
- constructor();
209
- }
210
- export declare class ObservedProperty {
211
- id: string;
212
- workspaceId: string;
213
- name: string;
214
- definition: string;
215
- description: string;
216
- type: string;
217
- code: string;
218
- constructor();
219
- }
220
- export declare class ProcessingLevel {
221
- id: string;
222
- workspaceId: string;
223
- code: string;
224
- definition: string;
225
- explanation: string;
226
- constructor();
227
- }
228
- export declare class ResultQualifier {
229
- id: string;
230
- workspaceId: string;
231
- code: string;
232
- description: string;
233
- constructor();
234
- }
235
- export declare class Organization {
236
- name?: string;
237
- code?: string;
238
- type?: string;
239
- description?: string;
240
- link?: string;
241
- constructor();
242
- }
243
- export declare class User {
244
- id: string;
245
- email: string;
246
- password: string;
247
- firstName: string;
248
- middleName: string;
249
- lastName: string;
250
- phone: string;
251
- address: string;
252
- organization?: Organization | null;
253
- type: string;
254
- link: string;
255
- accountType: 'admin' | 'standard' | 'limited';
256
- hydroShareConnected: boolean;
257
- constructor();
258
- }
259
- export interface Photo {
260
- name: string;
261
- link: string;
262
- }
263
- export declare class OAuthProvider {
264
- id: string;
265
- name: string;
266
- iconLink: string;
267
- signupEnabled: boolean;
268
- connectEnabled: boolean;
269
- constructor();
270
- }
271
- export declare enum PermissionAction {
272
- Global = "*",
273
- View = "view",
274
- Create = "create",
275
- Edit = "edit",
276
- Delete = "delete"
277
- }
278
- export declare enum PermissionResource {
279
- Global = "*",
280
- Workspace = "Workspace",
281
- Collaborator = "Collaborator",
282
- Thing = "Thing",
283
- Datastream = "Datastream",
284
- Sensor = "Sensor",
285
- Unit = "Unit",
286
- ObservedProperty = "ObservedProperty",
287
- ProcessingLevel = "ProcessingLevel",
288
- Observation = "Observation"
289
- }
290
- export interface Permission {
291
- action: PermissionAction;
292
- resource: PermissionResource;
293
- }
294
- export interface CollaboratorRole {
295
- name: string;
296
- description: string;
297
- id: string;
298
- workspaceId: string;
299
- isApikeyRole: boolean;
300
- isUserRole: boolean;
301
- permissions: Permission[];
302
- }
303
- export declare class ApiKey {
304
- id: string;
305
- key: string;
306
- name: string;
307
- description: string;
308
- isActive: boolean;
309
- expiresAt: string;
310
- createdAt: string;
311
- lastUsed: string;
312
- workspaceId: string;
313
- role: CollaboratorRole | null;
314
- constructor(init?: Partial<ApiKey>);
315
- }
316
- export interface WorkspaceData {
317
- id: string;
318
- name: string;
319
- isPrivate: boolean;
320
- owner: User;
321
- collaboratorRole: CollaboratorRole;
322
- pendingTransferTo?: User | null;
323
- }
324
- export declare class Workspace {
325
- id: string;
326
- name: string;
327
- isPrivate: boolean;
328
- owner: UserInfo | null;
329
- collaboratorRole: CollaboratorRole | null;
330
- pendingTransferTo?: UserInfo | null;
331
- constructor();
332
- }
333
- export interface UserInfo {
334
- name: string;
335
- email: string;
336
- phone: string;
337
- address: string;
338
- link: string;
339
- type: string;
340
- organizationName: string;
341
- }
342
- export declare class Collaborator {
343
- user: UserInfo;
344
- role: CollaboratorRole;
345
- constructor();
346
- }
347
- export interface ApiError {
348
- status: number;
349
- message?: string;
350
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export declare const measureEllapsedTime: (fn: () => any, message?: string) => Promise<{
2
- response: any;
3
- duration: number;
4
- }>;
@@ -1,5 +0,0 @@
1
- import { EnumDictionary, TimeUnit } from '@/types';
2
- export declare const timeUnitMultipliers: EnumDictionary<TimeUnit, number>;
3
- export declare const formatDate: (date: Date) => string;
4
- export declare const formatDuration: (duration: number) => string;
5
- export declare const shiftDatetime: (datetime: number, amount: number, unit: TimeUnit) => number;
@@ -1,5 +0,0 @@
1
- export * from './format';
2
- export * from './ellapsed-time';
3
- export * from './notifications';
4
- export * from './observations';
5
- export * from './plotting/observation-record';
@@ -1,46 +0,0 @@
1
- export declare const DEFAULT_SNACK_DURATION = 3000;
2
- export declare enum SnackColor {
3
- Warning = "warning",
4
- Success = "success",
5
- Error = "error",
6
- Info = "info"
7
- }
8
- export declare enum SnackIcon {
9
- Success = "mdi-checkbox-marked-circle",
10
- Warning = "mdi-alert",
11
- Error = "mdi-alert-circle",
12
- Info = "mdi-information",
13
- None = "none"
14
- }
15
- export declare enum SnackTitle {
16
- Warning = "Warning",
17
- Success = "Success",
18
- Error = "Error",
19
- Info = "Info"
20
- }
21
- export declare enum Position {
22
- Center = "center",
23
- Left = "left",
24
- Right = "right",
25
- Bottom = "bottom",
26
- Top = "top"
27
- }
28
- export declare class Snack {
29
- message: string;
30
- color: SnackColor;
31
- icon: SnackIcon;
32
- title: SnackTitle;
33
- timeout: number;
34
- position: Position;
35
- visible: boolean;
36
- constructor(message?: string, color?: SnackColor, icon?: SnackIcon, title?: SnackTitle, timeout?: number, position?: Position, visible?: boolean);
37
- }
38
- export declare class Snackbar {
39
- private static subject;
40
- static get snack$(): import("rxjs").Observable<Snack>;
41
- private static createSnackbar;
42
- static success(message: string): void;
43
- static warn(message: string): void;
44
- static error(message: string): void;
45
- static info(message: string): void;
46
- }
@@ -1,5 +0,0 @@
1
- export declare function subtractHours(timestamp: string, hours: number): string;
2
- /** Returns the index of the first value that is greater or equal to the target value */
3
- export declare const findFirstGreaterOrEqual: (array: number[] | Float64Array<SharedArrayBuffer>, target: number) => number;
4
- /** Returns the index of the last value that is lesser or equal to the target value */
5
- export declare const findLastLessOrEqual: (array: number[] | Float64Array<SharedArrayBuffer>, target: number) => number;
@@ -1,4 +0,0 @@
1
- export declare const mockDatastream: {
2
- phenomenon_time: string[];
3
- result: number[];
4
- };
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,155 +0,0 @@
1
- import { EnumEditOperations, EnumFilterOperations, HistoryItem } from '../../types';
2
- /**
3
- * This number should approximate the number of observations that a dataset could increase by during a session.
4
- * The lower this number, the less memory the entire app uses.
5
- * Note that when a dataset number of data points increases by more than `INCREASE_AMOUNT`,
6
- * the `_growBuffer()` method will allocate a new buffer, and the data will be copied into it.
7
- */
8
- export declare const INCREASE_AMOUNT: number;
9
- export declare class ObservationRecord {
10
- /** The generated dataset to be used for plotting */
11
- dataset: {
12
- dimensions: string[];
13
- source: {
14
- x: Float64Array<SharedArrayBuffer>;
15
- y: Float32Array<SharedArrayBuffer>;
16
- };
17
- };
18
- history: HistoryItem[];
19
- loadingTime: number | null;
20
- isLoading: boolean;
21
- rawData: {
22
- datetimes: Float64Array<ArrayBuffer> | number[];
23
- dataValues: Float32Array<ArrayBuffer> | number[];
24
- };
25
- constructor(dataArrays: {
26
- datetimes: Float64Array<ArrayBuffer> | number[];
27
- dataValues: Float32Array<ArrayBuffer> | number[];
28
- });
29
- loadData(dataArrays: {
30
- datetimes: Float64Array<ArrayBuffer> | number[];
31
- dataValues: Float32Array<ArrayBuffer> | number[];
32
- }): Promise<void>;
33
- get dataX(): Float64Array<SharedArrayBuffer>;
34
- get dataY(): Float32Array<SharedArrayBuffer>;
35
- /**
36
- * Resizes the typed array
37
- * @param length The total number of elements that the view will contain
38
- */
39
- private _resizeTo;
40
- /**
41
- * Buffer size is always in increments of `INCREASE_AMOUNT`.
42
- * Grows the buffer by `INCREASE_AMOUNT` in bytes if the current data doesn't fit
43
- * @param newLength The total number of elements that the view will contain
44
- */
45
- private _growBuffer;
46
- /**
47
- * Reloads the dataset with the raw data
48
- */
49
- reload(): Promise<void>;
50
- /**
51
- * @param index
52
- * @returns
53
- */
54
- reloadHistory(index: number): Promise<void>;
55
- /**
56
- * Remove a history item
57
- * @param index
58
- */
59
- removeHistoryItem(index: number): Promise<void>;
60
- get beginTime(): Date | null;
61
- get endTime(): Date | null;
62
- /** Dispatch an operation and log its signature in hisotry */
63
- dispatch(action: EnumEditOperations | [EnumEditOperations, ...any][], ...args: any): Promise<any[]>;
64
- /** Filter operations do not transform the data and are not logged in history */
65
- dispatchFilter(action: EnumFilterOperations | [EnumFilterOperations, ...any][], ...args: any): Promise<any>;
66
- /**
67
- * @param index An array containing the list of index of values to perform the operations on.
68
- * @param operator The operator that will be applied
69
- * @param value The value to use in the operation
70
- * @returns The modified DataFrame
71
- */
72
- private _changeValues;
73
- private _interpolate;
74
- /** Interpolate existing values in the data source */
75
- private _interpolateLinear;
76
- /**
77
- * Shifts the selected indexes by specified amount of units. Elements are reinserted according to their datetime.
78
- * @param index The index of the elements to shift
79
- * @param amount Number of {@link TimeUnit}
80
- * @param unit {@link TimeUnit}
81
- * @returns
82
- */
83
- private _shift;
84
- private _fillGapsV2;
85
- /**
86
- * Find gaps and fill them with placeholder value
87
- * @param gap Intervals to detect as gaps
88
- * @param fill Interval used to fill the detected gaps
89
- * @param interpolateValues If true, the new values will be linearly interpolated
90
- * @returns
91
- */
92
- private _fillGaps;
93
- /**
94
- Deletes data points from a large array using worker threads.
95
- 1. The main thread divides the original array into equal parts to distribute work among workers.
96
- 2. For each segment, binary search locates the indexes to delete (deleteSegment), ensuring efficient lookups.
97
- 3. The cumulative deletions before each segment help compute the starting index (startTarget) for each worker's output, ensuring no overlap.
98
- 4. Each worker processes its segment linearly, skipping deletions and copying kept elements to their computed positions.
99
- * @param deleteIndices
100
- */
101
- private _deleteDataPoints;
102
- /**
103
- *
104
- * @param start The start index
105
- * @param end The end index
106
- * @param value The drift amount
107
- */
108
- private _driftCorrection;
109
- /** Traverses the index array and returns groups of consecutive values.
110
- * i.e.: `[0, 1, 3, 4, 6] => [[0, 1], [3, 4], [6]]`
111
- * Assumes the input array is sorted.
112
- * @param index: the index array (sorted)
113
- */
114
- private _getConsecutiveGroups;
115
- /**
116
- * Adds data points. Their insert index is determined using `findFirstGreaterOrEqual` in the x-axis.
117
- * @param dataPoints
118
- */
119
- private _addDataPoints;
120
- /**
121
- * Filter by applying a set of logical operations
122
- * @param appliedFilters
123
- * @returns
124
- */
125
- private _valueThreshold;
126
- /**
127
- *
128
- * @param comparator
129
- * @param value
130
- * @returns
131
- */
132
- private _rateOfChange;
133
- /**
134
- *
135
- * @param comparator
136
- * @param value
137
- * @returns
138
- */
139
- private _change;
140
- /**
141
- * Find gaps in the data
142
- * @param value The time value
143
- * @param unit The time unit (TimeUnit)
144
- * @param range If specified, the gaps will be found only within the range
145
- * @returns
146
- */
147
- private _findGaps;
148
- /**
149
- * Find points where the values are the same at least x times in a row
150
- * @param times The number of times in a row that points can be equal
151
- * @param range If specified, the points will be found only within the range
152
- * @returns
153
- */
154
- private _persistence;
155
- }
File without changes