@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
@@ -1,320 +0,0 @@
1
- import isPlainObject from 'lodash.isplainobject';
2
- import { toCamelCase, toSnakeCase } from '../utils/objects';
3
-
4
- /**
5
- * @typedef {Object} FacilityGrouping
6
- * @param {string} createdAt ISO 8601 Extended Format date/time string
7
- * @param {string} [description]
8
- * @param {Facility[]} [facilities]
9
- * @param {string} id UUID
10
- * @param {boolean} isPrivate
11
- * @param {string} name
12
- * @param {string} organizationId UUID
13
- * @param {string} ownerId Auth0 identifer of the user
14
- * @param {string} [parentGroupingId] UUID
15
- * @param {string} updatedAt ISO 8601 Extended Format date/time string
16
- */
17
-
18
- /**
19
- * @typedef {Object} FacilityGroupingFacility
20
- * @param {string} createdAt ISO 8601 Extended Format date/time string
21
- * @param {string} facilityGroupingId UUID
22
- * @param {number} facilityId
23
- * @param {string} id UUID
24
- * @param {string} updatedAt ISO 8601 Extended Format date/time string
25
- */
26
-
27
- /**
28
- * Module that provides access to facility groupings, and helps manage
29
- * the relationship between those groupings and facilities
30
- *
31
- * @typicalname contxtSdk.facilities.groupings
32
- */
33
- class FacilityGroupings {
34
- /**
35
- * @param {Object} sdk An instance of the SDK so the module can communicate with other modules
36
- * @param {Object} request An instance of the request module tied to this module's audience.
37
- * @param {string} baseUrl The base URL provided by the parent module
38
- */
39
- constructor(sdk, request, baseUrl) {
40
- this._baseUrl = baseUrl;
41
- this._request = request;
42
- this._sdk = sdk;
43
- }
44
-
45
- /**
46
- * Adds a facility to a facility grouping
47
- *
48
- * API Endpoint: '/groupings/:facilityGroupingId/facilities/:facilityId'
49
- * Method: POST
50
- *
51
- * @param {string} facilityGroupingId UUID corresponding with a facility grouping
52
- * @param {number} facilityId
53
- *
54
- * @returns {Promise}
55
- * @fulfill {FacilityGroupingFacility} Information about the new facility/grouping relationship
56
- * @reject {Error}
57
- *
58
- * @example
59
- * contxtSdk.facilities.groupings
60
- * .addFacility('b3dbaae3-25dd-475b-80dc-66296630a8d0', 4)
61
- * .then((grouping) => console.log(grouping))
62
- * .catch((err) => console.log(err));
63
- */
64
- addFacility(facilityGroupingId, facilityId) {
65
- let errorMsg;
66
-
67
- if (!facilityGroupingId) {
68
- errorMsg =
69
- 'A facilityGroupingId is required to create a relationship between a facility grouping and a facility.';
70
- } else if (!facilityId) {
71
- errorMsg =
72
- 'A facilityId is required to create a relationship between a facility grouping and a facility.';
73
- }
74
-
75
- if (errorMsg) {
76
- return Promise.reject(new Error(errorMsg));
77
- }
78
-
79
- return this._request
80
- .post(
81
- `${
82
- this._baseUrl
83
- }/groupings/${facilityGroupingId}/facility/${facilityId}`
84
- )
85
- .then((groupingFacility) => toCamelCase(groupingFacility));
86
- }
87
-
88
- /**
89
- * Creates a new facility grouping
90
- *
91
- * API Endpoint: '/groupings'
92
- * Method: POST
93
- *
94
- * @param {Object} facilityGrouping
95
- * @param {string} [facilityGrouping.description]
96
- * @param {boolean} [facilityGrouping.isPrivate = false]
97
- * @param {string} facilityGrouping.name
98
- * @param {string} facilityGrouping.organizationId UUID
99
- * @param {string} [facilityGrouping.parentGroupingId] UUID
100
- *
101
- * @returns {Promise}
102
- * @fulfill {FacilityGrouping} Information about the new facility grouping
103
- * @reject {Error}
104
- *
105
- * @example
106
- * contxtSdk.facilities.groupings
107
- * .create({
108
- * description: 'US States of CT, MA, ME, NH, RI, VT',
109
- * isPrivate: false,
110
- * name: 'New England, USA',
111
- * organizationId: '61f5fe1d-d202-4ae7-af76-8f37f5bbeec5',
112
- * parentGroupingId: 'e9f8f89c-609c-4c83-8ebc-cea928af661e'
113
- * })
114
- * .then((grouping) => console.log(grouping))
115
- * .catch((err) => console.log(err));
116
- */
117
- create(grouping = {}) {
118
- const requiredFields = ['name', 'organizationId'];
119
-
120
- for (let i = 0; requiredFields.length > i; i++) {
121
- const field = requiredFields[i];
122
-
123
- if (!grouping[field]) {
124
- return Promise.reject(
125
- new Error(`A ${field} is required to create a new facility grouping.`)
126
- );
127
- }
128
- }
129
-
130
- return this._request
131
- .post(`${this._baseUrl}/groupings`, toSnakeCase(grouping))
132
- .then((grouping) => toCamelCase(grouping));
133
- }
134
-
135
- /**
136
- * Delete a facility groupings
137
- *
138
- * API Endpoint: '/groupings/:facilityGroupingId'
139
- * Method: DELETE
140
- *
141
- * @param {string} facilityGroupingId The id of the facility grouping (formatted as a UUID)
142
- *
143
- * @returns {Promise}
144
- * @fulfill {undefined}
145
- * @reject {Error}
146
- *
147
- * @example
148
- * contxtSdk.facilities.groupings.delete(
149
- * 'e4fec739-56aa-4b50-8dab-e9d6b9c91a5d'
150
- * );
151
- */
152
- delete(facilityGroupingId) {
153
- if (!facilityGroupingId) {
154
- return Promise.reject(
155
- new Error(
156
- 'A facility grouping id is required for deleting a facility grouping.'
157
- )
158
- );
159
- }
160
-
161
- return this._request.delete(
162
- `${this._baseUrl}/groupings/${facilityGroupingId}`
163
- );
164
- }
165
-
166
- /**
167
- * Get a listing of all facility groupings available to a user. Includes public groupings across
168
- * any organization the user has access to and the user's private groupings.
169
- *
170
- * API Endpoint: '/groupings'
171
- * Method: GET
172
- *
173
- * @returns {Promise}
174
- * @fulfill {FacilityGrouping[]}
175
- * @reject {Error}
176
- *
177
- * @example
178
- * contxtSdk.facilites.groupings
179
- * .getAll()
180
- * .then((groupings) => console.log(groupings))
181
- * .catch((err) => console.log(err));
182
- */
183
- getAll() {
184
- return this._request
185
- .get(`${this._baseUrl}/groupings`)
186
- .then((groupings) => toCamelCase(groupings));
187
- }
188
-
189
- /**
190
- * Get a listing of all facility groupings for an organization. Includes public groupings
191
- * across that specific organization and the user's private groupings for that organization.
192
- *
193
- * API Endpoint: '/organizations/:organizationId/groupings'
194
- * Method: GET
195
- *
196
- * @param {string} organizationId UUID corresponding with an organization
197
- *
198
- * @returns {Promise}
199
- * @fulfill {FacilityGrouping[]}
200
- * @reject {Error}
201
- *
202
- * @example
203
- * contxtSdk.facilites.groupings
204
- * .getAllByOrganizationId('349dbd36-5dca-4a10-b54d-d0f71c3c8709')
205
- * .then((groupings) => console.log(groupings))
206
- * .catch((err) => console.log(err));
207
- */
208
- getAllByOrganizationId(organizationId) {
209
- if (!organizationId) {
210
- return Promise.reject(
211
- new Error(
212
- "An organization id is required for getting a list of an organization's facility groupings"
213
- )
214
- );
215
- }
216
-
217
- return this._request
218
- .get(`${this._baseUrl}/organizations/${organizationId}/groupings`)
219
- .then((groupings) => toCamelCase(groupings));
220
- }
221
-
222
- /**
223
- * Removes a facility from a facility grouping
224
- *
225
- * API Endpoint: '/groupings/:facilityGroupingId/facilities/:facilityId'
226
- * Method: DELETE
227
- *
228
- * @param {string} facilityGroupingId UUID corresponding with a facility grouping
229
- * @param {number} facilityId
230
- *
231
- * @returns {Promise}
232
- * @reject {Error}
233
- *
234
- * @example
235
- * contxtSdk.facilities.groupings
236
- * .removeFacility('b3dbaae3-25dd-475b-80dc-66296630a8d0', 4)
237
- * .catch((err) => console.log(err));
238
- */
239
- removeFacility(facilityGroupingId, facilityId) {
240
- let errorMsg;
241
-
242
- if (!facilityGroupingId) {
243
- errorMsg =
244
- 'A facilityGroupingId is required to remove a relationship between a facility grouping and a facility.';
245
- } else if (!facilityId) {
246
- errorMsg =
247
- 'A facilityId is required to remove a relationship between a facility grouping and a facility.';
248
- }
249
-
250
- if (errorMsg) {
251
- return Promise.reject(new Error(errorMsg));
252
- }
253
-
254
- return this._request.delete(
255
- `${this._baseUrl}/groupings/${facilityGroupingId}/facility/${facilityId}`
256
- );
257
- }
258
-
259
- /**
260
- * Updates an existing facility grouping
261
- *
262
- * API Endpoint: '/groupings/:facilityGroupingId'
263
- * Method: PUT
264
- *
265
- * @param {String} facilityGroupingId
266
- * @param {Object} update
267
- * @param {string} [update.description]
268
- * @param {boolean} [update.isPrivate]
269
- * @param {string} [update.name]
270
- * @param {string} [update.parentGroupingId] UUID corresponding with another facility grouping
271
- *
272
- * @returns {Promise}
273
- * @fulfill {FacilityGrouping} Information about the updated facility grouping
274
- * @reject {Error}
275
- *
276
- * @example
277
- * contxtSdk.facilities.groupings
278
- * .update('b3dbaae3-25dd-475b-80dc-66296630a8d0', {
279
- * description: 'US States of CT, MA, ME, NH, RI, VT',
280
- * isPrivate: false,
281
- * name: 'New England, USA',
282
- * parentGroupingId: 'e9f8f89c-609c-4c83-8ebc-cea928af661e'
283
- * })
284
- * .then((grouping) => console.log(grouping))
285
- * .catch((err) => console.log(err));
286
- */
287
- update(facilityGroupingId, update) {
288
- if (!facilityGroupingId) {
289
- return Promise.reject(
290
- new Error(
291
- 'A facility grouping id is required to update a facility grouping.'
292
- )
293
- );
294
- }
295
-
296
- if (!update) {
297
- return Promise.reject(
298
- new Error('An update is required to update a facility grouping')
299
- );
300
- }
301
-
302
- if (!isPlainObject(update)) {
303
- return Promise.reject(
304
- new Error(
305
- 'The facility grouping update must be a well-formed object with the data you wish to update.'
306
- )
307
- );
308
- }
309
-
310
- const formattedUpdate = toSnakeCase(update, {
311
- excludeKeys: ['id', 'organizationId', 'ownerId']
312
- });
313
-
314
- return this._request
315
- .put(`${this._baseUrl}/groupings/${facilityGroupingId}`, formattedUpdate)
316
- .then((grouping) => toCamelCase(grouping));
317
- }
318
- }
319
-
320
- export default FacilityGroupings;