payload 3.0.0-beta.120 → 3.0.0-beta.121

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 (287) hide show
  1. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  2. package/dist/auth/operations/registerFirstUser.js.map +1 -1
  3. package/dist/auth/strategies/local/register.d.ts +3 -2
  4. package/dist/auth/strategies/local/register.d.ts.map +1 -1
  5. package/dist/auth/strategies/local/register.js +3 -2
  6. package/dist/auth/strategies/local/register.js.map +1 -1
  7. package/dist/bin/generateTypes.d.ts.map +1 -1
  8. package/dist/bin/generateTypes.js +4 -0
  9. package/dist/bin/generateTypes.js.map +1 -1
  10. package/dist/bin/index.d.ts +1 -1
  11. package/dist/bin/index.d.ts.map +1 -1
  12. package/dist/bin/index.js +25 -0
  13. package/dist/bin/index.js.map +1 -1
  14. package/dist/collections/config/types.d.ts +7 -5
  15. package/dist/collections/config/types.d.ts.map +1 -1
  16. package/dist/collections/config/types.js.map +1 -1
  17. package/dist/collections/dataloader.d.ts +3 -2
  18. package/dist/collections/dataloader.d.ts.map +1 -1
  19. package/dist/collections/dataloader.js +9 -5
  20. package/dist/collections/dataloader.js.map +1 -1
  21. package/dist/collections/operations/create.d.ts +4 -3
  22. package/dist/collections/operations/create.d.ts.map +1 -1
  23. package/dist/collections/operations/create.js +6 -3
  24. package/dist/collections/operations/create.js.map +1 -1
  25. package/dist/collections/operations/delete.d.ts +4 -9
  26. package/dist/collections/operations/delete.d.ts.map +1 -1
  27. package/dist/collections/operations/delete.js +3 -1
  28. package/dist/collections/operations/delete.js.map +1 -1
  29. package/dist/collections/operations/deleteByID.d.ts +4 -3
  30. package/dist/collections/operations/deleteByID.d.ts.map +1 -1
  31. package/dist/collections/operations/deleteByID.js +3 -1
  32. package/dist/collections/operations/deleteByID.js.map +1 -1
  33. package/dist/collections/operations/duplicate.d.ts +4 -3
  34. package/dist/collections/operations/duplicate.d.ts.map +1 -1
  35. package/dist/collections/operations/duplicate.js +7 -3
  36. package/dist/collections/operations/duplicate.js.map +1 -1
  37. package/dist/collections/operations/find.d.ts +4 -3
  38. package/dist/collections/operations/find.d.ts.map +1 -1
  39. package/dist/collections/operations/find.js +7 -1
  40. package/dist/collections/operations/find.js.map +1 -1
  41. package/dist/collections/operations/findByID.d.ts +4 -3
  42. package/dist/collections/operations/findByID.d.ts.map +1 -1
  43. package/dist/collections/operations/findByID.js +5 -2
  44. package/dist/collections/operations/findByID.js.map +1 -1
  45. package/dist/collections/operations/findVersionByID.d.ts +2 -1
  46. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  47. package/dist/collections/operations/findVersionByID.js +3 -1
  48. package/dist/collections/operations/findVersionByID.js.map +1 -1
  49. package/dist/collections/operations/findVersions.d.ts +2 -1
  50. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  51. package/dist/collections/operations/findVersions.js +3 -1
  52. package/dist/collections/operations/findVersions.js.map +1 -1
  53. package/dist/collections/operations/local/create.d.ts +5 -4
  54. package/dist/collections/operations/local/create.d.ts.map +1 -1
  55. package/dist/collections/operations/local/create.js +2 -1
  56. package/dist/collections/operations/local/create.js.map +1 -1
  57. package/dist/collections/operations/local/delete.d.ts +12 -11
  58. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  59. package/dist/collections/operations/local/delete.js +2 -1
  60. package/dist/collections/operations/local/delete.js.map +1 -1
  61. package/dist/collections/operations/local/duplicate.d.ts +5 -4
  62. package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
  63. package/dist/collections/operations/local/duplicate.js +2 -1
  64. package/dist/collections/operations/local/duplicate.js.map +1 -1
  65. package/dist/collections/operations/local/find.d.ts +5 -4
  66. package/dist/collections/operations/local/find.d.ts.map +1 -1
  67. package/dist/collections/operations/local/find.js +3 -1
  68. package/dist/collections/operations/local/find.js.map +1 -1
  69. package/dist/collections/operations/local/findByID.d.ts +7 -6
  70. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  71. package/dist/collections/operations/local/findByID.js +3 -2
  72. package/dist/collections/operations/local/findByID.js.map +1 -1
  73. package/dist/collections/operations/local/findVersionByID.d.ts +2 -1
  74. package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
  75. package/dist/collections/operations/local/findVersionByID.js +2 -1
  76. package/dist/collections/operations/local/findVersionByID.js.map +1 -1
  77. package/dist/collections/operations/local/findVersions.d.ts +2 -1
  78. package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
  79. package/dist/collections/operations/local/findVersions.js +2 -1
  80. package/dist/collections/operations/local/findVersions.js.map +1 -1
  81. package/dist/collections/operations/local/index.d.ts.map +1 -1
  82. package/dist/collections/operations/local/index.js +1 -1
  83. package/dist/collections/operations/local/index.js.map +1 -1
  84. package/dist/collections/operations/local/restoreVersion.d.ts +2 -1
  85. package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
  86. package/dist/collections/operations/local/restoreVersion.js +2 -1
  87. package/dist/collections/operations/local/restoreVersion.js.map +1 -1
  88. package/dist/collections/operations/local/update.d.ts +12 -11
  89. package/dist/collections/operations/local/update.d.ts.map +1 -1
  90. package/dist/collections/operations/local/update.js +2 -1
  91. package/dist/collections/operations/local/update.js.map +1 -1
  92. package/dist/collections/operations/restoreVersion.d.ts +2 -1
  93. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  94. package/dist/collections/operations/restoreVersion.js +4 -2
  95. package/dist/collections/operations/restoreVersion.js.map +1 -1
  96. package/dist/collections/operations/update.d.ts +4 -3
  97. package/dist/collections/operations/update.d.ts.map +1 -1
  98. package/dist/collections/operations/update.js +6 -3
  99. package/dist/collections/operations/update.js.map +1 -1
  100. package/dist/collections/operations/updateByID.d.ts +4 -3
  101. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  102. package/dist/collections/operations/updateByID.js +5 -2
  103. package/dist/collections/operations/updateByID.js.map +1 -1
  104. package/dist/collections/operations/utils.d.ts +8 -8
  105. package/dist/collections/operations/utils.d.ts.map +1 -1
  106. package/dist/collections/operations/utils.js.map +1 -1
  107. package/dist/config/client.d.ts +2 -2
  108. package/dist/config/client.d.ts.map +1 -1
  109. package/dist/config/client.js +1 -0
  110. package/dist/config/client.js.map +1 -1
  111. package/dist/config/defaults.d.ts.map +1 -1
  112. package/dist/config/defaults.js +8 -0
  113. package/dist/config/defaults.js.map +1 -1
  114. package/dist/config/sanitize.d.ts.map +1 -1
  115. package/dist/config/sanitize.js +21 -0
  116. package/dist/config/sanitize.js.map +1 -1
  117. package/dist/config/types.d.ts +6 -1
  118. package/dist/config/types.d.ts.map +1 -1
  119. package/dist/config/types.js.map +1 -1
  120. package/dist/database/types.d.ts +15 -1
  121. package/dist/database/types.d.ts.map +1 -1
  122. package/dist/database/types.js.map +1 -1
  123. package/dist/exports/shared.d.ts +1 -0
  124. package/dist/exports/shared.d.ts.map +1 -1
  125. package/dist/exports/shared.js +1 -0
  126. package/dist/exports/shared.js.map +1 -1
  127. package/dist/fields/config/types.d.ts +2 -0
  128. package/dist/fields/config/types.d.ts.map +1 -1
  129. package/dist/fields/config/types.js.map +1 -1
  130. package/dist/fields/hooks/afterRead/index.d.ts +2 -1
  131. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  132. package/dist/fields/hooks/afterRead/index.js +4 -1
  133. package/dist/fields/hooks/afterRead/index.js.map +1 -1
  134. package/dist/fields/hooks/afterRead/promise.d.ts +4 -2
  135. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  136. package/dist/fields/hooks/afterRead/promise.js +59 -1
  137. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  138. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
  139. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +1 -0
  140. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
  141. package/dist/fields/hooks/afterRead/traverseFields.d.ts +4 -2
  142. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  143. package/dist/fields/hooks/afterRead/traverseFields.js +3 -1
  144. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  145. package/dist/globals/config/types.d.ts +2 -1
  146. package/dist/globals/config/types.d.ts.map +1 -1
  147. package/dist/globals/config/types.js.map +1 -1
  148. package/dist/globals/operations/findOne.d.ts +2 -1
  149. package/dist/globals/operations/findOne.d.ts.map +1 -1
  150. package/dist/globals/operations/findOne.js +15 -2
  151. package/dist/globals/operations/findOne.js.map +1 -1
  152. package/dist/globals/operations/findVersionByID.d.ts +2 -1
  153. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  154. package/dist/globals/operations/findVersionByID.js +3 -1
  155. package/dist/globals/operations/findVersionByID.js.map +1 -1
  156. package/dist/globals/operations/findVersions.d.ts +2 -1
  157. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  158. package/dist/globals/operations/findVersions.js +7 -3
  159. package/dist/globals/operations/findVersions.js.map +1 -1
  160. package/dist/globals/operations/local/findOne.d.ts +5 -4
  161. package/dist/globals/operations/local/findOne.d.ts.map +1 -1
  162. package/dist/globals/operations/local/findOne.js +2 -1
  163. package/dist/globals/operations/local/findOne.js.map +1 -1
  164. package/dist/globals/operations/local/findVersionByID.d.ts +2 -1
  165. package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
  166. package/dist/globals/operations/local/findVersionByID.js +2 -1
  167. package/dist/globals/operations/local/findVersionByID.js.map +1 -1
  168. package/dist/globals/operations/local/findVersions.d.ts +2 -1
  169. package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
  170. package/dist/globals/operations/local/findVersions.js +3 -2
  171. package/dist/globals/operations/local/findVersions.js.map +1 -1
  172. package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
  173. package/dist/globals/operations/local/restoreVersion.js +1 -1
  174. package/dist/globals/operations/local/restoreVersion.js.map +1 -1
  175. package/dist/globals/operations/local/update.d.ts +5 -4
  176. package/dist/globals/operations/local/update.d.ts.map +1 -1
  177. package/dist/globals/operations/local/update.js +2 -1
  178. package/dist/globals/operations/local/update.js.map +1 -1
  179. package/dist/globals/operations/update.d.ts +4 -3
  180. package/dist/globals/operations/update.d.ts.map +1 -1
  181. package/dist/globals/operations/update.js +15 -2
  182. package/dist/globals/operations/update.js.map +1 -1
  183. package/dist/index.d.ts +61 -14
  184. package/dist/index.d.ts.map +1 -1
  185. package/dist/index.js +2 -0
  186. package/dist/index.js.map +1 -1
  187. package/dist/queues/config/generateJobsJSONSchemas.d.ts +18 -0
  188. package/dist/queues/config/generateJobsJSONSchemas.d.ts.map +1 -0
  189. package/dist/queues/config/generateJobsJSONSchemas.js +125 -0
  190. package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -0
  191. package/dist/queues/config/jobsCollection.d.ts +4 -0
  192. package/dist/queues/config/jobsCollection.d.ts.map +1 -0
  193. package/dist/queues/config/jobsCollection.js +211 -0
  194. package/dist/queues/config/jobsCollection.js.map +1 -0
  195. package/dist/queues/config/types/index.d.ts +45 -0
  196. package/dist/queues/config/types/index.d.ts.map +1 -0
  197. package/dist/queues/config/types/index.js +3 -0
  198. package/dist/queues/config/types/index.js.map +1 -0
  199. package/dist/queues/config/types/taskTypes.d.ts +134 -0
  200. package/dist/queues/config/types/taskTypes.d.ts.map +1 -0
  201. package/dist/queues/config/types/taskTypes.js +3 -0
  202. package/dist/queues/config/types/taskTypes.js.map +1 -0
  203. package/dist/queues/config/types/workflowJSONTypes.d.ts +29 -0
  204. package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -0
  205. package/dist/queues/config/types/workflowJSONTypes.js +3 -0
  206. package/dist/queues/config/types/workflowJSONTypes.js.map +1 -0
  207. package/dist/queues/config/types/workflowTypes.d.ts +98 -0
  208. package/dist/queues/config/types/workflowTypes.d.ts.map +1 -0
  209. package/dist/queues/config/types/workflowTypes.js +3 -0
  210. package/dist/queues/config/types/workflowTypes.js.map +1 -0
  211. package/dist/queues/localAPI.d.ts +23 -0
  212. package/dist/queues/localAPI.d.ts.map +1 -0
  213. package/dist/queues/localAPI.js +28 -0
  214. package/dist/queues/localAPI.js.map +1 -0
  215. package/dist/queues/operations/runJobs/index.d.ts +21 -0
  216. package/dist/queues/operations/runJobs/index.d.ts.map +1 -0
  217. package/dist/queues/operations/runJobs/index.js +180 -0
  218. package/dist/queues/operations/runJobs/index.js.map +1 -0
  219. package/dist/queues/operations/runJobs/runJSONJob/index.d.ts +18 -0
  220. package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -0
  221. package/dist/queues/operations/runJobs/runJSONJob/index.js +125 -0
  222. package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -0
  223. package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.d.ts +6 -0
  224. package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.d.ts.map +1 -0
  225. package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.js +26 -0
  226. package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.js.map +1 -0
  227. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts +26 -0
  228. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -0
  229. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +204 -0
  230. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -0
  231. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts +5 -0
  232. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -0
  233. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +18 -0
  234. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -0
  235. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.d.ts +17 -0
  236. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.d.ts.map +1 -0
  237. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.js +43 -0
  238. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.js.map +1 -0
  239. package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts +2 -0
  240. package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts.map +1 -0
  241. package/dist/queues/operations/runJobs/runJob/importHandlerPath.js +21 -0
  242. package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -0
  243. package/dist/queues/operations/runJobs/runJob/index.d.ts +17 -0
  244. package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -0
  245. package/dist/queues/operations/runJobs/runJob/index.js +48 -0
  246. package/dist/queues/operations/runJobs/runJob/index.js.map +1 -0
  247. package/dist/queues/restEndpointRun.d.ts +3 -0
  248. package/dist/queues/restEndpointRun.d.ts.map +1 -0
  249. package/dist/queues/restEndpointRun.js +66 -0
  250. package/dist/queues/restEndpointRun.js.map +1 -0
  251. package/dist/queues/utilities/getJobTaskStatus.d.ts +9 -0
  252. package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -0
  253. package/dist/queues/utilities/getJobTaskStatus.js +29 -0
  254. package/dist/queues/utilities/getJobTaskStatus.js.map +1 -0
  255. package/dist/types/index.d.ts +20 -2
  256. package/dist/types/index.d.ts.map +1 -1
  257. package/dist/types/index.js.map +1 -1
  258. package/dist/utilities/addSelectGenericsToGeneratedTyoes.spec.js +562 -0
  259. package/dist/utilities/addSelectGenericsToGeneratedTyoes.spec.js.map +1 -0
  260. package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts +4 -0
  261. package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -0
  262. package/dist/utilities/addSelectGenericsToGeneretedTypes.js +41 -0
  263. package/dist/utilities/addSelectGenericsToGeneretedTypes.js.map +1 -0
  264. package/dist/utilities/configToJSONSchema.d.ts +6 -1
  265. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  266. package/dist/utilities/configToJSONSchema.js +171 -15
  267. package/dist/utilities/configToJSONSchema.js.map +1 -1
  268. package/dist/utilities/getSelectMode.d.ts +3 -0
  269. package/dist/utilities/getSelectMode.d.ts.map +1 -0
  270. package/dist/utilities/getSelectMode.js +14 -0
  271. package/dist/utilities/getSelectMode.js.map +1 -0
  272. package/dist/utilities/traverseFields.d.ts.map +1 -1
  273. package/dist/utilities/traverseFields.js +51 -8
  274. package/dist/utilities/traverseFields.js.map +1 -1
  275. package/dist/versions/drafts/getQueryDraftsSelect.d.ts +5 -0
  276. package/dist/versions/drafts/getQueryDraftsSelect.d.ts.map +1 -0
  277. package/dist/versions/drafts/getQueryDraftsSelect.js +18 -0
  278. package/dist/versions/drafts/getQueryDraftsSelect.js.map +1 -0
  279. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts +3 -2
  280. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  281. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +11 -7
  282. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  283. package/dist/versions/saveVersion.d.ts +3 -2
  284. package/dist/versions/saveVersion.d.ts.map +1 -1
  285. package/dist/versions/saveVersion.js +5 -1
  286. package/dist/versions/saveVersion.js.map +1 -1
  287. package/package.json +3 -2
@@ -0,0 +1,211 @@
1
+ import { runJobsEndpoint } from '../restEndpointRun.js';
2
+ import { getJobTaskStatus } from '../utilities/getJobTaskStatus.js';
3
+ export const getDefaultJobsCollection = (config)=>{
4
+ if (!Array.isArray(config?.jobs?.workflows)) {
5
+ return null;
6
+ }
7
+ const workflowSlugs = new Set();
8
+ const taskSlugs = new Set([
9
+ 'inline'
10
+ ]);
11
+ const queueNames = new Set([
12
+ 'default'
13
+ ]);
14
+ config.jobs.workflows.forEach((workflow)=>{
15
+ workflowSlugs.add(workflow.slug);
16
+ if (workflow.queue) {
17
+ queueNames.add(workflow.queue);
18
+ }
19
+ });
20
+ config.jobs.tasks.forEach((task)=>{
21
+ if (workflowSlugs.has(task.slug)) {
22
+ throw new Error(`Task slug "${task.slug}" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.`);
23
+ }
24
+ taskSlugs.add(task.slug);
25
+ });
26
+ const jobsCollection = {
27
+ slug: 'payload-jobs',
28
+ admin: {
29
+ group: 'System',
30
+ hidden: true
31
+ },
32
+ endpoints: [
33
+ runJobsEndpoint
34
+ ],
35
+ fields: [
36
+ {
37
+ name: 'input',
38
+ type: 'json',
39
+ admin: {
40
+ description: 'Input data provided to the job'
41
+ }
42
+ },
43
+ {
44
+ name: 'taskStatus',
45
+ type: 'json',
46
+ virtual: true
47
+ },
48
+ {
49
+ type: 'tabs',
50
+ tabs: [
51
+ {
52
+ fields: [
53
+ {
54
+ name: 'completedAt',
55
+ type: 'date',
56
+ index: true
57
+ },
58
+ {
59
+ name: 'totalTried',
60
+ type: 'number',
61
+ defaultValue: 0,
62
+ index: true
63
+ },
64
+ {
65
+ name: 'hasError',
66
+ type: 'checkbox',
67
+ admin: {
68
+ description: 'If hasError is true this job will not be retried'
69
+ },
70
+ defaultValue: false,
71
+ index: true
72
+ },
73
+ {
74
+ name: 'error',
75
+ type: 'json',
76
+ admin: {
77
+ condition: (data)=>data.hasError,
78
+ description: 'If hasError is true, this is the error that caused it'
79
+ }
80
+ },
81
+ {
82
+ name: 'log',
83
+ type: 'array',
84
+ admin: {
85
+ description: 'Task execution log'
86
+ },
87
+ fields: [
88
+ {
89
+ name: 'executedAt',
90
+ type: 'date',
91
+ required: true
92
+ },
93
+ {
94
+ name: 'completedAt',
95
+ type: 'date',
96
+ required: true
97
+ },
98
+ {
99
+ name: 'taskSlug',
100
+ type: 'select',
101
+ options: [
102
+ ...taskSlugs
103
+ ],
104
+ required: true
105
+ },
106
+ {
107
+ name: 'taskID',
108
+ type: 'text',
109
+ required: true
110
+ },
111
+ {
112
+ name: 'input',
113
+ type: 'json'
114
+ },
115
+ {
116
+ name: 'output',
117
+ type: 'json'
118
+ },
119
+ {
120
+ name: 'state',
121
+ type: 'radio',
122
+ options: [
123
+ 'failed',
124
+ 'succeeded'
125
+ ],
126
+ required: true
127
+ },
128
+ {
129
+ name: 'error',
130
+ type: 'json',
131
+ admin: {
132
+ condition: (_, data)=>data.state === 'failed'
133
+ },
134
+ required: true
135
+ }
136
+ ]
137
+ }
138
+ ],
139
+ label: 'Status'
140
+ }
141
+ ]
142
+ },
143
+ {
144
+ name: 'workflowSlug',
145
+ type: 'select',
146
+ admin: {
147
+ position: 'sidebar'
148
+ },
149
+ index: true,
150
+ options: [
151
+ ...workflowSlugs
152
+ ],
153
+ required: false
154
+ },
155
+ {
156
+ name: 'taskSlug',
157
+ type: 'select',
158
+ admin: {
159
+ position: 'sidebar'
160
+ },
161
+ index: true,
162
+ options: [
163
+ ...taskSlugs
164
+ ],
165
+ required: false
166
+ },
167
+ {
168
+ name: 'queue',
169
+ type: 'select',
170
+ admin: {
171
+ position: 'sidebar'
172
+ },
173
+ defaultValue: 'default',
174
+ index: true,
175
+ options: [
176
+ ...queueNames
177
+ ]
178
+ },
179
+ {
180
+ name: 'waitUntil',
181
+ type: 'date',
182
+ index: true
183
+ },
184
+ {
185
+ name: 'processing',
186
+ type: 'checkbox',
187
+ admin: {
188
+ position: 'sidebar'
189
+ },
190
+ defaultValue: false,
191
+ index: true
192
+ }
193
+ ],
194
+ hooks: {
195
+ afterRead: [
196
+ ({ doc, req })=>{
197
+ // This hook is used to add the virtual `tasks` field to the document, that is computed from the `log` field
198
+ doc.taskStatus = getJobTaskStatus({
199
+ jobLog: doc.log,
200
+ tasksConfig: req.payload.config.jobs.tasks
201
+ });
202
+ return doc;
203
+ }
204
+ ]
205
+ },
206
+ lockDocuments: false
207
+ };
208
+ return jobsCollection;
209
+ };
210
+
211
+ //# sourceMappingURL=jobsCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/queues/config/jobsCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\n\nimport { runJobsEndpoint } from '../restEndpointRun.js'\nimport { getJobTaskStatus } from '../utilities/getJobTaskStatus.js'\n\nexport const getDefaultJobsCollection: (config: Config) => CollectionConfig | null = (config) => {\n if (!Array.isArray(config?.jobs?.workflows)) {\n return null\n }\n\n const workflowSlugs: Set<string> = new Set()\n const taskSlugs: Set<string> = new Set(['inline'])\n\n const queueNames: Set<string> = new Set(['default'])\n\n config.jobs.workflows.forEach((workflow) => {\n workflowSlugs.add(workflow.slug)\n\n if (workflow.queue) {\n queueNames.add(workflow.queue)\n }\n })\n\n config.jobs.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 taskSlugs.add(task.slug)\n })\n\n const jobsCollection: CollectionConfig = {\n slug: 'payload-jobs',\n admin: {\n group: 'System',\n hidden: true,\n },\n endpoints: [runJobsEndpoint],\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: [\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 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 ],\n label: 'Status',\n },\n ],\n },\n {\n name: 'workflowSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...workflowSlugs],\n required: false,\n },\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: 'select',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'default',\n index: true,\n options: [...queueNames],\n },\n {\n name: 'waitUntil',\n type: 'date',\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 ],\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 doc.taskStatus = getJobTaskStatus({\n jobLog: doc.log,\n tasksConfig: req.payload.config.jobs.tasks,\n })\n\n return doc\n },\n ],\n },\n lockDocuments: false,\n }\n return jobsCollection\n}\n"],"names":["runJobsEndpoint","getJobTaskStatus","getDefaultJobsCollection","config","Array","isArray","jobs","workflows","workflowSlugs","Set","taskSlugs","queueNames","forEach","workflow","add","slug","queue","tasks","task","has","Error","jobsCollection","admin","group","hidden","endpoints","fields","name","type","description","virtual","tabs","index","defaultValue","condition","data","hasError","required","options","_","state","label","position","hooks","afterRead","doc","req","taskStatus","jobLog","log","tasksConfig","payload","lockDocuments"],"mappings":"AAGA,SAASA,eAAe,QAAQ,wBAAuB;AACvD,SAASC,gBAAgB,QAAQ,mCAAkC;AAEnE,OAAO,MAAMC,2BAAwE,CAACC;IACpF,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQG,MAAMC,YAAY;QAC3C,OAAO;IACT;IAEA,MAAMC,gBAA6B,IAAIC;IACvC,MAAMC,YAAyB,IAAID,IAAI;QAAC;KAAS;IAEjD,MAAME,aAA0B,IAAIF,IAAI;QAAC;KAAU;IAEnDN,OAAOG,IAAI,CAACC,SAA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QACH;QACAO,eAAe;IACjB;IACA,OAAO/B;AACT,EAAC"}
@@ -0,0 +1,45 @@
1
+ import type { CollectionConfig } from '../../../index.js';
2
+ import type { PayloadRequest } from '../../../types/index.js';
3
+ import type { TaskConfig } from './taskTypes.js';
4
+ import type { WorkflowConfig } from './workflowTypes.js';
5
+ export type RunJobAccessArgs = {
6
+ req: PayloadRequest;
7
+ };
8
+ export type RunJobAccess = (args: RunJobAccessArgs) => boolean | Promise<boolean>;
9
+ export type JobsConfig = {
10
+ /**
11
+ * Specify access control to determine who can interact with jobs.
12
+ */
13
+ access?: {
14
+ /**
15
+ * By default, all logged-in users can trigger jobs.
16
+ */
17
+ run?: RunJobAccess;
18
+ };
19
+ /**
20
+ * Determine whether or not to delete a job after it has successfully completed.
21
+ */
22
+ deleteJobOnComplete?: boolean;
23
+ /**
24
+ * Specify depth for retrieving jobs from the queue.
25
+ * This should be as low as possible in order for job retrieval
26
+ * to be as efficient as possible. Defaults to 0.
27
+ */
28
+ depth?: number;
29
+ /**
30
+ * Override any settings on the default Jobs collection. Accepts the default collection and allows you to return
31
+ * a new collection.
32
+ */
33
+ jobsCollectionOverrides?: (args: {
34
+ defaultJobsCollection: CollectionConfig;
35
+ }) => CollectionConfig;
36
+ /**
37
+ * Define all possible tasks here
38
+ */
39
+ tasks: TaskConfig<any>[];
40
+ /**
41
+ * Define all the workflows here. Workflows orchestrate the flow of multiple tasks.
42
+ */
43
+ workflows: WorkflowConfig<any>[];
44
+ };
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,gBAAgB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAEjF,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,GAAG,CAAC,EAAE,YAAY,CAAA;KACnB,CAAA;IACD;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,qBAAqB,EAAE,gBAAgB,CAAA;KAAE,KAAK,gBAAgB,CAAA;IACjG;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAA;IACxB;;OAEG;IACH,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAA;CACjC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queues/config/types/index.ts"],"sourcesContent":["import type { CollectionConfig } from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\nimport type { TaskConfig } from './taskTypes.js'\nimport type { WorkflowConfig } from './workflowTypes.js'\n\nexport type RunJobAccessArgs = {\n req: PayloadRequest\n}\n\nexport type RunJobAccess = (args: RunJobAccessArgs) => boolean | Promise<boolean>\n\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 trigger jobs.\n */\n run?: RunJobAccess\n }\n /**\n * Determine whether or not to delete a job after it has successfully completed.\n */\n deleteJobOnComplete?: boolean\n /**\n * Specify depth for retrieving jobs from the queue.\n * This should be as low as possible in order for job retrieval\n * to be as efficient as possible. Defaults to 0.\n */\n depth?: number\n /**\n * Override any settings on the default Jobs collection. Accepts the default collection and allows you to return\n * a new collection.\n */\n jobsCollectionOverrides?: (args: { defaultJobsCollection: CollectionConfig }) => CollectionConfig\n /**\n * 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"],"names":[],"mappings":"AAWA,WAiCC"}
@@ -0,0 +1,134 @@
1
+ import type { Field, PayloadRequest, StringKeyOf, TypedJobs } from '../../../index.js';
2
+ import type { RunningJob, RunningJobSimple } from './workflowTypes.js';
3
+ export type TaskInputOutput = {
4
+ input: object;
5
+ output: object;
6
+ };
7
+ export type TaskHandlerResult<TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput> = {
8
+ output: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['output'] : TTaskSlugOrInputOutput extends TaskInputOutput ? TTaskSlugOrInputOutput['output'] : never;
9
+ state?: 'failed' | 'succeeded';
10
+ };
11
+ export type TaskHandlerArgs<TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput, TWorkflowSlug extends keyof TypedJobs['workflows'] = string> = {
12
+ input: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['input'] : TTaskSlugOrInputOutput extends TaskInputOutput ? TTaskSlugOrInputOutput['input'] : never;
13
+ job: RunningJob<TWorkflowSlug>;
14
+ req: PayloadRequest;
15
+ };
16
+ /**
17
+ * Inline tasks in JSON workflows have no input, as they can just get the input from job.taskStatus
18
+ */
19
+ export type TaskHandlerArgsNoInput<TWorkflowInput extends object> = {
20
+ job: RunningJobSimple<TWorkflowInput>;
21
+ req: PayloadRequest;
22
+ };
23
+ export type TaskHandler<TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput, TWorkflowSlug extends keyof TypedJobs['workflows'] = string> = (args: TaskHandlerArgs<TTaskSlugOrInputOutput, TWorkflowSlug>) => Promise<TaskHandlerResult<TTaskSlugOrInputOutput>> | TaskHandlerResult<TTaskSlugOrInputOutput>;
24
+ export type TaskType = StringKeyOf<TypedJobs['tasks']>;
25
+ export type TaskInput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['input'];
26
+ export type TaskOutput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['output'];
27
+ export type TaskHandlerResults = {
28
+ [TTaskSlug in keyof TypedJobs['tasks']]: {
29
+ [id: string]: TaskHandlerResult<TTaskSlug>;
30
+ };
31
+ };
32
+ export type RunTaskFunctionArgs<TTaskSlug extends keyof TypedJobs['tasks']> = {
33
+ input?: TaskInput<TTaskSlug>;
34
+ retries?: number | RetryConfig;
35
+ };
36
+ export type RunTaskFunction<TTaskSlug extends keyof TypedJobs['tasks']> = (taskID: string, taskArgs?: RunTaskFunctionArgs<TTaskSlug>) => Promise<TaskOutput<TTaskSlug>>;
37
+ export type RunTaskFunctions = {
38
+ [TTaskSlug in keyof TypedJobs['tasks']]: RunTaskFunction<TTaskSlug>;
39
+ };
40
+ export type RunInlineTaskFunction = <TTaskInput extends object, TTaskOutput extends object>(taskID: string, taskArgs: {
41
+ input?: TTaskInput;
42
+ retries?: number | RetryConfig;
43
+ task: (args: {
44
+ input: TTaskInput;
45
+ job: RunningJob<any>;
46
+ req: PayloadRequest;
47
+ }) => {
48
+ output: TTaskOutput;
49
+ state?: 'failed' | 'succeeded';
50
+ } | Promise<{
51
+ output: TTaskOutput;
52
+ state?: 'failed' | 'succeeded';
53
+ }>;
54
+ }) => Promise<TTaskOutput>;
55
+ export type RetryConfig = {
56
+ attempts: number;
57
+ /**
58
+ * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.
59
+ *
60
+ * If this is set on a single task, the longest backoff time of a task will determine the time until the entire workflow is retried.
61
+ */
62
+ backoff?: {
63
+ /**
64
+ * Base delay between running jobs in ms
65
+ */
66
+ delay?: number;
67
+ /**
68
+ * @default fixed
69
+ *
70
+ * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.
71
+ * If fixed (default) is used, the delay will be the same between each retry.
72
+ *
73
+ * If exponential is used, the delay will increase exponentially with each retry.
74
+ *
75
+ * @example
76
+ * delay = 1000
77
+ * attempts = 3
78
+ * type = 'fixed'
79
+ *
80
+ * The task will be retried 3 times with a delay of 1000ms between each retry.
81
+ *
82
+ * @example
83
+ * delay = 1000
84
+ * attempts = 3
85
+ * type = 'exponential'
86
+ *
87
+ * The task will be retried 3 times with a delay of 1000ms, 2000ms, and 4000ms between each retry.
88
+ */
89
+ type: 'exponential' | 'fixed';
90
+ };
91
+ };
92
+ export type TaskConfig<TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput = TaskType> = {
93
+ /**
94
+ * The function that should be responsible for running the job.
95
+ * You can either pass a string-based path to the job function file, or the job function itself.
96
+ *
97
+ * If you are using large dependencies within your job, you might prefer to pass the string path
98
+ * because that will avoid bundling large dependencies in your Next.js app.
99
+ */
100
+ handler: string | TaskHandler<TTaskSlugOrInputOutput>;
101
+ /**
102
+ * Define the input field schema - payload will generate a type for this schema.
103
+ */
104
+ inputSchema?: Field[];
105
+ /**
106
+ * You can use interfaceName to change the name of the interface that is generated for this task. By default, this is "Task" + the capitalized task slug.
107
+ */
108
+ interfaceName?: string;
109
+ /**
110
+ * Define a human-friendly label for this task.
111
+ */
112
+ label?: string;
113
+ /**
114
+ * Function to be executed if the task fails.
115
+ */
116
+ onFail?: () => Promise<void> | void;
117
+ /**
118
+ * Function to be executed if the task succeeds.
119
+ */
120
+ onSuccess?: () => Promise<void> | void;
121
+ /**
122
+ * Define the output field schema - payload will generate a type for this schema.
123
+ */
124
+ outputSchema?: Field[];
125
+ /**
126
+ * Specify the number of times that this step should be retried if it fails.
127
+ */
128
+ retries?: number | RetryConfig;
129
+ /**
130
+ * Define a slug-based name for this job. This slug needs to be unique among both tasks and workflows.
131
+ */
132
+ slug: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TTaskSlugOrInputOutput : string;
133
+ };
134
+ //# sourceMappingURL=taskTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskTypes.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/taskTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAEtE,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AACD,MAAM,MAAM,iBAAiB,CAC3B,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,IACvE;IACF,MAAM,EAAE,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAC3D,SAAS,CAAC,OAAO,CAAC,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,GACpD,sBAAsB,SAAS,eAAe,GAC5C,sBAAsB,CAAC,QAAQ,CAAC,GAChC,KAAK,CAAA;IACX,KAAK,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,eAAe,CACzB,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,EACzE,aAAa,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,IACzD;IACF,KAAK,EAAE,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAC1D,SAAS,CAAC,OAAO,CAAC,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,GACnD,sBAAsB,SAAS,eAAe,GAC5C,s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,IAAI,EAAE,aAAa,GAAG,OAAO,CAAA;KAC9B,CAAA;CACF,CAAA;AAED,MAAM,MAAM,UAAU,CACpB,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,QAAQ,IAClF;IACF;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAA;IACrD;;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;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACtC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAC9B;;OAEG;IACH,IAAI,EAAE,sBAAsB,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,sBAAsB,GAAG,MAAM,CAAA;CAChG,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=taskTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queues/config/types/taskTypes.ts"],"sourcesContent":["import type { Field, PayloadRequest, StringKeyOf, TypedJobs } from '../../../index.js'\nimport type { RunningJob, RunningJobSimple } from './workflowTypes.js'\n\nexport type TaskInputOutput = {\n input: object\n output: object\n}\nexport type TaskHandlerResult<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n> = {\n output: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['output']\n : TTaskSlugOrInputOutput extends TaskInputOutput // Check if it's actually TaskInputOutput type\n ? TTaskSlugOrInputOutput['output']\n : never\n state?: 'failed' | 'succeeded'\n}\n\nexport type TaskHandlerArgs<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n TWorkflowSlug extends keyof TypedJobs['workflows'] = string,\n> = {\n input: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks']\n ? TypedJobs['tasks'][TTaskSlugOrInputOutput]['input']\n : TTaskSlugOrInputOutput extends TaskInputOutput // Check if it's actually TaskInputOutput type\n ? TTaskSlugOrInputOutput['input']\n : never\n job: RunningJob<TWorkflowSlug>\n req: PayloadRequest\n}\n\n/**\n * Inline tasks in JSON workflows have no input, as they can just get the input from job.taskStatus\n */\nexport type TaskHandlerArgsNoInput<TWorkflowInput extends object> = {\n job: RunningJobSimple<TWorkflowInput>\n req: PayloadRequest\n}\n\nexport type TaskHandler<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput,\n TWorkflowSlug extends keyof TypedJobs['workflows'] = string,\n> = (\n args: TaskHandlerArgs<TTaskSlugOrInputOutput, TWorkflowSlug>,\n) => Promise<TaskHandlerResult<TTaskSlugOrInputOutput>> | TaskHandlerResult<TTaskSlugOrInputOutput>\n\nexport type TaskType = StringKeyOf<TypedJobs['tasks']>\n\n// Extracts the type of `input` corresponding to each task\nexport type TaskInput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['input']\n\nexport type TaskOutput<T extends keyof TypedJobs['tasks']> = TypedJobs['tasks'][T]['output']\n\nexport type TaskHandlerResults = {\n [TTaskSlug in keyof TypedJobs['tasks']]: {\n [id: string]: TaskHandlerResult<TTaskSlug>\n }\n}\n\n// Helper type to create correct argument type for the function corresponding to each task.\nexport type RunTaskFunctionArgs<TTaskSlug extends keyof TypedJobs['tasks']> = {\n input?: TaskInput<TTaskSlug>\n retries?: number | RetryConfig\n}\n\nexport type RunTaskFunction<TTaskSlug extends keyof TypedJobs['tasks']> = (\n taskID: string,\n taskArgs?: RunTaskFunctionArgs<TTaskSlug>,\n) => Promise<TaskOutput<TTaskSlug>>\n\nexport type RunTaskFunctions = {\n [TTaskSlug in keyof TypedJobs['tasks']]: RunTaskFunction<TTaskSlug>\n}\n\nexport type RunInlineTaskFunction = <TTaskInput extends object, TTaskOutput extends object>(\n taskID: string,\n taskArgs: {\n input?: TTaskInput\n retries?: number | RetryConfig\n // This is the same as TaskHandler, but typed out explicitly in order to improve type inference\n task: (args: { input: TTaskInput; job: RunningJob<any>; req: PayloadRequest }) =>\n | {\n output: TTaskOutput\n state?: 'failed' | 'succeeded'\n }\n | Promise<{ output: TTaskOutput; state?: 'failed' | 'succeeded' }>\n },\n) => Promise<TTaskOutput>\n\nexport type RetryConfig = {\n attempts: number\n /**\n * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.\n *\n * If this is set on a single task, the longest backoff time of a task will determine the time until the entire workflow is retried.\n */\n backoff?: {\n /**\n * Base delay between running jobs in ms\n */\n delay?: number\n /**\n * @default fixed\n *\n * The backoff strategy to use when retrying the task. This determines how long to wait before retrying the task.\n * If fixed (default) is used, the delay will be the same between each retry.\n *\n * If exponential is used, the delay will increase exponentially with each retry.\n *\n * @example\n * delay = 1000\n * attempts = 3\n * type = 'fixed'\n *\n * The task will be retried 3 times with a delay of 1000ms between each retry.\n *\n * @example\n * delay = 1000\n * attempts = 3\n * type = 'exponential'\n *\n * The task will be retried 3 times with a delay of 1000ms, 2000ms, and 4000ms between each retry.\n */\n type: 'exponential' | 'fixed'\n }\n}\n\nexport type TaskConfig<\n TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] | TaskInputOutput = TaskType,\n> = {\n /**\n * The function that should be responsible for running the job.\n * You can either pass a string-based path to the job function file, or the job function itself.\n *\n * If you are using large dependencies within your job, you might prefer to pass the string path\n * because that will avoid bundling large dependencies in your Next.js app.\n */\n handler: string | TaskHandler<TTaskSlugOrInputOutput>\n /**\n * Define the input field schema - payload will generate a type for this schema.\n */\n inputSchema?: Field[]\n /**\n * You can use interfaceName to change the name of the interface that is generated for this task. By default, this is \"Task\" + the capitalized task slug.\n */\n interfaceName?: string\n /**\n * Define a human-friendly label for this task.\n */\n label?: string\n /**\n * Function to be executed if the task fails.\n */\n onFail?: () => Promise<void> | void\n /**\n * Function to be executed if the task succeeds.\n */\n onSuccess?: () => Promise<void> | void\n /**\n * Define the output field schema - payload will generate a type for this schema.\n */\n outputSchema?: Field[]\n /**\n * Specify the number of times that this step should be retried if it fails.\n */\n retries?: number | RetryConfig\n /**\n * Define a slug-based name for this job. This slug needs to be unique among both tasks and workflows.\n */\n slug: TTaskSlugOrInputOutput extends keyof TypedJobs['tasks'] ? TTaskSlugOrInputOutput : string\n}\n"],"names":[],"mappings":"AA+HA,WA2CC"}
@@ -0,0 +1,29 @@
1
+ import type { RunningJob, TaskHandlerResult, TypedJobs } from '../../../index.js';
2
+ import type { RetryConfig, TaskHandlerArgsNoInput } from './taskTypes.js';
3
+ export type WorkflowStep<TTaskSlug extends keyof TypedJobs['tasks'], TWorkflowSlug extends keyof TypedJobs['workflows']> = {
4
+ /**
5
+ * If this step is completed, the workflow will be marked as completed
6
+ */
7
+ completesJob?: boolean;
8
+ condition?: (args: {
9
+ job: RunningJob<TWorkflowSlug>;
10
+ }) => boolean;
11
+ /**
12
+ * Each task needs to have a unique ID to track its status
13
+ */
14
+ id: string;
15
+ retries?: number | RetryConfig;
16
+ } & ({
17
+ inlineTask?: (args: TaskHandlerArgsNoInput<TypedJobs['workflows'][TWorkflowSlug]['input']>) => Promise<TaskHandlerResult<TTaskSlug>> | TaskHandlerResult<TTaskSlug>;
18
+ } | {
19
+ input: (args: {
20
+ job: RunningJob<TWorkflowSlug>;
21
+ }) => TypedJobs['tasks'][TTaskSlug]['input'];
22
+ task: TTaskSlug;
23
+ });
24
+ type AllWorkflowSteps<TWorkflowSlug extends keyof TypedJobs['workflows']> = {
25
+ [TTaskSlug in keyof TypedJobs['tasks']]: WorkflowStep<TTaskSlug, TWorkflowSlug>;
26
+ }[keyof TypedJobs['tasks']];
27
+ export type WorkflowJSON<TWorkflowSlug extends keyof TypedJobs['workflows']> = Array<AllWorkflowSteps<TWorkflowSlug>>;
28
+ export {};
29
+ //# sourceMappingURL=workflowJSONTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowJSONTypes.d.ts","sourceRoot":"","sources":["../../../../src/queues/config/types/workflowJSONTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAEzE,MAAM,MAAM,YAAY,CACtB,SAAS,SAAS,MAAM,SAAS,CAAC,OAAO,CAAC,EAC1C,aAAa,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,IAChD;IACF;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;KAAE,KAAK,OAAO,CAAA;IACjE;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;CAC/B,GAAG,CACA;IACE,UAAU,CAAC,EAAE,CACX,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,KACzE,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;CAC1E,GACD;IACE,KAAK,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;KAAE,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAA;IAC3F,IAAI,EAAE,SAAS,CAAA;CAChB,CACJ,CAAA;AAED,KAAK,gBAAgB,CAAC,aAAa,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,IAAI;KACzE,SAAS,IAAI,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,SAAS,EAAE,aAAa,CAAC;CAChF,CAAC,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;AAE3B,MAAM,MAAM,YAAY,CAAC,aAAa,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,IAAI,KAAK,CAClF,gBAAgB,CAAC,aAAa,CAAC,CAChC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=workflowJSONTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queues/config/types/workflowJSONTypes.ts"],"sourcesContent":["import type { RunningJob, TaskHandlerResult, TypedJobs } from '../../../index.js'\nimport type { RetryConfig, TaskHandlerArgsNoInput } from './taskTypes.js'\n\nexport type WorkflowStep<\n TTaskSlug extends keyof TypedJobs['tasks'],\n TWorkflowSlug extends keyof TypedJobs['workflows'],\n> = {\n /**\n * If this step is completed, the workflow will be marked as completed\n */\n completesJob?: boolean\n condition?: (args: { job: RunningJob<TWorkflowSlug> }) => boolean\n /**\n * Each task needs to have a unique ID to track its status\n */\n id: string\n retries?: number | RetryConfig\n} & (\n | {\n inlineTask?: (\n args: TaskHandlerArgsNoInput<TypedJobs['workflows'][TWorkflowSlug]['input']>,\n ) => Promise<TaskHandlerResult<TTaskSlug>> | TaskHandlerResult<TTaskSlug>\n }\n | {\n input: (args: { job: RunningJob<TWorkflowSlug> }) => TypedJobs['tasks'][TTaskSlug]['input']\n task: TTaskSlug\n }\n)\n\ntype AllWorkflowSteps<TWorkflowSlug extends keyof TypedJobs['workflows']> = {\n [TTaskSlug in keyof TypedJobs['tasks']]: WorkflowStep<TTaskSlug, TWorkflowSlug>\n}[keyof TypedJobs['tasks']]\n\nexport type WorkflowJSON<TWorkflowSlug extends keyof TypedJobs['workflows']> = Array<\n AllWorkflowSteps<TWorkflowSlug>\n>\n"],"names":[],"mappings":"AAiCA,WAEC"}
@@ -0,0 +1,98 @@
1
+ import type { Field } from '../../../fields/config/types.js';
2
+ import type { PayloadRequest, StringKeyOf, TypedCollection, TypedJobs } from '../../../index.js';
3
+ import type { RetryConfig, RunInlineTaskFunction, RunTaskFunctions, TaskInput, TaskOutput, TaskType } from './taskTypes.js';
4
+ import type { WorkflowJSON } from './workflowJSONTypes.js';
5
+ export type JobLog = {
6
+ completedAt: string;
7
+ error?: unknown;
8
+ executedAt: string;
9
+ input?: any;
10
+ output?: any;
11
+ state: 'failed' | 'succeeded';
12
+ taskID: string;
13
+ taskSlug: string;
14
+ };
15
+ export type BaseJob = {
16
+ completedAt?: string;
17
+ error?: unknown;
18
+ hasError?: boolean;
19
+ id: number | string;
20
+ input?: any;
21
+ log: JobLog[];
22
+ processing?: boolean;
23
+ queue: string;
24
+ taskSlug?: string;
25
+ taskStatus?: JobTaskStatus;
26
+ totalTried: number;
27
+ waitUntil?: string;
28
+ workflowSlug?: string;
29
+ };
30
+ export type WorkflowTypes = StringKeyOf<TypedJobs['workflows']>;
31
+ export type RunningJob<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = {
32
+ input: TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TypedJobs['workflows'][TWorkflowSlugOrInput]['input'] : TWorkflowSlugOrInput;
33
+ taskStatus: JobTaskStatus;
34
+ } & Omit<TypedCollection['payload-jobs'], 'input' | 'taskStatus'>;
35
+ export type RunningJobSimple<TWorkflowInput extends object> = {
36
+ input: TWorkflowInput;
37
+ } & TypedCollection['payload-jobs'];
38
+ export type RunningJobFromTask<TTaskSlug extends keyof TypedJobs['tasks']> = {
39
+ input: TypedJobs['tasks'][TTaskSlug]['input'];
40
+ } & TypedCollection['payload-jobs'];
41
+ export type WorkflowHandler<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = (args: {
42
+ inlineTask: RunInlineTaskFunction;
43
+ job: RunningJob<TWorkflowSlugOrInput>;
44
+ req: PayloadRequest;
45
+ tasks: RunTaskFunctions;
46
+ }) => Promise<void>;
47
+ export type SingleTaskStatus<T extends keyof TypedJobs['tasks']> = {
48
+ complete: boolean;
49
+ input: TaskInput<T>;
50
+ output: TaskOutput<T>;
51
+ taskSlug: TaskType;
52
+ totalTried: number;
53
+ };
54
+ /**
55
+ * Task IDs mapped to their status
56
+ */
57
+ export type JobTaskStatus = {
58
+ [taskSlug in TaskType]: {
59
+ [taskID: string]: SingleTaskStatus<taskSlug>;
60
+ };
61
+ };
62
+ export type WorkflowConfig<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = {
63
+ /**
64
+ * You can either pass a string-based path to the workflow function file, or the workflow function itself.
65
+ *
66
+ * If you are using large dependencies within your workflow control flow, you might prefer to pass the string path
67
+ * because that will avoid bundling large dependencies in your Next.js app.
68
+ *
69
+ *
70
+ */
71
+ handler: string | WorkflowHandler<TWorkflowSlugOrInput> | WorkflowJSON<TWorkflowSlugOrInput extends object ? string : TWorkflowSlugOrInput>;
72
+ /**
73
+ * Define the input field schema - payload will generate a type for this schema.
74
+ */
75
+ inputSchema?: Field[];
76
+ /**
77
+ * 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.
78
+ */
79
+ interfaceName?: string;
80
+ /**
81
+ * Define a human-friendly label for this workflow.
82
+ */
83
+ label?: string;
84
+ /**
85
+ * Optionally, define the queue name that this workflow should be tied to.
86
+ * Defaults to "default".
87
+ */
88
+ queue?: string;
89
+ /**
90
+ * Specify the number of times that this workflow should be retried if it fails for any reason.
91
+ */
92
+ retries?: number | RetryConfig;
93
+ /**
94
+ * Define a slug-based name for this job.
95
+ */
96
+ slug: TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TWorkflowSlugOrInput : string;
97
+ };
98
+ //# sourceMappingURL=workflowTypes.d.ts.map
@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AAC,CAAC,CAAC,CAAA;IACnB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;IACrB,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;KAEzB,QAAQ,IAAI,QAAQ,GAAG;QACtB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;KAC7C;CACF,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,oBAAoB,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI;IAC/F;;;;;;;OAOG;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;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAC9B;;OAEG;IACH,IAAI,EAAE,oBAAoB,SAAS,MAAM,SAAS,CAAC,WAAW,CAAC,GAAG,oBAAoB,GAAG,MAAM,CAAA;CAChG,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=workflowTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/queues/config/types/workflowTypes.ts"],"sourcesContent":["import type { Field } from '../../../fields/config/types.js'\nimport type { PayloadRequest, StringKeyOf, TypedCollection, TypedJobs } 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 input?: any\n output?: any\n state: 'failed' | 'succeeded'\n taskID: string\n taskSlug: string\n}\n\nexport type BaseJob = {\n completedAt?: string\n error?: unknown\n hasError?: boolean\n id: number | string\n input?: any\n log: JobLog[]\n processing?: boolean\n queue: string\n taskSlug?: string\n taskStatus?: JobTaskStatus\n totalTried: number\n waitUntil?: string\n workflowSlug?: string\n}\n\nexport type WorkflowTypes = StringKeyOf<TypedJobs['workflows']>\n\n// TODO: Type job.taskStatus once available - for JSON-defined workflows\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\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<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> =\n (args: {\n inlineTask: RunInlineTaskFunction\n job: RunningJob<TWorkflowSlugOrInput>\n req: PayloadRequest\n tasks: RunTaskFunctions\n }) => Promise<void>\n\nexport type SingleTaskStatus<T extends keyof TypedJobs['tasks']> = {\n complete: boolean\n input: TaskInput<T>\n output: TaskOutput<T>\n taskSlug: TaskType\n totalTried: number\n}\n\n/**\n * Task IDs mapped to their status\n */\nexport type JobTaskStatus = {\n // Wrap in taskSlug to improve typing\n [taskSlug in TaskType]: {\n [taskID: string]: SingleTaskStatus<taskSlug>\n }\n}\n\nexport type WorkflowConfig<TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] | object> = {\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.\n *\n *\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 queue name that this workflow should be tied to.\n * Defaults to \"default\".\n */\n queue?: string\n /**\n * Specify the number of times that this workflow should be retried if it fails for any reason.\n */\n retries?: number | RetryConfig\n /**\n * Define a slug-based name for this job.\n */\n slug: TWorkflowSlugOrInput extends keyof TypedJobs['workflows'] ? TWorkflowSlugOrInput : string\n}\n\ntype AllWorkflowConfigs = {\n [TWorkflowSlug in keyof TypedJobs['workflows']]: WorkflowConfig<TWorkflowSlug>\n}[keyof TypedJobs['workflows']]\n"],"names":[],"mappings":"AAoFA,WAsCC"}