payload 4.0.0-internal.8867dba → 4.0.0-internal.9726517

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.
Files changed (45) hide show
  1. package/dist/config/defaults.d.ts.map +1 -1
  2. package/dist/config/defaults.js +2 -1
  3. package/dist/config/defaults.js.map +1 -1
  4. package/dist/index.bundled.d.ts +14 -2
  5. package/dist/queues/config/collection.d.ts.map +1 -1
  6. package/dist/queues/config/collection.js +11 -5
  7. package/dist/queues/config/collection.js.map +1 -1
  8. package/dist/queues/config/types/index.d.ts +12 -1
  9. package/dist/queues/config/types/index.d.ts.map +1 -1
  10. package/dist/queues/config/types/index.js.map +1 -1
  11. package/dist/queues/config/types/workflowTypes.d.ts +1 -1
  12. package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
  13. package/dist/queues/config/types/workflowTypes.js.map +1 -1
  14. package/dist/queues/errors/calculateBackoffWaitUntil.d.ts +2 -1
  15. package/dist/queues/errors/calculateBackoffWaitUntil.d.ts.map +1 -1
  16. package/dist/queues/errors/calculateBackoffWaitUntil.js +2 -2
  17. package/dist/queues/errors/calculateBackoffWaitUntil.js.map +1 -1
  18. package/dist/queues/errors/handleTaskError.js +2 -2
  19. package/dist/queues/errors/handleTaskError.js.map +1 -1
  20. package/dist/queues/errors/handleWorkflowError.js +1 -1
  21. package/dist/queues/errors/handleWorkflowError.js.map +1 -1
  22. package/dist/queues/localAPI.js +4 -4
  23. package/dist/queues/localAPI.js.map +1 -1
  24. package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
  25. package/dist/queues/operations/runJobs/index.js +212 -42
  26. package/dist/queues/operations/runJobs/index.js.map +1 -1
  27. package/dist/queues/operations/runJobs/runJSONJob/index.js +2 -2
  28. package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -1
  29. package/dist/queues/operations/runJobs/runJob/index.js +1 -1
  30. package/dist/queues/operations/runJobs/runJob/index.js.map +1 -1
  31. package/dist/uploads/endpoints/uploadInstructions.d.ts.map +1 -1
  32. package/dist/uploads/endpoints/uploadInstructions.js +3 -3
  33. package/dist/uploads/endpoints/uploadInstructions.js.map +1 -1
  34. package/dist/uploads/getFileFromUploadInstructions.d.ts.map +1 -1
  35. package/dist/uploads/getFileFromUploadInstructions.js +1 -0
  36. package/dist/uploads/getFileFromUploadInstructions.js.map +1 -1
  37. package/dist/uploads/types.d.ts +1 -0
  38. package/dist/uploads/types.d.ts.map +1 -1
  39. package/dist/uploads/types.js.map +1 -1
  40. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  41. package/dist/utilities/addDataAndFileToRequest.js +8 -4
  42. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  43. package/dist/versions/deleteScheduledPublishJobs.js +2 -2
  44. package/dist/versions/deleteScheduledPublishJobs.js.map +1 -1
  45. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAKxC,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MA4FpD,CAAA"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAKxC,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MA6FpD,CAAA"}
@@ -59,7 +59,8 @@ export const addDefaultsToConfig = (config)=>{
59
59
  queue: defaultAccess,
60
60
  run: defaultAccess,
61
61
  ...config.jobs?.access || {}
62
- }
62
+ },
63
+ processingLeaseDuration: config.jobs?.processingLeaseDuration ?? 2 * 60 * 1000
63
64
  };
64
65
  config.localization = config.localization ?? false;
65
66
  config.maxDepth = config.maxDepth ?? 10;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/defaults.ts"],"sourcesContent":["import type { JobsConfig } from '../queues/config/types/index.js'\nimport type { Config } from './types.js'\n\nimport { defaultAccess } from '../auth/defaultAccess.js'\nimport { databaseKVAdapter } from '../kv/adapters/DatabaseKVAdapter.js'\n\nexport const addDefaultsToConfig = (config: Config): Config => {\n config.admin = {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n theme: 'all',\n ...(config.admin || {}),\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n ...(config?.admin?.importMap || {}),\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n ...(config?.admin?.meta || {}),\n },\n routes: {\n account: '/account',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n ...(config?.admin?.routes || {}),\n },\n }\n\n config.bin = config.bin ?? []\n config.collections = config.collections ?? []\n config.cookiePrefix = config.cookiePrefix ?? 'payload'\n config.cors = config.cors ?? []\n config.csrf = config.csrf ?? []\n config.custom = config.custom ?? {}\n config.defaultDepth = config.defaultDepth ?? 2\n config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000\n config.endpoints = config.endpoints ?? []\n config.globals = config.globals ?? []\n config.graphQL = {\n disableIntrospectionInProduction: true,\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n ...(config.graphQL || {}),\n }\n config.hooks = config.hooks ?? {}\n config.i18n = config.i18n ?? {}\n config.jobs = {\n deleteJobOnComplete: true,\n depth: 0,\n ...(config.jobs || {}),\n access: {\n cancel: defaultAccess,\n queue: defaultAccess,\n run: defaultAccess,\n ...(config.jobs?.access || {}),\n },\n } as JobsConfig\n config.localization = config.localization ?? false\n config.maxDepth = config.maxDepth ?? 10\n config.routes = {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n ...(config.routes || {}),\n }\n config.serverURL = config.serverURL ?? ''\n config.telemetry = config.telemetry ?? true\n config.typescript = {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n ...(config.typescript || {}),\n }\n config.upload = config.upload ?? {}\n\n config.auth = {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n ...(config.auth || {}),\n }\n\n config.kv = config.kv ?? databaseKVAdapter()\n\n if (config.kv?.kvCollection) {\n config.collections.push(config.kv.kvCollection)\n }\n\n return config\n}\n"],"names":["defaultAccess","databaseKVAdapter","addDefaultsToConfig","config","admin","avatar","components","custom","dateFormat","dependencies","theme","importMap","baseDir","process","cwd","meta","defaultOGImageType","robots","titleSuffix","routes","account","createFirstUser","forgot","inactivity","login","logout","reset","unauthorized","bin","collections","cookiePrefix","cors","csrf","defaultDepth","defaultMaxTextLength","endpoints","globals","graphQL","disableIntrospectionInProduction","disablePlaygroundInProduction","maxComplexity","schemaOutputFile","hooks","i18n","jobs","deleteJobOnComplete","depth","access","cancel","queue","run","localization","maxDepth","api","graphQLPlayground","serverURL","telemetry","typescript","autoGenerate","outputFile","upload","auth","jwtOrder","kv","kvCollection","push"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,iBAAiB,QAAQ,sCAAqC;AAEvE,OAAO,MAAMC,sBAAsB,CAACC;IAClCA,OAAOC,KAAK,GAAG;QACbC,QAAQ;QACRC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,YAAY;QACZC,cAAc,CAAC;QACfC,OAAO;QACP,GAAIP,OAAOC,KAAK,IAAI,CAAC,CAAC;QACtBO,WAAW;YACTC,SAAS,GAAG,OAAOC,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,IAAI;YACrE,GAAIX,QAAQC,OAAOO,aAAa,CAAC,CAAC;QACpC;QACAI,MAAM;YACJC,oBAAoB;YACpBC,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,CAAC,CAAC;QACrBG,QAAQ;YACNC,QAAQhD;YACRiD,OAAOjD;YACPkD,KAAKlD;YACL,GAAIG,OAAOyC,IAAI,EAAEG,UAAU,CAAC,CAAC;QAC/B;IACF;IACA5C,OAAOgD,YAAY,GAAGhD,OAAOgD,YAAY,IAAI;IAC7ChD,OAAOiD,QAAQ,GAAGjD,OAAOiD,QAAQ,IAAI;IACrCjD,OAAOgB,MAAM,GAAG;QACdf,OAAO;QACPiD,KAAK;QACLhB,SAAS;QACTiB,mBAAmB;QACnB,GAAInD,OAAOgB,MAAM,IAAI,CAAC,CAAC;IACzB;IACAhB,OAAOoD,SAAS,GAAGpD,OAAOoD,SAAS,IAAI;IACvCpD,OAAOqD,SAAS,GAAGrD,OAAOqD,SAAS,IAAI;IACvCrD,OAAOsD,UAAU,GAAG;QAClBC,cAAc;QACdC,YAAY,GAAG,OAAO9C,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,GAAG,iBAAiB,CAAC;QACzF,GAAIX,OAAOsD,UAAU,IAAI,CAAC,CAAC;IAC7B;IACAtD,OAAOyD,MAAM,GAAGzD,OAAOyD,MAAM,IAAI,CAAC;IAElCzD,OAAO0D,IAAI,GAAG;QACZC,UAAU;YAAC;YAAO;YAAU;SAAS;QACrC,GAAI3D,OAAO0D,IAAI,IAAI,CAAC,CAAC;IACvB;IAEA1D,OAAO4D,EAAE,GAAG5D,OAAO4D,EAAE,IAAI9D;IAEzB,IAAIE,OAAO4D,EAAE,EAAEC,cAAc;QAC3B7D,OAAO0B,WAAW,CAACoC,IAAI,CAAC9D,OAAO4D,EAAE,CAACC,YAAY;IAChD;IAEA,OAAO7D;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/config/defaults.ts"],"sourcesContent":["import type { JobsConfig } from '../queues/config/types/index.js'\nimport type { Config } from './types.js'\n\nimport { defaultAccess } from '../auth/defaultAccess.js'\nimport { databaseKVAdapter } from '../kv/adapters/DatabaseKVAdapter.js'\n\nexport const addDefaultsToConfig = (config: Config): Config => {\n config.admin = {\n avatar: 'gravatar',\n components: {},\n custom: {},\n dateFormat: 'MMMM do yyyy, h:mm a',\n dependencies: {},\n theme: 'all',\n ...(config.admin || {}),\n importMap: {\n baseDir: `${typeof process?.cwd === 'function' ? process.cwd() : ''}`,\n ...(config?.admin?.importMap || {}),\n },\n meta: {\n defaultOGImageType: 'dynamic',\n robots: 'noindex, nofollow',\n titleSuffix: '- Payload',\n ...(config?.admin?.meta || {}),\n },\n routes: {\n account: '/account',\n createFirstUser: '/create-first-user',\n forgot: '/forgot',\n inactivity: '/logout-inactivity',\n login: '/login',\n logout: '/logout',\n reset: '/reset',\n unauthorized: '/unauthorized',\n ...(config?.admin?.routes || {}),\n },\n }\n\n config.bin = config.bin ?? []\n config.collections = config.collections ?? []\n config.cookiePrefix = config.cookiePrefix ?? 'payload'\n config.cors = config.cors ?? []\n config.csrf = config.csrf ?? []\n config.custom = config.custom ?? {}\n config.defaultDepth = config.defaultDepth ?? 2\n config.defaultMaxTextLength = config.defaultMaxTextLength ?? 40000\n config.endpoints = config.endpoints ?? []\n config.globals = config.globals ?? []\n config.graphQL = {\n disableIntrospectionInProduction: true,\n disablePlaygroundInProduction: true,\n maxComplexity: 1000,\n schemaOutputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/schema.graphql`,\n ...(config.graphQL || {}),\n }\n config.hooks = config.hooks ?? {}\n config.i18n = config.i18n ?? {}\n config.jobs = {\n deleteJobOnComplete: true,\n depth: 0,\n ...(config.jobs || {}),\n access: {\n cancel: defaultAccess,\n queue: defaultAccess,\n run: defaultAccess,\n ...(config.jobs?.access || {}),\n },\n processingLeaseDuration: config.jobs?.processingLeaseDuration ?? 2 * 60 * 1000,\n } as JobsConfig\n config.localization = config.localization ?? false\n config.maxDepth = config.maxDepth ?? 10\n config.routes = {\n admin: '/admin',\n api: '/api',\n graphQL: '/graphql',\n graphQLPlayground: '/graphql-playground',\n ...(config.routes || {}),\n }\n config.serverURL = config.serverURL ?? ''\n config.telemetry = config.telemetry ?? true\n config.typescript = {\n autoGenerate: true,\n outputFile: `${typeof process?.cwd === 'function' ? process.cwd() : ''}/payload-types.ts`,\n ...(config.typescript || {}),\n }\n config.upload = config.upload ?? {}\n\n config.auth = {\n jwtOrder: ['JWT', 'Bearer', 'cookie'],\n ...(config.auth || {}),\n }\n\n config.kv = config.kv ?? databaseKVAdapter()\n\n if (config.kv?.kvCollection) {\n config.collections.push(config.kv.kvCollection)\n }\n\n return config\n}\n"],"names":["defaultAccess","databaseKVAdapter","addDefaultsToConfig","config","admin","avatar","components","custom","dateFormat","dependencies","theme","importMap","baseDir","process","cwd","meta","defaultOGImageType","robots","titleSuffix","routes","account","createFirstUser","forgot","inactivity","login","logout","reset","unauthorized","bin","collections","cookiePrefix","cors","csrf","defaultDepth","defaultMaxTextLength","endpoints","globals","graphQL","disableIntrospectionInProduction","disablePlaygroundInProduction","maxComplexity","schemaOutputFile","hooks","i18n","jobs","deleteJobOnComplete","depth","access","cancel","queue","run","processingLeaseDuration","localization","maxDepth","api","graphQLPlayground","serverURL","telemetry","typescript","autoGenerate","outputFile","upload","auth","jwtOrder","kv","kvCollection","push"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,iBAAiB,QAAQ,sCAAqC;AAEvE,OAAO,MAAMC,sBAAsB,CAACC;IAClCA,OAAOC,KAAK,GAAG;QACbC,QAAQ;QACRC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,YAAY;QACZC,cAAc,CAAC;QACfC,OAAO;QACP,GAAIP,OAAOC,KAAK,IAAI,CAAC,CAAC;QACtBO,WAAW;YACTC,SAAS,GAAG,OAAOC,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,IAAI;YACrE,GAAIX,QAAQC,OAAOO,aAAa,CAAC,CAAC;QACpC;QACAI,MAAM;YACJC,oBAAoB;YACpBC,QAAQ;YACRC,aAAa;YACb,GAAIf,QAAQC,OAAOW,QAAQ,CAAC,CAAC;QAC/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lD;YACL,GAAIG,OAAOyC,IAAI,EAAEG,UAAU,CAAC,CAAC;QAC/B;QACAI,yBAAyBhD,OAAOyC,IAAI,EAAEO,2BAA2B,IAAI,KAAK;IAC5E;IACAhD,OAAOiD,YAAY,GAAGjD,OAAOiD,YAAY,IAAI;IAC7CjD,OAAOkD,QAAQ,GAAGlD,OAAOkD,QAAQ,IAAI;IACrClD,OAAOgB,MAAM,GAAG;QACdf,OAAO;QACPkD,KAAK;QACLjB,SAAS;QACTkB,mBAAmB;QACnB,GAAIpD,OAAOgB,MAAM,IAAI,CAAC,CAAC;IACzB;IACAhB,OAAOqD,SAAS,GAAGrD,OAAOqD,SAAS,IAAI;IACvCrD,OAAOsD,SAAS,GAAGtD,OAAOsD,SAAS,IAAI;IACvCtD,OAAOuD,UAAU,GAAG;QAClBC,cAAc;QACdC,YAAY,GAAG,OAAO/C,SAASC,QAAQ,aAAaD,QAAQC,GAAG,KAAK,GAAG,iBAAiB,CAAC;QACzF,GAAIX,OAAOuD,UAAU,IAAI,CAAC,CAAC;IAC7B;IACAvD,OAAO0D,MAAM,GAAG1D,OAAO0D,MAAM,IAAI,CAAC;IAElC1D,OAAO2D,IAAI,GAAG;QACZC,UAAU;YAAC;YAAO;YAAU;SAAS;QACrC,GAAI5D,OAAO2D,IAAI,IAAI,CAAC,CAAC;IACvB;IAEA3D,OAAO6D,EAAE,GAAG7D,OAAO6D,EAAE,IAAI/D;IAEzB,IAAIE,OAAO6D,EAAE,EAAEC,cAAc;QAC3B9D,OAAO0B,WAAW,CAACqC,IAAI,CAAC/D,OAAO6D,EAAE,CAACC,YAAY;IAChD;IAEA,OAAO9D;AACT,EAAC"}
@@ -4622,6 +4622,7 @@ type UploadInstructionsRequest = {
4622
4622
  };
4623
4623
  type UploadInstructions = {
4624
4624
  file: {
4625
+ collectionSlug?: UploadCollectionSlug;
4625
4626
  filename: string;
4626
4627
  mimeType: string;
4627
4628
  size: number;
@@ -5441,7 +5442,7 @@ type BaseJob<TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] |
5441
5442
  */
5442
5443
  scheduled?: boolean;
5443
5444
  };
5444
- processing?: boolean;
5445
+ processingUntil?: null | string;
5445
5446
  queue?: string;
5446
5447
  taskSlug?: null | TaskType;
5447
5448
  taskStatus: JobTaskStatus;
@@ -5680,6 +5681,10 @@ type SanitizedJobsConfig = {
5680
5681
  * This property is automatically set during sanitization.
5681
5682
  */
5682
5683
  enabled?: boolean;
5684
+ /**
5685
+ * How long a job remains claimed without a successful lease renewal.
5686
+ */
5687
+ processingLeaseDuration: number;
5683
5688
  /**
5684
5689
  * If set to `true`, at least one task or workflow has scheduling enabled.
5685
5690
  * This property is automatically set during sanitization.
@@ -5690,7 +5695,7 @@ type SanitizedJobsConfig = {
5690
5695
  * This property is automatically set during sanitization.
5691
5696
  */
5692
5697
  stats?: boolean;
5693
- } & JobsConfig;
5698
+ } & Omit<JobsConfig, 'processingLeaseDuration'>;
5694
5699
  type JobsConfig = {
5695
5700
  /**
5696
5701
  * Specify access control to determine who can interact with jobs.
@@ -5747,6 +5752,13 @@ type JobsConfig = {
5747
5752
  jobsCollectionOverrides?: (args: {
5748
5753
  defaultJobsCollection: CollectionConfig;
5749
5754
  }) => CollectionConfig;
5755
+ /**
5756
+ * How long a job remains claimed without a successful lease renewal.
5757
+ * This is not a maximum job runtime; active jobs renew their lease automatically.
5758
+ *
5759
+ * @default 120000 (2 minutes)
5760
+ */
5761
+ processingLeaseDuration?: number;
5750
5762
  /**
5751
5763
  * Adjust the job processing order using a Payload sort string. This can be set globally or per queue.
5752
5764
  *
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/queues/config/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAMzC,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAEhD,eAAO,MAAM,wBAAwB,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,gBAwR/E,CAAA;AAGD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GAAG,GAAG,CAMxF"}
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/queues/config/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAMzC,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAEhD,eAAO,MAAM,wBAAwB,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,gBAgS/E,CAAA;AAGD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GAAG,GAAG,CAMxF"}
@@ -3,6 +3,9 @@ import { runJobsEndpoint } from '../endpoints/run.js';
3
3
  import { getJobTaskStatus } from '../utilities/getJobTaskStatus.js';
4
4
  export const jobsCollectionSlug = 'payload-jobs';
5
5
  export const getDefaultJobsCollection = (jobsConfig)=>{
6
+ if (!Number.isFinite(jobsConfig.processingLeaseDuration) || jobsConfig.processingLeaseDuration <= 0) {
7
+ throw new Error('jobs.processingLeaseDuration must be a positive number');
8
+ }
6
9
  const workflowSlugs = new Set();
7
10
  const taskSlugs = new Set([
8
11
  'inline'
@@ -214,12 +217,15 @@ export const getDefaultJobsCollection = (jobsConfig)=>{
214
217
  index: true
215
218
  },
216
219
  {
217
- name: 'processing',
218
- type: 'checkbox',
220
+ name: 'processingUntil',
221
+ type: 'date',
219
222
  admin: {
220
- position: 'sidebar'
223
+ date: {
224
+ pickerAppearance: 'dayAndTime'
225
+ },
226
+ position: 'sidebar',
227
+ readOnly: true
221
228
  },
222
- defaultValue: false,
223
229
  index: true
224
230
  },
225
231
  // Only add concurrencyKey field if concurrency control is enabled
@@ -252,7 +258,7 @@ export const getDefaultJobsCollection = (jobsConfig)=>{
252
258
  */ beforeChange: [
253
259
  ({ data, originalDoc })=>{
254
260
  if (originalDoc?.error?.cancelled) {
255
- data.processing = false;
261
+ data.processingUntil = null;
256
262
  data.hasError = true;
257
263
  delete data.completedAt;
258
264
  delete data.waitUntil;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/queues/config/collection.ts"],"sourcesContent":["import type { CollectionConfig } from '../../collections/config/types.js'\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { Field } from '../../fields/config/types.js'\nimport type { Job } from '../../index.js'\n\nimport { handleSchedulesJobsEndpoint } from '../endpoints/handleSchedules.js'\nimport { runJobsEndpoint } from '../endpoints/run.js'\nimport { getJobTaskStatus } from '../utilities/getJobTaskStatus.js'\n\nexport const jobsCollectionSlug = 'payload-jobs'\n\nexport const getDefaultJobsCollection: (jobsConfig: SanitizedConfig['jobs']) => CollectionConfig = (\n jobsConfig,\n) => {\n const workflowSlugs: Set<string> = new Set()\n const taskSlugs: Set<string> = new Set(['inline'])\n\n if (jobsConfig.workflows?.length) {\n jobsConfig.workflows.forEach((workflow) => {\n workflowSlugs.add(workflow.slug)\n\n // Validate concurrency config requires enableConcurrencyControl flag\n if (workflow.concurrency && !jobsConfig.enableConcurrencyControl) {\n throw new Error(\n `Workflow \"${workflow.slug}\" uses concurrency controls but \"jobs.enableConcurrencyControl\" is not enabled. ` +\n `Set \"jobs.enableConcurrencyControl: true\" in your Payload config to use concurrency controls. ` +\n `Note: This adds a new indexed field to the jobs collection schema and may require a database migration.`,\n )\n }\n })\n }\n\n if (jobsConfig.tasks?.length) {\n jobsConfig.tasks.forEach((task) => {\n if (workflowSlugs.has(task.slug)) {\n throw new Error(\n `Task slug \"${task.slug}\" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.`,\n )\n }\n\n // Validate concurrency config requires enableConcurrencyControl flag\n if (task.concurrency && !jobsConfig.enableConcurrencyControl) {\n throw new Error(\n `Task \"${task.slug}\" uses concurrency controls but \"jobs.enableConcurrencyControl\" is not enabled. ` +\n `Set \"jobs.enableConcurrencyControl: true\" in your Payload config to use concurrency controls. ` +\n `Note: This adds a new indexed field to the jobs collection schema and may require a database migration.`,\n )\n }\n\n taskSlugs.add(task.slug)\n })\n }\n\n const logFields: Field[] = [\n {\n name: 'executedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'completedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n required: true,\n },\n {\n name: 'taskID',\n type: 'text',\n required: true,\n },\n /**\n * @todo make required in 4.0\n */\n {\n name: 'input',\n type: 'json',\n },\n {\n name: 'output',\n type: 'json',\n },\n {\n name: 'state',\n type: 'radio',\n options: ['failed', 'succeeded'],\n required: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (_, data) => data.state === 'failed',\n },\n required: true,\n },\n ]\n\n if (jobsConfig.addParentToTaskLog) {\n logFields.push({\n name: 'parent',\n type: 'group',\n fields: [\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n },\n {\n name: 'taskID',\n type: 'text',\n },\n ],\n })\n }\n\n const jobsCollection: CollectionConfig = {\n slug: jobsCollectionSlug,\n admin: {\n group: 'System',\n hidden: true,\n },\n endpoints: [runJobsEndpoint, handleSchedulesJobsEndpoint],\n fields: [\n {\n name: 'input',\n type: 'json',\n admin: {\n description: 'Input data provided to the job',\n },\n },\n {\n name: 'taskStatus',\n type: 'json',\n virtual: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'completedAt',\n type: 'date',\n index: true,\n },\n {\n name: 'totalTried',\n type: 'number',\n defaultValue: 0,\n index: true,\n },\n {\n name: 'hasError',\n type: 'checkbox',\n admin: {\n description: 'If hasError is true this job will not be retried',\n },\n defaultValue: false,\n index: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (data) => data.hasError,\n description: 'If hasError is true, this is the error that caused it',\n },\n },\n {\n name: 'log',\n type: 'array',\n admin: {\n description: 'Task execution log',\n },\n fields: logFields,\n },\n ],\n label: 'Status',\n },\n ],\n },\n // only include the workflowSlugs field if workflows exist\n ...((workflowSlugs.size > 0\n ? [\n {\n name: 'workflowSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...workflowSlugs],\n },\n ]\n : []) as Field[]),\n {\n name: 'taskSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...taskSlugs],\n required: false,\n },\n {\n name: 'queue',\n type: 'text',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'default',\n index: true,\n },\n {\n name: 'waitUntil',\n type: 'date',\n admin: {\n date: { pickerAppearance: 'dayAndTime' },\n },\n index: true,\n },\n {\n name: 'processing',\n type: 'checkbox',\n admin: {\n position: 'sidebar',\n },\n defaultValue: false,\n index: true,\n },\n // Only add concurrencyKey field if concurrency control is enabled\n ...(jobsConfig.enableConcurrencyControl\n ? [\n {\n name: 'concurrencyKey',\n type: 'text',\n admin: {\n description:\n 'Used for concurrency control. Jobs with the same key are subject to exclusive/supersedes rules.',\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n } as Field,\n ]\n : []),\n ],\n hooks: {\n afterRead: [\n ({ doc, req }) => {\n // This hook is used to add the virtual `tasks` field to the document, that is computed from the `log` field\n\n return jobAfterRead({ config: req.payload.config, doc })\n },\n ],\n /**\n * If another update comes in after a job as already been cancelled, we need to make sure that update doesn't\n * change the state of the job.\n */\n beforeChange: [\n ({ data, originalDoc }) => {\n if (originalDoc?.error?.cancelled) {\n data.processing = false\n data.hasError = true\n delete data.completedAt\n delete data.waitUntil\n }\n return data\n },\n ],\n },\n lockDocuments: false,\n versions: false,\n }\n\n if (jobsConfig.stats) {\n // TODO: In 4.0, this should be added by default.\n // The meta field can be used to store arbitrary data about the job. The scheduling system uses this to store\n // `scheduled: true` to indicate that the job was queued by the scheduling system.\n jobsCollection.fields.push({\n name: 'meta',\n type: 'json',\n })\n }\n return jobsCollection\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function jobAfterRead({ config, doc }: { config: SanitizedConfig; doc: Job }): Job {\n doc.taskStatus = getJobTaskStatus({\n jobLog: doc.log || [],\n })\n doc.input = doc.input || {}\n return doc\n}\n"],"names":["handleSchedulesJobsEndpoint","runJobsEndpoint","getJobTaskStatus","jobsCollectionSlug","getDefaultJobsCollection","jobsConfig","workflowSlugs","Set","taskSlugs","workflows","length","forEach","workflow","add","slug","concurrency","enableConcurrencyControl","Error","tasks","task","has","logFields","name","type","required","options","admin","condition","_","data","state","addParentToTaskLog","push","fields","jobsCollection","group","hidden","endpoints","description","virtual","tabs","index","defaultValue","hasError","label","size","position","date","pickerAppearance","readOnly","hooks","afterRead","doc","req","jobAfterRead","config","payload","beforeChange","originalDoc","error","cancelled","processing","completedAt","waitUntil","lockDocuments","versions","stats","taskStatus","jobLog","log","input"],"mappings":"AAKA,SAASA,2BAA2B,QAAQ,kCAAiC;AAC7E,SAASC,eAAe,QAAQ,sBAAqB;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AAEnE,OAAO,MAAMC,qBAAqB,eAAc;AAEhD,OAAO,MAAMC,2BAAsF,CACjGC;IAEA,MAAMC,gBAA6B,IAAIC;IACvC,MAAMC,YAAyB,IAAID,IAAI;QAAC;KAAS;IAEjD,IAAIF,WAAWI,SAAS,EAAEC,QAAQ;QAChCL,WAAWI,SAAS,CAACE,OAAO,CAAC,CAACC;YAC5BN,cAAcO,GAAG,CAACD,SAASE,IAAI;YAE/B,qEAAqE;Y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AAM,EAAEH,GAAG,EAAyC;IACjFA,IAAIe,UAAU,GAAGjE,iBAAiB;QAChCkE,QAAQhB,IAAIiB,GAAG,IAAI,EAAE;IACvB;IACAjB,IAAIkB,KAAK,GAAGlB,IAAIkB,KAAK,IAAI,CAAC;IAC1B,OAAOlB;AACT"}
1
+ {"version":3,"sources":["../../../src/queues/config/collection.ts"],"sourcesContent":["import type { CollectionConfig } from '../../collections/config/types.js'\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { Field } from '../../fields/config/types.js'\nimport type { Job } from '../../index.js'\n\nimport { handleSchedulesJobsEndpoint } from '../endpoints/handleSchedules.js'\nimport { runJobsEndpoint } from '../endpoints/run.js'\nimport { getJobTaskStatus } from '../utilities/getJobTaskStatus.js'\n\nexport const jobsCollectionSlug = 'payload-jobs'\n\nexport const getDefaultJobsCollection: (jobsConfig: SanitizedConfig['jobs']) => CollectionConfig = (\n jobsConfig,\n) => {\n if (\n !Number.isFinite(jobsConfig.processingLeaseDuration) ||\n jobsConfig.processingLeaseDuration <= 0\n ) {\n throw new Error('jobs.processingLeaseDuration must be a positive number')\n }\n\n const workflowSlugs: Set<string> = new Set()\n const taskSlugs: Set<string> = new Set(['inline'])\n\n if (jobsConfig.workflows?.length) {\n jobsConfig.workflows.forEach((workflow) => {\n workflowSlugs.add(workflow.slug)\n\n // Validate concurrency config requires enableConcurrencyControl flag\n if (workflow.concurrency && !jobsConfig.enableConcurrencyControl) {\n throw new Error(\n `Workflow \"${workflow.slug}\" uses concurrency controls but \"jobs.enableConcurrencyControl\" is not enabled. ` +\n `Set \"jobs.enableConcurrencyControl: true\" in your Payload config to use concurrency controls. ` +\n `Note: This adds a new indexed field to the jobs collection schema and may require a database migration.`,\n )\n }\n })\n }\n\n if (jobsConfig.tasks?.length) {\n jobsConfig.tasks.forEach((task) => {\n if (workflowSlugs.has(task.slug)) {\n throw new Error(\n `Task slug \"${task.slug}\" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.`,\n )\n }\n\n // Validate concurrency config requires enableConcurrencyControl flag\n if (task.concurrency && !jobsConfig.enableConcurrencyControl) {\n throw new Error(\n `Task \"${task.slug}\" uses concurrency controls but \"jobs.enableConcurrencyControl\" is not enabled. ` +\n `Set \"jobs.enableConcurrencyControl: true\" in your Payload config to use concurrency controls. ` +\n `Note: This adds a new indexed field to the jobs collection schema and may require a database migration.`,\n )\n }\n\n taskSlugs.add(task.slug)\n })\n }\n\n const logFields: Field[] = [\n {\n name: 'executedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'completedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n required: true,\n },\n {\n name: 'taskID',\n type: 'text',\n required: true,\n },\n /**\n * @todo make required in 4.0\n */\n {\n name: 'input',\n type: 'json',\n },\n {\n name: 'output',\n type: 'json',\n },\n {\n name: 'state',\n type: 'radio',\n options: ['failed', 'succeeded'],\n required: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (_, data) => data.state === 'failed',\n },\n required: true,\n },\n ]\n\n if (jobsConfig.addParentToTaskLog) {\n logFields.push({\n name: 'parent',\n type: 'group',\n fields: [\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n },\n {\n name: 'taskID',\n type: 'text',\n },\n ],\n })\n }\n\n const jobsCollection: CollectionConfig = {\n slug: jobsCollectionSlug,\n admin: {\n group: 'System',\n hidden: true,\n },\n endpoints: [runJobsEndpoint, handleSchedulesJobsEndpoint],\n fields: [\n {\n name: 'input',\n type: 'json',\n admin: {\n description: 'Input data provided to the job',\n },\n },\n {\n name: 'taskStatus',\n type: 'json',\n virtual: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'completedAt',\n type: 'date',\n index: true,\n },\n {\n name: 'totalTried',\n type: 'number',\n defaultValue: 0,\n index: true,\n },\n {\n name: 'hasError',\n type: 'checkbox',\n admin: {\n description: 'If hasError is true this job will not be retried',\n },\n defaultValue: false,\n index: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (data) => data.hasError,\n description: 'If hasError is true, this is the error that caused it',\n },\n },\n {\n name: 'log',\n type: 'array',\n admin: {\n description: 'Task execution log',\n },\n fields: logFields,\n },\n ],\n label: 'Status',\n },\n ],\n },\n // only include the workflowSlugs field if workflows exist\n ...((workflowSlugs.size > 0\n ? [\n {\n name: 'workflowSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...workflowSlugs],\n },\n ]\n : []) as Field[]),\n {\n name: 'taskSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...taskSlugs],\n required: false,\n },\n {\n name: 'queue',\n type: 'text',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'default',\n index: true,\n },\n {\n name: 'waitUntil',\n type: 'date',\n admin: {\n date: { pickerAppearance: 'dayAndTime' },\n },\n index: true,\n },\n {\n name: 'processingUntil',\n type: 'date',\n admin: {\n date: { pickerAppearance: 'dayAndTime' },\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n },\n // Only add concurrencyKey field if concurrency control is enabled\n ...(jobsConfig.enableConcurrencyControl\n ? [\n {\n name: 'concurrencyKey',\n type: 'text',\n admin: {\n description:\n 'Used for concurrency control. Jobs with the same key are subject to exclusive/supersedes rules.',\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n } as Field,\n ]\n : []),\n ],\n hooks: {\n afterRead: [\n ({ doc, req }) => {\n // This hook is used to add the virtual `tasks` field to the document, that is computed from the `log` field\n\n return jobAfterRead({ config: req.payload.config, doc })\n },\n ],\n /**\n * If another update comes in after a job as already been cancelled, we need to make sure that update doesn't\n * change the state of the job.\n */\n beforeChange: [\n ({ data, originalDoc }) => {\n if (originalDoc?.error?.cancelled) {\n data.processingUntil = null\n data.hasError = true\n delete data.completedAt\n delete data.waitUntil\n }\n return data\n },\n ],\n },\n lockDocuments: false,\n versions: false,\n }\n\n if (jobsConfig.stats) {\n // TODO: In 4.0, this should be added by default.\n // The meta field can be used to store arbitrary data about the job. The scheduling system uses this to store\n // `scheduled: true` to indicate that the job was queued by the scheduling system.\n jobsCollection.fields.push({\n name: 'meta',\n type: 'json',\n })\n }\n return jobsCollection\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function jobAfterRead({ config, doc }: { config: SanitizedConfig; doc: Job }): Job {\n doc.taskStatus = getJobTaskStatus({\n jobLog: doc.log || [],\n })\n doc.input = doc.input || {}\n return doc\n}\n"],"names":["handleSchedulesJobsEndpoint","runJobsEndpoint","getJobTaskStatus","jobsCollectionSlug","getDefaultJobsCollection","jobsConfig","Number","isFinite","processingLeaseDuration","Error","workflowSlugs","Set","taskSlugs","workflows","length","forEach","workflow","add","slug","concurrency","enableConcurrencyControl","tasks","task","has","logFields","name","type","required","options","admin","condition","_","data","state","addParentToTaskLog","push","fields","jobsCollection","group","hidden","endpoints","description","virtual","tabs","index","defaultValue","hasError","label","size","position","date","pickerAppearance","readOnly","hooks","afterRead","doc","req","jobAfterRead","config","payload","beforeChange","originalDoc","error","cancelled","processingUntil","completedAt","waitUntil","lockDocuments","versions","stats","taskStatus","jobLog","log","input"],"mappings":"AAKA,SAASA,2BAA2B,QAAQ,kCAAiC;AAC7E,SAASC,eAAe,QAAQ,sBAAqB;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AAEnE,OAAO,MAAMC,qBAAqB,eAAc;AAEhD,OAAO,MAAMC,2BAAsF,CACjGC;IAEA,IACE,CAACC,OAAOC,QAAQ,CAACF,WAAWG,uBAAuB,KACnDH,WAAWG,uBAAuB,IAAI,GACtC;QACA,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,gBAA6B,IAAIC;IACvC,MAAMC,YAAyB,IAAID,IAAI;QAAC;KAAS;IAEjD,IAAIN,WAAWQ,SAAS,EAAEC,QAAQ;QAChCT,WAAWQ,SAAS,CAACE,OAAO,CAAC,CAACC;YAC5BN,cAAcO,GAAG,CAACD,SAASE,IAAI;YAE/B,q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AAED,6DAA6D;AAC7D,OAAO,SAASoB,aAAa,EAAEC,MAAM,EAAEH,GAAG,EAAyC;IACjFA,IAAIe,UAAU,GAAGpE,iBAAiB;QAChCqE,QAAQhB,IAAIiB,GAAG,IAAI,EAAE;IACvB;IACAjB,IAAIkB,KAAK,GAAGlB,IAAIkB,KAAK,IAAI,CAAC;IAC1B,OAAOlB;AACT"}
@@ -81,6 +81,10 @@ export type SanitizedJobsConfig = {
81
81
  * This property is automatically set during sanitization.
82
82
  */
83
83
  enabled?: boolean;
84
+ /**
85
+ * How long a job remains claimed without a successful lease renewal.
86
+ */
87
+ processingLeaseDuration: number;
84
88
  /**
85
89
  * If set to `true`, at least one task or workflow has scheduling enabled.
86
90
  * This property is automatically set during sanitization.
@@ -91,7 +95,7 @@ export type SanitizedJobsConfig = {
91
95
  * This property is automatically set during sanitization.
92
96
  */
93
97
  stats?: boolean;
94
- } & JobsConfig;
98
+ } & Omit<JobsConfig, 'processingLeaseDuration'>;
95
99
  export type JobsConfig = {
96
100
  /**
97
101
  * Specify access control to determine who can interact with jobs.
@@ -148,6 +152,13 @@ export type JobsConfig = {
148
152
  jobsCollectionOverrides?: (args: {
149
153
  defaultJobsCollection: CollectionConfig;
150
154
  }) => CollectionConfig;
155
+ /**
156
+ * How long a job remains claimed without a successful lease renewal.
157
+ * This is not a maximum job runtime; active jobs renew their lease automatically.
158
+ *
159
+ * @default 120000 (2 minutes)
160
+ */
161
+ processingLeaseDuration?: number;
151
162
  /**
152
163
  * Adjust the job processing order using a Payload sort string. This can be set globally or per queue.
153
164
  *
@@ -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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EAAE,eAAe,CAAA;IACrC;;OAEG;IACH,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAA;IACzB,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,CACA;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,CAAC,EAAE,KAAK,CAAA;IACX,MAAM,EAAE,OAAO,CAAA;CAChB,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,GAAG,EAAE,GAAG,CAAA;IACR,MAAM,EAAE,SAAS,CAAA;CAClB,GACD;IACE,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,GAAG,CAAC,EAAE,KAAK,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,SAAS,CAAA;CAClB,CACJ,KACE,YAAY,CAAC,IAAI,CAAC,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE;QACN;;;;WAIG;QACH,aAAa,CAAC,EAAE,eAAe,CAAA;QAC/B;;;;;;;;;WASG;QACH,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAClC,CAAA;IACD;;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 * 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 * 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":"AAiPA,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 * How long a job remains claimed without a successful lease renewal.\n */\n processingLeaseDuration: number\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} & Omit<JobsConfig, 'processingLeaseDuration'>\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 * 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 * How long a job remains claimed without a successful lease renewal.\n * This is not a maximum job runtime; active jobs renew their lease automatically.\n *\n * @default 120000 (2 minutes)\n */\n processingLeaseDuration?: number\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 * 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":"AA4PA,WA4CC"}
@@ -44,7 +44,7 @@ export type BaseJob<TWorkflowSlugOrInput extends false | keyof TypedJobs['workfl
44
44
  */
45
45
  scheduled?: boolean;
46
46
  };
47
- processing?: boolean;
47
+ processingUntil?: null | string;
48
48
  queue?: string;
49
49
  taskSlug?: null | TaskType;
50
50
  taskStatus: JobTaskStatus;
@@ -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,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,M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iB,CAC7B,oBAAoB,SAAS,KAAK,GAC9B,MAAM,GACN,oBAAoB,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GACvD,SAAS,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,GACrD,oBAAoB,CAC3B,CAAA;IACD;;;;;;OAMG;IACH,OAAO,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
+ {"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,EAC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oBAAoB,SAAS,KAAK,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,GAAG,KAAK,IAChF;IACF;;;;;OAKG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAC7B,oBAAoB,SAAS,KAAK,GAC9B,MAAM,GACN,oBAAoB,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GACvD,SAAS,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,GACrD,oBAAoB,CAC3B,CAAA;IACD;;;;;;OAMG;IACH,OAAO,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 /**\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"}
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 processingUntil?: null | string\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"}
@@ -1,5 +1,6 @@
1
1
  import type { RetryConfig } from '../config/types/taskTypes.js';
2
- export declare function calculateBackoffWaitUntil({ retriesConfig, totalTried, }: {
2
+ export declare function calculateBackoffWaitUntil({ currentDate, retriesConfig, totalTried, }: {
3
+ currentDate?: Date;
3
4
  retriesConfig: number | RetryConfig;
4
5
  totalTried: number;
5
6
  }): Date;
@@ -1 +1 @@
1
- {"version":3,"file":"calculateBackoffWaitUntil.d.ts","sourceRoot":"","sources":["../../../src/queues/errors/calculateBackoffWaitUntil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAI/D,wBAAgB,yBAAyB,CAAC,EACxC,aAAa,EACb,UAAU,GACX,EAAE;IACD,aAAa,EAAE,MAAM,GAAG,WAAW,CAAA;IACnC,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,IAAI,CAmBP"}
1
+ {"version":3,"file":"calculateBackoffWaitUntil.d.ts","sourceRoot":"","sources":["../../../src/queues/errors/calculateBackoffWaitUntil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAI/D,wBAAgB,yBAAyB,CAAC,EACxC,WAAW,EACX,aAAa,EACb,UAAU,GACX,EAAE;IACD,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,aAAa,EAAE,MAAM,GAAG,WAAW,CAAA;IACnC,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,IAAI,CAmBP"}
@@ -1,6 +1,6 @@
1
1
  import { getCurrentDate } from '../utilities/getCurrentDate.js';
2
- export function calculateBackoffWaitUntil({ retriesConfig, totalTried }) {
3
- const now = getCurrentDate();
2
+ export function calculateBackoffWaitUntil({ currentDate, retriesConfig, totalTried }) {
3
+ const now = currentDate ?? getCurrentDate();
4
4
  let waitUntil = now;
5
5
  if (typeof retriesConfig === 'object') {
6
6
  if (retriesConfig.backoff) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/queues/errors/calculateBackoffWaitUntil.ts"],"sourcesContent":["import type { RetryConfig } from '../config/types/taskTypes.js'\n\nimport { getCurrentDate } from '../utilities/getCurrentDate.js'\n\nexport function calculateBackoffWaitUntil({\n retriesConfig,\n totalTried,\n}: {\n retriesConfig: number | RetryConfig\n totalTried: number\n}): Date {\n const now = getCurrentDate()\n let waitUntil: Date = now\n\n if (typeof retriesConfig === 'object') {\n if (retriesConfig.backoff) {\n if (retriesConfig.backoff.type === 'fixed') {\n waitUntil = retriesConfig.backoff.delay\n ? new Date(now.getTime() + retriesConfig.backoff.delay)\n : now\n } else if (retriesConfig.backoff.type === 'exponential') {\n // 2 ^ (attempts - 1) * delay (current attempt is not included in totalTried, thus no need for -1)\n const delay = retriesConfig.backoff.delay ? retriesConfig.backoff.delay : 0\n waitUntil = new Date(now.getTime() + Math.pow(2, totalTried) * delay)\n }\n }\n }\n\n return waitUntil\n}\n"],"names":["getCurrentDate","calculateBackoffWaitUntil","retriesConfig","totalTried","now","waitUntil","backoff","type","delay","Date","getTime","Math","pow"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iCAAgC;AAE/D,OAAO,SAASC,0BAA0B,EACxCC,aAAa,EACbC,UAAU,EAIX;IACC,MAAMC,MAAMJ;IACZ,IAAIK,YAAkBD;IAEtB,IAAI,OAAOF,kBAAkB,UAAU;QACrC,IAAIA,cAAcI,OAAO,EAAE;YACzB,IAAIJ,cAAcI,OAAO,CAACC,IAAI,KAAK,SAAS;gBAC1CF,YAAYH,cAAcI,OAAO,CAACE,KAAK,GACnC,IAAIC,KAAKL,IAAIM,OAAO,KAAKR,cAAcI,OAAO,CAACE,KAAK,IACpDJ;YACN,OAAO,IAAIF,cAAcI,OAAO,CAACC,IAAI,KAAK,eAAe;gBACvD,kGAAkG;gBAClG,MAAMC,QAAQN,cAAcI,OAAO,CAACE,KAAK,GAAGN,cAAcI,OAAO,CAACE,KAAK,GAAG;gBAC1EH,YAAY,IAAII,KAAKL,IAAIM,OAAO,KAAKC,KAAKC,GAAG,CAAC,GAAGT,cAAcK;YACjE;QACF;IACF;IAEA,OAAOH;AACT"}
1
+ {"version":3,"sources":["../../../src/queues/errors/calculateBackoffWaitUntil.ts"],"sourcesContent":["import type { RetryConfig } from '../config/types/taskTypes.js'\n\nimport { getCurrentDate } from '../utilities/getCurrentDate.js'\n\nexport function calculateBackoffWaitUntil({\n currentDate,\n retriesConfig,\n totalTried,\n}: {\n currentDate?: Date\n retriesConfig: number | RetryConfig\n totalTried: number\n}): Date {\n const now = currentDate ?? getCurrentDate()\n let waitUntil: Date = now\n\n if (typeof retriesConfig === 'object') {\n if (retriesConfig.backoff) {\n if (retriesConfig.backoff.type === 'fixed') {\n waitUntil = retriesConfig.backoff.delay\n ? new Date(now.getTime() + retriesConfig.backoff.delay)\n : now\n } else if (retriesConfig.backoff.type === 'exponential') {\n // 2 ^ (attempts - 1) * delay (current attempt is not included in totalTried, thus no need for -1)\n const delay = retriesConfig.backoff.delay ? retriesConfig.backoff.delay : 0\n waitUntil = new Date(now.getTime() + Math.pow(2, totalTried) * delay)\n }\n }\n }\n\n return waitUntil\n}\n"],"names":["getCurrentDate","calculateBackoffWaitUntil","currentDate","retriesConfig","totalTried","now","waitUntil","backoff","type","delay","Date","getTime","Math","pow"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iCAAgC;AAE/D,OAAO,SAASC,0BAA0B,EACxCC,WAAW,EACXC,aAAa,EACbC,UAAU,EAKX;IACC,MAAMC,MAAMH,eAAeF;IAC3B,IAAIM,YAAkBD;IAEtB,IAAI,OAAOF,kBAAkB,UAAU;QACrC,IAAIA,cAAcI,OAAO,EAAE;YACzB,IAAIJ,cAAcI,OAAO,CAACC,IAAI,KAAK,SAAS;gBAC1CF,YAAYH,cAAcI,OAAO,CAACE,KAAK,GACnC,IAAIC,KAAKL,IAAIM,OAAO,KAAKR,cAAcI,OAAO,CAACE,KAAK,IACpDJ;YACN,OAAO,IAAIF,cAAcI,OAAO,CAACC,IAAI,KAAK,eAAe;gBACvD,kGAAkG;gBAClG,MAAMC,QAAQN,cAAcI,OAAO,CAACE,KAAK,GAAGN,cAAcI,OAAO,CAACE,KAAK,GAAG;gBAC1EH,YAAY,IAAII,KAAKL,IAAIM,OAAO,KAAKC,KAAKC,GAAG,CAAC,GAAGT,cAAcK;YACjE;QACF;IACF;IAEA,OAAOH;AACT"}
@@ -60,7 +60,7 @@ export async function handleTaskError({ error, req, silent = false, updateJob })
60
60
  log: {
61
61
  $push: taskLogToPush
62
62
  },
63
- processing: false,
63
+ processingUntil: null,
64
64
  totalTried: (job.totalTried ?? 0) + 1,
65
65
  waitUntil: job.waitUntil
66
66
  });
@@ -113,7 +113,7 @@ export async function handleTaskError({ error, req, silent = false, updateJob })
113
113
  log: {
114
114
  $push: taskLogToPush
115
115
  },
116
- processing: false,
116
+ processingUntil: null,
117
117
  totalTried: (job.totalTried ?? 0) + 1,
118
118
  waitUntil: job.waitUntil
119
119
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/queues/errors/handleTaskError.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nimport type { JobLog, PayloadRequest } from '../../index.js'\nimport type { RunJobsSilent } from '../localAPI.js'\nimport type { UpdateJobFunction } from '../operations/runJobs/runJob/getUpdateJobFunction.js'\nimport type { TaskError } from './index.js'\n\nimport { getCurrentDate } from '../utilities/getCurrentDate.js'\nimport { calculateBackoffWaitUntil } from './calculateBackoffWaitUntil.js'\nimport { getWorkflowRetryBehavior } from './getWorkflowRetryBehavior.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\nexport async function handleTaskError({\n error,\n req,\n silent = false,\n updateJob,\n}: {\n error: TaskError\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 updateJob: UpdateJobFunction\n}): Promise<{\n hasFinalError: boolean\n}> {\n const {\n executedAt,\n input,\n job,\n output,\n parent,\n retriesConfig,\n taskConfig,\n taskID,\n taskSlug,\n taskStatus,\n workflowConfig,\n } = error.args\n\n if (taskConfig?.onFail) {\n await taskConfig.onFail({\n input,\n job,\n req,\n taskStatus,\n })\n }\n\n const errorJSON = {\n name: error.name,\n cancelled: Boolean('cancelled' in error && error.cancelled),\n message: error.message,\n stack: error.stack,\n }\n\n const currentDate = getCurrentDate()\n\n if (job.waitUntil) {\n // Check if waitUntil is in the past\n const waitUntil = new Date(job.waitUntil)\n if (waitUntil < currentDate) {\n // Outdated waitUntil, remove it\n delete job.waitUntil\n }\n }\n\n let maxRetries: number = 0\n\n if (retriesConfig?.attempts === undefined || retriesConfig?.attempts === null) {\n // Inherit retries from workflow config, if they are undefined and the workflow config has retries configured\n if (workflowConfig.retries !== undefined && workflowConfig.retries !== null) {\n maxRetries =\n typeof workflowConfig.retries === 'object'\n ? typeof workflowConfig.retries.attempts === 'number'\n ? workflowConfig.retries.attempts\n : 0\n : workflowConfig.retries\n } else {\n maxRetries = 0\n }\n } else {\n maxRetries = retriesConfig.attempts\n }\n\n const taskLogToPush: JobLog = {\n id: new ObjectId().toHexString(),\n completedAt: currentDate.toISOString(),\n error: errorJSON,\n executedAt: executedAt.toISOString(),\n input,\n output: output ?? {},\n parent: req.payload.config.jobs.addParentToTaskLog ? parent : undefined,\n state: 'failed',\n taskID,\n taskSlug,\n }\n\n if (!taskStatus?.complete && (taskStatus?.totalTried ?? 0) >= maxRetries) {\n /**\n * Task reached max retries => workflow will not retry\n */\n\n await updateJob({\n error: errorJSON,\n hasError: true,\n log: {\n $push: taskLogToPush,\n } as any,\n processing: false,\n totalTried: (job.totalTried ?? 0) + 1,\n waitUntil: job.waitUntil,\n })\n\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n req.payload.logger.error({\n err: error,\n job,\n msg: `Error running task ${taskID}. Attempt ${job.totalTried} - max retries reached`,\n taskSlug,\n })\n }\n return {\n hasFinalError: true,\n }\n }\n\n /**\n * Task can retry:\n * - If workflow can retry, allow it to retry\n * - If workflow reached max retries, do not retry and set final error\n */\n\n // First set task waitUntil - if the workflow waitUntil is later, it will be updated later\n const taskWaitUntil: Date = calculateBackoffWaitUntil({\n retriesConfig,\n totalTried: taskStatus?.totalTried ?? 0,\n })\n\n // Update job's waitUntil only if this waitUntil is later than the current one\n if (!job.waitUntil || taskWaitUntil > new Date(job.waitUntil)) {\n job.waitUntil = taskWaitUntil.toISOString()\n }\n\n const { hasFinalError, maxWorkflowRetries, waitUntil } = getWorkflowRetryBehavior({\n job,\n retriesConfig: workflowConfig.retries,\n })\n\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n req.payload.logger.error({\n err: error,\n job,\n msg: `Error running task ${taskID}. Attempt ${job.totalTried + 1}${maxWorkflowRetries !== undefined ? '/' + (maxWorkflowRetries + 1) : ''}`,\n taskSlug,\n })\n }\n\n // Update job's waitUntil only if this waitUntil is later than the current one\n if (waitUntil && (!job.waitUntil || waitUntil > new Date(job.waitUntil))) {\n job.waitUntil = waitUntil.toISOString()\n }\n\n // Tasks update the job if they error - but in case there is an unhandled error (e.g. in the workflow itself, not in a task)\n // we need to ensure the job is updated to reflect the error\n await updateJob({\n error: hasFinalError ? errorJSON : undefined,\n hasError: hasFinalError, // If reached max retries => final error. If hasError is true this job will not be retried\n log: {\n $push: taskLogToPush,\n } as any,\n processing: false,\n totalTried: (job.totalTried ?? 0) + 1,\n waitUntil: job.waitUntil,\n })\n\n return {\n hasFinalError,\n }\n}\n"],"names":["ObjectIdImport","getCurrentDate","calculateBackoffWaitUntil","getWorkflowRetryBehavior","ObjectId","default","handleTaskError","error","req","silent","updateJob","executedAt","input","job","output","parent","retriesConfig","taskConfig","taskID","taskSlug","taskStatus","workflowConfig","args","onFail","errorJSON","name","cancelled","Boolean","message","stack","currentDate","waitUntil","Date","maxRetries","attempts","undefined","retries","taskLogToPush","id","toHexString","completedAt","toISOString","payload","config","jobs","addParentToTaskLog","state","complete","totalTried","hasError","log","$push","processing","logger","err","msg","hasFinalError","taskWaitUntil","maxWorkflowRetries"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAO1C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,wBAAwB,QAAQ,gCAA+B;AAExE,MAAMC,WAAW,aAAaJ,iBAAiBA,eAAeK,OAAO,GAAGL;AAExE,OAAO,eAAeM,gBAAgB,EACpCC,KAAK,EACLC,GAAG,EACHC,SAAS,KAAK,EACdC,SAAS,EAcV;IAGC,MAAM,EACJC,UAAU,EACVC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,UAAU,EACVC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACf,GAAGd,MAAMe,IAAI;IAEd,IAAIL,YAAYM,QAAQ;QACtB,MAAMN,WAAWM,MAAM,CAAC;YACtBX;YACAC;YACAL;YACAY;QACF;IACF;IAEA,MAAMI,YAAY;QAChBC,MAAMlB,MAAMkB,IAAI;QAChBC,WAAWC,QAAQ,eAAepB,SAASA,MAAMmB,SAAS;QAC1DE,SAASrB,MAAMqB,OAAO;QACtBC,OAAOtB,MAAMsB,KAAK;IACpB;IAEA,MAAMC,cAAc7B;IAEpB,IAAIY,IAAIkB,SAAS,EAAE;QACjB,oCAAoC;QACpC,MAAMA,YAAY,IAAIC,KAAKnB,IAAIkB,SAAS;QACxC,IAAIA,YAAYD,aAAa;YAC3B,gCAAgC;YAChC,OAAOjB,IAAIkB,S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Ae;QACjB;IACF;IAEA;;;;GAIC,GAED,0FAA0F;IAC1F,MAAMC,gBAAsBvD,0BAA0B;QACpDc;QACAgC,YAAY5B,YAAY4B,cAAc;IACxC;IAEA,8EAA8E;IAC9E,IAAI,CAACnC,IAAIkB,SAAS,IAAI0B,gBAAgB,IAAIzB,KAAKnB,IAAIkB,SAAS,GAAG;QAC7DlB,IAAIkB,SAAS,GAAG0B,cAAchB,WAAW;IAC3C;IAEA,MAAM,EAAEe,aAAa,EAAEE,kBAAkB,EAAE3B,SAAS,EAAE,GAAG5B,yBAAyB;QAChFU;QACAG,eAAeK,eAAee,OAAO;IACvC;IAEA,IAAI,CAAC3B,UAAW,OAAOA,WAAW,YAAY,CAACA,OAAOF,KAAK,EAAG;QAC5DC,IAAIkC,OAAO,CAACW,MAAM,CAAC9C,KAAK,CAAC;YACvB+C,KAAK/C;YACLM;YACA0C,KAAK,CAAC,mBAAmB,EAAErC,OAAO,UAAU,EAAEL,IAAImC,UAAU,GAAG,IAAIU,uBAAuBvB,YAAY,MAAOuB,CAAAA,qBAAqB,CAAA,IAAK,IAAI;YAC3IvC;QACF;IACF;IAEA,8EAA8E;IAC9E,IAAIY,aAAc,CAAA,CAAClB,IAAIkB,SAAS,IAAIA,YAAY,IAAIC,KAAKnB,IAAIkB,SAAS,CAAA,GAAI;QACxElB,IAAIkB,SAAS,GAAGA,UAAUU,WAAW;IACvC;IAEA,4HAA4H;IAC5H,4DAA4D;IAC5D,MAAM/B,UAAU;QACdH,OAAOiD,gBAAgBhC,YAAYW;QACnCc,UAAUO;QACVN,KAAK;YACHC,OAAOd;QACT;QACAe,YAAY;QACZJ,YAAY,AAACnC,CAAAA,IAAImC,UAAU,IAAI,CAAA,IAAK;QACpCjB,WAAWlB,IAAIkB,SAAS;IAC1B;IAEA,OAAO;QACLyB;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/queues/errors/handleTaskError.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nimport type { JobLog, PayloadRequest } from '../../index.js'\nimport type { RunJobsSilent } from '../localAPI.js'\nimport type { UpdateJobFunction } from '../operations/runJobs/runJob/getUpdateJobFunction.js'\nimport type { TaskError } from './index.js'\n\nimport { getCurrentDate } from '../utilities/getCurrentDate.js'\nimport { calculateBackoffWaitUntil } from './calculateBackoffWaitUntil.js'\nimport { getWorkflowRetryBehavior } from './getWorkflowRetryBehavior.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\nexport async function handleTaskError({\n error,\n req,\n silent = false,\n updateJob,\n}: {\n error: TaskError\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 updateJob: UpdateJobFunction\n}): Promise<{\n hasFinalError: boolean\n}> {\n const {\n executedAt,\n input,\n job,\n output,\n parent,\n retriesConfig,\n taskConfig,\n taskID,\n taskSlug,\n taskStatus,\n workflowConfig,\n } = error.args\n\n if (taskConfig?.onFail) {\n await taskConfig.onFail({\n input,\n job,\n req,\n taskStatus,\n })\n }\n\n const errorJSON = {\n name: error.name,\n cancelled: Boolean('cancelled' in error && error.cancelled),\n message: error.message,\n stack: error.stack,\n }\n\n const currentDate = getCurrentDate()\n\n if (job.waitUntil) {\n // Check if waitUntil is in the past\n const waitUntil = new Date(job.waitUntil)\n if (waitUntil < currentDate) {\n // Outdated waitUntil, remove it\n delete job.waitUntil\n }\n }\n\n let maxRetries: number = 0\n\n if (retriesConfig?.attempts === undefined || retriesConfig?.attempts === null) {\n // Inherit retries from workflow config, if they are undefined and the workflow config has retries configured\n if (workflowConfig.retries !== undefined && workflowConfig.retries !== null) {\n maxRetries =\n typeof workflowConfig.retries === 'object'\n ? typeof workflowConfig.retries.attempts === 'number'\n ? workflowConfig.retries.attempts\n : 0\n : workflowConfig.retries\n } else {\n maxRetries = 0\n }\n } else {\n maxRetries = retriesConfig.attempts\n }\n\n const taskLogToPush: JobLog = {\n id: new ObjectId().toHexString(),\n completedAt: currentDate.toISOString(),\n error: errorJSON,\n executedAt: executedAt.toISOString(),\n input,\n output: output ?? {},\n parent: req.payload.config.jobs.addParentToTaskLog ? parent : undefined,\n state: 'failed',\n taskID,\n taskSlug,\n }\n\n if (!taskStatus?.complete && (taskStatus?.totalTried ?? 0) >= maxRetries) {\n /**\n * Task reached max retries => workflow will not retry\n */\n\n await updateJob({\n error: errorJSON,\n hasError: true,\n log: {\n $push: taskLogToPush,\n } as any,\n processingUntil: null,\n totalTried: (job.totalTried ?? 0) + 1,\n waitUntil: job.waitUntil,\n })\n\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n req.payload.logger.error({\n err: error,\n job,\n msg: `Error running task ${taskID}. Attempt ${job.totalTried} - max retries reached`,\n taskSlug,\n })\n }\n return {\n hasFinalError: true,\n }\n }\n\n /**\n * Task can retry:\n * - If workflow can retry, allow it to retry\n * - If workflow reached max retries, do not retry and set final error\n */\n\n // First set task waitUntil - if the workflow waitUntil is later, it will be updated later\n const taskWaitUntil: Date = calculateBackoffWaitUntil({\n retriesConfig,\n totalTried: taskStatus?.totalTried ?? 0,\n })\n\n // Update job's waitUntil only if this waitUntil is later than the current one\n if (!job.waitUntil || taskWaitUntil > new Date(job.waitUntil)) {\n job.waitUntil = taskWaitUntil.toISOString()\n }\n\n const { hasFinalError, maxWorkflowRetries, waitUntil } = getWorkflowRetryBehavior({\n job,\n retriesConfig: workflowConfig.retries,\n })\n\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n req.payload.logger.error({\n err: error,\n job,\n msg: `Error running task ${taskID}. Attempt ${job.totalTried + 1}${maxWorkflowRetries !== undefined ? '/' + (maxWorkflowRetries + 1) : ''}`,\n taskSlug,\n })\n }\n\n // Update job's waitUntil only if this waitUntil is later than the current one\n if (waitUntil && (!job.waitUntil || waitUntil > new Date(job.waitUntil))) {\n job.waitUntil = waitUntil.toISOString()\n }\n\n // Tasks update the job if they error - but in case there is an unhandled error (e.g. in the workflow itself, not in a task)\n // we need to ensure the job is updated to reflect the error\n await updateJob({\n error: hasFinalError ? errorJSON : undefined,\n hasError: hasFinalError, // If reached max retries => final error. If hasError is true this job will not be retried\n log: {\n $push: taskLogToPush,\n } as any,\n processingUntil: null,\n totalTried: (job.totalTried ?? 0) + 1,\n waitUntil: job.waitUntil,\n })\n\n return {\n hasFinalError,\n }\n}\n"],"names":["ObjectIdImport","getCurrentDate","calculateBackoffWaitUntil","getWorkflowRetryBehavior","ObjectId","default","handleTaskError","error","req","silent","updateJob","executedAt","input","job","output","parent","retriesConfig","taskConfig","taskID","taskSlug","taskStatus","workflowConfig","args","onFail","errorJSON","name","cancelled","Boolean","message","stack","currentDate","waitUntil","Date","maxRetries","attempts","undefined","retries","taskLogToPush","id","toHexString","completedAt","toISOString","payload","config","jobs","addParentToTaskLog","state","complete","totalTried","hasError","log","$push","processingUntil","logger","err","msg","hasFinalError","taskWaitUntil","maxWorkflowRetries"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAO1C,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,wBAAwB,QAAQ,gCAA+B;AAExE,MAAMC,WAAW,aAAaJ,iBAAiBA,eAAeK,OAAO,GAAGL;AAExE,OAAO,eAAeM,gBAAgB,EACpCC,KAAK,EACLC,GAAG,EACHC,SAAS,KAAK,EACdC,SAAS,EAcV;IAGC,MAAM,EACJC,UAAU,EACVC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,UAAU,EACVC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,cAAc,EACf,GAAGd,MAAMe,IAAI;IAEd,IAAIL,YAAYM,QAAQ;QACtB,MAAMN,WAAWM,MAAM,CAAC;YACtBX;YACAC;YACAL;YACAY;QACF;IACF;IAEA,MAAMI,YAAY;QAChBC,MA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AAM/B,UAAU;QACdH,OAAOiD,gBAAgBhC,YAAYW;QACnCc,UAAUO;QACVN,KAAK;YACHC,OAAOd;QACT;QACAe,iBAAiB;QACjBJ,YAAY,AAACnC,CAAAA,IAAImC,UAAU,IAAI,CAAA,IAAK;QACpCjB,WAAWlB,IAAIkB,SAAS;IAC1B;IAEA,OAAO;QACLyB;IACF;AACF"}
@@ -53,7 +53,7 @@ import { getWorkflowRetryBehavior } from './getWorkflowRetryBehavior.js';
53
53
  await updateJob({
54
54
  error: errorJSON,
55
55
  hasError: hasFinalError,
56
- processing: false,
56
+ processingUntil: null,
57
57
  totalTried: (job.totalTried ?? 0) + 1,
58
58
  waitUntil: job.waitUntil
59
59
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/queues/errors/handleWorkflowError.ts"],"sourcesContent":["import type { PayloadRequest } from '../../index.js'\nimport type { RunJobsSilent } from '../localAPI.js'\nimport type { UpdateJobFunction } from '../operations/runJobs/runJob/getUpdateJobFunction.js'\nimport type { WorkflowError } from './index.js'\n\nimport { getCurrentDate } from '../utilities/getCurrentDate.js'\nimport { getWorkflowRetryBehavior } from './getWorkflowRetryBehavior.js'\n\n/**\n * This is called if a workflow catches an error. It determines if it's a final error\n * or not and handles logging.\n * A Workflow error = error that happens anywhere in between running tasks.\n *\n * This function assumes that the error is not a TaskError, but a WorkflowError. If a task errors,\n * only a TaskError should be thrown, not a WorkflowError.\n */\nexport async function handleWorkflowError({\n error,\n req,\n silent = false,\n updateJob,\n}: {\n error: WorkflowError\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 updateJob: UpdateJobFunction\n}): Promise<{\n hasFinalError: boolean\n}> {\n const { job, workflowConfig } = error.args\n\n const errorJSON = {\n name: error.name,\n cancelled: Boolean('cancelled' in error && error.cancelled),\n message: error.message,\n stack: error.stack,\n }\n\n // No retries configured => permanently fail. Errors reaching this handler are\n // workflow-level (task errors are routed to handleTaskError first), so there's\n // nothing else to bound them.\n const hasNoRetriesConfigured =\n workflowConfig.retries === undefined || workflowConfig.retries === null\n\n const { hasFinalError, maxWorkflowRetries, waitUntil } = hasNoRetriesConfigured\n ? { hasFinalError: true, maxWorkflowRetries: undefined, waitUntil: undefined }\n : getWorkflowRetryBehavior({\n job,\n retriesConfig: workflowConfig.retries,\n })\n\n if (!hasFinalError) {\n if (job.waitUntil) {\n // Check if waitUntil is in the past\n const waitUntil = new Date(job.waitUntil)\n if (waitUntil < getCurrentDate()) {\n // Outdated waitUntil, remove it\n delete job.waitUntil\n }\n }\n\n // Update job's waitUntil only if this waitUntil is later than the current one\n if (waitUntil && (!job.waitUntil || waitUntil > new Date(job.waitUntil))) {\n job.waitUntil = waitUntil.toISOString()\n }\n }\n\n const jobLabel = job.workflowSlug || `Task: ${job.taskSlug}`\n\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n req.payload.logger.error({\n err: error,\n msg: `Error running job ${jobLabel} id: ${job.id} attempt ${job.totalTried + 1}${maxWorkflowRetries !== undefined ? '/' + (maxWorkflowRetries + 1) : ''}`,\n })\n }\n\n // Tasks update the job if they error - but in case there is an unhandled error (e.g. in the workflow itself, not in a task)\n // we need to ensure the job is updated to reflect the error\n await updateJob({\n error: errorJSON,\n hasError: hasFinalError, // If reached max retries => final error. If hasError is true this job will not be retried\n processing: false,\n totalTried: (job.totalTried ?? 0) + 1,\n waitUntil: job.waitUntil,\n })\n\n return {\n hasFinalError,\n }\n}\n"],"names":["getCurrentDate","getWorkflowRetryBehavior","handleWorkflowError","error","req","silent","updateJob","job","workflowConfig","args","errorJSON","name","cancelled","Boolean","message","stack","hasNoRetriesConfigured","retries","undefined","hasFinalError","maxWorkflowRetries","waitUntil","retriesConfig","Date","toISOString","jobLabel","workflowSlug","taskSlug","payload","logger","err","msg","id","totalTried","hasError","processing"],"mappings":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C,IAAIwB,OAAO,CAACC,MAAM,CAAC1B,KAAK,CAAC;YACvB2B,KAAK3B;YACL4B,KAAK,CAAC,kBAAkB,EAAEN,SAAS,KAAK,EAAElB,IAAIyB,EAAE,CAAC,SAAS,EAAEzB,IAAI0B,UAAU,GAAG,IAAIb,uBAAuBF,YAAY,MAAOE,CAAAA,qBAAqB,CAAA,IAAK,IAAI;QAC3J;IACF;IAEA,4HAA4H;IAC5H,4DAA4D;IAC5D,MAAMd,UAAU;QACdH,OAAOO;QACPwB,UAAUf;QACVgB,YAAY;QACZF,YAAY,AAAC1B,CAAAA,IAAI0B,UAAU,IAAI,CAAA,IAAK;QACpCZ,WAAWd,IAAIc,SAAS;IAC1B;IAEA,OAAO;QACLF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/queues/errors/handleWorkflowError.ts"],"sourcesContent":["import type { PayloadRequest } from '../../index.js'\nimport type { RunJobsSilent } from '../localAPI.js'\nimport type { UpdateJobFunction } from '../operations/runJobs/runJob/getUpdateJobFunction.js'\nimport type { WorkflowError } from './index.js'\n\nimport { getCurrentDate } from '../utilities/getCurrentDate.js'\nimport { getWorkflowRetryBehavior } from './getWorkflowRetryBehavior.js'\n\n/**\n * This is called if a workflow catches an error. It determines if it's a final error\n * or not and handles logging.\n * A Workflow error = error that happens anywhere in between running tasks.\n *\n * This function assumes that the error is not a TaskError, but a WorkflowError. If a task errors,\n * only a TaskError should be thrown, not a WorkflowError.\n */\nexport async function handleWorkflowError({\n error,\n req,\n silent = false,\n updateJob,\n}: {\n error: WorkflowError\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 updateJob: UpdateJobFunction\n}): Promise<{\n hasFinalError: boolean\n}> {\n const { job, workflowConfig } = error.args\n\n const errorJSON = {\n name: error.name,\n cancelled: Boolean('cancelled' in error && error.cancelled),\n message: error.message,\n stack: error.stack,\n }\n\n // No retries configured => permanently fail. Errors reaching this handler are\n // workflow-level (task errors are routed to handleTaskError first), so there's\n // nothing else to bound them.\n const hasNoRetriesConfigured =\n workflowConfig.retries === undefined || workflowConfig.retries === null\n\n const { hasFinalError, maxWorkflowRetries, waitUntil } = hasNoRetriesConfigured\n ? { hasFinalError: true, maxWorkflowRetries: undefined, waitUntil: undefined }\n : getWorkflowRetryBehavior({\n job,\n retriesConfig: workflowConfig.retries,\n })\n\n if (!hasFinalError) {\n if (job.waitUntil) {\n // Check if waitUntil is in the past\n const waitUntil = new Date(job.waitUntil)\n if (waitUntil < getCurrentDate()) {\n // Outdated waitUntil, remove it\n delete job.waitUntil\n }\n }\n\n // Update job's waitUntil only if this waitUntil is later than the current one\n if (waitUntil && (!job.waitUntil || waitUntil > new Date(job.waitUntil))) {\n job.waitUntil = waitUntil.toISOString()\n }\n }\n\n const jobLabel = job.workflowSlug || `Task: ${job.taskSlug}`\n\n if (!silent || (typeof silent === 'object' && !silent.error)) {\n req.payload.logger.error({\n err: error,\n msg: `Error running job ${jobLabel} id: ${job.id} attempt ${job.totalTried + 1}${maxWorkflowRetries !== undefined ? '/' + (maxWorkflowRetries + 1) : ''}`,\n })\n }\n\n // Tasks update the job if they error - but in case there is an unhandled error (e.g. in the workflow itself, not in a task)\n // we need to ensure the job is updated to reflect the error\n await updateJob({\n error: errorJSON,\n hasError: hasFinalError, // If reached max retries => final error. If hasError is true this job will not be retried\n processingUntil: null,\n totalTried: (job.totalTried ?? 0) + 1,\n waitUntil: job.waitUntil,\n })\n\n return {\n hasFinalError,\n }\n}\n"],"names":["getCurrentDate","getWorkflowRetryBehavior","handleWorkflowError","error","req","silent","updateJob","job","workflowConfig","args","errorJSON","name","cancelled","Boolean","message","stack","hasNoRetriesConfigured","retries","undefined","hasFinalError","maxWorkflowRetries","waitUntil","retriesConfig","Date","toISOString","jobLabel","workflowSlug","taskSlug","payload","logger","err","msg","id","tot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AAOF,KAAK,EAAG;QAC5DC,IAAIwB,OAAO,CAACC,MAAM,CAAC1B,KAAK,CAAC;YACvB2B,KAAK3B;YACL4B,KAAK,CAAC,kBAAkB,EAAEN,SAAS,KAAK,EAAElB,IAAIyB,EAAE,CAAC,SAAS,EAAEzB,IAAI0B,UAAU,GAAG,IAAIb,uBAAuBF,YAAY,MAAOE,CAAAA,qBAAqB,CAAA,IAAK,IAAI;QAC3J;IACF;IAEA,4HAA4H;IAC5H,4DAA4D;IAC5D,MAAMd,UAAU;QACdH,OAAOO;QACPwB,UAAUf;QACVgB,iBAAiB;QACjBF,YAAY,AAAC1B,CAAAA,IAAI0B,UAAU,IAAI,CAAA,IAAK;QACpCZ,WAAWd,IAAIc,SAAS;IAC1B;IAEA,OAAO;QACLF;IACF;AACF"}
@@ -111,8 +111,8 @@ export const getJobsLocalAPI = (payload)=>({
111
111
  }
112
112
  },
113
113
  {
114
- processing: {
115
- equals: false
114
+ processingUntil: {
115
+ exists: false
116
116
  }
117
117
  },
118
118
  {
@@ -200,7 +200,7 @@ export const getJobsLocalAPI = (payload)=>({
200
200
  cancelled: true
201
201
  },
202
202
  hasError: true,
203
- processing: false,
203
+ processingUntil: null,
204
204
  waitUntil: null
205
205
  },
206
206
  req,
@@ -232,7 +232,7 @@ export const getJobsLocalAPI = (payload)=>({
232
232
  cancelled: true
233
233
  },
234
234
  hasError: true,
235
- processing: false,
235
+ processingUntil: null,
236
236
  waitUntil: null
237
237
  },
238
238
  req,