feat(MED-131): update analyses on package logic
This commit is contained in:
17
utils/medusa-product.ts
Normal file
17
utils/medusa-product.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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[];
|
||||
}
|
||||
Reference in New Issue
Block a user