payload 3.75.0-internal.8e0f8ba → 3.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queues/localAPI.ts"],"sourcesContent":["import type { BaseJob, RunningJobFromTask } from './config/types/workflowTypes.js'\n\nimport {\n createLocalReq,\n Forbidden,\n type Job,\n type Payload,\n type PayloadRequest,\n type Sort,\n type TypedJobs,\n type Where,\n} from '../index.js'\nimport { jobAfterRead, jobsCollectionSlug } from './config/collection.js'\nimport { handleSchedules, type HandleSchedulesResult } from './operations/handleSchedules/index.js'\nimport { runJobs } from './operations/runJobs/index.js'\nimport { updateJob, updateJobs } from './utilities/updateJob.js'\n\nexport type RunJobsSilent =\n | {\n error?: boolean\n info?: boolean\n }\n | boolean\nexport const getJobsLocalAPI = (payload: Payload) => ({\n handleSchedules: async (args?: {\n /**\n * If you want to schedule jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n // By default, schedule all queues - only scheduling jobs scheduled to be added to the `default` queue would not make sense\n // here, as you'd usually specify a different queue than `default` here, especially if this is used in combination with autorun.\n // The `queue` property for setting up schedules is required, and not optional.\n /**\n * If you want to only schedule jobs that are set to schedule in a specific queue, set this to the queue name.\n *\n * @default jobs from the `default` queue will be executed.\n */\n queue?: string\n req?: PayloadRequest\n }): Promise<HandleSchedulesResult> => {\n const newReq: PayloadRequest = args?.req ?? (await createLocalReq({}, payload))\n\n return await handleSchedules({\n allQueues: args?.allQueues,\n queue: args?.queue,\n req: newReq,\n })\n },\n queue: async <\n // eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents\n TTaskOrWorkflowSlug extends keyof TypedJobs['tasks'] | keyof TypedJobs['workflows'],\n >(\n args:\n | {\n input: TypedJobs['tasks'][TTaskOrWorkflowSlug]['input']\n meta?: BaseJob['meta']\n /**\n * If set to false, access control as defined in jobsConfig.access.queue will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.queue defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The queue to add the job to.\n * If not specified, the job will be added to the default queue.\n *\n * @default 'default'\n */\n queue?: string\n req?: PayloadRequest\n task: TTaskOrWorkflowSlug extends keyof TypedJobs['tasks'] ? TTaskOrWorkflowSlug : never\n waitUntil?: Date\n workflow?: never\n }\n | {\n input: TypedJobs['workflows'][TTaskOrWorkflowSlug]['input']\n meta?: BaseJob['meta']\n /**\n * If set to false, access control as defined in jobsConfig.access.queue will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.queue defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The queue to add the job to.\n * If not specified, the job will be added to the default queue.\n *\n * @default 'default'\n */\n queue?: string\n req?: PayloadRequest\n task?: never\n waitUntil?: Date\n workflow: TTaskOrWorkflowSlug extends keyof TypedJobs['workflows']\n ? TTaskOrWorkflowSlug\n : never\n },\n ): Promise<\n TTaskOrWorkflowSlug extends keyof TypedJobs['workflows']\n ? Job<TTaskOrWorkflowSlug>\n : RunningJobFromTask<TTaskOrWorkflowSlug>\n > => {\n const overrideAccess = args?.overrideAccess !== false\n const req: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.queue will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = payload.config.jobs?.access?.queue ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n let queue: string | undefined = undefined\n\n // If user specifies queue, use that\n if (args.queue) {\n queue = args.queue\n } else if (args.workflow) {\n // Otherwise, if there is a workflow specified, and it has a default queue to use,\n // use that\n const workflow = payload.config.jobs?.workflows?.find(({ slug }) => slug === args.workflow)\n if (workflow?.queue) {\n queue = workflow.queue\n }\n }\n\n const data: Partial<Job> = {\n input: args.input,\n }\n\n if (queue) {\n data.queue = queue\n }\n if (args.waitUntil) {\n data.waitUntil = args.waitUntil?.toISOString()\n }\n if (args.workflow) {\n data.workflowSlug = args.workflow as string\n }\n if (args.task) {\n data.taskSlug = args.task as string\n }\n\n if (args.meta) {\n data.meta = args.meta\n }\n\n // Compute concurrency key from workflow or task config (only if feature is enabled)\n if (payload.config.jobs?.enableConcurrencyControl) {\n let concurrencyKey: null | string = null\n let supersedes = false\n const queueName = queue || 'default'\n\n if (args.workflow) {\n const workflow = payload.config.jobs?.workflows?.find(({ slug }) => slug === args.workflow)\n if (workflow?.concurrency) {\n const concurrencyConfig = workflow.concurrency\n if (typeof concurrencyConfig === 'function') {\n concurrencyKey = concurrencyConfig({ input: args.input, queue: queueName })\n } else {\n concurrencyKey = concurrencyConfig.key({ input: args.input, queue: queueName })\n supersedes = concurrencyConfig.supersedes ?? false\n }\n }\n } else if (args.task) {\n const task = payload.config.jobs?.tasks?.find(({ slug }) => slug === args.task)\n if (task?.concurrency) {\n const concurrencyConfig = task.concurrency\n if (typeof concurrencyConfig === 'function') {\n concurrencyKey = concurrencyConfig({ input: args.input, queue: queueName })\n } else {\n concurrencyKey = concurrencyConfig.key({ input: args.input, queue: queueName })\n supersedes = concurrencyConfig.supersedes ?? false\n }\n }\n }\n\n if (concurrencyKey) {\n data.concurrencyKey = concurrencyKey\n\n // If supersedes is enabled, delete older pending jobs with the same key\n if (supersedes) {\n if (payload.config.jobs.runHooks) {\n await payload.delete({\n collection: jobsCollectionSlug,\n depth: 0,\n disableTransaction: true,\n where: {\n and: [\n { concurrencyKey: { equals: concurrencyKey } },\n { processing: { equals: false } },\n { completedAt: { exists: false } },\n ],\n },\n })\n } else {\n await payload.db.deleteMany({\n collection: jobsCollectionSlug,\n req,\n where: {\n and: [\n { concurrencyKey: { equals: concurrencyKey } },\n { processing: { equals: false } },\n { completedAt: { exists: false } },\n ],\n },\n })\n }\n }\n }\n }\n\n type ReturnType = TTaskOrWorkflowSlug extends keyof TypedJobs['workflows']\n ? Job<TTaskOrWorkflowSlug>\n : RunningJobFromTask<TTaskOrWorkflowSlug> // Type assertion is still needed here\n\n if (payload?.config?.jobs?.depth || payload?.config?.jobs?.runHooks) {\n console.log('[Queue] creating new job with data (legacy)', data)\n return (await payload.create({\n collection: jobsCollectionSlug,\n data,\n depth: payload.config.jobs.depth ?? 0,\n overrideAccess,\n req,\n })) as ReturnType\n } else {\n console.log('[Queue] creating new job with data', data)\n\n return jobAfterRead({\n config: payload.config,\n doc: await payload.db.create({\n collection: jobsCollectionSlug,\n data,\n req,\n }),\n }) as unknown as ReturnType\n }\n },\n\n run: async (args?: {\n /**\n * If you want to run jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n /**\n * The maximum number of jobs to run in this invocation\n *\n * @default 10\n */\n limit?: number\n /**\n * If set to false, access control as defined in jobsConfig.access.run will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.run defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Adjust the job processing order using a Payload sort string.\n *\n * FIFO would equal `createdAt` and LIFO would equal `-createdAt`.\n */\n processingOrder?: Sort\n /**\n * If you want to run jobs from a specific queue, set this to the queue name.\n *\n * @default jobs from the `default` queue will be executed.\n */\n queue?: string\n randomID?: string\n req?: PayloadRequest\n /**\n * By default, jobs are run in parallel.\n * If you want to run them in sequence, set this to true.\n */\n sequential?: boolean\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n where?: Where\n }): Promise<ReturnType<typeof runJobs>> => {\n console.log(`[${args?.randomID}] 1`)\n const newReq: PayloadRequest = args?.req ?? (await createLocalReq({}, payload))\n\n return await runJobs({\n allQueues: args?.allQueues,\n limit: args?.limit,\n overrideAccess: args?.overrideAccess !== false,\n processingOrder: args?.processingOrder,\n queue: args?.queue,\n randomID: args?.randomID,\n req: newReq,\n sequential: args?.sequential,\n silent: args?.silent,\n where: args?.where,\n })\n },\n\n runByID: async (args: {\n id: number | string\n /**\n * If set to false, access control as defined in jobsConfig.access.run will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.run defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n req?: PayloadRequest\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n }): Promise<ReturnType<typeof runJobs>> => {\n const newReq: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n return await runJobs({\n id: args.id,\n overrideAccess: args.overrideAccess !== false,\n req: newReq,\n silent: args.silent,\n })\n },\n\n cancel: async (args: {\n /**\n * If set to false, access control as defined in jobsConfig.access.cancel will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.cancel defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n queue?: string\n req?: PayloadRequest\n where: Where\n }): Promise<void> => {\n const req: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n const overrideAccess = args.overrideAccess !== false\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.cancel will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = payload.config.jobs?.access?.cancel ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n const and: Where[] = [\n args.where,\n {\n completedAt: {\n exists: false,\n },\n },\n {\n hasError: {\n not_equals: true,\n },\n },\n ]\n\n if (args.queue) {\n and.push({\n queue: {\n equals: args.queue,\n },\n })\n }\n\n await updateJobs({\n data: {\n completedAt: null,\n error: {\n cancelled: true,\n },\n hasError: true,\n processing: false,\n waitUntil: null,\n },\n depth: 0, // No depth, since we're not returning\n disableTransaction: true,\n req,\n returning: false,\n where: { and },\n })\n },\n\n cancelByID: async (args: {\n id: number | string\n /**\n * If set to false, access control as defined in jobsConfig.access.cancel will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.cancel defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n req?: PayloadRequest\n }): Promise<void> => {\n const req: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n const overrideAccess = args.overrideAccess !== false\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.cancel will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = payload.config.jobs?.access?.cancel ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n await updateJob({\n id: args.id,\n data: {\n completedAt: null,\n error: {\n cancelled: true,\n },\n hasError: true,\n processing: false,\n waitUntil: null,\n },\n depth: 0, // No depth, since we're not returning\n disableTransaction: true,\n req,\n returning: false,\n })\n },\n})\n"],"names":["createLocalReq","Forbidden","jobAfterRead","jobsCollectionSlug","handleSchedules","runJobs","updateJob","updateJobs","getJobsLocalAPI","payload","args","newReq","req","allQueues","queue","overrideAccess","accessFn","config","jobs","access","hasAccess","t","undefined","workflow","workflows","find","slug","data","input","waitUntil","toISOString","workflowSlug","task","taskSlug","meta","enableConcurrencyControl","concurrencyKey","supersedes","queueName","concurrency","concurrencyConfig","key","tasks","runHooks","delete","collection","depth","disableTransaction","where","and","equals","processing","completedAt","exists","db","deleteMany","console","log","create","doc","run","randomID","limit","processingOrder","sequential","silent","runByID","id","cancel","hasError","not_equals","push","error","cancelled","returning","cancelByID"],"mappings":"AAE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,UAAU;oBACVlB,YAAY;oBACZtB,WAAW;gBACb;gBACAiB,OAAO;gBACPC,oBAAoB;gBACpBnC;gBACA8D,WAAW;YACb;QACF;IACF,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../src/queues/localAPI.ts"],"sourcesContent":["import type { BaseJob, RunningJobFromTask } from './config/types/workflowTypes.js'\n\nimport {\n createLocalReq,\n Forbidden,\n type Job,\n type Payload,\n type PayloadRequest,\n type Sort,\n type TypedJobs,\n type Where,\n} from '../index.js'\nimport { jobAfterRead, jobsCollectionSlug } from './config/collection.js'\nimport { handleSchedules, type HandleSchedulesResult } from './operations/handleSchedules/index.js'\nimport { runJobs } from './operations/runJobs/index.js'\nimport { updateJob, updateJobs } from './utilities/updateJob.js'\n\nexport type RunJobsSilent =\n | {\n error?: boolean\n info?: boolean\n }\n | boolean\nexport const getJobsLocalAPI = (payload: Payload) => ({\n handleSchedules: async (args?: {\n /**\n * If you want to schedule jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n // By default, schedule all queues - only scheduling jobs scheduled to be added to the `default` queue would not make sense\n // here, as you'd usually specify a different queue than `default` here, especially if this is used in combination with autorun.\n // The `queue` property for setting up schedules is required, and not optional.\n /**\n * If you want to only schedule jobs that are set to schedule in a specific queue, set this to the queue name.\n *\n * @default jobs from the `default` queue will be executed.\n */\n queue?: string\n req?: PayloadRequest\n }): Promise<HandleSchedulesResult> => {\n const newReq: PayloadRequest = args?.req ?? (await createLocalReq({}, payload))\n\n return await handleSchedules({\n allQueues: args?.allQueues,\n queue: args?.queue,\n req: newReq,\n })\n },\n queue: async <\n // eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents\n TTaskOrWorkflowSlug extends keyof TypedJobs['tasks'] | keyof TypedJobs['workflows'],\n >(\n args:\n | {\n input: TypedJobs['tasks'][TTaskOrWorkflowSlug]['input']\n meta?: BaseJob['meta']\n /**\n * If set to false, access control as defined in jobsConfig.access.queue will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.queue defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The queue to add the job to.\n * If not specified, the job will be added to the default queue.\n *\n * @default 'default'\n */\n queue?: string\n req?: PayloadRequest\n task: TTaskOrWorkflowSlug extends keyof TypedJobs['tasks'] ? TTaskOrWorkflowSlug : never\n waitUntil?: Date\n workflow?: never\n }\n | {\n input: TypedJobs['workflows'][TTaskOrWorkflowSlug]['input']\n meta?: BaseJob['meta']\n /**\n * If set to false, access control as defined in jobsConfig.access.queue will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.queue defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The queue to add the job to.\n * If not specified, the job will be added to the default queue.\n *\n * @default 'default'\n */\n queue?: string\n req?: PayloadRequest\n task?: never\n waitUntil?: Date\n workflow: TTaskOrWorkflowSlug extends keyof TypedJobs['workflows']\n ? TTaskOrWorkflowSlug\n : never\n },\n ): Promise<\n TTaskOrWorkflowSlug extends keyof TypedJobs['workflows']\n ? Job<TTaskOrWorkflowSlug>\n : RunningJobFromTask<TTaskOrWorkflowSlug>\n > => {\n const overrideAccess = args?.overrideAccess !== false\n const req: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.queue will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = payload.config.jobs?.access?.queue ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n let queue: string | undefined = undefined\n\n // If user specifies queue, use that\n if (args.queue) {\n queue = args.queue\n } else if (args.workflow) {\n // Otherwise, if there is a workflow specified, and it has a default queue to use,\n // use that\n const workflow = payload.config.jobs?.workflows?.find(({ slug }) => slug === args.workflow)\n if (workflow?.queue) {\n queue = workflow.queue\n }\n }\n\n const data: Partial<Job> = {\n input: args.input,\n }\n\n if (queue) {\n data.queue = queue\n }\n if (args.waitUntil) {\n data.waitUntil = args.waitUntil?.toISOString()\n }\n if (args.workflow) {\n data.workflowSlug = args.workflow as string\n }\n if (args.task) {\n data.taskSlug = args.task as string\n }\n\n if (args.meta) {\n data.meta = args.meta\n }\n\n // Compute concurrency key from workflow or task config (only if feature is enabled)\n if (payload.config.jobs?.enableConcurrencyControl) {\n let concurrencyKey: null | string = null\n let supersedes = false\n const queueName = queue || 'default'\n\n if (args.workflow) {\n const workflow = payload.config.jobs?.workflows?.find(({ slug }) => slug === args.workflow)\n if (workflow?.concurrency) {\n const concurrencyConfig = workflow.concurrency\n if (typeof concurrencyConfig === 'function') {\n concurrencyKey = concurrencyConfig({ input: args.input, queue: queueName })\n } else {\n concurrencyKey = concurrencyConfig.key({ input: args.input, queue: queueName })\n supersedes = concurrencyConfig.supersedes ?? false\n }\n }\n } else if (args.task) {\n const task = payload.config.jobs?.tasks?.find(({ slug }) => slug === args.task)\n if (task?.concurrency) {\n const concurrencyConfig = task.concurrency\n if (typeof concurrencyConfig === 'function') {\n concurrencyKey = concurrencyConfig({ input: args.input, queue: queueName })\n } else {\n concurrencyKey = concurrencyConfig.key({ input: args.input, queue: queueName })\n supersedes = concurrencyConfig.supersedes ?? false\n }\n }\n }\n\n if (concurrencyKey) {\n data.concurrencyKey = concurrencyKey\n\n // If supersedes is enabled, delete older pending jobs with the same key\n if (supersedes) {\n if (payload.config.jobs.runHooks) {\n await payload.delete({\n collection: jobsCollectionSlug,\n depth: 0,\n disableTransaction: true,\n where: {\n and: [\n { concurrencyKey: { equals: concurrencyKey } },\n { processing: { equals: false } },\n { completedAt: { exists: false } },\n ],\n },\n })\n } else {\n await payload.db.deleteMany({\n collection: jobsCollectionSlug,\n req,\n where: {\n and: [\n { concurrencyKey: { equals: concurrencyKey } },\n { processing: { equals: false } },\n { completedAt: { exists: false } },\n ],\n },\n })\n }\n }\n }\n }\n\n type ReturnType = TTaskOrWorkflowSlug extends keyof TypedJobs['workflows']\n ? Job<TTaskOrWorkflowSlug>\n : RunningJobFromTask<TTaskOrWorkflowSlug> // Type assertion is still needed here\n\n if (payload?.config?.jobs?.depth || payload?.config?.jobs?.runHooks) {\n return (await payload.create({\n collection: jobsCollectionSlug,\n data,\n depth: payload.config.jobs.depth ?? 0,\n overrideAccess,\n req,\n })) as ReturnType\n } else {\n return jobAfterRead({\n config: payload.config,\n doc: await payload.db.create({\n collection: jobsCollectionSlug,\n data,\n req,\n }),\n }) as unknown as ReturnType\n }\n },\n\n run: async (args?: {\n /**\n * If you want to run jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n /**\n * The maximum number of jobs to run in this invocation\n *\n * @default 10\n */\n limit?: number\n /**\n * If set to false, access control as defined in jobsConfig.access.run will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.run defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Adjust the job processing order using a Payload sort string.\n *\n * FIFO would equal `createdAt` and LIFO would equal `-createdAt`.\n */\n processingOrder?: Sort\n /**\n * If you want to run jobs from a specific queue, set this to the queue name.\n *\n * @default jobs from the `default` queue will be executed.\n */\n queue?: string\n req?: PayloadRequest\n /**\n * By default, jobs are run in parallel.\n * If you want to run them in sequence, set this to true.\n */\n sequential?: boolean\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n where?: Where\n }): Promise<ReturnType<typeof runJobs>> => {\n const newReq: PayloadRequest = args?.req ?? (await createLocalReq({}, payload))\n\n return await runJobs({\n allQueues: args?.allQueues,\n limit: args?.limit,\n overrideAccess: args?.overrideAccess !== false,\n processingOrder: args?.processingOrder,\n queue: args?.queue,\n req: newReq,\n sequential: args?.sequential,\n silent: args?.silent,\n where: args?.where,\n })\n },\n\n runByID: async (args: {\n id: number | string\n /**\n * If set to false, access control as defined in jobsConfig.access.run will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.run defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n req?: PayloadRequest\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n }): Promise<ReturnType<typeof runJobs>> => {\n const newReq: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n return await runJobs({\n id: args.id,\n overrideAccess: args.overrideAccess !== false,\n req: newReq,\n silent: args.silent,\n })\n },\n\n cancel: async (args: {\n /**\n * If set to false, access control as defined in jobsConfig.access.cancel will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.cancel defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n queue?: string\n req?: PayloadRequest\n where: Where\n }): Promise<void> => {\n const req: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n const overrideAccess = args.overrideAccess !== false\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.cancel will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = payload.config.jobs?.access?.cancel ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n const and: Where[] = [\n args.where,\n {\n completedAt: {\n exists: false,\n },\n },\n {\n hasError: {\n not_equals: true,\n },\n },\n ]\n\n if (args.queue) {\n and.push({\n queue: {\n equals: args.queue,\n },\n })\n }\n\n await updateJobs({\n data: {\n completedAt: null,\n error: {\n cancelled: true,\n },\n hasError: true,\n processing: false,\n waitUntil: null,\n },\n depth: 0, // No depth, since we're not returning\n disableTransaction: true,\n req,\n returning: false,\n where: { and },\n })\n },\n\n cancelByID: async (args: {\n id: number | string\n /**\n * If set to false, access control as defined in jobsConfig.access.cancel will be run.\n * By default, this is true and no access control will be run.\n * If you set this to false and do not have jobsConfig.access.cancel defined, the default access control will be\n * run (which is a function that returns `true` if the user is logged in).\n *\n * @default true\n */\n overrideAccess?: boolean\n req?: PayloadRequest\n }): Promise<void> => {\n const req: PayloadRequest = args.req ?? (await createLocalReq({}, payload))\n\n const overrideAccess = args.overrideAccess !== false\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.cancel will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = payload.config.jobs?.access?.cancel ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n await updateJob({\n id: args.id,\n data: {\n completedAt: null,\n error: {\n cancelled: true,\n },\n hasError: true,\n processing: false,\n waitUntil: null,\n },\n depth: 0, // No depth, since we're not returning\n disableTransaction: true,\n req,\n returning: false,\n })\n },\n})\n"],"names":["createLocalReq","Forbidden","jobAfterRead","jobsCollectionSlug","handleSchedules","runJobs","updateJob","updateJobs","getJobsLocalAPI","payload","args","newReq","req","allQueues","queue","overrideAccess","accessFn","config","jobs","access","hasAccess","t","undefined","workflow","workflows","find","slug","data","input","waitUntil","toISOString","workflowSlug","task","taskSlug","meta","enableConcurrencyControl","concurrencyKey","supersedes","queueName","concurrency","concurrencyConfig","key","tasks","runHooks","delete","collection","depth","disableTransaction","where","and","equals","processing","completedAt","exists","db","deleteMany","create","doc","run","limit","processingOrder","sequential","silent","runByID","id","cancel","hasError","not_equals","push","error","cancelled","returning","cancelByID"],"mappings":"AAEA,SACEA,cAAc,EACdC,SAAS,QAOJ,cAAa;AACpB,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,yBAAwB;AACzE,SAASC,eAAe,QAAoC,wCAAu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;oBACV;gBACF;gBACA;oBACEa,UAAU;wBACRC,YAAY;oBACd;gBACF;aACD;YAED,IAAIzD,KAAKI,KAAK,EAAE;gBACdmC,IAAImB,IAAI,CAAC;oBACPtD,OAAO;wBACLoC,QAAQxC,KAAKI,KAAK;oBACpB;gBACF;YACF;YAEA,MAAMP,WAAW;gBACfoB,MAAM;oBACJyB,aAAa;oBACbiB,OAAO;wBACLC,WAAW;oBACb;oBACAJ,UAAU;oBACVf,YAAY;oBACZtB,WAAW;gBACb;gBACAiB,OAAO;gBACPC,oBAAoB;gBACpBnC;gBACA2D,WAAW;gBACXvB,OAAO;oBAAEC;gBAAI;YACf;QACF;QAEAuB,YAAY,OAAO9D;YAajB,MAAME,MAAsBF,KAAKE,GAAG,IAAK,MAAMZ,eAAe,CAAC,GAAGS;YAElE,MAAMM,iBAAiBL,KAAKK,cAAc,KAAK;YAC/C,IAAI,CAACA,gBAAgB;gBACnB;;OAEC,GACD,MAAMC,WAAWP,QAAQQ,MAAM,CAACC,IAAI,EAAEC,QAAQ8C,UAAW,CAAA,IAAM,IAAG;gBAClE,MAAM7C,YAAY,MAAMJ,SAAS;oBAAEJ;gBAAI;gBACvC,IAAI,CAACQ,WAAW;oBACd,MAAM,IAAInB,UAAUW,IAAIS,CAAC;gBAC3B;YACF;YAEA,MAAMf,UAAU;gBACd0D,IAAItD,KAAKsD,EAAE;gBACXrC,MAAM;oBACJyB,aAAa;oBACbiB,OAAO;wBACLC,WAAW;oBACb;oBACAJ,UAAU;oBACVf,YAAY;oBACZtB,WAAW;gBACb;gBACAiB,OAAO;gBACPC,oBAAoB;gBACpBnC;gBACA2D,WAAW;YACb;QACF;IACF,CAAA,EAAE"}
@@ -34,7 +34,6 @@ export type RunJobsArgs = {
34
34
  * @default jobs from the `default` queue will be executed.
35
35
  */
36
36
  queue?: string;
37
- randomID?: string;
38
37
  req: PayloadRequest;
39
38
  /**
40
39
  * By default, jobs are run in parallel.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queues/operations/runJobs/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAG1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAarD,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,IAAI,CAAA;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACxC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,OAAO,SAAgB,WAAW,KAAG,OAAO,CAAC,aAAa,CAijBtE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queues/operations/runJobs/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAG1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAarD,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,IAAI,CAAA;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACxC;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,OAAO,SAAgB,WAAW,KAAG,OAAO,CAAC,aAAa,CAyctE,CAAA"}
@@ -9,14 +9,7 @@ import { importHandlerPath } from './runJob/importHandlerPath.js';
9
9
  import { runJob } from './runJob/index.js';
10
10
  import { runJSONJob } from './runJSONJob/index.js';
11
11
  export const runJobs = async (args)=>{
12
- const { id, allQueues = false, limit = 10, overrideAccess, processingOrder, queue = 'default', randomID, req, req: { payload, payload: { config: { jobs: jobsConfig } } }, sequential, silent = false, where: whereFromProps } = args;
13
- console.log(`[${randomID}] 2 - runJobs started`, {
14
- id,
15
- allQueues,
16
- limit,
17
- queue,
18
- sequential
19
- });
12
+ const { id, allQueues = false, limit = 10, overrideAccess, processingOrder, queue = 'default', req, req: { payload, payload: { config: { jobs: jobsConfig } } }, sequential, silent = false, where: whereFromProps } = args;
20
13
  if (!overrideAccess) {
21
14
  /**
22
15
  * By default, jobsConfig.access.run will be `defaultAccess` which is a function that returns `true` if the user is logged in.
@@ -28,7 +21,6 @@ export const runJobs = async (args)=>{
28
21
  throw new Forbidden(req.t);
29
22
  }
30
23
  }
31
- console.log(`[${randomID}] 3 - access check passed`);
32
24
  const and = [
33
25
  {
34
26
  completedAt: {
@@ -70,7 +62,6 @@ export const runJobs = async (args)=>{
70
62
  if (whereFromProps) {
71
63
  and.push(whereFromProps);
72
64
  }
73
- console.log(`[${args?.randomID}] 4`);
74
65
  // Only enforce concurrency controls if the feature is enabled
75
66
  if (jobsConfig.enableConcurrencyControl) {
76
67
  // Find currently running jobs with concurrency keys to enforce exclusive concurrency
@@ -131,15 +122,10 @@ export const runJobs = async (args)=>{
131
122
  });
132
123
  }
133
124
  }
134
- console.log(`[${randomID}] 5 - concurrency control done, querying jobs`, {
135
- id,
136
- enableConcurrencyControl: jobsConfig.enableConcurrencyControl
137
- });
138
125
  // Find all jobs and ensure we set job to processing: true as early as possible to reduce the chance of
139
126
  // the same job being picked up by another worker
140
127
  let jobs = [];
141
128
  if (id) {
142
- console.log(`[${randomID}] 5.1 - fetching single job by ID: ${id}`);
143
129
  // Only one job to run
144
130
  const job = await updateJob({
145
131
  id,
@@ -151,16 +137,12 @@ export const runJobs = async (args)=>{
151
137
  req,
152
138
  returning: true
153
139
  });
154
- console.log(`[${randomID}] 5.2 - single job fetched`, {
155
- found: !!job
156
- });
157
140
  if (job) {
158
141
  jobs = [
159
142
  job
160
143
  ];
161
144
  }
162
145
  } else {
163
- console.log(`[${randomID}] 5.3 - fetching multiple jobs with limit: ${limit}`);
164
146
  let defaultProcessingOrder = payload.collections[jobsCollectionSlug]?.config.defaultSort ?? 'createdAt';
165
147
  const processingOrderConfig = jobsConfig.processingOrder;
166
148
  if (typeof processingOrderConfig === 'function') {
@@ -174,7 +156,6 @@ export const runJobs = async (args)=>{
174
156
  } else if (typeof processingOrderConfig === 'string') {
175
157
  defaultProcessingOrder = processingOrderConfig;
176
158
  }
177
- console.log(`[${randomID}] 5.3.1 - using where query "and":`, and);
178
159
  const updatedDocs = await updateJobs({
179
160
  data: {
180
161
  processing: true
@@ -189,38 +170,11 @@ export const runJobs = async (args)=>{
189
170
  and
190
171
  }
191
172
  });
192
- console.log(`[${randomID}] 5.4 - multiple jobs fetched`, {
193
- count: updatedDocs?.length ?? 0
194
- });
195
- if ((updatedDocs?.length ?? 0) > 0) {
196
- console.log(`[${randomID}] 5.5 - jobs found! fetched:`, {
197
- jobs: updatedDocs
198
- });
199
- }
200
- // Fetch ALL jobs using payload.db.find({})
201
- const allJobs = await payload.db.find({
202
- collection: jobsCollectionSlug,
203
- limit: 0,
204
- req
205
- });
206
- console.log(`[${randomID}] 5.6 - all jobs fetched`, {
207
- allJobs: allJobs?.docs,
208
- count: allJobs?.totalDocs
209
- });
210
- const anyRunnableJobs = allJobs?.docs?.some((job)=>job?.processing === false && job?.hasError === false && !job?.completedAt && !job?.waitUntil);
211
- if (anyRunnableJobs && updatedDocs?.length === 0) {
212
- console.log(`[${randomID}] 5.6.1 - potential issue here.`);
213
- }
214
173
  if (updatedDocs) {
215
174
  jobs = updatedDocs;
216
175
  }
217
176
  }
218
- console.log(`[${randomID}] 6 - jobs to process`, {
219
- count: jobs.length,
220
- jobIds: jobs.map((j)=>j.id)
221
- });
222
177
  if (!jobs.length) {
223
- console.log(`[${randomID}] 7 - no jobs found, returning early`);
224
178
  return {
225
179
  noJobsRemaining: true,
226
180
  remainingJobsFromQueried: 0
@@ -266,17 +220,12 @@ export const runJobs = async (args)=>{
266
220
  // Use only the filtered jobs going forward
267
221
  jobs = jobsToRun;
268
222
  }
269
- console.log(`[${randomID}] 8 - concurrency dedup done`, {
270
- jobsToRun: jobs.length
271
- });
272
223
  if (!jobs.length) {
273
- console.log(`[${randomID}] 9 - all jobs were duplicates, returning early`);
274
224
  return {
275
225
  noJobsRemaining: false,
276
226
  remainingJobsFromQueried: 0
277
227
  };
278
228
  }
279
- console.log(`[${randomID}] 10 - preparing to run ${jobs.length} jobs`);
280
229
  /**
281
230
  * Just for logging purposes, we want to know how many jobs are new and how many are existing (= already been tried).
282
231
  * This is only for logs - in the end we still want to run all jobs, regardless of whether they are new or existing.
@@ -291,10 +240,6 @@ export const runJobs = async (args)=>{
291
240
  existingJobs: [],
292
241
  newJobs: []
293
242
  });
294
- console.log(`[${randomID}] 11 - job breakdown`, {
295
- existingJobCount: existingJobs.length,
296
- newJobCount: newJobs.length
297
- });
298
243
  if (!silent || typeof silent === 'object' && !silent.info) {
299
244
  payload.logger.info({
300
245
  msg: `Running ${jobs.length} jobs.`,
@@ -304,11 +249,6 @@ export const runJobs = async (args)=>{
304
249
  }
305
250
  const successfullyCompletedJobs = [];
306
251
  const runSingleJob = async (job)=>{
307
- console.log(`[${randomID}] job:${job.id} - starting`, {
308
- taskSlug: job.taskSlug,
309
- totalTried: job.totalTried,
310
- workflowSlug: job.workflowSlug
311
- });
312
252
  if (!job.workflowSlug && !job.taskSlug) {
313
253
  throw new Error('Job must have either a workflowSlug or a taskSlug');
314
254
  }
@@ -322,7 +262,6 @@ export const runJobs = async (args)=>{
322
262
  }
323
263
  };
324
264
  if (!workflowConfig) {
325
- console.log(`[${randomID}] job:${job.id} - no workflow config found, skipping`);
326
265
  return {
327
266
  id: job.id,
328
267
  result: {
@@ -363,7 +302,6 @@ export const runJobs = async (args)=>{
363
302
  }
364
303
  }
365
304
  if (typeof workflowHandler === 'function') {
366
- console.log(`[${randomID}] job:${job.id} - running function handler`);
367
305
  const result = await runJob({
368
306
  job,
369
307
  req: jobReq,
@@ -372,9 +310,6 @@ export const runJobs = async (args)=>{
372
310
  workflowConfig,
373
311
  workflowHandler
374
312
  });
375
- console.log(`[${randomID}] job:${job.id} - completed`, {
376
- status: result.status
377
- });
378
313
  if (result.status === 'success') {
379
314
  successfullyCompletedJobs.push(job.id);
380
315
  }
@@ -383,7 +318,6 @@ export const runJobs = async (args)=>{
383
318
  result
384
319
  };
385
320
  } else {
386
- console.log(`[${randomID}] job:${job.id} - running JSON handler`);
387
321
  const result = await runJSONJob({
388
322
  job,
389
323
  req: jobReq,
@@ -392,9 +326,6 @@ export const runJobs = async (args)=>{
392
326
  workflowConfig,
393
327
  workflowHandler
394
328
  });
395
- console.log(`[${randomID}] job:${job.id} - completed`, {
396
- status: result.status
397
- });
398
329
  if (result.status === 'success') {
399
330
  successfullyCompletedJobs.push(job.id);
400
331
  }
@@ -405,9 +336,6 @@ export const runJobs = async (args)=>{
405
336
  }
406
337
  } catch (error) {
407
338
  if (error instanceof JobCancelledError) {
408
- console.log(`[${randomID}] job:${job.id} - cancelled`, {
409
- message: error.message
410
- });
411
339
  if (!job.error?.cancelled || !job.hasError || job.processing || job.completedAt || job.waitUntil) {
412
340
  // When using the local API to cancel jobs, the local API will update the job data for us to ensure the job is cancelled.
413
341
  // But when throwing a JobCancelledError within a task or workflow handler, we are responsible for updating the job data ourselves.
@@ -436,19 +364,11 @@ export const runJobs = async (args)=>{
436
364
  }
437
365
  };
438
366
  }
439
- console.log(`[${randomID}] job:${job.id} - error thrown`, {
440
- error: error instanceof Error ? error.message : String(error)
441
- });
442
367
  throw error;
443
368
  }
444
369
  };
445
- console.log(`[${randomID}] 12 - starting job execution`, {
446
- jobCount: jobs.length,
447
- sequential
448
- });
449
370
  let resultsArray = [];
450
371
  if (sequential) {
451
- console.log(`[${randomID}] 12.1 - running jobs sequentially`);
452
372
  for (const job of jobs){
453
373
  const result = await runSingleJob(job);
454
374
  if (result) {
@@ -456,18 +376,10 @@ export const runJobs = async (args)=>{
456
376
  }
457
377
  }
458
378
  } else {
459
- console.log(`[${randomID}] 12.2 - running jobs in parallel`);
460
379
  const jobPromises = jobs.map(runSingleJob);
461
380
  resultsArray = await Promise.all(jobPromises);
462
381
  }
463
- console.log(`[${randomID}] 13 - all jobs executed`, {
464
- resultsCount: resultsArray.length,
465
- successfulCount: successfullyCompletedJobs.length
466
- });
467
382
  if (jobsConfig.deleteJobOnComplete && successfullyCompletedJobs.length) {
468
- console.log(`[${randomID}] 14 - deleting completed jobs`, {
469
- count: successfullyCompletedJobs.length
470
- });
471
383
  try {
472
384
  if (jobsConfig.runHooks) {
473
385
  await payload.delete({
@@ -513,11 +425,6 @@ export const runJobs = async (args)=>{
513
425
  remainingJobsFromQueried++; // Can be retried
514
426
  }
515
427
  }
516
- console.log(`[${randomID}] 15 - runJobs complete`, {
517
- remainingJobsFromQueried,
518
- successCount: successfullyCompletedJobs.length,
519
- totalProcessed: Object.keys(resultsObject).length
520
- });
521
428
  return {
522
429
  jobStatus: resultsObject,
523
430
  remainingJobsFromQueried
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/queues/operations/runJobs/index.ts"],"sourcesContent":["import type { Job } from '../../../index.js'\nimport type { PayloadRequest, Sort, Where } from '../../../types/index.js'\nimport type { WorkflowJSON } from '../../config/types/workflowJSONTypes.js'\nimport type { WorkflowConfig, WorkflowHandler } from '../../config/types/workflowTypes.js'\nimport type { RunJobsSilent } from '../../localAPI.js'\nimport type { RunJobResult } from './runJob/index.js'\n\nimport { Forbidden } from '../../../errors/Forbidden.js'\nimport { isolateObjectProperty } from '../../../utilities/isolateObjectProperty.js'\nimport { jobsCollectionSlug } from '../../config/collection.js'\nimport { JobCancelledError } from '../../errors/index.js'\nimport { getCurrentDate } from '../../utilities/getCurrentDate.js'\nimport { updateJob, updateJobs } from '../../utilities/updateJob.js'\nimport { getUpdateJobFunction } from './runJob/getUpdateJobFunction.js'\nimport { importHandlerPath } from './runJob/importHandlerPath.js'\nimport { runJob } from './runJob/index.js'\nimport { runJSONJob } from './runJSONJob/index.js'\n\nexport type RunJobsArgs = {\n /**\n * If you want to run jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n /**\n * ID of the job to run\n */\n id?: number | string\n /**\n * The maximum number of jobs to run in this invocation\n *\n * @default 10\n */\n limit?: number\n overrideAccess?: boolean\n /**\n * Adjust the job processing order\n *\n * FIFO would equal `createdAt` and LIFO would equal `-createdAt`.\n *\n * @default all jobs for all queues will be executed in FIFO order.\n */\n processingOrder?: Sort\n /**\n * If you want to run jobs from a specific queue, set this to the queue name.\n *\n * @default jobs from the `default` queue will be executed.\n */\n queue?: string\n randomID?: string\n req: PayloadRequest\n /**\n * By default, jobs are run in parallel.\n * If you want to run them in sequence, set this to true.\n */\n sequential?: boolean\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n where?: Where\n}\n\nexport type RunJobsResult = {\n jobStatus?: Record<string, RunJobResult>\n /**\n * If this is true, there for sure are no jobs remaining, regardless of the limit\n */\n noJobsRemaining?: boolean\n /**\n * Out of the jobs that were queried & processed (within the set limit), how many are remaining and retryable?\n */\n remainingJobsFromQueried: number\n}\n\nexport const runJobs = async (args: RunJobsArgs): Promise<RunJobsResult> => {\n const {\n id,\n allQueues = false,\n limit = 10,\n overrideAccess,\n processingOrder,\n queue = 'default',\n randomID,\n req,\n req: {\n payload,\n payload: {\n config: { jobs: jobsConfig },\n },\n },\n sequential,\n silent = false,\n where: whereFromProps,\n } = args\n console.log(`[${randomID}] 2 - runJobs started`, {\n id,\n allQueues,\n limit,\n queue,\n sequential,\n })\n\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.run will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = jobsConfig?.access?.run ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n console.log(`[${randomID}] 3 - access check passed`)\n\n const and: Where[] = [\n {\n completedAt: {\n exists: false,\n },\n },\n {\n hasError: {\n not_equals: true,\n },\n },\n {\n processing: {\n equals: false,\n },\n },\n {\n or: [\n {\n waitUntil: {\n exists: false,\n },\n },\n {\n waitUntil: {\n less_than: getCurrentDate().toISOString(),\n },\n },\n ],\n },\n ]\n\n if (allQueues !== true) {\n and.push({\n queue: {\n equals: queue ?? 'default',\n },\n })\n }\n\n if (whereFromProps) {\n and.push(whereFromProps)\n }\n console.log(`[${args?.randomID}] 4`)\n\n // Only enforce concurrency controls if the feature is enabled\n if (jobsConfig.enableConcurrencyControl) {\n // Find currently running jobs with concurrency keys to enforce exclusive concurrency\n // Jobs with the same concurrencyKey should not run in parallel\n const runningJobsWithConcurrency = await payload.db.find({\n collection: jobsCollectionSlug,\n limit: 0,\n pagination: false,\n req: { transactionID: undefined },\n select: {\n concurrencyKey: true,\n },\n where: {\n and: [{ processing: { equals: true } }, { concurrencyKey: { exists: true } }],\n },\n })\n\n const runningConcurrencyKeys = new Set<string>()\n if (runningJobsWithConcurrency?.docs) {\n for (const doc of runningJobsWithConcurrency.docs) {\n const concurrencyKey = (doc as Job).concurrencyKey\n if (concurrencyKey) {\n runningConcurrencyKeys.add(concurrencyKey)\n }\n }\n }\n\n // Exclude jobs whose concurrencyKey is already running\n if (runningConcurrencyKeys.size > 0) {\n and.push({\n or: [\n // Jobs without a concurrency key can always run\n { concurrencyKey: { exists: false } },\n // Jobs with a concurrency key that is not currently running can run\n { concurrencyKey: { not_in: [...runningConcurrencyKeys] } },\n ],\n })\n }\n }\n\n console.log(`[${randomID}] 5 - concurrency control done, querying jobs`, {\n id,\n enableConcurrencyControl: jobsConfig.enableConcurrencyControl,\n })\n\n // Find all jobs and ensure we set job to processing: true as early as possible to reduce the chance of\n // the same job being picked up by another worker\n let jobs: Job[] = []\n\n if (id) {\n console.log(`[${randomID}] 5.1 - fetching single job by ID: ${id}`)\n\n // Only one job to run\n const job = await updateJob({\n id,\n data: {\n processing: true,\n },\n depth: jobsConfig.depth,\n disableTransaction: true,\n req,\n returning: true,\n })\n console.log(`[${randomID}] 5.2 - single job fetched`, { found: !!job })\n\n if (job) {\n jobs = [job]\n }\n } else {\n console.log(`[${randomID}] 5.3 - fetching multiple jobs with limit: ${limit}`)\n\n let defaultProcessingOrder: Sort =\n payload.collections[jobsCollectionSlug]?.config.defaultSort ?? 'createdAt'\n\n const processingOrderConfig = jobsConfig.processingOrder\n if (typeof processingOrderConfig === 'function') {\n defaultProcessingOrder = await processingOrderConfig(args)\n } else if (typeof processingOrderConfig === 'object' && !Array.isArray(processingOrderConfig)) {\n if (\n !allQueues &&\n queue &&\n processingOrderConfig.queues &&\n processingOrderConfig.queues[queue]\n ) {\n defaultProcessingOrder = processingOrderConfig.queues[queue]\n } else if (processingOrderConfig.default) {\n defaultProcessingOrder = processingOrderConfig.default\n }\n } else if (typeof processingOrderConfig === 'string') {\n defaultProcessingOrder = processingOrderConfig\n }\n\n console.log(`[${randomID}] 5.3.1 - using where query \"and\":`, and)\n\n const updatedDocs = await updateJobs({\n data: {\n processing: true,\n },\n depth: jobsConfig.depth,\n disableTransaction: true,\n limit,\n req,\n returning: true,\n sort: processingOrder ?? defaultProcessingOrder,\n where: { and },\n })\n console.log(`[${randomID}] 5.4 - multiple jobs fetched`, { count: updatedDocs?.length ?? 0 })\n if ((updatedDocs?.length ?? 0) > 0) {\n console.log(`[${randomID}] 5.5 - jobs found! fetched:`, { jobs: updatedDocs })\n }\n // Fetch ALL jobs using payload.db.find({})\n const allJobs = await payload.db.find({\n collection: jobsCollectionSlug,\n limit: 0,\n req,\n })\n console.log(`[${randomID}] 5.6 - all jobs fetched`, {\n allJobs: allJobs?.docs,\n count: allJobs?.totalDocs,\n })\n\n const anyRunnableJobs = allJobs?.docs?.some(\n (job: any) =>\n job?.processing === false &&\n job?.hasError === false &&\n !job?.completedAt &&\n !job?.waitUntil,\n )\n if (anyRunnableJobs && updatedDocs?.length === 0) {\n console.log(`[${randomID}] 5.6.1 - potential issue here.`)\n }\n\n if (updatedDocs) {\n jobs = updatedDocs\n }\n }\n console.log(`[${randomID}] 6 - jobs to process`, {\n count: jobs.length,\n jobIds: jobs.map((j) => j.id),\n })\n\n if (!jobs.length) {\n console.log(`[${randomID}] 7 - no jobs found, returning early`)\n\n return {\n noJobsRemaining: true,\n remainingJobsFromQueried: 0,\n }\n }\n\n // Only handle concurrency deduplication if the feature is enabled\n if (jobsConfig.enableConcurrencyControl) {\n // Handle the case where multiple jobs with the same concurrencyKey were picked up in the same batch\n // We should only run one job per concurrencyKey, release the others back to pending\n const seenConcurrencyKeys = new Set<string>()\n const jobsToRun: Job[] = []\n const jobsToRelease: Job[] = []\n\n for (const job of jobs) {\n if (job.concurrencyKey) {\n if (seenConcurrencyKeys.has(job.concurrencyKey)) {\n // This job has the same concurrencyKey as another job we're already running\n jobsToRelease.push(job)\n } else {\n seenConcurrencyKeys.add(job.concurrencyKey)\n jobsToRun.push(job)\n }\n } else {\n jobsToRun.push(job)\n }\n }\n\n // Release duplicate concurrencyKey jobs back to pending state\n if (jobsToRelease.length > 0) {\n const releaseIds = jobsToRelease.map((job) => job.id)\n await updateJobs({\n data: { processing: false },\n disableTransaction: true,\n req,\n returning: false,\n where: { id: { in: releaseIds } },\n })\n }\n\n // Use only the filtered jobs going forward\n jobs = jobsToRun\n }\n console.log(`[${randomID}] 8 - concurrency dedup done`, { jobsToRun: jobs.length })\n\n if (!jobs.length) {\n console.log(`[${randomID}] 9 - all jobs were duplicates, returning early`)\n\n return {\n noJobsRemaining: false,\n remainingJobsFromQueried: 0,\n }\n }\n console.log(`[${randomID}] 10 - preparing to run ${jobs.length} jobs`)\n\n /**\n * Just for logging purposes, we want to know how many jobs are new and how many are existing (= already been tried).\n * This is only for logs - in the end we still want to run all jobs, regardless of whether they are new or existing.\n */\n const { existingJobs, newJobs } = jobs.reduce(\n (acc, job) => {\n if (job.totalTried > 0) {\n acc.existingJobs.push(job)\n } else {\n acc.newJobs.push(job)\n }\n return acc\n },\n { existingJobs: [] as Job[], newJobs: [] as Job[] },\n )\n\n console.log(`[${randomID}] 11 - job breakdown`, {\n existingJobCount: existingJobs.length,\n newJobCount: newJobs.length,\n })\n\n if (!silent || (typeof silent === 'object' && !silent.info)) {\n payload.logger.info({\n msg: `Running ${jobs.length} jobs.`,\n new: newJobs?.length,\n retrying: existingJobs?.length,\n })\n }\n\n const successfullyCompletedJobs: (number | string)[] = []\n\n const runSingleJob = async (\n job: Job,\n ): Promise<{\n id: number | string\n result: RunJobResult\n }> => {\n console.log(`[${randomID}] job:${job.id} - starting`, {\n taskSlug: job.taskSlug,\n totalTried: job.totalTried,\n workflowSlug: job.workflowSlug,\n })\n\n if (!job.workflowSlug && !job.taskSlug) {\n throw new Error('Job must have either a workflowSlug or a taskSlug')\n }\n const jobReq = isolateObjectProperty(req, 'transactionID')\n\n const workflowConfig: WorkflowConfig =\n job.workflowSlug && jobsConfig.workflows?.length\n ? jobsConfig.workflows.find(({ slug }) => slug === job.workflowSlug)!\n : {\n slug: 'singleTask',\n handler: async ({ job, tasks }) => {\n await tasks[job.taskSlug as string]!('1', {\n input: job.input,\n })\n },\n }\n\n if (!workflowConfig) {\n console.log(`[${randomID}] job:${job.id} - no workflow config found, skipping`)\n return {\n id: job.id,\n result: {\n status: 'error',\n },\n } // Skip jobs with no workflow configuration\n }\n\n try {\n const updateJob = getUpdateJobFunction(job, jobReq)\n\n // the runner will either be passed to the config\n // OR it will be a path, which we will need to import via eval to avoid\n // Next.js compiler dynamic import expression errors\n let workflowHandler: WorkflowHandler | WorkflowJSON\n if (\n typeof workflowConfig.handler === 'function' ||\n (typeof workflowConfig.handler === 'object' && Array.isArray(workflowConfig.handler))\n ) {\n workflowHandler = workflowConfig.handler\n } else {\n workflowHandler = await importHandlerPath<typeof workflowHandler>(workflowConfig.handler)\n\n if (!workflowHandler) {\n const jobLabel = job.workflowSlug || `Task: ${job.taskSlug}`\n const errorMessage = `Can't find runner while importing with the path ${workflowConfig.handler} in job type ${jobLabel}.`\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n payload.logger.error(errorMessage)\n }\n\n await updateJob({\n error: {\n error: errorMessage,\n },\n hasError: true,\n processing: false,\n })\n\n return {\n id: job.id,\n result: {\n status: 'error-reached-max-retries',\n },\n }\n }\n }\n\n if (typeof workflowHandler === 'function') {\n console.log(`[${randomID}] job:${job.id} - running function handler`)\n const result = await runJob({\n job,\n req: jobReq,\n silent,\n updateJob,\n workflowConfig,\n workflowHandler,\n })\n\n console.log(`[${randomID}] job:${job.id} - completed`, { status: result.status })\n\n if (result.status === 'success') {\n successfullyCompletedJobs.push(job.id)\n }\n\n return { id: job.id, result }\n } else {\n console.log(`[${randomID}] job:${job.id} - running JSON handler`)\n const result = await runJSONJob({\n job,\n req: jobReq,\n silent,\n updateJob,\n workflowConfig,\n workflowHandler,\n })\n\n console.log(`[${randomID}] job:${job.id} - completed`, { status: result.status })\n\n if (result.status === 'success') {\n successfullyCompletedJobs.push(job.id)\n }\n\n return { id: job.id, result }\n }\n } catch (error) {\n if (error instanceof JobCancelledError) {\n console.log(`[${randomID}] job:${job.id} - cancelled`, { message: error.message })\n if (\n !(job.error as Record<string, unknown> | undefined)?.cancelled ||\n !job.hasError ||\n job.processing ||\n job.completedAt ||\n job.waitUntil\n ) {\n // When using the local API to cancel jobs, the local API will update the job data for us to ensure the job is cancelled.\n // But when throwing a JobCancelledError within a task or workflow handler, we are responsible for updating the job data ourselves.\n await updateJob({\n id: job.id,\n data: {\n completedAt: null,\n error: {\n cancelled: true,\n message: error.message,\n },\n hasError: true,\n processing: false,\n waitUntil: null,\n },\n depth: 0,\n disableTransaction: true,\n req,\n returning: false,\n })\n }\n\n return {\n id: job.id,\n result: {\n status: 'error-reached-max-retries',\n },\n }\n }\n console.log(`[${randomID}] job:${job.id} - error thrown`, {\n error: error instanceof Error ? error.message : String(error),\n })\n throw error\n }\n }\n\n console.log(`[${randomID}] 12 - starting job execution`, {\n jobCount: jobs.length,\n sequential,\n })\n\n let resultsArray: { id: number | string; result: RunJobResult }[] = []\n if (sequential) {\n console.log(`[${randomID}] 12.1 - running jobs sequentially`)\n\n for (const job of jobs) {\n const result = await runSingleJob(job)\n if (result) {\n resultsArray.push(result)\n }\n }\n } else {\n console.log(`[${randomID}] 12.2 - running jobs in parallel`)\n const jobPromises = jobs.map(runSingleJob)\n resultsArray = (await Promise.all(jobPromises)) as {\n id: number | string\n result: RunJobResult\n }[]\n }\n\n console.log(`[${randomID}] 13 - all jobs executed`, {\n resultsCount: resultsArray.length,\n successfulCount: successfullyCompletedJobs.length,\n })\n\n if (jobsConfig.deleteJobOnComplete && successfullyCompletedJobs.length) {\n console.log(`[${randomID}] 14 - deleting completed jobs`, {\n count: successfullyCompletedJobs.length,\n })\n try {\n if (jobsConfig.runHooks) {\n await payload.delete({\n collection: jobsCollectionSlug,\n depth: 0, // can be 0 since we're not returning anything\n disableTransaction: true,\n where: { id: { in: successfullyCompletedJobs } },\n })\n } else {\n await payload.db.deleteMany({\n collection: jobsCollectionSlug,\n where: { id: { in: successfullyCompletedJobs } },\n })\n }\n } catch (err) {\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n payload.logger.error({\n err,\n msg: `Failed to delete jobs ${successfullyCompletedJobs.join(', ')} on complete`,\n })\n }\n }\n }\n\n const resultsObject: RunJobsResult['jobStatus'] = resultsArray.reduce(\n (acc, cur) => {\n if (cur !== null) {\n // Check if there's a valid result to include\n acc[cur.id] = cur.result\n }\n return acc\n },\n {} as Record<string, RunJobResult>,\n )\n\n let remainingJobsFromQueried = 0\n for (const jobID in resultsObject) {\n const jobResult = resultsObject[jobID]\n if (jobResult?.status === 'error') {\n remainingJobsFromQueried++ // Can be retried\n }\n }\n\n console.log(`[${randomID}] 15 - runJobs complete`, {\n remainingJobsFromQueried,\n successCount: successfullyCompletedJobs.length,\n totalProcessed: Object.keys(resultsObject).length,\n })\n\n return {\n jobStatus: resultsObject,\n remainingJobsFromQueried,\n }\n}\n"],"names":["Forbidden","isolateObjectProperty","jobsCollectionSlug","JobCancelledError","getCurrentDate","updateJob","updateJobs","getUpdateJobFunction","importHandlerPath","runJob","runJSONJob","runJobs","args","id","allQueues","limit","overrideAccess","processingOrder","queue","randomID","req","payload","config","jobs","jobsConfig","sequential","silent","where","whereFromProps","console","log","accessFn","access","run","hasAccess","t","and","completedAt","exists","hasError","not_equals","processing","equals","or","waitUntil","less_than","toISOString","push","enableConcurrencyControl","runningJobsWithConcurrency","db","find","collection","pagination","transactionID","undefined","select","concurrencyKey","runningConcurrencyKeys","Set","docs","doc","add","size","not_in","job","data","depth","disableTransaction","returning","found","defaultProcessingOrder","collections","defaultSort","processingOrderConfig","Array","isArray","queues","default","updatedDocs","sort","count","length","allJobs","totalDocs","anyRunnableJobs","some","jobIds","map","j","noJobsRemaining","remainingJobsFromQueried","seenConcurrencyKeys","jobsToRun","jobsToRelease","has","releaseIds","in","existingJobs","newJobs","reduce","acc","totalTried","existingJobCount","newJobCount","info","logger","msg","new","retrying","successfullyCompletedJobs","runSingleJob","taskSlug","workflowSlug","Error","jobReq","workflowConfig","workflows","slug","handler","tasks","input","result","status","workflowHandler","jobLabel","errorMessage","error","message","cancelled","String","jobCount","resultsArray","jobPromises","Promise","all","resultsCount","successfulCount","deleteJobOnComplete","runHooks","delete","deleteMany","err","join","resultsObject","cur","jobID","jobResult","successCount","totalProcessed","Object","keys","jobStatus"],"mappings":"AAOA,SAASA,SAAS,QAAQ,+BAA8B;AACxD,SAASC,qBAAqB,QAAQ,8CAA6C;AACnF,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,SAAS,EAAEC,UAAU,QAAQ,+BAA8B;AACpE,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,UAAU,QAAQ,wBAAuB;AAkElD,OAAO,MAAMC,UAAU,OAAOC;IAC5B,MAAM,EACJC,EAAE,EAC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E;QACjDwE;QACAyD,cAActC,0BAA0B5B,MAAM;QAC9CmE,gBAAgBC,OAAOC,IAAI,CAACP,eAAe9D,MAAM;IACnD;IAEA,OAAO;QACLsE,WAAWR;QACXrD;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/queues/operations/runJobs/index.ts"],"sourcesContent":["import type { Job } from '../../../index.js'\nimport type { PayloadRequest, Sort, Where } from '../../../types/index.js'\nimport type { WorkflowJSON } from '../../config/types/workflowJSONTypes.js'\nimport type { WorkflowConfig, WorkflowHandler } from '../../config/types/workflowTypes.js'\nimport type { RunJobsSilent } from '../../localAPI.js'\nimport type { RunJobResult } from './runJob/index.js'\n\nimport { Forbidden } from '../../../errors/Forbidden.js'\nimport { isolateObjectProperty } from '../../../utilities/isolateObjectProperty.js'\nimport { jobsCollectionSlug } from '../../config/collection.js'\nimport { JobCancelledError } from '../../errors/index.js'\nimport { getCurrentDate } from '../../utilities/getCurrentDate.js'\nimport { updateJob, updateJobs } from '../../utilities/updateJob.js'\nimport { getUpdateJobFunction } from './runJob/getUpdateJobFunction.js'\nimport { importHandlerPath } from './runJob/importHandlerPath.js'\nimport { runJob } from './runJob/index.js'\nimport { runJSONJob } from './runJSONJob/index.js'\n\nexport type RunJobsArgs = {\n /**\n * If you want to run jobs from all queues, set this to true.\n * If you set this to true, the `queue` property will be ignored.\n *\n * @default false\n */\n allQueues?: boolean\n /**\n * ID of the job to run\n */\n id?: number | string\n /**\n * The maximum number of jobs to run in this invocation\n *\n * @default 10\n */\n limit?: number\n overrideAccess?: boolean\n /**\n * Adjust the job processing order\n *\n * FIFO would equal `createdAt` and LIFO would equal `-createdAt`.\n *\n * @default all jobs for all queues will be executed in FIFO order.\n */\n processingOrder?: Sort\n /**\n * If you want to run jobs from a specific queue, set this to the queue name.\n *\n * @default jobs from the `default` queue will be executed.\n */\n queue?: string\n req: PayloadRequest\n /**\n * By default, jobs are run in parallel.\n * If you want to run them in sequence, set this to true.\n */\n sequential?: boolean\n /**\n * If set to true, the job system will not log any output to the console (for both info and error logs).\n * Can be an option for more granular control over logging.\n *\n * This will not automatically affect user-configured logs (e.g. if you call `console.log` or `payload.logger.info` in your job code).\n *\n * @default false\n */\n silent?: RunJobsSilent\n where?: Where\n}\n\nexport type RunJobsResult = {\n jobStatus?: Record<string, RunJobResult>\n /**\n * If this is true, there for sure are no jobs remaining, regardless of the limit\n */\n noJobsRemaining?: boolean\n /**\n * Out of the jobs that were queried & processed (within the set limit), how many are remaining and retryable?\n */\n remainingJobsFromQueried: number\n}\n\nexport const runJobs = async (args: RunJobsArgs): Promise<RunJobsResult> => {\n const {\n id,\n allQueues = false,\n limit = 10,\n overrideAccess,\n processingOrder,\n queue = 'default',\n req,\n req: {\n payload,\n payload: {\n config: { jobs: jobsConfig },\n },\n },\n sequential,\n silent = false,\n where: whereFromProps,\n } = args\n\n if (!overrideAccess) {\n /**\n * By default, jobsConfig.access.run will be `defaultAccess` which is a function that returns `true` if the user is logged in.\n */\n const accessFn = jobsConfig?.access?.run ?? (() => true)\n const hasAccess = await accessFn({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n const and: Where[] = [\n {\n completedAt: {\n exists: false,\n },\n },\n {\n hasError: {\n not_equals: true,\n },\n },\n {\n processing: {\n equals: false,\n },\n },\n {\n or: [\n {\n waitUntil: {\n exists: false,\n },\n },\n {\n waitUntil: {\n less_than: getCurrentDate().toISOString(),\n },\n },\n ],\n },\n ]\n\n if (allQueues !== true) {\n and.push({\n queue: {\n equals: queue ?? 'default',\n },\n })\n }\n\n if (whereFromProps) {\n and.push(whereFromProps)\n }\n\n // Only enforce concurrency controls if the feature is enabled\n if (jobsConfig.enableConcurrencyControl) {\n // Find currently running jobs with concurrency keys to enforce exclusive concurrency\n // Jobs with the same concurrencyKey should not run in parallel\n const runningJobsWithConcurrency = await payload.db.find({\n collection: jobsCollectionSlug,\n limit: 0,\n pagination: false,\n req: { transactionID: undefined },\n select: {\n concurrencyKey: true,\n },\n where: {\n and: [{ processing: { equals: true } }, { concurrencyKey: { exists: true } }],\n },\n })\n\n const runningConcurrencyKeys = new Set<string>()\n if (runningJobsWithConcurrency?.docs) {\n for (const doc of runningJobsWithConcurrency.docs) {\n const concurrencyKey = (doc as Job).concurrencyKey\n if (concurrencyKey) {\n runningConcurrencyKeys.add(concurrencyKey)\n }\n }\n }\n\n // Exclude jobs whose concurrencyKey is already running\n if (runningConcurrencyKeys.size > 0) {\n and.push({\n or: [\n // Jobs without a concurrency key can always run\n { concurrencyKey: { exists: false } },\n // Jobs with a concurrency key that is not currently running can run\n { concurrencyKey: { not_in: [...runningConcurrencyKeys] } },\n ],\n })\n }\n }\n\n // Find all jobs and ensure we set job to processing: true as early as possible to reduce the chance of\n // the same job being picked up by another worker\n let jobs: Job[] = []\n\n if (id) {\n // Only one job to run\n const job = await updateJob({\n id,\n data: {\n processing: true,\n },\n depth: jobsConfig.depth,\n disableTransaction: true,\n req,\n returning: true,\n })\n if (job) {\n jobs = [job]\n }\n } else {\n let defaultProcessingOrder: Sort =\n payload.collections[jobsCollectionSlug]?.config.defaultSort ?? 'createdAt'\n\n const processingOrderConfig = jobsConfig.processingOrder\n if (typeof processingOrderConfig === 'function') {\n defaultProcessingOrder = await processingOrderConfig(args)\n } else if (typeof processingOrderConfig === 'object' && !Array.isArray(processingOrderConfig)) {\n if (\n !allQueues &&\n queue &&\n processingOrderConfig.queues &&\n processingOrderConfig.queues[queue]\n ) {\n defaultProcessingOrder = processingOrderConfig.queues[queue]\n } else if (processingOrderConfig.default) {\n defaultProcessingOrder = processingOrderConfig.default\n }\n } else if (typeof processingOrderConfig === 'string') {\n defaultProcessingOrder = processingOrderConfig\n }\n const updatedDocs = await updateJobs({\n data: {\n processing: true,\n },\n depth: jobsConfig.depth,\n disableTransaction: true,\n limit,\n req,\n returning: true,\n sort: processingOrder ?? defaultProcessingOrder,\n where: { and },\n })\n\n if (updatedDocs) {\n jobs = updatedDocs\n }\n }\n\n if (!jobs.length) {\n return {\n noJobsRemaining: true,\n remainingJobsFromQueried: 0,\n }\n }\n\n // Only handle concurrency deduplication if the feature is enabled\n if (jobsConfig.enableConcurrencyControl) {\n // Handle the case where multiple jobs with the same concurrencyKey were picked up in the same batch\n // We should only run one job per concurrencyKey, release the others back to pending\n const seenConcurrencyKeys = new Set<string>()\n const jobsToRun: Job[] = []\n const jobsToRelease: Job[] = []\n\n for (const job of jobs) {\n if (job.concurrencyKey) {\n if (seenConcurrencyKeys.has(job.concurrencyKey)) {\n // This job has the same concurrencyKey as another job we're already running\n jobsToRelease.push(job)\n } else {\n seenConcurrencyKeys.add(job.concurrencyKey)\n jobsToRun.push(job)\n }\n } else {\n jobsToRun.push(job)\n }\n }\n\n // Release duplicate concurrencyKey jobs back to pending state\n if (jobsToRelease.length > 0) {\n const releaseIds = jobsToRelease.map((job) => job.id)\n await updateJobs({\n data: { processing: false },\n disableTransaction: true,\n req,\n returning: false,\n where: { id: { in: releaseIds } },\n })\n }\n\n // Use only the filtered jobs going forward\n jobs = jobsToRun\n }\n\n if (!jobs.length) {\n return {\n noJobsRemaining: false,\n remainingJobsFromQueried: 0,\n }\n }\n\n /**\n * Just for logging purposes, we want to know how many jobs are new and how many are existing (= already been tried).\n * This is only for logs - in the end we still want to run all jobs, regardless of whether they are new or existing.\n */\n const { existingJobs, newJobs } = jobs.reduce(\n (acc, job) => {\n if (job.totalTried > 0) {\n acc.existingJobs.push(job)\n } else {\n acc.newJobs.push(job)\n }\n return acc\n },\n { existingJobs: [] as Job[], newJobs: [] as Job[] },\n )\n\n if (!silent || (typeof silent === 'object' && !silent.info)) {\n payload.logger.info({\n msg: `Running ${jobs.length} jobs.`,\n new: newJobs?.length,\n retrying: existingJobs?.length,\n })\n }\n\n const successfullyCompletedJobs: (number | string)[] = []\n\n const runSingleJob = async (\n job: Job,\n ): Promise<{\n id: number | string\n result: RunJobResult\n }> => {\n if (!job.workflowSlug && !job.taskSlug) {\n throw new Error('Job must have either a workflowSlug or a taskSlug')\n }\n const jobReq = isolateObjectProperty(req, 'transactionID')\n\n const workflowConfig: WorkflowConfig =\n job.workflowSlug && jobsConfig.workflows?.length\n ? jobsConfig.workflows.find(({ slug }) => slug === job.workflowSlug)!\n : {\n slug: 'singleTask',\n handler: async ({ job, tasks }) => {\n await tasks[job.taskSlug as string]!('1', {\n input: job.input,\n })\n },\n }\n\n if (!workflowConfig) {\n return {\n id: job.id,\n result: {\n status: 'error',\n },\n } // Skip jobs with no workflow configuration\n }\n\n try {\n const updateJob = getUpdateJobFunction(job, jobReq)\n\n // the runner will either be passed to the config\n // OR it will be a path, which we will need to import via eval to avoid\n // Next.js compiler dynamic import expression errors\n let workflowHandler: WorkflowHandler | WorkflowJSON\n if (\n typeof workflowConfig.handler === 'function' ||\n (typeof workflowConfig.handler === 'object' && Array.isArray(workflowConfig.handler))\n ) {\n workflowHandler = workflowConfig.handler\n } else {\n workflowHandler = await importHandlerPath<typeof workflowHandler>(workflowConfig.handler)\n\n if (!workflowHandler) {\n const jobLabel = job.workflowSlug || `Task: ${job.taskSlug}`\n const errorMessage = `Can't find runner while importing with the path ${workflowConfig.handler} in job type ${jobLabel}.`\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n payload.logger.error(errorMessage)\n }\n\n await updateJob({\n error: {\n error: errorMessage,\n },\n hasError: true,\n processing: false,\n })\n\n return {\n id: job.id,\n result: {\n status: 'error-reached-max-retries',\n },\n }\n }\n }\n\n if (typeof workflowHandler === 'function') {\n const result = await runJob({\n job,\n req: jobReq,\n silent,\n updateJob,\n workflowConfig,\n workflowHandler,\n })\n\n if (result.status === 'success') {\n successfullyCompletedJobs.push(job.id)\n }\n\n return { id: job.id, result }\n } else {\n const result = await runJSONJob({\n job,\n req: jobReq,\n silent,\n updateJob,\n workflowConfig,\n workflowHandler,\n })\n\n if (result.status === 'success') {\n successfullyCompletedJobs.push(job.id)\n }\n\n return { id: job.id, result }\n }\n } catch (error) {\n if (error instanceof JobCancelledError) {\n if (\n !(job.error as Record<string, unknown> | undefined)?.cancelled ||\n !job.hasError ||\n job.processing ||\n job.completedAt ||\n job.waitUntil\n ) {\n // When using the local API to cancel jobs, the local API will update the job data for us to ensure the job is cancelled.\n // But when throwing a JobCancelledError within a task or workflow handler, we are responsible for updating the job data ourselves.\n await updateJob({\n id: job.id,\n data: {\n completedAt: null,\n error: {\n cancelled: true,\n message: error.message,\n },\n hasError: true,\n processing: false,\n waitUntil: null,\n },\n depth: 0,\n disableTransaction: true,\n req,\n returning: false,\n })\n }\n\n return {\n id: job.id,\n result: {\n status: 'error-reached-max-retries',\n },\n }\n }\n throw error\n }\n }\n\n let resultsArray: { id: number | string; result: RunJobResult }[] = []\n if (sequential) {\n for (const job of jobs) {\n const result = await runSingleJob(job)\n if (result) {\n resultsArray.push(result)\n }\n }\n } else {\n const jobPromises = jobs.map(runSingleJob)\n resultsArray = (await Promise.all(jobPromises)) as {\n id: number | string\n result: RunJobResult\n }[]\n }\n\n if (jobsConfig.deleteJobOnComplete && successfullyCompletedJobs.length) {\n try {\n if (jobsConfig.runHooks) {\n await payload.delete({\n collection: jobsCollectionSlug,\n depth: 0, // can be 0 since we're not returning anything\n disableTransaction: true,\n where: { id: { in: successfullyCompletedJobs } },\n })\n } else {\n await payload.db.deleteMany({\n collection: jobsCollectionSlug,\n where: { id: { in: successfullyCompletedJobs } },\n })\n }\n } catch (err) {\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n payload.logger.error({\n err,\n msg: `Failed to delete jobs ${successfullyCompletedJobs.join(', ')} on complete`,\n })\n }\n }\n }\n\n const resultsObject: RunJobsResult['jobStatus'] = resultsArray.reduce(\n (acc, cur) => {\n if (cur !== null) {\n // Check if there's a valid result to include\n acc[cur.id] = cur.result\n }\n return acc\n },\n {} as Record<string, RunJobResult>,\n )\n\n let remainingJobsFromQueried = 0\n for (const jobID in resultsObject) {\n const jobResult = resultsObject[jobID]\n if (jobResult?.status === 'error') {\n remainingJobsFromQueried++ // Can be retried\n }\n }\n\n return {\n jobStatus: resultsObject,\n remainingJobsFromQueried,\n }\n}\n"],"names":["Forbidden","isolateObjectProperty","jobsCollectionSlug","JobCancelledError","getCurrentDate","updateJob","updateJobs","getUpdateJobFunction","importHandlerPath","runJob","runJSONJob","runJobs","args","id","allQueues","limit","overrideAccess","processingOrder","queue","req","payload","config","jobs","jobsConfig","sequential","silent","where","whereFromProps","accessFn","access","run","hasAccess","t","and","completedAt","exists","hasError","not_equals","processing","equals","or","waitUntil","less_than","toISOString","push","enableConcurrencyControl","runningJobsWithConcurrency","db","find","collection","pagination","transactionID","undefined","select","concurrencyKey","runningConcurrencyKeys","Set","docs","doc","add","size","not_in","job","data","depth","disableTransaction","returning","defaultProcessingOrder","collections","defaultSort","processingOrderConfig","Array","isArray","queues","default","updatedDocs","sort","length","noJobsRemaining","remainingJobsFromQueried","seenConcurrencyKeys","jobsToRun","jobsToRelease","has","releaseIds","map","in","existingJobs","newJobs","reduce","acc","totalTried","info","logger","msg","new","retrying","successfullyCompletedJobs","runSingleJob","workflowSlug","taskSlug","Error","jobReq","workflowConfig","workflows","slug","handler","tasks","input","result","status","workflowHandler","jobLabel","errorMessage","error","cancelled","message","resultsArray","jobPromises","Promise","all","deleteJobOnComplete","runHooks","delete","deleteMany","err","join","resultsObject","cur","jobID","jobResult","jobStatus"],"mappings":"AAOA,SAASA,SAAS,QAAQ,+BAA8B;AACxD,SAASC,qBAAqB,QAAQ,8CAA6C;AACnF,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,SAAS,EAAEC,UAAU,QAAQ,+BAA8B;AACpE,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,SAASC,UAAU,QAAQ,wBAAuB;AAiElD,OAAO,MAAMC,UAAU,OAAOC;IAC5B,MAAM,EACJC,EAAE,EACFC,YAAY,KAAK,EAC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,GAAG,CAACF;IAIpC;IAEA,IAAI/F,WAAWkG,mBAAmB,IAAIxB,0BAA0BpB,MAAM,EAAE;QACtE,IAAI;YACF,IAAItD,WAAWmG,QAAQ,EAAE;gBACvB,MAAMtG,QAAQuG,MAAM,CAAC;oBACnB1E,YAAY/C;oBACZ8D,OAAO;oBACPC,oBAAoB;oBACpBvC,OAAO;wBAAEb,IAAI;4BAAEyE,IAAIW;wBAA0B;oBAAE;gBACjD;YACF,OAAO;gBACL,MAAM7E,QAAQ2B,EAAE,CAAC6E,UAAU,CAAC;oBAC1B3E,YAAY/C;oBACZwB,OAAO;wBAAEb,IAAI;4BAAEyE,IAAIW;wBAA0B;oBAAE;gBACjD;YACF;QACF,EAAE,OAAO4B,KAAK;YACZ,IAAI,CAACpG,UAAW,OAAOA,WAAW,YAAY,CAACA,OAAOyF,KAAK,EAAG;gBAC5D9F,QAAQyE,MAAM,CAACqB,KAAK,CAAC;oBACnBW;oBACA/B,KAAK,CAAC,sBAAsB,EAAEG,0BAA0B6B,IAAI,CAAC,MAAM,YAAY,CAAC;gBAClF;YACF;QACF;IACF;IAEA,MAAMC,gBAA4CV,aAAa5B,MAAM,CACnE,CAACC,KAAKsC;QACJ,IAAIA,QAAQ,MAAM;YAChB,6CAA6C;YAC7CtC,GAAG,CAACsC,IAAInH,EAAE,CAAC,GAAGmH,IAAInB,MAAM;QAC1B;QACA,OAAOnB;IACT,GACA,CAAC;IAGH,IAAIX,2BAA2B;IAC/B,IAAK,MAAMkD,SAASF,cAAe;QACjC,MAAMG,YAAYH,aAAa,CAACE,MAAM;QACtC,IAAIC,WAAWpB,WAAW,SAAS;YACjC/B,4BAA2B,iBAAiB;QAC9C;IACF;IAEA,OAAO;QACLoD,WAAWJ;QACXhD;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.75.0-internal.8e0f8ba",
3
+ "version": "3.75.0",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -115,7 +115,7 @@
115
115
  "undici": "7.18.2",
116
116
  "uuid": "10.0.0",
117
117
  "ws": "^8.16.0",
118
- "@payloadcms/translations": "3.75.0-internal.8e0f8ba"
118
+ "@payloadcms/translations": "3.75.0"
119
119
  },
120
120
  "devDependencies": {
121
121
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",