@ndustrial/contxt-sdk 5.5.7 → 5.6.1
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.
- package/.nvmrc +1 -1
- package/eslint.config.mjs +44 -0
- package/esm/bus/channels.js +1883 -216
- package/esm/bus/channels.js.map +1 -1
- package/esm/bus/index.browser.js +218 -37
- package/esm/bus/index.browser.js.map +1 -1
- package/esm/bus/index.js +906 -94
- package/esm/bus/index.js.map +1 -1
- package/esm/bus/webSocketConnection.browser.js +86 -12
- package/esm/bus/webSocketConnection.browser.js.map +1 -1
- package/esm/bus/webSocketConnection.js +2464 -332
- package/esm/bus/webSocketConnection.js.map +1 -1
- package/esm/config/audiences.js +37 -1
- package/esm/config/audiences.js.map +1 -1
- package/esm/config/defaults.js +37 -1
- package/esm/config/defaults.js.map +1 -1
- package/esm/config/index.js +1622 -203
- package/esm/config/index.js.map +1 -1
- package/esm/coordinator/applications.js +1019 -172
- package/esm/coordinator/applications.js.map +1 -1
- package/esm/coordinator/consent.js +603 -76
- package/esm/coordinator/consent.js.map +1 -1
- package/esm/coordinator/edgeNodes.js +520 -40
- package/esm/coordinator/edgeNodes.js.map +1 -1
- package/esm/coordinator/index.js +811 -54
- package/esm/coordinator/index.js.map +1 -1
- package/esm/coordinator/organizations.js +533 -60
- package/esm/coordinator/organizations.js.map +1 -1
- package/esm/coordinator/permissions.js +914 -107
- package/esm/coordinator/permissions.js.map +1 -1
- package/esm/coordinator/roles.js +2146 -258
- package/esm/coordinator/roles.js.map +1 -1
- package/esm/coordinator/users.js +3427 -484
- package/esm/coordinator/users.js.map +1 -1
- package/esm/events/index.js +2301 -393
- package/esm/events/index.js.map +1 -1
- package/esm/files/index.js +2053 -410
- package/esm/files/index.js.map +1 -1
- package/esm/index.js +1002 -148
- package/esm/index.js.map +1 -1
- package/esm/iot/feedTypes.js +188 -25
- package/esm/iot/feedTypes.js.map +1 -1
- package/esm/iot/feeds.js +420 -59
- package/esm/iot/feeds.js.map +1 -1
- package/esm/iot/fieldCategories.js +1172 -195
- package/esm/iot/fieldCategories.js.map +1 -1
- package/esm/iot/fieldGroupings.js +1689 -255
- package/esm/iot/fieldGroupings.js.map +1 -1
- package/esm/iot/fields.js +254 -28
- package/esm/iot/fields.js.map +1 -1
- package/esm/iot/index.js +212 -34
- package/esm/iot/index.js.map +1 -1
- package/esm/iot/outputs.js +320 -31
- package/esm/iot/outputs.js.map +1 -1
- package/esm/nionic/index.js +1097 -97
- package/esm/nionic/index.js.map +1 -1
- package/esm/request.js +1313 -219
- package/esm/request.js.map +1 -1
- package/esm/sessionTypes/auth0WebAuth.js +3395 -409
- package/esm/sessionTypes/auth0WebAuth.js.map +1 -1
- package/esm/sessionTypes/index.js +213 -22
- package/esm/sessionTypes/index.js.map +1 -1
- package/esm/sessionTypes/machineAuth.js +1314 -144
- package/esm/sessionTypes/machineAuth.js.map +1 -1
- package/esm/sessionTypes/passwordGrantAuth.js +1060 -145
- package/esm/sessionTypes/passwordGrantAuth.js.map +1 -1
- package/esm/utils/events/formatEventUpdateToServer.js +107 -4
- package/esm/utils/events/formatEventUpdateToServer.js.map +1 -1
- package/esm/utils/events/index.js +54 -2
- package/esm/utils/events/index.js.map +1 -1
- package/esm/utils/iot/formatOutputFieldDataFromServer.js +227 -14
- package/esm/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
- package/esm/utils/iot/index.js +56 -3
- package/esm/utils/iot/index.js.map +1 -1
- package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js +207 -7
- package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
- package/esm/utils/objects/createCaseChangeFn.js +449 -18
- package/esm/utils/objects/createCaseChangeFn.js.map +1 -1
- package/esm/utils/objects/index.js +56 -3
- package/esm/utils/objects/index.js.map +1 -1
- package/esm/utils/objects/map.js +520 -26
- package/esm/utils/objects/map.js.map +1 -1
- package/esm/utils/objects/toCamelCase.js +39 -3
- package/esm/utils/objects/toCamelCase.js.map +1 -1
- package/esm/utils/objects/toSnakeCase.js +39 -3
- package/esm/utils/objects/toSnakeCase.js.map +1 -1
- package/esm/utils/pagination/formatPaginatedDataFromServer.js +268 -11
- package/esm/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
- package/esm/utils/pagination/index.js +54 -2
- package/esm/utils/pagination/index.js.map +1 -1
- package/esm/utils/url/index.js +47 -2
- package/esm/utils/url/index.js.map +1 -1
- package/esm/utils/url/stringifyParams.js +176 -10
- package/esm/utils/url/stringifyParams.js.map +1 -1
- package/lib/bus/channels.js +1880 -223
- package/lib/bus/channels.js.map +1 -1
- package/lib/bus/index.browser.js +215 -43
- package/lib/bus/index.browser.js.map +1 -1
- package/lib/bus/index.js +903 -106
- package/lib/bus/index.js.map +1 -1
- package/lib/bus/webSocketConnection.browser.js +83 -15
- package/lib/bus/webSocketConnection.browser.js.map +1 -1
- package/lib/bus/webSocketConnection.js +2461 -339
- package/lib/bus/webSocketConnection.js.map +1 -1
- package/lib/config/audiences.js +33 -2
- package/lib/config/audiences.js.map +1 -1
- package/lib/config/defaults.js +33 -2
- package/lib/config/defaults.js.map +1 -1
- package/lib/config/index.js +1619 -212
- package/lib/config/index.js.map +1 -1
- package/lib/coordinator/applications.js +1016 -174
- package/lib/coordinator/applications.js.map +1 -1
- package/lib/coordinator/consent.js +600 -78
- package/lib/coordinator/consent.js.map +1 -1
- package/lib/coordinator/edgeNodes.js +517 -42
- package/lib/coordinator/edgeNodes.js.map +1 -1
- package/lib/coordinator/index.js +808 -78
- package/lib/coordinator/index.js.map +1 -1
- package/lib/coordinator/organizations.js +530 -62
- package/lib/coordinator/organizations.js.map +1 -1
- package/lib/coordinator/permissions.js +911 -109
- package/lib/coordinator/permissions.js.map +1 -1
- package/lib/coordinator/roles.js +2143 -260
- package/lib/coordinator/roles.js.map +1 -1
- package/lib/coordinator/users.js +3423 -489
- package/lib/coordinator/users.js.map +1 -1
- package/lib/events/index.js +2297 -404
- package/lib/events/index.js.map +1 -1
- package/lib/files/index.js +2050 -418
- package/lib/files/index.js.map +1 -1
- package/lib/index.js +999 -183
- package/lib/index.js.map +1 -1
- package/lib/iot/feedTypes.js +185 -27
- package/lib/iot/feedTypes.js.map +1 -1
- package/lib/iot/feeds.js +417 -61
- package/lib/iot/feeds.js.map +1 -1
- package/lib/iot/fieldCategories.js +1169 -203
- package/lib/iot/fieldCategories.js.map +1 -1
- package/lib/iot/fieldGroupings.js +1686 -263
- package/lib/iot/fieldGroupings.js.map +1 -1
- package/lib/iot/fields.js +251 -30
- package/lib/iot/fields.js.map +1 -1
- package/lib/iot/index.js +209 -55
- package/lib/iot/index.js.map +1 -1
- package/lib/iot/outputs.js +317 -34
- package/lib/iot/outputs.js.map +1 -1
- package/lib/nionic/index.js +1094 -98
- package/lib/nionic/index.js.map +1 -1
- package/lib/request.js +1310 -226
- package/lib/request.js.map +1 -1
- package/lib/sessionTypes/auth0WebAuth.js +3391 -421
- package/lib/sessionTypes/auth0WebAuth.js.map +1 -1
- package/lib/sessionTypes/index.js +209 -26
- package/lib/sessionTypes/index.js.map +1 -1
- package/lib/sessionTypes/machineAuth.js +1311 -151
- package/lib/sessionTypes/machineAuth.js.map +1 -1
- package/lib/sessionTypes/passwordGrantAuth.js +1057 -156
- package/lib/sessionTypes/passwordGrantAuth.js.map +1 -1
- package/lib/utils/events/formatEventUpdateToServer.js +102 -4
- package/lib/utils/events/formatEventUpdateToServer.js.map +1 -1
- package/lib/utils/events/index.js +51 -10
- package/lib/utils/events/index.js.map +1 -1
- package/lib/utils/iot/formatOutputFieldDataFromServer.js +224 -18
- package/lib/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
- package/lib/utils/iot/index.js +53 -15
- package/lib/utils/iot/index.js.map +1 -1
- package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js +203 -13
- package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
- package/lib/utils/objects/createCaseChangeFn.js +446 -25
- package/lib/utils/objects/createCaseChangeFn.js.map +1 -1
- package/lib/utils/objects/index.js +53 -15
- package/lib/utils/objects/index.js.map +1 -1
- package/lib/utils/objects/map.js +517 -33
- package/lib/utils/objects/map.js.map +1 -1
- package/lib/utils/objects/toCamelCase.js +36 -11
- package/lib/utils/objects/toCamelCase.js.map +1 -1
- package/lib/utils/objects/toSnakeCase.js +36 -11
- package/lib/utils/objects/toSnakeCase.js.map +1 -1
- package/lib/utils/pagination/formatPaginatedDataFromServer.js +265 -14
- package/lib/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
- package/lib/utils/pagination/index.js +51 -10
- package/lib/utils/pagination/index.js.map +1 -1
- package/lib/utils/url/index.js +44 -7
- package/lib/utils/url/index.js.map +1 -1
- package/lib/utils/url/stringifyParams.js +172 -18
- package/lib/utils/url/stringifyParams.js.map +1 -1
- package/package.json +32 -36
- package/src/bus/channels.js +6 -6
- package/src/bus/channels.spec.js +1 -1
- package/src/coordinator/applications.js +7 -7
- package/src/coordinator/applications.spec.js +1 -1
- package/src/coordinator/consent.js +3 -3
- package/src/coordinator/edgeNodes.js +3 -3
- package/src/coordinator/edgeNodes.spec.js +1 -1
- package/src/coordinator/organizations.js +4 -4
- package/src/coordinator/organizations.spec.js +1 -1
- package/src/coordinator/permissions.js +6 -6
- package/src/coordinator/permissions.spec.js +1 -1
- package/src/coordinator/roles.js +9 -9
- package/src/coordinator/roles.spec.js +1 -1
- package/src/coordinator/users.js +13 -13
- package/src/coordinator/users.spec.js +294 -294
- package/src/events/index.js +18 -18
- package/src/events/index.spec.js +3 -3
- package/src/files/index.js +9 -9
- package/src/files/index.spec.js +2 -2
- package/src/index.js +3 -1
- package/src/iot/feedTypes.js +2 -2
- package/src/iot/feeds.js +4 -4
- package/src/iot/feeds.spec.js +1 -1
- package/src/iot/fieldCategories.js +10 -10
- package/src/iot/fieldCategories.spec.js +2 -2
- package/src/iot/fieldGroupings.js +10 -10
- package/src/iot/fieldGroupings.spec.js +2 -2
- package/src/iot/fields.js +2 -2
- package/src/iot/fields.spec.js +1 -1
- package/src/iot/outputs.js +2 -2
- package/src/iot/outputs.spec.js +1 -1
- package/src/sessionTypes/auth0WebAuth.spec.js +1 -1
- package/src/utils/events/index.js +2 -1
- package/src/utils/iot/formatOutputFieldDataFromServer.js +5 -5
- package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +2 -2
- package/src/utils/iot/index.js +2 -1
- package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.js +3 -1
- package/src/utils/objects/index.js +2 -1
- package/src/utils/pagination/formatPaginatedDataFromServer.js +3 -3
- package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +1 -1
- package/src/utils/pagination/index.js +2 -1
- package/support/mocharc.yml +1 -1
- package/.eslintrc +0 -24
package/src/events/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import has from 'lodash.has';
|
|
2
2
|
import isPlainObject from 'lodash.isplainobject';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import EventUtils from '../utils/events';
|
|
4
|
+
import ObjectUtils from '../utils/objects';
|
|
5
|
+
import PaginationUtils from '../utils/pagination';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {Object} Event
|
|
@@ -189,8 +189,8 @@ class Events {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
return this._request
|
|
192
|
-
.post(`${this._baseUrl}/events`, toSnakeCase(event))
|
|
193
|
-
.then((response) => toCamelCase(response));
|
|
192
|
+
.post(`${this._baseUrl}/events`, ObjectUtils.toSnakeCase(event))
|
|
193
|
+
.then((response) => ObjectUtils.toCamelCase(response));
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/**
|
|
@@ -247,7 +247,7 @@ class Events {
|
|
|
247
247
|
|
|
248
248
|
return this._request
|
|
249
249
|
.get(`${this._baseUrl}/events/${eventId}`)
|
|
250
|
-
.then((event) => toCamelCase(event));
|
|
250
|
+
.then((event) => ObjectUtils.toCamelCase(event));
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
/**
|
|
@@ -278,9 +278,9 @@ class Events {
|
|
|
278
278
|
|
|
279
279
|
return this._request
|
|
280
280
|
.get(`${this._baseUrl}/clients/${clientId}/types`, {
|
|
281
|
-
params: toSnakeCase(paginationOptions)
|
|
281
|
+
params: ObjectUtils.toSnakeCase(paginationOptions)
|
|
282
282
|
})
|
|
283
|
-
.then((response) => formatPaginatedDataFromServer(response));
|
|
283
|
+
.then((response) => PaginationUtils.formatPaginatedDataFromServer(response));
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
/**
|
|
@@ -322,9 +322,9 @@ class Events {
|
|
|
322
322
|
|
|
323
323
|
return this._request
|
|
324
324
|
.get(`${this._baseUrl}/types/${eventTypeId}/events`, {
|
|
325
|
-
params: toSnakeCase(eventFilters)
|
|
325
|
+
params: ObjectUtils.toSnakeCase(eventFilters)
|
|
326
326
|
})
|
|
327
|
-
.then((events) => formatPaginatedDataFromServer(events));
|
|
327
|
+
.then((events) => PaginationUtils.formatPaginatedDataFromServer(events));
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
/**
|
|
@@ -351,12 +351,12 @@ class Events {
|
|
|
351
351
|
|
|
352
352
|
return this._request
|
|
353
353
|
.get(`${this._baseUrl}/facilities/${facilityId}/triggered-events`, {
|
|
354
|
-
params: toSnakeCase(triggeredEventFilters, {
|
|
354
|
+
params: ObjectUtils.toSnakeCase(triggeredEventFilters, {
|
|
355
355
|
deep: true,
|
|
356
356
|
excludeTransform: ['orderBy', 'reverseOrder']
|
|
357
357
|
})
|
|
358
358
|
})
|
|
359
|
-
.then((events) => formatPaginatedDataFromServer(events));
|
|
359
|
+
.then((events) => PaginationUtils.formatPaginatedDataFromServer(events));
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
/**
|
|
@@ -386,7 +386,7 @@ class Events {
|
|
|
386
386
|
|
|
387
387
|
return this._request
|
|
388
388
|
.get(`${this._baseUrl}/users/${userId}`)
|
|
389
|
-
.then((user) => toCamelCase(user));
|
|
389
|
+
.then((user) => ObjectUtils.toCamelCase(user));
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
/**
|
|
@@ -425,9 +425,9 @@ class Events {
|
|
|
425
425
|
return this._request
|
|
426
426
|
.post(
|
|
427
427
|
`${this._baseUrl}/users/${userId}/events/${eventId}`,
|
|
428
|
-
toSnakeCase(subscribeOpts)
|
|
428
|
+
ObjectUtils.toSnakeCase(subscribeOpts)
|
|
429
429
|
)
|
|
430
|
-
.then((response) => toCamelCase(response));
|
|
430
|
+
.then((response) => ObjectUtils.toCamelCase(response));
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
/**
|
|
@@ -512,7 +512,7 @@ class Events {
|
|
|
512
512
|
);
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
const formattedUpdate = formatEventUpdateToServer(update);
|
|
515
|
+
const formattedUpdate = EventUtils.formatEventUpdateToServer(update);
|
|
516
516
|
|
|
517
517
|
return this._request.put(
|
|
518
518
|
`${this._baseUrl}/events/${eventId}`,
|
|
@@ -574,8 +574,8 @@ class Events {
|
|
|
574
574
|
}
|
|
575
575
|
|
|
576
576
|
return this._request
|
|
577
|
-
.post(`${this._baseUrl}/types`, toSnakeCase(eventType))
|
|
578
|
-
.then((response) => toCamelCase(response));
|
|
577
|
+
.post(`${this._baseUrl}/types`, ObjectUtils.toSnakeCase(eventType))
|
|
578
|
+
.then((response) => ObjectUtils.toCamelCase(response));
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
|
package/src/events/index.spec.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import omit from 'lodash.omit';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import eventsUtils from '../utils/events';
|
|
3
|
+
import objectUtils from '../utils/objects';
|
|
4
|
+
import paginationUtils from '../utils/pagination';
|
|
5
5
|
import Events from './index';
|
|
6
6
|
|
|
7
7
|
describe('Events', function() {
|
package/src/files/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import ObjectUtils from '../utils/objects';
|
|
3
|
+
import PaginationUtils from '../utils/pagination';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} File
|
|
@@ -142,11 +142,11 @@ class Files {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
return this._request
|
|
145
|
-
.post(`${this._baseUrl}/files`, toSnakeCase(fileInfo))
|
|
145
|
+
.post(`${this._baseUrl}/files`, ObjectUtils.toSnakeCase(fileInfo))
|
|
146
146
|
.then(({ upload_info, ...createdFile }) => {
|
|
147
147
|
return {
|
|
148
|
-
...toCamelCase(createdFile),
|
|
149
|
-
uploadInfo: toCamelCase(upload_info, {
|
|
148
|
+
...ObjectUtils.toCamelCase(createdFile),
|
|
149
|
+
uploadInfo: ObjectUtils.toCamelCase(upload_info, {
|
|
150
150
|
deep: false,
|
|
151
151
|
excludeTransform: ['headers']
|
|
152
152
|
})
|
|
@@ -321,7 +321,7 @@ class Files {
|
|
|
321
321
|
|
|
322
322
|
return this._request
|
|
323
323
|
.get(`${this._baseUrl}/files/${fileId}/download`)
|
|
324
|
-
.then((file) => toCamelCase(file));
|
|
324
|
+
.then((file) => ObjectUtils.toCamelCase(file));
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
/**
|
|
@@ -351,7 +351,7 @@ class Files {
|
|
|
351
351
|
|
|
352
352
|
return this._request
|
|
353
353
|
.get(`${this._baseUrl}/files/${fileId}`)
|
|
354
|
-
.then((file) => toCamelCase(file));
|
|
354
|
+
.then((file) => ObjectUtils.toCamelCase(file));
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
/**
|
|
@@ -381,9 +381,9 @@ class Files {
|
|
|
381
381
|
getAll(filesFilters) {
|
|
382
382
|
return this._request
|
|
383
383
|
.get(`${this._baseUrl}/files`, {
|
|
384
|
-
params: toSnakeCase(filesFilters)
|
|
384
|
+
params: ObjectUtils.toSnakeCase(filesFilters)
|
|
385
385
|
})
|
|
386
|
-
.then((assetsData) => formatPaginatedDataFromServer(assetsData));
|
|
386
|
+
.then((assetsData) => PaginationUtils.formatPaginatedDataFromServer(assetsData));
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
/**
|
package/src/files/index.spec.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import omit from 'lodash.omit';
|
|
3
3
|
import pick from 'lodash.pick';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import objectUtils from '../utils/objects';
|
|
5
|
+
import paginationUtils from '../utils/pagination';
|
|
6
6
|
import Files from './index';
|
|
7
7
|
|
|
8
8
|
describe('Files', function() {
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import Iot from './iot';
|
|
|
7
7
|
import Nionic from './nionic';
|
|
8
8
|
import Request from './request';
|
|
9
9
|
import * as sessionTypes from './sessionTypes';
|
|
10
|
-
import
|
|
10
|
+
import ObjectUtils from './utils/objects';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* An adapter that allows the SDK to authenticate with different services and manage various tokens.
|
|
@@ -197,5 +197,7 @@ class ContxtSdk {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
const { toSnakeCase, toCamelCase } = ObjectUtils
|
|
201
|
+
|
|
200
202
|
export default ContxtSdk;
|
|
201
203
|
export { toSnakeCase, toCamelCase };
|
package/src/iot/feedTypes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectUtils from '../utils/objects';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {Object} FeedType
|
|
@@ -48,7 +48,7 @@ class FeedTypes {
|
|
|
48
48
|
getAll() {
|
|
49
49
|
return this._request
|
|
50
50
|
.get(`${this._baseUrl}/feeds/types`)
|
|
51
|
-
.then((feedTypes) => toCamelCase(feedTypes));
|
|
51
|
+
.then((feedTypes) => ObjectUtils.toCamelCase(feedTypes));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
package/src/iot/feeds.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectUtils from '../utils/objects';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {Object} Feed
|
|
@@ -111,9 +111,9 @@ class Feeds {
|
|
|
111
111
|
|
|
112
112
|
return this._request
|
|
113
113
|
.get(`${this._baseUrl}/feeds`, {
|
|
114
|
-
params: toSnakeCase({ facilityId })
|
|
114
|
+
params: ObjectUtils.toSnakeCase({ facilityId })
|
|
115
115
|
})
|
|
116
|
-
.then((response) => toCamelCase(response));
|
|
116
|
+
.then((response) => ObjectUtils.toCamelCase(response));
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
@@ -143,7 +143,7 @@ class Feeds {
|
|
|
143
143
|
|
|
144
144
|
return this._request
|
|
145
145
|
.get(`${this._baseUrl}/facilities/${facilityId}/status`)
|
|
146
|
-
.then((response) => toCamelCase(response));
|
|
146
|
+
.then((response) => ObjectUtils.toCamelCase(response));
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
package/src/iot/feeds.spec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isPlainObject from 'lodash.isplainobject';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import ObjectUtils from '../utils/objects';
|
|
3
|
+
import PaginationUtils from '../utils/pagination';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} FieldCategory
|
|
@@ -77,11 +77,11 @@ class FieldCategories {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const formattedCategory = toSnakeCase(fieldCategory);
|
|
80
|
+
const formattedCategory = ObjectUtils.toSnakeCase(fieldCategory);
|
|
81
81
|
|
|
82
82
|
return this._request
|
|
83
83
|
.post(`${this._baseUrl}/categories`, formattedCategory)
|
|
84
|
-
.then((fieldCategory) => toCamelCase(fieldCategory));
|
|
84
|
+
.then((fieldCategory) => ObjectUtils.toCamelCase(fieldCategory));
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
@@ -139,7 +139,7 @@ class FieldCategories {
|
|
|
139
139
|
|
|
140
140
|
return this._request
|
|
141
141
|
.get(`${this._baseUrl}/categories/${categoryId}`)
|
|
142
|
-
.then((fieldCategory) => toCamelCase(fieldCategory));
|
|
142
|
+
.then((fieldCategory) => ObjectUtils.toCamelCase(fieldCategory));
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
@@ -163,10 +163,10 @@ class FieldCategories {
|
|
|
163
163
|
getAll(paginationOptions) {
|
|
164
164
|
return this._request
|
|
165
165
|
.get(`${this._baseUrl}/categories`, {
|
|
166
|
-
params: toSnakeCase(paginationOptions)
|
|
166
|
+
params: ObjectUtils.toSnakeCase(paginationOptions)
|
|
167
167
|
})
|
|
168
168
|
.then((fieldCategories) =>
|
|
169
|
-
formatPaginatedDataFromServer(fieldCategories)
|
|
169
|
+
PaginationUtils.formatPaginatedDataFromServer(fieldCategories)
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -199,7 +199,7 @@ class FieldCategories {
|
|
|
199
199
|
|
|
200
200
|
return this._request
|
|
201
201
|
.get(`${this._baseUrl}/facilities/${facilityId}/categories`)
|
|
202
|
-
.then((fieldCategories) => toCamelCase(fieldCategories));
|
|
202
|
+
.then((fieldCategories) => ObjectUtils.toCamelCase(fieldCategories));
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/**
|
|
@@ -251,13 +251,13 @@ class FieldCategories {
|
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
const formattedUpdate = toSnakeCase(update, {
|
|
254
|
+
const formattedUpdate = ObjectUtils.toSnakeCase(update, {
|
|
255
255
|
excludeKeys: ['id', 'organizationId']
|
|
256
256
|
});
|
|
257
257
|
|
|
258
258
|
return this._request
|
|
259
259
|
.put(`${this._baseUrl}/categories/${categoryId}`, formattedUpdate)
|
|
260
|
-
.then((fieldCategory) => toCamelCase(fieldCategory));
|
|
260
|
+
.then((fieldCategory) => ObjectUtils.toCamelCase(fieldCategory));
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import omit from 'lodash.omit';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import objectUtils from '../utils/objects';
|
|
3
|
+
import paginationUtils from '../utils/pagination';
|
|
4
4
|
import FieldCategories from './fieldCategories';
|
|
5
5
|
|
|
6
6
|
describe('Iot/FieldCategories', function() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isPlainObject from 'lodash.isplainobject';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import ObjectUtils from '../utils/objects';
|
|
3
|
+
import PaginationUtils from '../utils/pagination';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} FieldGrouping
|
|
@@ -88,7 +88,7 @@ class FieldGroupings {
|
|
|
88
88
|
.post(
|
|
89
89
|
`${this._baseUrl}/groupings/${fieldGroupingId}/fields/${outputFieldId}`
|
|
90
90
|
)
|
|
91
|
-
.then((grouping) => toCamelCase(grouping));
|
|
91
|
+
.then((grouping) => ObjectUtils.toCamelCase(grouping));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -137,14 +137,14 @@ class FieldGroupings {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const formattedGrouping = toSnakeCase(fieldGrouping);
|
|
140
|
+
const formattedGrouping = ObjectUtils.toSnakeCase(fieldGrouping);
|
|
141
141
|
|
|
142
142
|
return this._request
|
|
143
143
|
.post(
|
|
144
144
|
`${this._baseUrl}/facilities/${facilityId}/groupings`,
|
|
145
145
|
formattedGrouping
|
|
146
146
|
)
|
|
147
|
-
.then((fieldGrouping) => toCamelCase(fieldGrouping));
|
|
147
|
+
.then((fieldGrouping) => ObjectUtils.toCamelCase(fieldGrouping));
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/**
|
|
@@ -202,7 +202,7 @@ class FieldGroupings {
|
|
|
202
202
|
|
|
203
203
|
return this._request
|
|
204
204
|
.get(`${this._baseUrl}/groupings/${groupingId}`)
|
|
205
|
-
.then((fieldGrouping) => toCamelCase(fieldGrouping));
|
|
205
|
+
.then((fieldGrouping) => ObjectUtils.toCamelCase(fieldGrouping));
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
@@ -234,9 +234,9 @@ class FieldGroupings {
|
|
|
234
234
|
|
|
235
235
|
return this._request
|
|
236
236
|
.get(`${this._baseUrl}/facilities/${facilityId}/groupings`, {
|
|
237
|
-
params: toSnakeCase(paginationOptions)
|
|
237
|
+
params: ObjectUtils.toSnakeCase(paginationOptions)
|
|
238
238
|
})
|
|
239
|
-
.then((fieldGrouping) => formatPaginatedDataFromServer(fieldGrouping));
|
|
239
|
+
.then((fieldGrouping) => PaginationUtils.formatPaginatedDataFromServer(fieldGrouping));
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -327,13 +327,13 @@ class FieldGroupings {
|
|
|
327
327
|
);
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
const formattedUpdate = toSnakeCase(update, {
|
|
330
|
+
const formattedUpdate = ObjectUtils.toSnakeCase(update, {
|
|
331
331
|
excludeKeys: ['facilityId', 'id', 'ownerId', 'slug']
|
|
332
332
|
});
|
|
333
333
|
|
|
334
334
|
return this._request
|
|
335
335
|
.put(`${this._baseUrl}/groupings/${groupingId}`, formattedUpdate)
|
|
336
|
-
.then((fieldGrouping) => toCamelCase(fieldGrouping));
|
|
336
|
+
.then((fieldGrouping) => ObjectUtils.toCamelCase(fieldGrouping));
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import omit from 'lodash.omit';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import objectUtils from '../utils/objects';
|
|
3
|
+
import paginationUtils from '../utils/pagination';
|
|
4
4
|
import FieldGroupings from './fieldGroupings';
|
|
5
5
|
|
|
6
6
|
describe('Iot/FieldGroupings', function() {
|
package/src/iot/fields.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectUtils from '../utils/objects';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {Object} OutputField
|
|
@@ -70,7 +70,7 @@ class Fields {
|
|
|
70
70
|
|
|
71
71
|
return this._request
|
|
72
72
|
.get(`${this._baseUrl}/fields/${outputFieldId}`)
|
|
73
|
-
.then((outputField) => toCamelCase(outputField));
|
|
73
|
+
.then((outputField) => ObjectUtils.toCamelCase(outputField));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
package/src/iot/fields.spec.js
CHANGED
package/src/iot/outputs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import IotUtils from '../utils/iot';
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {Object} OutputFieldDataResponse
|
|
4
4
|
* @property {Object} meta
|
|
@@ -98,7 +98,7 @@ class Outputs {
|
|
|
98
98
|
`${this._baseUrl}/outputs/${outputId}/fields/${fieldHumanName}/data`,
|
|
99
99
|
{ params: options }
|
|
100
100
|
)
|
|
101
|
-
.then((fieldData) => formatOutputFieldDataFromServer(fieldData));
|
|
101
|
+
.then((fieldData) => IotUtils.formatOutputFieldDataFromServer(fieldData));
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
package/src/iot/outputs.spec.js
CHANGED
|
@@ -185,7 +185,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
|
|
|
185
185
|
isAuthenticated.restore();
|
|
186
186
|
sinon.stub(Auth0WebAuth.prototype, 'isAuthenticated').returns(false);
|
|
187
187
|
|
|
188
|
-
const auth0WebAuth = new Auth0WebAuth(sdk);
|
|
188
|
+
const auth0WebAuth = new Auth0WebAuth(sdk);
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
it('does not schedule a future token renewal', function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import IotUtils from './index';
|
|
2
|
+
import ObjectUtils from '../objects';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Normalizes the output field data and metadata returned from the API server
|
|
@@ -38,15 +38,15 @@ import { toCamelCase } from '../objects';
|
|
|
38
38
|
*/
|
|
39
39
|
function formatOutputFieldDataFromServer(input = {}) {
|
|
40
40
|
const meta = input.meta || {};
|
|
41
|
-
const query = parseOutputFieldNextPageUrlMetadata(meta.next_page_url);
|
|
41
|
+
const query = IotUtils.parseOutputFieldNextPageUrlMetadata(meta.next_page_url);
|
|
42
42
|
const records = input.records || [];
|
|
43
43
|
|
|
44
44
|
return {
|
|
45
45
|
meta: {
|
|
46
|
-
...toCamelCase(input.meta, { excludeKeys: ['next_page_url'] }),
|
|
46
|
+
...ObjectUtils.toCamelCase(input.meta, { excludeKeys: ['next_page_url'] }),
|
|
47
47
|
...query
|
|
48
48
|
},
|
|
49
|
-
records: toCamelCase(records)
|
|
49
|
+
records: ObjectUtils.toCamelCase(records)
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import omit from 'lodash.omit';
|
|
2
2
|
import URL from 'url-parse';
|
|
3
|
-
import
|
|
3
|
+
import objectUtils from '../objects';
|
|
4
4
|
import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer';
|
|
5
|
-
import
|
|
5
|
+
import iotUtils from './index';
|
|
6
6
|
|
|
7
7
|
describe('utils/iot/formatOutputFieldDataFromServer', function() {
|
|
8
8
|
let expectedOutputFieldDataRecords;
|
package/src/utils/iot/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer';
|
|
2
2
|
import parseOutputFieldNextPageUrlMetadata from './parseOutputFieldNextPageUrlMetadata';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const IotUtils = { formatOutputFieldDataFromServer, parseOutputFieldNextPageUrlMetadata }
|
|
5
|
+
export default IotUtils;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import URL from 'url-parse';
|
|
2
2
|
|
|
3
|
+
const allowedQueryParams = ['after', 'limit', 'timeEnd', 'timeStart', 'window'];
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Parses metadata from the provided url. Will coerce fields that should be
|
|
5
7
|
* numbers from `String` to `Number`
|
|
@@ -21,7 +23,7 @@ import URL from 'url-parse';
|
|
|
21
23
|
function parseOutputFieldNextPageUrlMetadata(url) {
|
|
22
24
|
const query = new URL(url, true).query;
|
|
23
25
|
|
|
24
|
-
return
|
|
26
|
+
return allowedQueryParams.reduce((memo, key) => {
|
|
25
27
|
if (memo[key]) {
|
|
26
28
|
memo[key] = parseInt(memo[key], 10);
|
|
27
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectUtils from '../objects';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Default formatter. Returns the original value in case no formatter is
|
|
@@ -11,7 +11,7 @@ import { toCamelCase } from '../objects';
|
|
|
11
11
|
* @private
|
|
12
12
|
*/
|
|
13
13
|
function defaultFormatter(value) {
|
|
14
|
-
return toCamelCase(value);
|
|
14
|
+
return ObjectUtils.toCamelCase(value);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -38,7 +38,7 @@ function formatPaginatedDataFromServer(
|
|
|
38
38
|
const records = input.records || [];
|
|
39
39
|
|
|
40
40
|
return {
|
|
41
|
-
_metadata: toCamelCase(_metadata),
|
|
41
|
+
_metadata: ObjectUtils.toCamelCase(_metadata),
|
|
42
42
|
records: records.map(recordFormatter)
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import times from 'lodash.times';
|
|
2
|
-
import
|
|
2
|
+
import objectUtils from '../objects';
|
|
3
3
|
import formatPaginatedDataFromServer from './formatPaginatedDataFromServer';
|
|
4
4
|
|
|
5
5
|
describe('utils/pagination/formatPaginatedDataFromServer', function() {
|
package/support/mocharc.yml
CHANGED
package/.eslintrc
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es6": true,
|
|
5
|
-
"mocha": true,
|
|
6
|
-
"node": true
|
|
7
|
-
},
|
|
8
|
-
"extends": ["ndustrial", "prettier"],
|
|
9
|
-
"parser": "babel-eslint",
|
|
10
|
-
"parserOptions": {
|
|
11
|
-
"ecmaVersion": 6,
|
|
12
|
-
"sourceType": "module"
|
|
13
|
-
},
|
|
14
|
-
"globals": {
|
|
15
|
-
"expect": true,
|
|
16
|
-
"faker": true,
|
|
17
|
-
"fixture": true,
|
|
18
|
-
"sinon": true
|
|
19
|
-
},
|
|
20
|
-
"plugins": [],
|
|
21
|
-
"rules": {
|
|
22
|
-
"no-unused-expressions": "off"
|
|
23
|
-
}
|
|
24
|
-
}
|