@itentialopensource/adapter-utils 6.1.10 → 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.
- package/lib/requestHandler.js +11 -17
- package/package.json +1 -1
package/lib/requestHandler.js
CHANGED
|
@@ -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
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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);
|