@ndustrial/contxt-sdk 4.3.4 → 5.1.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 (169) hide show
  1. package/.gitattributes +1 -0
  2. package/.nvmrc +1 -1
  3. package/CHANGELOG.md +8 -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 +3 -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 +19 -13
  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 +3 -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/.envrc +0 -0
  108. package/.huskyrc.js +0 -11
  109. package/.nycrc +0 -12
  110. package/esm/assets/assetAttributes.js +0 -574
  111. package/esm/assets/assetAttributes.js.map +0 -1
  112. package/esm/assets/assetMetrics.js +0 -690
  113. package/esm/assets/assetMetrics.js.map +0 -1
  114. package/esm/assets/assetTypes.js +0 -273
  115. package/esm/assets/assetTypes.js.map +0 -1
  116. package/esm/assets/index.js +0 -283
  117. package/esm/assets/index.js.map +0 -1
  118. package/esm/facilities/costCenters.js +0 -306
  119. package/esm/facilities/costCenters.js.map +0 -1
  120. package/esm/facilities/groupings.js +0 -323
  121. package/esm/facilities/groupings.js.map +0 -1
  122. package/esm/facilities/index.js +0 -343
  123. package/esm/facilities/index.js.map +0 -1
  124. package/esm/health/index.js +0 -229
  125. package/esm/health/index.js.map +0 -1
  126. package/esm/utils/facilities/formatFacilityWithInfoFromServer.js +0 -65
  127. package/esm/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
  128. package/esm/utils/facilities/index.js +0 -4
  129. package/esm/utils/facilities/index.js.map +0 -1
  130. package/lib/assets/assetAttributes.js +0 -588
  131. package/lib/assets/assetAttributes.js.map +0 -1
  132. package/lib/assets/assetMetrics.js +0 -705
  133. package/lib/assets/assetMetrics.js.map +0 -1
  134. package/lib/assets/assetTypes.js +0 -287
  135. package/lib/assets/assetTypes.js.map +0 -1
  136. package/lib/assets/index.js +0 -302
  137. package/lib/assets/index.js.map +0 -1
  138. package/lib/facilities/costCenters.js +0 -316
  139. package/lib/facilities/costCenters.js.map +0 -1
  140. package/lib/facilities/groupings.js +0 -333
  141. package/lib/facilities/groupings.js.map +0 -1
  142. package/lib/facilities/index.js +0 -360
  143. package/lib/facilities/index.js.map +0 -1
  144. package/lib/health/index.js +0 -232
  145. package/lib/health/index.js.map +0 -1
  146. package/lib/utils/facilities/formatFacilityWithInfoFromServer.js +0 -71
  147. package/lib/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
  148. package/lib/utils/facilities/index.js +0 -15
  149. package/lib/utils/facilities/index.js.map +0 -1
  150. package/src/assets/assetAttributes.js +0 -619
  151. package/src/assets/assetAttributes.spec.js +0 -1143
  152. package/src/assets/assetMetrics.js +0 -736
  153. package/src/assets/assetMetrics.spec.js +0 -1180
  154. package/src/assets/assetTypes.js +0 -260
  155. package/src/assets/assetTypes.spec.js +0 -556
  156. package/src/assets/index.js +0 -271
  157. package/src/assets/index.spec.js +0 -515
  158. package/src/facilities/costCenters.js +0 -295
  159. package/src/facilities/costCenters.spec.js +0 -529
  160. package/src/facilities/groupings.js +0 -320
  161. package/src/facilities/groupings.spec.js +0 -567
  162. package/src/facilities/index.js +0 -343
  163. package/src/facilities/index.spec.js +0 -551
  164. package/src/health/index.js +0 -200
  165. package/src/health/index.spec.js +0 -501
  166. package/src/utils/facilities/formatFacilityWithInfoFromServer.js +0 -62
  167. package/src/utils/facilities/formatFacilityWithInfoFromServer.spec.js +0 -73
  168. package/src/utils/facilities/index.js +0 -3
  169. package/tmp/package.json +0 -11
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Module that provides access to Nionic platform.
3
+ *
4
+ * @typicalname contxtSdk.nionic
5
+ */
6
+ class Nionic {
7
+ /**
8
+ * @param {Object} sdk An instance of the SDK so the module can communicate with other modules.
9
+ * @param {Object} request An instance of the request module tied to this module's audience.
10
+ */
11
+ constructor(sdk, request) {
12
+ this._baseUrl = `${sdk.config.audiences.nionic.host}`;
13
+ this._request = request;
14
+ this._sdk = sdk;
15
+
16
+ // Backwards compatibility for legacy uuid's
17
+ this._orgIdToTenantId = {
18
+ '18d8b68e-3e59-418e-9f23-47b7cd6bdd6b': 'genan',
19
+ '02efa741-a96f-4124-a463-ae13a704b8fc': 'lineage',
20
+ '5209751f-ea46-4b3e-a5dd-b8d03311b791': 'ndustrial',
21
+ '2fe29680-fc3d-4888-9e9b-44be1e59c22c': 'sfnt',
22
+ 'b2c6705d-1727-467f-a450-207f110c9966': 'trenton'
23
+ };
24
+ this._tenants = new Set(Object.values(this._orgIdToTenantId));
25
+ }
26
+
27
+ static queryDefaults = {
28
+ additionalFields: []
29
+ };
30
+
31
+ _getTenantId(orgOrTenantId) {
32
+ if (!orgOrTenantId) throw Error('Tenant is required');
33
+ if (
34
+ !(orgOrTenantId in this._orgIdToTenantId) &&
35
+ !this._tenants.has(orgOrTenantId)
36
+ ) {
37
+ throw Error(
38
+ `Tenant is either unrecognized or not yet supported: ${orgOrTenantId}`
39
+ );
40
+ }
41
+ return this._orgIdToTenantId[orgOrTenantId] || orgOrTenantId;
42
+ }
43
+
44
+ _query(orgOrTenantId, options) {
45
+ const tenantId = this._getTenantId(orgOrTenantId);
46
+ const url = `${this._baseUrl.replace('<tenant>', tenantId)}/graphql`;
47
+ return this._request.post(url, options).then((resp) => {
48
+ if (resp.data && resp.data.errors) {
49
+ return Promise.reject(Error(resp.data.errors));
50
+ }
51
+ return Promise.resolve(resp.data);
52
+ });
53
+ }
54
+
55
+ executeQuery(orgOrTenantId, query, variables = {}) {
56
+ return this._query(orgOrTenantId, { query, variables });
57
+ }
58
+
59
+ getAllFacilities(orgOrTenantId, options = Nionic.queryDefaults) {
60
+ const { additionalFields } = options;
61
+ return this._query(orgOrTenantId, {
62
+ query: `
63
+ query {
64
+ facilities {
65
+ nodes {
66
+ id
67
+ name
68
+ slug
69
+ address
70
+ city
71
+ state
72
+ zip
73
+ timezone: timezoneName
74
+ createdAt
75
+ updatedAt
76
+ ${additionalFields.join('\n')}
77
+ }
78
+ }
79
+ }
80
+ `
81
+ }).then((data) => data.facilities.nodes);
82
+ }
83
+
84
+ getFacility(orgOrTenantId, facilityId, options = Nionic.queryDefaults) {
85
+ const { additionalFields } = options;
86
+ return this._query(orgOrTenantId, {
87
+ query: `
88
+ query($facilityId: Int!) {
89
+ facility(id: $facilityId) {
90
+ id
91
+ name
92
+ slug
93
+ address
94
+ city
95
+ state
96
+ zip
97
+ timezone: timezoneName
98
+ createdAt
99
+ updatedAt
100
+ ${additionalFields.join('\n')}
101
+ }
102
+ }
103
+ `,
104
+ variables: { facilityId: parseInt(facilityId) }
105
+ }).then((resp) => resp.facility);
106
+ }
107
+
108
+ getFacilityMetricLabels(orgOrTenantId, { facilityId }) {
109
+ return this._query(orgOrTenantId, {
110
+ query: `
111
+ query($facilityId: Int!) {
112
+ facility(id: $facilityId) {
113
+ metricLabels {
114
+ sourceId
115
+ label
116
+ }
117
+ }
118
+ }
119
+ `,
120
+ variables: { facilityId: parseInt(facilityId) }
121
+ }).then((resp) => resp.facility.metricLabels);
122
+ }
123
+
124
+ getFacilityMetrics(
125
+ orgOrTenantId,
126
+ { facilityId, metricLabel, mutableOnly = false },
127
+ options = Nionic.queryDefaults
128
+ ) {
129
+ const { additionalFields } = options;
130
+ return this._query(orgOrTenantId, {
131
+ query: `
132
+ query($facilityId: Int!, $metricLabel: String!, $mutableOnly: Boolean) {
133
+ facility(id: $facilityId) {
134
+ metricData(label: $metricLabel, mutableOnly: $mutableOnly) {
135
+ nodes {
136
+ time
137
+ sourceId
138
+ label
139
+ data
140
+ ${additionalFields.join('\n')}
141
+ }
142
+ }
143
+ }
144
+ }
145
+ `,
146
+ variables: { facilityId: parseInt(facilityId), metricLabel, mutableOnly }
147
+ }).then((resp) => resp.facility.metricData.nodes);
148
+ }
149
+ }
150
+
151
+ export default Nionic;
@@ -85,7 +85,7 @@ describe('Request', function() {
85
85
  let response;
86
86
 
87
87
  beforeEach(function() {
88
- expectedArgs = times(faker.random.number({ min: 1, max: 10 })).map(
88
+ expectedArgs = times(faker.datatype.number({ 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.random.number({ min: 0, max: 10 }),
125
+ faker.datatype.number({ 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.random.number({ min: 0, max: 10 }),
134
+ faker.datatype.number({ 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.random.number()
26
+ tokenExpiresAtBufferMs: faker.datatype.number()
27
27
  }
28
28
  }
29
29
  };
@@ -1141,7 +1141,7 @@ describe('sessionTypes/Auth0WebAuth', function() {
1141
1141
 
1142
1142
  it('throws the original error if it includes a status code', function() {
1143
1143
  const expectedError = new Error();
1144
- expectedError.response = { status: faker.random.number() };
1144
+ expectedError.response = { status: faker.datatype.number() };
1145
1145
 
1146
1146
  sinon
1147
1147
  .stub(Auth0WebAuth.prototype, '_checkSession')
@@ -1,8 +1,8 @@
1
1
  import auth0 from 'auth0-js';
2
2
  import Auth0WebAuth from './auth0WebAuth';
3
- import PasswordGrantAuth from './passwordGrantAuth';
4
- import MachineAuth from './machineAuth';
5
3
  import * as sessionTypes from './index';
4
+ import MachineAuth from './machineAuth';
5
+ import PasswordGrantAuth from './passwordGrantAuth';
6
6
 
7
7
  describe('sessionTypes', function() {
8
8
  afterEach(function() {
@@ -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.random.number()
26
+ tokenExpiresAtBufferMs: faker.datatype.number()
27
27
  }
28
28
  }
29
29
  };
@@ -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.random.number({ min: 1000, max: 100000 });
364
+ expiresInMs = faker.datatype.number({ 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.random.number() };
521
+ expectedError.response = { status: faker.datatype.number() };
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.random.number({ min: 1, max: 10 })
546
+ faker.datatype.number({ 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.random.number({ min: 100, max: 1000 }),
163
+ expiresIn: faker.datatype.number({ min: 100, max: 1000 }),
164
164
  tokenType: 'Bearer'
165
165
  };
166
166
 
@@ -1,8 +1,8 @@
1
1
  import omit from 'lodash.omit';
2
2
  import URL from 'url-parse';
3
+ import * as objectUtils from '../objects';
3
4
  import formatOutputFieldDataFromServer from './formatOutputFieldDataFromServer';
4
5
  import * as iotUtils from './index';
5
- import * as objectUtils from '../objects';
6
6
 
7
7
  describe('utils/iot/formatOutputFieldDataFromServer', function() {
8
8
  let expectedOutputFieldDataRecords;
@@ -16,19 +16,19 @@ describe('utils/iot/formatOutputFieldDataFromServer', function() {
16
16
 
17
17
  beforeEach(function() {
18
18
  expectedOutputFieldMetadata = {
19
- count: faker.random.number(),
20
- hasMore: faker.random.boolean(),
19
+ count: faker.datatype.number(),
20
+ hasMore: faker.datatype.boolean(),
21
21
  nextRecordTime: Math.floor(faker.date.recent().getTime() / 1000)
22
22
  };
23
23
  expectedOutputFieldParsedMetadata = {
24
- limit: faker.random.number(),
24
+ limit: faker.datatype.number(),
25
25
  timeEnd: expectedOutputFieldMetadata.nextRecordTime,
26
26
  timeStart: Math.floor(faker.date.past().getTime() / 1000),
27
27
  window: faker.random.arrayElement([0, 60, 900, 3600])
28
28
  };
29
29
  expectedOutputFieldDataRecords = fixture.buildList(
30
30
  'outputFieldData',
31
- faker.random.number({ min: 1, max: 10 })
31
+ faker.datatype.number({ min: 1, max: 10 })
32
32
  );
33
33
  initialOutputFieldMetadata = omit(
34
34
  {
@@ -37,7 +37,7 @@ describe('utils/iot/formatOutputFieldDataFromServer', function() {
37
37
  next_page_url:
38
38
  faker.internet.url() +
39
39
  '/outputs/' +
40
- faker.random.number() +
40
+ faker.datatype.number() +
41
41
  '/fields/' +
42
42
  faker.hacker.noun() +
43
43
  '/data' +
@@ -7,7 +7,7 @@ describe('utils/iot/parseOutputFieldNextPageUrlMetadata', function() {
7
7
 
8
8
  beforeEach(function() {
9
9
  expectedMetadata = {
10
- limit: faker.random.number(),
10
+ limit: faker.datatype.number(),
11
11
  timeEnd: Math.floor(faker.date.recent().getTime() / 1000),
12
12
  timeStart: Math.floor(faker.date.past().getTime() / 1000),
13
13
  window: faker.random.arrayElement([0, 60, 900, 3600])
@@ -16,7 +16,7 @@ describe('utils/iot/parseOutputFieldNextPageUrlMetadata', function() {
16
16
  const url =
17
17
  faker.internet.url() +
18
18
  '/outputs/' +
19
- faker.random.number() +
19
+ faker.datatype.number() +
20
20
  '/fields/' +
21
21
  faker.hacker.noun() +
22
22
  '/data' +
@@ -18,7 +18,7 @@ describe('utils/pagination/formatPaginatedDataFromServer', function() {
18
18
 
19
19
  beforeEach(function() {
20
20
  expectedMetadata = fixture.build('paginationMetadata');
21
- expectedRecords = times(faker.random.number({ min: 1, max: 10 }), () =>
21
+ expectedRecords = times(faker.datatype.number({ min: 1, max: 10 }), () =>
22
22
  faker.helpers.createTransaction()
23
23
  );
24
24
  initialMetadata = fixture.build('paginationMetadata');
@@ -70,7 +70,7 @@ describe('utils/pagination/formatPaginatedDataFromServer', function() {
70
70
  beforeEach(function() {
71
71
  expectedRecords = fixture.buildList(
72
72
  'organization',
73
- faker.random.number({ min: 1, max: 10 })
73
+ faker.datatype.number({ min: 1, max: 10 })
74
74
  );
75
75
  initialRecords = expectedRecords.map((record) =>
76
76
  fixture.build('organization', record, { fromServer: true })
@@ -1,6 +1,5 @@
1
1
  import { expect } from 'chai';
2
2
  import faker from 'faker';
3
-
4
3
  import { stringifyParamsWithCommaSeparatedArrays } from './stringifyParams';
5
4
 
6
5
  const URL_ENCODED_COLON = '%3A';
@@ -19,9 +18,9 @@ describe('src/utils/url/stringifyParams.js', function() {
19
18
  let allParams;
20
19
 
21
20
  beforeEach(function() {
22
- value = { value: faker.random.number() };
21
+ value = { value: faker.datatype.number() };
23
22
  word = { word: faker.lorem.word() };
24
- uuid = { uuid: faker.random.uuid() };
23
+ uuid = { uuid: faker.datatype.uuid() };
25
24
  date = { date: faker.date.past().toISOString() };
26
25
 
27
26
  listValue1 = faker.lorem.word();
@@ -9,9 +9,9 @@ factory
9
9
  .sequence('id')
10
10
  .attrs({
11
11
  createdAt: () => faker.date.past().toISOString(),
12
- deviceToken: () => faker.random.uuid(),
13
- isActive: () => faker.random.boolean(),
14
- snsEndpointArn: () => faker.random.uuid(),
12
+ deviceToken: () => faker.datatype.uuid(),
13
+ isActive: () => faker.datatype.boolean(),
14
+ snsEndpointArn: () => faker.datatype.uuid(),
15
15
  updatedAt: () => faker.date.recent().toISOString(),
16
16
  userId: () => factory.build('eventUser').id
17
17
  })
@@ -6,15 +6,15 @@ const faker = require('faker');
6
6
  factory
7
7
  .define('applicationGrouping')
8
8
  .attrs({
9
- applicationId: () => faker.random.number(),
10
- id: () => faker.random.uuid(),
11
- index: () => faker.random.number(),
9
+ applicationId: () => faker.datatype.number(),
10
+ id: () => faker.datatype.uuid(),
11
+ index: () => faker.datatype.number(),
12
12
  label: () => faker.random.words()
13
13
  })
14
14
  .attr('applicationModules', ['id'], (id) => {
15
15
  return factory.buildList(
16
16
  'applicationModule',
17
- faker.random.number({ min: 1, max: 10 }),
17
+ faker.datatype.number({ min: 1, max: 10 }),
18
18
  { applicationGroupingId: id }
19
19
  );
20
20
  })
@@ -9,8 +9,8 @@ factory
9
9
  applicationGroupingId: () => factory.build('applicationGrouping').id,
10
10
  externalLink: () => faker.internet.url(),
11
11
  iconUrl: () => faker.internet.url(),
12
- id: () => faker.random.uuid(),
13
- index: () => faker.random.number(),
12
+ id: () => faker.datatype.uuid(),
13
+ index: () => faker.datatype.number(),
14
14
  label: () => faker.commerce.productName(),
15
15
  slug: () => `nsight-${faker.internet.domainWord()}`
16
16
  })
@@ -10,7 +10,7 @@ factory
10
10
  assetTypeId: () => factory.build('assetType').id,
11
11
  createdAt: () => faker.date.past().toISOString(),
12
12
  description: () => faker.hacker.phrase(),
13
- id: () => faker.random.uuid(),
13
+ id: () => faker.datatype.uuid(),
14
14
  label: () => faker.lorem.sentence(),
15
15
  organizationId: () => factory.build('organization').id,
16
16
  updatedAt: () => faker.date.recent().toISOString()
@@ -12,8 +12,8 @@ factory
12
12
  dataType: () =>
13
13
  faker.random.arrayElement(['boolean', 'date', 'number', 'string']),
14
14
  description: () => faker.lorem.sentence(),
15
- id: () => faker.random.uuid(),
16
- isRequired: () => faker.random.boolean(),
15
+ id: () => faker.datatype.uuid(),
16
+ isRequired: () => faker.datatype.boolean(),
17
17
  label: () => faker.hacker.phrase(),
18
18
  organizationId: () => factory.build('organization').id,
19
19
  units: () => faker.lorem.sentence(),
@@ -12,11 +12,11 @@ factory
12
12
  assetLabel: () => faker.lorem.word(),
13
13
  createdAt: () => faker.date.past().toISOString(),
14
14
  effectiveDate: () => faker.date.recent().toISOString(),
15
- id: () => faker.random.uuid(),
15
+ id: () => faker.datatype.uuid(),
16
16
  label: () => faker.lorem.word(),
17
17
  notes: () => faker.lorem.sentence(),
18
18
  updatedAt: () => faker.date.recent().toISOString(),
19
- value: () => `${faker.random.number()}`
19
+ value: () => `${faker.datatype.number()}`
20
20
  })
21
21
  .after((assetAttributeValue, options) => {
22
22
  // If building an asset attribute value object that comes from the server,
@@ -10,7 +10,7 @@ factory
10
10
  assetTypeId: () => factory.build('assetType').id,
11
11
  createdAt: () => faker.date.past().toISOString(),
12
12
  description: () => faker.lorem.sentence(),
13
- id: () => faker.random.uuid(),
13
+ id: () => faker.datatype.uuid(),
14
14
  label: () => faker.hacker.phrase(),
15
15
  organizationId: () => factory.build('organization').id,
16
16
  timeInterval: () =>
@@ -12,11 +12,11 @@ factory
12
12
  createdAt: () => faker.date.past().toISOString(),
13
13
  effectiveEndDate: () => faker.date.recent().toISOString(),
14
14
  effectiveStartDate: () => faker.date.past().toISOString(),
15
- id: () => faker.random.uuid(),
15
+ id: () => faker.datatype.uuid(),
16
16
  notes: () => faker.lorem.sentence(),
17
17
  updatedAt: () => faker.date.recent().toISOString(),
18
- value: () => `${faker.random.number()}`,
19
- isEstimated: () => faker.random.boolean()
18
+ value: () => `${faker.datatype.number()}`,
19
+ isEstimated: () => faker.datatype.boolean()
20
20
  })
21
21
  .after((assetMetricValue, options) => {
22
22
  // If building an asset metric value object that comes from the server,
@@ -5,8 +5,8 @@ factory
5
5
  .define('assetMetricValueCompact')
6
6
  .option('fromServer', false)
7
7
  .attrs({
8
- id: faker.random.uuid(),
9
- value: faker.random.number(),
8
+ id: faker.datatype.uuid(),
9
+ value: faker.datatype.number(),
10
10
  isEstimated: false,
11
11
  effectiveStartDate: faker.date.past().toISOString(),
12
12
  effectiveEndDate: faker.date.recent().toISOString()
@@ -9,7 +9,7 @@ factory
9
9
  .attrs({
10
10
  createdAt: () => faker.date.past().toISOString(),
11
11
  description: () => faker.hacker.phrase(),
12
- id: () => faker.random.uuid(),
12
+ id: () => faker.datatype.uuid(),
13
13
  label: () => faker.lorem.sentence(),
14
14
  organizationId: () => factory.build('organization').id,
15
15
  updatedAt: () => faker.date.recent().toISOString()
@@ -4,12 +4,12 @@ const factory = require('rosie').Factory;
4
4
  const faker = require('faker');
5
5
 
6
6
  factory.define('Auth0WebAuthSessionInfo').attrs({
7
- accessToken: () => faker.random.uuid(),
7
+ accessToken: () => faker.datatype.uuid(),
8
8
  expiresAt: () => sometimeSoon(2, 24)
9
9
  });
10
10
 
11
11
  factory.define('MachineAuthSessionInfo').attrs({
12
- apiToken: () => faker.random.uuid(),
12
+ apiToken: () => faker.datatype.uuid(),
13
13
  expiresAt: () => sometimeSoon(2, 24)
14
14
  });
15
15
 
@@ -24,7 +24,7 @@ const sometimeSoon = (minHours, maxHours) => {
24
24
  const date = new Date();
25
25
 
26
26
  let future = date.getTime();
27
- future += faker.random.number(range);
27
+ future += faker.datatype.number(range);
28
28
  date.setTime(future);
29
29
 
30
30
  return date;
@@ -7,7 +7,7 @@ factory
7
7
  .define('channel')
8
8
  .option('fromServer', false)
9
9
  .attrs({
10
- id: () => faker.random.uuid(),
10
+ id: () => faker.datatype.uuid(),
11
11
  name: () => faker.hacker.noun(),
12
12
  organizationId: () => factory.build('organization').id,
13
13
  serviceId: () => faker.internet.password()
@@ -7,15 +7,15 @@ factory
7
7
  .define('contxtApplication')
8
8
  .option('fromServer', false)
9
9
  .attrs({
10
- clientId: () => faker.random.uuid(),
11
- clientSecret: () => faker.random.uuid(),
10
+ clientId: () => faker.datatype.uuid(),
11
+ clientSecret: () => faker.datatype.uuid(),
12
12
  createdAt: () => faker.date.past().toISOString(),
13
- currentVersionId: () => faker.random.uuid(),
13
+ currentVersionId: () => faker.datatype.uuid(),
14
14
  description: () => faker.random.words(),
15
15
  iconUrl: () => faker.image.imageUrl(),
16
- id: () => faker.random.number(),
16
+ id: () => faker.datatype.number(),
17
17
  name: () => faker.name.title(),
18
- serviceId: () => faker.random.number(),
18
+ serviceId: () => faker.datatype.number(),
19
19
  type: () => faker.random.word(),
20
20
  updatedAt: () => faker.date.recent().toISOString()
21
21
  })
@@ -8,8 +8,8 @@ factory
8
8
  .option('fromServer', false)
9
9
  .attrs({
10
10
  createdAt: () => faker.date.past().toISOString(),
11
- id: () => faker.random.uuid(),
12
- legacyOrganizationId: () => faker.random.number(),
11
+ id: () => faker.datatype.uuid(),
12
+ legacyOrganizationId: () => faker.datatype.number(),
13
13
  name: () => faker.name.title(),
14
14
  updatedAt: () => faker.date.recent().toISOString()
15
15
  })
@@ -7,10 +7,10 @@ factory
7
7
  .define('contxtOrganizationFeaturedApplication')
8
8
  .option('fromServer', false)
9
9
  .attrs({
10
- applicationId: () => faker.random.number(),
10
+ applicationId: () => faker.datatype.number(),
11
11
  createdAt: () => faker.date.past().toISOString(),
12
- id: () => faker.random.uuid(),
13
- organizationId: () => faker.random.uuid(),
12
+ id: () => faker.datatype.uuid(),
13
+ organizationId: () => faker.datatype.uuid(),
14
14
  updatedAt: () => faker.date.recent().toISOString()
15
15
  })
16
16
  .after((featuredApp, options) => {
@@ -10,10 +10,10 @@ factory
10
10
  createdAt: () => faker.date.past().toISOString(),
11
11
  createdBy: () => factory.build('contxtUser').id,
12
12
  description: () => faker.random.words(),
13
- id: () => faker.random.number(),
13
+ id: () => faker.datatype.number(),
14
14
  name: () => faker.name.title(),
15
15
  organizationId: () => factory.build('contxtOrganization').id,
16
- ownerRoleId: () => faker.random.uuid(),
16
+ ownerRoleId: () => faker.datatype.uuid(),
17
17
  slug: () => faker.random.word(),
18
18
  type: () => faker.random.word(),
19
19
  updatedAt: () => faker.date.recent().toISOString()
@@ -9,10 +9,10 @@ factory
9
9
  .attrs({
10
10
  createdAt: () => faker.date.past().toISOString(),
11
11
  updatedAt: () => faker.date.recent().toISOString(),
12
- id: () => faker.random.uuid(),
12
+ id: () => faker.datatype.uuid(),
13
13
  organizationId: () => factory.build('contxtOrganization').id,
14
14
  projectId: () => factory.build('contxtProject').id,
15
- clusterId: () => faker.random.uuid(),
15
+ clusterId: () => faker.datatype.uuid(),
16
16
  slug: () => `${faker.random.word()}-${faker.random.word()}`,
17
17
  name: () => faker.name.title(),
18
18
  type: () => faker.random.word(),
@@ -10,17 +10,17 @@ factory
10
10
  applications: () =>
11
11
  factory.buildList(
12
12
  'contxtApplication',
13
- faker.random.number({ min: 0, max: 10 })
13
+ faker.datatype.number({ min: 0, max: 10 })
14
14
  ),
15
15
  createdAt: () => faker.date.past().toISOString(),
16
16
  description: () => faker.hacker.phrase(),
17
- id: () => faker.random.uuid(),
17
+ id: () => faker.datatype.uuid(),
18
18
  name: () => faker.name.title(),
19
19
  organizationId: () => factory.build('contxtOrganization').id,
20
20
  projects: () =>
21
21
  factory.buildList(
22
22
  'contxtProject',
23
- faker.random.number({ min: 0, max: 10 })
23
+ faker.datatype.number({ min: 0, max: 10 })
24
24
  ),
25
25
  updatedAt: () => faker.date.recent().toISOString()
26
26
  })
@@ -9,7 +9,7 @@ factory
9
9
  .attrs({
10
10
  applicationId: () => factory.build('contxtApplication').id,
11
11
  createdAt: () => faker.date.past().toISOString(),
12
- id: () => faker.random.uuid(),
12
+ id: () => faker.datatype.uuid(),
13
13
  updatedAt: () => faker.date.recent().toISOString(),
14
14
  roleId: () => factory.build('contxtRole').id
15
15
  })
@@ -9,7 +9,7 @@ factory
9
9
  .attrs({
10
10
  accessType: () => faker.random.arrayElement(['reader', 'admin']),
11
11
  createdAt: () => faker.date.past().toISOString(),
12
- id: () => faker.random.uuid(),
12
+ id: () => faker.datatype.uuid(),
13
13
  environmentId: () => factory.build('contxtProjectEnvironment').id,
14
14
  updatedAt: () => faker.date.recent().toISOString(),
15
15
  roleId: () => factory.build('contxtRole').id
@@ -11,8 +11,8 @@ factory
11
11
  email: () => faker.internet.email(),
12
12
  firstName: () => faker.name.firstName(),
13
13
  id: () => `auth0|${faker.internet.password()}`,
14
- isActivated: () => faker.random.boolean(),
15
- isSuperuser: () => faker.random.boolean(),
14
+ isActivated: () => faker.datatype.boolean(),
15
+ isSuperuser: () => faker.datatype.boolean(),
16
16
  lastName: () => faker.name.lastName(),
17
17
  phoneNumber: () => faker.phone.phoneNumber(),
18
18
  updatedAt: () => faker.date.recent().toISOString()