@ndustrial/contxt-sdk 5.8.0 → 5.8.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.
Files changed (209) hide show
  1. package/.nvmrc +1 -1
  2. package/esm/bus/channels.js +0 -1
  3. package/esm/bus/channels.js.map +1 -1
  4. package/esm/bus/index.js +0 -1
  5. package/esm/bus/index.js.map +1 -1
  6. package/esm/bus/webSocketConnection.js +46 -47
  7. package/esm/bus/webSocketConnection.js.map +1 -1
  8. package/esm/config/index.js +27 -27
  9. package/esm/config/index.js.map +1 -1
  10. package/esm/coordinator/applications.js +0 -2
  11. package/esm/coordinator/applications.js.map +1 -1
  12. package/esm/coordinator/consent.js +0 -1
  13. package/esm/coordinator/consent.js.map +1 -1
  14. package/esm/coordinator/edgeNodes.js +0 -1
  15. package/esm/coordinator/edgeNodes.js.map +1 -1
  16. package/esm/coordinator/organizations.js +0 -2
  17. package/esm/coordinator/organizations.js.map +1 -1
  18. package/esm/coordinator/permissions.js +0 -1
  19. package/esm/coordinator/permissions.js.map +1 -1
  20. package/esm/coordinator/roles.js +0 -3
  21. package/esm/coordinator/roles.js.map +1 -1
  22. package/esm/coordinator/users.js +0 -2
  23. package/esm/coordinator/users.js.map +1 -1
  24. package/esm/events/index.js +0 -1
  25. package/esm/events/index.js.map +1 -1
  26. package/esm/files/index.js +20 -31
  27. package/esm/files/index.js.map +1 -1
  28. package/esm/index.js +7 -8
  29. package/esm/index.js.map +1 -1
  30. package/esm/iot/feeds.js +0 -1
  31. package/esm/iot/feeds.js.map +1 -1
  32. package/esm/iot/fieldCategories.js +0 -1
  33. package/esm/iot/fieldCategories.js.map +1 -1
  34. package/esm/iot/fieldGroupings.js +0 -1
  35. package/esm/iot/fieldGroupings.js.map +1 -1
  36. package/esm/iot/fields.js +0 -1
  37. package/esm/iot/fields.js.map +1 -1
  38. package/esm/iot/outputs.js +0 -1
  39. package/esm/iot/outputs.js.map +1 -1
  40. package/esm/nionic/index.js +12 -15
  41. package/esm/nionic/index.js.map +1 -1
  42. package/esm/request.js +8 -9
  43. package/esm/request.js.map +1 -1
  44. package/esm/sessionTypes/auth0WebAuth.js +10 -19
  45. package/esm/sessionTypes/auth0WebAuth.js.map +1 -1
  46. package/esm/sessionTypes/index.js +0 -1
  47. package/esm/sessionTypes/index.js.map +1 -1
  48. package/esm/sessionTypes/machineAuth.js +7 -16
  49. package/esm/sessionTypes/machineAuth.js.map +1 -1
  50. package/esm/sessionTypes/passwordGrantAuth.js +3 -6
  51. package/esm/sessionTypes/passwordGrantAuth.js.map +1 -1
  52. package/esm/utils/iot/formatOutputFieldDataFromServer.js +6 -13
  53. package/esm/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
  54. package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js +0 -2
  55. package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
  56. package/esm/utils/objects/createCaseChangeFn.js +4 -14
  57. package/esm/utils/objects/createCaseChangeFn.js.map +1 -1
  58. package/esm/utils/objects/map.js +5 -29
  59. package/esm/utils/objects/map.js.map +1 -1
  60. package/esm/utils/pagination/formatPaginatedDataFromServer.js +0 -1
  61. package/esm/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
  62. package/esm/utils/url/index.js +2 -2
  63. package/lib/bus/channels.js +0 -1
  64. package/lib/bus/channels.js.map +1 -1
  65. package/lib/bus/index.js +0 -1
  66. package/lib/bus/index.js.map +1 -1
  67. package/lib/bus/webSocketConnection.js +46 -47
  68. package/lib/bus/webSocketConnection.js.map +1 -1
  69. package/lib/config/index.js +27 -27
  70. package/lib/config/index.js.map +1 -1
  71. package/lib/coordinator/applications.js +0 -2
  72. package/lib/coordinator/applications.js.map +1 -1
  73. package/lib/coordinator/consent.js +0 -1
  74. package/lib/coordinator/consent.js.map +1 -1
  75. package/lib/coordinator/edgeNodes.js +0 -1
  76. package/lib/coordinator/edgeNodes.js.map +1 -1
  77. package/lib/coordinator/organizations.js +0 -2
  78. package/lib/coordinator/organizations.js.map +1 -1
  79. package/lib/coordinator/permissions.js +0 -1
  80. package/lib/coordinator/permissions.js.map +1 -1
  81. package/lib/coordinator/roles.js +0 -3
  82. package/lib/coordinator/roles.js.map +1 -1
  83. package/lib/coordinator/users.js +0 -2
  84. package/lib/coordinator/users.js.map +1 -1
  85. package/lib/events/index.js +0 -1
  86. package/lib/events/index.js.map +1 -1
  87. package/lib/files/index.js +20 -31
  88. package/lib/files/index.js.map +1 -1
  89. package/lib/index.js +7 -8
  90. package/lib/index.js.map +1 -1
  91. package/lib/iot/feeds.js +0 -1
  92. package/lib/iot/feeds.js.map +1 -1
  93. package/lib/iot/fieldCategories.js +0 -1
  94. package/lib/iot/fieldCategories.js.map +1 -1
  95. package/lib/iot/fieldGroupings.js +0 -1
  96. package/lib/iot/fieldGroupings.js.map +1 -1
  97. package/lib/iot/fields.js +0 -1
  98. package/lib/iot/fields.js.map +1 -1
  99. package/lib/iot/outputs.js +0 -1
  100. package/lib/iot/outputs.js.map +1 -1
  101. package/lib/nionic/index.js +12 -15
  102. package/lib/nionic/index.js.map +1 -1
  103. package/lib/request.js +8 -9
  104. package/lib/request.js.map +1 -1
  105. package/lib/sessionTypes/auth0WebAuth.js +10 -19
  106. package/lib/sessionTypes/auth0WebAuth.js.map +1 -1
  107. package/lib/sessionTypes/index.js +0 -1
  108. package/lib/sessionTypes/index.js.map +1 -1
  109. package/lib/sessionTypes/machineAuth.js +7 -16
  110. package/lib/sessionTypes/machineAuth.js.map +1 -1
  111. package/lib/sessionTypes/passwordGrantAuth.js +3 -6
  112. package/lib/sessionTypes/passwordGrantAuth.js.map +1 -1
  113. package/lib/utils/iot/formatOutputFieldDataFromServer.js +6 -13
  114. package/lib/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
  115. package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js +0 -2
  116. package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
  117. package/lib/utils/objects/createCaseChangeFn.js +4 -14
  118. package/lib/utils/objects/createCaseChangeFn.js.map +1 -1
  119. package/lib/utils/objects/map.js +5 -29
  120. package/lib/utils/objects/map.js.map +1 -1
  121. package/lib/utils/pagination/formatPaginatedDataFromServer.js +0 -1
  122. package/lib/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
  123. package/lib/utils/url/index.js +2 -2
  124. package/package.json +6 -3
  125. package/src/bus/index.spec.js +1 -1
  126. package/src/bus/webSocketConnection.spec.js +53 -53
  127. package/src/config/index.spec.js +5 -5
  128. package/src/coordinator/applications.spec.js +7 -7
  129. package/src/coordinator/consent.spec.js +1 -1
  130. package/src/coordinator/edgeNodes.spec.js +2 -2
  131. package/src/coordinator/organizations.spec.js +3 -3
  132. package/src/coordinator/permissions.spec.js +3 -3
  133. package/src/coordinator/roles.spec.js +3 -3
  134. package/src/coordinator/users.spec.js +17 -17
  135. package/src/events/index.spec.js +15 -15
  136. package/src/files/index.spec.js +8 -8
  137. package/src/index.spec.js +8 -8
  138. package/src/iot/feeds.spec.js +3 -3
  139. package/src/iot/fieldCategories.spec.js +3 -3
  140. package/src/iot/fieldGroupings.spec.js +4 -4
  141. package/src/iot/outputs.spec.js +6 -6
  142. package/src/request.spec.js +3 -3
  143. package/src/sessionTypes/auth0WebAuth.spec.js +16 -14
  144. package/src/sessionTypes/index.spec.js +1 -1
  145. package/src/sessionTypes/machineAuth.spec.js +5 -5
  146. package/src/sessionTypes/passwordGrantAuth.spec.js +1 -1
  147. package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +6 -6
  148. package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.spec.js +3 -3
  149. package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +2 -2
  150. package/src/utils/url/stringifyParams.spec.js +3 -3
  151. package/support/fixtures/factories/IOSDevice.js +4 -4
  152. package/support/fixtures/factories/applicationGrouping.js +6 -6
  153. package/support/fixtures/factories/applicationModule.js +3 -3
  154. package/support/fixtures/factories/asset.js +2 -2
  155. package/support/fixtures/factories/assetAttribute.js +4 -4
  156. package/support/fixtures/factories/assetAttributeValue.js +3 -3
  157. package/support/fixtures/factories/assetMetric.js +3 -3
  158. package/support/fixtures/factories/assetMetricValue.js +4 -4
  159. package/support/fixtures/factories/assetMetricValueCompact.js +3 -3
  160. package/support/fixtures/factories/assetType.js +2 -2
  161. package/support/fixtures/factories/audience.js +1 -1
  162. package/support/fixtures/factories/authResults.js +4 -4
  163. package/support/fixtures/factories/channel.js +2 -2
  164. package/support/fixtures/factories/contxtApplication.js +10 -10
  165. package/support/fixtures/factories/contxtOrganization.js +3 -3
  166. package/support/fixtures/factories/contxtOrganizationFeaturedApplication.js +4 -4
  167. package/support/fixtures/factories/contxtProject.js +7 -7
  168. package/support/fixtures/factories/contxtProjectEnvironment.js +7 -7
  169. package/support/fixtures/factories/contxtRole.js +5 -5
  170. package/support/fixtures/factories/contxtRoleApplication.js +2 -2
  171. package/support/fixtures/factories/contxtRoleProjectEnvironment.js +3 -3
  172. package/support/fixtures/factories/contxtUser.js +6 -6
  173. package/support/fixtures/factories/contxtUserApplication.js +2 -2
  174. package/support/fixtures/factories/contxtUserFavoriteApplication.js +3 -3
  175. package/support/fixtures/factories/contxtUserPermissions.js +6 -6
  176. package/support/fixtures/factories/contxtUserProjectEnvironment.js +3 -3
  177. package/support/fixtures/factories/contxtUserRole.js +3 -3
  178. package/support/fixtures/factories/costCenter.js +3 -3
  179. package/support/fixtures/factories/costCenterFacility.js +4 -4
  180. package/support/fixtures/factories/edgeNode.js +2 -2
  181. package/support/fixtures/factories/event.js +7 -7
  182. package/support/fixtures/factories/eventType.js +6 -6
  183. package/support/fixtures/factories/eventUser.js +8 -8
  184. package/support/fixtures/factories/facility.js +12 -12
  185. package/support/fixtures/factories/facilityGrouping.js +5 -5
  186. package/support/fixtures/factories/facilityGroupingFacility.js +4 -4
  187. package/support/fixtures/factories/facilityInfo.js +6 -6
  188. package/support/fixtures/factories/facilityTag.js +2 -2
  189. package/support/fixtures/factories/feedStatus.js +3 -3
  190. package/support/fixtures/factories/feedType.js +2 -2
  191. package/support/fixtures/factories/feeds.js +8 -8
  192. package/support/fixtures/factories/fieldCategory.js +4 -4
  193. package/support/fixtures/factories/fieldGrouping.js +6 -6
  194. package/support/fixtures/factories/fieldGroupingField.js +4 -4
  195. package/support/fixtures/factories/fieldGroupingStatus.js +3 -3
  196. package/support/fixtures/factories/file.js +3 -3
  197. package/support/fixtures/factories/fileToDownload.js +1 -1
  198. package/support/fixtures/factories/fileUploadInfo.js +3 -3
  199. package/support/fixtures/factories/organization.js +3 -3
  200. package/support/fixtures/factories/outputField.js +18 -18
  201. package/support/fixtures/factories/outputFieldData.js +2 -2
  202. package/support/fixtures/factories/owner.js +5 -5
  203. package/support/fixtures/factories/paginationMetadata.js +3 -3
  204. package/support/fixtures/factories/triggeredEvent.js +5 -5
  205. package/support/fixtures/factories/userEventSubscription.js +3 -3
  206. package/support/fixtures/factories/userMobileNumber.js +4 -4
  207. package/support/fixtures/factories/userPermissionsMap.js +3 -3
  208. package/support/fixtures/factories/userProfile.js +3 -3
  209. package/support/globals.js +11 -1
@@ -183,7 +183,7 @@ describe('Coordinator/Users', function () {
183
183
  userActivationPayload = {
184
184
  email: user.email,
185
185
  password: faker.internet.password(),
186
- userToken: faker.datatype.uuid(),
186
+ userToken: faker.string.uuid(),
187
187
  };
188
188
 
189
189
  userActivationPayloadToServer = {
@@ -253,12 +253,12 @@ describe('Coordinator/Users', function () {
253
253
  const payload = {
254
254
  email: faker.internet.email(),
255
255
  password: faker.internet.password(),
256
- userToken: faker.datatype.uuid(),
256
+ userToken: faker.string.uuid(),
257
257
  };
258
258
 
259
259
  const users = new Users(baseSdk, baseRequest, expectedBaseUrl);
260
260
  const promise = users.activate(
261
- faker.datatype.uuid(),
261
+ faker.string.uuid(),
262
262
  omit(payload, [field]),
263
263
  );
264
264
 
@@ -588,7 +588,7 @@ describe('Coordinator/Users', function () {
588
588
  const promise = users.addProjectEnvironment(
589
589
  user.id,
590
590
  projectEnvironment.id,
591
- faker.random.word(),
591
+ faker.lorem.word(),
592
592
  );
593
593
 
594
594
  return expect(promise).to.be.rejectedWith(
@@ -609,7 +609,7 @@ describe('Coordinator/Users', function () {
609
609
  let toCamelCase;
610
610
 
611
611
  beforeEach(function () {
612
- expectedUserId = faker.datatype.uuid();
612
+ expectedUserId = faker.string.uuid();
613
613
  userFromServerAfterFormat = fixture.build('contxtUser', {
614
614
  id: expectedUserId,
615
615
  });
@@ -681,11 +681,11 @@ describe('Coordinator/Users', function () {
681
681
  let toCamelCase;
682
682
 
683
683
  beforeEach(function () {
684
- expectedOrganizationId = faker.datatype.uuid();
684
+ expectedOrganizationId = faker.string.uuid();
685
685
 
686
686
  expectedOrganizationUsers = fixture.buildList(
687
687
  'contxtUser',
688
- faker.datatype.number({ min: 1, max: 10 }),
688
+ faker.number.int({ min: 1, max: 10 }),
689
689
  );
690
690
 
691
691
  organizationUsersFromServer = expectedOrganizationUsers.map((user) =>
@@ -756,11 +756,11 @@ describe('Coordinator/Users', function () {
756
756
  let users;
757
757
 
758
758
  beforeEach(function () {
759
- expectedOrganizationId = faker.datatype.uuid();
759
+ expectedOrganizationId = faker.string.uuid();
760
760
 
761
761
  expectedOrganizationUsers = fixture.buildList(
762
762
  'contxtUser',
763
- faker.datatype.number({ min: 1, max: 10 }),
763
+ faker.number.int({ min: 1, max: 10 }),
764
764
  );
765
765
 
766
766
  organizationUsersFromServer = expectedOrganizationUsers.map((user) =>
@@ -930,8 +930,8 @@ describe('Coordinator/Users', function () {
930
930
  it(`it throws an error when ${field} is missing`, function () {
931
931
  const newUserPayload = {
932
932
  email: faker.internet.email(),
933
- firstName: faker.name.firstName(),
934
- lastName: faker.name.lastName(),
933
+ firstName: faker.person.firstName(),
934
+ lastName: faker.person.lastName(),
935
935
  redirectUrl: faker.internet.url(),
936
936
  };
937
937
 
@@ -941,7 +941,7 @@ describe('Coordinator/Users', function () {
941
941
  expectedLegacyBaseUrl,
942
942
  );
943
943
  const promise = users.invite(
944
- faker.datatype.uuid(),
944
+ faker.string.uuid(),
945
945
  omit(newUserPayload, [field]),
946
946
  );
947
947
 
@@ -1062,8 +1062,8 @@ describe('Coordinator/Users', function () {
1062
1062
  const organization = fixture.build('organization');
1063
1063
  const newUserPayload = {
1064
1064
  email: faker.internet.email(),
1065
- firstName: faker.name.firstName(),
1066
- lastName: faker.name.lastName(),
1065
+ firstName: faker.person.firstName(),
1066
+ lastName: faker.person.lastName(),
1067
1067
  redirectUrl: faker.internet.url(),
1068
1068
  };
1069
1069
 
@@ -1076,7 +1076,7 @@ describe('Coordinator/Users', function () {
1076
1076
  organization.id,
1077
1077
  );
1078
1078
  const promise = users.invite(
1079
- faker.datatype.uuid(),
1079
+ faker.string.uuid(),
1080
1080
  omit(newUserPayload, [field]),
1081
1081
  );
1082
1082
 
@@ -1130,7 +1130,7 @@ describe('Coordinator/Users', function () {
1130
1130
  context('when the organization ID is not provided', function () {
1131
1131
  it('throws an error', function () {
1132
1132
  const users = new Users(baseSdk, baseRequest, expectedLegacyBaseUrl);
1133
- const promise = users.remove(null, faker.datatype.uuid());
1133
+ const promise = users.remove(null, faker.string.uuid());
1134
1134
 
1135
1135
  return expect(promise).to.be.rejectedWith(
1136
1136
  'An organization ID is required for removing a user from an organization',
@@ -1141,7 +1141,7 @@ describe('Coordinator/Users', function () {
1141
1141
  context('when the user ID is not provided', function () {
1142
1142
  it('throws an error', function () {
1143
1143
  const users = new Users(baseSdk, baseRequest, expectedLegacyBaseUrl);
1144
- const promise = users.remove(faker.datatype.uuid(), null);
1144
+ const promise = users.remove(faker.string.uuid(), null);
1145
1145
 
1146
1146
  return expect(promise).to.be.rejectedWith(
1147
1147
  'A user ID is required for removing a user from an organization',
@@ -186,7 +186,7 @@ describe('Events', function() {
186
186
  let toCamelCase;
187
187
 
188
188
  beforeEach(function() {
189
- expectedEventId = faker.datatype.uuid();
189
+ expectedEventId = faker.string.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.datatype.uuid();
259
+ clientId = faker.string.uuid();
260
260
  eventTypeFromServerAfterFormat = {
261
261
  _metadata: fixture.build('paginationMetadata'),
262
262
  records: fixture.buildList(
263
263
  'eventType',
264
- faker.datatype.number({ min: 5, max: 10 })
264
+ faker.number.int({ 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.datatype.number({ min: 10, max: 1000 }),
275
- offset: faker.datatype.number({ max: 1000 })
274
+ limit: faker.number.int({ min: 10, max: 1000 }),
275
+ offset: faker.number.int({ 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.datatype.uuid();
354
+ typeId = faker.string.uuid();
355
355
  eventsFiltersBeforeFormat = {
356
356
  include: ['triggered.latest'],
357
- facilityId: faker.datatype.number(),
358
- limit: faker.datatype.number({ min: 10, max: 1000 }),
359
- offset: faker.datatype.number({ max: 1000 })
357
+ facilityId: faker.number.int(),
358
+ limit: faker.number.int({ min: 10, max: 1000 }),
359
+ offset: faker.number.int({ 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.datatype.number({ min: 5, max: 20 }),
367
+ faker.number.int({ 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.datatype.number();
445
+ facilityId = faker.number.int();
446
446
 
447
447
  triggeredEventsFromServerAfterFormat = {
448
448
  _metadata: fixture.build('paginationMetadata'),
449
449
  records: fixture.buildList(
450
450
  'triggeredEvent',
451
- faker.datatype.number({ min: 5, max: 10 })
451
+ faker.number.int({ 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.datatype.number({ min: 10, max: 1000 }),
463
- offset: faker.datatype.number({ max: 1000 }),
464
- eventTypeId: faker.datatype.uuid()
462
+ limit: faker.number.int({ min: 10, max: 1000 }),
463
+ offset: faker.number.int({ max: 1000 }),
464
+ eventTypeId: faker.string.uuid()
465
465
  };
466
466
  paginationOptionsAfterFormat = {
467
467
  ...paginationOptionsBeforeFormat
@@ -825,7 +825,7 @@ describe('Files', function() {
825
825
  let toCamelCase;
826
826
 
827
827
  beforeEach(function() {
828
- expectedFileId = faker.datatype.uuid();
828
+ expectedFileId = faker.string.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.datatype.uuid();
893
+ expectedFileId = faker.string.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.datatype.number({ min: 1, max: 10 })
965
+ faker.number.int({ min: 1, max: 10 })
966
966
  )
967
967
  };
968
968
  filesFromServerBeforeFormat = {
@@ -972,9 +972,9 @@ describe('Files', function() {
972
972
  )
973
973
  };
974
974
  filesFiltersBeforeFormat = {
975
- limit: faker.datatype.number({ min: 10, max: 1000 }),
976
- offset: faker.datatype.number({ max: 1000 }),
977
- orderBy: faker.random.arrayElement([
975
+ limit: faker.number.int({ min: 10, max: 1000 }),
976
+ offset: faker.number.int({ max: 1000 }),
977
+ orderBy: faker.helpers.arrayElement([
978
978
  'content_type',
979
979
  'created_at',
980
980
  'description',
@@ -985,8 +985,8 @@ describe('Files', function() {
985
985
  'status',
986
986
  'updated_at'
987
987
  ]),
988
- reverseOrder: faker.datatype.boolean(),
989
- status: faker.random.arrayElement(['ACTIVE', 'UPLOADING'])
988
+ reverseOrder: fakerBoolean(),
989
+ status: faker.helpers.arrayElement(['ACTIVE', 'UPLOADING'])
990
990
  };
991
991
  filesFiltersAfterFormat = {
992
992
  ...filesFiltersBeforeFormat
package/src/index.spec.js CHANGED
@@ -33,7 +33,7 @@ describe('ContxtSdk', function() {
33
33
 
34
34
  beforeEach(function() {
35
35
  expectedExternalModules = times(
36
- faker.datatype.number({ min: 1, max: 5 })
36
+ faker.number.int({ min: 1, max: 5 })
37
37
  ).reduce((memo) => {
38
38
  const moduleName = faker.hacker.verb();
39
39
  memo[moduleName] = {
@@ -140,7 +140,7 @@ describe('ContxtSdk', function() {
140
140
 
141
141
  beforeEach(function() {
142
142
  existingDynamicModuleNames = times(
143
- faker.datatype.number({ min: 1, max: 10 })
143
+ faker.number.int({ min: 1, max: 10 })
144
144
  ).map((index) => `${faker.hacker.adjective()}-${index}`);
145
145
  existingStaticModule = sinon.stub();
146
146
  expectedAudience = fixture.build('audience');
@@ -225,7 +225,7 @@ describe('ContxtSdk', function() {
225
225
  .callsFake((moduleName) => `request module for: ${moduleName}`),
226
226
  _dynamicModuleNames: [
227
227
  moduleName,
228
- times(faker.datatype.number({ min: 1, max: 10 })).map(
228
+ times(faker.number.int({ min: 1, max: 10 })).map(
229
229
  (index) => `${faker.hacker.adjective()}-${index}`
230
230
  )
231
231
  ],
@@ -286,7 +286,7 @@ describe('ContxtSdk', function() {
286
286
 
287
287
  beforeEach(function() {
288
288
  existingDynamicModuleNames = times(
289
- faker.datatype.number({ min: 1, max: 10 })
289
+ faker.number.int({ min: 1, max: 10 })
290
290
  ).map((index) => `${faker.hacker.adjective()}-${index}`);
291
291
  existingStaticModule = sinon.stub();
292
292
  expectedAudience = fixture.build('audience');
@@ -373,7 +373,7 @@ describe('ContxtSdk', function() {
373
373
  expectedRemovedModule = sinon.stub();
374
374
  moduleName = faker.hacker.verb();
375
375
  remainingDynamicModules = times(
376
- faker.datatype.number({ min: 1, max: 10 })
376
+ faker.number.int({ min: 1, max: 10 })
377
377
  ).reduce((memo, index) => {
378
378
  memo[`${faker.hacker.adjective()}-${index}`] = sinon.stub();
379
379
 
@@ -452,7 +452,7 @@ describe('ContxtSdk', function() {
452
452
  internalModule = sinon.stub();
453
453
  internalModuleName = faker.hacker.verb();
454
454
  externalModules = times(
455
- faker.datatype.number({ min: 1, max: 10 })
455
+ faker.number.int({ min: 1, max: 10 })
456
456
  ).reduce((memo, index) => {
457
457
  memo[`${faker.hacker.adjective()}-${index}`] = sinon.stub();
458
458
 
@@ -538,7 +538,7 @@ describe('ContxtSdk', function() {
538
538
  fn = () =>
539
539
  ContxtSdk.prototype.unmountDynamicModule.call(
540
540
  instance,
541
- faker.random.arrayElement(Object.keys(externalModules))
541
+ faker.helpers.arrayElement(Object.keys(externalModules))
542
542
  );
543
543
  });
544
544
 
@@ -646,7 +646,7 @@ describe('ContxtSdk', function() {
646
646
  let instance;
647
647
 
648
648
  beforeEach(function() {
649
- externalModules = times(faker.datatype.number({ min: 1, max: 5 })).reduce(
649
+ externalModules = times(faker.number.int({ min: 1, max: 5 })).reduce(
650
650
  (memo, index) => {
651
651
  const moduleName = `${faker.hacker.verb()}-${index}`;
652
652
  memo[moduleName] = { module: sinon.stub() };
@@ -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.datatype.number({
61
+ faker.number.int({
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.datatype.number({
136
+ faker.number.int({
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.datatype.number({ min: 1, max: 4 })
146
+ faker.number.int({ min: 1, max: 4 })
147
147
  );
148
148
  });
149
149
 
@@ -256,7 +256,7 @@ describe('Iot/FieldCategories', function() {
256
256
  _metadata: fixture.build('paginationMetadata'),
257
257
  records: fixture.buildList(
258
258
  'fieldCategory',
259
- faker.datatype.number({ min: 5, max: 10 })
259
+ faker.number.int({ 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.datatype.number({ min: 10, max: 1000 }),
270
- offset: faker.datatype.number({ max: 1000 })
269
+ limit: faker.number.int({ min: 10, max: 1000 }),
270
+ offset: faker.number.int({ max: 1000 })
271
271
  };
272
272
  paginationOptionsAfterFormat = {
273
273
  ...paginationOptionsBeforeFormat
@@ -357,12 +357,12 @@ describe('Iot/FieldGroupings', function() {
357
357
  let toSnakeCase;
358
358
 
359
359
  beforeEach(function() {
360
- facilityId = faker.datatype.number({ min: 1, max: 300 });
360
+ facilityId = faker.number.int({ min: 1, max: 300 });
361
361
  fieldGroupingFromServerAfterFormat = {
362
362
  _metadata: fixture.build('paginationMetadata'),
363
363
  records: fixture.buildList(
364
364
  'fieldGrouping',
365
- faker.datatype.number({ min: 5, max: 10 })
365
+ faker.number.int({ 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.datatype.number({ min: 10, max: 1000 }),
376
- offset: faker.datatype.number({ max: 1000 })
375
+ limit: faker.number.int({ min: 10, max: 1000 }),
376
+ offset: faker.number.int({ max: 1000 })
377
377
  };
378
378
  paginationOptionsAfterFormat = {
379
379
  ...paginationOptionsBeforeFormat
@@ -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.datatype.number(),
64
+ limit: faker.number.int(),
65
65
  timeEnd: Math.floor(faker.date.recent().getTime() / 1000),
66
66
  timeStart: Math.floor(faker.date.past().getTime() / 1000),
67
- window: faker.random.arrayElement([0, 60, 900, 3600])
67
+ window: faker.helpers.arrayElement([0, 60, 900, 3600])
68
68
  };
69
69
  expectedOutputFieldData = {
70
- meta: { count: faker.datatype.number() },
70
+ meta: { count: faker.number.int() },
71
71
  records: fixture.buildList(
72
72
  'outputFieldData',
73
- faker.datatype.number({ min: 1, max: 10 })
73
+ faker.number.int({ min: 1, max: 10 })
74
74
  )
75
75
  };
76
- expectedOutputId = faker.datatype.number();
76
+ expectedOutputId = faker.number.int();
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.datatype.number(), null);
136
+ const promise = outputs.getFieldData(faker.number.int(), 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"
@@ -85,7 +85,7 @@ describe('Request', function() {
85
85
  let response;
86
86
 
87
87
  beforeEach(function() {
88
- expectedArgs = times(faker.datatype.number({ min: 1, max: 10 })).map(
88
+ expectedArgs = times(faker.number.int({ min: 1, max: 10 })).map(
89
89
  faker.hacker.phrase
90
90
  );
91
91
  expectedResponse = faker.hacker.phrase();
@@ -122,7 +122,7 @@ describe('Request', function() {
122
122
 
123
123
  beforeEach(function() {
124
124
  const requestInterceptors = times(
125
- faker.datatype.number({ min: 0, max: 10 }),
125
+ faker.number.int({ min: 0, max: 10 }),
126
126
  () => {
127
127
  return {
128
128
  fulfilled: sinon.stub(),
@@ -131,7 +131,7 @@ describe('Request', function() {
131
131
  }
132
132
  );
133
133
  const responseInterceptors = times(
134
- faker.datatype.number({ min: 0, max: 10 }),
134
+ faker.number.int({ min: 0, max: 10 }),
135
135
  () => {
136
136
  return {
137
137
  fulfilled: sinon.stub(),
@@ -23,7 +23,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
23
23
  domain: faker.internet.domainName(),
24
24
  authorizationPath: faker.hacker.noun(),
25
25
  clientId: faker.internet.password(),
26
- tokenExpiresAtBufferMs: faker.datatype.number()
26
+ tokenExpiresAtBufferMs: faker.number.int({ max: 10000 })
27
27
  }
28
28
  }
29
29
  };
@@ -105,14 +105,15 @@ describe('sessionTypes/Auth0WebAuth', function() {
105
105
  });
106
106
 
107
107
  it('creates an auth0 WebAuth instance with the default settings', function() {
108
+ const currentUrl = new URL(global.window.location);
109
+ currentUrl.pathname = sdk.config.auth.authorizationPath;
110
+
108
111
  expect(webAuth).to.be.calledWithNew;
109
112
  expect(webAuth).to.be.calledWith({
110
113
  audience: sdk.config.audiences.contxtAuth.clientId,
111
114
  clientID: sdk.config.auth.clientId,
112
115
  domain: sdk.config.auth.domain,
113
- redirectUri: `${global.window.location}/${
114
- sdk.config.auth.authorizationPath
115
- }`,
116
+ redirectUri: `${currentUrl.origin}${currentUrl.pathname}`,
116
117
  responseType: 'token',
117
118
  scope: 'email profile openid'
118
119
  });
@@ -166,14 +167,15 @@ describe('sessionTypes/Auth0WebAuth', function() {
166
167
  });
167
168
 
168
169
  it('creates an auth0 WebAuth instance with the default settings', function() {
170
+ const currentUrl = new URL(global.window.location);
171
+ currentUrl.pathname = sdk.config.auth.authorizationPath;
172
+
169
173
  expect(webAuth).to.be.calledWithNew;
170
174
  expect(webAuth).to.be.calledWith({
171
175
  audience: sdk.config.audiences.contxtAuth.clientId,
172
176
  clientID: sdk.config.auth.clientId,
173
177
  domain: 'random.auth0.com',
174
- redirectUri: `${global.window.location}/${
175
- sdk.config.auth.authorizationPath
176
- }`,
178
+ redirectUri: `${currentUrl.origin}${currentUrl.pathname}`,
177
179
  responseType: 'token',
178
180
  scope: 'email profile openid'
179
181
  });
@@ -212,7 +214,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
212
214
  let promise;
213
215
 
214
216
  beforeEach(function() {
215
- audienceNameToDelete = faker.random.arrayElement(
217
+ audienceNameToDelete = faker.helpers.arrayElement(
216
218
  Object.keys(sdk.config.audiences)
217
219
  );
218
220
 
@@ -251,7 +253,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
251
253
  beforeEach(function() {
252
254
  let resolver;
253
255
 
254
- audienceNameToDelete = faker.random.arrayElement(
256
+ audienceNameToDelete = faker.helpers.arrayElement(
255
257
  Object.keys(sdk.config.audiences)
256
258
  );
257
259
 
@@ -384,7 +386,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
384
386
  let expectedAudienceName;
385
387
 
386
388
  beforeEach(function() {
387
- expectedAudienceName = faker.random.arrayElement(
389
+ expectedAudienceName = faker.helpers.arrayElement(
388
390
  Object.keys(sdk.config.audiences)
389
391
  );
390
392
  });
@@ -780,7 +782,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
780
782
  beforeEach(function() {
781
783
  expectedOptions = {
782
784
  federated: true,
783
- returnTo: global.window.location,
785
+ returnTo: new URL(global.window.location).origin,
784
786
  [faker.hacker.adjective()]: faker.hacker.phrase()
785
787
  };
786
788
  expectedTokenRenewalTimeout = faker.helpers.createTransaction();
@@ -1074,7 +1076,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
1074
1076
  });
1075
1077
 
1076
1078
  it('throws a 401 and logs the user out if Auth0 requires the session to be re-authenticated', function() {
1077
- const errorType = faker.random.arrayElement([
1079
+ const errorType = faker.helpers.arrayElement([
1078
1080
  'consent_required',
1079
1081
  'interaction_required',
1080
1082
  'login_required'
@@ -1141,7 +1143,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
1141
1143
 
1142
1144
  it('throws the original error if it includes a status code', function() {
1143
1145
  const expectedError = new Error();
1144
- expectedError.response = { status: faker.datatype.number() };
1146
+ expectedError.response = { status: faker.number.int() };
1145
1147
 
1146
1148
  sinon
1147
1149
  .stub(Auth0WebAuth.prototype, '_checkSession')
@@ -1267,7 +1269,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
1267
1269
  const currentDate = new Date();
1268
1270
  clock = sinon.useFakeTimers(currentDate);
1269
1271
 
1270
- const expiresAt = faker.date.future().getTime();
1272
+ const expiresAt = currentDate.getTime() + 100000;
1271
1273
  expectedDelay =
1272
1274
  expiresAt -
1273
1275
  sdk.config.auth.tokenExpiresAtBufferMs -
@@ -23,7 +23,7 @@ describe('sessionTypes', function() {
23
23
  auth: {
24
24
  authorizationPath: faker.hacker.noun(),
25
25
  clientId: faker.internet.password(),
26
- tokenExpiresAtBufferMs: faker.datatype.number()
26
+ tokenExpiresAtBufferMs: faker.number.int()
27
27
  }
28
28
  }
29
29
  };
@@ -69,7 +69,7 @@ describe('sessionTypes/MachineAuth', function() {
69
69
  let promise;
70
70
 
71
71
  beforeEach(function() {
72
- audienceNameToDelete = faker.random.arrayElement(
72
+ audienceNameToDelete = faker.helpers.arrayElement(
73
73
  Object.keys(sdk.config.audiences)
74
74
  );
75
75
 
@@ -110,7 +110,7 @@ describe('sessionTypes/MachineAuth', function() {
110
110
  let promise;
111
111
 
112
112
  beforeEach(function() {
113
- audienceNameToDelete = faker.random.arrayElement(
113
+ audienceNameToDelete = faker.helpers.arrayElement(
114
114
  Object.keys(sdk.config.audiences)
115
115
  );
116
116
 
@@ -361,7 +361,7 @@ describe('sessionTypes/MachineAuth', function() {
361
361
  const currentDate = new Date();
362
362
  audienceName = faker.hacker.adjective();
363
363
  expectedAudience = fixture.build('audience');
364
- expiresInMs = faker.datatype.number({ min: 1000, max: 100000 });
364
+ expiresInMs = faker.number.int({ min: 1000, max: 100000 });
365
365
  expectedSessionInfo = {
366
366
  apiToken: faker.internet.password(),
367
367
  expiresAt: currentDate.getTime() + expiresInMs
@@ -518,7 +518,7 @@ describe('sessionTypes/MachineAuth', function() {
518
518
  const audienceName = faker.hacker.adjective();
519
519
  sdk.config.audiences[audienceName] = fixture.build('audience');
520
520
  const expectedError = new Error();
521
- expectedError.response = { status: faker.datatype.number() };
521
+ expectedError.response = { status: faker.number.int() };
522
522
 
523
523
  sinon.stub(axios, 'post').rejects(expectedError);
524
524
 
@@ -543,7 +543,7 @@ describe('sessionTypes/MachineAuth', function() {
543
543
  expiresAt: faker.date.future().getTime()
544
544
  };
545
545
  initialSessionInfo = times(
546
- faker.datatype.number({ min: 1, max: 10 })
546
+ faker.number.int({ min: 1, max: 10 })
547
547
  ).reduce((memo) => {
548
548
  memo[faker.hacker.verb()] = {
549
549
  apiToken: faker.internet.password(),
@@ -160,7 +160,7 @@ describe('sessionTypes/passwordGrantAuth', function() {
160
160
  username = faker.internet.email();
161
161
  expectedResponse = {
162
162
  accessToken: faker.internet.password(),
163
- expiresIn: faker.datatype.number({ min: 100, max: 1000 }),
163
+ expiresIn: faker.number.int({ min: 100, max: 1000 }),
164
164
  tokenType: 'Bearer'
165
165
  };
166
166