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
4.3 KiB
Plaintext
1 line
4.3 KiB
Plaintext
{"version":3,"sources":["../../../src/globals/operations/countGlobalVersions.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport {\n buildVersionGlobalFields,\n type GlobalSlug,\n type SanitizedGlobalConfig,\n} from '../../index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n disableErrors?: boolean\n global: SanitizedGlobalConfig\n overrideAccess?: boolean\n req?: PayloadRequest\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countGlobalVersionsOperation = async <TSlug extends GlobalSlug>(\n args: Arguments,\n): Promise<{ totalDocs: number }> => {\n try {\n const { disableErrors, global, overrideAccess, where } = args\n const req = args.req!\n const { payload } = req\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (global.hooks?.beforeOperation?.length) {\n for (const hook of global.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: req.context,\n global,\n operation: 'countVersions',\n overrideAccess,\n req,\n })) || args\n }\n }\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ disableErrors, req }, global.access.readVersions)\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n const fullWhere = combineQueries(where!, accessResult!)\n\n const versionFields = buildVersionGlobalFields(payload.config, global, true)\n\n await validateQueryPaths({\n globalConfig: global,\n overrideAccess: overrideAccess!,\n req,\n versionFields,\n where: where!,\n })\n\n const result = await payload.db.countGlobalVersions({\n global: global.slug,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","buildVersionGlobalFields","killTransaction","countGlobalVersionsOperation","args","disableErrors","global","overrideAccess","where","req","payload","hooks","beforeOperation","length","hook","context","operation","accessResult","access","readVersions","totalDocs","fullWhere","versionFields","config","globalConfig","result","db","countGlobalVersions","slug","error"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SACEC,wBAAwB,QAGnB,iBAAgB;AACvB,SAASC,eAAe,QAAQ,qCAAoC;AAUpE,6DAA6D;AAC7D,OAAO,MAAMC,+BAA+B,OAC1CC;IAEA,IAAI;QACF,MAAM,EAAEC,aAAa,EAAEC,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGJ;QACzD,MAAMK,MAAML,KAAKK,GAAG;QACpB,MAAM,EAAEC,OAAO,EAAE,GAAGD;QAEpB,wCAAwC;QACxC,2BAA2B;QAC3B,wCAAwC;QAExC,IAAIH,OAAOK,KAAK,EAAEC,iBAAiBC,QAAQ;YACzC,KAAK,MAAMC,QAAQR,OAAOK,KAAK,CAACC,eAAe,CAAE;gBAC/CR,OACE,AAAC,MAAMU,KAAK;oBACVV;oBACAW,SAASN,IAAIM,OAAO;oBACpBT;oBACAU,WAAW;oBACXT;oBACAE;gBACF,MAAOL;YACX;QACF;QAEA,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,IAAIa;QAEJ,IAAI,CAACV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