Files
klz-cables.com/.pnpm-store/v10/files/c9/e626c7cc5178ff8ee8cf7715ab6bbab3f3cd5d7866aaa550d080ebf04553f2d2e72c906fec192f9e57e4d79942f0600593964967e7bc4cc4043603a5ab643f
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
2.8 KiB
Plaintext

{"version":3,"sources":["../../src/utilities/mergeListSearchAndWhere.ts"],"sourcesContent":["import type { ClientCollectionConfig } from '../collections/config/client.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Where } from '../types/index.js'\n\nconst isEmptyObject = (obj: object) => Object.keys(obj).length === 0\n\nexport const hoistQueryParamsToAnd = (currentWhere: Where, incomingWhere: Where) => {\n if (isEmptyObject(incomingWhere)) {\n return currentWhere\n }\n\n if (isEmptyObject(currentWhere)) {\n return incomingWhere\n }\n\n if ('and' in currentWhere && currentWhere.and) {\n currentWhere.and.push(incomingWhere)\n } else if ('or' in currentWhere) {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n } else {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n }\n\n return currentWhere\n}\n\ntype Args = {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n search: string\n where?: Where\n}\n\nexport const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} }: Args): Where => {\n if (search) {\n let copyOfWhere = { ...(where || {}) }\n\n const searchAsConditions = (\n collectionConfig.admin.listSearchableFields || [collectionConfig.admin?.useAsTitle || 'id']\n ).map((fieldName) => ({\n [fieldName]: {\n like: search,\n },\n }))\n\n if (searchAsConditions.length > 0) {\n copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {\n or: searchAsConditions,\n })\n }\n\n if (!isEmptyObject(copyOfWhere)) {\n where = copyOfWhere\n }\n }\n\n return where\n}\n"],"names":["isEmptyObject","obj","Object","keys","length","hoistQueryParamsToAnd","currentWhere","incomingWhere","and","push","mergeListSearchAndWhere","collectionConfig","search","where","copyOfWhere","searchAsConditions","admin","listSearchableFields","useAsTitle","map","fieldName","like","or"],"mappings":"AAIA,MAAMA,gBAAgB,CAACC,MAAgBC,OAAOC,IAAI,CAACF,KAAKG,MAAM,KAAK;AAEnE,OAAO,MAAMC,wBAAwB,CAACC,cAAqBC;IACzD,IAAIP,cAAcO,gBAAgB;QAChC,OAAOD;IACT;IAEA,IAAIN,cAAcM,eAAe;QAC/B,OAAOC;IACT;IAEA,IAAI,SAASD,gBAAgBA,aAAaE,GAAG,EAAE;QAC7CF,aAAaE,GAAG,CAACC,IAAI,CAACF;IACxB,OAAO,IAAI,QAAQD,cAAc;QAC/BA,eAAe;YACbE,KAAK;gBAACF;gBAAcC;aAAc;QACpC;IACF,OAAO;QACLD,eAAe;YACbE,KAAK;gBAACF;gBAAcC;aAAc;QACpC;IACF;IAEA,OAAOD;AACT,EAAC;AAQD,OAAO,MAAMI,0BAA0B,CAAC,EAAEC,gBAAgB,EAAEC,MAAM,EAAEC,QAAQ,CAAC,CAAC,EAAQ;IACpF,IAAID,QAAQ;QACV,IAAIE,cAAc;YAAE,GAAID,SAAS,CAAC,CAAC;QAAE;QAErC,MAAME,qBAAqB,AACzBJ,CAAAA,iBAAiBK,KAAK,CAACC,oBAAoB,IAAI;YAACN,iBAAiBK,KAAK,EAAEE,cAAc;SAAK,AAAD,EAC1FC,GAAG,CAAC,CAACC,YAAe,CAAA;gBACpB,CAACA,UAAU,EAAE;oBACXC,MAAMT;gBACR;YACF,CAAA;QAEA,IAAIG,mBAAmBX,MAAM,GAAG,GAAG;YACjCU,cAAcT,sBAAsBS,aAAa;gBAC/CQ,IAAIP;YACN;QACF;QAEA,IAAI,CAACf,cAAcc,cAAc;YAC/BD,QAAQC;QACV;IACF;IAEA,OAAOD;AACT,EAAC"}