@shivaedev/jobs 0.30.0 → 0.32.0

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 (447) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +88 -24
  3. package/dist/display.d.ts +14 -0
  4. package/dist/display.d.ts.map +1 -0
  5. package/dist/display.js +2 -0
  6. package/dist/display.js.map +1 -0
  7. package/dist/server/ClientDatabase.d.ts +21 -0
  8. package/dist/server/ClientDatabase.d.ts.map +1 -0
  9. package/dist/server/ClientDatabase.js +2 -0
  10. package/dist/server/ClientDatabase.js.map +1 -0
  11. package/dist/server/PgBoss.d.ts +2 -2
  12. package/dist/server/PgBoss.d.ts.map +1 -1
  13. package/dist/server/adapters/batchClockOffset.d.ts +2 -2
  14. package/dist/server/adapters/batchClockOffset.d.ts.map +1 -1
  15. package/dist/server/adapters/batchClockOffset.js +5 -4
  16. package/dist/server/adapters/batchClockOffset.js.map +1 -1
  17. package/dist/server/adapters/batchHandler.d.ts +5 -0
  18. package/dist/server/adapters/batchHandler.d.ts.map +1 -0
  19. package/dist/server/{internal → adapters}/batchHandler.js +6 -6
  20. package/dist/server/adapters/batchHandler.js.map +1 -0
  21. package/dist/server/adapters/clientCache.d.ts +10 -0
  22. package/dist/server/adapters/clientCache.d.ts.map +1 -0
  23. package/dist/server/{internal → adapters}/clientCache.js +5 -19
  24. package/dist/server/adapters/clientCache.js.map +1 -0
  25. package/dist/server/adapters/clientErrorLogger.js +1 -1
  26. package/dist/server/adapters/clientErrorLogger.js.map +1 -1
  27. package/dist/server/adapters/defaultClientFactory.d.ts +4 -0
  28. package/dist/server/adapters/defaultClientFactory.d.ts.map +1 -0
  29. package/dist/server/adapters/defaultClientFactory.js.map +1 -0
  30. package/dist/server/adapters/deferralCount.d.ts +3 -3
  31. package/dist/server/adapters/deferralCount.d.ts.map +1 -1
  32. package/dist/server/adapters/deferralCount.js +2 -2
  33. package/dist/server/adapters/deferralCount.js.map +1 -1
  34. package/dist/server/adapters/expireAttempt.d.ts +4 -0
  35. package/dist/server/adapters/expireAttempt.d.ts.map +1 -0
  36. package/dist/server/{internal → adapters}/expireAttempt.js +1 -1
  37. package/dist/server/{internal → adapters}/expireAttempt.js.map +1 -1
  38. package/dist/server/adapters/inspection.d.ts +5 -0
  39. package/dist/server/adapters/inspection.d.ts.map +1 -0
  40. package/dist/server/adapters/inspection.js +25 -0
  41. package/dist/server/adapters/inspection.js.map +1 -0
  42. package/dist/server/adapters/inspectionChanges.d.ts +7 -0
  43. package/dist/server/adapters/inspectionChanges.d.ts.map +1 -0
  44. package/dist/server/adapters/inspectionChanges.js +23 -0
  45. package/dist/server/adapters/inspectionChanges.js.map +1 -0
  46. package/dist/server/adapters/inspectionDeferrals.d.ts +10 -0
  47. package/dist/server/adapters/inspectionDeferrals.d.ts.map +1 -0
  48. package/dist/server/adapters/inspectionDeferrals.js +13 -0
  49. package/dist/server/adapters/inspectionDeferrals.js.map +1 -0
  50. package/dist/server/adapters/inspectionJobs.d.ts +50 -0
  51. package/dist/server/adapters/inspectionJobs.d.ts.map +1 -0
  52. package/dist/server/adapters/inspectionJobs.js +21 -0
  53. package/dist/server/adapters/inspectionJobs.js.map +1 -0
  54. package/dist/server/adapters/inspectionOperation.d.ts +3 -0
  55. package/dist/server/adapters/inspectionOperation.d.ts.map +1 -0
  56. package/dist/server/adapters/inspectionOperation.js +6 -0
  57. package/dist/server/adapters/inspectionOperation.js.map +1 -0
  58. package/dist/server/adapters/inspectionPlan.d.ts +3 -0
  59. package/dist/server/adapters/inspectionPlan.d.ts.map +1 -0
  60. package/dist/server/adapters/inspectionPlan.js +20 -0
  61. package/dist/server/adapters/inspectionPlan.js.map +1 -0
  62. package/dist/server/adapters/inspectionReads.d.ts +59 -0
  63. package/dist/server/adapters/inspectionReads.d.ts.map +1 -0
  64. package/dist/server/adapters/inspectionReads.js +44 -0
  65. package/dist/server/adapters/inspectionReads.js.map +1 -0
  66. package/dist/server/adapters/inspectionSnapshot.d.ts +6 -0
  67. package/dist/server/adapters/inspectionSnapshot.d.ts.map +1 -0
  68. package/dist/server/{internal/testingSnapshot.js → adapters/inspectionSnapshot.js} +10 -8
  69. package/dist/server/adapters/inspectionSnapshot.js.map +1 -0
  70. package/dist/server/adapters/installSchema.d.ts +1 -1
  71. package/dist/server/adapters/installSchema.d.ts.map +1 -1
  72. package/dist/server/adapters/installSchema.js +1 -1
  73. package/dist/server/adapters/installSchema.js.map +1 -1
  74. package/dist/server/adapters/jobEngine.d.ts +5 -0
  75. package/dist/server/adapters/jobEngine.d.ts.map +1 -0
  76. package/dist/server/adapters/jobEngine.js +46 -0
  77. package/dist/server/adapters/jobEngine.js.map +1 -0
  78. package/dist/server/adapters/lifecycle.d.ts +11 -0
  79. package/dist/server/adapters/lifecycle.d.ts.map +1 -0
  80. package/dist/server/adapters/lifecycle.js +48 -0
  81. package/dist/server/adapters/lifecycle.js.map +1 -0
  82. package/dist/server/adapters/listJobs.d.ts +5 -0
  83. package/dist/server/adapters/listJobs.d.ts.map +1 -0
  84. package/dist/server/adapters/listJobs.js +37 -0
  85. package/dist/server/adapters/listJobs.js.map +1 -0
  86. package/dist/server/adapters/payloadIdentity.d.ts +3 -0
  87. package/dist/server/adapters/payloadIdentity.d.ts.map +1 -0
  88. package/dist/server/adapters/payloadIdentity.js +14 -0
  89. package/dist/server/adapters/payloadIdentity.js.map +1 -0
  90. package/dist/server/adapters/queueAdministration.d.ts +4 -0
  91. package/dist/server/adapters/queueAdministration.d.ts.map +1 -0
  92. package/dist/server/adapters/queueAdministration.js +42 -0
  93. package/dist/server/adapters/queueAdministration.js.map +1 -0
  94. package/dist/server/{internal/testingSignal.d.ts → adapters/queueSignal.d.ts} +2 -2
  95. package/dist/server/adapters/queueSignal.d.ts.map +1 -0
  96. package/dist/server/{internal/testingSignal.js → adapters/queueSignal.js} +2 -2
  97. package/dist/server/adapters/queueSignal.js.map +1 -0
  98. package/dist/server/adapters/registerWorker.d.ts +5 -3
  99. package/dist/server/adapters/registerWorker.d.ts.map +1 -1
  100. package/dist/server/adapters/registerWorker.js +9 -6
  101. package/dist/server/adapters/registerWorker.js.map +1 -1
  102. package/dist/server/adapters/retireJobs.d.ts +3 -3
  103. package/dist/server/adapters/retireJobs.d.ts.map +1 -1
  104. package/dist/server/adapters/retireJobs.js +3 -3
  105. package/dist/server/adapters/retireJobs.js.map +1 -1
  106. package/dist/server/adapters/schemaIndexBuilds.d.ts +2 -2
  107. package/dist/server/adapters/schemaIndexBuilds.d.ts.map +1 -1
  108. package/dist/server/adapters/schemaIndexBuilds.js.map +1 -1
  109. package/dist/server/adapters/settleDeferral.d.ts +7 -0
  110. package/dist/server/adapters/settleDeferral.d.ts.map +1 -0
  111. package/dist/server/{internal → adapters}/settleDeferral.js +2 -2
  112. package/dist/server/adapters/settleDeferral.js.map +1 -0
  113. package/dist/server/adapters/testingClient.d.ts +13 -0
  114. package/dist/server/adapters/testingClient.d.ts.map +1 -0
  115. package/dist/server/{internal → adapters}/testingClient.js +27 -48
  116. package/dist/server/adapters/testingClient.js.map +1 -0
  117. package/dist/server/adapters/testingController.d.ts +79 -0
  118. package/dist/server/adapters/testingController.d.ts.map +1 -0
  119. package/dist/server/adapters/testingController.js +108 -0
  120. package/dist/server/adapters/testingController.js.map +1 -0
  121. package/dist/server/adapters/testingDueNow.d.ts +3 -3
  122. package/dist/server/adapters/testingDueNow.d.ts.map +1 -1
  123. package/dist/server/adapters/testingDueNow.js +2 -2
  124. package/dist/server/adapters/testingDueNow.js.map +1 -1
  125. package/dist/server/adapters/testingEngine.d.ts +5 -0
  126. package/dist/server/adapters/testingEngine.d.ts.map +1 -0
  127. package/dist/server/adapters/testingEngine.js +12 -0
  128. package/dist/server/adapters/testingEngine.js.map +1 -0
  129. package/dist/server/adapters/testingExpirations.d.ts +6 -4
  130. package/dist/server/adapters/testingExpirations.d.ts.map +1 -1
  131. package/dist/server/adapters/testingExpirations.js.map +1 -1
  132. package/dist/server/adapters/testingInspectionClient.d.ts +5 -0
  133. package/dist/server/adapters/testingInspectionClient.d.ts.map +1 -0
  134. package/dist/server/adapters/testingInspectionClient.js +52 -0
  135. package/dist/server/adapters/testingInspectionClient.js.map +1 -0
  136. package/dist/server/adapters/transactionDb.d.ts +2 -2
  137. package/dist/server/adapters/transactionDb.d.ts.map +1 -1
  138. package/dist/server/adapters/transactionDb.js.map +1 -1
  139. package/dist/server/client.d.ts +95 -18
  140. package/dist/server/client.d.ts.map +1 -1
  141. package/dist/server/clientOptions.d.ts +74 -0
  142. package/dist/server/clientOptions.d.ts.map +1 -0
  143. package/dist/server/clientOptions.js +2 -0
  144. package/dist/server/clientOptions.js.map +1 -0
  145. package/dist/server/defineSchedule.d.ts +1 -1
  146. package/dist/server/defineSchedule.d.ts.map +1 -1
  147. package/dist/server/defineSchedule.js +2 -1
  148. package/dist/server/defineSchedule.js.map +1 -1
  149. package/dist/server/definition.d.ts +29 -26
  150. package/dist/server/definition.d.ts.map +1 -1
  151. package/dist/server/definition.js +5 -2
  152. package/dist/server/definition.js.map +1 -1
  153. package/dist/server/engineClient.d.ts +21 -0
  154. package/dist/server/engineClient.d.ts.map +1 -0
  155. package/dist/server/engineClient.js +2 -0
  156. package/dist/server/engineClient.js.map +1 -0
  157. package/dist/server/enqueueOptions.d.ts +28 -0
  158. package/dist/server/enqueueOptions.d.ts.map +1 -0
  159. package/dist/server/enqueueOptions.js +2 -0
  160. package/dist/server/enqueueOptions.js.map +1 -0
  161. package/dist/server/error.d.ts +11 -1
  162. package/dist/server/error.d.ts.map +1 -1
  163. package/dist/server/error.js +8 -1
  164. package/dist/server/error.js.map +1 -1
  165. package/dist/server/health.d.ts +2 -2
  166. package/dist/server/health.d.ts.map +1 -1
  167. package/dist/server/inspection.d.ts +102 -0
  168. package/dist/server/inspection.d.ts.map +1 -0
  169. package/dist/server/inspection.js +30 -0
  170. package/dist/server/inspection.js.map +1 -0
  171. package/dist/server/internal/acquireClient.d.ts +11 -0
  172. package/dist/server/internal/acquireClient.d.ts.map +1 -0
  173. package/dist/server/internal/acquireClient.js +21 -0
  174. package/dist/server/internal/acquireClient.js.map +1 -0
  175. package/dist/server/internal/adapters/testingFetches.d.ts +2 -2
  176. package/dist/server/internal/adapters/testingFetches.d.ts.map +1 -1
  177. package/dist/server/internal/adapters/testingFetches.js.map +1 -1
  178. package/dist/server/internal/clientErrors.d.ts +1 -1
  179. package/dist/server/internal/clientErrors.d.ts.map +1 -1
  180. package/dist/server/internal/countsFor.d.ts +3 -3
  181. package/dist/server/internal/countsFor.d.ts.map +1 -1
  182. package/dist/server/internal/countsFor.js +2 -2
  183. package/dist/server/internal/countsFor.js.map +1 -1
  184. package/dist/server/internal/deadLetterResolutionPlan.js +1 -1
  185. package/dist/server/internal/deadLetterResolutionPlan.js.map +1 -1
  186. package/dist/server/internal/deadlineOf.d.ts +2 -2
  187. package/dist/server/internal/deadlineOf.d.ts.map +1 -1
  188. package/dist/server/internal/deadlineOf.js.map +1 -1
  189. package/dist/server/internal/deferrableAttempt.d.ts +4 -5
  190. package/dist/server/internal/deferrableAttempt.d.ts.map +1 -1
  191. package/dist/server/internal/deferrableAttempt.js +5 -14
  192. package/dist/server/internal/deferrableAttempt.js.map +1 -1
  193. package/dist/server/internal/deferral.d.ts +2 -4
  194. package/dist/server/internal/deferral.d.ts.map +1 -1
  195. package/dist/server/internal/deferral.js +0 -1
  196. package/dist/server/internal/deferral.js.map +1 -1
  197. package/dist/server/internal/deferralStorePlan.js +2 -2
  198. package/dist/server/internal/deferralStorePlan.js.map +1 -1
  199. package/dist/server/internal/definitionOptions.d.ts +7 -7
  200. package/dist/server/internal/definitionOptions.d.ts.map +1 -1
  201. package/dist/server/internal/engine.d.ts +25 -0
  202. package/dist/server/internal/engine.d.ts.map +1 -0
  203. package/dist/server/internal/engine.js +6 -0
  204. package/dist/server/internal/engine.js.map +1 -0
  205. package/dist/server/internal/enqueueFor.d.ts +2 -2
  206. package/dist/server/internal/enqueueFor.d.ts.map +1 -1
  207. package/dist/server/internal/enqueueFor.js +14 -4
  208. package/dist/server/internal/enqueueFor.js.map +1 -1
  209. package/dist/server/internal/ensureQueue.d.ts +2 -3
  210. package/dist/server/internal/ensureQueue.d.ts.map +1 -1
  211. package/dist/server/internal/ensureQueue.js +2 -2
  212. package/dist/server/internal/ensureQueue.js.map +1 -1
  213. package/dist/server/internal/healthFor.d.ts +3 -3
  214. package/dist/server/internal/healthFor.d.ts.map +1 -1
  215. package/dist/server/internal/healthFor.js +2 -2
  216. package/dist/server/internal/healthFor.js.map +1 -1
  217. package/dist/server/internal/jobControl.d.ts +9 -4
  218. package/dist/server/internal/jobControl.d.ts.map +1 -1
  219. package/dist/server/internal/jobControl.js +13 -40
  220. package/dist/server/internal/jobControl.js.map +1 -1
  221. package/dist/server/internal/jobListings.d.ts +16 -0
  222. package/dist/server/internal/jobListings.d.ts.map +1 -0
  223. package/dist/server/internal/jobListings.js +52 -0
  224. package/dist/server/internal/jobListings.js.map +1 -0
  225. package/dist/server/internal/jobStorePlans.d.ts.map +1 -1
  226. package/dist/server/internal/jobStorePlans.js +4 -3
  227. package/dist/server/internal/jobStorePlans.js.map +1 -1
  228. package/dist/server/internal/lifecycle.d.ts +11 -7
  229. package/dist/server/internal/lifecycle.d.ts.map +1 -1
  230. package/dist/server/internal/lifecycle.js +2 -49
  231. package/dist/server/internal/lifecycle.js.map +1 -1
  232. package/dist/server/internal/makeService.d.ts +5 -3
  233. package/dist/server/internal/makeService.d.ts.map +1 -1
  234. package/dist/server/internal/makeService.js +18 -13
  235. package/dist/server/internal/makeService.js.map +1 -1
  236. package/dist/server/internal/register.d.ts +5 -5
  237. package/dist/server/internal/register.d.ts.map +1 -1
  238. package/dist/server/internal/register.js +5 -9
  239. package/dist/server/internal/register.js.map +1 -1
  240. package/dist/server/internal/registerReleasedJobs.d.ts +4 -4
  241. package/dist/server/internal/registerReleasedJobs.d.ts.map +1 -1
  242. package/dist/server/internal/registerReleasedJobs.js +2 -2
  243. package/dist/server/internal/registerReleasedJobs.js.map +1 -1
  244. package/dist/server/internal/retryWake.d.ts +1 -1
  245. package/dist/server/internal/retryWake.d.ts.map +1 -1
  246. package/dist/server/internal/retryWake.js +2 -2
  247. package/dist/server/internal/retryWake.js.map +1 -1
  248. package/dist/server/internal/runQueueWorker.d.ts +4 -4
  249. package/dist/server/internal/runQueueWorker.d.ts.map +1 -1
  250. package/dist/server/internal/runQueueWorker.js +5 -5
  251. package/dist/server/internal/runQueueWorker.js.map +1 -1
  252. package/dist/server/internal/storedRows.d.ts +2 -2
  253. package/dist/server/internal/storedRows.d.ts.map +1 -1
  254. package/dist/server/internal/storedRows.js +2 -2
  255. package/dist/server/internal/storedRows.js.map +1 -1
  256. package/dist/server/internal/testingIdle.d.ts +4 -3
  257. package/dist/server/internal/testingIdle.d.ts.map +1 -1
  258. package/dist/server/internal/testingIdle.js +5 -25
  259. package/dist/server/internal/testingIdle.js.map +1 -1
  260. package/dist/server/internal/testingOperation.d.ts +5 -0
  261. package/dist/server/internal/testingOperation.d.ts.map +1 -0
  262. package/dist/server/internal/testingOperation.js +12 -0
  263. package/dist/server/internal/testingOperation.js.map +1 -0
  264. package/dist/server/internal/testingSchedules.d.ts +9 -6
  265. package/dist/server/internal/testingSchedules.d.ts.map +1 -1
  266. package/dist/server/internal/testingSchedules.js +14 -9
  267. package/dist/server/internal/testingSchedules.js.map +1 -1
  268. package/dist/server/internal/testingWaits.d.ts +12 -8
  269. package/dist/server/internal/testingWaits.d.ts.map +1 -1
  270. package/dist/server/internal/testingWaits.js +6 -7
  271. package/dist/server/internal/testingWaits.js.map +1 -1
  272. package/dist/server/internal/tracing.d.ts +2 -2
  273. package/dist/server/internal/tracing.d.ts.map +1 -1
  274. package/dist/server/internal/tracing.js.map +1 -1
  275. package/dist/server/internal/validateQueueNames.d.ts +2 -2
  276. package/dist/server/internal/validateQueueNames.d.ts.map +1 -1
  277. package/dist/server/internal/validateQueueNames.js +1 -1
  278. package/dist/server/internal/validateQueueNames.js.map +1 -1
  279. package/dist/server/internal/waitForBatchExpiry.d.ts +4 -4
  280. package/dist/server/internal/waitForBatchExpiry.d.ts.map +1 -1
  281. package/dist/server/internal/waitForBatchExpiry.js +1 -1
  282. package/dist/server/internal/waitForBatchExpiry.js.map +1 -1
  283. package/dist/server/job.d.ts +42 -0
  284. package/dist/server/job.d.ts.map +1 -0
  285. package/dist/server/job.js +2 -0
  286. package/dist/server/job.js.map +1 -0
  287. package/dist/server/jobModule.d.ts +6 -4
  288. package/dist/server/jobModule.d.ts.map +1 -1
  289. package/dist/server/jobModule.js +7 -5
  290. package/dist/server/jobModule.js.map +1 -1
  291. package/dist/server/queueOptions.d.ts +19 -0
  292. package/dist/server/queueOptions.d.ts.map +1 -0
  293. package/dist/server/queueOptions.js +2 -0
  294. package/dist/server/queueOptions.js.map +1 -0
  295. package/dist/server/readJobFailure.d.ts +5 -0
  296. package/dist/server/readJobFailure.d.ts.map +1 -0
  297. package/dist/server/readJobFailure.js +8 -0
  298. package/dist/server/readJobFailure.js.map +1 -0
  299. package/dist/server/schema.d.ts +1 -1
  300. package/dist/server/schema.d.ts.map +1 -1
  301. package/dist/server/schema.js +23 -7
  302. package/dist/server/schema.js.map +1 -1
  303. package/dist/server/service.d.ts +17 -12
  304. package/dist/server/service.d.ts.map +1 -1
  305. package/dist/server/service.js +19 -27
  306. package/dist/server/service.js.map +1 -1
  307. package/dist/server/testing.d.ts +63 -67
  308. package/dist/server/testing.d.ts.map +1 -1
  309. package/dist/server/testing.js +5 -97
  310. package/dist/server/testing.js.map +1 -1
  311. package/dist/server/workerOptions.d.ts +25 -0
  312. package/dist/server/workerOptions.d.ts.map +1 -0
  313. package/dist/server/workerOptions.js +2 -0
  314. package/dist/server/workerOptions.js.map +1 -0
  315. package/package.json +11 -16
  316. package/src/display.ts +12 -0
  317. package/src/server/ClientDatabase.ts +7 -0
  318. package/src/server/PgBoss.ts +2 -2
  319. package/src/server/adapters/batchClockOffset.ts +8 -5
  320. package/src/server/{internal → adapters}/batchHandler.ts +13 -13
  321. package/src/server/{internal → adapters}/clientCache.ts +10 -22
  322. package/src/server/adapters/clientErrorLogger.ts +1 -1
  323. package/src/server/{defaultClientFactory.ts → adapters/defaultClientFactory.ts} +4 -2
  324. package/src/server/adapters/deferralCount.ts +5 -5
  325. package/src/server/{internal → adapters}/expireAttempt.ts +4 -3
  326. package/src/server/adapters/inspection.ts +31 -0
  327. package/src/server/adapters/inspectionChanges.ts +31 -0
  328. package/src/server/adapters/inspectionDeferrals.ts +20 -0
  329. package/src/server/adapters/inspectionJobs.ts +28 -0
  330. package/src/server/adapters/inspectionOperation.ts +6 -0
  331. package/src/server/adapters/inspectionPlan.ts +21 -0
  332. package/src/server/adapters/inspectionReads.ts +55 -0
  333. package/src/server/{internal/testingSnapshot.ts → adapters/inspectionSnapshot.ts} +16 -18
  334. package/src/server/adapters/installSchema.ts +2 -2
  335. package/src/server/adapters/jobEngine.ts +55 -0
  336. package/src/server/adapters/lifecycle.ts +67 -0
  337. package/src/server/adapters/listJobs.ts +43 -0
  338. package/src/server/adapters/payloadIdentity.ts +15 -0
  339. package/src/server/adapters/queueAdministration.ts +47 -0
  340. package/src/server/{internal/testingSignal.ts → adapters/queueSignal.ts} +1 -1
  341. package/src/server/adapters/registerWorker.ts +17 -12
  342. package/src/server/adapters/retireJobs.ts +5 -5
  343. package/src/server/adapters/schemaIndexBuilds.ts +2 -2
  344. package/src/server/{internal → adapters}/settleDeferral.ts +5 -5
  345. package/src/server/{internal → adapters}/testingClient.ts +24 -40
  346. package/src/server/adapters/testingController.ts +125 -0
  347. package/src/server/adapters/testingDueNow.ts +5 -5
  348. package/src/server/adapters/testingEngine.ts +15 -0
  349. package/src/server/adapters/testingExpirations.ts +6 -4
  350. package/src/server/adapters/testingInspectionClient.ts +70 -0
  351. package/src/server/adapters/transactionDb.ts +2 -2
  352. package/src/server/client.ts +86 -30
  353. package/src/server/clientOptions.ts +80 -0
  354. package/src/server/defineSchedule.ts +3 -2
  355. package/src/server/definition.ts +38 -29
  356. package/src/server/engineClient.ts +22 -0
  357. package/src/server/enqueueOptions.ts +25 -0
  358. package/src/server/error.ts +18 -2
  359. package/src/server/health.ts +2 -2
  360. package/src/server/inspection.ts +50 -0
  361. package/src/server/internal/acquireClient.ts +26 -0
  362. package/src/server/internal/adapters/testingFetches.ts +2 -2
  363. package/src/server/internal/clientErrors.ts +1 -1
  364. package/src/server/internal/countsFor.ts +5 -5
  365. package/src/server/internal/deadLetterResolutionPlan.ts +1 -1
  366. package/src/server/internal/deadlineOf.ts +2 -2
  367. package/src/server/internal/deferrableAttempt.ts +5 -22
  368. package/src/server/internal/deferral.ts +2 -4
  369. package/src/server/internal/deferralStorePlan.ts +2 -2
  370. package/src/server/internal/definitionOptions.ts +1 -1
  371. package/src/server/internal/engine.ts +35 -0
  372. package/src/server/internal/enqueueFor.ts +19 -6
  373. package/src/server/internal/ensureQueue.ts +5 -6
  374. package/src/server/internal/healthFor.ts +4 -4
  375. package/src/server/internal/jobControl.ts +15 -50
  376. package/src/server/internal/jobListings.ts +85 -0
  377. package/src/server/internal/jobStorePlans.ts +4 -3
  378. package/src/server/internal/lifecycle.ts +14 -55
  379. package/src/server/internal/makeService.ts +24 -15
  380. package/src/server/internal/register.ts +8 -12
  381. package/src/server/internal/registerReleasedJobs.ts +5 -5
  382. package/src/server/internal/retryWake.ts +3 -3
  383. package/src/server/internal/runQueueWorker.ts +8 -8
  384. package/src/server/internal/storedRows.ts +3 -3
  385. package/src/server/internal/testingIdle.ts +8 -31
  386. package/src/server/internal/testingOperation.ts +18 -0
  387. package/src/server/internal/testingSchedules.ts +29 -17
  388. package/src/server/internal/testingWaits.ts +16 -16
  389. package/src/server/internal/tracing.ts +2 -2
  390. package/src/server/internal/validateQueueNames.ts +2 -2
  391. package/src/server/internal/waitForBatchExpiry.ts +4 -4
  392. package/src/server/job.ts +42 -0
  393. package/src/server/jobModule.ts +19 -7
  394. package/src/server/queueOptions.ts +20 -0
  395. package/src/server/readJobFailure.ts +12 -0
  396. package/src/server/schema.ts +23 -7
  397. package/src/server/service.ts +43 -44
  398. package/src/server/testing.ts +4 -117
  399. package/src/server/workerOptions.ts +28 -0
  400. package/dist/server/defaultClientFactory.d.ts +0 -3
  401. package/dist/server/defaultClientFactory.d.ts.map +0 -1
  402. package/dist/server/defaultClientFactory.js.map +0 -1
  403. package/dist/server/internal/batchHandler.d.ts +0 -5
  404. package/dist/server/internal/batchHandler.d.ts.map +0 -1
  405. package/dist/server/internal/batchHandler.js.map +0 -1
  406. package/dist/server/internal/clientCache.d.ts +0 -8
  407. package/dist/server/internal/clientCache.d.ts.map +0 -1
  408. package/dist/server/internal/clientCache.js.map +0 -1
  409. package/dist/server/internal/expireAttempt.d.ts +0 -3
  410. package/dist/server/internal/expireAttempt.d.ts.map +0 -1
  411. package/dist/server/internal/listJobs.d.ts +0 -5
  412. package/dist/server/internal/listJobs.d.ts.map +0 -1
  413. package/dist/server/internal/listJobs.js +0 -75
  414. package/dist/server/internal/listJobs.js.map +0 -1
  415. package/dist/server/internal/observeTestingSettlements.d.ts +0 -6
  416. package/dist/server/internal/observeTestingSettlements.d.ts.map +0 -1
  417. package/dist/server/internal/observeTestingSettlements.js +0 -35
  418. package/dist/server/internal/observeTestingSettlements.js.map +0 -1
  419. package/dist/server/internal/settleDeferral.d.ts +0 -7
  420. package/dist/server/internal/settleDeferral.d.ts.map +0 -1
  421. package/dist/server/internal/settleDeferral.js.map +0 -1
  422. package/dist/server/internal/testingClient.d.ts +0 -13
  423. package/dist/server/internal/testingClient.d.ts.map +0 -1
  424. package/dist/server/internal/testingClient.js.map +0 -1
  425. package/dist/server/internal/testingDeferrals.d.ts +0 -10
  426. package/dist/server/internal/testingDeferrals.d.ts.map +0 -1
  427. package/dist/server/internal/testingDeferrals.js +0 -15
  428. package/dist/server/internal/testingDeferrals.js.map +0 -1
  429. package/dist/server/internal/testingReadout.d.ts +0 -44
  430. package/dist/server/internal/testingReadout.d.ts.map +0 -1
  431. package/dist/server/internal/testingReadout.js +0 -13
  432. package/dist/server/internal/testingReadout.js.map +0 -1
  433. package/dist/server/internal/testingRegistrations.d.ts +0 -4
  434. package/dist/server/internal/testingRegistrations.d.ts.map +0 -1
  435. package/dist/server/internal/testingRegistrations.js +0 -8
  436. package/dist/server/internal/testingRegistrations.js.map +0 -1
  437. package/dist/server/internal/testingSignal.d.ts.map +0 -1
  438. package/dist/server/internal/testingSignal.js.map +0 -1
  439. package/dist/server/internal/testingSnapshot.d.ts +0 -6
  440. package/dist/server/internal/testingSnapshot.d.ts.map +0 -1
  441. package/dist/server/internal/testingSnapshot.js.map +0 -1
  442. package/src/server/internal/listJobs.ts +0 -116
  443. package/src/server/internal/observeTestingSettlements.ts +0 -36
  444. package/src/server/internal/testingDeferrals.ts +0 -22
  445. package/src/server/internal/testingReadout.ts +0 -19
  446. package/src/server/internal/testingRegistrations.ts +0 -10
  447. /package/dist/server/{defaultClientFactory.js → adapters/defaultClientFactory.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.32.0 - 2026-11-03
4
+
5
+ ### Added
6
+
7
+ - Expose `PgBossInspection` for stored jobs, deferrals, expiry, queue diagnostics and scoped PostgreSQL queue-change signals. Jobs runtimes also expose the service through `inspection()`.
8
+ - Refresh cached queue statistics through `testing.refreshQueueStats(queue?)` before reading health.
9
+ - Read and await jobs with null payloads through `testing.jobs({ name, schema: Schema.Null })` and `testing.untilJob`.
10
+ - Queues accept `id: ["field", ...]` to derive deterministic UUIDs from the queue name and typed scalar payload parts. Repeated parts deduplicate while pg-boss retains the job. Enqueueing rejects conflicting IDs owned by a queue definition.
11
+
12
+ ### Changed
13
+
14
+ - The testing controller reads through inspection and waits on committed queue changes, including work done by another client, without production testing hooks or private settlement spies.
15
+
16
+ ### Fixed
17
+
18
+ - Apply testing expiry controls to triggered schedule runs.
19
+
20
+ ### Breaking
21
+
22
+ - Import `SnapshotQueue` and `UnfinishedJob` from `@shivaedev/jobs/server/inspection.ts` instead of `server/testing.ts`.
23
+ - Remove `__test__enableSpies` from client options. Replace `EngineClient.getSpy` waits with inspection `changes()`. Replace `getJobById(name, id)` with `storedJobs({ name }, { id })`, taking the first result; missing jobs return an empty array.
24
+ - `testing.trigger(schedule)` returns the run ID, or null when pg-boss suppresses the send, instead of void. Consumers that require an `Effect<void>` should apply `Effect.asVoid` to the result.
25
+ - Replace singleton `key: (payload) => string` callbacks with `key: ["field", ...]`, naming required string, number, boolean or null fields in the decoded payload schema. Use `key: []` for a queue-wide singleton key. To preserve application-specific normalization, put the normalized value in a payload field and name it as a part. Derived singleton key strings use typed tuples; drain existing singleton work before switching producers and workers together so old and new keys do not run concurrently.
26
+
27
+ ## 0.31.0 - 2026-11-03
28
+
29
+ ### Added
30
+
31
+ - Expose `readJobFailure` to read direct or wrapped pg-boss failures as sanitized `JobFailure | null` values, failing with `PgBossPayloadError` for invalid stored output.
32
+ - `linkedWorkerSpans(sender, spans)` in jobs testing returns recorded pg-boss worker spans linked to the sender's trace and span IDs, including retry attempts.
33
+ - Add `unschedule`, `deleteQueue` and `refreshQueueStats` to the jobs service so applications can administer queues through their owned client. Missing queues and schedule registrations fail with `PgBossNotFoundError`; engine failures retain the operation in `PgBossError`.
34
+ - Queues and schedules accept display labels, and queues declare subject columns whose fields come from the decoded payload schema.
35
+ - `jobModule` derives a module's queue declarations and worker Layer from its registrations.
36
+
37
+ ### Fixed
38
+
39
+ - Share the failure readout across job details, failed listings and dead-letter source failures, preserving native timeout messages and tags while redacting secrets and removing diagnostic fields.
40
+ - Keep testing expiry failures in the Effect error channel as `PgBossTestingError`, with the original failure and queue retained.
41
+ - The pg-boss schema readiness check reports missing deferral tables, cleanup indexes, functions and triggers even when the pg-boss version is current. Its pending detail names the missing artifacts.
42
+ - Release the jobs engine client when acquisition is interrupted, including pending shared-client acquisitions. Keep the client alive until its final owning Scope closes.
43
+ - Log a tagged shutdown error when cleanup after a failed startup also fails, while preserving the startup error for callers.
44
+ - Preserve job module queue payload schemas and their Effect service requirements when composing queue inventories.
45
+
46
+ ### Breaking
47
+
48
+ - Public declarations use jobs-owned types, including adapter and testing signatures. Replace pg-boss `WorkOptions`, `SendOptions`, `ScheduleOptions`, `ConstructorOptions`, `StopOptions`, `FindJobsOptions` and `JobWithMetadata` annotations with `WorkerOptions` from `@shivaedev/jobs/server/workerOptions.ts`, `EnqueueOptions` and `ScheduleOptions` from `@shivaedev/jobs/server/enqueueOptions.ts`, `ClientOptions` and `StopOptions` from `@shivaedev/jobs/server/clientOptions.ts`, `JobReadOptions` from `@shivaedev/jobs/server/client.ts`, and `Job` from `@shivaedev/jobs/server/job.ts`. `JobState` is declared in `@shivaedev/jobs/server/job.ts`; job reads explicitly allow null `startedOn` and `output` values, which callers must handle before dereferencing. Database adapters use `ClientDatabase` from `@shivaedev/jobs/server/ClientDatabase.ts`; decode their unknown row values before use.
49
+ - Move `QueueOptions` and `QueuePolicy` imports from `@shivaedev/jobs/server/definition.ts` to `@shivaedev/jobs/server/queueOptions.ts`. The previous module no longer exports those names. Move `batchHandler` imports from `@shivaedev/jobs/server/internal/batchHandler.ts` to its engine adapter at `@shivaedev/jobs/server/adapters/batchHandler.ts`.
50
+ - `defaultClientFactory` returns the jobs-owned `EngineClient` contract from `@shivaedev/jobs/server/engineClient.ts`. Code needing additional engine methods must own a pg-boss client in its custom factory. Constructor OpenTelemetry options support `enabled` and `propagateContext`; configure custom OpenTelemetry providers on the client inside that factory.
51
+ - Import `defaultClientFactory` from `@shivaedev/jobs/server/adapters/defaultClientFactory.ts` instead of `@shivaedev/jobs/server/defaultClientFactory.ts`. Its signature and the public jobs types are unchanged.
52
+
3
53
  ## 0.30.0 - 2026-11-02
4
54
 
5
55
  ### Fixed
package/README.md CHANGED
@@ -77,6 +77,21 @@ With the second argument, every `Jobs.layer({ jobs })` checks its registrations
77
77
 
78
78
  Declare names per jobs service, so producer and worker Layers share a declaration when they register the same queues. Keep worker-only schedules in their own service when producers do not register them. Import only the browser-safe declaration module from client code; `defineQueue`, `defineSchedule` and `makePgBoss` stay on the server.
79
79
 
80
+ ### Label queues and identify jobs
81
+
82
+ Queue and schedule definitions accept an optional `label`. A queue's `subject` declares display columns by naming fields in its decoded payload Schema:
83
+
84
+ ```ts
85
+ const SendEmail = defineQueue({
86
+ name: "send-email",
87
+ label: "Email delivery",
88
+ schema: Schema.Struct({ userId: Schema.NumberFromString }),
89
+ subject: [{ field: "userId", label: "Recipient" }],
90
+ });
91
+ ```
92
+
93
+ `subject` fields are checked against the Schema's decoded keys. Keep labels and columns beside the name and Schema in the browser-safe declaration when using the admin Jobs view, then spread that declaration into `defineQueue`. The browser-safe types `QueueDisplay` and `SubjectColumn<PayloadSchema>` come from `@shivaedev/jobs/display.ts`. Pass the declarations to the admin page and view to show their labels and subjects. Subject columns read the masked inspection payload, so native `Redacted` values and sensitive keys stay masked in failed and dead-letter lists. Dead-letter copies stay with the source queue and use its columns. Definitions without labels display their internal names.
94
+
80
95
  ### Once per database: install the schema
81
96
 
82
97
  For an application on the app host of `@shivaedev/server`, register `pgBossSchema` beside the migration loader. The host's `migrate` mode installs or upgrades it after committing the application ledger. Its `check` and `wait` modes include pg-boss readiness in the same check as the numbered migrations.
@@ -207,7 +222,7 @@ const Compare = defineQueue({
207
222
  });
208
223
  ```
209
224
 
210
- This worker runs up to five handlers at once. `worker` accepts pg-boss 12's `WorkOptions`, including `batchSize`, `localConcurrency`, `pollingIntervalSeconds`, `notifyPollingIntervalSeconds` and the burst options. Explicit options override the adapter defaults. pg-boss ignores `burstWhenBatchFull` at `batchSize: 1`; keep a batch size of at least two for immediate backlog draining. Each job is settled separately through pg-boss: success completes that job, and a typed failure, payload decoding failure or defect fails only that job with its own error. A failed job does not spend the retries of other jobs in its batch or rerun their successful handlers. Interruption stops the batch and leaves the interrupted and remaining jobs to pg-boss expiry; handlers must still tolerate repeated side effects across retries and interrupted attempts.
225
+ This worker runs up to five handlers at once. `worker` accepts jobs' `WorkerOptions`, including `batchSize`, `localConcurrency`, `pollingIntervalSeconds`, `notifyPollingIntervalSeconds` and the burst options. Explicit options override the adapter defaults. pg-boss ignores `burstWhenBatchFull` at `batchSize: 1`; keep a batch size of at least two for immediate backlog draining. Each job is settled separately through pg-boss: success completes that job, and a typed failure, payload decoding failure or defect fails only that job with its own error. A failed job does not spend the retries of other jobs in its batch or rerun their successful handlers. Interruption stops the batch and leaves the interrupted and remaining jobs to pg-boss expiry; handlers must still tolerate repeated side effects across retries and interrupted attempts.
211
226
 
212
227
  Apps do not need to shorten the polling backstop to drain a backlog. With `notify: true` and an active LISTEN/NOTIFY listener, pg-boss wakes workers on notifications and defaults to a 30-second backstop (`notifyPollingIntervalSeconds`). Without active notifications its base poll defaults to two seconds (`pollingIntervalSeconds`). Bursting takes precedence over both intervals. After an adapter worker fails or defers a job, it reads pg-boss's stored retry time and schedules a wake for every native worker in its registration at that time, so an idle sibling can retry while another worker is busy. The wake accounts for differences between the runtime and PostgreSQL clocks. The wake, including its retry-time read, belongs to the worker Layer's scope and is canceled when that scope closes. Wake failures are logged with redacted diagnostics and do not fail the batch. Override the backstop when the application needs a different bound for other work that becomes runnable without a notification, such as delayed jobs or retries initiated outside the adapter worker.
213
228
 
@@ -245,19 +260,37 @@ const PullRequestJobs = defineQueue({
245
260
  Schema.TaggedStruct("Reconcile", { pullRequestId: Schema.NumberFromString }),
246
261
  ]),
247
262
  queue: { policy: "singleton" },
248
- key: ({ pullRequestId }) => `pr:${pullRequestId.toFixed(0)}`,
263
+ key: ["pullRequestId"],
249
264
  worker: { batchSize: 1, localConcurrency: 3 },
250
265
  });
251
266
 
252
267
  const refresh = Effect.flatMap(Jobs, (jobs) => jobs.enqueue(PullRequestJobs, { _tag: "Refresh", pullRequestId: 42 }));
253
268
  ```
254
269
 
255
- `queue.policy` accepts pg-boss's policy literals and rejects typos. The `singleton` policy requires `key: (payload) => string`. The callback sees the decoded payload, so `pullRequestId` is a number. `enqueue` supplies pg-boss's `singletonKey` automatically; callers cannot supply a conflicting key in send options.
270
+ `queue.policy` accepts pg-boss's policy literals and rejects typos. The `singleton` policy requires `key: ["field", ...]`. Each part names a required scalar field in the decoded payload schema, so `pullRequestId` contributes its numeric value. `enqueue` supplies pg-boss's `singletonKey` automatically; callers cannot supply a conflicting key in send options.
256
271
 
257
272
  PostgreSQL guarantees one active job per key across workers, including different job kinds in this queue. Different keys can run in parallel when workers have capacity. A job waiting to retry frees its key for another job; exhausting retries sends it to the dead-letter queue and leaves the key available.
258
273
 
259
274
  Singleton guarantees one active job per key, not order. Ordering stays the application's job. Keep handlers idempotent and write state only when the source is newer than what is stored, so an older event or retry cannot overwrite newer state.
260
275
 
276
+ ### Deterministic job IDs
277
+
278
+ Declare the payload fields that identify a job:
279
+
280
+ ```ts
281
+ const Revisions = defineQueue({
282
+ name: "revisions",
283
+ schema: Schema.Struct({ tenant: Schema.String, revision: Schema.NumberFromString, note: Schema.String }),
284
+ id: ["tenant", "revision"],
285
+ key: ["tenant"],
286
+ queue: { policy: "singleton" },
287
+ });
288
+ ```
289
+
290
+ `id` derives a deterministic UUID from the queue name and its ordered payload parts. Enqueuing the same parts again returns `None` while pg-boss retains that job, even if other fields change. Different queue names have separate identities. Here, different revisions create separate jobs while sharing the tenant's singleton key. Callers cannot pass an `id` or `singletonKey` that the queue owns.
291
+
292
+ Both declarations accept fields whose decoded values are strings, numbers, booleans or null. Parts preserve value types and field boundaries, including separators in strings. An empty list gives every payload the same identity within the queue. Omit `id` to keep pg-boss's generated IDs or caller-supplied IDs. Identity is separate from tracing metadata.
293
+
261
294
  ### Size batches against expiry
262
295
 
263
296
  pg-boss marks every job in a fetched batch active together. Each job's expiry window starts at its stored `startedOn`, including time waiting for earlier handlers. Size each queue's batch so its sequential work fits within that window; use a small batch for long-running work and keep the default for short work:
@@ -387,6 +420,24 @@ export const readJobCounts = Effect.gen(function* () {
387
420
 
388
421
  `health([{ name: "cleanup-mail" }])` reads only the supplied queues, in order, even when another runtime registered them. Omitting the argument keeps the Layer's registered names. Admin pages use this to include worker-only schedules without registering those schedules in the request runtime.
389
422
 
423
+ ### Inspect stored work
424
+
425
+ `PgBossInspection` from `@shivaedev/jobs/server/inspection.ts` exposes the shared read service used by admin pages and the testing controller. Provide `PgBossInspection.layer` with your `pgBossLayer`, or obtain the same reads from a configured jobs runtime with `yield* jobs.inspection()`.
426
+
427
+ `storedJobs(queue, options?)` reads native stored metadata and encoded payloads. `jobs(queue, options?)` decodes stored payloads through the supplied queue Schema and includes native state, `startAfter`, `expireInSeconds`, `startedOn` and `keepUntil`. These reads include unredacted payloads; keep them inside trusted server code. The admin-facing `getJob`, `failedJobs` and `deadLetteredJobs` reads retain their payload redaction. `deferred(queue)` reads stored RetryAt reasons and requested times, while `snapshot(queues)` lists unfinished work with future RetryAt attempts marked `deferred`. `counts`, `health`, `queue`, `schedules`, `schemaVersion` and `busy` serve queue diagnostics and controller readouts.
428
+
429
+ `changes(queue?)` acquires a scoped PostgreSQL listener and returns `revision` and `waitForChange(after)`. Capture its revision before reading, then wait against that revision to avoid missing a change between the read and the wait. The signal wakes for committed job changes from any client, optionally filtered to one queue. It is a hint to read again, not a durable event log. The caller owns the listener's scope.
430
+
431
+ Automatic migration and `installPgBossSchema` install the queue-change trigger. Applications using `migrate: false` run `installPgBossSchema` before using change signals. Custom clients need `getDb().listen` to subscribe.
432
+
433
+ ### Administer queues and schedules
434
+
435
+ `unschedule(schedule)` removes the registration named by the schedule definition and its `scheduleOptions.key` (the empty key by default). Other keys for that queue stay registered. A missing registration fails with `PgBossNotFoundError`, carrying `operation: "unschedule"`, `queue` and `key`.
436
+
437
+ `deleteQueue(queue)` stops local workers for that name and deletes the queue through the owned client. Other queues stay in place. A missing queue fails with `PgBossNotFoundError` with `operation: "deleteQueue"` and `queue`; a native refusal, such as deleting a dead-letter queue still in use, fails with `PgBossError`.
438
+
439
+ `refreshQueueStats(queue?)` requests a native pg-boss supervisor pass for one queue, or all queues when omitted, so `health` can read refreshed counts. The pass also performs native queue maintenance and respects pg-boss's monitor intervals and backoff; it does not promise a fresh snapshot on every call. Use `counts` for an immediate live read.
440
+
390
441
  ### Read live counts and retry a job
391
442
 
392
443
  ```ts
@@ -408,7 +459,7 @@ export const inspectEmail = (id: string) =>
408
459
 
409
460
  `counts(queue)` reads the job table directly on each call. `queuedCount` includes created and retry-waiting jobs, including future jobs; `activeCount` counts running jobs, `failedCount` counts retained failures, and `totalCount` includes retained terminal jobs. A queue has drained when queued and active counts are both zero. These counts are a snapshot, so a producer can enqueue more work after the query returns.
410
461
 
411
- `getJob(queue, id)` returns `None` when the ID is absent, or `Some` pg-boss job metadata with masked inspection `data: unknown`. The queue's Schema decodes the stored payload before the errors package's redactor masks native `Redacted` values and sensitive keys, including nested objects and arrays. Invalid stored data fails with `PgBossPayloadError`, and the Effect requires the Schema's decoding services. `retry(queue, id)` reuses the original ID: it makes a failed job eligible for another attempt and pulls a retry-waiting job forward to run now. Missing IDs and jobs in other states are left unchanged. Its dead-letter copies stay listed while the retry is pending or fails again; a successful completion removes those copies in the same database transaction.
462
+ `getJob(queue, id)` returns `None` when the ID is absent, or `Some` jobs-owned `Job<unknown>` metadata with masked inspection `data: unknown`. The queue's Schema decodes the stored payload before the errors package's redactor masks native `Redacted` values and sensitive keys, including nested objects and arrays. Invalid stored data fails with `PgBossPayloadError`, and the Effect requires the Schema's decoding services. `retry(queue, id)` reuses the original ID: it makes a failed job eligible for another attempt and pulls a retry-waiting job forward to run now. Missing IDs and jobs in other states are left unchanged. Its dead-letter copies stay listed while the retry is pending or fails again; a successful completion removes those copies in the same database transaction.
412
463
 
413
464
  ### List failed and dead-lettered jobs
414
465
 
@@ -434,7 +485,9 @@ export const failedEmails = (cursor?: string) =>
434
485
 
435
486
  Each page holds at most `limit` jobs, newest first by creation time; a dead-letter copy is created when its original fails for good. `limit` must be a positive integer. When more jobs remain, `next` is `Some` opaque cursor; pass it back as `cursor` for the following page, and stop when `next` is `None`. Paging continues from the last job it returned, so jobs that fail while you page appear in a fresh listing instead of shifting later pages, and no job appears twice. A malformed cursor or limit fails with `SchemaError` before pg-boss is called.
436
487
 
437
- An entry carries the job's `id`, `queue`, native `state`, `retryCount`, `retryLimit` and `attempt`, the one-based number of its last started attempt (zero for a job that never started). `createdOn` is a UTC `DateTime`; `startedOn` and `completedOn` are `Option`s of UTC `DateTime`s. `output` is `JobFailure | null`, decoded through `JobFailure` from `@shivaedev/jobs/JobFailure.ts`. Handler failures store only `{ _tag: string, message: string }`, with the message redacted through `@shivaedev/errors`; stack traces, cause chains and other error fields are omitted. `null` means pg-boss stored no output. Native pg-boss failures without a tag decode with `_tag: "Error"`; decoding also redacts messages from older stored failures. Stored output that does not match the Schema fails the listing with `PgBossPayloadError`. `data: unknown` is decoded by the queue's JSON codec and masked through the errors package's redactor, including traced payloads; invalid stored data fails the listing with `PgBossPayloadError`, as `getJob` does, and the Effect requires the Schema's decoding services. A dead-letter entry adds `sourceQueue`, the source queue name without the dead-letter suffix, `sourceId`, the original job's ID as an `Option`, and `sourceOutput`, the original's decoded `JobFailure | null`. The copy has not run, so its own `output` stays `null` and its `attempt` is zero.
488
+ An entry carries the job's `id`, `queue`, native `state`, `retryCount`, `retryLimit` and `attempt`, the one-based number of its last started attempt (zero for a job that never started). `createdOn` is a UTC `DateTime`; `startedOn` and `completedOn` are `Option`s of UTC `DateTime`s. `output` is `JobFailure | null`, decoded through `JobFailure` from `@shivaedev/jobs/JobFailure.ts`. Handler failures store only `{ _tag: string, message: string }`, with the message redacted through `@shivaedev/errors`; stack traces, cause chains and other error fields are omitted. `null` means pg-boss stored no output. Direct failures and native pg-boss failures wrapped in `{ value: failure }` share the same sanitized readout in details and listings. Failures without a tag decode with `_tag: "Error"`; decoding also redacts messages from older stored failures. Stored output that does not match the Schema fails the listing with `PgBossPayloadError`. `data: unknown` is decoded by the queue's JSON codec and masked through the errors package's redactor, including traced payloads; invalid stored data fails the listing with `PgBossPayloadError`, as `getJob` does, and the Effect requires the Schema's decoding services. A dead-letter entry adds `sourceQueue`, the source queue name without the dead-letter suffix, `sourceId`, the original job's ID as an `Option`, and `sourceOutput`, the original's decoded `JobFailure | null`. The copy has not run, so its own `output` stays `null` and its `attempt` is zero.
489
+
490
+ `readJobFailure(queue, output)` from `@shivaedev/jobs/server/readJobFailure.ts` exposes this readout for adapters. It returns an Effect with `JobFailure | null` and fails with `PgBossPayloadError` when stored output cannot be decoded.
438
491
 
439
492
  Pass a failed entry's `id` to `retry(queue, id)` to run that job again under its original ID; once it completes it leaves the failed listing and its copies leave the dead-letter listing. Dead-letter IDs belong to the `-dlq` queue, so `retry(queue, id)` does not find them and leaves them unchanged.
440
493
 
@@ -502,7 +555,7 @@ Include every target queue in `jobs`, as either a worker or a producer-only defi
502
555
 
503
556
  `linkedWorkerSpans(sender, spans)` from `@shivaedev/jobs/server/testing.ts` reads native recorded Effect spans and returns the pg-boss consumer spans whose links match both the sender's `traceId` and `spanId`. It returns every matching attempt, including retries, and no matches before a worker runs. An untraced job has no sender link. Settle the workers before reading their completed attempts; this readout does not wait or read queue storage.
504
557
 
505
- `testing.ts` gives story kits a controller for one real pg-boss client. Create a fresh controller per runtime, pass its `clientFactory` to `pgBossLayer`, and keep that Layer scoped as usual. `jobs(queue, options?)` returns native job metadata with `data` decoded through the queue's Schema, including traced payloads. Invalid durable data fails with `PgBossPayloadError`; decoding services remain in the Effect's requirements.
558
+ `testing.ts` gives story kits a controller for one real pg-boss client. Create a fresh controller per runtime, pass its `clientFactory` to `pgBossLayer`, and keep that Layer scoped as usual. `jobs(queue, options?)` returns jobs-owned `Job` metadata with `data` decoded through the queue's Schema, including traced payloads. For a scheduled run with no payload, pass `{ name: Cleanup.name, schema: Schema.Null }` to read `data: null`. Invalid durable data fails with `PgBossPayloadError`; decoding services remain in the Effect's requirements.
506
559
 
507
560
  This producer story uses the `SendEmail` definition and `Jobs` service from above. `databaseUrl` points to the story's PostgreSQL database:
508
561
 
@@ -538,13 +591,15 @@ emailStories.it("decodes the queued email", [], function* ({ enqueue, testing })
538
591
 
539
592
  Set `retryPolicy: testRetryPolicy` through the controller to override queue and send settings with `retryDelay: 0` and `retryBackoff: false`. A failing worker can then exhaust its native retries without production backoff. The policy applies to subsequently sent jobs; it does not rewrite jobs already stored.
540
593
 
541
- `schedules()` lists registered schedules as `{ name, cron, timezone }` entries from PostgreSQL. `trigger(schedule)` takes a schedule definition, such as `Cleanup`, and enqueues one run now using its stored schedule data and options. Register `Cleanup.run(effect)` in the testing Layer first, then yield `testing.trigger(Cleanup)` and `testing.waitForIdle` before observing the Effect's result. An unregistered schedule fails with `PgBossTestingError` (`operation: "trigger"`).
594
+ `schedules()` lists registered schedules as `{ name, cron, timezone }` entries from PostgreSQL. `trigger(schedule)` takes a schedule definition, such as `Cleanup`, and enqueues one run now using its stored schedule data and options. It returns the run ID, or null when pg-boss suppresses the send. Register `Cleanup.run(effect)` in the testing Layer first, then yield `testing.trigger(Cleanup)` and `testing.waitForIdle` before observing the Effect's result. An unregistered schedule fails with `PgBossTestingError` (`operation: "trigger"`).
595
+
596
+ `refreshQueueStats(queue?)` requests a native pg-boss supervisor pass for one queue, or all queues when omitted, before reading cached counts through the jobs service's `health`. Like the service method, it performs native queue maintenance and respects pg-boss monitor intervals and backoff.
542
597
 
543
598
  `failNextSend(queue)` arms one send failure for that queue. The next valid `enqueue` fails with the usual typed `PgBossError` (`operation: "enqueue"`); the following send proceeds normally.
544
599
 
545
600
  `expireAfter(queue, n)` takes a positive attempt count: configure it before enqueueing to limit subsequent jobs to `n` attempts. Each successful send keeps its own expiry rule; later changes and duplicate-ID sends do not alter pending jobs. Earlier attempts run the handler normally; on attempt `n`, the controller expires the claimed job instead of invoking its handler. PostgreSQL supervision performs the terminal failure and dead lettering. A job that succeeds earlier completes normally.
546
601
 
547
- `expireIn(queue, duration)` takes an Effect `Duration.Input`, such as `"1 second"`, and sets the expiry of subsequent sends, rounded up to whole seconds. Durations below one second or nonfinite durations fail with `PgBossTestingError` (`operation: "expireIn"`). Earlier sends retain their expiry, and later calls and duplicate-ID sends do not change stored jobs. It can be combined with `expireAfter`: one sets each attempt's time budget, the other limits attempts. A stuck handler is interrupted at its deadline, and the same worker can fetch its retry after pg-boss fails the attempt. The testing expiry hooks support pg-boss schema version 46.
602
+ `expireIn(queue, duration)` takes an Effect `Duration.Input`, such as `"1 second"`, and sets the expiry of subsequent sends, rounded up to whole seconds. Durations below one second or nonfinite durations fail with `PgBossTestingError` (`operation: "expireIn"`). Earlier sends retain their expiry, and later calls and duplicate-ID sends do not change stored jobs. Both expiry controls also apply to runs sent by `trigger(schedule)`. It can be combined with `expireAfter`: one sets each attempt's time budget, the other limits attempts. A stuck handler is interrupted at its deadline, and the same worker can fetch its retry after pg-boss fails the attempt. The testing expiry hooks support pg-boss schema version 46.
548
603
 
549
604
  `runDueNow(queue)` makes future jobs in the queue's `created` or `retry` state due at the database's current time and wakes local workers. It includes delayed sends (`startAfter`), native retries and `RetryAt` deferrals. Yield `waitForIdle` afterwards before observing handler results; future jobs do not hold that wait open. It leaves active and terminal jobs and other queues unchanged.
550
605
 
@@ -558,7 +613,7 @@ Set `retryPolicy: testRetryPolicy` through the controller to override queue and
558
613
 
559
614
  A kit can also capture `revision` before reading jobs and yield `waitForChange(revision)` when its condition is unmet. The wait resumes after a local send, settlement or worker fetch, and when a local worker returns to idle as `waitForIdle` defines it, including terminal native worker timeouts. It also resumes immediately if a change occurred between the read and the wait. This signal observes the controller's client; external clients, future scheduled work and external database writes need their own wake source. Stories should retain a bounded test timeout.
560
615
 
561
- `untilJob(queue, id, state)` waits that way for one job: it reads the job, waits for the next change when the job is in another state, and returns the job with `data` decoded through the queue's Schema once it reaches `state`. `fetchesPass(queue, n)` completes once `n` worker fetches on the queue that began after the wait started have finished, whether or not they claimed anything, so a story can show that a job stayed untaken by fetches that could have claimed it. Each fetch also counts as a change for `waitForChange`. Both waits give up after `within` (default 20 seconds) of wall time, which a story's `TestClock` does not move, and fail with `PgBossWaitError`, whose message names what the wait expected and what it last saw:
616
+ `untilJob(queue, id, state)` waits that way for one job: it reads the job, waits for the next change when the job is in another state, and returns the job with `data` decoded through the queue's Schema once it reaches `state`. It also accepts `{ name, schema: Schema.Null }` for a triggered schedule's run. `fetchesPass(queue, n)` completes once `n` worker fetches on the queue that began after the wait started have finished, whether or not they claimed anything, so a story can show that a job stayed untaken by fetches that could have claimed it. Each fetch also counts as a change for `waitForChange`. Both waits give up after `within` (default 20 seconds) of wall time, which a story's `TestClock` does not move, and fail with `PgBossWaitError`, whose message names what the wait expected and what it last saw:
562
617
 
563
618
  ```ts
564
619
  yield* testing.untilJob(SendEmail, id, "completed", { within: "5 seconds" });
@@ -569,24 +624,33 @@ yield* testing.untilJob(SendEmail, id, "completed", { within: "5 seconds" });
569
624
 
570
625
  Import the module that defines the name; the package has no root entry.
571
626
 
572
- | Module | Public names |
573
- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
574
- | `@shivaedev/jobs/server/definition.ts` | `defineQueue`, `jobContext`, `RetryAt`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueOptions`, `QueuePolicy`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
575
- | `@shivaedev/jobs/server/service.ts` | `makePgBoss`, `pgBossLayer`; `PgBossDefinition`, `PgBossLayerOptions`, `PgBossOptions`, `PgBossService` |
576
- | `@shivaedev/jobs/server/PgBoss.ts` | `PgBoss`: the shared client Context service. |
577
- | `@shivaedev/jobs/server/schema.ts` | `installPgBossSchema`, `pgBossSchema`; `PgBossSchemaOptions` |
578
- | `@shivaedev/jobs/server/health.ts` | `deadLetterQueueName`; `DeadLetteredJob`, `JobPage`, `JobPageOptions`, `JobsHealth`, `ListedJob`, `QueueCounts`, `QueueHealth` |
579
- | `@shivaedev/jobs/server/error.ts` | `PgBossError`, `PgBossPayloadError`, `PgBossQueueNamesError`, `PgBossQueueOptionsError`, `PgBossClientOptionsError`, `PgBossTestingError`, `PgBossWaitError`, `toPgBossError`; `PgBossOperation` |
580
- | `@shivaedev/jobs/server/client.ts` | `PgBossClient`, `PgBossClientFactory` |
581
- | `@shivaedev/jobs/server/testing.ts` | `makePgBossTesting`, `testRetryPolicy`; `PgBossTesting`, `PgBossTestingOptions`, `PgBossTestingWaitOptions`, `SnapshotQueue`, `UnfinishedJob` |
582
- | `@shivaedev/jobs/server/defineSchedule.ts` | `defineSchedule` |
583
- | `@shivaedev/jobs/server/defaultClientFactory.ts` | `defaultClientFactory` |
584
-
585
- The definition options keep the pg-boss names: `queue` uses `QueueOptions` (`Queue` except `name` and `deadLetter`, with literal `QueuePolicy` values and `maxDeferrals`), `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
627
+ | Module | Public names |
628
+ | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
629
+ | `@shivaedev/jobs/display.ts` | `QueueDisplay`, `SubjectColumn` |
630
+ | `@shivaedev/jobs/server/definition.ts` | `defineQueue`, `jobContext`, `RetryAt`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `PayloadParts`, `QueueDefinition`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
631
+ | `@shivaedev/jobs/server/service.ts` | `makePgBoss`, `pgBossLayer`; `PgBossDefinition`, `PgBossLayerOptions`, `PgBossOptions`, `PgBossService` |
632
+ | `@shivaedev/jobs/server/PgBoss.ts` | `PgBoss`: the shared client Context service. |
633
+ | `@shivaedev/jobs/server/schema.ts` | `installPgBossSchema`, `pgBossSchema`; `PgBossSchemaOptions` |
634
+ | `@shivaedev/jobs/server/health.ts` | `deadLetterQueueName`; `DeadLetteredJob`, `JobPage`, `JobPageOptions`, `JobsHealth`, `ListedJob`, `QueueCounts`, `QueueHealth` |
635
+ | `@shivaedev/jobs/server/error.ts` | `PgBossError`, `PgBossNotFoundError`, `PgBossPayloadError`, `PgBossQueueNamesError`, `PgBossQueueOptionsError`, `PgBossClientOptionsError`, `PgBossTestingError`, `PgBossWaitError`, `toPgBossError`; `PgBossOperation` |
636
+ | `@shivaedev/jobs/server/queueOptions.ts` | `QueueOptions`, `QueuePolicy`, `RetryOptions` |
637
+ | `@shivaedev/jobs/server/workerOptions.ts` | `WorkerOptions`, `GroupConcurrencyConfig` |
638
+ | `@shivaedev/jobs/server/enqueueOptions.ts` | `EnqueueOptions`, `QueueEnqueueOptions`, `ScheduleOptions` |
639
+ | `@shivaedev/jobs/server/job.ts` | `Job`, `JobState`, `WorkerJob` |
640
+ | `@shivaedev/jobs/server/clientOptions.ts` | `ClientOptions`, `StopOptions`, `Clock`, `ReindexOptions`, `IndexBloatOptions` |
641
+ | `@shivaedev/jobs/server/ClientDatabase.ts` | `ClientDatabase` |
642
+ | `@shivaedev/jobs/server/engineClient.ts` | `EngineClient`, `EngineSchedule` |
643
+ | `@shivaedev/jobs/server/client.ts` | `PgBossClient`, `PgBossClientFactory` |
644
+ | `@shivaedev/jobs/server/inspection.ts` | `PgBossInspection`; `PgBossInspectionService` |
645
+ | `@shivaedev/jobs/server/testing.ts` | `makePgBossTesting`, `testRetryPolicy`; `PgBossTesting`, `PgBossTestingOptions`, `PgBossTestingWaitOptions` |
646
+ | `@shivaedev/jobs/server/defineSchedule.ts` | `defineSchedule` |
647
+ | `@shivaedev/jobs/server/adapters/defaultClientFactory.ts` | `defaultClientFactory` |
648
+
649
+ Jobs declares its public types independently of pg-boss. The option fields keep their familiar names: `queue` uses `QueueOptions`, including literal `QueuePolicy` values and `maxDeferrals`; `worker` uses `WorkerOptions`; a schedule's `schedule` uses `ScheduleOptions`; enqueueing uses `EnqueueOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
586
650
 
587
651
  Queue and scheduled workers reject `perJobResults: true` and `transactional: true` during Layer acquisition with a registration `PgBossError`; its redacted `original` names the unsupported options. Omit these options or set them to `false`. The adapter settles each job itself and does not expose pg-boss's transaction client to handlers.
588
652
 
589
- `Jobs.layer(options)` accepts pg-boss `ConstructorOptions` plus the adapter's own options. Custom clients must supply native `complete` and `fail` capabilities to register queue or schedule workers; missing settlement capabilities fail Layer acquisition with a registration `PgBossError`. Workers also require `getDb()` to read the PostgreSQL clock when a batch arrives. Producer-only clients do not need these capabilities. Custom clients can also supply the optional native capabilities `findJobs`, `retry`, `update`, `getDb` and `updateQueue` for lookup, retry, live counts and listings, deferral and reconciliation; a requested operation fails with `PgBossError` if its required capability is absent.
653
+ `pgBossLayer(options)` accepts `PgBossOptions`, built from jobs-owned `ClientOptions` with a redacted connection string and lifecycle settings. `Jobs.layer(options)` accepts registrations, retired names and `onError`. Custom clients must supply native `complete` and `fail` capabilities to register queue or schedule workers; missing settlement capabilities fail Layer acquisition with a registration `PgBossError`. Workers also require `getDb()` to read the PostgreSQL clock when a batch arrives. Producer-only clients do not need these capabilities. Custom clients can also supply the optional native capabilities `findJobs`, `retry`, `update`, `getDb` and `updateQueue` for lookup, retry, live counts and listings, deferral and reconciliation; administration uses optional `deleteQueue`, `getSchedule`, `unschedule` and `supervise` capabilities. A requested operation fails with `PgBossError` if its required capability is absent.
590
654
 
591
655
  `onError` handles pg-boss client `error` events using the services captured by the Layer. The Layer interrupts pending callbacks and waits for them to end before release completes. Only the owning jobs service is supplied automatically; a handler using another jobs definition still requires that definition's Layer.
592
656
 
@@ -0,0 +1,14 @@
1
+ import type { Schema } from "effect";
2
+ export interface SubjectColumn<TPayload extends Schema.Top> {
3
+ readonly field: Extract<keyof TPayload["Type"], string>;
4
+ readonly label: string;
5
+ }
6
+ export interface QueueDisplay {
7
+ readonly label?: string;
8
+ readonly name: string;
9
+ readonly subject?: readonly {
10
+ readonly field: string;
11
+ readonly label: string;
12
+ }[];
13
+ }
14
+ //# sourceMappingURL=display.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,WAAW,aAAa,CAAC,QAAQ,SAAS,MAAM,CAAC,GAAG;IACzD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ export interface ClientDatabase {
2
+ beginTransaction?: () => Promise<{
3
+ db: ClientDatabase;
4
+ commit: () => Promise<void>;
5
+ rollback: () => Promise<void>;
6
+ }>;
7
+ executeSql: (text: string, values?: unknown[]) => Promise<{
8
+ rows: Record<string, unknown>[];
9
+ }>;
10
+ listen?: (channel: string, onNotification: (payload: string) => void, onReconnect: () => void) => Promise<{
11
+ close: () => Promise<void>;
12
+ }>;
13
+ poolCounts?: () => {
14
+ max: number;
15
+ total: number;
16
+ idle: number;
17
+ waiting: number;
18
+ } | null;
19
+ setSessionStatements?: (statements: string[]) => Promise<void>;
20
+ }
21
+ //# sourceMappingURL=ClientDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientDatabase.d.ts","sourceRoot":"","sources":["../../src/server/ClientDatabase.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC9B,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,EAAE,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC;IACrH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAAE,CAAC,CAAC;IAC/F,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EAAE,WAAW,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC;IAC1I,UAAU,CAAC,EAAE,MAAM;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxF,oBAAoB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ClientDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientDatabase.js","sourceRoot":"","sources":["../../src/server/ClientDatabase.ts"],"names":[],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { Context } from "effect";
2
- import type { StopOptions } from "pg-boss";
3
- import type { AcquiredClient } from "#internal/lifecycle.ts";
2
+ import type { StopOptions } from "#server/clientOptions.ts";
3
+ import type { AcquiredClient } from "#server/internal/lifecycle.ts";
4
4
  declare const PgBoss_base: Context.ServiceClass<PgBoss, "@shivaedev/jobs/PgBoss", AcquiredClient & {
5
5
  readonly schema: string | undefined;
6
6
  readonly stop: StopOptions | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"PgBoss.d.ts","sourceRoot":"","sources":["../../src/server/PgBoss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;;qBAIxB,MAAM,GAAG,SAAS;mBAAiB,WAAW,GAAG,SAAS;;AAF/F,qBAAa,MAAO,SAAQ,WAGC;CAAG"}
1
+ {"version":3,"file":"PgBoss.d.ts","sourceRoot":"","sources":["../../src/server/PgBoss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;;qBAI/B,MAAM,GAAG,SAAS;mBAAiB,WAAW,GAAG,SAAS;;AAF/F,qBAAa,MAAO,SAAQ,WAGC;CAAG"}
@@ -1,4 +1,4 @@
1
1
  import { Effect } from "effect";
2
- import type { PgBossClient } from "#client.ts";
3
- export declare const batchClockOffset: (client: PgBossClient, schema: string, name: string) => Effect.Effect<number, import("#error.ts").PgBossError, never>;
2
+ import type { PgBossClient } from "#server/client.ts";
3
+ export declare const batchClockOffset: (client: PgBossClient, schema: string, name: string) => Effect.Effect<number, import("#server/error.ts").PgBossError, never>;
4
4
  //# sourceMappingURL=batchClockOffset.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batchClockOffset.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/batchClockOffset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,eAAO,MAAM,gBAAgB,uHAW3B,CAAC"}
1
+ {"version":3,"file":"batchClockOffset.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/batchClockOffset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAU,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,eAAO,MAAM,gBAAgB,8HAc3B,CAAC"}
@@ -1,6 +1,6 @@
1
- import { Clock, Effect } from "effect";
2
- import { toPgBossError } from "#error.ts";
3
- import { quotedSchema } from "#internal/storedRows.ts";
1
+ import { Clock, Effect, Schema } from "effect";
2
+ import { toPgBossError } from "#server/error.ts";
3
+ import { quotedSchema } from "#server/internal/storedRows.ts";
4
4
  export const batchClockOffset = Effect.fnUntraced(function* (client, schema, name) {
5
5
  const { rows } = yield* Effect.tryPromise({
6
6
  catch: (error) => toPgBossError("settle", error, name),
@@ -11,6 +11,7 @@ export const batchClockOffset = Effect.fnUntraced(function* (client, schema, nam
11
11
  return client.getDb().executeSql(`SELECT EXTRACT(EPOCH FROM ${quotedSchema(schema)}.job_now()) * 1000 AS now`);
12
12
  },
13
13
  });
14
- return (yield* Clock.currentTimeMillis) - Number(rows[0].now);
14
+ const row = yield* Schema.decodeUnknownEffect(Schema.Struct({ now: Schema.Union([Schema.String, Schema.Number]) }))(rows[0]).pipe(Effect.mapError((error) => toPgBossError("settle", error, name)));
15
+ return (yield* Clock.currentTimeMillis) - Number(row.now);
15
16
  });
16
17
  //# sourceMappingURL=batchClockOffset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"batchClockOffset.js","sourceRoot":"","sources":["../../../src/server/adapters/batchClockOffset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAoB,EAAE,MAAc,EAAE,IAAY;IAC9G,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QACzC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;QACtD,GAAG,EAAE,GAAG,EAAE;YACT,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;YAC/E,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,6BAA6B,YAAY,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;QAChH,CAAC;KACD,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"batchClockOffset.js","sourceRoot":"","sources":["../../../src/server/adapters/batchClockOffset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAoB,EAAE,MAAc,EAAE,IAAY;IAC9G,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QACzC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;QACtD,GAAG,EAAE,GAAG,EAAE;YACT,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;YAC/E,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,6BAA6B,YAAY,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;QAChH,CAAC;KACD,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAChI,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAChE,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Effect } from "effect";
2
+ import type { PgBossClient } from "#server/client.ts";
3
+ import type { WorkerJob } from "#server/job.ts";
4
+ export declare function batchHandler<R>(client: PgBossClient, name: string, schema: string, run: (job: WorkerJob<unknown>, deadline: number) => Effect.Effect<unknown, unknown, R>, afterRetry?: (job: WorkerJob<unknown>) => Effect.Effect<void, unknown>): (jobs: readonly WorkerJob<unknown>[]) => Effect.Effect<void, unknown, R>;
5
+ //# sourceMappingURL=batchHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batchHandler.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/batchHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAyChD,wBAAgB,YAAY,CAAC,CAAC,EAC7B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EACtF,UAAU,GAAE,CAAC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAqB,UA0B3E,SAAS,SAAS,CAAC,OAAO,CAAC,EAAE,qCAiB3C"}
@@ -1,10 +1,10 @@
1
1
  import { Cause, Clock, Effect, Exit } from "effect";
2
- import { batchClockOffset } from "#adapters/batchClockOffset.ts";
3
- import { toPgBossError } from "#error.ts";
4
- import { deadlineOf } from "#internal/deadlineOf.ts";
5
- import { deferredAttempt } from "#internal/deferral.ts";
6
- import { failureOutput } from "#internal/failureOutput.ts";
7
- import { waitForBatchExpiry } from "#internal/waitForBatchExpiry.ts";
2
+ import { batchClockOffset } from "#server/adapters/batchClockOffset.ts";
3
+ import { toPgBossError } from "#server/error.ts";
4
+ import { deadlineOf } from "#server/internal/deadlineOf.ts";
5
+ import { deferredAttempt } from "#server/internal/deferral.ts";
6
+ import { failureOutput } from "#server/internal/failureOutput.ts";
7
+ import { waitForBatchExpiry } from "#server/internal/waitForBatchExpiry.ts";
8
8
  function settleAttempt(complete, fail, name, job, exit) {
9
9
  if (Exit.isSuccess(exit) && exit.value === deferredAttempt) {
10
10
  return Effect.void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batchHandler.js","sourceRoot":"","sources":["../../../src/server/adapters/batchHandler.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import type { ClientOptions } from "#server/clientOptions.ts";
2
+ import type { StartingClient } from "./lifecycle.ts";
3
+ export declare function acquireCachedClient(key: string | symbol, constructorOptions: ClientOptions, start: () => StartingClient): {
4
+ reused: boolean;
5
+ client: import("../client.ts").PgBossClient;
6
+ ready: Promise<void>;
7
+ stop: (options?: import("#server/clientOptions.ts").StopOptions) => Promise<void>;
8
+ };
9
+ export declare function releaseCachedClient(key: string | symbol): StartingClient | undefined;
10
+ //# sourceMappingURL=clientCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientCache.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/clientCache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA4BrD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,cAAc;;;;;EAgBvH;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,CAWpF"}
@@ -1,5 +1,5 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
- import { PgBossClientOptionsError } from "#error.ts";
2
+ import { PgBossClientOptionsError } from "#server/error.ts";
3
3
  const cacheSymbol = Symbol.for("@shivaedev/jobs/server/client-cache");
4
4
  const shared = Reflect.get(globalThis, cacheSymbol);
5
5
  const clients = shared instanceof Map ? shared : new Map();
@@ -11,11 +11,11 @@ function entryFor(key) {
11
11
  function isCachedClient(value) {
12
12
  return (typeof value === "object"
13
13
  && value !== null
14
- && Reflect.get(value, "client") instanceof Promise
14
+ && typeof Reflect.get(value, "client") === "object"
15
15
  && typeof Reflect.get(value, "constructorOptions") === "object"
16
16
  && typeof Reflect.get(value, "references") === "number");
17
17
  }
18
- export async function acquireCachedClient(key, constructorOptions, start) {
18
+ export function acquireCachedClient(key, constructorOptions, start) {
19
19
  const existing = entryFor(key);
20
20
  if (existing !== undefined) {
21
21
  const options = [...new Set([...Object.keys(existing.constructorOptions), ...Object.keys(constructorOptions)])]
@@ -25,26 +25,12 @@ export async function acquireCachedClient(key, constructorOptions, start) {
25
25
  throw new PgBossClientOptionsError({ key, options });
26
26
  }
27
27
  existing.references += 1;
28
- try {
29
- return { client: await existing.client, reused: true };
30
- }
31
- catch (error) {
32
- existing.references -= 1;
33
- throw error;
34
- }
28
+ return { ...existing.client, reused: true };
35
29
  }
36
30
  const settings = { ...constructorOptions };
37
31
  const entry = { client: start(), constructorOptions: settings, references: 1 };
38
32
  clients.set(key, entry);
39
- try {
40
- return { client: await entry.client, reused: false };
41
- }
42
- catch (error) {
43
- if (clients.get(key) === entry) {
44
- clients.delete(key);
45
- }
46
- throw error;
47
- }
33
+ return { ...entry.client, reused: false };
48
34
  }
49
35
  export function releaseCachedClient(key) {
50
36
  const entry = entryFor(key);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientCache.js","sourceRoot":"","sources":["../../../src/server/adapters/clientCache.ts"],"names":[],"mappings":"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"}
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { logClientError } from "#internal/clientErrors.ts";
2
+ import { logClientError } from "#server/internal/clientErrors.ts";
3
3
  export const clientErrorLogger = Effect.fnUntraced(function* () {
4
4
  const run = Effect.runForkWith(yield* Effect.context());
5
5
  return (error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"clientErrorLogger.js","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAY,EAAQ,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC;AACH,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"clientErrorLogger.js","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAY,EAAQ,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ClientOptions } from "#server/clientOptions.ts";
2
+ import type { EngineClient } from "#server/engineClient.ts";
3
+ export declare function defaultClientFactory(options: ClientOptions): EngineClient;
4
+ //# sourceMappingURL=defaultClientFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultClientFactory.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/defaultClientFactory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CA0BzE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultClientFactory.js","sourceRoot":"","sources":["../../../src/server/adapters/defaultClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,MAAM,UAAU,oBAAoB,CAAC,OAAsB;IAC1D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAiB,CAAC;IAC9C,MAAM,MAAM,GAAG;QACd,GAAG,OAAO;QACV,MAAM,EAAE,GAAG,EAAE;YACZ,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAC5C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;gBACzB,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC5B,OAAO,EAAE,CAAC;YACX,CAAC,CAAC,CACF,CAAC;YACF,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACzB,OAAO,MAAM,CAAC;QACf,CAAC;KACD,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,IAAI,GAAG,KAAK,EAAE,WAAW,EAAE,EAAE;QACnC,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,0EAA0E;QAC1E,IAAI,WAAW,EAAE,KAAK,KAAK,KAAK,EAAE,CAAC;YAClC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;QACtC,CAAC;IACF,CAAC,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import type { Job } from "pg-boss";
3
- import type { PgBossClient } from "#client.ts";
4
- export declare const deferralCount: (client: PgBossClient, schema: string, job: Job<unknown>) => Effect.Effect<number, import("#error.ts").PgBossError, never>;
2
+ import type { PgBossClient } from "#server/client.ts";
3
+ import type { WorkerJob } from "#server/job.ts";
4
+ export declare const deferralCount: (client: PgBossClient, schema: string, job: WorkerJob<unknown>) => Effect.Effect<number, import("#server/error.ts").PgBossError, never>;
5
5
  //# sourceMappingURL=deferralCount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deferralCount.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/deferralCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C,eAAO,MAAM,aAAa,4HAmBxB,CAAC"}
1
+ {"version":3,"file":"deferralCount.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/deferralCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,eAAO,MAAM,aAAa,yIAmBxB,CAAC"}