@ndustrial/contxt-sdk 5.5.7 → 5.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 (230) hide show
  1. package/.nvmrc +1 -1
  2. package/eslint.config.mjs +44 -0
  3. package/esm/bus/channels.js +1883 -216
  4. package/esm/bus/channels.js.map +1 -1
  5. package/esm/bus/index.browser.js +218 -37
  6. package/esm/bus/index.browser.js.map +1 -1
  7. package/esm/bus/index.js +906 -94
  8. package/esm/bus/index.js.map +1 -1
  9. package/esm/bus/webSocketConnection.browser.js +86 -12
  10. package/esm/bus/webSocketConnection.browser.js.map +1 -1
  11. package/esm/bus/webSocketConnection.js +2464 -332
  12. package/esm/bus/webSocketConnection.js.map +1 -1
  13. package/esm/config/audiences.js +37 -1
  14. package/esm/config/audiences.js.map +1 -1
  15. package/esm/config/defaults.js +37 -1
  16. package/esm/config/defaults.js.map +1 -1
  17. package/esm/config/index.js +1622 -203
  18. package/esm/config/index.js.map +1 -1
  19. package/esm/coordinator/applications.js +1019 -172
  20. package/esm/coordinator/applications.js.map +1 -1
  21. package/esm/coordinator/consent.js +603 -76
  22. package/esm/coordinator/consent.js.map +1 -1
  23. package/esm/coordinator/edgeNodes.js +520 -40
  24. package/esm/coordinator/edgeNodes.js.map +1 -1
  25. package/esm/coordinator/index.js +811 -54
  26. package/esm/coordinator/index.js.map +1 -1
  27. package/esm/coordinator/organizations.js +533 -60
  28. package/esm/coordinator/organizations.js.map +1 -1
  29. package/esm/coordinator/permissions.js +914 -107
  30. package/esm/coordinator/permissions.js.map +1 -1
  31. package/esm/coordinator/roles.js +2146 -258
  32. package/esm/coordinator/roles.js.map +1 -1
  33. package/esm/coordinator/users.js +3393 -484
  34. package/esm/coordinator/users.js.map +1 -1
  35. package/esm/events/index.js +2301 -393
  36. package/esm/events/index.js.map +1 -1
  37. package/esm/files/index.js +2053 -410
  38. package/esm/files/index.js.map +1 -1
  39. package/esm/index.js +1002 -148
  40. package/esm/index.js.map +1 -1
  41. package/esm/iot/feedTypes.js +188 -25
  42. package/esm/iot/feedTypes.js.map +1 -1
  43. package/esm/iot/feeds.js +420 -59
  44. package/esm/iot/feeds.js.map +1 -1
  45. package/esm/iot/fieldCategories.js +1172 -195
  46. package/esm/iot/fieldCategories.js.map +1 -1
  47. package/esm/iot/fieldGroupings.js +1689 -255
  48. package/esm/iot/fieldGroupings.js.map +1 -1
  49. package/esm/iot/fields.js +254 -28
  50. package/esm/iot/fields.js.map +1 -1
  51. package/esm/iot/index.js +212 -34
  52. package/esm/iot/index.js.map +1 -1
  53. package/esm/iot/outputs.js +320 -31
  54. package/esm/iot/outputs.js.map +1 -1
  55. package/esm/nionic/index.js +1097 -97
  56. package/esm/nionic/index.js.map +1 -1
  57. package/esm/request.js +1313 -219
  58. package/esm/request.js.map +1 -1
  59. package/esm/sessionTypes/auth0WebAuth.js +3395 -409
  60. package/esm/sessionTypes/auth0WebAuth.js.map +1 -1
  61. package/esm/sessionTypes/index.js +213 -22
  62. package/esm/sessionTypes/index.js.map +1 -1
  63. package/esm/sessionTypes/machineAuth.js +1314 -144
  64. package/esm/sessionTypes/machineAuth.js.map +1 -1
  65. package/esm/sessionTypes/passwordGrantAuth.js +1060 -145
  66. package/esm/sessionTypes/passwordGrantAuth.js.map +1 -1
  67. package/esm/utils/events/formatEventUpdateToServer.js +107 -4
  68. package/esm/utils/events/formatEventUpdateToServer.js.map +1 -1
  69. package/esm/utils/events/index.js +54 -2
  70. package/esm/utils/events/index.js.map +1 -1
  71. package/esm/utils/iot/formatOutputFieldDataFromServer.js +227 -14
  72. package/esm/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
  73. package/esm/utils/iot/index.js +56 -3
  74. package/esm/utils/iot/index.js.map +1 -1
  75. package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js +207 -7
  76. package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
  77. package/esm/utils/objects/createCaseChangeFn.js +449 -18
  78. package/esm/utils/objects/createCaseChangeFn.js.map +1 -1
  79. package/esm/utils/objects/index.js +56 -3
  80. package/esm/utils/objects/index.js.map +1 -1
  81. package/esm/utils/objects/map.js +520 -26
  82. package/esm/utils/objects/map.js.map +1 -1
  83. package/esm/utils/objects/toCamelCase.js +39 -3
  84. package/esm/utils/objects/toCamelCase.js.map +1 -1
  85. package/esm/utils/objects/toSnakeCase.js +39 -3
  86. package/esm/utils/objects/toSnakeCase.js.map +1 -1
  87. package/esm/utils/pagination/formatPaginatedDataFromServer.js +268 -11
  88. package/esm/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
  89. package/esm/utils/pagination/index.js +54 -2
  90. package/esm/utils/pagination/index.js.map +1 -1
  91. package/esm/utils/url/index.js +47 -2
  92. package/esm/utils/url/index.js.map +1 -1
  93. package/esm/utils/url/stringifyParams.js +176 -10
  94. package/esm/utils/url/stringifyParams.js.map +1 -1
  95. package/lib/bus/channels.js +1880 -223
  96. package/lib/bus/channels.js.map +1 -1
  97. package/lib/bus/index.browser.js +215 -43
  98. package/lib/bus/index.browser.js.map +1 -1
  99. package/lib/bus/index.js +903 -106
  100. package/lib/bus/index.js.map +1 -1
  101. package/lib/bus/webSocketConnection.browser.js +83 -15
  102. package/lib/bus/webSocketConnection.browser.js.map +1 -1
  103. package/lib/bus/webSocketConnection.js +2461 -339
  104. package/lib/bus/webSocketConnection.js.map +1 -1
  105. package/lib/config/audiences.js +33 -2
  106. package/lib/config/audiences.js.map +1 -1
  107. package/lib/config/defaults.js +33 -2
  108. package/lib/config/defaults.js.map +1 -1
  109. package/lib/config/index.js +1619 -212
  110. package/lib/config/index.js.map +1 -1
  111. package/lib/coordinator/applications.js +1016 -174
  112. package/lib/coordinator/applications.js.map +1 -1
  113. package/lib/coordinator/consent.js +600 -78
  114. package/lib/coordinator/consent.js.map +1 -1
  115. package/lib/coordinator/edgeNodes.js +517 -42
  116. package/lib/coordinator/edgeNodes.js.map +1 -1
  117. package/lib/coordinator/index.js +808 -78
  118. package/lib/coordinator/index.js.map +1 -1
  119. package/lib/coordinator/organizations.js +530 -62
  120. package/lib/coordinator/organizations.js.map +1 -1
  121. package/lib/coordinator/permissions.js +911 -109
  122. package/lib/coordinator/permissions.js.map +1 -1
  123. package/lib/coordinator/roles.js +2143 -260
  124. package/lib/coordinator/roles.js.map +1 -1
  125. package/lib/coordinator/users.js +3389 -489
  126. package/lib/coordinator/users.js.map +1 -1
  127. package/lib/events/index.js +2297 -404
  128. package/lib/events/index.js.map +1 -1
  129. package/lib/files/index.js +2050 -418
  130. package/lib/files/index.js.map +1 -1
  131. package/lib/index.js +999 -183
  132. package/lib/index.js.map +1 -1
  133. package/lib/iot/feedTypes.js +185 -27
  134. package/lib/iot/feedTypes.js.map +1 -1
  135. package/lib/iot/feeds.js +417 -61
  136. package/lib/iot/feeds.js.map +1 -1
  137. package/lib/iot/fieldCategories.js +1169 -203
  138. package/lib/iot/fieldCategories.js.map +1 -1
  139. package/lib/iot/fieldGroupings.js +1686 -263
  140. package/lib/iot/fieldGroupings.js.map +1 -1
  141. package/lib/iot/fields.js +251 -30
  142. package/lib/iot/fields.js.map +1 -1
  143. package/lib/iot/index.js +209 -55
  144. package/lib/iot/index.js.map +1 -1
  145. package/lib/iot/outputs.js +317 -34
  146. package/lib/iot/outputs.js.map +1 -1
  147. package/lib/nionic/index.js +1094 -98
  148. package/lib/nionic/index.js.map +1 -1
  149. package/lib/request.js +1310 -226
  150. package/lib/request.js.map +1 -1
  151. package/lib/sessionTypes/auth0WebAuth.js +3391 -421
  152. package/lib/sessionTypes/auth0WebAuth.js.map +1 -1
  153. package/lib/sessionTypes/index.js +209 -26
  154. package/lib/sessionTypes/index.js.map +1 -1
  155. package/lib/sessionTypes/machineAuth.js +1311 -151
  156. package/lib/sessionTypes/machineAuth.js.map +1 -1
  157. package/lib/sessionTypes/passwordGrantAuth.js +1057 -156
  158. package/lib/sessionTypes/passwordGrantAuth.js.map +1 -1
  159. package/lib/utils/events/formatEventUpdateToServer.js +102 -4
  160. package/lib/utils/events/formatEventUpdateToServer.js.map +1 -1
  161. package/lib/utils/events/index.js +51 -10
  162. package/lib/utils/events/index.js.map +1 -1
  163. package/lib/utils/iot/formatOutputFieldDataFromServer.js +224 -18
  164. package/lib/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
  165. package/lib/utils/iot/index.js +53 -15
  166. package/lib/utils/iot/index.js.map +1 -1
  167. package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js +203 -13
  168. package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
  169. package/lib/utils/objects/createCaseChangeFn.js +446 -25
  170. package/lib/utils/objects/createCaseChangeFn.js.map +1 -1
  171. package/lib/utils/objects/index.js +53 -15
  172. package/lib/utils/objects/index.js.map +1 -1
  173. package/lib/utils/objects/map.js +517 -33
  174. package/lib/utils/objects/map.js.map +1 -1
  175. package/lib/utils/objects/toCamelCase.js +36 -11
  176. package/lib/utils/objects/toCamelCase.js.map +1 -1
  177. package/lib/utils/objects/toSnakeCase.js +36 -11
  178. package/lib/utils/objects/toSnakeCase.js.map +1 -1
  179. package/lib/utils/pagination/formatPaginatedDataFromServer.js +265 -14
  180. package/lib/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
  181. package/lib/utils/pagination/index.js +51 -10
  182. package/lib/utils/pagination/index.js.map +1 -1
  183. package/lib/utils/url/index.js +44 -7
  184. package/lib/utils/url/index.js.map +1 -1
  185. package/lib/utils/url/stringifyParams.js +172 -18
  186. package/lib/utils/url/stringifyParams.js.map +1 -1
  187. package/package.json +31 -35
  188. package/src/bus/channels.js +6 -6
  189. package/src/bus/channels.spec.js +1 -1
  190. package/src/coordinator/applications.js +7 -7
  191. package/src/coordinator/applications.spec.js +1 -1
  192. package/src/coordinator/consent.js +3 -3
  193. package/src/coordinator/edgeNodes.js +3 -3
  194. package/src/coordinator/edgeNodes.spec.js +1 -1
  195. package/src/coordinator/organizations.js +4 -4
  196. package/src/coordinator/organizations.spec.js +1 -1
  197. package/src/coordinator/permissions.js +6 -6
  198. package/src/coordinator/permissions.spec.js +1 -1
  199. package/src/coordinator/roles.js +9 -9
  200. package/src/coordinator/roles.spec.js +1 -1
  201. package/src/coordinator/users.js +12 -12
  202. package/src/coordinator/users.spec.js +1 -1
  203. package/src/events/index.js +18 -18
  204. package/src/events/index.spec.js +3 -3
  205. package/src/files/index.js +9 -9
  206. package/src/files/index.spec.js +2 -2
  207. package/src/index.js +3 -1
  208. package/src/iot/feedTypes.js +2 -2
  209. package/src/iot/feeds.js +4 -4
  210. package/src/iot/feeds.spec.js +1 -1
  211. package/src/iot/fieldCategories.js +10 -10
  212. package/src/iot/fieldCategories.spec.js +2 -2
  213. package/src/iot/fieldGroupings.js +10 -10
  214. package/src/iot/fieldGroupings.spec.js +2 -2
  215. package/src/iot/fields.js +2 -2
  216. package/src/iot/fields.spec.js +1 -1
  217. package/src/iot/outputs.js +2 -2
  218. package/src/iot/outputs.spec.js +1 -1
  219. package/src/sessionTypes/auth0WebAuth.spec.js +1 -1
  220. package/src/utils/events/index.js +2 -1
  221. package/src/utils/iot/formatOutputFieldDataFromServer.js +5 -5
  222. package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +2 -2
  223. package/src/utils/iot/index.js +2 -1
  224. package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.js +3 -1
  225. package/src/utils/objects/index.js +2 -1
  226. package/src/utils/pagination/formatPaginatedDataFromServer.js +3 -3
  227. package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +1 -1
  228. package/src/utils/pagination/index.js +2 -1
  229. package/support/mocharc.yml +1 -1
  230. package/.eslintrc +0 -24
@@ -1,4 +1,4 @@
1
- import * as objectUtils from '../utils/objects';
1
+ import objectUtils from '../utils/objects';
2
2
  import Roles from './roles';
3
3
 
4
4
  describe('Coordinator/Roles', function() {
@@ -1,6 +1,6 @@
1
1
  import axios from 'axios';
2
2
 
3
- import { toCamelCase, toSnakeCase } from '../utils/objects';
3
+ import ObjectUtils from '../utils/objects';
4
4
 
5
5
  /**
6
6
  * @typedef {Object} ContxtUser
@@ -137,7 +137,7 @@ class Users {
137
137
  // Uses axios directly instead of this.request to bypass authorization interceptors
138
138
  return axios.post(
139
139
  `${this._getBaseUrl('access')}/users/${userId}/activate`,
140
- toSnakeCase(user)
140
+ ObjectUtils.toSnakeCase(user)
141
141
  );
142
142
  }
143
143
 
@@ -179,7 +179,7 @@ class Users {
179
179
  .post(
180
180
  `${this._getBaseUrl()}/users/${userId}/applications/${applicationId}`
181
181
  )
182
- .then((response) => toCamelCase(response));
182
+ .then((response) => ObjectUtils.toCamelCase(response));
183
183
  }
184
184
 
185
185
  /**
@@ -216,7 +216,7 @@ class Users {
216
216
 
217
217
  return this._request
218
218
  .post(`${this._getBaseUrl()}/users/${userId}/roles/${roleId}`)
219
- .then((response) => toCamelCase(response));
219
+ .then((response) => ObjectUtils.toCamelCase(response));
220
220
  }
221
221
 
222
222
  /**
@@ -271,7 +271,7 @@ class Users {
271
271
  access_type: accessType
272
272
  }
273
273
  )
274
- .then((response) => toCamelCase(response));
274
+ .then((response) => ObjectUtils.toCamelCase(response));
275
275
  }
276
276
 
277
277
  /**
@@ -301,7 +301,7 @@ class Users {
301
301
 
302
302
  return this._request
303
303
  .get(`${this._getBaseUrl('access')}/users/${userId}`)
304
- .then((user) => toCamelCase(user));
304
+ .then((user) => ObjectUtils.toCamelCase(user));
305
305
  }
306
306
 
307
307
  /**
@@ -327,7 +327,7 @@ class Users {
327
327
  if (this._organizationId) {
328
328
  return this._request
329
329
  .get(`${this._getBaseUrl()}/users`)
330
- .then((orgUsers) => toCamelCase(orgUsers));
330
+ .then((orgUsers) => ObjectUtils.toCamelCase(orgUsers));
331
331
  }
332
332
 
333
333
  if (!organizationId) {
@@ -342,7 +342,7 @@ class Users {
342
342
  .get(
343
343
  `${this._getBaseUrl('legacy')}/organizations/${organizationId}/users`
344
344
  )
345
- .then((orgUsers) => toCamelCase(orgUsers));
345
+ .then((orgUsers) => ObjectUtils.toCamelCase(orgUsers));
346
346
  }
347
347
 
348
348
  /**
@@ -395,8 +395,8 @@ class Users {
395
395
  }
396
396
 
397
397
  return this._request
398
- .post(`${this._getBaseUrl()}/users`, toSnakeCase(user))
399
- .then((response) => toCamelCase(response));
398
+ .post(`${this._getBaseUrl()}/users`, ObjectUtils.toSnakeCase(user))
399
+ .then((response) => ObjectUtils.toCamelCase(response));
400
400
  }
401
401
 
402
402
  if (!organizationId) {
@@ -420,9 +420,9 @@ class Users {
420
420
  return this._request
421
421
  .post(
422
422
  `${this._getBaseUrl('legacy')}/organizations/${organizationId}/users`,
423
- toSnakeCase(user)
423
+ ObjectUtils.toSnakeCase(user)
424
424
  )
425
- .then((response) => toCamelCase(response));
425
+ .then((response) => ObjectUtils.toCamelCase(response));
426
426
  }
427
427
 
428
428
  /**
@@ -1,7 +1,7 @@
1
1
  import axios from 'axios';
2
2
  import { expect } from 'chai';
3
3
  import omit from 'lodash.omit';
4
- import * as objectUtils from '../utils/objects';
4
+ import objectUtils from '../utils/objects';
5
5
  import Users from './users';
6
6
 
7
7
  describe('Coordinator/Users', function() {
@@ -1,8 +1,8 @@
1
1
  import has from 'lodash.has';
2
2
  import isPlainObject from 'lodash.isplainobject';
3
- import { formatEventUpdateToServer } from '../utils/events';
4
- import { toCamelCase, toSnakeCase } from '../utils/objects';
5
- import { formatPaginatedDataFromServer } from '../utils/pagination';
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
 
@@ -1,7 +1,7 @@
1
1
  import omit from 'lodash.omit';
2
- import * as eventsUtils from '../utils/events';
3
- import * as objectUtils from '../utils/objects';
4
- import * as paginationUtils from '../utils/pagination';
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() {
@@ -1,6 +1,6 @@
1
1
  import axios from 'axios';
2
- import { toCamelCase, toSnakeCase } from '../utils/objects';
3
- import { formatPaginatedDataFromServer } from '../utils/pagination';
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
  /**
@@ -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 * as objectUtils from '../utils/objects';
5
- import * as paginationUtils from '../utils/pagination';
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 { toSnakeCase, toCamelCase } from './utils/objects';
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 };
@@ -1,4 +1,4 @@
1
- import { toCamelCase } from '../utils/objects';
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 { toCamelCase, toSnakeCase } from '../utils/objects';
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
 
@@ -1,4 +1,4 @@
1
- import * as objectUtils from '../utils/objects';
1
+ import objectUtils from '../utils/objects';
2
2
  import Feeds from './feeds';
3
3
 
4
4
  describe('Iot/Feeds', function() {
@@ -1,6 +1,6 @@
1
1
  import isPlainObject from 'lodash.isplainobject';
2
- import { toCamelCase, toSnakeCase } from '../utils/objects';
3
- import { formatPaginatedDataFromServer } from '../utils/pagination';
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 * as objectUtils from '../utils/objects';
3
- import * as paginationUtils from '../utils/pagination';
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 { toCamelCase, toSnakeCase } from '../utils/objects';
3
- import { formatPaginatedDataFromServer } from '../utils/pagination';
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 * as objectUtils from '../utils/objects';
3
- import * as paginationUtils from '../utils/pagination';
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 { toCamelCase } from '../utils/objects';
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
 
@@ -1,5 +1,5 @@
1
1
  import Fields from './fields';
2
- import * as objectUtils from '../utils/objects';
2
+ import objectUtils from '../utils/objects';
3
3
 
4
4
  describe('Iot/Fields', function() {
5
5
  let baseRequest;
@@ -1,4 +1,4 @@
1
- import { formatOutputFieldDataFromServer } from '../utils/iot';
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
 
@@ -1,4 +1,4 @@
1
- import * as iotUtils from '../utils/iot';
1
+ import iotUtils from '../utils/iot';
2
2
  import Outputs from './outputs';
3
3
 
4
4
  describe('Iot/Outputs', function() {
@@ -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); // eslint-disable-line no-unused-vars
188
+ const auth0WebAuth = new Auth0WebAuth(sdk);
189
189
  });
190
190
 
191
191
  it('does not schedule a future token renewal', function() {
@@ -1,3 +1,4 @@
1
1
  import formatEventUpdateToServer from './formatEventUpdateToServer';
2
2
 
3
- export { formatEventUpdateToServer };
3
+ const EventUtils = { formatEventUpdateToServer };
4
+ export default EventUtils;
@@ -1,5 +1,5 @@
1
- import { parseOutputFieldNextPageUrlMetadata } from './index';
2
- import { toCamelCase } from '../objects';
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 * as objectUtils from '../objects';
3
+ import objectUtils from '../objects';
4
4
  import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer';
5
- import * as iotUtils from './index';
5
+ import iotUtils from './index';
6
6
 
7
7
  describe('utils/iot/formatOutputFieldDataFromServer', function() {
8
8
  let expectedOutputFieldDataRecords;
@@ -1,4 +1,5 @@
1
1
  import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer';
2
2
  import parseOutputFieldNextPageUrlMetadata from './parseOutputFieldNextPageUrlMetadata';
3
3
 
4
- export { formatOutputFieldDataFromServer, parseOutputFieldNextPageUrlMetadata };
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 ['limit', 'timeEnd', 'timeStart', 'window'].reduce((memo, key) => {
26
+ return allowedQueryParams.reduce((memo, key) => {
25
27
  if (memo[key]) {
26
28
  memo[key] = parseInt(memo[key], 10);
27
29
  }
@@ -1,4 +1,5 @@
1
1
  import toCamelCase from './toCamelCase';
2
2
  import toSnakeCase from './toSnakeCase';
3
3
 
4
- export { toCamelCase, toSnakeCase };
4
+ const ObjectUtils = { toCamelCase, toSnakeCase };
5
+ export default ObjectUtils