@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,260 +0,0 @@
1
- import has from 'lodash.has';
2
- import isPlainObject from 'lodash.isplainobject';
3
- import { toCamelCase, toSnakeCase } from '../utils/objects';
4
- import { formatPaginatedDataFromServer } from '../utils/pagination';
5
-
6
- /**
7
- * @typedef {Object} AssetType
8
- * @property {string} createdAt ISO 8601 Extended Format date/time string
9
- * @property {string} description
10
- * @property {string} id UUID
11
- * @property {string} label
12
- * @property {string} organizationId UUID corresponding with the organization
13
- * @property {string} updatedAt ISO 8601 Extended Format date/time string
14
- */
15
-
16
- /**
17
- * @typedef {Object} AssetTypesFromServer
18
- * @property {Object} _metadata Metadata about the pagination settings
19
- * @property {number} _metadata.offset Offset of records in subsequent queries
20
- * @property {number} _metadata.totalRecords Total number of asset types found
21
- * @property {AssetType[]} records
22
- */
23
-
24
- /**
25
- * Module that provides access to, and the manipulation of, information about different asset types
26
- *
27
- * @typicalname contxtSdk.assets.types
28
- */
29
- class AssetTypes {
30
- /**
31
- * @param {Object} sdk An instance of the SDK so the module can communicate with other modules.
32
- * @param {Object} request An instance of the request module tied to this module's audience.
33
- * @param {string} baseUrl The base URL provided by the parent module
34
- */
35
- constructor(sdk, request, baseUrl) {
36
- this._baseUrl = baseUrl;
37
- this._request = request;
38
- this._sdk = sdk;
39
- }
40
-
41
- /**
42
- * Creates a new asset type
43
- *
44
- * API Endpoint: '/assets/types'
45
- * Method: POST
46
- *
47
- * @param {Object} assetType
48
- * @param {string} assetType.description
49
- * @param {string} assetType.label
50
- * @param {string} assetType.organizationId The ID of the asset type's parent organization. Can be
51
- * explicitly set to `null` to create a global asset type
52
- *
53
- * @returns {Promise}
54
- * @fulfill {AssetType} Information about the new asset type
55
- * @reject {Error}
56
- *
57
- * @example
58
- * contxtSdk.assets.types
59
- * .create({
60
- * description: 'A physicial facility building',
61
- * label: 'Facility',
62
- * organizationId: 'b47e45af-3e18-408a-8070-008f9e6d7b42'
63
- * })
64
- * .then((assetType) => console.log(assetType))
65
- * .catch((err) => console.log(err));
66
- */
67
- create(assetType = {}) {
68
- const hasFieldFns = {
69
- default: (object, key) => !!object[key],
70
- organizationId: (object, key) => has(object, key)
71
- };
72
- const requiredFields = ['description', 'label', 'organizationId'];
73
-
74
- for (let i = 0; i < requiredFields.length; i++) {
75
- const field = requiredFields[i];
76
- const hasField = hasFieldFns[field] || hasFieldFns.default;
77
-
78
- if (!hasField(assetType, field)) {
79
- return Promise.reject(
80
- new Error(`A ${field} is required to create a new asset type.`)
81
- );
82
- }
83
- }
84
-
85
- return this._request
86
- .post(`${this._baseUrl}/assets/types`, toSnakeCase(assetType))
87
- .then((assetType) => toCamelCase(assetType));
88
- }
89
-
90
- /**
91
- * Deletes an asset type
92
- *
93
- * API Endpoint: '/assets/types/:assetTypeId'
94
- * Method: DELETE
95
- *
96
- * @param {string} assetTypeId The ID of the asset type (formatted as a UUID)
97
- *
98
- * @returns {Promise}
99
- * @fulfill {undefined}
100
- * @reject {Error}
101
- *
102
- * @example
103
- * contxtSdk.assets.types.delete('4f0e51c6-728b-4892-9863-6d002e61204d')
104
- */
105
- delete(assetTypeId) {
106
- if (!assetTypeId) {
107
- return Promise.reject(
108
- new Error('An asset type ID is required for deleting an asset type.')
109
- );
110
- }
111
-
112
- return this._request.delete(`${this._baseUrl}/assets/types/${assetTypeId}`);
113
- }
114
-
115
- /**
116
- * Gets information about an asset type
117
- *
118
- * API Endpoint: '/assets/types/:assetTypeId'
119
- * Method: GET
120
- *
121
- * @param {string} assetTypeId The ID of the asset type (formatted as a UUID)
122
- *
123
- * @returns {Promise}
124
- * @fulfill {AssetType} Information about the asset type
125
- * @reject {Error}
126
- *
127
- * @example
128
- * contxtSdk.assets.types
129
- * .get('4f0e51c6-728b-4892-9863-6d002e61204d')
130
- * .then((assetType) => console.log(assetType))
131
- * .catch((err) => console.log(err));
132
- */
133
- get(assetTypeId) {
134
- if (!assetTypeId) {
135
- return Promise.reject(
136
- new Error(
137
- 'An asset type ID is required for getting information about an asset type.'
138
- )
139
- );
140
- }
141
-
142
- return this._request
143
- .get(`${this._baseUrl}/assets/types/${assetTypeId}`)
144
- .then((assetType) => toCamelCase(assetType));
145
- }
146
-
147
- /**
148
- * Gets a list of all asset types
149
- *
150
- * API Endpoint: '/assets/types/
151
- * Method: GET
152
- *
153
- * @param {PaginationOptions} [paginationOptions]
154
- *
155
- * @returns {Promise}
156
- * @fulfill {AssetTypesFromServer}
157
- * @reject {Error}
158
- *
159
- * @example
160
- * contxtSdk.assets.types
161
- * .getAll()
162
- * .then((assetTypes) => console.log(assetTypes))
163
- * .catch((err) => console.log(err));
164
- */
165
- getAll(paginationOptions) {
166
- return this._request
167
- .get(`${this._baseUrl}/assets/types`, {
168
- params: toSnakeCase(paginationOptions)
169
- })
170
- .then((assetTypesData) => formatPaginatedDataFromServer(assetTypesData));
171
- }
172
-
173
- /**
174
- * Gets a list of all asset types that belong to a particular organization
175
- *
176
- * API Endpoint: '/organizations/:organizationId/assets/types'
177
- * Method: GET
178
- *
179
- * @param {string} organizationId UUID corresponding with an organization
180
- * @param {PaginationOptions} [paginationOptions]
181
- *
182
- * @returns {Promise}
183
- * @fulfill {AssetTypesFromServer}
184
- * @reject {Error}
185
- *
186
- * @example
187
- * contxtSdk.assets.types
188
- * .getAllByOrganizationId('53fba880-70b7-47a2-b4e3-ad9ecfb67d5c')
189
- * .then((assetTypes) => console.log(assetTypes))
190
- * .catch((err) => console.log(assetTypes));
191
- */
192
- getAllByOrganizationId(organizationId, paginationOptions) {
193
- if (!organizationId) {
194
- return Promise.reject(
195
- new Error(
196
- "An organization ID is required for getting a list of an organization's asset types."
197
- )
198
- );
199
- }
200
-
201
- return this._request
202
- .get(`${this._baseUrl}/organizations/${organizationId}/assets/types`, {
203
- params: toSnakeCase(paginationOptions)
204
- })
205
- .then((assetTypesData) => formatPaginatedDataFromServer(assetTypesData));
206
- }
207
-
208
- /**
209
- * Updates an asset type's data
210
- *
211
- * API Endpoint: '/assets/types/:assetTypeId'
212
- * Method: PUT
213
- *
214
- * @param {string} assetTypeId The ID of the asset type to update (formatted as a UUID)
215
- * @param {Object} update An object containing the updated data for the asset type
216
- * @param {string} update.description
217
- *
218
- * @returns {Promise}
219
- * @fulfill {undefined}
220
- * @reject {Error}
221
- *
222
- * @example
223
- * contxtSdk.assets.types
224
- * .update('5f310899-d8f9-4dac-ae82-cedb2048a8ef', {
225
- * description: 'A physical facility building'
226
- * });
227
- */
228
- update(assetTypeId, update) {
229
- if (!assetTypeId) {
230
- return Promise.reject(
231
- new Error('An asset type ID is required to update an asset type.')
232
- );
233
- }
234
-
235
- if (!update) {
236
- return Promise.reject(
237
- new Error('An update is required to update an asset type.')
238
- );
239
- }
240
-
241
- if (!isPlainObject(update)) {
242
- return Promise.reject(
243
- new Error(
244
- 'The asset type update must be a well-formed object with the data you wish to update.'
245
- )
246
- );
247
- }
248
-
249
- const formattedUpdate = toSnakeCase(update, {
250
- excludeKeys: ['id', 'label', 'organizationId']
251
- });
252
-
253
- return this._request.put(
254
- `${this._baseUrl}/assets/types/${assetTypeId}`,
255
- formattedUpdate
256
- );
257
- }
258
- }
259
-
260
- export default AssetTypes;