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
1 line
3.2 KiB
Plaintext
1 line
3.2 KiB
Plaintext
{"version":3,"sources":["../../../src/folders/utils/buildFolderWhereConstraints.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { combineWhereConstraints } from '../../utilities/combineWhereConstraints.js'\nimport { mergeListSearchAndWhere } from '../../utilities/mergeListSearchAndWhere.js'\n\ntype Args = {\n collectionConfig: SanitizedCollectionConfig\n folderID?: number | string\n localeCode?: string\n req: PayloadRequest\n search?: string\n sort?: string\n}\nexport async function buildFolderWhereConstraints({\n collectionConfig,\n folderID,\n localeCode,\n req,\n search = '',\n sort,\n}: Args): Promise<undefined | Where> {\n const constraints: Where[] = [\n mergeListSearchAndWhere({\n collectionConfig,\n search,\n // where // cannot have where since fields in folders and collection will differ\n }),\n ]\n\n const baseFilterConstraint = await (\n collectionConfig.admin?.baseFilter ?? collectionConfig.admin?.baseListFilter\n )?.({\n limit: 0,\n locale: localeCode,\n page: 1,\n req,\n sort:\n sort ||\n (typeof collectionConfig.defaultSort === 'string' ? collectionConfig.defaultSort : 'id'),\n })\n\n if (baseFilterConstraint) {\n constraints.push(baseFilterConstraint)\n }\n\n if (folderID) {\n // build folder join where constraints\n constraints.push({\n relationTo: {\n equals: collectionConfig.slug,\n },\n })\n\n // join queries need to omit trashed documents\n if (collectionConfig.trash) {\n constraints.push({\n deletedAt: {\n exists: false,\n },\n })\n }\n }\n\n const filteredConstraints = constraints.filter(Boolean)\n\n if (filteredConstraints.length > 1) {\n return combineWhereConstraints(filteredConstraints)\n } else if (filteredConstraints.length === 1) {\n return filteredConstraints[0]\n }\n\n return undefined\n}\n"],"names":["combineWhereConstraints","mergeListSearchAndWhere","buildFolderWhereConstraints","collectionConfig","folderID","localeCode","req","search","sort","constraints","baseFilterConstraint","admin","baseFilter","baseListFilter","limit","locale","page","defaultSort","push","relationTo","equals","slug","trash","deletedAt","exists","filteredConstraints","filter","Boolean","length","undefined"],"mappings":"AAGA,SAASA,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,uBAAuB,QAAQ,6CAA4C;AAUpF,OAAO,eAAeC,4BAA4B,EAChDC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,GAAG,EACHC,SAAS,EAAE,EACXC,IAAI,EACC;IACL,MAAMC,cAAuB;QAC3BR,wBAAwB;YACtBE;YACAI;QAEF;KACD;IAED,MAAMG,uBAAuB,MAC3BP,CAAAA,iBAAiBQ,KAAK,EAAEC,cAAcT,iBAAiBQ,KAAK,EAAEE,cAAa,IACzE;QACFC,OAAO;QACPC,QAAQV;QACRW,MAAM;QACNV;QACAE,MACEA,QACC,CAAA,OAAOL,iBAAiBc,WAAW,KAAK,WAAWd,iBAAiBc,WAAW,GAAG,IAAG;IAC1F;IAEA,IAAIP,sBAAsB;QACxBD,YAAYS,IAAI,CAACR;IACnB;IAEA,IAAIN,UAAU;QACZ,sCAAsC;QACtCK,YAAYS,IAAI,CAAC;YACfC,YAAY;gBACVC,QAAQjB,iBAAiBkB,IAAI;YAC/B;QACF;QAEA,8CAA8C;QAC9C,IAAIlB,iBAAiBmB,KAAK,EAAE;YAC1Bb,YAAYS,IAAI,CAAC;gBACfK,WAAW;oBACTC,QAAQ;gBACV;YACF;QACF;IACF;IAEA,MAAMC,sBAAsBhB,YAAYiB,MAAM,CAACC;IAE/C,IAAIF,oBAAoBG,MAAM,GAAG,GAAG;QAClC,OAAO5B,wBAAwByB;IACjC,OAAO,IAAIA,oBAAoBG,MAAM,KAAK,GAAG;QAC3C,OAAOH,mBAAmB,CAAC,EAAE;IAC/B;IAEA,OAAOI;AACT"} |