@itentialopensource/adapter-utils 6.1.11 → 6.1.12

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.
@@ -152,23 +152,17 @@ function walkThroughActionFiles(directory) {
152
152
  // if invalid properties throw an error
153
153
  if (!result) {
154
154
  // Get the action and component from the first ajv error
155
- let action = 'checkErrorDetails';
156
- let component = 'checkErrorDetails';
157
- const temp = validate.errors[0].dataPath;
158
- const actStInd = temp.indexOf('[');
159
- const actEndInd = temp.indexOf(']');
160
- // if we have indexes for the action we can get specifics
161
- if (actStInd >= 0 && actEndInd > actStInd) {
162
- const actNum = temp.substring(actStInd + 1, actEndInd);
163
- // get the action name from the number
164
- if (actions.actions.length >= actNum) {
165
- action = actions.actions[actNum].name;
166
- }
167
- // get the component that failed for the action
168
- if (temp.length > actEndInd + 1) {
169
- component = temp.substring(actEndInd + 2);
170
- }
171
- }
155
+ const instancePath = validate.errors?.[0]?.instancePath || '';
156
+ const match = instancePath.match(/\/actions\/(\d+)/);
157
+ const actNum = match ? parseInt(match[1], 10) : undefined;
158
+ // Get action name
159
+ const action = actions.actions?.[actNum]?.name ?? 'checkErrorDetails';
160
+ // Get component from remaining path
161
+ const remainingPath = match ? instancePath.substring(match[0].length) : '';
162
+ const component = remainingPath.length > 1
163
+ ? remainingPath.substring(1)
164
+ : 'checkErrorDetails';
165
+
172
166
  let msg = `${origin}: Error on validation of actions for entity `;
173
167
  msg += `${entities[e]} - ${action} - ${component} Details: ${JSON.stringify(validate.errors)}`;
174
168
  clean.push(msg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "6.1.11",
3
+ "version": "6.1.12",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",