@ndustrial/contxt-sdk 4.3.6 → 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.
- package/.gitattributes +1 -0
- package/CHANGELOG.md +8 -0
- package/docs/Facilities.md +0 -144
- package/docs/FacilityGroupings.md +0 -160
- package/docs/Nionic.md +63 -0
- package/docs/README.md +3 -29
- package/docs/Typedefs.md +0 -101
- package/esm/config/audiences.js +13 -13
- package/esm/config/audiences.js.map +1 -1
- package/esm/index.js +3 -6
- package/esm/index.js.map +1 -1
- package/esm/nionic/index.js +126 -0
- package/esm/nionic/index.js.map +1 -0
- package/lib/config/audiences.js +13 -13
- package/lib/config/audiences.js.map +1 -1
- package/lib/index.js +19 -13
- package/lib/index.js.map +1 -1
- package/lib/nionic/index.js +130 -0
- package/lib/nionic/index.js.map +1 -0
- package/meta.yaml +11 -0
- package/package.json +9 -10
- package/src/bus/index.spec.js +3 -2
- package/src/bus/webSocketConnection.spec.js +31 -31
- package/src/config/audiences.js +13 -13
- package/src/config/index.spec.js +6 -6
- package/src/coordinator/applications.spec.js +8 -8
- package/src/coordinator/consent.spec.js +1 -1
- package/src/coordinator/edgeNodes.spec.js +3 -3
- package/src/coordinator/organizations.spec.js +4 -4
- package/src/coordinator/permissions.spec.js +4 -4
- package/src/coordinator/roles.spec.js +3 -3
- package/src/coordinator/users.spec.js +14 -15
- package/src/events/index.spec.js +16 -16
- package/src/files/index.spec.js +7 -7
- package/src/index.js +3 -6
- package/src/index.spec.js +8 -22
- package/src/iot/feeds.spec.js +4 -4
- package/src/iot/fieldCategories.spec.js +4 -4
- package/src/iot/fieldGroupings.spec.js +5 -5
- package/src/iot/outputs.spec.js +6 -6
- package/src/nionic/index.js +151 -0
- package/src/request.spec.js +3 -3
- package/src/sessionTypes/auth0WebAuth.spec.js +2 -2
- package/src/sessionTypes/index.spec.js +3 -3
- package/src/sessionTypes/machineAuth.spec.js +3 -3
- package/src/sessionTypes/passwordGrantAuth.spec.js +1 -1
- package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +6 -6
- package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.spec.js +2 -2
- package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +2 -2
- package/src/utils/url/stringifyParams.spec.js +2 -3
- package/support/fixtures/factories/IOSDevice.js +3 -3
- package/support/fixtures/factories/applicationGrouping.js +4 -4
- package/support/fixtures/factories/applicationModule.js +2 -2
- package/support/fixtures/factories/asset.js +1 -1
- package/support/fixtures/factories/assetAttribute.js +2 -2
- package/support/fixtures/factories/assetAttributeValue.js +2 -2
- package/support/fixtures/factories/assetMetric.js +1 -1
- package/support/fixtures/factories/assetMetricValue.js +3 -3
- package/support/fixtures/factories/assetMetricValueCompact.js +2 -2
- package/support/fixtures/factories/assetType.js +1 -1
- package/support/fixtures/factories/authResults.js +3 -3
- package/support/fixtures/factories/channel.js +1 -1
- package/support/fixtures/factories/contxtApplication.js +5 -5
- package/support/fixtures/factories/contxtOrganization.js +2 -2
- package/support/fixtures/factories/contxtOrganizationFeaturedApplication.js +3 -3
- package/support/fixtures/factories/contxtProject.js +2 -2
- package/support/fixtures/factories/contxtProjectEnvironment.js +2 -2
- package/support/fixtures/factories/contxtRole.js +3 -3
- package/support/fixtures/factories/contxtRoleApplication.js +1 -1
- package/support/fixtures/factories/contxtRoleProjectEnvironment.js +1 -1
- package/support/fixtures/factories/contxtUser.js +2 -2
- package/support/fixtures/factories/contxtUserApplication.js +1 -1
- package/support/fixtures/factories/contxtUserFavoriteApplication.js +2 -2
- package/support/fixtures/factories/contxtUserPermissions.js +5 -5
- package/support/fixtures/factories/contxtUserProjectEnvironment.js +1 -1
- package/support/fixtures/factories/contxtUserRole.js +2 -2
- package/support/fixtures/factories/costCenter.js +2 -2
- package/support/fixtures/factories/costCenterFacility.js +3 -3
- package/support/fixtures/factories/edgeNode.js +1 -1
- package/support/fixtures/factories/event.js +5 -5
- package/support/fixtures/factories/eventType.js +4 -4
- package/support/fixtures/factories/eventUser.js +5 -5
- package/support/fixtures/factories/facility.js +4 -4
- package/support/fixtures/factories/facilityGrouping.js +3 -3
- package/support/fixtures/factories/facilityGroupingFacility.js +3 -3
- package/support/fixtures/factories/facilityInfo.js +2 -2
- package/support/fixtures/factories/facilityTag.js +1 -1
- package/support/fixtures/factories/feedStatus.js +1 -1
- package/support/fixtures/factories/feedType.js +1 -1
- package/support/fixtures/factories/feeds.js +5 -5
- package/support/fixtures/factories/fieldCategory.js +3 -3
- package/support/fixtures/factories/fieldGrouping.js +4 -4
- package/support/fixtures/factories/fieldGroupingField.js +3 -3
- package/support/fixtures/factories/fieldGroupingStatus.js +1 -1
- package/support/fixtures/factories/file.js +1 -1
- package/support/fixtures/factories/fileUploadInfo.js +1 -1
- package/support/fixtures/factories/organization.js +1 -1
- package/support/fixtures/factories/outputField.js +10 -10
- package/support/fixtures/factories/outputFieldData.js +1 -1
- package/support/fixtures/factories/owner.js +2 -2
- package/support/fixtures/factories/paginationMetadata.js +2 -2
- package/support/fixtures/factories/triggeredEvent.js +4 -4
- package/support/fixtures/factories/userEventSubscription.js +1 -1
- package/support/fixtures/factories/userMobileNumber.js +1 -1
- package/support/fixtures/factories/userPermissionsMap.js +2 -2
- package/.huskyrc.js +0 -11
- package/.nycrc +0 -12
- package/esm/assets/assetAttributes.js +0 -574
- package/esm/assets/assetAttributes.js.map +0 -1
- package/esm/assets/assetMetrics.js +0 -690
- package/esm/assets/assetMetrics.js.map +0 -1
- package/esm/assets/assetTypes.js +0 -273
- package/esm/assets/assetTypes.js.map +0 -1
- package/esm/assets/index.js +0 -283
- package/esm/assets/index.js.map +0 -1
- package/esm/facilities/costCenters.js +0 -306
- package/esm/facilities/costCenters.js.map +0 -1
- package/esm/facilities/groupings.js +0 -323
- package/esm/facilities/groupings.js.map +0 -1
- package/esm/facilities/index.js +0 -343
- package/esm/facilities/index.js.map +0 -1
- package/esm/health/index.js +0 -229
- package/esm/health/index.js.map +0 -1
- package/esm/utils/facilities/formatFacilityWithInfoFromServer.js +0 -65
- package/esm/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
- package/esm/utils/facilities/index.js +0 -4
- package/esm/utils/facilities/index.js.map +0 -1
- package/lib/assets/assetAttributes.js +0 -588
- package/lib/assets/assetAttributes.js.map +0 -1
- package/lib/assets/assetMetrics.js +0 -705
- package/lib/assets/assetMetrics.js.map +0 -1
- package/lib/assets/assetTypes.js +0 -287
- package/lib/assets/assetTypes.js.map +0 -1
- package/lib/assets/index.js +0 -302
- package/lib/assets/index.js.map +0 -1
- package/lib/facilities/costCenters.js +0 -316
- package/lib/facilities/costCenters.js.map +0 -1
- package/lib/facilities/groupings.js +0 -333
- package/lib/facilities/groupings.js.map +0 -1
- package/lib/facilities/index.js +0 -360
- package/lib/facilities/index.js.map +0 -1
- package/lib/health/index.js +0 -232
- package/lib/health/index.js.map +0 -1
- package/lib/utils/facilities/formatFacilityWithInfoFromServer.js +0 -71
- package/lib/utils/facilities/formatFacilityWithInfoFromServer.js.map +0 -1
- package/lib/utils/facilities/index.js +0 -15
- package/lib/utils/facilities/index.js.map +0 -1
- package/src/assets/assetAttributes.js +0 -619
- package/src/assets/assetAttributes.spec.js +0 -1143
- package/src/assets/assetMetrics.js +0 -736
- package/src/assets/assetMetrics.spec.js +0 -1180
- package/src/assets/assetTypes.js +0 -260
- package/src/assets/assetTypes.spec.js +0 -556
- package/src/assets/index.js +0 -271
- package/src/assets/index.spec.js +0 -515
- package/src/facilities/costCenters.js +0 -295
- package/src/facilities/costCenters.spec.js +0 -529
- package/src/facilities/groupings.js +0 -320
- package/src/facilities/groupings.spec.js +0 -567
- package/src/facilities/index.js +0 -343
- package/src/facilities/index.spec.js +0 -551
- package/src/health/index.js +0 -200
- package/src/health/index.spec.js +0 -501
- package/src/utils/facilities/formatFacilityWithInfoFromServer.js +0 -62
- package/src/utils/facilities/formatFacilityWithInfoFromServer.spec.js +0 -73
- package/src/utils/facilities/index.js +0 -3
package/src/assets/assetTypes.js
DELETED
|
@@ -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;
|