Files
klz-cables.com/.pnpm-store/v10/files/ec/39a549e7dc9ac6bcde1d9f9b9c8b2c34331cf558c819f5d9ab18e8cf140fa8b25e72480c5068db82740ae4c45e99c7ca01c9de2181b529f3a405a222342c2b
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.0 KiB
Plaintext

{"version":3,"sources":["../../../../../src/queues/operations/runJobs/runJob/getUpdateJobFunction.ts"],"sourcesContent":["import type { Job } from '../../../../index.js'\nimport type { PayloadRequest } from '../../../../types/index.js'\n\nimport { JobCancelledError } from '../../../errors/index.js'\nimport { updateJob } from '../../../utilities/updateJob.js'\n\nexport type UpdateJobFunction = (jobData: Partial<Job>) => Promise<Job>\n\n/**\n * Helper for updating a job that does the following, additionally to updating the job:\n * - Merges incoming data from the updated job into the original job object\n * - Handles job cancellation by throwing a `JobCancelledError` if the job was cancelled.\n */\nexport function getUpdateJobFunction(job: Job, req: PayloadRequest): UpdateJobFunction {\n return async (jobData) => {\n const updatedJob = await updateJob({\n id: job.id,\n data: jobData,\n depth: req.payload.config.jobs.depth,\n disableTransaction: true,\n req,\n })\n\n if (!updatedJob) {\n return job\n }\n\n // Update job object like this to modify the original object - that way, incoming changes (e.g. taskStatus field that will be re-generated through the hook) will be reflected in the calling function\n for (const key in updatedJob) {\n if (key === 'log') {\n // Add all new log entries to the original job.log object. Do not delete any existing log entries.\n // Do not update existing log entries, as existing log entries should be immutable.\n for (const logEntry of updatedJob?.log ?? []) {\n if (!job.log || !job.log.some((entry) => entry.id === logEntry.id)) {\n ;(job.log ??= []).push(logEntry)\n }\n }\n } else {\n ;(job as any)[key] = updatedJob[key as keyof Job]\n }\n }\n\n if ((updatedJob?.error as Record<string, unknown>)?.cancelled) {\n throw new JobCancelledError(`Job ${job.id} was cancelled`)\n }\n\n return updatedJob\n }\n}\n"],"names":["JobCancelledError","updateJob","getUpdateJobFunction","job","req","jobData","updatedJob","id","data","depth","payload","config","jobs","disableTransaction","key","logEntry","log","some","entry","push","error","cancelled"],"mappings":"AAGA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,SAAS,QAAQ,kCAAiC;AAI3D;;;;CAIC,GACD,OAAO,SAASC,qBAAqBC,GAAQ,EAAEC,GAAmB;IAChE,OAAO,OAAOC;QACZ,MAAMC,aAAa,MAAML,UAAU;YACjCM,IAAIJ,IAAII,EAAE;YACVC,MAAMH;YACNI,OAAOL,IAAIM,OAAO,CAACC,MAAM,CAACC,IAAI,CAACH,KAAK;YACpCI,oBAAoB;YACpBT;QACF;QAEA,IAAI,CAACE,YAAY;YACf,OAAOH;QACT;QAEA,sMAAsM;QACtM,IAAK,MAAMW,OAAOR,WAAY;YAC5B,IAAIQ,QAAQ,OAAO;gBACjB,kGAAkG;gBAClG,mFAAmF;gBACnF,KAAK,MAAMC,YAAYT,YAAYU,OAAO,EAAE,CAAE;oBAC5C,IAAI,CAACb,IAAIa,GAAG,IAAI,CAACb,IAAIa,GAAG,CAACC,IAAI,CAAC,CAACC,QAAUA,MAAMX,EAAE,KAAKQ,SAASR,EAAE,GAAG;;wBAChEJ,CAAAA,IAAIa,GAAG,KAAK,EAAE,AAAD,EAAGG,IAAI,CAACJ;oBACzB;gBACF;YACF,OAAO;;gBACHZ,GAAW,CAACW,IAAI,GAAGR,UAAU,CAACQ,IAAiB;YACnD;QACF;QAEA,IAAKR,YAAYc,OAAmCC,WAAW;YAC7D,MAAM,IAAIrB,kBAAkB,CAAC,IAAI,EAAEG,IAAII,EAAE,CAAC,cAAc,CAAC;QAC3D;QAEA,OAAOD;IACT;AACF"}