payload 4.0.0-internal.cd69eef → 4.0.0-internal.d1cc1d3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +1 -1
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/functions/index.d.ts +10 -8
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +2 -2
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/auth/endpoints/login.d.ts.map +1 -1
- package/dist/auth/endpoints/login.js +2 -11
- package/dist/auth/endpoints/login.js.map +1 -1
- package/dist/auth/loginWithCookie.d.ts +33 -0
- package/dist/auth/loginWithCookie.d.ts.map +1 -0
- package/dist/auth/loginWithCookie.js +34 -0
- package/dist/auth/loginWithCookie.js.map +1 -0
- package/dist/auth/serverFunctions/cookies.d.ts +47 -0
- package/dist/auth/serverFunctions/cookies.d.ts.map +1 -0
- package/dist/auth/serverFunctions/cookies.js +52 -0
- package/dist/auth/serverFunctions/cookies.js.map +1 -0
- package/dist/auth/serverFunctions/login.d.ts +29 -0
- package/dist/auth/serverFunctions/login.d.ts.map +1 -0
- package/dist/auth/serverFunctions/login.js +63 -0
- package/dist/auth/serverFunctions/login.js.map +1 -0
- package/dist/auth/serverFunctions/logout.d.ts +17 -0
- package/dist/auth/serverFunctions/logout.d.ts.map +1 -0
- package/dist/auth/serverFunctions/logout.js +58 -0
- package/dist/auth/serverFunctions/logout.js.map +1 -0
- package/dist/auth/serverFunctions/refresh.d.ts +17 -0
- package/dist/auth/serverFunctions/refresh.d.ts.map +1 -0
- package/dist/auth/serverFunctions/refresh.js +61 -0
- package/dist/auth/serverFunctions/refresh.js.map +1 -0
- package/dist/collections/config/client.d.ts +2 -3
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +5 -7
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +1 -0
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts +3 -8
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +2 -6
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +1 -1
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/config/useAsTitle.spec.js +27 -27
- package/dist/collections/config/useAsTitle.spec.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +10 -0
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +7 -4
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/updateByID.js +1 -0
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/config/build.js +1 -1
- package/dist/config/build.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +5 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/orderable/index.d.ts +1 -1
- package/dist/config/orderable/index.d.ts.map +1 -1
- package/dist/config/orderable/index.js +2 -2
- package/dist/config/orderable/index.js.map +1 -1
- package/dist/config/sanitize.d.ts +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +33 -40
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/createDatabaseAdapter.d.ts +1 -1
- package/dist/database/createDatabaseAdapter.d.ts.map +1 -1
- package/dist/database/createDatabaseAdapter.js +0 -2
- package/dist/database/createDatabaseAdapter.js.map +1 -1
- package/dist/database/types.d.ts +6 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/exports/auth.d.ts +5 -0
- package/dist/exports/auth.d.ts.map +1 -0
- package/dist/exports/auth.js +6 -0
- package/dist/exports/auth.js.map +1 -0
- package/dist/exports/internal.d.ts +2 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +3 -1
- package/dist/exports/internal.js.map +1 -1
- package/dist/fields/baseFields/slug/duplicateContext.d.ts +11 -0
- package/dist/fields/baseFields/slug/duplicateContext.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/duplicateContext.js +21 -0
- package/dist/fields/baseFields/slug/duplicateContext.js.map +1 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.d.ts +22 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.js +63 -0
- package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.js.map +1 -0
- package/dist/fields/baseFields/slug/generateSlug.d.ts +13 -8
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.js +98 -45
- package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.d.ts +18 -0
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.js +20 -0
- package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.js.map +1 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.d.ts +22 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.js +23 -0
- package/dist/fields/baseFields/slug/getSlugFallbackValue.js.map +1 -0
- package/dist/fields/baseFields/slug/hasValue.d.ts +3 -0
- package/dist/fields/baseFields/slug/hasValue.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/hasValue.js +3 -0
- package/dist/fields/baseFields/slug/hasValue.js.map +1 -0
- package/dist/fields/config/reservedFieldNames.spec.js +18 -18
- package/dist/fields/config/reservedFieldNames.spec.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts +3 -9
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +33 -34
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +128 -105
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +4 -3
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +5 -3
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/stripNullRows.d.ts +10 -0
- package/dist/fields/hooks/beforeValidate/stripNullRows.d.ts.map +1 -0
- package/dist/fields/hooks/beforeValidate/stripNullRows.js +18 -0
- package/dist/fields/hooks/beforeValidate/stripNullRows.js.map +1 -0
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +7 -8
- package/dist/fields/validations.js.map +1 -1
- package/dist/fields/validations.spec.js +61 -37
- package/dist/fields/validations.spec.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts +2 -7
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +2 -6
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/sanitize.spec.js +6 -6
- package/dist/globals/config/sanitize.spec.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/countGlobalVersions.js +1 -0
- package/dist/globals/operations/countGlobalVersions.js.map +1 -1
- package/dist/index.bundled.d.ts +247 -178
- package/dist/index.d.ts +49 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/query-presets/constraints.js +1 -1
- package/dist/query-presets/constraints.js.map +1 -1
- package/dist/queues/config/collection.d.ts.map +1 -1
- package/dist/queues/config/collection.js +37 -43
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/config/global.d.ts +5 -6
- package/dist/queues/config/global.d.ts.map +1 -1
- package/dist/queues/config/global.js +1 -1
- package/dist/queues/config/global.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +29 -24
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/config/types/taskTypes.d.ts +4 -7
- package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
- package/dist/queues/config/types/taskTypes.js.map +1 -1
- package/dist/queues/config/types/workflowJSONTypes.d.ts +10 -9
- package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -1
- package/dist/queues/config/types/workflowJSONTypes.js.map +1 -1
- package/dist/queues/config/types/workflowTypes.d.ts +11 -58
- package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
- package/dist/queues/config/types/workflowTypes.js.map +1 -1
- package/dist/queues/endpoints/handleSchedules.js +1 -1
- package/dist/queues/endpoints/handleSchedules.js.map +1 -1
- package/dist/queues/errors/handleTaskError.js +4 -4
- package/dist/queues/errors/handleTaskError.js.map +1 -1
- package/dist/queues/errors/handleWorkflowError.js +1 -1
- package/dist/queues/errors/handleWorkflowError.js.map +1 -1
- package/dist/queues/errors/index.d.ts +6 -0
- package/dist/queues/errors/index.d.ts.map +1 -1
- package/dist/queues/errors/index.js +5 -0
- package/dist/queues/errors/index.js.map +1 -1
- package/dist/queues/localAPI.d.ts +4 -4
- package/dist/queues/localAPI.d.ts.map +1 -1
- package/dist/queues/localAPI.js +63 -66
- package/dist/queues/localAPI.js.map +1 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts +4 -4
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.js.map +1 -1
- package/dist/queues/operations/handleSchedules/index.d.ts +1 -1
- package/dist/queues/operations/handleSchedules/index.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/index.js +1 -1
- package/dist/queues/operations/handleSchedules/index.js.map +1 -1
- package/dist/queues/operations/runJobs/heartbeat.d.ts +13 -0
- package/dist/queues/operations/runJobs/heartbeat.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/heartbeat.js +66 -0
- package/dist/queues/operations/runJobs/heartbeat.js.map +1 -0
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.js +133 -84
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.js +6 -3
- package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +5 -5
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts +2 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +39 -8
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -1
- package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJob/index.js +4 -4
- package/dist/queues/operations/runJobs/runJob/index.js.map +1 -1
- package/dist/queues/utilities/updateJob.d.ts.map +1 -1
- package/dist/queues/utilities/updateJob.js +3 -0
- package/dist/queues/utilities/updateJob.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/checkFileRestrictions.d.ts +1 -1
- package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
- package/dist/uploads/checkFileRestrictions.js +15 -1
- package/dist/uploads/checkFileRestrictions.js.map +1 -1
- package/dist/uploads/endpoints/uploadInstructions.d.ts +12 -0
- package/dist/uploads/endpoints/uploadInstructions.d.ts.map +1 -1
- package/dist/uploads/endpoints/uploadInstructions.js +66 -20
- package/dist/uploads/endpoints/uploadInstructions.js.map +1 -1
- package/dist/uploads/generateFileData.js +4 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getFileFromUploadInstructions.d.ts +8 -0
- package/dist/uploads/getFileFromUploadInstructions.d.ts.map +1 -0
- package/dist/uploads/getFileFromUploadInstructions.js +62 -0
- package/dist/uploads/getFileFromUploadInstructions.js.map +1 -0
- package/dist/uploads/getImageSize.d.ts +12 -1
- package/dist/uploads/getImageSize.d.ts.map +1 -1
- package/dist/uploads/getImageSize.js +20 -18
- package/dist/uploads/getImageSize.js.map +1 -1
- package/dist/uploads/getImageSize.spec.js +298 -0
- package/dist/uploads/getImageSize.spec.js.map +1 -0
- package/dist/uploads/probeImageSize.d.ts +39 -0
- package/dist/uploads/probeImageSize.d.ts.map +1 -0
- package/dist/uploads/probeImageSize.js +374 -0
- package/dist/uploads/probeImageSize.js.map +1 -0
- package/dist/uploads/probeImageSize.spec.js +366 -0
- package/dist/uploads/probeImageSize.spec.js.map +1 -0
- package/dist/uploads/stagedUpload.d.ts +27 -0
- package/dist/uploads/stagedUpload.d.ts.map +1 -0
- package/dist/uploads/stagedUpload.js +197 -0
- package/dist/uploads/stagedUpload.js.map +1 -0
- package/dist/uploads/types.d.ts +41 -13
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +12 -46
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +33 -33
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/fieldValueExists.d.ts +29 -0
- package/dist/utilities/fieldValueExists.d.ts.map +1 -0
- package/dist/utilities/fieldValueExists.js +27 -0
- package/dist/utilities/fieldValueExists.js.map +1 -0
- package/dist/utilities/getUniqueFieldValue.d.ts +27 -0
- package/dist/utilities/getUniqueFieldValue.d.ts.map +1 -0
- package/dist/utilities/getUniqueFieldValue.js +26 -0
- package/dist/utilities/getUniqueFieldValue.js.map +1 -0
- package/dist/versions/deleteScheduledPublishJobs.js +2 -2
- package/dist/versions/deleteScheduledPublishJobs.js.map +1 -1
- package/dist/versions/payloadPackageList.d.ts.map +1 -1
- package/dist/versions/payloadPackageList.js +0 -1
- package/dist/versions/payloadPackageList.js.map +1 -1
- package/package.json +8 -3
- package/dist/database/defaultUpdateJobs.d.ts +0 -3
- package/dist/database/defaultUpdateJobs.d.ts.map +0 -1
- package/dist/database/defaultUpdateJobs.js +0 -41
- package/dist/database/defaultUpdateJobs.js.map +0 -1
- package/dist/fields/baseFields/slug/countVersions.d.ts +0 -13
- package/dist/fields/baseFields/slug/countVersions.d.ts.map +0 -1
- package/dist/fields/baseFields/slug/countVersions.js +0 -27
- package/dist/fields/baseFields/slug/countVersions.js.map +0 -1
- package/dist/uploads/tempFile.d.ts +0 -7
- package/dist/uploads/tempFile.d.ts.map +0 -1
- package/dist/uploads/tempFile.js +0 -39
- package/dist/uploads/tempFile.js.map +0 -1
|
@@ -2,7 +2,7 @@ import type { Field } from '../../../fields/config/types.js';
|
|
|
2
2
|
import type { Job, MaybePromise, PayloadRequest, StringKeyOf, TypedCollection, TypedJobs } from '../../../index.js';
|
|
3
3
|
import type { TaskParent } from '../../operations/runJobs/runJob/getRunTaskFunction.js';
|
|
4
4
|
import type { ScheduleConfig } from './index.js';
|
|
5
|
-
import type { RetryConfig, RunInlineTaskFunction, RunTaskFunctions, TaskInput, TaskOutput,
|
|
5
|
+
import type { RetryConfig, RunInlineTaskFunction, RunTaskFunctions, TaskInput, TaskOutput, TaskSlug } from './taskTypes.js';
|
|
6
6
|
import type { WorkflowJSON } from './workflowJSONTypes.js';
|
|
7
7
|
export type JobLog = {
|
|
8
8
|
completedAt: string;
|
|
@@ -12,7 +12,7 @@ export type JobLog = {
|
|
|
12
12
|
* ID added by the array field when the log is saved in the database
|
|
13
13
|
*/
|
|
14
14
|
id: string;
|
|
15
|
-
input
|
|
15
|
+
input: Record<string, any>;
|
|
16
16
|
output?: Record<string, any>;
|
|
17
17
|
/**
|
|
18
18
|
* Sub-tasks (tasks that are run within a task) will have a parent task ID
|
|
@@ -20,60 +20,13 @@ export type JobLog = {
|
|
|
20
20
|
parent?: TaskParent;
|
|
21
21
|
state: 'failed' | 'succeeded';
|
|
22
22
|
taskID: string;
|
|
23
|
-
taskSlug:
|
|
23
|
+
taskSlug: TaskSlug;
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
export type BaseJob<TWorkflowSlugOrInput extends false | keyof TypedJobs['workflows'] | object = false> = {
|
|
29
|
-
completedAt?: null | string;
|
|
30
|
-
/**
|
|
31
|
-
* Used for concurrency control. Jobs with the same key are subject to exclusive/supersedes rules.
|
|
32
|
-
*/
|
|
33
|
-
concurrencyKey?: null | string;
|
|
34
|
-
createdAt: string;
|
|
35
|
-
error?: unknown;
|
|
36
|
-
hasError?: boolean;
|
|
37
|
-
id: number | string;
|
|
38
|
-
input: TWorkflowSlugOrInput extends false ? object : TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input'] : TWorkflowSlugOrInput;
|
|
39
|
-
log?: JobLog[];
|
|
40
|
-
meta?: {
|
|
41
|
-
[key: string]: unknown;
|
|
42
|
-
/**
|
|
43
|
-
* If true, this job was queued by the scheduling system.
|
|
44
|
-
*/
|
|
45
|
-
scheduled?: boolean;
|
|
46
|
-
};
|
|
47
|
-
processing?: boolean;
|
|
48
|
-
queue?: string;
|
|
49
|
-
taskSlug?: null | TaskType;
|
|
50
|
-
taskStatus: JobTaskStatus;
|
|
51
|
-
totalTried: number;
|
|
52
|
-
updatedAt: string;
|
|
53
|
-
waitUntil?: null | string;
|
|
54
|
-
workflowSlug?: null | WorkflowTypes;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* @todo rename to WorkflowSlug in 4.0, similar to CollectionSlug
|
|
58
|
-
*/
|
|
59
|
-
export type WorkflowTypes = StringKeyOf<TypedJobs['workflows']>;
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated - will be removed in 4.0. Use `Job` type instead.
|
|
62
|
-
*/
|
|
63
|
-
export type RunningJob<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = {
|
|
64
|
-
input: TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input'] : TWorkflowSlugOrInput;
|
|
65
|
-
taskStatus: JobTaskStatus;
|
|
66
|
-
} & Omit<TypedCollection['payload-jobs'], 'input' | 'taskStatus'>;
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated - will be removed in 4.0. Use `Job` type instead.
|
|
69
|
-
*/
|
|
70
|
-
export type RunningJobSimple<TWorkflowInput extends object> = {
|
|
71
|
-
input: TWorkflowInput;
|
|
72
|
-
} & TypedCollection['payload-jobs'];
|
|
73
|
-
export type RunningJobFromTask<TTaskSlug extends keyof TypedJobs['tasks']> = {
|
|
25
|
+
export type WorkflowSlug = StringKeyOf<TypedJobs['workflows']>;
|
|
26
|
+
export type JobFromTask<TTaskSlug extends keyof TypedJobs['tasks']> = {
|
|
74
27
|
input: TypedJobs['tasks'][TTaskSlug]['input'];
|
|
75
28
|
} & TypedCollection['payload-jobs'];
|
|
76
|
-
export type WorkflowHandler<TWorkflowSlugOrInput extends
|
|
29
|
+
export type WorkflowHandler<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object = object> = (args: {
|
|
77
30
|
inlineTask: RunInlineTaskFunction;
|
|
78
31
|
job: Job<TWorkflowSlugOrInput>;
|
|
79
32
|
req: PayloadRequest;
|
|
@@ -83,14 +36,14 @@ export type SingleTaskStatus<T extends keyof TypedJobs['tasks']> = {
|
|
|
83
36
|
complete: boolean;
|
|
84
37
|
input: TaskInput<T>;
|
|
85
38
|
output: TaskOutput<T>;
|
|
86
|
-
taskSlug:
|
|
39
|
+
taskSlug: TaskSlug;
|
|
87
40
|
totalTried: number;
|
|
88
41
|
};
|
|
89
42
|
/**
|
|
90
43
|
* Task IDs mapped to their status
|
|
91
44
|
*/
|
|
92
45
|
export type JobTaskStatus = {
|
|
93
|
-
[taskSlug in
|
|
46
|
+
[taskSlug in TaskSlug]: {
|
|
94
47
|
[taskID: string]: SingleTaskStatus<taskSlug>;
|
|
95
48
|
};
|
|
96
49
|
};
|
|
@@ -125,14 +78,14 @@ export type ConcurrencyConfig<TInput = object> = ((args: {
|
|
|
125
78
|
*/
|
|
126
79
|
supersedes?: boolean;
|
|
127
80
|
};
|
|
128
|
-
export type WorkflowConfig<TWorkflowSlugOrInput extends
|
|
81
|
+
export type WorkflowConfig<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object = object> = {
|
|
129
82
|
/**
|
|
130
83
|
* Job concurrency controls for preventing race conditions.
|
|
131
84
|
*
|
|
132
85
|
* Can be an object with full options, or a shorthand function that just returns the key
|
|
133
86
|
* (in which case exclusive defaults to true).
|
|
134
87
|
*/
|
|
135
|
-
concurrency?: ConcurrencyConfig<TWorkflowSlugOrInput extends
|
|
88
|
+
concurrency?: ConcurrencyConfig<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input'] : TWorkflowSlugOrInput>;
|
|
136
89
|
/**
|
|
137
90
|
* You can either pass a string-based path to the workflow function file, or the workflow function itself.
|
|
138
91
|
*
|
|
@@ -140,7 +93,7 @@ export type WorkflowConfig<TWorkflowSlugOrInput extends false | keyof TypedJobs[
|
|
|
140
93
|
* because that will avoid bundling large dependencies in your Next.js app. Passing a string path is an advanced feature
|
|
141
94
|
* that may require a sophisticated build pipeline in order to work.
|
|
142
95
|
*/
|
|
143
|
-
handler: string | WorkflowHandler<TWorkflowSlugOrInput> | WorkflowJSON<TWorkflowSlugOrInput
|
|
96
|
+
handler: string | WorkflowHandler<TWorkflowSlugOrInput> | WorkflowJSON<TWorkflowSlugOrInput>;
|
|
144
97
|
/**
|
|
145
98
|
* Define the input field schema - payload will generate a type for this schema.
|
|
146
99
|
*/
|
|
@@ -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,MAAM,MAAM,GAAG;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,
|
|
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,E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AM,SAAS,CAAC,WAAW,CAAC,GACrD,SAAS,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,GACrD,oBAAoB,CACzB,CAAA;IACD;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,GAAG,eAAe,CAAC,oBAAoB,CAAC,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAA;IAC5F;;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
|
|
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 TaskSlug,\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: TaskSlug\n}\n\nexport type WorkflowSlug = StringKeyOf<TypedJobs['workflows']>\n\n// Simplified version of Job that doesn't break TypeScript (TypeScript seems to stop evaluating Job when it's too complex)\nexport type JobFromTask<TTaskSlug extends keyof TypedJobs['tasks']> = {\n input: TypedJobs['tasks'][TTaskSlug]['input']\n} & TypedCollection['payload-jobs']\n\nexport type WorkflowHandler<\n TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object = object,\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: TaskSlug\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 TaskSlug]: {\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 keyof TypedJobs['workflows'] | object = object,\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 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: string | WorkflowHandler<TWorkflowSlugOrInput> | WorkflowJSON<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":"AAuGA,WAyDC"}
|
|
@@ -26,7 +26,7 @@ import { configHasJobs } from './run.js';
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
if (!jobsConfig.scheduling) {
|
|
29
|
-
// There is no reason to call the handleSchedules endpoint
|
|
29
|
+
// There is no reason to call the handleSchedules endpoint when no schedules are defined.
|
|
30
30
|
return Response.json({
|
|
31
31
|
message: 'Cannot handle schedules because no tasks or workflows with schedules are defined.'
|
|
32
32
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/queues/endpoints/handleSchedules.ts"],"sourcesContent":["import type { Endpoint } from '../../config/types.js'\n\nimport { handleSchedules } from '../operations/handleSchedules/index.js'\nimport { configHasJobs } from './run.js'\n\n/**\n * GET /api/payload-jobs/handle-schedules endpoint\n *\n * This endpoint is GET instead of POST to allow it to be used in a Vercel Cron.\n */\nexport const handleSchedulesJobsEndpoint: Endpoint = {\n handler: async (req) => {\n const jobsConfig = req.payload.config.jobs\n\n if (!configHasJobs(jobsConfig)) {\n return Response.json(\n {\n message: 'No jobs to schedule.',\n },\n { status: 200 },\n )\n }\n\n const accessFn = jobsConfig.access?.run ?? (() => true)\n\n const hasAccess = await accessFn({ req })\n\n if (!hasAccess) {\n return Response.json(\n {\n message: req.i18n.t('error:unauthorized'),\n },\n { status: 401 },\n )\n }\n\n if (!jobsConfig.scheduling) {\n // There is no reason to call the handleSchedules endpoint
|
|
1
|
+
{"version":3,"sources":["../../../src/queues/endpoints/handleSchedules.ts"],"sourcesContent":["import type { Endpoint } from '../../config/types.js'\n\nimport { handleSchedules } from '../operations/handleSchedules/index.js'\nimport { configHasJobs } from './run.js'\n\n/**\n * GET /api/payload-jobs/handle-schedules endpoint\n *\n * This endpoint is GET instead of POST to allow it to be used in a Vercel Cron.\n */\nexport const handleSchedulesJobsEndpoint: Endpoint = {\n handler: async (req) => {\n const jobsConfig = req.payload.config.jobs\n\n if (!configHasJobs(jobsConfig)) {\n return Response.json(\n {\n message: 'No jobs to schedule.',\n },\n { status: 200 },\n )\n }\n\n const accessFn = jobsConfig.access?.run ?? (() => true)\n\n const hasAccess = await accessFn({ req })\n\n if (!hasAccess) {\n return Response.json(\n {\n message: req.i18n.t('error:unauthorized'),\n },\n { status: 401 },\n )\n }\n\n if (!jobsConfig.scheduling) {\n // There is no reason to call the handleSchedules endpoint when no schedules are defined.\n return Response.json(\n {\n message:\n 'Cannot handle schedules because no tasks or workflows with schedules are defined.',\n },\n { status: 500 },\n )\n }\n\n const { allQueues, queue } = req.query as {\n allQueues?: 'false' | 'true'\n queue?: string\n }\n\n const runAllQueues = allQueues && !(typeof allQueues === 'string' && allQueues === 'false')\n\n const { errored, queued, skipped } = await handleSchedules({\n allQueues: runAllQueues,\n queue,\n req,\n })\n\n return Response.json(\n {\n errored,\n message: req.i18n.t('general:success'),\n queued,\n skipped,\n },\n { status: 200 },\n )\n },\n method: 'get',\n path: '/handle-schedules',\n}\n"],"names":["handleSchedules","configHasJobs","handleSchedulesJobsEndpoint","handler","req","jobsConfig","payload","config","jobs","Response","json","message","status","accessFn","access","run","hasAccess","i18n","t","scheduling","allQueues","queue","query","runAllQueues","errored","queued","skipped","method","path"],"mappings":"AAEA,SAASA,eAAe,QAAQ,yCAAwC;AACxE,SAASC,aAAa,QAAQ,WAAU;AAExC;;;;CAIC,GACD,OAAO,MAAMC,8BAAwC;IACnDC,SAAS,OAAOC;QACd,MAAMC,aAAaD,IAAIE,OAAO,CAACC,MAAM,CAACC,IAAI;QAE1C,IAAI,CAACP,cAAcI,aAAa;YAC9B,OAAOI,SAASC,IAAI,CAClB;gBACEC,SAAS;YACX,GACA;gBAAEC,QAAQ;YAAI;QAElB;QAEA,MAAMC,WAAWR,WAAWS,MAAM,EAAEC,OAAQ,CAAA,IAAM,IAAG;QAErD,MAAMC,YAAY,MAAMH,SAAS;YAAET;QAAI;QAEvC,IAAI,CAACY,WAAW;YACd,OAAOP,SAASC,IAAI,CAClB;gBACEC,SAASP,IAAIa,IAAI,CAACC,CAAC,CAAC;YACtB,GACA;gBAAEN,QAAQ;YAAI;QAElB;QAEA,IAAI,CAACP,WAAWc,UAAU,EAAE;YAC1B,yFAAyF;YACzF,OAAOV,SAASC,IAAI,CAClB;gBACEC,SACE;YACJ,GACA;gBAAEC,QAAQ;YAAI;QAElB;QAEA,MAAM,EAAEQ,SAAS,EAAEC,KAAK,EAAE,GAAGjB,IAAIkB,KAAK;QAKtC,MAAMC,eAAeH,aAAa,CAAE,CAAA,OAAOA,cAAc,YAAYA,cAAc,OAAM;QAEzF,MAAM,EAAEI,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAM1B,gBAAgB;YACzDoB,WAAWG;YACXF;YACAjB;QACF;QAEA,OAAOK,SAASC,IAAI,CAClB;YACEc;YACAb,SAASP,IAAIa,IAAI,CAACC,CAAC,CAAC;YACpBO;YACAC;QACF,GACA;YAAEd,QAAQ;QAAI;IAElB;IACAe,QAAQ;IACRC,MAAM;AACR,EAAC"}
|
|
@@ -44,9 +44,9 @@ export async function handleTaskError({ error, req, silent = false, updateJob })
|
|
|
44
44
|
completedAt: currentDate.toISOString(),
|
|
45
45
|
error: errorJSON,
|
|
46
46
|
executedAt: executedAt.toISOString(),
|
|
47
|
-
input,
|
|
47
|
+
input: input ?? {},
|
|
48
48
|
output: output ?? {},
|
|
49
|
-
parent
|
|
49
|
+
parent,
|
|
50
50
|
state: 'failed',
|
|
51
51
|
taskID,
|
|
52
52
|
taskSlug
|
|
@@ -60,7 +60,7 @@ export async function handleTaskError({ error, req, silent = false, updateJob })
|
|
|
60
60
|
log: {
|
|
61
61
|
$push: taskLogToPush
|
|
62
62
|
},
|
|
63
|
-
|
|
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
|
-
|
|
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
|
|
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: input ?? {},\n output: output ?? {},\n parent,\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","state","complete","totalTried","hasError","log","$push","processingUntil","payload","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,SAAS;QACtB;IACF;IAEA,IAAIE,aAAqB;IAEzB,IAAIjB,eAAekB,aAAaC,aAAanB,eAAekB,aAAa,MAAM;QAC7E,6GAA6G;QAC7G,IAAIb,eAAee,OAAO,KAAKD,aAAad,eAAee,OAAO,KAAK,MAAM;YAC3EH,aACE,OAAOZ,eAAee,OAAO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cAAcb,WAAW;IAC3C;IAEA,MAAM,EAAEY,aAAa,EAAEE,kBAAkB,EAAExB,SAAS,EAAE,GAAG5B,yBAAyB;QAChFU;QACAG,eAAeK,eAAee,OAAO;IACvC;IAEA,IAAI,CAAC3B,UAAW,OAAOA,WAAW,YAAY,CAACA,OAAOF,KAAK,EAAG;QAC5DC,IAAIyC,OAAO,CAACC,MAAM,CAAC3C,KAAK,CAAC;YACvB4C,KAAK5C;YACLM;YACAuC,KAAK,CAAC,mBAAmB,EAAElC,OAAO,UAAU,EAAEL,IAAI+B,UAAU,GAAG,IAAIW,uBAAuBpB,YAAY,MAAOoB,CAAAA,qBAAqB,CAAA,IAAK,IAAI;YAC3IpC;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,OAAO8C,gBAAgB7B,YAAYW;QACnCU,UAAUQ;QACVP,KAAK;YACHC,OAAOV;QACT;QACAW,iBAAiB;QACjBJ,YAAY,AAAC/B,CAAAA,IAAI+B,UAAU,IAAI,CAAA,IAAK;QACpCb,WAAWlB,IAAIkB,SAAS;IAC1B;IAEA,OAAO;QACLsB;IACF;AACF"}
|
|
@@ -53,7 +53,7 @@ import { getWorkflowRetryBehavior } from './getWorkflowRetryBehavior.js';
|
|
|
53
53
|
await updateJob({
|
|
54
54
|
error: errorJSON,
|
|
55
55
|
hasError: hasFinalError,
|
|
56
|
-
|
|
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
|
|
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","totalTried","hasError","processingUntil"],"mappings":"AAKA,SAASA,cAAc,QAAQ,iCAAgC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1B,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"}
|
|
@@ -28,6 +28,12 @@ export declare class WorkflowError extends Error {
|
|
|
28
28
|
args: WorkflowErrorArgs;
|
|
29
29
|
constructor(args: WorkflowErrorArgs);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Stops the current job run after this worker loses ownership.
|
|
33
|
+
* The job remains recoverable by another worker.
|
|
34
|
+
*/
|
|
35
|
+
export declare class JobRunAbortedError extends Error {
|
|
36
|
+
}
|
|
31
37
|
/**
|
|
32
38
|
* Throw this error from within a task or workflow handler to cancel the job.
|
|
33
39
|
* Unlike failing a job (e.g. by throwing any other error), a cancelled job will not be retried.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queues/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAA;AAEpF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,IAAI,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA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AG,CAAA;IACR,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,aAAa,EAAE,WAAW,CAAA;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC3C,cAAc,EAAE,cAAc,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,GAAG,CAAA;IACR,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,cAAc,CAAA;CAC/B,CAAA;AAED,qBAAa,SAAU,SAAQ,KAAK;IAClC,IAAI,EAAE,aAAa,CAAA;IACnB,YAAY,IAAI,EAAE,aAAa,EAG9B;CACF;AACD,qBAAa,aAAc,SAAQ,KAAK;IACtC,IAAI,EAAE,iBAAiB,CAAA;IAEvB,YAAY,IAAI,EAAE,iBAAiB,EAGlC;CACF;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,EAAE,MAAM,EAE1B;CACF"}
|
|
@@ -12,6 +12,11 @@ export class WorkflowError extends Error {
|
|
|
12
12
|
this.args = args;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Stops the current job run after this worker loses ownership.
|
|
17
|
+
* The job remains recoverable by another worker.
|
|
18
|
+
*/ export class JobRunAbortedError extends Error {
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* Throw this error from within a task or workflow handler to cancel the job.
|
|
17
22
|
* Unlike failing a job (e.g. by throwing any other error), a cancelled job will not be retried.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/queues/errors/index.ts"],"sourcesContent":["import type { Job, SingleTaskStatus, WorkflowConfig } from '../../index.js'\nimport type { RetryConfig, TaskConfig } from '../config/types/taskTypes.js'\nimport type { TaskParent } from '../operations/runJobs/runJob/getRunTaskFunction.js'\n\nexport type TaskErrorArgs = {\n executedAt: Date\n input?: object\n job: Job\n message: string\n output?: object\n parent?: TaskParent\n retriesConfig: RetryConfig\n taskConfig?: TaskConfig<string>\n taskID: string\n taskSlug: string\n taskStatus: null | SingleTaskStatus<string>\n workflowConfig: WorkflowConfig\n}\n\nexport type WorkflowErrorArgs = {\n job: Job\n message: string\n workflowConfig: WorkflowConfig\n}\n\nexport class TaskError extends Error {\n args: TaskErrorArgs\n constructor(args: TaskErrorArgs) {\n super(args.message)\n this.args = args\n }\n}\nexport class WorkflowError extends Error {\n args: WorkflowErrorArgs\n\n constructor(args: WorkflowErrorArgs) {\n super(args.message)\n this.args = args\n }\n}\n\n/**\n * Throw this error from within a task or workflow handler to cancel the job.\n * Unlike failing a job (e.g. by throwing any other error), a cancelled job will not be retried.\n */\nexport class JobCancelledError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n"],"names":["TaskError","Error","args","message","WorkflowError","JobCancelledError"],"mappings":"AAyBA,OAAO,MAAMA,kBAAkBC;IAC7BC,KAAmB;IACnB,YAAYA,IAAmB,CAAE;QAC/B,KAAK,CAACA,KAAKC,OAAO;QAClB,IAAI,CAACD,IAAI,GAAGA;IACd;AACF;AACA,OAAO,MAAME,sBAAsBH;IACjCC,KAAuB;IAEvB,YAAYA,IAAuB,CAAE;QACnC,KAAK,CAACA,KAAKC,OAAO;QAClB,IAAI,CAACD,IAAI,GAAGA;IACd;AACF;AAEA;;;CAGC,GACD,OAAO,MAAMG,
|
|
1
|
+
{"version":3,"sources":["../../../src/queues/errors/index.ts"],"sourcesContent":["import type { Job, SingleTaskStatus, WorkflowConfig } from '../../index.js'\nimport type { RetryConfig, TaskConfig } from '../config/types/taskTypes.js'\nimport type { TaskParent } from '../operations/runJobs/runJob/getRunTaskFunction.js'\n\nexport type TaskErrorArgs = {\n executedAt: Date\n input?: object\n job: Job\n message: string\n output?: object\n parent?: TaskParent\n retriesConfig: RetryConfig\n taskConfig?: TaskConfig<string>\n taskID: string\n taskSlug: string\n taskStatus: null | SingleTaskStatus<string>\n workflowConfig: WorkflowConfig\n}\n\nexport type WorkflowErrorArgs = {\n job: Job\n message: string\n workflowConfig: WorkflowConfig\n}\n\nexport class TaskError extends Error {\n args: TaskErrorArgs\n constructor(args: TaskErrorArgs) {\n super(args.message)\n this.args = args\n }\n}\nexport class WorkflowError extends Error {\n args: WorkflowErrorArgs\n\n constructor(args: WorkflowErrorArgs) {\n super(args.message)\n this.args = args\n }\n}\n\n/**\n * Stops the current job run after this worker loses ownership.\n * The job remains recoverable by another worker.\n */\nexport class JobRunAbortedError extends Error {}\n\n/**\n * Throw this error from within a task or workflow handler to cancel the job.\n * Unlike failing a job (e.g. by throwing any other error), a cancelled job will not be retried.\n */\nexport class JobCancelledError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n"],"names":["TaskError","Error","args","message","WorkflowError","JobRunAbortedError","JobCancelledError"],"mappings":"AAyBA,OAAO,MAAMA,kBAAkBC;IAC7BC,KAAmB;IACnB,YAAYA,IAAmB,CAAE;QAC/B,KAAK,CAACA,KAAKC,OAAO;QAClB,IAAI,CAACD,IAAI,GAAGA;IACd;AACF;AACA,OAAO,MAAME,sBAAsBH;IACjCC,KAAuB;IAEvB,YAAYA,IAAuB,CAAE;QACnC,KAAK,CAACA,KAAKC,OAAO;QAClB,IAAI,CAACD,IAAI,GAAGA;IACd;AACF;AAEA;;;CAGC,GACD,OAAO,MAAMG,2BAA2BJ;AAAO;AAE/C;;;CAGC,GACD,OAAO,MAAMK,0BAA0BL;IACrC,YAAYE,OAAe,CAAE;QAC3B,KAAK,CAACA;IACR;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JobFromTask } from './config/types/workflowTypes.js';
|
|
2
2
|
import { type Job, type Payload, type PayloadRequest, type Sort, type TypedJobs, type Where } from '../index.js';
|
|
3
3
|
import { type HandleSchedulesResult } from './operations/handleSchedules/index.js';
|
|
4
4
|
import { runJobs } from './operations/runJobs/index.js';
|
|
@@ -25,7 +25,7 @@ export declare const getJobsLocalAPI: (payload: Payload) => {
|
|
|
25
25
|
}) => Promise<HandleSchedulesResult>;
|
|
26
26
|
queue: <TTaskOrWorkflowSlug extends keyof TypedJobs['tasks'] | keyof TypedJobs['workflows']>(args: {
|
|
27
27
|
input: TypedJobs['tasks'][TTaskOrWorkflowSlug]['input'];
|
|
28
|
-
meta?:
|
|
28
|
+
meta?: Job['meta'];
|
|
29
29
|
/**
|
|
30
30
|
* If set to false, access control as defined in jobsConfig.access.queue will be run.
|
|
31
31
|
* By default, this is true and no access control will be run.
|
|
@@ -48,7 +48,7 @@ export declare const getJobsLocalAPI: (payload: Payload) => {
|
|
|
48
48
|
workflow?: never;
|
|
49
49
|
} | {
|
|
50
50
|
input: TypedJobs['workflows'][TTaskOrWorkflowSlug]['input'];
|
|
51
|
-
meta?:
|
|
51
|
+
meta?: Job['meta'];
|
|
52
52
|
/**
|
|
53
53
|
* If set to false, access control as defined in jobsConfig.access.queue will be run.
|
|
54
54
|
* By default, this is true and no access control will be run.
|
|
@@ -69,7 +69,7 @@ export declare const getJobsLocalAPI: (payload: Payload) => {
|
|
|
69
69
|
task?: never;
|
|
70
70
|
waitUntil?: Date;
|
|
71
71
|
workflow: TTaskOrWorkflowSlug extends keyof TypedJobs['workflows'] ? TTaskOrWorkflowSlug : never;
|
|
72
|
-
}) => Promise<TTaskOrWorkflowSlug extends keyof TypedJobs['workflows'] ? Job<TTaskOrWorkflowSlug> :
|
|
72
|
+
}) => Promise<TTaskOrWorkflowSlug extends keyof TypedJobs['workflows'] ? Job<TTaskOrWorkflowSlug> : JobFromTask<TTaskOrWorkflowSlug>>;
|
|
73
73
|
run: (args?: {
|
|
74
74
|
/**
|
|
75
75
|
* If you want to run jobs from all queues, set this to true.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localAPI.d.ts","sourceRoot":"","sources":["../../src/queues/localAPI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"localAPI.d.ts","sourceRoot":"","sources":["../../src/queues/localAPI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAElE,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,KAAK,EACX,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AACnG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAA;AAGvD,MAAM,MAAM,aAAa,GACrB;IACE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,GACD,OAAO,CAAA;AACX,eAAO,MAAM,eAAe,YAAa,OAAO;IAC9C,eAAe,UAAgB;QAC7B;;;;;WAKG;QACH,SAAS,CAAC,EAAE,OAAO,CAAA;QAInB;;;;WAIG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,GAAG,CAAC,EAAE,cAAc,CAAA;KACrB,KAAG,OAAO,CAAC,qBAAqB,CAAC;IASlC,KAAK,GAEH,mBAAmB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,QAG/E;QACE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAA;QACvD,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAClB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB;;;;;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M,CAAC,EAAE,aAAa,CAAA;QACtB,KAAK,CAAC,EAAE,KAAK,CAAA;KACd,KAAG,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IAgBvC,OAAO,SAAe;QACpB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,GAAG,CAAC,EAAE,cAAc,CAAA;QACpB;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,aAAa,CAAA;KACvB,KAAG,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IAWvC,MAAM,SAAe;QACnB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,GAAG,CAAC,EAAE,cAAc,CAAA;QACpB,KAAK,EAAE,KAAK,CAAA;KACb,KAAG,OAAO,CAAC,IAAI,CAAC;IAqDjB,UAAU,SAAe;QACvB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB;;;;;;;WAOG;QACH,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,GAAG,CAAC,EAAE,cAAc,CAAA;KACrB,KAAG,OAAO,CAAC,IAAI,CAAC;CA8BjB,CAAA"}
|
package/dist/queues/localAPI.js
CHANGED
|
@@ -56,76 +56,73 @@ export const getJobsLocalAPI = (payload)=>({
|
|
|
56
56
|
if (args.meta) {
|
|
57
57
|
data.meta = args.meta;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
supersedes = concurrencyConfig.supersedes ?? false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} else if (args.task) {
|
|
82
|
-
const task = payload.config.jobs?.tasks?.find(({ slug })=>slug === args.task);
|
|
83
|
-
if (task?.concurrency) {
|
|
84
|
-
const concurrencyConfig = task.concurrency;
|
|
85
|
-
if (typeof concurrencyConfig === 'function') {
|
|
86
|
-
concurrencyKey = concurrencyConfig({
|
|
87
|
-
input: args.input,
|
|
88
|
-
queue: queueName
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
concurrencyKey = concurrencyConfig.key({
|
|
92
|
-
input: args.input,
|
|
93
|
-
queue: queueName
|
|
94
|
-
});
|
|
95
|
-
supersedes = concurrencyConfig.supersedes ?? false;
|
|
96
|
-
}
|
|
59
|
+
let concurrencyKey = null;
|
|
60
|
+
let supersedes = false;
|
|
61
|
+
const queueName = queue || 'default';
|
|
62
|
+
if (args.workflow) {
|
|
63
|
+
const workflow = payload.config.jobs?.workflows?.find(({ slug })=>slug === args.workflow);
|
|
64
|
+
if (workflow?.concurrency) {
|
|
65
|
+
const concurrencyConfig = workflow.concurrency;
|
|
66
|
+
if (typeof concurrencyConfig === 'function') {
|
|
67
|
+
concurrencyKey = concurrencyConfig({
|
|
68
|
+
input: args.input,
|
|
69
|
+
queue: queueName
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
concurrencyKey = concurrencyConfig.key({
|
|
73
|
+
input: args.input,
|
|
74
|
+
queue: queueName
|
|
75
|
+
});
|
|
76
|
+
supersedes = concurrencyConfig.supersedes ?? false;
|
|
97
77
|
}
|
|
98
78
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
and: [
|
|
108
|
-
{
|
|
109
|
-
concurrencyKey: {
|
|
110
|
-
equals: concurrencyKey
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
processing: {
|
|
115
|
-
equals: false
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
completedAt: {
|
|
120
|
-
exists: false
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
}
|
|
79
|
+
} else if (args.task) {
|
|
80
|
+
const task = payload.config.jobs?.tasks?.find(({ slug })=>slug === args.task);
|
|
81
|
+
if (task?.concurrency) {
|
|
82
|
+
const concurrencyConfig = task.concurrency;
|
|
83
|
+
if (typeof concurrencyConfig === 'function') {
|
|
84
|
+
concurrencyKey = concurrencyConfig({
|
|
85
|
+
input: args.input,
|
|
86
|
+
queue: queueName
|
|
125
87
|
});
|
|
88
|
+
} else {
|
|
89
|
+
concurrencyKey = concurrencyConfig.key({
|
|
90
|
+
input: args.input,
|
|
91
|
+
queue: queueName
|
|
92
|
+
});
|
|
93
|
+
supersedes = concurrencyConfig.supersedes ?? false;
|
|
126
94
|
}
|
|
127
95
|
}
|
|
128
96
|
}
|
|
97
|
+
if (concurrencyKey) {
|
|
98
|
+
data.concurrencyKey = concurrencyKey;
|
|
99
|
+
// If supersedes is enabled, delete older pending jobs with the same key
|
|
100
|
+
if (supersedes) {
|
|
101
|
+
await payload.db.deleteMany({
|
|
102
|
+
collection: jobsCollectionSlug,
|
|
103
|
+
req,
|
|
104
|
+
where: {
|
|
105
|
+
and: [
|
|
106
|
+
{
|
|
107
|
+
concurrencyKey: {
|
|
108
|
+
equals: concurrencyKey
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
processingUntil: {
|
|
113
|
+
exists: false
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
completedAt: {
|
|
118
|
+
exists: false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
129
126
|
// Type assertion is still needed here
|
|
130
127
|
return jobAfterRead({
|
|
131
128
|
config: payload.config,
|
|
@@ -200,7 +197,7 @@ export const getJobsLocalAPI = (payload)=>({
|
|
|
200
197
|
cancelled: true
|
|
201
198
|
},
|
|
202
199
|
hasError: true,
|
|
203
|
-
|
|
200
|
+
processingUntil: null,
|
|
204
201
|
waitUntil: null
|
|
205
202
|
},
|
|
206
203
|
req,
|
|
@@ -232,7 +229,7 @@ export const getJobsLocalAPI = (payload)=>({
|
|
|
232
229
|
cancelled: true
|
|
233
230
|
},
|
|
234
231
|
hasError: true,
|
|
235
|
-
|
|
232
|
+
processingUntil: null,
|
|
236
233
|
waitUntil: null
|
|
237
234
|
},
|
|
238
235
|
req,
|