@ndustrial/contxt-sdk 4.3.6 → 5.2.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 (167) hide show
  1. package/.gitattributes +1 -0
  2. package/CHANGELOG.md +8 -0
  3. package/CODEOWNERS +1 -0
  4. package/docs/Facilities.md +0 -144
  5. package/docs/FacilityGroupings.md +0 -160
  6. package/docs/Nionic.md +63 -0
  7. package/docs/README.md +3 -29
  8. package/docs/Typedefs.md +0 -101
  9. package/esm/config/audiences.js +13 -13
  10. package/esm/config/audiences.js.map +1 -1
  11. package/esm/index.js +4 -6
  12. package/esm/index.js.map +1 -1
  13. package/esm/nionic/index.js +126 -0
  14. package/esm/nionic/index.js.map +1 -0
  15. package/lib/config/audiences.js +13 -13
  16. package/lib/config/audiences.js.map +1 -1
  17. package/lib/index.js +10 -15
  18. package/lib/index.js.map +1 -1
  19. package/lib/nionic/index.js +130 -0
  20. package/lib/nionic/index.js.map +1 -0
  21. package/meta.yaml +11 -0
  22. package/package.json +9 -10
  23. package/src/bus/index.spec.js +3 -2
  24. package/src/bus/webSocketConnection.spec.js +31 -31
  25. package/src/config/audiences.js +13 -13
  26. package/src/config/index.spec.js +6 -6
  27. package/src/coordinator/applications.spec.js +8 -8
  28. package/src/coordinator/consent.spec.js +1 -1
  29. package/src/coordinator/edgeNodes.spec.js +3 -3
  30. package/src/coordinator/organizations.spec.js +4 -4
  31. package/src/coordinator/permissions.spec.js +4 -4
  32. package/src/coordinator/roles.spec.js +3 -3
  33. package/src/coordinator/users.spec.js +14 -15
  34. package/src/events/index.spec.js +16 -16
  35. package/src/files/index.spec.js +7 -7
  36. package/src/index.js +4 -6
  37. package/src/index.spec.js +8 -22
  38. package/src/iot/feeds.spec.js +4 -4
  39. package/src/iot/fieldCategories.spec.js +4 -4
  40. package/src/iot/fieldGroupings.spec.js +5 -5
  41. package/src/iot/outputs.spec.js +6 -6
  42. package/src/nionic/index.js +151 -0
  43. package/src/request.spec.js +3 -3
  44. package/src/sessionTypes/auth0WebAuth.spec.js +2 -2
  45. package/src/sessionTypes/index.spec.js +3 -3
  46. package/src/sessionTypes/machineAuth.spec.js +3 -3
  47. package/src/sessionTypes/passwordGrantAuth.spec.js +1 -1
  48. package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +6 -6
  49. package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.spec.js +2 -2
  50. package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +2 -2
  51. package/src/utils/url/stringifyParams.spec.js +2 -3
  52. package/support/fixtures/factories/IOSDevice.js +3 -3
  53. package/support/fixtures/factories/applicationGrouping.js +4 -4
  54. package/support/fixtures/factories/applicationModule.js +2 -2
  55. package/support/fixtures/factories/asset.js +1 -1
  56. package/support/fixtures/factories/assetAttribute.js +2 -2
  57. package/support/fixtures/factories/assetAttributeValue.js +2 -2
  58. package/support/fixtures/factories/assetMetric.js +1 -1
  59. package/support/fixtures/factories/assetMetricValue.js +3 -3
  60. package/support/fixtures/factories/assetMetricValueCompact.js +2 -2
  61. package/support/fixtures/factories/assetType.js +1 -1
  62. package/support/fixtures/factories/authResults.js +3 -3
  63. package/support/fixtures/factories/channel.js +1 -1
  64. package/support/fixtures/factories/contxtApplication.js +5 -5
  65. package/support/fixtures/factories/contxtOrganization.js +2 -2
  66. package/support/fixtures/factories/contxtOrganizationFeaturedApplication.js +3 -3
  67. package/support/fixtures/factories/contxtProject.js +2 -2
  68. package/support/fixtures/factories/contxtProjectEnvironment.js +2 -2
  69. package/support/fixtures/factories/contxtRole.js +3 -3
  70. package/support/fixtures/factories/contxtRoleApplication.js +1 -1
  71. package/support/fixtures/factories/contxtRoleProjectEnvironment.js +1 -1
  72. package/support/fixtures/factories/contxtUser.js +2 -2
  73. package/support/fixtures/factories/contxtUserApplication.js +1 -1
  74. package/support/fixtures/factories/contxtUserFavoriteApplication.js +2 -2
  75. package/support/fixtures/factories/contxtUserPermissions.js +5 -5
  76. package/support/fixtures/factories/contxtUserProjectEnvironment.js +1 -1
  77. package/support/fixtures/factories/contxtUserRole.js +2 -2
  78. package/support/fixtures/factories/costCenter.js +2 -2
  79. package/support/fixtures/factories/costCenterFacility.js +3 -3
  80. package/support/fixtures/factories/edgeNode.js +1 -1
  81. package/support/fixtures/factories/event.js +5 -5
  82. package/support/fixtures/factories/eventType.js +4 -4
  83. package/support/fixtures/factories/eventUser.js +5 -5
  84. package/support/fixtures/factories/facility.js +4 -4
  85. package/support/fixtures/factories/facilityGrouping.js +3 -3
  86. package/support/fixtures/factories/facilityGroupingFacility.js +3 -3
  87. package/support/fixtures/factories/facilityInfo.js +2 -2
  88. package/support/fixtures/factories/facilityTag.js +1 -1
  89. package/support/fixtures/factories/feedStatus.js +1 -1
  90. package/support/fixtures/factories/feedType.js +1 -1
  91. package/support/fixtures/factories/feeds.js +5 -5
  92. package/support/fixtures/factories/fieldCategory.js +3 -3
  93. package/support/fixtures/factories/fieldGrouping.js +4 -4
  94. package/support/fixtures/factories/fieldGroupingField.js +3 -3
  95. package/support/fixtures/factories/fieldGroupingStatus.js +1 -1
  96. package/support/fixtures/factories/file.js +1 -1
  97. package/support/fixtures/factories/fileUploadInfo.js +1 -1
  98. package/support/fixtures/factories/organization.js +1 -1
  99. package/support/fixtures/factories/outputField.js +10 -10
  100. package/support/fixtures/factories/outputFieldData.js +1 -1
  101. package/support/fixtures/factories/owner.js +2 -2
  102. package/support/fixtures/factories/paginationMetadata.js +2 -2
  103. package/support/fixtures/factories/triggeredEvent.js +4 -4
  104. package/support/fixtures/factories/userEventSubscription.js +1 -1
  105. package/support/fixtures/factories/userMobileNumber.js +1 -1
  106. package/support/fixtures/factories/userPermissionsMap.js +2 -2
  107. package/.huskyrc.js +0 -11
  108. package/.nycrc +0 -12
  109. package/esm/assets/assetAttributes.js +0 -574
  110. package/esm/assets/assetAttributes.js.map +0 -1
  111. package/esm/assets/assetMetrics.js +0 -690
  112. package/esm/assets/assetMetrics.js.map +0 -1
  113. package/esm/assets/assetTypes.js +0 -273
  114. package/esm/assets/assetTypes.js.map +0 -1
  115. package/esm/assets/index.js +0 -283
  116. package/esm/assets/index.js.map +0 -1
  117. package/esm/facilities/costCenters.js +0 -306
  118. package/esm/facilities/costCenters.js.map +0 -1
  119. package/esm/facilities/groupings.js +0 -323
  120. package/esm/facilities/groupings.js.map +0 -1
  121. package/esm/facilities/index.js +0 -343
  122. package/esm/facilities/index.js.map +0 -1
  123. package/esm/health/index.js +0 -229
  124. package/esm/health/index.js.map +0 -1
  125. package/esm/utils/facilities/formatFacilityWithInfoFromServer.js +0 -65
  126. package/esm/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
  127. package/esm/utils/facilities/index.js +0 -4
  128. package/esm/utils/facilities/index.js.map +0 -1
  129. package/lib/assets/assetAttributes.js +0 -588
  130. package/lib/assets/assetAttributes.js.map +0 -1
  131. package/lib/assets/assetMetrics.js +0 -705
  132. package/lib/assets/assetMetrics.js.map +0 -1
  133. package/lib/assets/assetTypes.js +0 -287
  134. package/lib/assets/assetTypes.js.map +0 -1
  135. package/lib/assets/index.js +0 -302
  136. package/lib/assets/index.js.map +0 -1
  137. package/lib/facilities/costCenters.js +0 -316
  138. package/lib/facilities/costCenters.js.map +0 -1
  139. package/lib/facilities/groupings.js +0 -333
  140. package/lib/facilities/groupings.js.map +0 -1
  141. package/lib/facilities/index.js +0 -360
  142. package/lib/facilities/index.js.map +0 -1
  143. package/lib/health/index.js +0 -232
  144. package/lib/health/index.js.map +0 -1
  145. package/lib/utils/facilities/formatFacilityWithInfoFromServer.js +0 -71
  146. package/lib/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
  147. package/lib/utils/facilities/index.js +0 -15
  148. package/lib/utils/facilities/index.js.map +0 -1
  149. package/src/assets/assetAttributes.js +0 -619
  150. package/src/assets/assetAttributes.spec.js +0 -1143
  151. package/src/assets/assetMetrics.js +0 -736
  152. package/src/assets/assetMetrics.spec.js +0 -1180
  153. package/src/assets/assetTypes.js +0 -260
  154. package/src/assets/assetTypes.spec.js +0 -556
  155. package/src/assets/index.js +0 -271
  156. package/src/assets/index.spec.js +0 -515
  157. package/src/facilities/costCenters.js +0 -295
  158. package/src/facilities/costCenters.spec.js +0 -529
  159. package/src/facilities/groupings.js +0 -320
  160. package/src/facilities/groupings.spec.js +0 -567
  161. package/src/facilities/index.js +0 -343
  162. package/src/facilities/index.spec.js +0 -551
  163. package/src/health/index.js +0 -200
  164. package/src/health/index.spec.js +0 -501
  165. package/src/utils/facilities/formatFacilityWithInfoFromServer.js +0 -62
  166. package/src/utils/facilities/formatFacilityWithInfoFromServer.spec.js +0 -73
  167. package/src/utils/facilities/index.js +0 -3
@@ -1,5 +1,5 @@
1
- import EdgeNodes from './edgeNodes';
2
1
  import * as objectUtils from '../utils/objects';
2
+ import EdgeNodes from './edgeNodes';
3
3
 
4
4
  describe('edgeNodes', function() {
5
5
  let baseRequest;
@@ -143,7 +143,7 @@ describe('edgeNodes', function() {
143
143
  context('the organization ID is not provided', function() {
144
144
  it('throws an error', function() {
145
145
  const edgeNodes = new EdgeNodes(baseSdk, baseRequest);
146
- const promise = edgeNodes.get(null, faker.random.uuid());
146
+ const promise = edgeNodes.get(null, faker.datatype.uuid());
147
147
 
148
148
  return expect(promise).to.be.rejectedWith(
149
149
  'An organizationId is required for getting an edge node.'
@@ -154,7 +154,7 @@ describe('edgeNodes', function() {
154
154
  context('the edge node client ID is not provided', function() {
155
155
  it('throws an error', function() {
156
156
  const edgeNodes = new EdgeNodes(baseSdk, baseRequest);
157
- const promise = edgeNodes.get(faker.random.uuid());
157
+ const promise = edgeNodes.get(faker.datatype.uuid());
158
158
 
159
159
  return expect(promise).to.be.rejectedWith(
160
160
  'An edgeNodeClientId is required for getting an edge node.'
@@ -1,5 +1,5 @@
1
- import Organizations from './organizations';
2
1
  import * as objectUtils from '../utils/objects';
2
+ import Organizations from './organizations';
3
3
 
4
4
  describe('Coordinator/Organizations', function() {
5
5
  let baseRequest;
@@ -96,7 +96,7 @@ describe('Coordinator/Organizations', function() {
96
96
  let toCamelCase;
97
97
 
98
98
  beforeEach(function() {
99
- expectedOrganizationId = faker.random.uuid();
99
+ expectedOrganizationId = faker.datatype.uuid();
100
100
  organizationFromServerAfterFormat = fixture.build(
101
101
  'contxtOrganization',
102
102
  {
@@ -172,7 +172,7 @@ describe('Coordinator/Organizations', function() {
172
172
  let toCamelCase;
173
173
 
174
174
  beforeEach(function() {
175
- expectedOrganizationId = faker.random.uuid();
175
+ expectedOrganizationId = faker.datatype.uuid();
176
176
  organizationFromServerAfterFormat = fixture.build(
177
177
  'contxtOrganization',
178
178
  {
@@ -263,7 +263,7 @@ describe('Coordinator/Organizations', function() {
263
263
  let toCamelCase;
264
264
 
265
265
  beforeEach(function() {
266
- const numberOfOrganizations = faker.random.number({
266
+ const numberOfOrganizations = faker.datatype.number({
267
267
  min: 1,
268
268
  max: 10
269
269
  });
@@ -1,5 +1,5 @@
1
- import Permissions from './permissions';
2
1
  import * as objectUtils from '../utils/objects';
2
+ import Permissions from './permissions';
3
3
 
4
4
  describe('Coordinator/Permissions', function() {
5
5
  let baseRequest;
@@ -99,7 +99,7 @@ describe('Coordinator/Permissions', function() {
99
99
  expectedOrganizationId = fixture.build('contxtOrganization').id;
100
100
  expectedUsersPermissions = fixture.buildList(
101
101
  'contxtUserPermissions',
102
- faker.random.number({
102
+ faker.datatype.number({
103
103
  min: 1,
104
104
  max: 10
105
105
  }),
@@ -173,7 +173,7 @@ describe('Coordinator/Permissions', function() {
173
173
  expectedOrganizationId = fixture.build('organization').id;
174
174
  expectedUsersPermissions = fixture.buildList(
175
175
  'contxtUserPermissions',
176
- faker.random.number({
176
+ faker.datatype.number({
177
177
  min: 1,
178
178
  max: 10
179
179
  }),
@@ -481,7 +481,7 @@ describe('Coordinator/Permissions', function() {
481
481
 
482
482
  beforeEach(function() {
483
483
  expectedPermissionsMap = fixture.build('userPermissionsMap');
484
- expectedUserId = faker.random.uuid();
484
+ expectedUserId = faker.datatype.uuid();
485
485
 
486
486
  request = {
487
487
  ...baseRequest,
@@ -1,5 +1,5 @@
1
- import Roles from './roles';
2
1
  import * as objectUtils from '../utils/objects';
2
+ import Roles from './roles';
3
3
 
4
4
  describe('Coordinator/Roles', function() {
5
5
  let baseRequest;
@@ -691,7 +691,7 @@ describe('Coordinator/Roles', function() {
691
691
  expectedOrganizationId = fixture.build('contxtOrganization').id;
692
692
  expectedRoles = fixture.buildList(
693
693
  'contxtRole',
694
- faker.random.number({
694
+ faker.datatype.number({
695
695
  min: 1,
696
696
  max: 10
697
697
  }),
@@ -761,7 +761,7 @@ describe('Coordinator/Roles', function() {
761
761
  expectedOrganizationId = fixture.build('organization').id;
762
762
  expectedRoles = fixture.buildList(
763
763
  'contxtRole',
764
- faker.random.number({
764
+ faker.datatype.number({
765
765
  min: 1,
766
766
  max: 10
767
767
  }),
@@ -1,9 +1,8 @@
1
1
  import axios from 'axios';
2
+ import { expect } from 'chai';
2
3
  import omit from 'lodash.omit';
3
-
4
- import Users from './users';
5
4
  import * as objectUtils from '../utils/objects';
6
- import { expect } from 'chai';
5
+ import Users from './users';
7
6
 
8
7
  describe('Coordinator/Users', function() {
9
8
  let baseRequest;
@@ -184,7 +183,7 @@ describe('Coordinator/Users', function() {
184
183
  userActivationPayload = {
185
184
  email: user.email,
186
185
  password: faker.internet.password(),
187
- userToken: faker.random.uuid()
186
+ userToken: faker.datatype.uuid()
188
187
  };
189
188
 
190
189
  userActivationPayloadToServer = {
@@ -254,12 +253,12 @@ describe('Coordinator/Users', function() {
254
253
  const payload = {
255
254
  email: faker.internet.email(),
256
255
  password: faker.internet.password(),
257
- userToken: faker.random.uuid()
256
+ userToken: faker.datatype.uuid()
258
257
  };
259
258
 
260
259
  const users = new Users(baseSdk, baseRequest, expectedBaseUrl);
261
260
  const promise = users.activate(
262
- faker.random.uuid(),
261
+ faker.datatype.uuid(),
263
262
  omit(payload, [field])
264
263
  );
265
264
 
@@ -610,7 +609,7 @@ describe('Coordinator/Users', function() {
610
609
  let toCamelCase;
611
610
 
612
611
  beforeEach(function() {
613
- expectedUserId = faker.random.uuid();
612
+ expectedUserId = faker.datatype.uuid();
614
613
  userFromServerAfterFormat = fixture.build('contxtUser', {
615
614
  id: expectedUserId
616
615
  });
@@ -682,11 +681,11 @@ describe('Coordinator/Users', function() {
682
681
  let toCamelCase;
683
682
 
684
683
  beforeEach(function() {
685
- expectedOrganizationId = faker.random.uuid();
684
+ expectedOrganizationId = faker.datatype.uuid();
686
685
 
687
686
  expectedOrganizationUsers = fixture.buildList(
688
687
  'contxtUser',
689
- faker.random.number({ min: 1, max: 10 })
688
+ faker.datatype.number({ min: 1, max: 10 })
690
689
  );
691
690
 
692
691
  organizationUsersFromServer = expectedOrganizationUsers.map((user) =>
@@ -757,11 +756,11 @@ describe('Coordinator/Users', function() {
757
756
  let users;
758
757
 
759
758
  beforeEach(function() {
760
- expectedOrganizationId = faker.random.uuid();
759
+ expectedOrganizationId = faker.datatype.uuid();
761
760
 
762
761
  expectedOrganizationUsers = fixture.buildList(
763
762
  'contxtUser',
764
- faker.random.number({ min: 1, max: 10 })
763
+ faker.datatype.number({ min: 1, max: 10 })
765
764
  );
766
765
 
767
766
  organizationUsersFromServer = expectedOrganizationUsers.map((user) =>
@@ -942,7 +941,7 @@ describe('Coordinator/Users', function() {
942
941
  expectedLegacyBaseUrl
943
942
  );
944
943
  const promise = users.invite(
945
- faker.random.uuid(),
944
+ faker.datatype.uuid(),
946
945
  omit(newUserPayload, [field])
947
946
  );
948
947
 
@@ -1077,7 +1076,7 @@ describe('Coordinator/Users', function() {
1077
1076
  organization.id
1078
1077
  );
1079
1078
  const promise = users.invite(
1080
- faker.random.uuid(),
1079
+ faker.datatype.uuid(),
1081
1080
  omit(newUserPayload, [field])
1082
1081
  );
1083
1082
 
@@ -1131,7 +1130,7 @@ describe('Coordinator/Users', function() {
1131
1130
  context('when the organization ID is not provided', function() {
1132
1131
  it('throws an error', function() {
1133
1132
  const users = new Users(baseSdk, baseRequest, expectedLegacyBaseUrl);
1134
- const promise = users.remove(null, faker.random.uuid());
1133
+ const promise = users.remove(null, faker.datatype.uuid());
1135
1134
 
1136
1135
  return expect(promise).to.be.rejectedWith(
1137
1136
  'An organization ID is required for removing a user from an organization'
@@ -1142,7 +1141,7 @@ describe('Coordinator/Users', function() {
1142
1141
  context('when the user ID is not provided', function() {
1143
1142
  it('throws an error', function() {
1144
1143
  const users = new Users(baseSdk, baseRequest, expectedLegacyBaseUrl);
1145
- const promise = users.remove(faker.random.uuid(), null);
1144
+ const promise = users.remove(faker.datatype.uuid(), null);
1146
1145
 
1147
1146
  return expect(promise).to.be.rejectedWith(
1148
1147
  'A user ID is required for removing a user from an organization'
@@ -1,8 +1,8 @@
1
1
  import omit from 'lodash.omit';
2
- import Events from './index';
3
2
  import * as eventsUtils from '../utils/events';
4
3
  import * as objectUtils from '../utils/objects';
5
4
  import * as paginationUtils from '../utils/pagination';
5
+ import Events from './index';
6
6
 
7
7
  describe('Events', function() {
8
8
  let baseRequest;
@@ -186,7 +186,7 @@ describe('Events', function() {
186
186
  let toCamelCase;
187
187
 
188
188
  beforeEach(function() {
189
- expectedEventId = faker.random.uuid();
189
+ expectedEventId = faker.datatype.uuid();
190
190
  eventFromServerAfterFormat = fixture.build('event', {
191
191
  id: expectedEventId
192
192
  });
@@ -256,12 +256,12 @@ describe('Events', function() {
256
256
  let toSnakeCase;
257
257
 
258
258
  beforeEach(function() {
259
- clientId = faker.random.uuid();
259
+ clientId = faker.datatype.uuid();
260
260
  eventTypeFromServerAfterFormat = {
261
261
  _metadata: fixture.build('paginationMetadata'),
262
262
  records: fixture.buildList(
263
263
  'eventType',
264
- faker.random.number({ min: 5, max: 10 })
264
+ faker.datatype.number({ min: 5, max: 10 })
265
265
  )
266
266
  };
267
267
  eventTypeFromServerBeforeFormat = {
@@ -271,8 +271,8 @@ describe('Events', function() {
271
271
  )
272
272
  };
273
273
  paginationOptionsBeforeFormat = {
274
- limit: faker.random.number({ min: 10, max: 1000 }),
275
- offset: faker.random.number({ max: 1000 })
274
+ limit: faker.datatype.number({ min: 10, max: 1000 }),
275
+ offset: faker.datatype.number({ max: 1000 })
276
276
  };
277
277
  paginationOptionsAfterFormat = {
278
278
  ...paginationOptionsBeforeFormat
@@ -351,12 +351,12 @@ describe('Events', function() {
351
351
 
352
352
  context('all required params are passed', function() {
353
353
  beforeEach(function() {
354
- typeId = faker.random.uuid();
354
+ typeId = faker.datatype.uuid();
355
355
  eventsFiltersBeforeFormat = {
356
356
  include: ['triggered.latest'],
357
- facilityId: faker.random.number(),
358
- limit: faker.random.number({ min: 10, max: 1000 }),
359
- offset: faker.random.number({ max: 1000 })
357
+ facilityId: faker.datatype.number(),
358
+ limit: faker.datatype.number({ min: 10, max: 1000 }),
359
+ offset: faker.datatype.number({ max: 1000 })
360
360
  };
361
361
  eventsFiltersAfterFormat = { ...eventsFiltersBeforeFormat };
362
362
  eventId = fixture.build('assetType').id;
@@ -364,7 +364,7 @@ describe('Events', function() {
364
364
  _metadata: fixture.build('paginationMetadata'),
365
365
  records: fixture.buildList(
366
366
  'event',
367
- faker.random.number({ min: 5, max: 20 }),
367
+ faker.datatype.number({ min: 5, max: 20 }),
368
368
  { eventId }
369
369
  )
370
370
  };
@@ -442,13 +442,13 @@ describe('Events', function() {
442
442
  let triggeredEventsFromServerBeforeFormat;
443
443
 
444
444
  beforeEach(function() {
445
- facilityId = faker.random.number();
445
+ facilityId = faker.datatype.number();
446
446
 
447
447
  triggeredEventsFromServerAfterFormat = {
448
448
  _metadata: fixture.build('paginationMetadata'),
449
449
  records: fixture.buildList(
450
450
  'triggeredEvent',
451
- faker.random.number({ min: 5, max: 10 })
451
+ faker.datatype.number({ min: 5, max: 10 })
452
452
  )
453
453
  };
454
454
 
@@ -459,9 +459,9 @@ describe('Events', function() {
459
459
  )
460
460
  };
461
461
  paginationOptionsBeforeFormat = {
462
- limit: faker.random.number({ min: 10, max: 1000 }),
463
- offset: faker.random.number({ max: 1000 }),
464
- eventTypeId: faker.random.uuid()
462
+ limit: faker.datatype.number({ min: 10, max: 1000 }),
463
+ offset: faker.datatype.number({ max: 1000 }),
464
+ eventTypeId: faker.datatype.uuid()
465
465
  };
466
466
  paginationOptionsAfterFormat = {
467
467
  ...paginationOptionsBeforeFormat
@@ -1,9 +1,9 @@
1
1
  import axios from 'axios';
2
2
  import omit from 'lodash.omit';
3
3
  import pick from 'lodash.pick';
4
- import Files from './index';
5
4
  import * as objectUtils from '../utils/objects';
6
5
  import * as paginationUtils from '../utils/pagination';
6
+ import Files from './index';
7
7
 
8
8
  describe('Files', function() {
9
9
  let baseRequest;
@@ -825,7 +825,7 @@ describe('Files', function() {
825
825
  let toCamelCase;
826
826
 
827
827
  beforeEach(function() {
828
- expectedFileId = faker.random.uuid();
828
+ expectedFileId = faker.datatype.uuid();
829
829
  fileFromServerAfterFormat = fixture.build('fileToDownload');
830
830
 
831
831
  fileFromServerBeforeFormat = fixture.build(
@@ -890,7 +890,7 @@ describe('Files', function() {
890
890
  let toCamelCase;
891
891
 
892
892
  beforeEach(function() {
893
- expectedFileId = faker.random.uuid();
893
+ expectedFileId = faker.datatype.uuid();
894
894
  fileFromServerAfterFormat = fixture.build('file', {
895
895
  id: expectedFileId
896
896
  });
@@ -962,7 +962,7 @@ describe('Files', function() {
962
962
  _metadata: fixture.build('paginationMetadata'),
963
963
  records: fixture.buildList(
964
964
  'file',
965
- faker.random.number({ min: 1, max: 10 })
965
+ faker.datatype.number({ min: 1, max: 10 })
966
966
  )
967
967
  };
968
968
  filesFromServerBeforeFormat = {
@@ -972,8 +972,8 @@ describe('Files', function() {
972
972
  )
973
973
  };
974
974
  filesFiltersBeforeFormat = {
975
- limit: faker.random.number({ min: 10, max: 1000 }),
976
- offset: faker.random.number({ max: 1000 }),
975
+ limit: faker.datatype.number({ min: 10, max: 1000 }),
976
+ offset: faker.datatype.number({ max: 1000 }),
977
977
  orderBy: faker.random.arrayElement([
978
978
  'content_type',
979
979
  'created_at',
@@ -985,7 +985,7 @@ describe('Files', function() {
985
985
  'status',
986
986
  'updated_at'
987
987
  ]),
988
- reverseOrder: faker.random.boolean(),
988
+ reverseOrder: faker.datatype.boolean(),
989
989
  status: faker.random.arrayElement(['ACTIVE', 'UPLOADING'])
990
990
  };
991
991
  filesFiltersAfterFormat = {
package/src/index.js CHANGED
@@ -1,14 +1,13 @@
1
- import Assets from './assets';
2
1
  import Bus from './bus';
3
2
  import Config from './config';
4
3
  import Coordinator from './coordinator';
5
4
  import Events from './events';
6
- import Facilities from './facilities';
7
5
  import Files from './files';
8
- import Health from './health';
9
6
  import Iot from './iot';
7
+ import Nionic from './nionic';
10
8
  import Request from './request';
11
9
  import * as sessionTypes from './sessionTypes';
10
+ import { toSnakeCase, toCamelCase } from './utils/objects';
12
11
 
13
12
  /**
14
13
  * An adapter that allows the SDK to authenticate with different services and manage various tokens.
@@ -78,7 +77,6 @@ class ContxtSdk {
78
77
 
79
78
  this.config = new Config(config, externalModules);
80
79
 
81
- this.assets = new Assets(this, this._createRequest('facilities'));
82
80
  this.auth = this._createAuthSession(sessionType);
83
81
  this.bus = new Bus(this, this._createRequest('bus'));
84
82
  this.coordinator = new Coordinator(
@@ -86,10 +84,9 @@ class ContxtSdk {
86
84
  this._createRequest('coordinator')
87
85
  );
88
86
  this.events = new Events(this, this._createRequest('events'));
89
- this.facilities = new Facilities(this, this._createRequest('facilities'));
90
87
  this.files = new Files(this, this._createRequest('files'));
91
- this.health = new Health(this, this._createRequest('health'));
92
88
  this.iot = new Iot(this, this._createRequest('iot'));
89
+ this.nionic = new Nionic(this, this._createRequest('nionic'));
93
90
 
94
91
  this._decorate(externalModules);
95
92
  }
@@ -201,3 +198,4 @@ class ContxtSdk {
201
198
  }
202
199
 
203
200
  export default ContxtSdk;
201
+ export { toSnakeCase, toCamelCase };
package/src/index.spec.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import times from 'lodash.times';
2
2
  import Bus from './bus';
3
3
  import Config from './config';
4
- import ContxtSdk from './index';
5
4
  import Coordinator from './coordinator';
6
5
  import Events from './events';
7
- import Facilities from './facilities';
8
6
  import Files from './files';
9
- import Health from './health';
7
+ import ContxtSdk from './index';
10
8
  import Iot from './iot';
11
9
  import Request from './request';
12
10
  import * as sessionTypes from './sessionTypes';
@@ -35,7 +33,7 @@ describe('ContxtSdk', function() {
35
33
 
36
34
  beforeEach(function() {
37
35
  expectedExternalModules = times(
38
- faker.random.number({ min: 1, max: 5 })
36
+ faker.datatype.number({ min: 1, max: 5 })
39
37
  ).reduce((memo) => {
40
38
  const moduleName = faker.hacker.verb();
41
39
  memo[moduleName] = {
@@ -103,22 +101,10 @@ describe('ContxtSdk', function() {
103
101
  expect(contxtSdk.events).to.be.an.instanceof(Events);
104
102
  });
105
103
 
106
- it('creates an instance of the request module for Facilities', function() {
107
- expect(createRequest).to.be.calledWith('facilities');
108
- });
109
-
110
- it('sets an instance of Facilities', function() {
111
- expect(contxtSdk.facilities).to.be.an.instanceof(Facilities);
112
- });
113
-
114
104
  it('sets an instance of Files', function() {
115
105
  expect(contxtSdk.files).to.be.an.instanceof(Files);
116
106
  });
117
107
 
118
- it('sets an instance of Health', function() {
119
- expect(contxtSdk.health).to.be.an.instanceof(Health);
120
- });
121
-
122
108
  it('creates an instance of the request module for IOT', function() {
123
109
  expect(createRequest).to.be.calledWith('iot');
124
110
  });
@@ -145,7 +131,7 @@ describe('ContxtSdk', function() {
145
131
 
146
132
  beforeEach(function() {
147
133
  existingDynamicModuleNames = times(
148
- faker.random.number({ min: 1, max: 10 })
134
+ faker.datatype.number({ min: 1, max: 10 })
149
135
  ).map((index) => `${faker.hacker.adjective()}-${index}`);
150
136
  existingStaticModule = sinon.stub();
151
137
  expectedAudience = fixture.build('audience');
@@ -230,7 +216,7 @@ describe('ContxtSdk', function() {
230
216
  .callsFake((moduleName) => `request module for: ${moduleName}`),
231
217
  _dynamicModuleNames: [
232
218
  moduleName,
233
- times(faker.random.number({ min: 1, max: 10 })).map(
219
+ times(faker.datatype.number({ min: 1, max: 10 })).map(
234
220
  (index) => `${faker.hacker.adjective()}-${index}`
235
221
  )
236
222
  ],
@@ -291,7 +277,7 @@ describe('ContxtSdk', function() {
291
277
 
292
278
  beforeEach(function() {
293
279
  existingDynamicModuleNames = times(
294
- faker.random.number({ min: 1, max: 10 })
280
+ faker.datatype.number({ min: 1, max: 10 })
295
281
  ).map((index) => `${faker.hacker.adjective()}-${index}`);
296
282
  existingStaticModule = sinon.stub();
297
283
  expectedAudience = fixture.build('audience');
@@ -378,7 +364,7 @@ describe('ContxtSdk', function() {
378
364
  expectedRemovedModule = sinon.stub();
379
365
  moduleName = faker.hacker.verb();
380
366
  remainingDynamicModules = times(
381
- faker.random.number({ min: 1, max: 10 })
367
+ faker.datatype.number({ min: 1, max: 10 })
382
368
  ).reduce((memo, index) => {
383
369
  memo[`${faker.hacker.adjective()}-${index}`] = sinon.stub();
384
370
 
@@ -457,7 +443,7 @@ describe('ContxtSdk', function() {
457
443
  internalModule = sinon.stub();
458
444
  internalModuleName = faker.hacker.verb();
459
445
  externalModules = times(
460
- faker.random.number({ min: 1, max: 10 })
446
+ faker.datatype.number({ min: 1, max: 10 })
461
447
  ).reduce((memo, index) => {
462
448
  memo[`${faker.hacker.adjective()}-${index}`] = sinon.stub();
463
449
 
@@ -651,7 +637,7 @@ describe('ContxtSdk', function() {
651
637
  let instance;
652
638
 
653
639
  beforeEach(function() {
654
- externalModules = times(faker.random.number({ min: 1, max: 5 })).reduce(
640
+ externalModules = times(faker.datatype.number({ min: 1, max: 5 })).reduce(
655
641
  (memo, index) => {
656
642
  const moduleName = `${faker.hacker.verb()}-${index}`;
657
643
  memo[moduleName] = { module: sinon.stub() };
@@ -1,5 +1,5 @@
1
- import Feeds from './feeds';
2
1
  import * as objectUtils from '../utils/objects';
2
+ import Feeds from './feeds';
3
3
 
4
4
  describe('Iot/Feeds', function() {
5
5
  let baseRequest;
@@ -58,7 +58,7 @@ describe('Iot/Feeds', function() {
58
58
  facilityId = fixture.build('facility').id;
59
59
  expectedFeeds = fixture.buildList(
60
60
  'feed',
61
- faker.random.number({
61
+ faker.datatype.number({
62
62
  min: 1,
63
63
  max: 10
64
64
  })
@@ -133,7 +133,7 @@ describe('Iot/Feeds', function() {
133
133
  expectedResult = {
134
134
  feeds: fixture.buildList(
135
135
  'feed',
136
- faker.random.number({
136
+ faker.datatype.number({
137
137
  min: 1,
138
138
  max: 10
139
139
  })
@@ -143,7 +143,7 @@ describe('Iot/Feeds', function() {
143
143
  expectedResult.feeds.forEach((feed) => {
144
144
  feed.groupings = fixture.buildList(
145
145
  'fieldGroupingStatus',
146
- faker.random.number({ min: 1, max: 4 })
146
+ faker.datatype.number({ min: 1, max: 4 })
147
147
  );
148
148
  });
149
149
 
@@ -1,7 +1,7 @@
1
1
  import omit from 'lodash.omit';
2
- import FieldCategories from './fieldCategories';
3
2
  import * as objectUtils from '../utils/objects';
4
3
  import * as paginationUtils from '../utils/pagination';
4
+ import FieldCategories from './fieldCategories';
5
5
 
6
6
  describe('Iot/FieldCategories', function() {
7
7
  let baseRequest;
@@ -256,7 +256,7 @@ describe('Iot/FieldCategories', function() {
256
256
  _metadata: fixture.build('paginationMetadata'),
257
257
  records: fixture.buildList(
258
258
  'fieldCategory',
259
- faker.random.number({ min: 5, max: 10 })
259
+ faker.datatype.number({ min: 5, max: 10 })
260
260
  )
261
261
  };
262
262
  fieldCategoriesFromServerBeforeFormat = {
@@ -266,8 +266,8 @@ describe('Iot/FieldCategories', function() {
266
266
  )
267
267
  };
268
268
  paginationOptionsBeforeFormat = {
269
- limit: faker.random.number({ min: 10, max: 1000 }),
270
- offset: faker.random.number({ max: 1000 })
269
+ limit: faker.datatype.number({ min: 10, max: 1000 }),
270
+ offset: faker.datatype.number({ max: 1000 })
271
271
  };
272
272
  paginationOptionsAfterFormat = {
273
273
  ...paginationOptionsBeforeFormat
@@ -1,7 +1,7 @@
1
1
  import omit from 'lodash.omit';
2
- import FieldGroupings from './fieldGroupings';
3
2
  import * as objectUtils from '../utils/objects';
4
3
  import * as paginationUtils from '../utils/pagination';
4
+ import FieldGroupings from './fieldGroupings';
5
5
 
6
6
  describe('Iot/FieldGroupings', function() {
7
7
  let baseRequest;
@@ -357,12 +357,12 @@ describe('Iot/FieldGroupings', function() {
357
357
  let toSnakeCase;
358
358
 
359
359
  beforeEach(function() {
360
- facilityId = faker.random.number({ min: 1, max: 300 });
360
+ facilityId = faker.datatype.number({ min: 1, max: 300 });
361
361
  fieldGroupingFromServerAfterFormat = {
362
362
  _metadata: fixture.build('paginationMetadata'),
363
363
  records: fixture.buildList(
364
364
  'fieldGrouping',
365
- faker.random.number({ min: 5, max: 10 })
365
+ faker.datatype.number({ min: 5, max: 10 })
366
366
  )
367
367
  };
368
368
  fieldGroupingFromServerBeforeFormat = {
@@ -372,8 +372,8 @@ describe('Iot/FieldGroupings', function() {
372
372
  )
373
373
  };
374
374
  paginationOptionsBeforeFormat = {
375
- limit: faker.random.number({ min: 10, max: 1000 }),
376
- offset: faker.random.number({ max: 1000 })
375
+ limit: faker.datatype.number({ min: 10, max: 1000 }),
376
+ offset: faker.datatype.number({ max: 1000 })
377
377
  };
378
378
  paginationOptionsAfterFormat = {
379
379
  ...paginationOptionsBeforeFormat
@@ -1,5 +1,5 @@
1
- import Outputs from './outputs';
2
1
  import * as iotUtils from '../utils/iot';
2
+ import Outputs from './outputs';
3
3
 
4
4
  describe('Iot/Outputs', function() {
5
5
  let baseRequest;
@@ -61,19 +61,19 @@ describe('Iot/Outputs', function() {
61
61
  beforeEach(function() {
62
62
  expectedFieldHumanName = fixture.build('outputField').fieldHumanName;
63
63
  expectedOptions = {
64
- limit: faker.random.number(),
64
+ limit: faker.datatype.number(),
65
65
  timeEnd: Math.floor(faker.date.recent().getTime() / 1000),
66
66
  timeStart: Math.floor(faker.date.past().getTime() / 1000),
67
67
  window: faker.random.arrayElement([0, 60, 900, 3600])
68
68
  };
69
69
  expectedOutputFieldData = {
70
- meta: { count: faker.random.number() },
70
+ meta: { count: faker.datatype.number() },
71
71
  records: fixture.buildList(
72
72
  'outputFieldData',
73
- faker.random.number({ min: 1, max: 10 })
73
+ faker.datatype.number({ min: 1, max: 10 })
74
74
  )
75
75
  };
76
- expectedOutputId = faker.random.number();
76
+ expectedOutputId = faker.datatype.number();
77
77
  rawOutputFieldData = {
78
78
  meta: expectedOutputFieldData.meta,
79
79
  records: expectedOutputFieldData.records.map((record) =>
@@ -133,7 +133,7 @@ describe('Iot/Outputs', function() {
133
133
 
134
134
  it('throws an error when there is no provided output ID', function() {
135
135
  const outputs = new Outputs(baseSdk, baseRequest);
136
- const promise = outputs.getFieldData(faker.random.number(), null);
136
+ const promise = outputs.getFieldData(faker.datatype.number(), null);
137
137
 
138
138
  return expect(promise).to.be.rejectedWith(
139
139
  "A fieldHumanName is required for getting a specific field's output data"