@ndustrial/contxt-sdk 5.7.4 → 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.
- package/.nvmrc +1 -1
- package/esm/bus/channels.js +0 -1
- package/esm/bus/channels.js.map +1 -1
- package/esm/bus/index.js +0 -1
- package/esm/bus/index.js.map +1 -1
- package/esm/bus/webSocketConnection.js +403 -405
- package/esm/bus/webSocketConnection.js.map +1 -1
- package/esm/config/index.js +27 -27
- package/esm/config/index.js.map +1 -1
- package/esm/coordinator/applications.js +0 -2
- package/esm/coordinator/applications.js.map +1 -1
- package/esm/coordinator/consent.js +0 -1
- package/esm/coordinator/consent.js.map +1 -1
- package/esm/coordinator/edgeNodes.js +0 -1
- package/esm/coordinator/edgeNodes.js.map +1 -1
- package/esm/coordinator/organizations.js +0 -2
- package/esm/coordinator/organizations.js.map +1 -1
- package/esm/coordinator/permissions.js +0 -1
- package/esm/coordinator/permissions.js.map +1 -1
- package/esm/coordinator/roles.js +0 -3
- package/esm/coordinator/roles.js.map +1 -1
- package/esm/coordinator/users.js +0 -2
- package/esm/coordinator/users.js.map +1 -1
- package/esm/events/index.js +0 -1
- package/esm/events/index.js.map +1 -1
- package/esm/files/index.js +20 -31
- package/esm/files/index.js.map +1 -1
- package/esm/index.js +7 -8
- package/esm/index.js.map +1 -1
- package/esm/iot/feeds.js +0 -1
- package/esm/iot/feeds.js.map +1 -1
- package/esm/iot/fieldCategories.js +0 -1
- package/esm/iot/fieldCategories.js.map +1 -1
- package/esm/iot/fieldGroupings.js +0 -1
- package/esm/iot/fieldGroupings.js.map +1 -1
- package/esm/iot/fields.js +0 -1
- package/esm/iot/fields.js.map +1 -1
- package/esm/iot/outputs.js +0 -1
- package/esm/iot/outputs.js.map +1 -1
- package/esm/nionic/index.js +12 -15
- package/esm/nionic/index.js.map +1 -1
- package/esm/request.js +8 -9
- package/esm/request.js.map +1 -1
- package/esm/sessionTypes/auth0WebAuth.js +10 -19
- package/esm/sessionTypes/auth0WebAuth.js.map +1 -1
- package/esm/sessionTypes/index.js +0 -1
- package/esm/sessionTypes/index.js.map +1 -1
- package/esm/sessionTypes/machineAuth.js +7 -16
- package/esm/sessionTypes/machineAuth.js.map +1 -1
- package/esm/sessionTypes/passwordGrantAuth.js +3 -6
- package/esm/sessionTypes/passwordGrantAuth.js.map +1 -1
- package/esm/utils/iot/formatOutputFieldDataFromServer.js +6 -13
- package/esm/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
- package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js +0 -2
- package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
- package/esm/utils/objects/createCaseChangeFn.js +4 -14
- package/esm/utils/objects/createCaseChangeFn.js.map +1 -1
- package/esm/utils/objects/map.js +5 -29
- package/esm/utils/objects/map.js.map +1 -1
- package/esm/utils/pagination/formatPaginatedDataFromServer.js +0 -1
- package/esm/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
- package/esm/utils/url/index.js +2 -2
- package/lib/bus/channels.js +0 -1
- package/lib/bus/channels.js.map +1 -1
- package/lib/bus/index.js +0 -1
- package/lib/bus/index.js.map +1 -1
- package/lib/bus/webSocketConnection.js +403 -405
- package/lib/bus/webSocketConnection.js.map +1 -1
- package/lib/config/index.js +27 -27
- package/lib/config/index.js.map +1 -1
- package/lib/coordinator/applications.js +0 -2
- package/lib/coordinator/applications.js.map +1 -1
- package/lib/coordinator/consent.js +0 -1
- package/lib/coordinator/consent.js.map +1 -1
- package/lib/coordinator/edgeNodes.js +0 -1
- package/lib/coordinator/edgeNodes.js.map +1 -1
- package/lib/coordinator/organizations.js +0 -2
- package/lib/coordinator/organizations.js.map +1 -1
- package/lib/coordinator/permissions.js +0 -1
- package/lib/coordinator/permissions.js.map +1 -1
- package/lib/coordinator/roles.js +0 -3
- package/lib/coordinator/roles.js.map +1 -1
- package/lib/coordinator/users.js +0 -2
- package/lib/coordinator/users.js.map +1 -1
- package/lib/events/index.js +0 -1
- package/lib/events/index.js.map +1 -1
- package/lib/files/index.js +20 -31
- package/lib/files/index.js.map +1 -1
- package/lib/index.js +7 -8
- package/lib/index.js.map +1 -1
- package/lib/iot/feeds.js +0 -1
- package/lib/iot/feeds.js.map +1 -1
- package/lib/iot/fieldCategories.js +0 -1
- package/lib/iot/fieldCategories.js.map +1 -1
- package/lib/iot/fieldGroupings.js +0 -1
- package/lib/iot/fieldGroupings.js.map +1 -1
- package/lib/iot/fields.js +0 -1
- package/lib/iot/fields.js.map +1 -1
- package/lib/iot/outputs.js +0 -1
- package/lib/iot/outputs.js.map +1 -1
- package/lib/nionic/index.js +12 -15
- package/lib/nionic/index.js.map +1 -1
- package/lib/request.js +8 -9
- package/lib/request.js.map +1 -1
- package/lib/sessionTypes/auth0WebAuth.js +10 -19
- package/lib/sessionTypes/auth0WebAuth.js.map +1 -1
- package/lib/sessionTypes/index.js +0 -1
- package/lib/sessionTypes/index.js.map +1 -1
- package/lib/sessionTypes/machineAuth.js +7 -16
- package/lib/sessionTypes/machineAuth.js.map +1 -1
- package/lib/sessionTypes/passwordGrantAuth.js +3 -6
- package/lib/sessionTypes/passwordGrantAuth.js.map +1 -1
- package/lib/utils/iot/formatOutputFieldDataFromServer.js +6 -13
- package/lib/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
- package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js +0 -2
- package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
- package/lib/utils/objects/createCaseChangeFn.js +4 -14
- package/lib/utils/objects/createCaseChangeFn.js.map +1 -1
- package/lib/utils/objects/map.js +5 -29
- package/lib/utils/objects/map.js.map +1 -1
- package/lib/utils/pagination/formatPaginatedDataFromServer.js +0 -1
- package/lib/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
- package/lib/utils/url/index.js +2 -2
- package/package.json +14 -7
- package/src/bus/index.spec.js +1 -1
- package/src/bus/webSocketConnection.js +1 -2
- package/src/bus/webSocketConnection.spec.js +53 -53
- package/src/config/index.spec.js +5 -5
- package/src/coordinator/applications.spec.js +7 -7
- package/src/coordinator/consent.spec.js +1 -1
- package/src/coordinator/edgeNodes.spec.js +2 -2
- package/src/coordinator/organizations.spec.js +3 -3
- package/src/coordinator/permissions.spec.js +3 -3
- package/src/coordinator/roles.spec.js +3 -3
- package/src/coordinator/users.spec.js +17 -17
- package/src/events/index.spec.js +15 -15
- package/src/files/index.spec.js +8 -8
- package/src/index.spec.js +8 -8
- package/src/iot/feeds.spec.js +3 -3
- package/src/iot/fieldCategories.spec.js +3 -3
- package/src/iot/fieldGroupings.spec.js +4 -4
- package/src/iot/outputs.spec.js +6 -6
- package/src/request.spec.js +3 -3
- package/src/sessionTypes/auth0WebAuth.spec.js +16 -14
- package/src/sessionTypes/index.spec.js +1 -1
- package/src/sessionTypes/machineAuth.spec.js +5 -5
- package/src/sessionTypes/passwordGrantAuth.spec.js +1 -1
- package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +6 -6
- package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.spec.js +3 -3
- package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +2 -2
- package/src/utils/url/stringifyParams.spec.js +3 -3
- package/support/fixtures/factories/IOSDevice.js +4 -4
- package/support/fixtures/factories/applicationGrouping.js +6 -6
- package/support/fixtures/factories/applicationModule.js +3 -3
- package/support/fixtures/factories/asset.js +2 -2
- package/support/fixtures/factories/assetAttribute.js +4 -4
- package/support/fixtures/factories/assetAttributeValue.js +3 -3
- package/support/fixtures/factories/assetMetric.js +3 -3
- package/support/fixtures/factories/assetMetricValue.js +4 -4
- package/support/fixtures/factories/assetMetricValueCompact.js +3 -3
- package/support/fixtures/factories/assetType.js +2 -2
- package/support/fixtures/factories/audience.js +1 -1
- package/support/fixtures/factories/authResults.js +4 -4
- package/support/fixtures/factories/channel.js +2 -2
- package/support/fixtures/factories/contxtApplication.js +10 -10
- package/support/fixtures/factories/contxtOrganization.js +3 -3
- package/support/fixtures/factories/contxtOrganizationFeaturedApplication.js +4 -4
- package/support/fixtures/factories/contxtProject.js +7 -7
- package/support/fixtures/factories/contxtProjectEnvironment.js +7 -7
- package/support/fixtures/factories/contxtRole.js +5 -5
- package/support/fixtures/factories/contxtRoleApplication.js +2 -2
- package/support/fixtures/factories/contxtRoleProjectEnvironment.js +3 -3
- package/support/fixtures/factories/contxtUser.js +6 -6
- package/support/fixtures/factories/contxtUserApplication.js +2 -2
- package/support/fixtures/factories/contxtUserFavoriteApplication.js +3 -3
- package/support/fixtures/factories/contxtUserPermissions.js +6 -6
- package/support/fixtures/factories/contxtUserProjectEnvironment.js +3 -3
- package/support/fixtures/factories/contxtUserRole.js +3 -3
- package/support/fixtures/factories/costCenter.js +3 -3
- package/support/fixtures/factories/costCenterFacility.js +4 -4
- package/support/fixtures/factories/edgeNode.js +2 -2
- package/support/fixtures/factories/event.js +7 -7
- package/support/fixtures/factories/eventType.js +6 -6
- package/support/fixtures/factories/eventUser.js +8 -8
- package/support/fixtures/factories/facility.js +12 -12
- package/support/fixtures/factories/facilityGrouping.js +5 -5
- package/support/fixtures/factories/facilityGroupingFacility.js +4 -4
- package/support/fixtures/factories/facilityInfo.js +6 -6
- package/support/fixtures/factories/facilityTag.js +2 -2
- package/support/fixtures/factories/feedStatus.js +3 -3
- package/support/fixtures/factories/feedType.js +2 -2
- package/support/fixtures/factories/feeds.js +8 -8
- package/support/fixtures/factories/fieldCategory.js +4 -4
- package/support/fixtures/factories/fieldGrouping.js +6 -6
- package/support/fixtures/factories/fieldGroupingField.js +4 -4
- package/support/fixtures/factories/fieldGroupingStatus.js +3 -3
- package/support/fixtures/factories/file.js +3 -3
- package/support/fixtures/factories/fileToDownload.js +1 -1
- package/support/fixtures/factories/fileUploadInfo.js +3 -3
- package/support/fixtures/factories/organization.js +3 -3
- package/support/fixtures/factories/outputField.js +18 -18
- package/support/fixtures/factories/outputFieldData.js +2 -2
- package/support/fixtures/factories/owner.js +5 -5
- package/support/fixtures/factories/paginationMetadata.js +3 -3
- package/support/fixtures/factories/triggeredEvent.js +5 -5
- package/support/fixtures/factories/userEventSubscription.js +3 -3
- package/support/fixtures/factories/userMobileNumber.js +4 -4
- package/support/fixtures/factories/userPermissionsMap.js +3 -3
- package/support/fixtures/factories/userProfile.js +3 -3
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
684
|
+
expectedOrganizationId = faker.string.uuid();
|
|
685
685
|
|
|
686
686
|
expectedOrganizationUsers = fixture.buildList(
|
|
687
687
|
'contxtUser',
|
|
688
|
-
faker.
|
|
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.
|
|
759
|
+
expectedOrganizationId = faker.string.uuid();
|
|
760
760
|
|
|
761
761
|
expectedOrganizationUsers = fixture.buildList(
|
|
762
762
|
'contxtUser',
|
|
763
|
-
faker.
|
|
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.
|
|
934
|
-
lastName: faker.
|
|
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.
|
|
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.
|
|
1066
|
-
lastName: faker.
|
|
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.
|
|
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.
|
|
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.
|
|
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',
|
package/src/events/index.spec.js
CHANGED
|
@@ -186,7 +186,7 @@ describe('Events', function() {
|
|
|
186
186
|
let toCamelCase;
|
|
187
187
|
|
|
188
188
|
beforeEach(function() {
|
|
189
|
-
expectedEventId = faker.
|
|
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.
|
|
259
|
+
clientId = faker.string.uuid();
|
|
260
260
|
eventTypeFromServerAfterFormat = {
|
|
261
261
|
_metadata: fixture.build('paginationMetadata'),
|
|
262
262
|
records: fixture.buildList(
|
|
263
263
|
'eventType',
|
|
264
|
-
faker.
|
|
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.
|
|
275
|
-
offset: faker.
|
|
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.
|
|
354
|
+
typeId = faker.string.uuid();
|
|
355
355
|
eventsFiltersBeforeFormat = {
|
|
356
356
|
include: ['triggered.latest'],
|
|
357
|
-
facilityId: faker.
|
|
358
|
-
limit: faker.
|
|
359
|
-
offset: faker.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
463
|
-
offset: faker.
|
|
464
|
-
eventTypeId: faker.
|
|
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
|
package/src/files/index.spec.js
CHANGED
|
@@ -825,7 +825,7 @@ describe('Files', function() {
|
|
|
825
825
|
let toCamelCase;
|
|
826
826
|
|
|
827
827
|
beforeEach(function() {
|
|
828
|
-
expectedFileId = faker.
|
|
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.
|
|
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.
|
|
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.
|
|
976
|
-
offset: faker.
|
|
977
|
-
orderBy: faker.
|
|
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:
|
|
989
|
-
status: faker.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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() };
|
package/src/iot/feeds.spec.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
270
|
-
offset: faker.
|
|
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.
|
|
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.
|
|
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.
|
|
376
|
-
offset: faker.
|
|
375
|
+
limit: faker.number.int({ min: 10, max: 1000 }),
|
|
376
|
+
offset: faker.number.int({ max: 1000 })
|
|
377
377
|
};
|
|
378
378
|
paginationOptionsAfterFormat = {
|
|
379
379
|
...paginationOptionsBeforeFormat
|
package/src/iot/outputs.spec.js
CHANGED
|
@@ -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.
|
|
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.
|
|
67
|
+
window: faker.helpers.arrayElement([0, 60, 900, 3600])
|
|
68
68
|
};
|
|
69
69
|
expectedOutputFieldData = {
|
|
70
|
-
meta: { count: faker.
|
|
70
|
+
meta: { count: faker.number.int() },
|
|
71
71
|
records: fixture.buildList(
|
|
72
72
|
'outputFieldData',
|
|
73
|
-
faker.
|
|
73
|
+
faker.number.int({ min: 1, max: 10 })
|
|
74
74
|
)
|
|
75
75
|
};
|
|
76
|
-
expectedOutputId = faker.
|
|
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.
|
|
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"
|
package/src/request.spec.js
CHANGED
|
@@ -85,7 +85,7 @@ describe('Request', function() {
|
|
|
85
85
|
let response;
|
|
86
86
|
|
|
87
87
|
beforeEach(function() {
|
|
88
|
-
expectedArgs = times(faker.
|
|
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.
|
|
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.
|
|
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.
|
|
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: `${
|
|
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: `${
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 =
|
|
1272
|
+
const expiresAt = currentDate.getTime() + 100000;
|
|
1271
1273
|
expectedDelay =
|
|
1272
1274
|
expiresAt -
|
|
1273
1275
|
sdk.config.auth.tokenExpiresAtBufferMs -
|
|
@@ -69,7 +69,7 @@ describe('sessionTypes/MachineAuth', function() {
|
|
|
69
69
|
let promise;
|
|
70
70
|
|
|
71
71
|
beforeEach(function() {
|
|
72
|
-
audienceNameToDelete = faker.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
163
|
+
expiresIn: faker.number.int({ min: 100, max: 1000 }),
|
|
164
164
|
tokenType: 'Bearer'
|
|
165
165
|
};
|
|
166
166
|
|