@zudojs/queue 0.0.1

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 (211) hide show
  1. package/README.md +46 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/deadLetter/deadLetter.core.d.ts +13 -0
  4. package/dist/deadLetter/deadLetter.core.d.ts.map +1 -0
  5. package/dist/deadLetter/deadLetter.core.js +41 -0
  6. package/dist/deadLetter/deadLetter.core.js.map +1 -0
  7. package/dist/deadLetter/deadLetter.type.d.ts +33 -0
  8. package/dist/deadLetter/deadLetter.type.d.ts.map +1 -0
  9. package/dist/deadLetter/deadLetter.type.js +2 -0
  10. package/dist/deadLetter/deadLetter.type.js.map +1 -0
  11. package/dist/deadLetter/index.d.ts +9 -0
  12. package/dist/deadLetter/index.d.ts.map +1 -0
  13. package/dist/deadLetter/index.js +8 -0
  14. package/dist/deadLetter/index.js.map +1 -0
  15. package/dist/inMemoryQueue/inMemoryQueue.core.d.ts +48 -0
  16. package/dist/inMemoryQueue/inMemoryQueue.core.d.ts.map +1 -0
  17. package/dist/inMemoryQueue/inMemoryQueue.core.js +230 -0
  18. package/dist/inMemoryQueue/inMemoryQueue.core.js.map +1 -0
  19. package/dist/inMemoryQueue/inMemoryQueue.factory.d.ts +7 -0
  20. package/dist/inMemoryQueue/inMemoryQueue.factory.d.ts.map +1 -0
  21. package/dist/inMemoryQueue/inMemoryQueue.factory.js +8 -0
  22. package/dist/inMemoryQueue/inMemoryQueue.factory.js.map +1 -0
  23. package/dist/inMemoryQueue/inMemoryQueue.processing.d.ts +19 -0
  24. package/dist/inMemoryQueue/inMemoryQueue.processing.d.ts.map +1 -0
  25. package/dist/inMemoryQueue/inMemoryQueue.processing.js +112 -0
  26. package/dist/inMemoryQueue/inMemoryQueue.processing.js.map +1 -0
  27. package/dist/inMemoryQueue/inMemoryQueue.scheduling.d.ts +10 -0
  28. package/dist/inMemoryQueue/inMemoryQueue.scheduling.d.ts.map +1 -0
  29. package/dist/inMemoryQueue/inMemoryQueue.scheduling.js +38 -0
  30. package/dist/inMemoryQueue/inMemoryQueue.scheduling.js.map +1 -0
  31. package/dist/inMemoryQueue/index.d.ts +8 -0
  32. package/dist/inMemoryQueue/index.d.ts.map +1 -0
  33. package/dist/inMemoryQueue/index.js +8 -0
  34. package/dist/inMemoryQueue/index.js.map +1 -0
  35. package/dist/index.d.ts +27 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +44 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/job/index.d.ts +9 -0
  40. package/dist/job/index.d.ts.map +1 -0
  41. package/dist/job/index.js +8 -0
  42. package/dist/job/index.js.map +1 -0
  43. package/dist/job/job.core.d.ts +19 -0
  44. package/dist/job/job.core.d.ts.map +1 -0
  45. package/dist/job/job.core.js +74 -0
  46. package/dist/job/job.core.js.map +1 -0
  47. package/dist/job/job.type.d.ts +65 -0
  48. package/dist/job/job.type.d.ts.map +1 -0
  49. package/dist/job/job.type.js +2 -0
  50. package/dist/job/job.type.js.map +1 -0
  51. package/dist/jobContext/index.d.ts +8 -0
  52. package/dist/jobContext/index.d.ts.map +1 -0
  53. package/dist/jobContext/index.js +7 -0
  54. package/dist/jobContext/index.js.map +1 -0
  55. package/dist/jobContext/jobContext.core.d.ts +17 -0
  56. package/dist/jobContext/jobContext.core.d.ts.map +1 -0
  57. package/dist/jobContext/jobContext.core.js +36 -0
  58. package/dist/jobContext/jobContext.core.js.map +1 -0
  59. package/dist/jobContext/jobContext.type.d.ts +16 -0
  60. package/dist/jobContext/jobContext.type.d.ts.map +1 -0
  61. package/dist/jobContext/jobContext.type.js +2 -0
  62. package/dist/jobContext/jobContext.type.js.map +1 -0
  63. package/dist/jobOptions/index.d.ts +8 -0
  64. package/dist/jobOptions/index.d.ts.map +1 -0
  65. package/dist/jobOptions/index.js +7 -0
  66. package/dist/jobOptions/index.js.map +1 -0
  67. package/dist/jobOptions/jobOptions.core.d.ts +10 -0
  68. package/dist/jobOptions/jobOptions.core.d.ts.map +1 -0
  69. package/dist/jobOptions/jobOptions.core.js +23 -0
  70. package/dist/jobOptions/jobOptions.core.js.map +1 -0
  71. package/dist/jobOptions/jobOptions.type.d.ts +36 -0
  72. package/dist/jobOptions/jobOptions.type.d.ts.map +1 -0
  73. package/dist/jobOptions/jobOptions.type.js +2 -0
  74. package/dist/jobOptions/jobOptions.type.js.map +1 -0
  75. package/dist/jobResult/index.d.ts +8 -0
  76. package/dist/jobResult/index.d.ts.map +1 -0
  77. package/dist/jobResult/index.js +7 -0
  78. package/dist/jobResult/index.js.map +1 -0
  79. package/dist/jobResult/jobResult.core.d.ts +19 -0
  80. package/dist/jobResult/jobResult.core.d.ts.map +1 -0
  81. package/dist/jobResult/jobResult.core.js +36 -0
  82. package/dist/jobResult/jobResult.core.js.map +1 -0
  83. package/dist/jobResult/jobResult.type.d.ts +34 -0
  84. package/dist/jobResult/jobResult.type.d.ts.map +1 -0
  85. package/dist/jobResult/jobResult.type.js +2 -0
  86. package/dist/jobResult/jobResult.type.js.map +1 -0
  87. package/dist/jobTypes/index.d.ts +9 -0
  88. package/dist/jobTypes/index.d.ts.map +1 -0
  89. package/dist/jobTypes/index.js +8 -0
  90. package/dist/jobTypes/index.js.map +1 -0
  91. package/dist/jobTypes/jobTypes.type.d.ts +89 -0
  92. package/dist/jobTypes/jobTypes.type.d.ts.map +1 -0
  93. package/dist/jobTypes/jobTypes.type.js +81 -0
  94. package/dist/jobTypes/jobTypes.type.js.map +1 -0
  95. package/dist/middleware/index.d.ts +8 -0
  96. package/dist/middleware/index.d.ts.map +1 -0
  97. package/dist/middleware/index.js +7 -0
  98. package/dist/middleware/index.js.map +1 -0
  99. package/dist/middleware/middleware.core.d.ts +16 -0
  100. package/dist/middleware/middleware.core.d.ts.map +1 -0
  101. package/dist/middleware/middleware.core.js +76 -0
  102. package/dist/middleware/middleware.core.js.map +1 -0
  103. package/dist/middleware/middleware.type.d.ts +19 -0
  104. package/dist/middleware/middleware.type.d.ts.map +1 -0
  105. package/dist/middleware/middleware.type.js +2 -0
  106. package/dist/middleware/middleware.type.js.map +1 -0
  107. package/dist/processor/index.d.ts +10 -0
  108. package/dist/processor/index.d.ts.map +1 -0
  109. package/dist/processor/index.js +9 -0
  110. package/dist/processor/index.js.map +1 -0
  111. package/dist/processor/processor.core.d.ts +6 -0
  112. package/dist/processor/processor.core.d.ts.map +1 -0
  113. package/dist/processor/processor.core.js +40 -0
  114. package/dist/processor/processor.core.js.map +1 -0
  115. package/dist/processor/processor.type.d.ts +42 -0
  116. package/dist/processor/processor.type.d.ts.map +1 -0
  117. package/dist/processor/processor.type.js +7 -0
  118. package/dist/processor/processor.type.js.map +1 -0
  119. package/dist/queue/index.d.ts +10 -0
  120. package/dist/queue/index.d.ts.map +1 -0
  121. package/dist/queue/index.js +8 -0
  122. package/dist/queue/index.js.map +1 -0
  123. package/dist/queue/queue.core.d.ts +13 -0
  124. package/dist/queue/queue.core.d.ts.map +1 -0
  125. package/dist/queue/queue.core.js +23 -0
  126. package/dist/queue/queue.core.js.map +1 -0
  127. package/dist/queue/queue.type.d.ts +109 -0
  128. package/dist/queue/queue.type.d.ts.map +1 -0
  129. package/dist/queue/queue.type.js +2 -0
  130. package/dist/queue/queue.type.js.map +1 -0
  131. package/dist/queueEmitter/index.d.ts +9 -0
  132. package/dist/queueEmitter/index.d.ts.map +1 -0
  133. package/dist/queueEmitter/index.js +8 -0
  134. package/dist/queueEmitter/index.js.map +1 -0
  135. package/dist/queueEmitter/queueEmitter.core.d.ts +24 -0
  136. package/dist/queueEmitter/queueEmitter.core.d.ts.map +1 -0
  137. package/dist/queueEmitter/queueEmitter.core.js +45 -0
  138. package/dist/queueEmitter/queueEmitter.core.js.map +1 -0
  139. package/dist/queueEmitter/queueEmitter.type.d.ts +14 -0
  140. package/dist/queueEmitter/queueEmitter.type.d.ts.map +1 -0
  141. package/dist/queueEmitter/queueEmitter.type.js +2 -0
  142. package/dist/queueEmitter/queueEmitter.type.js.map +1 -0
  143. package/dist/queueEvents/index.d.ts +8 -0
  144. package/dist/queueEvents/index.d.ts.map +1 -0
  145. package/dist/queueEvents/index.js +7 -0
  146. package/dist/queueEvents/index.js.map +1 -0
  147. package/dist/queueEvents/queueEvents.core.d.ts +6 -0
  148. package/dist/queueEvents/queueEvents.core.d.ts.map +1 -0
  149. package/dist/queueEvents/queueEvents.core.js +12 -0
  150. package/dist/queueEvents/queueEvents.core.js.map +1 -0
  151. package/dist/queueEvents/queueEvents.type.d.ts +97 -0
  152. package/dist/queueEvents/queueEvents.type.d.ts.map +1 -0
  153. package/dist/queueEvents/queueEvents.type.js +2 -0
  154. package/dist/queueEvents/queueEvents.type.js.map +1 -0
  155. package/dist/queueManager/index.d.ts +8 -0
  156. package/dist/queueManager/index.d.ts.map +1 -0
  157. package/dist/queueManager/index.js +7 -0
  158. package/dist/queueManager/index.js.map +1 -0
  159. package/dist/queueManager/queueManager.core.d.ts +6 -0
  160. package/dist/queueManager/queueManager.core.d.ts.map +1 -0
  161. package/dist/queueManager/queueManager.core.js +32 -0
  162. package/dist/queueManager/queueManager.core.js.map +1 -0
  163. package/dist/queueManager/queueManager.type.d.ts +18 -0
  164. package/dist/queueManager/queueManager.type.d.ts.map +1 -0
  165. package/dist/queueManager/queueManager.type.js +2 -0
  166. package/dist/queueManager/queueManager.type.js.map +1 -0
  167. package/dist/queueRegistry/index.d.ts +8 -0
  168. package/dist/queueRegistry/index.d.ts.map +1 -0
  169. package/dist/queueRegistry/index.js +7 -0
  170. package/dist/queueRegistry/index.js.map +1 -0
  171. package/dist/queueRegistry/queueRegistry.core.d.ts +6 -0
  172. package/dist/queueRegistry/queueRegistry.core.d.ts.map +1 -0
  173. package/dist/queueRegistry/queueRegistry.core.js +41 -0
  174. package/dist/queueRegistry/queueRegistry.core.js.map +1 -0
  175. package/dist/queueRegistry/queueRegistry.type.d.ts +31 -0
  176. package/dist/queueRegistry/queueRegistry.type.d.ts.map +1 -0
  177. package/dist/queueRegistry/queueRegistry.type.js +2 -0
  178. package/dist/queueRegistry/queueRegistry.type.js.map +1 -0
  179. package/dist/retryPolicy/index.d.ts +8 -0
  180. package/dist/retryPolicy/index.d.ts.map +1 -0
  181. package/dist/retryPolicy/index.js +8 -0
  182. package/dist/retryPolicy/index.js.map +1 -0
  183. package/dist/retryPolicy/retryPolicy.core.d.ts +29 -0
  184. package/dist/retryPolicy/retryPolicy.core.d.ts.map +1 -0
  185. package/dist/retryPolicy/retryPolicy.core.js +51 -0
  186. package/dist/retryPolicy/retryPolicy.core.js.map +1 -0
  187. package/dist/serializer/index.d.ts +9 -0
  188. package/dist/serializer/index.d.ts.map +1 -0
  189. package/dist/serializer/index.js +8 -0
  190. package/dist/serializer/index.js.map +1 -0
  191. package/dist/serializer/serializer.core.d.ts +19 -0
  192. package/dist/serializer/serializer.core.d.ts.map +1 -0
  193. package/dist/serializer/serializer.core.js +53 -0
  194. package/dist/serializer/serializer.core.js.map +1 -0
  195. package/dist/serializer/serializer.type.d.ts +12 -0
  196. package/dist/serializer/serializer.type.d.ts.map +1 -0
  197. package/dist/serializer/serializer.type.js +2 -0
  198. package/dist/serializer/serializer.type.js.map +1 -0
  199. package/dist/worker/index.d.ts +9 -0
  200. package/dist/worker/index.d.ts.map +1 -0
  201. package/dist/worker/index.js +8 -0
  202. package/dist/worker/index.js.map +1 -0
  203. package/dist/worker/worker.core.d.ts +11 -0
  204. package/dist/worker/worker.core.d.ts.map +1 -0
  205. package/dist/worker/worker.core.js +117 -0
  206. package/dist/worker/worker.core.js.map +1 -0
  207. package/dist/worker/worker.type.d.ts +61 -0
  208. package/dist/worker/worker.type.d.ts.map +1 -0
  209. package/dist/worker/worker.type.js +2 -0
  210. package/dist/worker/worker.type.js.map +1 -0
  211. package/package.json +54 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @zudojs/queue - Background job and asynchronous task infrastructure.
3
+ *
4
+ * This package provides the core queue system for the Zudojs framework,
5
+ * enabling asynchronous job processing with support for retries, backoff,
6
+ * concurrency, and lifecycle management.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export * from "./jobTypes/index.js";
11
+ export * from "./job/index.js";
12
+ export * from "./jobContext/index.js";
13
+ export * from "./jobOptions/index.js";
14
+ export * from "./jobResult/index.js";
15
+ export * from "./processor/index.js";
16
+ export * from "./queue/index.js";
17
+ export * from "./queueManager/index.js";
18
+ export * from "./queueRegistry/index.js";
19
+ export * from "./queueEvents/index.js";
20
+ export * from "./queueEmitter/index.js";
21
+ export * from "./retryPolicy/index.js";
22
+ export * from "./serializer/index.js";
23
+ export * from "./middleware/index.js";
24
+ export * from "./worker/index.js";
25
+ export * from "./inMemoryQueue/index.js";
26
+ export * from "./deadLetter/index.js";
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,qBAAqB,CAAC;AAGpC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,uBAAuB,CAAC;AAGtC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @zudojs/queue - Background job and asynchronous task infrastructure.
3
+ *
4
+ * This package provides the core queue system for the Zudojs framework,
5
+ * enabling asynchronous job processing with support for retries, backoff,
6
+ * concurrency, and lifecycle management.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ // Job types
11
+ export * from "./jobTypes/index.js";
12
+ // Job
13
+ export * from "./job/index.js";
14
+ // Job context
15
+ export * from "./jobContext/index.js";
16
+ // Job options
17
+ export * from "./jobOptions/index.js";
18
+ // Job result
19
+ export * from "./jobResult/index.js";
20
+ // Processor
21
+ export * from "./processor/index.js";
22
+ // Queue
23
+ export * from "./queue/index.js";
24
+ // Queue manager
25
+ export * from "./queueManager/index.js";
26
+ // Queue registry
27
+ export * from "./queueRegistry/index.js";
28
+ // Queue events
29
+ export * from "./queueEvents/index.js";
30
+ // Queue emitter
31
+ export * from "./queueEmitter/index.js";
32
+ // Retry policy
33
+ export * from "./retryPolicy/index.js";
34
+ // Serializer
35
+ export * from "./serializer/index.js";
36
+ // Middleware
37
+ export * from "./middleware/index.js";
38
+ // Worker
39
+ export * from "./worker/index.js";
40
+ // In-memory queue
41
+ export * from "./inMemoryQueue/index.js";
42
+ // Dead letter
43
+ export * from "./deadLetter/index.js";
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY;AACZ,cAAc,qBAAqB,CAAC;AAEpC,MAAM;AACN,cAAc,gBAAgB,CAAC;AAE/B,cAAc;AACd,cAAc,uBAAuB,CAAC;AAEtC,cAAc;AACd,cAAc,uBAAuB,CAAC;AAEtC,aAAa;AACb,cAAc,sBAAsB,CAAC;AAErC,YAAY;AACZ,cAAc,sBAAsB,CAAC;AAErC,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,gBAAgB;AAChB,cAAc,yBAAyB,CAAC;AAExC,iBAAiB;AACjB,cAAc,0BAA0B,CAAC;AAEzC,eAAe;AACf,cAAc,wBAAwB,CAAC;AAEvC,gBAAgB;AAChB,cAAc,yBAAyB,CAAC;AAExC,eAAe;AACf,cAAc,wBAAwB,CAAC;AAEvC,aAAa;AACb,cAAc,uBAAuB,CAAC;AAEtC,aAAa;AACb,cAAc,uBAAuB,CAAC;AAEtC,SAAS;AACT,cAAc,mBAAmB,CAAC;AAElC,kBAAkB;AAClB,cAAc,0BAA0B,CAAC;AAEzC,cAAc;AACd,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Job interface and factory functions.
3
+ *
4
+ * Provides the core Job type and functions for creating
5
+ * and manipulating job instances.
6
+ */
7
+ export { createJob, isJob, updateJobState, incrementJobAttempt, } from "./job.core.js";
8
+ export type { Job, JobInput } from "./job.type.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/job/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,KAAK,EACL,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Job interface and factory functions.
3
+ *
4
+ * Provides the core Job type and functions for creating
5
+ * and manipulating job instances.
6
+ */
7
+ export { createJob, isJob, updateJobState, incrementJobAttempt, } from "./job.core.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/job/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,KAAK,EACL,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { JobId, JobState } from "../jobTypes/jobTypes.type.js";
2
+ import type { Job, JobInput } from "./job.type.js";
3
+ /**
4
+ * Creates a new job instance.
5
+ */
6
+ export declare function createJob<TData>(input: JobInput<TData>, id?: JobId): Job<TData>;
7
+ /**
8
+ * Checks if a value is a valid Job.
9
+ */
10
+ export declare function isJob(value: unknown): value is Job;
11
+ /**
12
+ * Updates a job's state.
13
+ */
14
+ export declare function updateJobState<TData>(job: Job<TData>, state: JobState, additional?: Partial<Pick<Job, "error" | "startedAt" | "completedAt" | "failedAt">>): Job<TData>;
15
+ /**
16
+ * Increments a job's attempt counter.
17
+ */
18
+ export declare function incrementJobAttempt<TData>(job: Job<TData>): Job<TData>;
19
+ //# sourceMappingURL=job.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.core.d.ts","sourceRoot":"","sources":["../../src/job/job.core.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOnD;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EACtB,EAAE,CAAC,EAAE,KAAK,GACT,GAAG,CAAC,KAAK,CAAC,CAqCZ;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CASlD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAClC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,EACf,KAAK,EAAE,QAAQ,EACf,UAAU,CAAC,EAAE,OAAO,CAClB,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC,CAC9D,GACA,GAAG,CAAC,KAAK,CAAC,CASZ;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAMtE"}
@@ -0,0 +1,74 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { createJobId, JobState as JobStateEnum, } from "../jobTypes/jobTypes.type.js";
3
+ /**
4
+ * Creates a new job instance.
5
+ */
6
+ export function createJob(input, id) {
7
+ const now = new Date().toISOString();
8
+ const options = input.options;
9
+ const jobId = id ?? createJobId(`job_${Date.now()}_${randomBytes(6).toString("hex")}`);
10
+ return {
11
+ id: jobId,
12
+ name: input.name,
13
+ queueName: input.queueName,
14
+ data: input.data,
15
+ state: options?.delay || options?.scheduledAt
16
+ ? JobStateEnum.SCHEDULED
17
+ : JobStateEnum.WAITING,
18
+ attempt: 0,
19
+ maxAttempts: options?.attempts ?? 1,
20
+ priority: options?.priority ?? 50,
21
+ createdAt: now,
22
+ updatedAt: now,
23
+ scheduledAt: options?.scheduledAt
24
+ ? options.scheduledAt.toISOString()
25
+ : options?.delay
26
+ ? new Date(Date.now() + options.delay).toISOString()
27
+ : undefined,
28
+ timeoutMs: options?.timeout,
29
+ deduplicationKey: options?.deduplicationKey,
30
+ metadata: options?.metadata,
31
+ backoff: options?.backoff
32
+ ? {
33
+ type: options.backoff.type,
34
+ delay: options.backoff.delay,
35
+ maxDelay: options.backoff.maxDelay,
36
+ multiplier: options.backoff.multiplier,
37
+ }
38
+ : undefined,
39
+ };
40
+ }
41
+ /**
42
+ * Checks if a value is a valid Job.
43
+ */
44
+ export function isJob(value) {
45
+ return (typeof value === "object" &&
46
+ value !== null &&
47
+ "id" in value &&
48
+ "name" in value &&
49
+ "state" in value &&
50
+ "data" in value);
51
+ }
52
+ /**
53
+ * Updates a job's state.
54
+ */
55
+ export function updateJobState(job, state, additional) {
56
+ const now = new Date().toISOString();
57
+ return {
58
+ ...job,
59
+ state,
60
+ updatedAt: now,
61
+ ...additional,
62
+ };
63
+ }
64
+ /**
65
+ * Increments a job's attempt counter.
66
+ */
67
+ export function incrementJobAttempt(job) {
68
+ return {
69
+ ...job,
70
+ attempt: job.attempt + 1,
71
+ updatedAt: new Date().toISOString(),
72
+ };
73
+ }
74
+ //# sourceMappingURL=job.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.core.js","sourceRoot":"","sources":["../../src/job/job.core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,OAAO,EACL,WAAW,EACX,QAAQ,IAAI,YAAY,GACzB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,KAAsB,EACtB,EAAU;IAEV,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe,CAAC;IAClD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,MAAM,KAAK,GACT,EAAE,IAAI,WAAW,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE3E,OAAO;QACL,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EACH,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,WAAW;YACpC,CAAC,CAAC,YAAY,CAAC,SAAS;YACxB,CAAC,CAAC,YAAY,CAAC,OAAO;QAC1B,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC;QACnC,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE;QACjC,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,OAAO,EAAE,WAAW;YAC/B,CAAC,CAAE,OAAO,CAAC,WAAW,CAAC,WAAW,EAAgB;YAClD,CAAC,CAAC,OAAO,EAAE,KAAK;gBACd,CAAC,CAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,EAAgB;gBACnE,CAAC,CAAC,SAAS;QACf,SAAS,EAAE,OAAO,EAAE,OAAO;QAC3B,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,OAAO,EAAE,OAAO,EAAE,OAAO;YACvB,CAAC,CAAC;gBACE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;gBAC1B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK;gBAC5B,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;gBAClC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU;aACvC;YACH,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,IAAI,IAAI,KAAK;QACb,MAAM,IAAI,KAAK;QACf,OAAO,IAAI,KAAK;QAChB,MAAM,IAAI,KAAK,CAChB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAe,EACf,KAAe,EACf,UAEC;IAED,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe,CAAC;IAElD,OAAO;QACL,GAAG,GAAG;QACN,KAAK;QACL,SAAS,EAAE,GAAG;QACd,GAAG,UAAU;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAQ,GAAe;IACxD,OAAO;QACL,GAAG,GAAG;QACN,OAAO,EAAE,GAAG,CAAC,OAAO,GAAG,CAAC;QACxB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe;KACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ import type { Timestamp } from "@zudojs/constants";
2
+ import type { JobId, JobName, JobState, JobPriority, BackoffType } from "../jobTypes/jobTypes.type.js";
3
+ import type { JobOptions } from "../jobOptions/jobOptions.type.js";
4
+ /**
5
+ * A unit of work in the queue system.
6
+ */
7
+ export interface Job<TData = unknown> {
8
+ /** Unique identifier for the job. */
9
+ readonly id: JobId;
10
+ /** Name/type of the job. */
11
+ readonly name: JobName;
12
+ /** Queue this job belongs to. */
13
+ readonly queueName: string;
14
+ /** Job payload data. */
15
+ readonly data: TData;
16
+ /** Current state of the job. */
17
+ readonly state: JobState;
18
+ /** Number of attempts made. */
19
+ readonly attempt: number;
20
+ /** Maximum number of attempts allowed. */
21
+ readonly maxAttempts: number;
22
+ /** Job priority. */
23
+ readonly priority: JobPriority;
24
+ /** When the job was created. */
25
+ readonly createdAt: Timestamp;
26
+ /** When the job was last updated. */
27
+ readonly updatedAt: Timestamp;
28
+ /** When the job should be processed (for delayed jobs). */
29
+ readonly scheduledAt?: Timestamp;
30
+ /** When the job started processing. */
31
+ readonly startedAt?: Timestamp;
32
+ /** When the job completed. */
33
+ readonly completedAt?: Timestamp;
34
+ /** When the job failed. */
35
+ readonly failedAt?: Timestamp;
36
+ /** Error message if the job failed. */
37
+ readonly error?: string;
38
+ /** Timeout in milliseconds. */
39
+ readonly timeoutMs?: number;
40
+ /** Deduplication key. */
41
+ readonly deduplicationKey?: string;
42
+ /** Additional metadata. */
43
+ readonly metadata?: Record<string, unknown>;
44
+ /** Backoff configuration. */
45
+ readonly backoff?: {
46
+ readonly type: BackoffType;
47
+ readonly delay: number;
48
+ readonly maxDelay?: number;
49
+ readonly multiplier?: number;
50
+ };
51
+ }
52
+ /**
53
+ * Input data for creating a new job.
54
+ */
55
+ export interface JobInput<TData = unknown> {
56
+ /** Name/type of the job. */
57
+ readonly name: JobName;
58
+ /** Queue this job belongs to. */
59
+ readonly queueName: string;
60
+ /** Job payload data. */
61
+ readonly data: TData;
62
+ /** Job options. */
63
+ readonly options?: JobOptions;
64
+ }
65
+ //# sourceMappingURL=job.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.type.d.ts","sourceRoot":"","sources":["../../src/job/job.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,KAAK,GAAG,OAAO;IAClC,qCAAqC;IACrC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC;IACjC,uCAAuC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC;IACjC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,uCAAuC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;QAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,KAAK,GAAG,OAAO;IACvC,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,mBAAmB;IACnB,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=job.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.type.js","sourceRoot":"","sources":["../../src/job/job.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Job context for processor execution.
3
+ *
4
+ * Provides context information to job processors during execution.
5
+ */
6
+ export { createJobContext, isJobContext } from "./jobContext.core.js";
7
+ export type { JobContext } from "./jobContext.type.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jobContext/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Job context for processor execution.
3
+ *
4
+ * Provides context information to job processors during execution.
5
+ */
6
+ export { createJobContext, isJobContext } from "./jobContext.core.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobContext/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Job } from "../job/job.type.js";
2
+ import type { JobProgress } from "../jobResult/jobResult.type.js";
3
+ import type { JobContext } from "./jobContext.type.js";
4
+ /**
5
+ * Creates a JobContext for a job processor.
6
+ */
7
+ export declare function createJobContext<TData>(job: Job<TData>, signal: AbortSignal, options?: {
8
+ onProgress?: (progress: JobProgress) => Promise<void>;
9
+ logger?: {
10
+ info: (message: string, data?: Record<string, unknown>) => void;
11
+ };
12
+ }): JobContext<TData>;
13
+ /**
14
+ * Checks if a value is a valid JobContext.
15
+ */
16
+ export declare function isJobContext(value: unknown): value is JobContext;
17
+ //# sourceMappingURL=jobContext.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobContext.core.d.ts","sourceRoot":"","sources":["../../src/jobContext/jobContext.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EACpC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,EACf,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KACjE,CAAC;CACE,GACL,UAAU,CAAC,KAAK,CAAC,CAoBnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAShE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Creates a JobContext for a job processor.
3
+ */
4
+ export function createJobContext(job, signal, options = {}) {
5
+ return {
6
+ job,
7
+ signal,
8
+ updateProgress: async (progress) => {
9
+ if (options.onProgress) {
10
+ await options.onProgress(progress);
11
+ }
12
+ },
13
+ log: (message, data) => {
14
+ if (options.logger) {
15
+ options.logger.info(message, {
16
+ jobId: job.id,
17
+ jobName: job.name,
18
+ queueName: job.queueName,
19
+ ...data,
20
+ });
21
+ }
22
+ },
23
+ };
24
+ }
25
+ /**
26
+ * Checks if a value is a valid JobContext.
27
+ */
28
+ export function isJobContext(value) {
29
+ return (typeof value === "object" &&
30
+ value !== null &&
31
+ "job" in value &&
32
+ "signal" in value &&
33
+ "updateProgress" in value &&
34
+ "log" in value);
35
+ }
36
+ //# sourceMappingURL=jobContext.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobContext.core.js","sourceRoot":"","sources":["../../src/jobContext/jobContext.core.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAe,EACf,MAAmB,EACnB,OAAO,GAKH,EAAE;IAEN,OAAO;QACL,GAAG;QACH,MAAM;QACN,cAAc,EAAE,KAAK,EAAE,QAAqB,EAAE,EAAE;YAC9C,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QACD,GAAG,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE;YACvD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;oBAC3B,KAAK,EAAE,GAAG,CAAC,EAAE;oBACb,OAAO,EAAE,GAAG,CAAC,IAAI;oBACjB,SAAS,EAAE,GAAG,CAAC,SAAS;oBACxB,GAAG,IAAI;iBACR,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,IAAI,KAAK;QACd,QAAQ,IAAI,KAAK;QACjB,gBAAgB,IAAI,KAAK;QACzB,KAAK,IAAI,KAAK,CACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Job } from "../job/job.type.js";
2
+ import type { JobProgress } from "../jobResult/jobResult.type.js";
3
+ /**
4
+ * Context provided to a job processor during execution.
5
+ */
6
+ export interface JobContext<TData = unknown> {
7
+ /** The job being processed. */
8
+ readonly job: Job<TData>;
9
+ /** AbortSignal for cancellation support. */
10
+ readonly signal: AbortSignal;
11
+ /** Update job progress. */
12
+ updateProgress(progress: JobProgress): Promise<void>;
13
+ /** Log a message with job context. */
14
+ log(message: string, data?: Record<string, unknown>): void;
15
+ }
16
+ //# sourceMappingURL=jobContext.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobContext.type.d.ts","sourceRoot":"","sources":["../../src/jobContext/jobContext.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,KAAK,GAAG,OAAO;IACzC,+BAA+B;IAC/B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,2BAA2B;IAC3B,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,sCAAsC;IACtC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC5D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jobContext.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobContext.type.js","sourceRoot":"","sources":["../../src/jobContext/jobContext.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Job options and configuration types.
3
+ *
4
+ * Provides options for job creation, retry policies, and defaults.
5
+ */
6
+ export { DEFAULT_JOB_OPTIONS, mergeJobOptions } from "./jobOptions.core.js";
7
+ export type { BackoffOptions, JobOptions } from "./jobOptions.type.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jobOptions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5E,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Job options and configuration types.
3
+ *
4
+ * Provides options for job creation, retry policies, and defaults.
5
+ */
6
+ export { DEFAULT_JOB_OPTIONS, mergeJobOptions } from "./jobOptions.core.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobOptions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { JobOptions } from "./jobOptions.type.js";
2
+ /**
3
+ * Default job options.
4
+ */
5
+ export declare const DEFAULT_JOB_OPTIONS: Readonly<Pick<JobOptions, "attempts" | "timeout">>;
6
+ /**
7
+ * Merges user-provided job options with defaults.
8
+ */
9
+ export declare function mergeJobOptions(options?: JobOptions): Required<Pick<JobOptions, "attempts" | "timeout">> & Pick<JobOptions, "backoff" | "delay" | "priority" | "deduplicationKey" | "scheduledAt" | "metadata">;
10
+ //# sourceMappingURL=jobOptions.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobOptions.core.d.ts","sourceRoot":"","sources":["../../src/jobOptions/jobOptions.core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CACxC,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC,CAIxC,CAAC;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,CAAC,EAAE,UAAU,GACnB,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC,GACnD,IAAI,CACF,UAAU,EACR,SAAS,GACT,OAAO,GACP,UAAU,GACV,kBAAkB,GAClB,aAAa,GACb,UAAU,CACb,CAWF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Default job options.
3
+ */
4
+ export const DEFAULT_JOB_OPTIONS = Object.freeze({
5
+ attempts: 1,
6
+ timeout: 30_000,
7
+ });
8
+ /**
9
+ * Merges user-provided job options with defaults.
10
+ */
11
+ export function mergeJobOptions(options) {
12
+ return {
13
+ attempts: options?.attempts ?? DEFAULT_JOB_OPTIONS.attempts ?? 1,
14
+ timeout: options?.timeout ?? DEFAULT_JOB_OPTIONS.timeout ?? 30_000,
15
+ backoff: options?.backoff,
16
+ delay: options?.delay,
17
+ priority: options?.priority,
18
+ deduplicationKey: options?.deduplicationKey,
19
+ scheduledAt: options?.scheduledAt,
20
+ metadata: options?.metadata,
21
+ };
22
+ }
23
+ //# sourceMappingURL=jobOptions.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobOptions.core.js","sourceRoot":"","sources":["../../src/jobOptions/jobOptions.core.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,MAAM,CAAC,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,MAAM;CAChB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAoB;IAWpB,OAAO;QACL,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,mBAAmB,CAAC,QAAQ,IAAI,CAAC;QAChE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,mBAAmB,CAAC,OAAO,IAAI,MAAM;QAClE,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,QAAQ,EAAE,OAAO,EAAE,QAAQ;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { BackoffType } from "../jobTypes/jobTypes.type.js";
2
+ /**
3
+ * Backoff configuration for retry attempts.
4
+ */
5
+ export interface BackoffOptions {
6
+ /** Backoff strategy type. */
7
+ readonly type: BackoffType;
8
+ /** Initial delay in milliseconds. */
9
+ readonly delay: number;
10
+ /** Maximum delay in milliseconds (for exponential). */
11
+ readonly maxDelay?: number;
12
+ /** Multiplier for exponential backoff. */
13
+ readonly multiplier?: number;
14
+ }
15
+ /**
16
+ * Options for adding a job to the queue.
17
+ */
18
+ export interface JobOptions {
19
+ /** Maximum number of attempts (default: 1, no retries). */
20
+ readonly attempts?: number;
21
+ /** Backoff configuration for retries. */
22
+ readonly backoff?: BackoffOptions;
23
+ /** Delay in milliseconds before the job becomes active. */
24
+ readonly delay?: number;
25
+ /** Job priority (higher number = higher priority). */
26
+ readonly priority?: number;
27
+ /** Timeout in milliseconds for job execution. */
28
+ readonly timeout?: number;
29
+ /** Key for job deduplication. */
30
+ readonly deduplicationKey?: string;
31
+ /** Timestamp when the job should be scheduled. */
32
+ readonly scheduledAt?: Date;
33
+ /** Additional metadata to attach to the job. */
34
+ readonly metadata?: Record<string, unknown>;
35
+ }
36
+ //# sourceMappingURL=jobOptions.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobOptions.type.d.ts","sourceRoot":"","sources":["../../src/jobOptions/jobOptions.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jobOptions.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobOptions.type.js","sourceRoot":"","sources":["../../src/jobOptions/jobOptions.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Job result and progress types.
3
+ *
4
+ * Provides types for job execution results and progress tracking.
5
+ */
6
+ export { createJobResult, createJobErrorResult, createJobProgress, } from "./jobResult.core.js";
7
+ export type { JobResult, JobProgress } from "./jobResult.type.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jobResult/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Job result and progress types.
3
+ *
4
+ * Provides types for job execution results and progress tracking.
5
+ */
6
+ export { createJobResult, createJobErrorResult, createJobProgress, } from "./jobResult.core.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobResult/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { JobResult, JobProgress } from "./jobResult.type.js";
2
+ /**
3
+ * Creates a successful job result.
4
+ */
5
+ export declare function createJobResult<T>(data: T, durationMs: number): JobResult<T>;
6
+ /**
7
+ * Creates a failed job result.
8
+ */
9
+ export declare function createJobErrorResult(error: string, durationMs: number): JobResult;
10
+ /**
11
+ * Creates a job progress update.
12
+ */
13
+ export declare function createJobProgress(percent: number, options?: {
14
+ step?: string;
15
+ totalSteps?: number;
16
+ currentStep?: number;
17
+ message?: string;
18
+ }): JobProgress;
19
+ //# sourceMappingURL=jobResult.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobResult.core.d.ts","sourceRoot":"","sources":["../../src/jobResult/jobResult.core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElE;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAO5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,GACjB,SAAS,CAOX;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,WAAW,CASb"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Creates a successful job result.
3
+ */
4
+ export function createJobResult(data, durationMs) {
5
+ return {
6
+ success: true,
7
+ data,
8
+ durationMs,
9
+ timestamp: new Date().toISOString(),
10
+ };
11
+ }
12
+ /**
13
+ * Creates a failed job result.
14
+ */
15
+ export function createJobErrorResult(error, durationMs) {
16
+ return {
17
+ success: false,
18
+ error,
19
+ durationMs,
20
+ timestamp: new Date().toISOString(),
21
+ };
22
+ }
23
+ /**
24
+ * Creates a job progress update.
25
+ */
26
+ export function createJobProgress(percent, options = {}) {
27
+ return {
28
+ percent: Math.max(0, Math.min(100, percent)),
29
+ step: options.step,
30
+ totalSteps: options.totalSteps,
31
+ currentStep: options.currentStep,
32
+ message: options.message,
33
+ timestamp: new Date().toISOString(),
34
+ };
35
+ }
36
+ //# sourceMappingURL=jobResult.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobResult.core.js","sourceRoot":"","sources":["../../src/jobResult/jobResult.core.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAI,IAAO,EAAE,UAAkB;IAC5D,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI;QACJ,UAAU;QACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe;KACjD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,UAAkB;IAElB,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK;QACL,UAAU;QACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe;KACjD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAe,EACf,OAAO,GAKH,EAAE;IAEN,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe;KACjD,CAAC;AACJ,CAAC"}