payload 3.71.0-internal.cbf546e → 3.71.0-internal.ef75fa0
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.
- package/dist/index.bundled.d.ts +62 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/queues/config/collection.d.ts.map +1 -1
- package/dist/queues/config/collection.js +22 -1
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +12 -0
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/config/types/taskTypes.d.ts +8 -1
- package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
- package/dist/queues/config/types/taskTypes.js.map +1 -1
- package/dist/queues/config/types/workflowTypes.d.ts +42 -0
- package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
- package/dist/queues/config/types/workflowTypes.js.map +1 -1
- package/dist/queues/localAPI.d.ts +12 -0
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/localAPI.js +97 -0
- package/dist/queues/localAPI.js.map +1 -1
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.js +106 -0
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -140,6 +140,18 @@ export type JobsConfig = {
|
|
|
140
140
|
* @deprecated - this will be removed in 4.0
|
|
141
141
|
*/
|
|
142
142
|
depth?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Enable concurrency controls for workflows and tasks.
|
|
145
|
+
* When enabled, adds a `concurrencyKey` field to the jobs collection schema.
|
|
146
|
+
* This allows workflows and tasks to use the `concurrency` option to prevent race conditions.
|
|
147
|
+
*
|
|
148
|
+
* **Important:** Enabling this may require a database migration depending on your database adapter,
|
|
149
|
+
* as it adds a new indexed field to the jobs collection schema.
|
|
150
|
+
*
|
|
151
|
+
* @default false
|
|
152
|
+
* @todo In 4.0, this will default to `true`.
|
|
153
|
+
*/
|
|
154
|
+
enableConcurrencyControl?: boolean;
|
|
143
155
|
/**
|
|
144
156
|
* Override any settings on the default Jobs collection. Accepts the default collection and allows you to return
|
|
145
157
|
* a new collection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,gBAAgB,KAAK,YAAY,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;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queues/config/types/index.ts"],"sourcesContent":["import type { CollectionConfig, Job } from '../../../index.js'\nimport type { MaybePromise, Payload, PayloadRequest, Sort } from '../../../types/index.js'\nimport type { RunJobsSilent } from '../../localAPI.js'\nimport type { RunJobsArgs } from '../../operations/runJobs/index.js'\nimport type { JobStats } from '../global.js'\nimport type { TaskConfig } from './taskTypes.js'\nimport type { WorkflowConfig } from './workflowTypes.js'\n\nexport type AutorunCronConfig = {\n /**\n * If you want to autoRUn 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 cron schedule for the job.\n * @default '* * * * *' (every minute).\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron?: string\n /**\n * By default, the autorun will attempt to schedule jobs for tasks and workflows that have a `schedule` property, given\n * the queue name is the same.\n *\n * Set this to `true` to disable the scheduling of jobs automatically.\n *\n * @default false\n */\n disableScheduling?: boolean\n /**\n * The limit for the job. This can be overridden by the user. Defaults to 10.\n */\n limit?: number\n /**\n * The queue name for the job.\n *\n * @default 'default'\n */\n queue?: string\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}\n\nexport type RunJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type RunJobAccess = (args: RunJobAccessArgs) => MaybePromise<boolean>\n\nexport type QueueJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type CancelJobAccessArgs = {\n req: PayloadRequest\n}\nexport type CancelJobAccess = (args: CancelJobAccessArgs) => MaybePromise<boolean>\nexport type QueueJobAccess = (args: QueueJobAccessArgs) => MaybePromise<boolean>\n\nexport type SanitizedJobsConfig = {\n /**\n * If set to `true`, the job system is enabled and a payload-jobs collection exists.\n * This property is automatically set during sanitization.\n */\n enabled?: boolean\n /**\n * If set to `true`, at least one task or workflow has scheduling enabled.\n * This property is automatically set during sanitization.\n */\n scheduling?: boolean\n /**\n * If set to `true`, a payload-job-stats global exists.\n * This property is automatically set during sanitization.\n */\n stats?: boolean\n} & JobsConfig\nexport type JobsConfig = {\n /**\n * Specify access control to determine who can interact with jobs.\n */\n access?: {\n /**\n * By default, all logged-in users can cancel jobs.\n */\n cancel?: CancelJobAccess\n /**\n * By default, all logged-in users can queue jobs.\n */\n queue?: QueueJobAccess\n /**\n * By default, all logged-in users can run jobs.\n */\n run?: RunJobAccess\n }\n /** Adds information about the parent job to the task log. This is useful for debugging and tracking the flow of tasks.\n *\n * In 4.0, this will default to `true`.\n *\n * @default false\n */\n addParentToTaskLog?: boolean\n /**\n * Allows you to configure cron jobs that automatically run queued jobs\n * at specified intervals. Note that this does not _queue_ new jobs - only\n * _runs_ jobs that are already in the specified queue.\n *\n * @remark this property should not be used on serverless platforms like Vercel\n */\n autoRun?: ((payload: Payload) => MaybePromise<AutorunCronConfig[]>) | AutorunCronConfig[]\n /**\n * Determine whether or not to delete a job after it has successfully completed.\n */\n deleteJobOnComplete?: boolean\n /**\n * Specify depth for retrieving jobs from the queue.\n * This should be as low as possible in order for job retrieval\n * to be as efficient as possible. Setting it to anything higher than\n * 0 will drastically affect performance, as less efficient database\n * queries will be used.\n *\n * @default 0\n * @deprecated - this will be removed in 4.0\n */\n depth?: number\n /**\n * Override any settings on the default Jobs collection. Accepts the default collection and allows you to return\n * a new collection.\n */\n jobsCollectionOverrides?: (args: { defaultJobsCollection: CollectionConfig }) => CollectionConfig\n /**\n * Adjust the job processing order using a Payload sort string. This can be set globally or per queue.\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?:\n | ((args: RunJobsArgs) => Promise<Sort> | Sort)\n | {\n default?: Sort\n queues: {\n [queue: string]: Sort\n }\n }\n | Sort\n /**\n * By default, the job system uses direct database calls for optimal performance.\n * If you added custom hooks to your jobs collection, you can set this to true to\n * use the standard Payload API for all job operations. This is discouraged, as it will\n * drastically affect performance.\n *\n * @default false\n * @deprecated - this will be removed in 4.0\n */\n runHooks?: boolean\n /**\n * A function that will be executed before Payload picks up jobs which are configured by the `jobs.autorun` function.\n * If this function returns true, jobs will be queried and picked up. If it returns false, jobs will not be run.\n * @default undefined - if this function is not defined, jobs will be run - as if () => true was passed.\n * @param payload\n * @returns boolean\n */\n shouldAutoRun?: (payload: Payload) => MaybePromise<boolean>\n /**\n * Define all possible tasks here\n */\n tasks?: TaskConfig<any>[]\n /**\n * Define all the workflows here. Workflows orchestrate the flow of multiple tasks.\n */\n workflows?: WorkflowConfig<any>[]\n}\n\nexport type Queueable = {\n scheduleConfig: ScheduleConfig\n taskConfig?: TaskConfig\n // If not set, queue it immediately\n waitUntil?: Date\n workflowConfig?: WorkflowConfig\n}\n\nexport type BeforeScheduleFn = (args: {\n defaultBeforeSchedule: BeforeScheduleFn\n /**\n * payload-job-stats global data\n */\n jobStats: JobStats\n queueable: Queueable\n req: PayloadRequest\n}) => MaybePromise<{\n input?: object\n shouldSchedule: boolean\n waitUntil?: Date\n}>\n\nexport type AfterScheduleFn = (\n args: {\n defaultAfterSchedule: AfterScheduleFn\n /**\n * payload-job-stats global data. If the global does not exist, it will be null.\n */\n jobStats: JobStats | null\n queueable: Queueable\n req: PayloadRequest\n } & (\n | {\n error: Error\n job?: never\n status: 'error'\n }\n | {\n error?: never\n job: Job\n status: 'success'\n }\n | {\n error?: never\n job?: never\n /**\n * If the beforeSchedule hook returned `shouldSchedule: false`, this will be called with status `skipped`.\n */\n status: 'skipped'\n }\n ),\n) => MaybePromise<void>\n\nexport type ScheduleConfig = {\n /**\n * The cron for scheduling the job.\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron: string\n hooks?: {\n /**\n * Functions that will be executed after the job has been successfully scheduled.\n *\n * @default By default, global update?? Unless global update should happen before\n */\n afterSchedule?: AfterScheduleFn\n /**\n * Functions that will be executed before the job is scheduled.\n * You can use this to control whether or not the job should be scheduled, or what input\n * data should be passed to the job.\n *\n * @default By default, this has one function that returns { shouldSchedule: true } if the following conditions are met:\n * - There currently is no job of the same type in the specified queue that is currently running\n * - There currently is no job of the same type in the specified queue that is scheduled to run in the future\n * - There currently is no job of the same type in the specified queue that failed previously but can be retried\n */\n beforeSchedule?: BeforeScheduleFn\n }\n /**\n * Queue to which the scheduled job will be added.\n */\n queue: string\n}\n"],"names":[],"mappings":"AA0PA,WA4CC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/queues/config/types/index.ts"],"sourcesContent":["import type { CollectionConfig, Job } from '../../../index.js'\nimport type { MaybePromise, Payload, PayloadRequest, Sort } from '../../../types/index.js'\nimport type { RunJobsSilent } from '../../localAPI.js'\nimport type { RunJobsArgs } from '../../operations/runJobs/index.js'\nimport type { JobStats } from '../global.js'\nimport type { TaskConfig } from './taskTypes.js'\nimport type { WorkflowConfig } from './workflowTypes.js'\n\nexport type AutorunCronConfig = {\n /**\n * If you want to autoRUn 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 cron schedule for the job.\n * @default '* * * * *' (every minute).\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron?: string\n /**\n * By default, the autorun will attempt to schedule jobs for tasks and workflows that have a `schedule` property, given\n * the queue name is the same.\n *\n * Set this to `true` to disable the scheduling of jobs automatically.\n *\n * @default false\n */\n disableScheduling?: boolean\n /**\n * The limit for the job. This can be overridden by the user. Defaults to 10.\n */\n limit?: number\n /**\n * The queue name for the job.\n *\n * @default 'default'\n */\n queue?: string\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}\n\nexport type RunJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type RunJobAccess = (args: RunJobAccessArgs) => MaybePromise<boolean>\n\nexport type QueueJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type CancelJobAccessArgs = {\n req: PayloadRequest\n}\nexport type CancelJobAccess = (args: CancelJobAccessArgs) => MaybePromise<boolean>\nexport type QueueJobAccess = (args: QueueJobAccessArgs) => MaybePromise<boolean>\n\nexport type SanitizedJobsConfig = {\n /**\n * If set to `true`, the job system is enabled and a payload-jobs collection exists.\n * This property is automatically set during sanitization.\n */\n enabled?: boolean\n /**\n * If set to `true`, at least one task or workflow has scheduling enabled.\n * This property is automatically set during sanitization.\n */\n scheduling?: boolean\n /**\n * If set to `true`, a payload-job-stats global exists.\n * This property is automatically set during sanitization.\n */\n stats?: boolean\n} & JobsConfig\nexport type JobsConfig = {\n /**\n * Specify access control to determine who can interact with jobs.\n */\n access?: {\n /**\n * By default, all logged-in users can cancel jobs.\n */\n cancel?: CancelJobAccess\n /**\n * By default, all logged-in users can queue jobs.\n */\n queue?: QueueJobAccess\n /**\n * By default, all logged-in users can run jobs.\n */\n run?: RunJobAccess\n }\n /** Adds information about the parent job to the task log. This is useful for debugging and tracking the flow of tasks.\n *\n * In 4.0, this will default to `true`.\n *\n * @default false\n */\n addParentToTaskLog?: boolean\n /**\n * Allows you to configure cron jobs that automatically run queued jobs\n * at specified intervals. Note that this does not _queue_ new jobs - only\n * _runs_ jobs that are already in the specified queue.\n *\n * @remark this property should not be used on serverless platforms like Vercel\n */\n autoRun?: ((payload: Payload) => MaybePromise<AutorunCronConfig[]>) | AutorunCronConfig[]\n /**\n * Determine whether or not to delete a job after it has successfully completed.\n */\n deleteJobOnComplete?: boolean\n /**\n * Specify depth for retrieving jobs from the queue.\n * This should be as low as possible in order for job retrieval\n * to be as efficient as possible. Setting it to anything higher than\n * 0 will drastically affect performance, as less efficient database\n * queries will be used.\n *\n * @default 0\n * @deprecated - this will be removed in 4.0\n */\n depth?: number\n /**\n * Enable concurrency controls for workflows and tasks.\n * When enabled, adds a `concurrencyKey` field to the jobs collection schema.\n * This allows workflows and tasks to use the `concurrency` option to prevent race conditions.\n *\n * **Important:** Enabling this may require a database migration depending on your database adapter,\n * as it adds a new indexed field to the jobs collection schema.\n *\n * @default false\n * @todo In 4.0, this will default to `true`.\n */\n enableConcurrencyControl?: boolean\n /**\n * Override any settings on the default Jobs collection. Accepts the default collection and allows you to return\n * a new collection.\n */\n jobsCollectionOverrides?: (args: { defaultJobsCollection: CollectionConfig }) => CollectionConfig\n /**\n * Adjust the job processing order using a Payload sort string. This can be set globally or per queue.\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?:\n | ((args: RunJobsArgs) => Promise<Sort> | Sort)\n | {\n default?: Sort\n queues: {\n [queue: string]: Sort\n }\n }\n | Sort\n /**\n * By default, the job system uses direct database calls for optimal performance.\n * If you added custom hooks to your jobs collection, you can set this to true to\n * use the standard Payload API for all job operations. This is discouraged, as it will\n * drastically affect performance.\n *\n * @default false\n * @deprecated - this will be removed in 4.0\n */\n runHooks?: boolean\n /**\n * A function that will be executed before Payload picks up jobs which are configured by the `jobs.autorun` function.\n * If this function returns true, jobs will be queried and picked up. If it returns false, jobs will not be run.\n * @default undefined - if this function is not defined, jobs will be run - as if () => true was passed.\n * @param payload\n * @returns boolean\n */\n shouldAutoRun?: (payload: Payload) => MaybePromise<boolean>\n /**\n * Define all possible tasks here\n */\n tasks?: TaskConfig<any>[]\n /**\n * Define all the workflows here. Workflows orchestrate the flow of multiple tasks.\n */\n workflows?: WorkflowConfig<any>[]\n}\n\nexport type Queueable = {\n scheduleConfig: ScheduleConfig\n taskConfig?: TaskConfig\n // If not set, queue it immediately\n waitUntil?: Date\n workflowConfig?: WorkflowConfig\n}\n\nexport type BeforeScheduleFn = (args: {\n defaultBeforeSchedule: BeforeScheduleFn\n /**\n * payload-job-stats global data\n */\n jobStats: JobStats\n queueable: Queueable\n req: PayloadRequest\n}) => MaybePromise<{\n input?: object\n shouldSchedule: boolean\n waitUntil?: Date\n}>\n\nexport type AfterScheduleFn = (\n args: {\n defaultAfterSchedule: AfterScheduleFn\n /**\n * payload-job-stats global data. If the global does not exist, it will be null.\n */\n jobStats: JobStats | null\n queueable: Queueable\n req: PayloadRequest\n } & (\n | {\n error: Error\n job?: never\n status: 'error'\n }\n | {\n error?: never\n job: Job\n status: 'success'\n }\n | {\n error?: never\n job?: never\n /**\n * If the beforeSchedule hook returned `shouldSchedule: false`, this will be called with status `skipped`.\n */\n status: 'skipped'\n }\n ),\n) => MaybePromise<void>\n\nexport type ScheduleConfig = {\n /**\n * The cron for scheduling the job.\n *\n * @example\n * ┌───────────── (optional) second (0 - 59)\n * │ ┌───────────── minute (0 - 59)\n * │ │ ┌───────────── hour (0 - 23)\n * │ │ │ ┌───────────── day of the month (1 - 31)\n * │ │ │ │ ┌───────────── month (1 - 12)\n * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)\n * │ │ │ │ │ │\n * │ │ │ │ │ │\n * - '* 0 * * * *' every hour at minute 0\n * - '* 0 0 * * *' daily at midnight\n * - '* 0 0 * * 0' weekly at midnight on Sundays\n * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month\n * - '* 0/5 * * * *' every 5 minutes\n * - '* * * * * *' every second\n */\n cron: string\n hooks?: {\n /**\n * Functions that will be executed after the job has been successfully scheduled.\n *\n * @default By default, global update?? Unless global update should happen before\n */\n afterSchedule?: AfterScheduleFn\n /**\n * Functions that will be executed before the job is scheduled.\n * You can use this to control whether or not the job should be scheduled, or what input\n * data should be passed to the job.\n *\n * @default By default, this has one function that returns { shouldSchedule: true } if the following conditions are met:\n * - There currently is no job of the same type in the specified queue that is currently running\n * - There currently is no job of the same type in the specified queue that is scheduled to run in the future\n * - There currently is no job of the same type in the specified queue that failed previously but can be retried\n */\n beforeSchedule?: BeforeScheduleFn\n }\n /**\n * Queue to which the scheduled job will be added.\n */\n queue: string\n}\n"],"names":[],"mappings":"AAsQA,WA4CC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Field, Job, MaybePromise, PayloadRequest, StringKeyOf, TypedJobs } from '../../../index.js';
|
|
2
2
|
import type { ScheduleConfig } from './index.js';
|
|
3
|
-
import type { SingleTaskStatus } from './workflowTypes.js';
|
|
3
|
+
import type { ConcurrencyConfig, SingleTaskStatus } from './workflowTypes.js';
|
|
4
4
|
export type TaskInputOutput = {
|
|
5
5
|
input: object;
|
|
6
6
|
output: object;
|
|
@@ -161,6 +161,13 @@ export type RetryConfig = {
|
|
|
161
161
|
shouldRestore?: boolean | ShouldRestoreFn;
|
|
162
162
|
};
|
|
163
163
|
export type TaskConfig<TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput = TaskType> = {
|
|
164
|
+
/**
|
|
165
|
+
* Job concurrency controls for preventing race conditions.
|
|
166
|
+
*
|
|
167
|
+
* Can be an object with full options, or a shorthand function that just returns the key
|
|
168
|
+
* (in which case exclusive defaults to true).
|
|
169
|
+
*/
|
|
170
|
+
concurrency?: ConcurrencyConfig<TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['input'] : TTaskSlugOrInputOutput extends TaskInputOutput ? TTaskSlugOrInputOutput['input'] : object>;
|
|
164
171
|
/**
|
|
165
172
|
* The function that should be responsible for running the job.
|
|
166
173
|
* You can either pass a string-based path to the job function file, or the job function itself.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskTypes.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/taskTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,GAAG,EACH,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"taskTypes.d.ts","sourceRoot":"","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,EAAE,KAAK,EAAE,CAAA;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAA;IAC1C;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAA;IAC3B;;OAEG;IACH,IAAI,EAAE,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,sBAAsB,GAAG,MAAM,CAAA;CAChG,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queues/config/types/taskTypes.ts"],"sourcesContent":["import type {\n Field,\n Job,\n MaybePromise,\n PayloadRequest,\n StringKeyOf,\n TypedJobs,\n} from '../../../index.js'\nimport type { ScheduleConfig } from './index.js'\nimport type { SingleTaskStatus } from './workflowTypes.js'\n\nexport type TaskInputOutput = {\n input: object\n output: object\n}\nexport type TaskHandlerResult<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n> =\n | {\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n errorMessage?: string\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n state: 'failed'\n }\n | {\n output: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['output']\n : TTaskSlugOrInputOutput extends TaskInputOutput // Check if it's actually TaskInputOutput type\n ? TTaskSlugOrInputOutput['output']\n : never\n state?: 'succeeded'\n }\n\nexport type TaskHandlerArgs<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n TWorkflowSlug extends keyof TypedJobs['workflows'] = string,\n> = {\n /**\n * Use this function to run a sub-task from within another task.\n */\n inlineTask: RunInlineTaskFunction\n input: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['input']\n : TTaskSlugOrInputOutput extends TaskInputOutput // Check if it's actually TaskInputOutput type\n ? TTaskSlugOrInputOutput['input']\n : never\n job: Job<TWorkflowSlug>\n req: PayloadRequest\n tasks: RunTaskFunctions\n}\n\n/**\n * Inline tasks in JSON workflows have no input, as they can just get the input from job.taskStatus\n */\nexport type TaskHandlerArgsNoInput<TWorkflowInput extends false | object = false> = {\n job: Job<TWorkflowInput>\n req: PayloadRequest\n}\n\nexport type TaskHandler<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n TWorkflowSlug extends keyof TypedJobs['workflows'] = string,\n> = (\n args: TaskHandlerArgs<TTaskSlugOrInputOutput, TWorkflowSlug>,\n) => MaybePromise<TaskHandlerResult<TTaskSlugOrInputOutput>>\n\n/**\n * @todo rename to TaskSlug in 4.0, similar to CollectionSlug\n */\nexport type TaskType = StringKeyOf<TypedJobs['tasks']>\n\n// Extracts the type of `input` corresponding to each task\nexport type TaskInput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['input']\n\nexport type TaskOutput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['output']\n\nexport type TaskHandlerResults = {\n [TTaskSlug in keyof TypedJobs['tasks']]: {\n [id: string]: TaskHandlerResult<TTaskSlug>\n }\n}\n\n// Helper type to create correct argument type for the function corresponding to each task.\nexport type RunTaskFunctionArgs<TTaskSlug extends keyof TypedJobs['tasks']> = {\n input?: TaskInput<TTaskSlug>\n /**\n * Specify the number of times that this task should be retried if it fails for any reason.\n * If this is undefined, the task will either inherit the retries from the workflow or have no retries.\n * If this is 0, the task will not be retried.\n *\n * @default By default, tasks are not retried and `retries` is `undefined`.\n */\n retries?: number | RetryConfig | undefined\n}\n\nexport type RunTaskFunction<TTaskSlug extends keyof TypedJobs['tasks']> = (\n taskID: string,\n taskArgs?: RunTaskFunctionArgs<TTaskSlug>,\n) => Promise<TaskOutput<TTaskSlug>>\n\nexport type RunTaskFunctions = {\n [TTaskSlug in keyof TypedJobs['tasks']]: RunTaskFunction<TTaskSlug>\n}\n\nexport type RunInlineTaskFunction = <TTaskInput extends object, TTaskOutput extends object>(\n taskID: string,\n taskArgs: {\n input?: TTaskInput\n /**\n * Specify the number of times that this task should be retried if it fails for any reason.\n * If this is undefined, the task will either inherit the retries from the workflow or have no retries.\n * If this is 0, the task will not be retried.\n *\n * @default By default, tasks are not retried and `retries` is `undefined`.\n */\n retries?: number | RetryConfig | undefined\n // This is the same as TaskHandler, but typed out explicitly in order to improve type inference\n task: (args: {\n inlineTask: RunInlineTaskFunction\n input: TTaskInput\n job: Job<any>\n req: PayloadRequest\n tasks: RunTaskFunctions\n }) => MaybePromise<\n | {\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n errorMessage?: string\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n state: 'failed'\n }\n | {\n output: TTaskOutput\n state?: 'succeeded'\n }\n >\n },\n) => Promise<TTaskOutput>\n\nexport type TaskCallbackArgs = {\n /**\n * Input data passed to the task\n */\n input?: object\n job: Job\n req: PayloadRequest\n taskStatus: null | SingleTaskStatus<string>\n}\n\nexport type ShouldRestoreFn = (\n args: { taskStatus: SingleTaskStatus<string> } & Omit<TaskCallbackArgs, 'taskStatus'>,\n) => MaybePromise<boolean>\nexport type TaskCallbackFn = (args: TaskCallbackArgs) => MaybePromise<void>\n\nexport type RetryConfig = {\n /**\n * This controls how many times the task should be retried if it fails.\n *\n * @default undefined - attempts are either inherited from the workflow retry config or set to 0.\n */\n attempts?: number\n /**\n * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.\n *\n * If this is set on a single task, the longest backoff time of a task will determine the time until the entire workflow is retried.\n */\n backoff?: {\n /**\n * Base delay between running jobs in ms\n */\n delay?: number\n /**\n * @default fixed\n *\n * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.\n * If fixed (default) is used, the delay will be the same between each retry.\n *\n * If exponential is used, the delay will increase exponentially with each retry.\n *\n * @example\n * delay = 1000\n * attempts = 3\n * type = 'fixed'\n *\n * The task will be retried 3 times with a delay of 1000ms between each retry.\n *\n * @example\n * delay = 1000\n * attempts = 3\n * type = 'exponential'\n *\n * The task will be retried 3 times with a delay of 1000ms, 2000ms, and 4000ms between each retry.\n */\n type: 'exponential' | 'fixed'\n }\n /**\n * This controls whether the task output should be restored if the task previously succeeded and the workflow is being retried.\n *\n * If this is set to false, the task will be re-run even if it previously succeeded, ignoring the maximum number of retries.\n *\n * If this is set to true, the task will only be re-run if it previously failed.\n *\n * If this is a function, the return value of the function will determine whether the task should be re-run. This can be used for more complex restore logic,\n * e.g you may want to re-run a task up until a certain point and then restore it, or only re-run a task if the input has changed.\n *\n * @default true - the task output will be restored if the task previously succeeded.\n */\n shouldRestore?: boolean | ShouldRestoreFn\n}\n\nexport type TaskConfig<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput = TaskType,\n> = {\n /**\n * The function that should be responsible for running the job.\n * You can either pass a string-based path to the job function file, or the job function itself.\n *\n * If you are using large dependencies within your job, you might prefer to pass the string path\n * because that will avoid bundling large dependencies in your Next.js app. Passing a string path is an advanced feature\n * that may require a sophisticated build pipeline in order to work.\n */\n handler: string | TaskHandler<TTaskSlugOrInputOutput>\n /**\n * Define the input field schema - payload will generate a type for this schema.\n */\n inputSchema?: Field[]\n /**\n * You can use interfaceName to change the name of the interface that is generated for this task. By default, this is \"Task\" + the capitalized task slug.\n */\n interfaceName?: string\n /**\n * Define a human-friendly label for this task.\n */\n label?: string\n /**\n * Function to be executed if the task fails.\n */\n onFail?: TaskCallbackFn\n /**\n * Function to be executed if the task succeeds.\n */\n onSuccess?: TaskCallbackFn\n /**\n * Define the output field schema - payload will generate a type for this schema.\n */\n outputSchema?: Field[]\n /**\n * Specify the number of times that this step should be retried if it fails.\n * If this is undefined, the task will either inherit the retries from the workflow or have no retries.\n * If this is 0, the task will not be retried.\n *\n * @default By default, tasks are not retried and `retries` is `undefined`.\n */\n retries?: number | RetryConfig | undefined\n /**\n * Allows automatically scheduling this task to run regularly at a specified interval.\n */\n schedule?: ScheduleConfig[]\n /**\n * Define a slug-based name for this job. This slug needs to be unique among both tasks and workflows.\n */\n slug: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TTaskSlugOrInputOutput : string\n}\n"],"names":[],"mappings":"AAyNA,WAoDC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/queues/config/types/taskTypes.ts"],"sourcesContent":["import type {\n Field,\n Job,\n MaybePromise,\n PayloadRequest,\n StringKeyOf,\n TypedJobs,\n} from '../../../index.js'\nimport type { ScheduleConfig } from './index.js'\nimport type { ConcurrencyConfig, SingleTaskStatus } from './workflowTypes.js'\n\nexport type TaskInputOutput = {\n input: object\n output: object\n}\nexport type TaskHandlerResult<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n> =\n | {\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n errorMessage?: string\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n state: 'failed'\n }\n | {\n output: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['output']\n : TTaskSlugOrInputOutput extends TaskInputOutput // Check if it's actually TaskInputOutput type\n ? TTaskSlugOrInputOutput['output']\n : never\n state?: 'succeeded'\n }\n\nexport type TaskHandlerArgs<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n TWorkflowSlug extends keyof TypedJobs['workflows'] = string,\n> = {\n /**\n * Use this function to run a sub-task from within another task.\n */\n inlineTask: RunInlineTaskFunction\n input: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['input']\n : TTaskSlugOrInputOutput extends TaskInputOutput // Check if it's actually TaskInputOutput type\n ? TTaskSlugOrInputOutput['input']\n : never\n job: Job<TWorkflowSlug>\n req: PayloadRequest\n tasks: RunTaskFunctions\n}\n\n/**\n * Inline tasks in JSON workflows have no input, as they can just get the input from job.taskStatus\n */\nexport type TaskHandlerArgsNoInput<TWorkflowInput extends false | object = false> = {\n job: Job<TWorkflowInput>\n req: PayloadRequest\n}\n\nexport type TaskHandler<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n TWorkflowSlug extends keyof TypedJobs['workflows'] = string,\n> = (\n args: TaskHandlerArgs<TTaskSlugOrInputOutput, TWorkflowSlug>,\n) => MaybePromise<TaskHandlerResult<TTaskSlugOrInputOutput>>\n\n/**\n * @todo rename to TaskSlug in 4.0, similar to CollectionSlug\n */\nexport type TaskType = StringKeyOf<TypedJobs['tasks']>\n\n// Extracts the type of `input` corresponding to each task\nexport type TaskInput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['input']\n\nexport type TaskOutput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['output']\n\nexport type TaskHandlerResults = {\n [TTaskSlug in keyof TypedJobs['tasks']]: {\n [id: string]: TaskHandlerResult<TTaskSlug>\n }\n}\n\n// Helper type to create correct argument type for the function corresponding to each task.\nexport type RunTaskFunctionArgs<TTaskSlug extends keyof TypedJobs['tasks']> = {\n input?: TaskInput<TTaskSlug>\n /**\n * Specify the number of times that this task should be retried if it fails for any reason.\n * If this is undefined, the task will either inherit the retries from the workflow or have no retries.\n * If this is 0, the task will not be retried.\n *\n * @default By default, tasks are not retried and `retries` is `undefined`.\n */\n retries?: number | RetryConfig | undefined\n}\n\nexport type RunTaskFunction<TTaskSlug extends keyof TypedJobs['tasks']> = (\n taskID: string,\n taskArgs?: RunTaskFunctionArgs<TTaskSlug>,\n) => Promise<TaskOutput<TTaskSlug>>\n\nexport type RunTaskFunctions = {\n [TTaskSlug in keyof TypedJobs['tasks']]: RunTaskFunction<TTaskSlug>\n}\n\nexport type RunInlineTaskFunction = <TTaskInput extends object, TTaskOutput extends object>(\n taskID: string,\n taskArgs: {\n input?: TTaskInput\n /**\n * Specify the number of times that this task should be retried if it fails for any reason.\n * If this is undefined, the task will either inherit the retries from the workflow or have no retries.\n * If this is 0, the task will not be retried.\n *\n * @default By default, tasks are not retried and `retries` is `undefined`.\n */\n retries?: number | RetryConfig | undefined\n // This is the same as TaskHandler, but typed out explicitly in order to improve type inference\n task: (args: {\n inlineTask: RunInlineTaskFunction\n input: TTaskInput\n job: Job<any>\n req: PayloadRequest\n tasks: RunTaskFunctions\n }) => MaybePromise<\n | {\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n errorMessage?: string\n /**\n * @deprecated Returning `state: 'failed'` is deprecated. Throw an error instead.\n */\n state: 'failed'\n }\n | {\n output: TTaskOutput\n state?: 'succeeded'\n }\n >\n },\n) => Promise<TTaskOutput>\n\nexport type TaskCallbackArgs = {\n /**\n * Input data passed to the task\n */\n input?: object\n job: Job\n req: PayloadRequest\n taskStatus: null | SingleTaskStatus<string>\n}\n\nexport type ShouldRestoreFn = (\n args: { taskStatus: SingleTaskStatus<string> } & Omit<TaskCallbackArgs, 'taskStatus'>,\n) => MaybePromise<boolean>\nexport type TaskCallbackFn = (args: TaskCallbackArgs) => MaybePromise<void>\n\nexport type RetryConfig = {\n /**\n * This controls how many times the task should be retried if it fails.\n *\n * @default undefined - attempts are either inherited from the workflow retry config or set to 0.\n */\n attempts?: number\n /**\n * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.\n *\n * If this is set on a single task, the longest backoff time of a task will determine the time until the entire workflow is retried.\n */\n backoff?: {\n /**\n * Base delay between running jobs in ms\n */\n delay?: number\n /**\n * @default fixed\n *\n * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.\n * If fixed (default) is used, the delay will be the same between each retry.\n *\n * If exponential is used, the delay will increase exponentially with each retry.\n *\n * @example\n * delay = 1000\n * attempts = 3\n * type = 'fixed'\n *\n * The task will be retried 3 times with a delay of 1000ms between each retry.\n *\n * @example\n * delay = 1000\n * attempts = 3\n * type = 'exponential'\n *\n * The task will be retried 3 times with a delay of 1000ms, 2000ms, and 4000ms between each retry.\n */\n type: 'exponential' | 'fixed'\n }\n /**\n * This controls whether the task output should be restored if the task previously succeeded and the workflow is being retried.\n *\n * If this is set to false, the task will be re-run even if it previously succeeded, ignoring the maximum number of retries.\n *\n * If this is set to true, the task will only be re-run if it previously failed.\n *\n * If this is a function, the return value of the function will determine whether the task should be re-run. This can be used for more complex restore logic,\n * e.g you may want to re-run a task up until a certain point and then restore it, or only re-run a task if the input has changed.\n *\n * @default true - the task output will be restored if the task previously succeeded.\n */\n shouldRestore?: boolean | ShouldRestoreFn\n}\n\nexport type TaskConfig<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput = TaskType,\n> = {\n /**\n * Job concurrency controls for preventing race conditions.\n *\n * Can be an object with full options, or a shorthand function that just returns the key\n * (in which case exclusive defaults to true).\n */\n concurrency?: ConcurrencyConfig<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['input']\n : TTaskSlugOrInputOutput extends TaskInputOutput\n ? TTaskSlugOrInputOutput['input']\n : object\n >\n /**\n * The function that should be responsible for running the job.\n * You can either pass a string-based path to the job function file, or the job function itself.\n *\n * If you are using large dependencies within your job, you might prefer to pass the string path\n * because that will avoid bundling large dependencies in your Next.js app. Passing a string path is an advanced feature\n * that may require a sophisticated build pipeline in order to work.\n */\n handler: string | TaskHandler<TTaskSlugOrInputOutput>\n /**\n * Define the input field schema - payload will generate a type for this schema.\n */\n inputSchema?: Field[]\n /**\n * You can use interfaceName to change the name of the interface that is generated for this task. By default, this is \"Task\" + the capitalized task slug.\n */\n interfaceName?: string\n /**\n * Define a human-friendly label for this task.\n */\n label?: string\n /**\n * Function to be executed if the task fails.\n */\n onFail?: TaskCallbackFn\n /**\n * Function to be executed if the task succeeds.\n */\n onSuccess?: TaskCallbackFn\n /**\n * Define the output field schema - payload will generate a type for this schema.\n */\n outputSchema?: Field[]\n /**\n * Specify the number of times that this step should be retried if it fails.\n * If this is undefined, the task will either inherit the retries from the workflow or have no retries.\n * If this is 0, the task will not be retried.\n *\n * @default By default, tasks are not retried and `retries` is `undefined`.\n */\n retries?: number | RetryConfig | undefined\n /**\n * Allows automatically scheduling this task to run regularly at a specified interval.\n */\n schedule?: ScheduleConfig[]\n /**\n * Define a slug-based name for this job. This slug needs to be unique among both tasks and workflows.\n */\n slug: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TTaskSlugOrInputOutput : string\n}\n"],"names":[],"mappings":"AAyNA,WAiEC"}
|
|
@@ -27,6 +27,10 @@ export type JobLog = {
|
|
|
27
27
|
*/
|
|
28
28
|
export type BaseJob<TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false> = {
|
|
29
29
|
completedAt?: null | string;
|
|
30
|
+
/**
|
|
31
|
+
* Used for concurrency control. Jobs with the same key are subject to exclusive/supersedes rules.
|
|
32
|
+
*/
|
|
33
|
+
concurrencyKey?: null | string;
|
|
30
34
|
createdAt: string;
|
|
31
35
|
error?: unknown;
|
|
32
36
|
hasError?: boolean;
|
|
@@ -90,7 +94,45 @@ export type JobTaskStatus = {
|
|
|
90
94
|
[taskID: string]: SingleTaskStatus<taskSlug>;
|
|
91
95
|
};
|
|
92
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Concurrency configuration for workflows and tasks.
|
|
99
|
+
* Controls how jobs with the same concurrency key are handled.
|
|
100
|
+
*/
|
|
101
|
+
export type ConcurrencyConfig<TInput = object> = ((args: {
|
|
102
|
+
input: TInput;
|
|
103
|
+
queue: string;
|
|
104
|
+
}) => string) | {
|
|
105
|
+
/**
|
|
106
|
+
* Only one job with this key can run at a time.
|
|
107
|
+
* Other jobs with the same key remain queued until the running job completes.
|
|
108
|
+
* @default true
|
|
109
|
+
*/
|
|
110
|
+
exclusive?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Function that returns a key to group related jobs.
|
|
113
|
+
* Jobs with the same key are subject to concurrency rules.
|
|
114
|
+
* The queue name is provided to allow for queue-specific concurrency keys if needed.
|
|
115
|
+
*/
|
|
116
|
+
key: (args: {
|
|
117
|
+
input: TInput;
|
|
118
|
+
queue: string;
|
|
119
|
+
}) => string;
|
|
120
|
+
/**
|
|
121
|
+
* When a new job is queued, delete older pending (not yet running) jobs with the same key.
|
|
122
|
+
* Already-running jobs are not affected.
|
|
123
|
+
* Useful when only the latest state matters (e.g., regenerating data after multiple rapid edits).
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
supersedes?: boolean;
|
|
127
|
+
};
|
|
93
128
|
export type WorkflowConfig<TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false> = {
|
|
129
|
+
/**
|
|
130
|
+
* Job concurrency controls for preventing race conditions.
|
|
131
|
+
*
|
|
132
|
+
* Can be an object with full options, or a shorthand function that just returns the key
|
|
133
|
+
* (in which case exclusive defaults to true).
|
|
134
|
+
*/
|
|
135
|
+
concurrency?: ConcurrencyConfig<TWorkflowSlugOrInput extends false ? object : TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input'] : TWorkflowSlugOrInput>;
|
|
94
136
|
/**
|
|
95
137
|
* You can either pass a string-based path to the workflow function file, or the workflow function itself.
|
|
96
138
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflowTypes.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/workflowTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,EACV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F;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAA;IAC1C;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAA;IAC3B;;OAEG;IACH,IAAI,EAAE,oBAAoB,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,oBAAoB,GAAG,MAAM,CAAA;CAChG,CAAA"}
|
|
1
|
+
{"version":3,"file":"workflowTypes.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/workflowTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,EACV,GAAG,EACH,YAAY,EACZ,cAAc,EACd,WAAW,EACX,eAAe,EACf,SAAS,EACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAA;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,QAAQ,EACT,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D,MAAM,MAAM,MAAM,GAAG;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAA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,EACH,MAAM,GACN,eAAe,CAAC,oBAAoB,CAAC,GACrC,YAAY,CAAC,oBAAoB,SAAS,MAAM,GAAG,MAAM,GAAG,oBAAoB,CAAC,CAAA;IACrF;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAA;IAC1C;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAA;IAC3B;;OAEG;IACH,IAAI,EAAE,oBAAoB,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,oBAAoB,GAAG,MAAM,CAAA;CAChG,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queues/config/types/workflowTypes.ts"],"sourcesContent":["import type { Field } from '../../../fields/config/types.js'\nimport type {\n Job,\n MaybePromise,\n PayloadRequest,\n StringKeyOf,\n TypedCollection,\n TypedJobs,\n} from '../../../index.js'\nimport type { TaskParent } from '../../operations/runJobs/runJob/getRunTaskFunction.js'\nimport type { ScheduleConfig } from './index.js'\nimport type {\n RetryConfig,\n RunInlineTaskFunction,\n RunTaskFunctions,\n TaskInput,\n TaskOutput,\n TaskType,\n} from './taskTypes.js'\nimport type { WorkflowJSON } from './workflowJSONTypes.js'\n\nexport type JobLog = {\n completedAt: string\n error?: unknown\n executedAt: string\n /**\n * ID added by the array field when the log is saved in the database\n */\n id: string\n input?: Record<string, any>\n output?: Record<string, any>\n /**\n * Sub-tasks (tasks that are run within a task) will have a parent task ID\n */\n parent?: TaskParent\n state: 'failed' | 'succeeded'\n taskID: string\n taskSlug: TaskType\n}\n\n/**\n * @deprecated - will be made private in 4.0. Please use the `Job` type instead.\n */\nexport type BaseJob<\n TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false,\n> = {\n completedAt?: null | string\n createdAt: string\n error?: unknown\n hasError?: boolean\n id: number | string\n input: TWorkflowSlugOrInput extends false\n ? object\n : TWorkflowSlugOrInput extends keyof TypedJobs['workflows']\n ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input']\n : TWorkflowSlugOrInput\n log?: JobLog[]\n meta?: {\n [key: string]: unknown\n /**\n * If true, this job was queued by the scheduling system.\n */\n scheduled?: boolean\n }\n processing?: boolean\n queue?: string\n taskSlug?: null | TaskType\n taskStatus: JobTaskStatus\n totalTried: number\n updatedAt: string\n waitUntil?: null | string\n workflowSlug?: null | WorkflowTypes\n}\n\n/**\n * @todo rename to WorkflowSlug in 4.0, similar to CollectionSlug\n */\nexport type WorkflowTypes = StringKeyOf<TypedJobs['workflows']>\n\n/**\n * @deprecated - will be removed in 4.0. Use `Job` type instead.\n */\nexport type RunningJob<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = {\n input: TWorkflowSlugOrInput extends keyof TypedJobs['workflows']\n ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input']\n : TWorkflowSlugOrInput\n taskStatus: JobTaskStatus\n} & Omit<TypedCollection['payload-jobs'], 'input' | 'taskStatus'>\n\n/**\n * @deprecated - will be removed in 4.0. Use `Job` type instead.\n */\nexport type RunningJobSimple<TWorkflowInput extends object> = {\n input: TWorkflowInput\n} & TypedCollection['payload-jobs']\n\n// Simplified version of RunningJob that doesn't break TypeScript (TypeScript seems to stop evaluating RunningJob when it's too complex)\nexport type RunningJobFromTask<TTaskSlug extends keyof TypedJobs['tasks']> = {\n input: TypedJobs['tasks'][TTaskSlug]['input']\n} & TypedCollection['payload-jobs']\n\nexport type WorkflowHandler<\n TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false,\n> = (args: {\n inlineTask: RunInlineTaskFunction\n job: Job<TWorkflowSlugOrInput>\n req: PayloadRequest\n tasks: RunTaskFunctions\n}) => MaybePromise<void>\n\nexport type SingleTaskStatus<T extends keyof TypedJobs['tasks']> = {\n complete: boolean\n input: TaskInput<T>\n output: TaskOutput<T>\n taskSlug: TaskType\n totalTried: number\n}\n\n/**\n * Task IDs mapped to their status\n */\nexport type JobTaskStatus = {\n // Wrap in taskSlug to improve typing\n [taskSlug in TaskType]: {\n [taskID: string]: SingleTaskStatus<taskSlug>\n }\n}\n\nexport type WorkflowConfig<\n TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false,\n> = {\n /**\n * You can either pass a string-based path to the workflow function file, or the workflow function itself.\n *\n * If you are using large dependencies within your workflow control flow, you might prefer to pass the string path\n * because that will avoid bundling large dependencies in your Next.js app. Passing a string path is an advanced feature\n * that may require a sophisticated build pipeline in order to work.\n */\n handler:\n | string\n | WorkflowHandler<TWorkflowSlugOrInput>\n | WorkflowJSON<TWorkflowSlugOrInput extends object ? string : TWorkflowSlugOrInput>\n /**\n * Define the input field schema - payload will generate a type for this schema.\n */\n inputSchema?: Field[]\n /**\n * You can use interfaceName to change the name of the interface that is generated for this workflow. By default, this is \"Workflow\" + the capitalized workflow slug.\n */\n interfaceName?: string\n /**\n * Define a human-friendly label for this workflow.\n */\n label?: string\n /**\n * Optionally, define the default queue name that this workflow should be tied to.\n * Defaults to \"default\".\n * Can be overridden when queuing jobs via Local API.\n */\n queue?: string\n /**\n * You can define `retries` on the workflow level, which will enforce that the workflow can only fail up to that number of retries. If a task does not have retries specified, it will inherit the retry count as specified on the workflow.\n *\n * You can specify `0` as `workflow` retries, which will disregard all `task` retry specifications and fail the entire workflow on any task failure.\n * You can leave `workflow` retries as undefined, in which case, the workflow will respect what each task dictates as their own retry count.\n *\n * @default undefined. By default, workflows retries are defined by their tasks\n */\n retries?: number | RetryConfig | undefined\n /**\n * Allows automatically scheduling this workflow to run regularly at a specified interval.\n */\n schedule?: ScheduleConfig[]\n /**\n * Define a slug-based name for this job.\n */\n slug: TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TWorkflowSlugOrInput : string\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/queues/config/types/workflowTypes.ts"],"sourcesContent":["import type { Field } from '../../../fields/config/types.js'\nimport type {\n Job,\n MaybePromise,\n PayloadRequest,\n StringKeyOf,\n TypedCollection,\n TypedJobs,\n} from '../../../index.js'\nimport type { TaskParent } from '../../operations/runJobs/runJob/getRunTaskFunction.js'\nimport type { ScheduleConfig } from './index.js'\nimport type {\n RetryConfig,\n RunInlineTaskFunction,\n RunTaskFunctions,\n TaskInput,\n TaskOutput,\n TaskType,\n} from './taskTypes.js'\nimport type { WorkflowJSON } from './workflowJSONTypes.js'\n\nexport type JobLog = {\n completedAt: string\n error?: unknown\n executedAt: string\n /**\n * ID added by the array field when the log is saved in the database\n */\n id: string\n input?: Record<string, any>\n output?: Record<string, any>\n /**\n * Sub-tasks (tasks that are run within a task) will have a parent task ID\n */\n parent?: TaskParent\n state: 'failed' | 'succeeded'\n taskID: string\n taskSlug: TaskType\n}\n\n/**\n * @deprecated - will be made private in 4.0. Please use the `Job` type instead.\n */\nexport type BaseJob<\n TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false,\n> = {\n completedAt?: null | string\n /**\n * Used for concurrency control. Jobs with the same key are subject to exclusive/supersedes rules.\n */\n concurrencyKey?: null | string\n createdAt: string\n error?: unknown\n hasError?: boolean\n id: number | string\n input: TWorkflowSlugOrInput extends false\n ? object\n : TWorkflowSlugOrInput extends keyof TypedJobs['workflows']\n ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input']\n : TWorkflowSlugOrInput\n log?: JobLog[]\n meta?: {\n [key: string]: unknown\n /**\n * If true, this job was queued by the scheduling system.\n */\n scheduled?: boolean\n }\n processing?: boolean\n queue?: string\n taskSlug?: null | TaskType\n taskStatus: JobTaskStatus\n totalTried: number\n updatedAt: string\n waitUntil?: null | string\n workflowSlug?: null | WorkflowTypes\n}\n\n/**\n * @todo rename to WorkflowSlug in 4.0, similar to CollectionSlug\n */\nexport type WorkflowTypes = StringKeyOf<TypedJobs['workflows']>\n\n/**\n * @deprecated - will be removed in 4.0. Use `Job` type instead.\n */\nexport type RunningJob<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = {\n input: TWorkflowSlugOrInput extends keyof TypedJobs['workflows']\n ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input']\n : TWorkflowSlugOrInput\n taskStatus: JobTaskStatus\n} & Omit<TypedCollection['payload-jobs'], 'input' | 'taskStatus'>\n\n/**\n * @deprecated - will be removed in 4.0. Use `Job` type instead.\n */\nexport type RunningJobSimple<TWorkflowInput extends object> = {\n input: TWorkflowInput\n} & TypedCollection['payload-jobs']\n\n// Simplified version of RunningJob that doesn't break TypeScript (TypeScript seems to stop evaluating RunningJob when it's too complex)\nexport type RunningJobFromTask<TTaskSlug extends keyof TypedJobs['tasks']> = {\n input: TypedJobs['tasks'][TTaskSlug]['input']\n} & TypedCollection['payload-jobs']\n\nexport type WorkflowHandler<\n TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false,\n> = (args: {\n inlineTask: RunInlineTaskFunction\n job: Job<TWorkflowSlugOrInput>\n req: PayloadRequest\n tasks: RunTaskFunctions\n}) => MaybePromise<void>\n\nexport type SingleTaskStatus<T extends keyof TypedJobs['tasks']> = {\n complete: boolean\n input: TaskInput<T>\n output: TaskOutput<T>\n taskSlug: TaskType\n totalTried: number\n}\n\n/**\n * Task IDs mapped to their status\n */\nexport type JobTaskStatus = {\n // Wrap in taskSlug to improve typing\n [taskSlug in TaskType]: {\n [taskID: string]: SingleTaskStatus<taskSlug>\n }\n}\n\n/**\n * Concurrency configuration for workflows and tasks.\n * Controls how jobs with the same concurrency key are handled.\n */\nexport type ConcurrencyConfig<TInput = object> =\n | ((args: { input: TInput; queue: string }) => string)\n // Shorthand: key function only, exclusive defaults to true, supersedes defaults to false\n | {\n /**\n * Only one job with this key can run at a time.\n * Other jobs with the same key remain queued until the running job completes.\n * @default true\n */\n exclusive?: boolean\n /**\n * Function that returns a key to group related jobs.\n * Jobs with the same key are subject to concurrency rules.\n * The queue name is provided to allow for queue-specific concurrency keys if needed.\n */\n key: (args: { input: TInput; queue: string }) => string\n /**\n * When a new job is queued, delete older pending (not yet running) jobs with the same key.\n * Already-running jobs are not affected.\n * Useful when only the latest state matters (e.g., regenerating data after multiple rapid edits).\n * @default false\n */\n supersedes?: boolean\n }\n\nexport type WorkflowConfig<\n TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false,\n> = {\n /**\n * Job concurrency controls for preventing race conditions.\n *\n * Can be an object with full options, or a shorthand function that just returns the key\n * (in which case exclusive defaults to true).\n */\n concurrency?: ConcurrencyConfig<\n TWorkflowSlugOrInput extends false\n ? object\n : TWorkflowSlugOrInput extends keyof TypedJobs['workflows']\n ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input']\n : TWorkflowSlugOrInput\n >\n /**\n * You can either pass a string-based path to the workflow function file, or the workflow function itself.\n *\n * If you are using large dependencies within your workflow control flow, you might prefer to pass the string path\n * because that will avoid bundling large dependencies in your Next.js app. Passing a string path is an advanced feature\n * that may require a sophisticated build pipeline in order to work.\n */\n handler:\n | string\n | WorkflowHandler<TWorkflowSlugOrInput>\n | WorkflowJSON<TWorkflowSlugOrInput extends object ? string : TWorkflowSlugOrInput>\n /**\n * Define the input field schema - payload will generate a type for this schema.\n */\n inputSchema?: Field[]\n /**\n * You can use interfaceName to change the name of the interface that is generated for this workflow. By default, this is \"Workflow\" + the capitalized workflow slug.\n */\n interfaceName?: string\n /**\n * Define a human-friendly label for this workflow.\n */\n label?: string\n /**\n * Optionally, define the default queue name that this workflow should be tied to.\n * Defaults to \"default\".\n * Can be overridden when queuing jobs via Local API.\n */\n queue?: string\n /**\n * You can define `retries` on the workflow level, which will enforce that the workflow can only fail up to that number of retries. If a task does not have retries specified, it will inherit the retry count as specified on the workflow.\n *\n * You can specify `0` as `workflow` retries, which will disregard all `task` retry specifications and fail the entire workflow on any task failure.\n * You can leave `workflow` retries as undefined, in which case, the workflow will respect what each task dictates as their own retry count.\n *\n * @default undefined. By default, workflows retries are defined by their tasks\n */\n retries?: number | RetryConfig | undefined\n /**\n * Allows automatically scheduling this workflow to run regularly at a specified interval.\n */\n schedule?: ScheduleConfig[]\n /**\n * Define a slug-based name for this job.\n */\n slug: TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TWorkflowSlugOrInput : string\n}\n"],"names":[],"mappings":"AAiKA,WA8DC"}
|
|
@@ -35,6 +35,12 @@ export declare const getJobsLocalAPI: (payload: Payload) => {
|
|
|
35
35
|
* @default true
|
|
36
36
|
*/
|
|
37
37
|
overrideAccess?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The queue to add the job to.
|
|
40
|
+
* If not specified, the job will be added to the default queue.
|
|
41
|
+
*
|
|
42
|
+
* @default 'default'
|
|
43
|
+
*/
|
|
38
44
|
queue?: string;
|
|
39
45
|
req?: PayloadRequest;
|
|
40
46
|
task: TTaskOrWorkflowSlug extends keyof TypedJobs["tasks"] ? TTaskOrWorkflowSlug : never;
|
|
@@ -52,6 +58,12 @@ export declare const getJobsLocalAPI: (payload: Payload) => {
|
|
|
52
58
|
* @default true
|
|
53
59
|
*/
|
|
54
60
|
overrideAccess?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The queue to add the job to.
|
|
63
|
+
* If not specified, the job will be added to the default queue.
|
|
64
|
+
*
|
|
65
|
+
* @default 'default'
|
|
66
|
+
*/
|
|
55
67
|
queue?: string;
|
|
56
68
|
req?: PayloadRequest;
|
|
57
69
|
task?: never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localAPI.d.ts","sourceRoot":"","sources":["../../src/queues/localAPI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAElF,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,OAAO,E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AAC,EAAE,OAAO,CAAA;QACxB;;;;WAIG;QACH,eAAe,CAAC,EAAE,IAAI,CAAA;QACtB;;;;WAIG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,GAAG,CAAC,EAAE,cAAc,CAAA;QACpB;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,aAAa,CAAA;QACtB,KAAK,CAAC,EAAE,KAAK,CAAA;KACd,KAAG,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;oBAgBjB;QACpB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,GAAG,CAAC,EAAE,cAAc,CAAA;QACpB;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,aAAa,CAAA;KACvB,KAAG,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;mBAWlB;QACnB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,GAAG,CAAC,EAAE,cAAc,CAAA;QACpB,KAAK,EAAE,KAAK,CAAA;KACb,KAAG,OAAO,CAAC,IAAI,CAAC;uBAuDQ;QACvB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,GAAG,CAAC,EAAE,cAAc,CAAA;KACrB,KAAG,OAAO,CAAC,IAAI,CAAC;CAgCjB,CAAA"}
|
package/dist/queues/localAPI.js
CHANGED
|
@@ -56,6 +56,103 @@ export const getJobsLocalAPI = (payload)=>({
|
|
|
56
56
|
if (args.meta) {
|
|
57
57
|
data.meta = args.meta;
|
|
58
58
|
}
|
|
59
|
+
// Compute concurrency key from workflow or task config (only if feature is enabled)
|
|
60
|
+
if (payload.config.jobs?.enableConcurrencyControl) {
|
|
61
|
+
let concurrencyKey = null;
|
|
62
|
+
let supersedes = false;
|
|
63
|
+
const queueName = queue || 'default';
|
|
64
|
+
if (args.workflow) {
|
|
65
|
+
const workflow = payload.config.jobs?.workflows?.find(({ slug })=>slug === args.workflow);
|
|
66
|
+
if (workflow?.concurrency) {
|
|
67
|
+
const concurrencyConfig = workflow.concurrency;
|
|
68
|
+
if (typeof concurrencyConfig === 'function') {
|
|
69
|
+
concurrencyKey = concurrencyConfig({
|
|
70
|
+
input: args.input,
|
|
71
|
+
queue: queueName
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
concurrencyKey = concurrencyConfig.key({
|
|
75
|
+
input: args.input,
|
|
76
|
+
queue: queueName
|
|
77
|
+
});
|
|
78
|
+
supersedes = concurrencyConfig.supersedes ?? false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else if (args.task) {
|
|
82
|
+
const task = payload.config.jobs?.tasks?.find(({ slug })=>slug === args.task);
|
|
83
|
+
if (task?.concurrency) {
|
|
84
|
+
const concurrencyConfig = task.concurrency;
|
|
85
|
+
if (typeof concurrencyConfig === 'function') {
|
|
86
|
+
concurrencyKey = concurrencyConfig({
|
|
87
|
+
input: args.input,
|
|
88
|
+
queue: queueName
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
concurrencyKey = concurrencyConfig.key({
|
|
92
|
+
input: args.input,
|
|
93
|
+
queue: queueName
|
|
94
|
+
});
|
|
95
|
+
supersedes = concurrencyConfig.supersedes ?? false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (concurrencyKey) {
|
|
100
|
+
data.concurrencyKey = concurrencyKey;
|
|
101
|
+
// If supersedes is enabled, delete older pending jobs with the same key
|
|
102
|
+
if (supersedes) {
|
|
103
|
+
if (payload.config.jobs.runHooks) {
|
|
104
|
+
await payload.delete({
|
|
105
|
+
collection: jobsCollectionSlug,
|
|
106
|
+
depth: 0,
|
|
107
|
+
disableTransaction: true,
|
|
108
|
+
where: {
|
|
109
|
+
and: [
|
|
110
|
+
{
|
|
111
|
+
concurrencyKey: {
|
|
112
|
+
equals: concurrencyKey
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
processing: {
|
|
117
|
+
equals: false
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
completedAt: {
|
|
122
|
+
exists: false
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
await payload.db.deleteMany({
|
|
130
|
+
collection: jobsCollectionSlug,
|
|
131
|
+
req,
|
|
132
|
+
where: {
|
|
133
|
+
and: [
|
|
134
|
+
{
|
|
135
|
+
concurrencyKey: {
|
|
136
|
+
equals: concurrencyKey
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
processing: {
|
|
141
|
+
equals: false
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
completedAt: {
|
|
146
|
+
exists: false
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
59
156
|
// Type assertion is still needed here
|
|
60
157
|
if (payload?.config?.jobs?.depth || payload?.config?.jobs?.runHooks) {
|
|
61
158
|
return await payload.create({
|
|
@@ -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 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 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 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","depth","runHooks","create","collection","doc","db","run","limit","processingOrder","sequential","silent","where","runByID","id","cancel","and","completedAt","exists","hasError","not_equals","push","equals","error","cancelled","processing","disableTransaction","returning","cancelByID"],"mappings":"AAEA,SACEA,cAAc,EACdC,SAAS,QAOJ,cAAa;AACpB,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,yBAAwB;AACzE,SAASC,eAAe,QAAoC,wCAAuC;AACnG,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,EAAEC,UAAU,QAAQ,2BAA0B;AAQhE,OAAO,MAAMC,kBAAkB,CAACC,UAAsB,CAAA;QACpDL,iBAAiB,OAAOM;YAmBtB,MAAMC,SAAyBD,MAAME,OAAQ,MAAMZ,eAAe,CAAC,GAAGS;YAEtE,OAAO,MAAML,gBAAgB;gBAC3BS,WAAWH,MAAMG;gBACjBC,OAAOJ,MAAMI;gBACbF,KAAKD;YACP;QACF;QACAG,OAAO,OAILJ;YA4CA,MAAMK,iBAAiBL,MAAMK,mBAAm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../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,wCAAuC;AACnG,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,EAAEC,UAAU,QAAQ,2BAA0B;AAQhE,OAAO,MAAMC,kBAAkB,CAACC,UAAsB,CAAA;QACpDL,iBAAi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C,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"}
|
|
@@ -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,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,
|
|
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,CA0ctE,CAAA"}
|