bunqueue 1.0.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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +640 -0
  3. package/dist/application/dlqManager.d.ts +19 -0
  4. package/dist/application/dlqManager.d.ts.map +1 -0
  5. package/dist/application/dlqManager.js +44 -0
  6. package/dist/application/dlqManager.js.map +1 -0
  7. package/dist/application/eventsManager.d.ts +28 -0
  8. package/dist/application/eventsManager.d.ts.map +1 -0
  9. package/dist/application/eventsManager.js +59 -0
  10. package/dist/application/eventsManager.js.map +1 -0
  11. package/dist/application/jobLogsManager.d.ts +20 -0
  12. package/dist/application/jobLogsManager.d.ts.map +1 -0
  13. package/dist/application/jobLogsManager.js +28 -0
  14. package/dist/application/jobLogsManager.js.map +1 -0
  15. package/dist/application/metricsExporter.d.ts +24 -0
  16. package/dist/application/metricsExporter.d.ts.map +1 -0
  17. package/dist/application/metricsExporter.js +80 -0
  18. package/dist/application/metricsExporter.js.map +1 -0
  19. package/dist/application/operations/ack.d.ts +48 -0
  20. package/dist/application/operations/ack.d.ts.map +1 -0
  21. package/dist/application/operations/ack.js +109 -0
  22. package/dist/application/operations/ack.js.map +1 -0
  23. package/dist/application/operations/index.d.ts +10 -0
  24. package/dist/application/operations/index.d.ts.map +1 -0
  25. package/dist/application/operations/index.js +10 -0
  26. package/dist/application/operations/index.js.map +1 -0
  27. package/dist/application/operations/jobManagement.d.ts +32 -0
  28. package/dist/application/operations/jobManagement.d.ts.map +1 -0
  29. package/dist/application/operations/jobManagement.js +122 -0
  30. package/dist/application/operations/jobManagement.js.map +1 -0
  31. package/dist/application/operations/pull.d.ts +36 -0
  32. package/dist/application/operations/pull.d.ts.map +1 -0
  33. package/dist/application/operations/pull.js +109 -0
  34. package/dist/application/operations/pull.js.map +1 -0
  35. package/dist/application/operations/push.d.ts +36 -0
  36. package/dist/application/operations/push.d.ts.map +1 -0
  37. package/dist/application/operations/push.js +94 -0
  38. package/dist/application/operations/push.js.map +1 -0
  39. package/dist/application/operations/queryOperations.d.ts +33 -0
  40. package/dist/application/operations/queryOperations.d.ts.map +1 -0
  41. package/dist/application/operations/queryOperations.js +57 -0
  42. package/dist/application/operations/queryOperations.js.map +1 -0
  43. package/dist/application/operations/queueControl.d.ts +32 -0
  44. package/dist/application/operations/queueControl.d.ts.map +1 -0
  45. package/dist/application/operations/queueControl.js +72 -0
  46. package/dist/application/operations/queueControl.js.map +1 -0
  47. package/dist/application/queueManager.d.ts +113 -0
  48. package/dist/application/queueManager.d.ts.map +1 -0
  49. package/dist/application/queueManager.js +406 -0
  50. package/dist/application/queueManager.js.map +1 -0
  51. package/dist/application/webhookManager.d.ts +35 -0
  52. package/dist/application/webhookManager.d.ts.map +1 -0
  53. package/dist/application/webhookManager.js +109 -0
  54. package/dist/application/webhookManager.js.map +1 -0
  55. package/dist/application/workerManager.d.ts +48 -0
  56. package/dist/application/workerManager.d.ts.map +1 -0
  57. package/dist/application/workerManager.js +121 -0
  58. package/dist/application/workerManager.js.map +1 -0
  59. package/dist/domain/queue/index.d.ts +6 -0
  60. package/dist/domain/queue/index.d.ts.map +1 -0
  61. package/dist/domain/queue/index.js +6 -0
  62. package/dist/domain/queue/index.js.map +1 -0
  63. package/dist/domain/queue/priorityQueue.d.ts +45 -0
  64. package/dist/domain/queue/priorityQueue.d.ts.map +1 -0
  65. package/dist/domain/queue/priorityQueue.js +203 -0
  66. package/dist/domain/queue/priorityQueue.js.map +1 -0
  67. package/dist/domain/queue/shard.d.ts +98 -0
  68. package/dist/domain/queue/shard.d.ts.map +1 -0
  69. package/dist/domain/queue/shard.js +245 -0
  70. package/dist/domain/queue/shard.js.map +1 -0
  71. package/dist/domain/types/command.d.ts +270 -0
  72. package/dist/domain/types/command.d.ts.map +1 -0
  73. package/dist/domain/types/command.js +6 -0
  74. package/dist/domain/types/command.js.map +1 -0
  75. package/dist/domain/types/cron.d.ts +32 -0
  76. package/dist/domain/types/cron.d.ts.map +1 -0
  77. package/dist/domain/types/cron.js +31 -0
  78. package/dist/domain/types/cron.js.map +1 -0
  79. package/dist/domain/types/index.d.ts +9 -0
  80. package/dist/domain/types/index.d.ts.map +1 -0
  81. package/dist/domain/types/index.js +9 -0
  82. package/dist/domain/types/index.js.map +1 -0
  83. package/dist/domain/types/job.d.ts +94 -0
  84. package/dist/domain/types/job.d.ts.map +1 -0
  85. package/dist/domain/types/job.js +81 -0
  86. package/dist/domain/types/job.js.map +1 -0
  87. package/dist/domain/types/queue.d.ts +86 -0
  88. package/dist/domain/types/queue.d.ts.map +1 -0
  89. package/dist/domain/types/queue.js +84 -0
  90. package/dist/domain/types/queue.js.map +1 -0
  91. package/dist/domain/types/response.d.ts +158 -0
  92. package/dist/domain/types/response.d.ts.map +1 -0
  93. package/dist/domain/types/response.js +86 -0
  94. package/dist/domain/types/response.js.map +1 -0
  95. package/dist/domain/types/webhook.d.ts +33 -0
  96. package/dist/domain/types/webhook.d.ts.map +1 -0
  97. package/dist/domain/types/webhook.js +20 -0
  98. package/dist/domain/types/webhook.js.map +1 -0
  99. package/dist/domain/types/worker.d.ts +27 -0
  100. package/dist/domain/types/worker.d.ts.map +1 -0
  101. package/dist/domain/types/worker.js +27 -0
  102. package/dist/domain/types/worker.js.map +1 -0
  103. package/dist/infrastructure/persistence/index.d.ts +6 -0
  104. package/dist/infrastructure/persistence/index.d.ts.map +1 -0
  105. package/dist/infrastructure/persistence/index.js +6 -0
  106. package/dist/infrastructure/persistence/index.js.map +1 -0
  107. package/dist/infrastructure/persistence/schema.d.ts +14 -0
  108. package/dist/infrastructure/persistence/schema.d.ts.map +1 -0
  109. package/dist/infrastructure/persistence/schema.js +123 -0
  110. package/dist/infrastructure/persistence/schema.js.map +1 -0
  111. package/dist/infrastructure/persistence/sqlite.d.ts +42 -0
  112. package/dist/infrastructure/persistence/sqlite.d.ts.map +1 -0
  113. package/dist/infrastructure/persistence/sqlite.js +164 -0
  114. package/dist/infrastructure/persistence/sqlite.js.map +1 -0
  115. package/dist/infrastructure/persistence/statements.d.ts +55 -0
  116. package/dist/infrastructure/persistence/statements.d.ts.map +1 -0
  117. package/dist/infrastructure/persistence/statements.js +42 -0
  118. package/dist/infrastructure/persistence/statements.js.map +1 -0
  119. package/dist/infrastructure/scheduler/cronParser.d.ts +44 -0
  120. package/dist/infrastructure/scheduler/cronParser.d.ts.map +1 -0
  121. package/dist/infrastructure/scheduler/cronParser.js +90 -0
  122. package/dist/infrastructure/scheduler/cronParser.js.map +1 -0
  123. package/dist/infrastructure/scheduler/cronScheduler.d.ts +68 -0
  124. package/dist/infrastructure/scheduler/cronScheduler.d.ts.map +1 -0
  125. package/dist/infrastructure/scheduler/cronScheduler.js +172 -0
  126. package/dist/infrastructure/scheduler/cronScheduler.js.map +1 -0
  127. package/dist/infrastructure/scheduler/index.d.ts +6 -0
  128. package/dist/infrastructure/scheduler/index.d.ts.map +1 -0
  129. package/dist/infrastructure/scheduler/index.js +6 -0
  130. package/dist/infrastructure/scheduler/index.js.map +1 -0
  131. package/dist/infrastructure/server/handler.d.ts +13 -0
  132. package/dist/infrastructure/server/handler.d.ts.map +1 -0
  133. package/dist/infrastructure/server/handler.js +167 -0
  134. package/dist/infrastructure/server/handler.js.map +1 -0
  135. package/dist/infrastructure/server/handlers/advanced.d.ts +68 -0
  136. package/dist/infrastructure/server/handlers/advanced.d.ts.map +1 -0
  137. package/dist/infrastructure/server/handlers/advanced.js +99 -0
  138. package/dist/infrastructure/server/handlers/advanced.js.map +1 -0
  139. package/dist/infrastructure/server/handlers/core.d.ts +36 -0
  140. package/dist/infrastructure/server/handlers/core.d.ts.map +1 -0
  141. package/dist/infrastructure/server/handlers/core.js +82 -0
  142. package/dist/infrastructure/server/handlers/core.js.map +1 -0
  143. package/dist/infrastructure/server/handlers/cron.d.ts +20 -0
  144. package/dist/infrastructure/server/handlers/cron.d.ts.map +1 -0
  145. package/dist/infrastructure/server/handlers/cron.js +56 -0
  146. package/dist/infrastructure/server/handlers/cron.js.map +1 -0
  147. package/dist/infrastructure/server/handlers/dlq.d.ts +20 -0
  148. package/dist/infrastructure/server/handlers/dlq.d.ts.map +1 -0
  149. package/dist/infrastructure/server/handlers/dlq.js +31 -0
  150. package/dist/infrastructure/server/handlers/dlq.js.map +1 -0
  151. package/dist/infrastructure/server/handlers/index.d.ts +7 -0
  152. package/dist/infrastructure/server/handlers/index.d.ts.map +1 -0
  153. package/dist/infrastructure/server/handlers/index.js +7 -0
  154. package/dist/infrastructure/server/handlers/index.js.map +1 -0
  155. package/dist/infrastructure/server/handlers/management.d.ts +36 -0
  156. package/dist/infrastructure/server/handlers/management.d.ts.map +1 -0
  157. package/dist/infrastructure/server/handlers/management.js +75 -0
  158. package/dist/infrastructure/server/handlers/management.js.map +1 -0
  159. package/dist/infrastructure/server/handlers/monitoring.d.ts +18 -0
  160. package/dist/infrastructure/server/handlers/monitoring.d.ts.map +1 -0
  161. package/dist/infrastructure/server/handlers/monitoring.js +102 -0
  162. package/dist/infrastructure/server/handlers/monitoring.js.map +1 -0
  163. package/dist/infrastructure/server/handlers/query.d.ts +32 -0
  164. package/dist/infrastructure/server/handlers/query.d.ts.map +1 -0
  165. package/dist/infrastructure/server/handlers/query.js +61 -0
  166. package/dist/infrastructure/server/handlers/query.js.map +1 -0
  167. package/dist/infrastructure/server/http.d.ts +43 -0
  168. package/dist/infrastructure/server/http.d.ts.map +1 -0
  169. package/dist/infrastructure/server/http.js +344 -0
  170. package/dist/infrastructure/server/http.js.map +1 -0
  171. package/dist/infrastructure/server/index.d.ts +8 -0
  172. package/dist/infrastructure/server/index.d.ts.map +1 -0
  173. package/dist/infrastructure/server/index.js +8 -0
  174. package/dist/infrastructure/server/index.js.map +1 -0
  175. package/dist/infrastructure/server/protocol.d.ts +44 -0
  176. package/dist/infrastructure/server/protocol.d.ts.map +1 -0
  177. package/dist/infrastructure/server/protocol.js +129 -0
  178. package/dist/infrastructure/server/protocol.js.map +1 -0
  179. package/dist/infrastructure/server/rateLimiter.d.ts +31 -0
  180. package/dist/infrastructure/server/rateLimiter.d.ts.map +1 -0
  181. package/dist/infrastructure/server/rateLimiter.js +79 -0
  182. package/dist/infrastructure/server/rateLimiter.js.map +1 -0
  183. package/dist/infrastructure/server/tcp.d.ts +36 -0
  184. package/dist/infrastructure/server/tcp.d.ts.map +1 -0
  185. package/dist/infrastructure/server/tcp.js +101 -0
  186. package/dist/infrastructure/server/tcp.js.map +1 -0
  187. package/dist/infrastructure/server/types.d.ts +11 -0
  188. package/dist/infrastructure/server/types.d.ts.map +1 -0
  189. package/dist/infrastructure/server/types.js +5 -0
  190. package/dist/infrastructure/server/types.js.map +1 -0
  191. package/dist/main.d.ts +6 -0
  192. package/dist/main.d.ts.map +1 -0
  193. package/dist/main.js +111 -0
  194. package/dist/main.js.map +1 -0
  195. package/dist/shared/hash.d.ts +30 -0
  196. package/dist/shared/hash.d.ts.map +1 -0
  197. package/dist/shared/hash.js +69 -0
  198. package/dist/shared/hash.js.map +1 -0
  199. package/dist/shared/index.d.ts +6 -0
  200. package/dist/shared/index.d.ts.map +1 -0
  201. package/dist/shared/index.js +6 -0
  202. package/dist/shared/index.js.map +1 -0
  203. package/dist/shared/lock.d.ts +70 -0
  204. package/dist/shared/lock.d.ts.map +1 -0
  205. package/dist/shared/lock.js +207 -0
  206. package/dist/shared/lock.js.map +1 -0
  207. package/dist/shared/logger.d.ts +38 -0
  208. package/dist/shared/logger.d.ts.map +1 -0
  209. package/dist/shared/logger.js +74 -0
  210. package/dist/shared/logger.js.map +1 -0
  211. package/dist/shared/serialization.d.ts +23 -0
  212. package/dist/shared/serialization.d.ts.map +1 -0
  213. package/dist/shared/serialization.js +63 -0
  214. package/dist/shared/serialization.js.map +1 -0
  215. package/package.json +82 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dlq.js","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/dlq.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,IAAI,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,wCAAwC;AACxC,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAqC,EACrC,GAAmB,EACnB,KAAc;IAEd,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,+CAA+C;AAC/C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAA0C,EAC1C,GAAmB,EACnB,KAAc;IAEd,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK;QACL,KAAK;KACM,CAAC;AAChB,CAAC;AAED,0CAA0C;AAC1C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAA0C,EAC1C,GAAmB,EACnB,KAAc;IAEd,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK;QACL,KAAK;KACM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Handler barrel export
3
+ */
4
+ export * from './core';
5
+ export * from './query';
6
+ export * from './management';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Handler barrel export
3
+ */
4
+ export * from './core';
5
+ export * from './query';
6
+ export * from './management';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Management Command Handlers
3
+ * Cancel, Progress, Pause, Resume, Drain, Stats, Metrics
4
+ */
5
+ import type { Command } from '../../../domain/types/command';
6
+ import type { Response } from '../../../domain/types/response';
7
+ import type { HandlerContext } from '../types';
8
+ /** Handle Cancel command */
9
+ export declare function handleCancel(cmd: Extract<Command, {
10
+ cmd: 'Cancel';
11
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
12
+ /** Handle Progress command */
13
+ export declare function handleProgress(cmd: Extract<Command, {
14
+ cmd: 'Progress';
15
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
16
+ /** Handle GetProgress command */
17
+ export declare function handleGetProgress(cmd: Extract<Command, {
18
+ cmd: 'GetProgress';
19
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
20
+ /** Handle Pause command */
21
+ export declare function handlePause(cmd: Extract<Command, {
22
+ cmd: 'Pause';
23
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
24
+ /** Handle Resume command */
25
+ export declare function handleResume(cmd: Extract<Command, {
26
+ cmd: 'Resume';
27
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
28
+ /** Handle Drain command */
29
+ export declare function handleDrain(cmd: Extract<Command, {
30
+ cmd: 'Drain';
31
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
32
+ /** Handle Stats command */
33
+ export declare function handleStats(ctx: HandlerContext, reqId?: string): Response;
34
+ /** Handle Metrics command */
35
+ export declare function handleMetrics(ctx: HandlerContext, reqId?: string): Response;
36
+ //# sourceMappingURL=management.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/management.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,4BAA4B;AAC5B,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,CAAC,EACxC,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAKnB;AAED,8BAA8B;AAC9B,wBAAsB,cAAc,CAClC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAAC,EAC1C,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED,iCAAiC;AACjC,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,aAAa,CAAA;CAAE,CAAC,EAC7C,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CASnB;AAED,2BAA2B;AAC3B,wBAAsB,WAAW,CAC/B,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC,EACvC,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB;AAED,4BAA4B;AAC5B,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,CAAC,EACxC,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB;AAED,2BAA2B;AAC3B,wBAAsB,WAAW,CAC/B,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC,EACvC,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB;AAED,2BAA2B;AAC3B,wBAAgB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAezE;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAgB3E"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Management Command Handlers
3
+ * Cancel, Progress, Pause, Resume, Drain, Stats, Metrics
4
+ */
5
+ import * as resp from '../../../domain/types/response';
6
+ import { jobId } from '../../../domain/types/job';
7
+ /** Handle Cancel command */
8
+ export async function handleCancel(cmd, ctx, reqId) {
9
+ const success = await ctx.queueManager.cancel(jobId(BigInt(cmd.id)));
10
+ return success
11
+ ? resp.ok(undefined, reqId)
12
+ : resp.error('Job not found or cannot be cancelled', reqId);
13
+ }
14
+ /** Handle Progress command */
15
+ export async function handleProgress(cmd, ctx, reqId) {
16
+ const success = await ctx.queueManager.updateProgress(jobId(BigInt(cmd.id)), cmd.progress, cmd.message);
17
+ return success ? resp.ok(undefined, reqId) : resp.error('Job not found or not active', reqId);
18
+ }
19
+ /** Handle GetProgress command */
20
+ export async function handleGetProgress(cmd, ctx, reqId) {
21
+ const progress = ctx.queueManager.getProgress(jobId(BigInt(cmd.id)));
22
+ if (!progress)
23
+ return resp.error('Job not found or not active', reqId);
24
+ return {
25
+ ok: true,
26
+ progress: progress.progress,
27
+ message: progress.message,
28
+ reqId,
29
+ };
30
+ }
31
+ /** Handle Pause command */
32
+ export async function handlePause(cmd, ctx, reqId) {
33
+ ctx.queueManager.pause(cmd.queue);
34
+ return resp.ok(undefined, reqId);
35
+ }
36
+ /** Handle Resume command */
37
+ export async function handleResume(cmd, ctx, reqId) {
38
+ ctx.queueManager.resume(cmd.queue);
39
+ return resp.ok(undefined, reqId);
40
+ }
41
+ /** Handle Drain command */
42
+ export async function handleDrain(cmd, ctx, reqId) {
43
+ const count = ctx.queueManager.drain(cmd.queue);
44
+ return { ok: true, count, reqId };
45
+ }
46
+ /** Handle Stats command */
47
+ export function handleStats(ctx, reqId) {
48
+ const s = ctx.queueManager.getStats();
49
+ return resp.stats({
50
+ queued: s.waiting,
51
+ processing: s.active,
52
+ delayed: s.delayed,
53
+ dlq: s.dlq,
54
+ completed: s.completed,
55
+ uptime: s.uptime,
56
+ pushPerSec: 0,
57
+ pullPerSec: 0,
58
+ }, reqId);
59
+ }
60
+ /** Handle Metrics command */
61
+ export function handleMetrics(ctx, reqId) {
62
+ const s = ctx.queueManager.getStats();
63
+ return resp.metrics({
64
+ totalPushed: Number(s.totalPushed),
65
+ totalPulled: Number(s.totalPulled),
66
+ totalCompleted: Number(s.totalCompleted),
67
+ totalFailed: Number(s.totalFailed),
68
+ avgLatencyMs: 0,
69
+ avgProcessingMs: 0,
70
+ memoryUsageMb: process.memoryUsage().heapUsed / 1024 / 1024,
71
+ sqliteSizeMb: 0,
72
+ activeConnections: 0,
73
+ }, reqId);
74
+ }
75
+ //# sourceMappingURL=management.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management.js","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/management.ts"],"names":[],"mappings":"AAAA;;;GAGG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,CAAC,CAAC,SAAS;QACtB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;KACd,EACD,KAAK,CACN,CAAC;AACJ,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,GAAmB,EAAE,KAAc;IAC/D,MAAM,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,OAAO,IAAI,CAAC,OAAO,CACjB;QACE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;QAClC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;QAClC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC;QACxC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;QAClC,YAAY,EAAE,CAAC;QACf,eAAe,EAAE,CAAC;QAClB,aAAa,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,GAAG,IAAI,GAAG,IAAI;QAC3D,YAAY,EAAE,CAAC;QACf,iBAAiB,EAAE,CAAC;KACrB,EACD,KAAK,CACN,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Monitoring Handlers
3
+ * Handles logs, workers, webhooks, and prometheus metrics
4
+ */
5
+ import type { AddLogCommand, GetLogsCommand, HeartbeatCommand, RegisterWorkerCommand, UnregisterWorkerCommand, ListWorkersCommand, AddWebhookCommand, RemoveWebhookCommand, ListWebhooksCommand, PrometheusCommand } from '../../../domain/types/command';
6
+ import type { Response } from '../../../domain/types/response';
7
+ import type { HandlerContext } from '../types';
8
+ export declare function handleAddLog(cmd: AddLogCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
9
+ export declare function handleGetLogs(cmd: GetLogsCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
10
+ export declare function handleHeartbeat(cmd: HeartbeatCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
11
+ export declare function handleRegisterWorker(cmd: RegisterWorkerCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
12
+ export declare function handleUnregisterWorker(cmd: UnregisterWorkerCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
13
+ export declare function handleListWorkers(_cmd: ListWorkersCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
14
+ export declare function handleAddWebhook(cmd: AddWebhookCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
15
+ export declare function handleRemoveWebhook(cmd: RemoveWebhookCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
16
+ export declare function handleListWebhooks(_cmd: ListWebhooksCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
17
+ export declare function handlePrometheus(_cmd: PrometheusCommand, ctx: HandlerContext, reqId?: string): Promise<Response>;
18
+ //# sourceMappingURL=monitoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitoring.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/monitoring.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,wBAAsB,YAAY,CAChC,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CASnB;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAInB;AAID,wBAAsB,eAAe,CACnC,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAMnB;AAID,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,qBAAqB,EAC1B,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAWnB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,uBAAuB,EAC5B,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAMnB;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAkBnB;AAID,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAYnB;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,oBAAoB,EACzB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAMnB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,mBAAmB,EACzB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAmBnB;AAID,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Monitoring Handlers
3
+ * Handles logs, workers, webhooks, and prometheus metrics
4
+ */
5
+ import * as resp from '../../../domain/types/response';
6
+ // ============ Job Logs ============
7
+ export async function handleAddLog(cmd, ctx, reqId) {
8
+ const jobId = BigInt(cmd.id);
9
+ const level = cmd.level ?? 'info';
10
+ const success = ctx.queueManager.addLog(jobId, cmd.message, level);
11
+ if (success) {
12
+ return resp.data({ added: true }, reqId);
13
+ }
14
+ return resp.error('Job not found', reqId);
15
+ }
16
+ export async function handleGetLogs(cmd, ctx, reqId) {
17
+ const jobId = BigInt(cmd.id);
18
+ const logs = ctx.queueManager.getLogs(jobId);
19
+ return resp.data({ logs }, reqId);
20
+ }
21
+ // ============ Worker Heartbeat ============
22
+ export async function handleHeartbeat(cmd, ctx, reqId) {
23
+ const success = ctx.queueManager.workerManager.heartbeat(cmd.id);
24
+ if (success) {
25
+ return resp.data({ ok: true }, reqId);
26
+ }
27
+ return resp.error('Worker not found', reqId);
28
+ }
29
+ // ============ Worker Management ============
30
+ export async function handleRegisterWorker(cmd, ctx, reqId) {
31
+ const worker = ctx.queueManager.workerManager.register(cmd.name, cmd.queues);
32
+ return resp.data({
33
+ workerId: worker.id,
34
+ name: worker.name,
35
+ queues: worker.queues,
36
+ registeredAt: worker.registeredAt,
37
+ }, reqId);
38
+ }
39
+ export async function handleUnregisterWorker(cmd, ctx, reqId) {
40
+ const success = ctx.queueManager.workerManager.unregister(cmd.workerId);
41
+ if (success) {
42
+ return resp.data({ removed: true }, reqId);
43
+ }
44
+ return resp.error('Worker not found', reqId);
45
+ }
46
+ export async function handleListWorkers(_cmd, ctx, reqId) {
47
+ const workers = ctx.queueManager.workerManager.list();
48
+ return resp.data({
49
+ workers: workers.map((w) => ({
50
+ id: w.id,
51
+ name: w.name,
52
+ queues: w.queues,
53
+ registeredAt: w.registeredAt,
54
+ lastSeen: w.lastSeen,
55
+ activeJobs: w.activeJobs,
56
+ processedJobs: w.processedJobs,
57
+ failedJobs: w.failedJobs,
58
+ })),
59
+ stats: ctx.queueManager.workerManager.getStats(),
60
+ }, reqId);
61
+ }
62
+ // ============ Webhooks ============
63
+ export async function handleAddWebhook(cmd, ctx, reqId) {
64
+ const webhook = ctx.queueManager.webhookManager.add(cmd.url, cmd.events, cmd.queue, cmd.secret);
65
+ return resp.data({
66
+ webhookId: webhook.id,
67
+ url: webhook.url,
68
+ events: webhook.events,
69
+ queue: webhook.queue,
70
+ createdAt: webhook.createdAt,
71
+ }, reqId);
72
+ }
73
+ export async function handleRemoveWebhook(cmd, ctx, reqId) {
74
+ const success = ctx.queueManager.webhookManager.remove(cmd.webhookId);
75
+ if (success) {
76
+ return resp.data({ removed: true }, reqId);
77
+ }
78
+ return resp.error('Webhook not found', reqId);
79
+ }
80
+ export async function handleListWebhooks(_cmd, ctx, reqId) {
81
+ const webhooks = ctx.queueManager.webhookManager.list();
82
+ return resp.data({
83
+ webhooks: webhooks.map((w) => ({
84
+ id: w.id,
85
+ url: w.url,
86
+ events: w.events,
87
+ queue: w.queue,
88
+ createdAt: w.createdAt,
89
+ lastTriggered: w.lastTriggered,
90
+ successCount: w.successCount,
91
+ failureCount: w.failureCount,
92
+ enabled: w.enabled,
93
+ })),
94
+ stats: ctx.queueManager.webhookManager.getStats(),
95
+ }, reqId);
96
+ }
97
+ // ============ Prometheus Metrics ============
98
+ export async function handlePrometheus(_cmd, ctx, reqId) {
99
+ const metrics = ctx.queueManager.getPrometheusMetrics();
100
+ return resp.data({ metrics }, reqId);
101
+ }
102
+ //# sourceMappingURL=monitoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitoring.js","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/monitoring.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,KAAK,IAAI,MAAM,gCAAgC,CAAC;AAGvD,qCAAqC;AAErC,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAkB,EAClB,GAAmB,EACnB,KAAc;IAEd,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAU,CAAC;IACtC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,MAA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AAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,aAAa,EAAE,CAAC,CAAC,aAAa;YAC9B,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;QACH,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,EAAE;KAClD,EACD,KAAK,CACN,CAAC;AACJ,CAAC;AAED,+CAA+C;AAE/C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAuB,EACvB,GAAmB,EACnB,KAAc;IAEd,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC;IACxD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Query Command Handlers
3
+ * GetJob, GetState, GetResult, GetJobCounts, GetJobByCustomId, GetJobs
4
+ */
5
+ import type { Command } from '../../../domain/types/command';
6
+ import type { Response } from '../../../domain/types/response';
7
+ import type { HandlerContext } from '../types';
8
+ /** Handle GetJob command */
9
+ export declare function handleGetJob(cmd: Extract<Command, {
10
+ cmd: 'GetJob';
11
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
12
+ /** Handle GetState command */
13
+ export declare function handleGetState(cmd: Extract<Command, {
14
+ cmd: 'GetState';
15
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
16
+ /** Handle GetResult command */
17
+ export declare function handleGetResult(cmd: Extract<Command, {
18
+ cmd: 'GetResult';
19
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
20
+ /** Handle GetJobCounts command */
21
+ export declare function handleGetJobCounts(_cmd: Extract<Command, {
22
+ cmd: 'GetJobCounts';
23
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
24
+ /** Handle GetJobByCustomId command */
25
+ export declare function handleGetJobByCustomId(cmd: Extract<Command, {
26
+ cmd: 'GetJobByCustomId';
27
+ }>, ctx: HandlerContext, reqId?: string): Promise<Response>;
28
+ /** Handle GetJobs command - list jobs with filtering */
29
+ export declare function handleGetJobs(_cmd: Extract<Command, {
30
+ cmd: 'GetJobs';
31
+ }>, _ctx: HandlerContext, reqId?: string): Promise<Response>;
32
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/query.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,4BAA4B;AAC5B,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,CAAC,EACxC,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB;AAED,8BAA8B;AAC9B,wBAAsB,cAAc,CAClC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAAC,EAC1C,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAgBnB;AAED,+BAA+B;AAC/B,wBAAsB,eAAe,CACnC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,WAAW,CAAA;CAAE,CAAC,EAC3C,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB;AAED,kCAAkC;AAClC,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,CAAC,EAC/C,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAcnB;AAED,sCAAsC;AACtC,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAClD,GAAG,EAAE,cAAc,EACnB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAGnB;AAED,wDAAwD;AACxD,wBAAsB,aAAa,CACjC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,CAAC,EAC1C,IAAI,EAAE,cAAc,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC,CAInB"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Query Command Handlers
3
+ * GetJob, GetState, GetResult, GetJobCounts, GetJobByCustomId, GetJobs
4
+ */
5
+ import * as resp from '../../../domain/types/response';
6
+ import { jobId } from '../../../domain/types/job';
7
+ /** Handle GetJob command */
8
+ export async function handleGetJob(cmd, ctx, reqId) {
9
+ const job = await ctx.queueManager.getJob(jobId(BigInt(cmd.id)));
10
+ return job ? resp.job(job, reqId) : resp.error('Job not found', reqId);
11
+ }
12
+ /** Handle GetState command */
13
+ export async function handleGetState(cmd, ctx, reqId) {
14
+ const job = await ctx.queueManager.getJob(jobId(BigInt(cmd.id)));
15
+ if (!job)
16
+ return resp.error('Job not found', reqId);
17
+ let state;
18
+ if (job.completedAt) {
19
+ state = 'completed';
20
+ }
21
+ else if (job.startedAt) {
22
+ state = 'active';
23
+ }
24
+ else if (job.runAt > Date.now()) {
25
+ state = 'delayed';
26
+ }
27
+ else {
28
+ state = 'waiting';
29
+ }
30
+ return { ok: true, id: cmd.id, state, reqId };
31
+ }
32
+ /** Handle GetResult command */
33
+ export async function handleGetResult(cmd, ctx, reqId) {
34
+ const result = ctx.queueManager.getResult(jobId(BigInt(cmd.id)));
35
+ return { ok: true, id: cmd.id, result, reqId };
36
+ }
37
+ /** Handle GetJobCounts command */
38
+ export async function handleGetJobCounts(_cmd, ctx, reqId) {
39
+ const stats = ctx.queueManager.getStats();
40
+ // For a specific queue, we'd need per-queue stats
41
+ // For now return global stats
42
+ return resp.counts({
43
+ waiting: stats.waiting,
44
+ delayed: stats.delayed,
45
+ active: stats.active,
46
+ completed: stats.completed,
47
+ failed: Number(stats.totalFailed),
48
+ }, reqId);
49
+ }
50
+ /** Handle GetJobByCustomId command */
51
+ export async function handleGetJobByCustomId(cmd, ctx, reqId) {
52
+ const job = ctx.queueManager.getJobByCustomId(cmd.customId);
53
+ return job ? resp.job(job, reqId) : resp.error('Job not found', reqId);
54
+ }
55
+ /** Handle GetJobs command - list jobs with filtering */
56
+ export async function handleGetJobs(_cmd, _ctx, reqId) {
57
+ // Simplified implementation - full version would filter by state and paginate
58
+ // For now, return empty list - full implementation would iterate shards
59
+ return resp.jobs([], reqId);
60
+ }
61
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/infrastructure/server/handlers/query.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,IAAI,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,4BAA4B;AAC5B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAwC,EACxC,GAAmB,EACnB,KAAc;IA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,43 @@
1
+ /**
2
+ * HTTP Server
3
+ * REST API and WebSocket support
4
+ */
5
+ import type { ServerWebSocket } from 'bun';
6
+ import type { QueueManager } from '../../application/queueManager';
7
+ /** HTTP Server configuration */
8
+ export interface HttpServerConfig {
9
+ port: number;
10
+ hostname?: string;
11
+ authTokens?: string[];
12
+ corsOrigins?: string[];
13
+ requireAuthForMetrics?: boolean;
14
+ }
15
+ /** WebSocket client data */
16
+ interface WsData {
17
+ id: string;
18
+ authenticated: boolean;
19
+ queueFilter: string | null;
20
+ }
21
+ /** SSE client tracking */
22
+ interface SseClient {
23
+ id: string;
24
+ controller: ReadableStreamDefaultController;
25
+ queueFilter: string | null;
26
+ }
27
+ /**
28
+ * Create and start HTTP server
29
+ */
30
+ export declare function createHttpServer(queueManager: QueueManager, config: HttpServerConfig): {
31
+ server: Bun.Server<WsData>;
32
+ wsClients: Map<string, ServerWebSocket<WsData>>;
33
+ sseClients: Map<string, SseClient>;
34
+ /** Get WebSocket client count */
35
+ getWsClientCount(): number;
36
+ /** Get SSE client count */
37
+ getSseClientCount(): number;
38
+ /** Stop the server */
39
+ stop(): void;
40
+ };
41
+ export type HttpServer = ReturnType<typeof createHttpServer>;
42
+ export {};
43
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/server/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAQnE,gCAAgC;AAChC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,4BAA4B;AAC5B,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,0BAA0B;AAC1B,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,+BAA+B,CAAC;IAC5C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB;;;;IA2NjF,iCAAiC;wBACb,MAAM;IAI1B,2BAA2B;yBACN,MAAM;IAI3B,sBAAsB;YACd,IAAI;EAef;AAoJD,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}