@itentialopensource/adapter-utils
Advanced tools
Comparing version 4.45.0 to 4.45.1
## 4.45.1 [12-08-2021] | ||
* Modified response handling on error to use the translator | ||
Closes ADAPT-1876 | ||
See merge request itentialopensource/adapter-utils!225 | ||
--- | ||
## 4.45.0 [12-08-2021] | ||
@@ -3,0 +13,0 @@ |
@@ -190,2 +190,3 @@ /* @copyright Itential, LLC 2018-9 */ | ||
const respSchemaFile = path.join(this.baseDir, `/entities/${entityName}/${respSchemaName}`); | ||
const errorSchemaFile = path.join(this.baseDir, '/entities/.system/errorSchema'); | ||
@@ -248,2 +249,12 @@ // if the file does not exist - error | ||
// if the error schema file exist - read it in | ||
if (fs.existsSync(errorSchemaFile)) { | ||
entitySchema.errorSchema = JSON.parse(fs.readFileSync(errorSchemaFile, 'utf-8')); | ||
// if the error schema file is bad, warn about it but continue and use the global on! | ||
if (entitySchema.errorSchema && typeof entitySchema.errorSchema !== 'object') { | ||
log.warn(`${origin}: Invalid error schema, please verify file: ${errorSchemaFile}`); | ||
} | ||
} | ||
// Merge the information into the entity schema | ||
@@ -250,0 +261,0 @@ entitySchema.protocol = actionInfo.protocol; |
@@ -54,3 +54,3 @@ /* @copyright Itential, LLC 2018 */ | ||
// get the path for the specific action file | ||
const propertyFile = path.join(__dirname, '/../propertiesSchema.json'); | ||
const propertyFile = path.join(__dirname, '/../schemas/propertiesSchema.json'); | ||
@@ -117,3 +117,3 @@ // Read the action from the file system | ||
// Read the action schema from the file system | ||
const actionSchemaFile = path.join(__dirname, '/../actionSchema.json'); | ||
const actionSchemaFile = path.join(__dirname, '/../schemas/actionSchema.json'); | ||
const actionSchema = JSON.parse(fs.readFileSync(actionSchemaFile, 'utf-8')); | ||
@@ -120,0 +120,0 @@ const entitydir = `${directory}/entities`; |
@@ -12,2 +12,4 @@ /* @copyright Itential, LLC 2018 */ | ||
const globalSchema = JSON.parse(require('fs').readFileSync(require('path').join(__dirname, '/../schemas/globalSchema.json'))); | ||
let transUtilInst = null; | ||
@@ -183,3 +185,9 @@ let connectorInst = null; | ||
if (retError !== null) { | ||
retErrorObj.response = retError; | ||
// if there is a local error schema in the entity use that one | ||
if (Object.hasOwnProperty.call(entitySchema, 'errorSchema')) { | ||
retErrorObj.response = transUtilInst.mapFromOutboundEntity(retError, entitySchema.errorSchema); | ||
} else { | ||
// if there is a no local error schema in the entity use that one | ||
retErrorObj.response = transUtilInst.mapFromOutboundEntity(retError, globalSchema); | ||
} | ||
} | ||
@@ -466,2 +474,5 @@ | ||
// Apply global schema | ||
// retResponse = transUtilInst.mapFromOutboundEntity(retResponse, globalSchema); | ||
// added the translated response to the return Object | ||
@@ -468,0 +479,0 @@ retObject.response = transUtilInst.mapFromOutboundEntity(retResponse, entitySchema.responseSchema); |
{ | ||
"name": "@itentialopensource/adapter-utils", | ||
"version": "4.45.0", | ||
"version": "4.45.1", | ||
"description": "Itential Adapter Utility Libraries", | ||
@@ -5,0 +5,0 @@ "scripts": { |
536795
24
11560
17