Files
klz-cables.com/.pnpm-store/v10/files/e8/ab44264b4212d1cb5cc78871509d90aff8bc6dffe7dcfe2bc4c0e7ecccf4ffa78270a536fa71169fe2c3181605a37caeab127003f720a104c50cd71dcaf88a
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

49 lines
1.7 KiB
Plaintext

/**
* Currently used only for virtual fields linked with relationships
*/ export const sanitizeWhereQuery = ({ fields, payload, where })=>{
for(const key in where){
const value = where[key];
if ([
'and',
'or'
].includes(key.toLowerCase()) && Array.isArray(value)) {
for (const where of value){
sanitizeWhereQuery({
fields,
payload,
where
});
}
continue;
}
const paths = key.split('.');
let pathHasChanged = false;
let currentFields = fields;
for(let i = 0; i < paths.length; i++){
const path = paths[i];
const field = currentFields.find((each)=>each.name === path);
if (!field) {
break;
}
if ('virtual' in field && field.virtual && typeof field.virtual === 'string') {
paths[i] = field.virtual;
pathHasChanged = true;
}
if ('flattenedFields' in field) {
currentFields = field.flattenedFields;
}
if ((field.type === 'relationship' || field.type === 'upload') && typeof field.relationTo === 'string') {
const relatedCollection = payload.collections[field.relationTo];
if (relatedCollection) {
currentFields = relatedCollection.config.flattenedFields;
}
}
}
if (pathHasChanged) {
where[paths.join('.')] = where[key];
delete where[key];
}
}
};
//# sourceMappingURL=sanitizeWhereQuery.js.map