Files
klz-cables.com/.pnpm-store/v10/files/01/76e9db47820976198419c06a94e2136ba151d701002651d7aa671809f6f364985e46685e2100192087616c0b1baab8e0c9d244632b47cd94dc160ab3f11338
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

1 line
3.1 KiB
Plaintext

{"version":3,"sources":["../../src/database/sanitizeWhereQuery.ts"],"sourcesContent":["import type { FlattenedField } from '../fields/config/types.js'\nimport type { Payload, Where } from '../types/index.js'\n\n/**\n * Currently used only for virtual fields linked with relationships\n */\nexport const sanitizeWhereQuery = ({\n fields,\n payload,\n where,\n}: {\n fields: FlattenedField[]\n payload: Payload\n where: Where\n}) => {\n for (const key in where) {\n const value = where[key]\n\n if (['and', 'or'].includes(key.toLowerCase()) && Array.isArray(value)) {\n for (const where of value) {\n sanitizeWhereQuery({ fields, payload, where })\n }\n continue\n }\n\n const paths = key.split('.')\n let pathHasChanged = false\n\n let currentFields = fields\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!\n const field = currentFields.find((each) => each.name === path)\n\n if (!field) {\n break\n }\n\n if ('virtual' in field && field.virtual && typeof field.virtual === 'string') {\n paths[i] = field.virtual\n pathHasChanged = true\n }\n\n if ('flattenedFields' in field) {\n currentFields = field.flattenedFields\n }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n typeof field.relationTo === 'string'\n ) {\n const relatedCollection = payload.collections[field.relationTo]\n if (relatedCollection) {\n currentFields = relatedCollection.config.flattenedFields\n }\n }\n }\n\n if (pathHasChanged) {\n where[paths.join('.')] = where[key]!\n delete where[key]\n }\n }\n}\n"],"names":["sanitizeWhereQuery","fields","payload","where","key","value","includes","toLowerCase","Array","isArray","paths","split","pathHasChanged","currentFields","i","length","path","field","find","each","name","virtual","flattenedFields","type","relationTo","relatedCollection","collections","config","join"],"mappings":"AAGA;;CAEC,GACD,OAAO,MAAMA,qBAAqB,CAAC,EACjCC,MAAM,EACNC,OAAO,EACPC,KAAK,EAKN;IACC,IAAK,MAAMC,OAAOD,MAAO;QACvB,MAAME,QAAQF,KAAK,CAACC,IAAI;QAExB,IAAI;YAAC;YAAO;SAAK,CAACE,QAAQ,CAACF,IAAIG,WAAW,OAAOC,MAAMC,OAAO,CAACJ,QAAQ;YACrE,KAAK,MAAMF,SAASE,MAAO;gBACzBL,mBAAmB;oBAAEC;oBAAQC;oBAASC;gBAAM;YAC9C;YACA;QACF;QAEA,MAAMO,QAAQN,IAAIO,KAAK,CAAC;QACxB,IAAIC,iBAAiB;QAErB,IAAIC,gBAAgBZ;QAEpB,IAAK,IAAIa,IAAI,GAAGA,IAAIJ,MAAMK,MAAM,EAAED,IAAK;YACrC,MAAME,OAAON,KAAK,CAACI,EAAE;YACrB,MAAMG,QAAQJ,cAAcK,IAAI,CAAC,CAACC,OAASA,KAAKC,IAAI,KAAKJ;YAEzD,IAAI,CAACC,OAAO;gBACV;YACF;YAEA,IAAI,aAAaA,SAASA,MAAMI,OAAO,IAAI,OAAOJ,MAAMI,OAAO,KAAK,UAAU;gBAC5EX,KAAK,CAACI,EAAE,GAAGG,MAAMI,OAAO;gBACxBT,iBAAiB;YACnB;YAEA,IAAI,qBAAqBK,OAAO;gBAC9BJ,gBAAgBI,MAAMK,eAAe;YACvC;YAEA,IACE,AAACL,CAAAA,MAAMM,IAAI,KAAK,kBAAkBN,MAAMM,IAAI,KAAK,QAAO,KACxD,OAAON,MAAMO,UAAU,KAAK,UAC5B;gBACA,MAAMC,oBAAoBvB,QAAQwB,WAAW,CAACT,MAAMO,UAAU,CAAC;gBAC/D,IAAIC,mBAAmB;oBACrBZ,gBAAgBY,kBAAkBE,MAAM,CAACL,eAAe;gBAC1D;YACF;QACF;QAEA,IAAIV,gBAAgB;YAClBT,KAAK,CAACO,MAAMkB,IAAI,CAAC,KAAK,GAAGzB,KAAK,CAACC,IAAI;YACnC,OAAOD,KAAK,CAACC,IAAI;QACnB;IACF;AACF,EAAC"}