fix(orchestration): filter out undefined items (#9046)

This commit is contained in:
Carlos R. L. Rodrigues
2024-09-08 07:58:48 -03:00
committed by GitHub
parent 4b8d9cc735
commit afb83b2408
@@ -92,7 +92,18 @@ export class RemoteJoiner {
}
private static getNestedItems(items: any[], property: string): any[] {
return items.flatMap((item) => item?.[property])
const result: unknown[] = []
for (const item of items) {
const allValues = item?.[property] ?? []
const values = Array.isArray(allValues) ? allValues : [allValues]
for (const value of values) {
if (isDefined(value)) {
result.push(value)
}
}
}
return result
}
private static createRelatedDataMap(
@@ -377,7 +388,11 @@ export class RemoteJoiner {
const isObj = isDefined(response.path)
let resData = isObj ? response.data[response.path!] : response.data
resData = Array.isArray(resData) ? resData : [resData]
resData = isDefined(resData)
? Array.isArray(resData)
? resData
: [resData]
: []
this.checkIfKeysExist(
uniqueIds,