18 lines
552 B
TypeScript
18 lines
552 B
TypeScript
export const getAnalysisElementOriginalIds = (products: ({ metadata?: { analysisElementOriginalIds?: string } | null } | null)[]) => {
|
|
if (!products) {
|
|
return [];
|
|
}
|
|
|
|
return products
|
|
.flatMap((product) => {
|
|
const value = product?.metadata?.analysisElementOriginalIds;
|
|
try {
|
|
return JSON.parse(value as string);
|
|
} catch (e) {
|
|
console.error("Failed to parse analysisElementOriginalIds from analysis package, possibly invalid format", e);
|
|
return [];
|
|
}
|
|
})
|
|
.filter(Boolean) as string[];
|
|
}
|