@itentialopensource/adapter-utils
Advanced tools
Comparing version 4.30.12 to 4.30.13
## 4.30.13 [03-17-2020] | ||
* updates for how global properties are handled - in particular when the payload is an array | ||
Closes ADAPT-135 | ||
See merge request itentialopensource/adapter-utils!168 | ||
--- | ||
## 4.30.12 [03-06-2020] | ||
@@ -3,0 +13,0 @@ |
@@ -938,3 +938,3 @@ /* Required libraries. */ | ||
// TODO: Need to create a new filter object instead of mutating the exsisting one | ||
const filterKeys = Object.keys(filter).filter(key => (key[0] !== '$' && typeof filter[key] === 'string')); | ||
const filterKeys = Object.keys(filter).filter((key) => (key[0] !== '$' && typeof filter[key] === 'string')); | ||
filterKeys.map((key) => { | ||
@@ -941,0 +941,0 @@ try { |
@@ -577,4 +577,5 @@ /* @copyright Itential, LLC 2018 */ | ||
// only add options if a GET | ||
if (entitySchema.method.toUpperCase() === 'GET' && globalRequestGl) { | ||
// only add global options if there are global options to add and this is a GET | ||
if (entitySchema.method.toUpperCase() === 'GET' && globalRequestGl && globalRequestGl.uriOptions | ||
&& Object.keys(globalRequestGl.uriOptions).length > 0) { | ||
thisOdata = transUtilInst.mergeObjects(thisOdata, globalRequestGl.uriOptions); | ||
@@ -711,7 +712,9 @@ } | ||
if (entitySchema) { | ||
// only add action headers if there are action headers to add | ||
if (entitySchema && entitySchema.headers && Object.keys(entitySchema.headers).length > 0) { | ||
thisAHdata = transUtilInst.mergeObjects(thisAHdata, entitySchema.headers); | ||
} | ||
if (globalRequestGl) { | ||
// only add global headers if there are global headers to add | ||
if (globalRequestGl && globalRequestGl.addlHeaders && Object.keys(globalRequestGl.addlHeaders).length > 0) { | ||
thisAHdata = transUtilInst.mergeObjects(thisAHdata, globalRequestGl.addlHeaders); | ||
@@ -801,5 +804,19 @@ } | ||
// only add body if not a GET | ||
if ((entitySchema.method.toUpperCase() !== 'GET' || entitySchema.sendGetBody) && globalRequestGl) { | ||
thisBdata = transUtilInst.mergeObjects(thisBdata, globalRequestGl.payload); | ||
// only add body if there is payload to add and it is not a GET or if it is a GET and we need to send a body | ||
if ((entitySchema.method.toUpperCase() !== 'GET' || entitySchema.sendGetBody) && globalRequestGl && globalRequestGl.payload) { | ||
// if both are objects, merge the objects | ||
if (!Array.isArray(thisBdata) && typeof thisBdata === 'object' && !Array.isArray(globalRequestGl.payload) | ||
&& typeof globalRequestGl.payload === 'object' && Object.keys(globalRequestGl.payload).length > 0) { | ||
thisBdata = transUtilInst.mergeObjects(thisBdata, globalRequestGl.payload); | ||
} else if (Array.isArray(thisBdata) && !Array.isArray(globalRequestGl.payload) && typeof globalRequestGl.payload === 'object' | ||
&& Object.keys(globalRequestGl.payload).length > 0) { | ||
// if payload is an array of objects, add the global payload to each object - only one level deep | ||
for (let a = 0; a < thisBdata.length; a += 1) { | ||
if (!Array.isArray(thisBdata[a]) && typeof thisBdata[a] === 'object') { | ||
thisBdata[a] = transUtilInst.mergeObjects(thisBdata[a], globalRequestGl.payload); | ||
} | ||
} | ||
} else { | ||
log.warn(`${origin}: Payload and Gloabl Payload can not be merged!`); | ||
} | ||
} | ||
@@ -806,0 +823,0 @@ |
@@ -8,2 +8,3 @@ /* @copyright Itential, LLC 2018-9 */ | ||
/* eslint no-use-before-define: warn */ | ||
/* eslint prefer-object-spread:warn */ | ||
@@ -10,0 +11,0 @@ /* NodeJS internal utilities */ |
{ | ||
"name": "@itentialopensource/adapter-utils", | ||
"version": "4.30.12", | ||
"version": "4.30.13", | ||
"description": "Itential Adapter Utility Libraries", | ||
@@ -45,13 +45,13 @@ "scripts": { | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"eslint": "^5.14.1", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-json": "^1.4.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^14.0.0", | ||
"strip-ansi": "^4.0.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-json": "^2.1.1", | ||
"mocha": "^7.1.0", | ||
"nyc": "^15.0.0", | ||
"strip-ansi": "^6.0.0", | ||
"strip-ansi-cli": "^2.0.0", | ||
"testdouble": "^3.8.1", | ||
"winston": "^2.4.0" | ||
"testdouble": "^3.13.1", | ||
"winston": "^3.2.1" | ||
}, | ||
@@ -58,0 +58,0 @@ "peerDependencies": {}, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1627483
14137