@uwrl/qc-utils 0.0.14 → 0.0.17

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 (31) hide show
  1. package/dist/index.d.ts +4 -2
  2. package/dist/index.js +1647 -285
  3. package/dist/index.umd.cjs +5 -3
  4. package/dist/models/dataSource.d.ts +173 -0
  5. package/dist/models/index.d.ts +2 -0
  6. package/dist/models/payload.d.ts +24 -0
  7. package/dist/models/settings.d.ts +65 -0
  8. package/dist/models/timestamp.d.ts +150 -0
  9. package/dist/services/api.d.ts +147 -0
  10. package/dist/services/apiMethods.d.ts +8 -0
  11. package/dist/services/createPatchObject.d.ts +17 -0
  12. package/dist/services/getCSRFToken.d.ts +1 -0
  13. package/dist/services/index.d.ts +6 -0
  14. package/dist/services/requestInterceptor.d.ts +12 -0
  15. package/dist/services/responseInterceptor.d.ts +2 -0
  16. package/dist/types/index.d.ts +350 -0
  17. package/dist/utils/__tests__/ellapsed-time.spec.d.ts +1 -0
  18. package/dist/utils/__tests__/observations.spec.d.ts +1 -0
  19. package/dist/utils/ellapsed-time.d.ts +4 -0
  20. package/dist/utils/format.d.ts +5 -0
  21. package/dist/utils/index.d.ts +5 -0
  22. package/dist/utils/observations.d.ts +5 -0
  23. package/dist/utils/plotting/__tests__/observation-record.spec.d.ts +1 -0
  24. package/dist/utils/plotting/{observationRecord.d.ts → observation-record.d.ts} +8 -23
  25. package/package.json +1 -1
  26. package/dist/types.d.ts +0 -51
  27. package/dist/utils/ellapsedTime.d.ts +0 -0
  28. package/dist/utils/observationsUtils.d.ts +0 -0
  29. /package/dist/{utils/__tests__/ellapsedTime.spec.d.ts → services/__tests__/createPatchObject.spec.d.ts} +0 -0
  30. /package/dist/{utils/__tests__/observationsUtils.spec.d.ts → services/__tests__/requestInterceptor.spec.d.ts} +0 -0
  31. /package/dist/{utils/plotting/__tests__/observationRecord.spec.d.ts → services/__tests__/responseInterceptor.spec.d.ts} +0 -0
@@ -0,0 +1,147 @@
1
+ import { Unit, Thing, Sensor, ResultQualifier, ProcessingLevel, ObservedProperty, Datastream, Tag, PostHydroShareArchive, HydroShareArchive, User, Workspace, ApiKey } from '@/types';
2
+ import { DataSource } from '@/models';
3
+ import { OrchestrationSystem } from '@/models/dataSource';
4
+ export declare const BASE_URL: string;
5
+ export declare const AUTH_BASE: string;
6
+ export declare const ACCOUNT_BASE: string;
7
+ export declare const SESSION_BASE: string;
8
+ export declare const PROVIDER_BASE: string;
9
+ export declare const THINGS_BASE: string;
10
+ export declare const TAG_BASE: string;
11
+ type DatastreamFilterKey = 'unit_id' | 'sensor_id' | 'observed_property_id' | 'processing_level_id' | 'result_qualifier_id';
12
+ export declare const getObservationsEndpoint: (id: string, pageSize: number, startTime: string, endTime?: string, page?: number) => string;
13
+ export declare const api: {
14
+ fetchSession: () => Promise<any>;
15
+ login: (email: string, password: string) => Promise<any>;
16
+ logout: () => Promise<any>;
17
+ fetchUser: () => Promise<any>;
18
+ signup: (user: User) => Promise<any>;
19
+ updateUser: (user: User, oldUser: User) => Promise<any>;
20
+ deleteUser: () => Promise<any>;
21
+ sendVerificationEmail: (email: string) => Promise<any>;
22
+ verifyEmailWithCode: (key: string) => Promise<any>;
23
+ requestPasswordReset: (email: string) => Promise<any>;
24
+ resetPassword: (key: string, password: string) => Promise<any>;
25
+ fetchWorkspaces: () => Promise<any>;
26
+ fetchAssociatedWorkspaces: () => Promise<any>;
27
+ fetchWorkspace: (id: string) => Promise<any>;
28
+ createWorkspace: (postWorkspace: Workspace) => Promise<any>;
29
+ updateWorkspace: (newWorkspace: Workspace, oldWorkspace?: Workspace | null) => Promise<any>;
30
+ deleteWorkspace: (id: string) => Promise<any>;
31
+ transferWorkspace: (id: string, newOwner: string) => Promise<any>;
32
+ acceptWorkspaceTransfer: (id: string) => Promise<any>;
33
+ rejectWorkspaceTransfer: (id: string) => Promise<any>;
34
+ getCollaboratorRoles: (id: string) => Promise<any>;
35
+ getAPIKeyRoles: (id: string) => Promise<any>;
36
+ getRole: (roleId: string) => Promise<any>;
37
+ getCollaborators: (id: string) => Promise<any>;
38
+ addCollaborator: (id: string, email: string, roleId: string) => Promise<any>;
39
+ updateCollaboratorRole: (id: string, email: string, roleId: string) => Promise<any>;
40
+ removeCollaborator: (id: string, email: string) => Promise<any>;
41
+ fetchApiKeys: (workspaceId: string) => Promise<any>;
42
+ fetchApiKey: (workspaceId: string, apiKeyId: string) => Promise<any>;
43
+ createApiKey: (apiKey: ApiKey) => Promise<any>;
44
+ updateApiKey: (newKey: ApiKey, oldKey?: ApiKey) => Promise<any>;
45
+ regenerateApiKey: (id: string, apiKeyId: string) => Promise<any>;
46
+ deleteApiKey: (id: string, apiKeyId: string) => Promise<any>;
47
+ fetchConnectedProviders: () => Promise<any>;
48
+ providerRedirect: (provider: string, callbackUrl: string, process: string) => void;
49
+ providerSignup: (user: User) => Promise<any>;
50
+ deleteProvider: (provider: string, account: string) => Promise<any>;
51
+ createUnit: (unit: Unit) => Promise<any>;
52
+ fetchUnits: () => Promise<any>;
53
+ fetchWorkspaceUnits: (id: string) => Promise<any>;
54
+ updateUnit: (newUnit: Unit, oldUnit?: Unit | null) => Promise<any>;
55
+ deleteUnit: (id: string) => Promise<any>;
56
+ getUnit: (id: string) => Promise<any>;
57
+ removeThingOwner: (id: string, email: string) => Promise<any>;
58
+ addSecondaryOwner: (id: string, email: string) => Promise<any>;
59
+ transferPrimaryOwnership: (id: string, email: string) => Promise<any>;
60
+ createThing: (thing: Thing) => Promise<any>;
61
+ fetchThings: () => Promise<any>;
62
+ fetchThingsForWorkspace: (id: string) => Promise<any>;
63
+ fetchOwnedThings: () => Promise<any>;
64
+ fetchThing: (id: string) => Promise<any>;
65
+ updateThing: (thing: Thing) => Promise<any>;
66
+ updateThingPrivacy: (id: string, isPrivate: boolean) => Promise<any>;
67
+ deleteThing: (id: string) => Promise<any>;
68
+ fetchMetadataForThingOwner: (thingId: string) => Promise<any>;
69
+ fetchMetadataForThing: (thingId: string) => Promise<any>;
70
+ uploadSitePhotos: (thingId: string, data: FormData) => Promise<any>;
71
+ fetchSitePhotos: (thingId: string) => Promise<any>;
72
+ deleteSitePhoto: (thingId: string, name: string) => Promise<any>;
73
+ createSiteTag: (thingId: string, tag: Tag) => Promise<any>;
74
+ editSiteTag: (thingId: string, tag: Tag) => Promise<any>;
75
+ fetchSiteTags: (thingId: string) => Promise<any>;
76
+ fetchUsersSiteTags: () => Promise<any>;
77
+ deleteSiteTag: (thingId: string, tag: Tag) => Promise<any>;
78
+ fetchWorkspaceTags: (workspaceId: string) => Promise<any>;
79
+ createHydroShareArchive: (archive: PostHydroShareArchive) => Promise<any>;
80
+ updateHydroShareArchive: (newArchive: HydroShareArchive, oldArchive?: HydroShareArchive) => Promise<any>;
81
+ fetchHydroShareArchive: (thingId: string) => Promise<any>;
82
+ deleteHydroShareArchive: (thingId: string) => Promise<any>;
83
+ archiveToHydroShare: (thingId: string) => Promise<any>;
84
+ createDatastream: (datastream: Datastream) => Promise<any>;
85
+ fetchDatastreams: (filters?: Partial<Record<DatastreamFilterKey, string>>) => Promise<any>;
86
+ fetchDatastreamsForThing: (thingId: string) => Promise<any>;
87
+ fetchExpandedDatastreamsForThing: (thingId: string) => Promise<any>;
88
+ fetchDatastreamsForDataSource: (id: string) => Promise<any>;
89
+ fetchDatastream: (id: string) => Promise<any>;
90
+ fetchDatastreamExpanded: (id: string) => Promise<any>;
91
+ fetchUsersDatastreams: () => Promise<any>;
92
+ updateDatastream: (newDS: Datastream, oldDS?: Datastream | null) => Promise<any>;
93
+ deleteDatastream: (id: string) => Promise<any>;
94
+ downloadDatastreamCSV: (id: string) => Promise<any>;
95
+ createObservedProperty: (op: ObservedProperty) => Promise<any>;
96
+ fetchObservedProperty: (id: string) => Promise<any>;
97
+ fetchObservedProperties: () => Promise<any>;
98
+ fetchWorkspaceObservedProperties: (id: string) => Promise<any>;
99
+ updateObservedProperty: (newOP: ObservedProperty, oldOP?: ObservedProperty | null) => Promise<any>;
100
+ deleteObservedProperty: (id: string) => Promise<any>;
101
+ createProcessingLevel: (pl: ProcessingLevel) => Promise<any>;
102
+ fetchProcessingLevels: () => Promise<any>;
103
+ fetchProcessingLevel: (id: string) => Promise<any>;
104
+ fetchWorkspaceProcessingLevels: (id: string) => Promise<any>;
105
+ updateProcessingLevel: (newPL: ProcessingLevel, oldPL?: ProcessingLevel | null) => Promise<any>;
106
+ deleteProcessingLevel: (id: string) => Promise<any>;
107
+ createSensor: (sensor: Sensor) => Promise<any>;
108
+ fetchSensors: () => Promise<any>;
109
+ fetchSensor: (id: string) => Promise<any>;
110
+ fetchWorkspaceSensors: (id: string) => Promise<any>;
111
+ updateSensor: (newSensor: Sensor, oldSensor?: Sensor | null) => Promise<any>;
112
+ deleteSensor: (id: string) => Promise<any>;
113
+ createResultQualifier: (resultQualifier: ResultQualifier) => Promise<any>;
114
+ fetchResultQualifiers: () => Promise<any>;
115
+ fetchWorkspaceResultQualifiers: (id: string) => Promise<any>;
116
+ updateResultQualifier: (newResultQualifier: ResultQualifier, oldResultQualifier?: ResultQualifier | null) => Promise<any>;
117
+ deleteResultQualifier: (id: string) => Promise<any>;
118
+ createOrchestrationSystem: (system: OrchestrationSystem) => Promise<any>;
119
+ fetchOrchestrationSystems: () => Promise<any>;
120
+ fetchWorkspaceOrchestrationSystems: (id: string) => Promise<any>;
121
+ fetchOrchestrationSystem: (id: string) => Promise<any>;
122
+ updateOrchestrationSystem: (id: string, system: OrchestrationSystem) => Promise<any>;
123
+ deleteOrchestrationSystem: (id: string) => Promise<any>;
124
+ createDataSource: (dataSource: DataSource) => Promise<any>;
125
+ fetchDataSources: () => Promise<any>;
126
+ fetchWorkspaceDataSources: (id: string) => Promise<any>;
127
+ fetchDataSource: (id: string) => Promise<any>;
128
+ updateDataSource: (newS: DataSource) => Promise<any>;
129
+ updateDataSourcePartial: (newS: DataSource) => Promise<any>;
130
+ deleteDataSource: (id: string) => Promise<any>;
131
+ linkDatastreamToDataSource: (dataSourceId: string, datastreamId: string) => Promise<any>;
132
+ unlinkDatastreamFromDataSource: (dataSourceId: string, datastreamId: string) => Promise<any>;
133
+ fetchObservations: (endpoint: string) => Promise<any>;
134
+ deleteObservationsForDatastream: (datastreamId: string) => Promise<any>;
135
+ fetchUserTypes: () => Promise<any>;
136
+ fetchOrganizationTypes: () => Promise<any>;
137
+ fetchSiteTypes: () => Promise<any>;
138
+ fetchSamplingFeatureTypes: () => Promise<any>;
139
+ fetchSensorEncodingTypes: () => Promise<any>;
140
+ fetchMethodTypes: () => Promise<any>;
141
+ fetchVariableTypes: () => Promise<any>;
142
+ fetchUnitTypes: () => Promise<any>;
143
+ fetchDatastreamStatuses: () => Promise<any>;
144
+ fetchDatastreamAggregations: () => Promise<any>;
145
+ fetchSampledMediums: () => Promise<any>;
146
+ };
147
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare const apiMethods: {
2
+ fetch(endpoint: string, options?: any): Promise<any>;
3
+ patch(endpoint: string, body: any, originalBody?: any, options?: any): Promise<any>;
4
+ post(endpoint: string, body?: any, options?: any): Promise<any>;
5
+ put(endpoint: string, body?: any, options?: any): Promise<any>;
6
+ delete(endpoint: string, body?: any, options?: any): Promise<any>;
7
+ paginatedFetch<T>(base: string, pageSize?: number): Promise<any>;
8
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates an object that represents the differences (patches) between the
3
+ * original and the updated objects.
4
+ *
5
+ * This function iterates through the properties of the updated object and compares each property
6
+ * with the corresponding property in the original object. If a difference is found:
7
+ * 1. For properties that are objects, it recursively computes the nested differences.
8
+ * 2. For other properties, it directly assigns the updated value.
9
+ *
10
+ * Note: The function only checks properties that exist in the updated object.
11
+ *
12
+ * @param {any} original - The original object to compare from.
13
+ * @param {any} updated - The updated object to compare against.
14
+ * @returns {any} An object representing the differences between the two input objects.
15
+ * If two properties are identical, they won't appear in the result.
16
+ */
17
+ export declare function createPatchObject(original: any, updated: any): any;
@@ -0,0 +1 @@
1
+ export declare function getCSRFToken(): string | null;
@@ -0,0 +1,6 @@
1
+ export * from './api';
2
+ export * from './apiMethods';
3
+ export * from './createPatchObject';
4
+ export * from './getCSRFToken';
5
+ export * from './requestInterceptor';
6
+ export * from './responseInterceptor';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Intercepts and enhances a request options object.
3
+ *
4
+ * - Adds Django AllAuth 'sessionid' to all requests
5
+ * - Adds CSRF Token to non-GET requests
6
+ * - If a body is present and it's an object, the body is stringified.
7
+ *
8
+ * @param {any} options - The original request options object.
9
+ *
10
+ * @returns {any} The enhanced request options with possible modified headers and body.
11
+ */
12
+ export declare function requestInterceptor(options: any): any;
@@ -0,0 +1,2 @@
1
+ export declare function extractErrorMessage(body: any): any;
2
+ export declare function responseInterceptor(response: Response): Promise<any>;
@@ -0,0 +1,350 @@
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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const measureEllapsedTime: (fn: () => any, message?: string) => Promise<{
2
+ response: any;
3
+ duration: number;
4
+ }>;
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,5 @@
1
+ export * from './format';
2
+ export * from './ellapsed-time';
3
+ export * from './notifications';
4
+ export * from './observations';
5
+ export * from './plotting/observation-record';
@@ -0,0 +1,5 @@
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,26 +1,4 @@
1
- import { EnumDictionary, EnumEditOperations, EnumFilterOperations, HistoryItem } from '../../types';
2
- export declare function subtractHours(timestamp: string, hours: number): string;
3
- /** Returns the index of the first value that is greater or equal to the target value */
4
- export declare const findFirstGreaterOrEqual: (array: number[] | Float64Array<SharedArrayBuffer>, target: number) => number;
5
- /** Returns the index of the last value that is lesser or equal to the target value */
6
- export declare const findLastLessOrEqual: (array: number[] | Float64Array<SharedArrayBuffer>, target: number) => number;
7
- export declare const measureEllapsedTime: (fn: () => any, message?: string) => Promise<{
8
- response: any;
9
- duration: number;
10
- }>;
11
- export declare enum TimeUnit {
12
- SECOND = "s",
13
- MINUTE = "m",
14
- HOUR = "h",
15
- DAY = "D",
16
- WEEK = "W",
17
- MONTH = "M",
18
- YEAR = "Y"
19
- }
20
- export declare const timeUnitMultipliers: EnumDictionary<TimeUnit, number>;
21
- export declare const formatDate: (date: Date) => string;
22
- export declare const formatDuration: (duration: number) => string;
23
- export declare const shiftDatetime: (datetime: number, amount: number, unit: TimeUnit) => number;
1
+ import { EnumEditOperations, EnumFilterOperations, HistoryItem } from '../../types';
24
2
  /**
25
3
  * This number should approximate the number of observations that a dataset could increase by during a session.
26
4
  * The lower this number, the less memory the entire app uses.
@@ -152,6 +130,13 @@ export declare class ObservationRecord {
152
130
  * @returns
153
131
  */
154
132
  private _rateOfChange;
133
+ /**
134
+ *
135
+ * @param comparator
136
+ * @param value
137
+ * @returns
138
+ */
139
+ private _change;
155
140
  /**
156
141
  * Find gaps in the data
157
142
  * @param value The time value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwrl/qc-utils",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "description": "Quality Control Utilities",
5
5
  "homepage": "https://github.com/hydroserver2/qc-utils#readme",
6
6
  "bugs": {