@ddd-ts-kit/redis 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/README.md +699 -2
  2. package/dist/cache/cache-codec.d.ts +6 -0
  3. package/dist/cache/cache-codec.d.ts.map +1 -0
  4. package/dist/cache/cache-codec.js +2 -0
  5. package/dist/cache/cache-codec.js.map +1 -0
  6. package/dist/cache/cache-operation.d.ts +3 -0
  7. package/dist/cache/cache-operation.d.ts.map +1 -0
  8. package/dist/cache/cache-operation.js +2 -0
  9. package/dist/cache/cache-operation.js.map +1 -0
  10. package/dist/cache/json-codec.d.ts +4 -0
  11. package/dist/cache/json-codec.d.ts.map +1 -0
  12. package/dist/cache/json-codec.js +9 -0
  13. package/dist/cache/json-codec.js.map +1 -0
  14. package/dist/cache/redis-cache.d.ts +65 -0
  15. package/dist/cache/redis-cache.d.ts.map +1 -0
  16. package/dist/cache/redis-cache.js +147 -0
  17. package/dist/cache/redis-cache.js.map +1 -0
  18. package/dist/connection/close-redis.d.ts +4 -0
  19. package/dist/connection/close-redis.d.ts.map +1 -0
  20. package/dist/connection/close-redis.js +20 -0
  21. package/dist/connection/close-redis.js.map +1 -0
  22. package/dist/connection/connect-redis.d.ts +10 -0
  23. package/dist/connection/connect-redis.d.ts.map +1 -0
  24. package/dist/connection/connect-redis.js +26 -0
  25. package/dist/connection/connect-redis.js.map +1 -0
  26. package/dist/connection/fail-fast.d.ts +9 -0
  27. package/dist/connection/fail-fast.d.ts.map +1 -0
  28. package/dist/connection/fail-fast.js +8 -0
  29. package/dist/connection/fail-fast.js.map +1 -0
  30. package/dist/connection/redis-connection-options.d.ts +7 -0
  31. package/dist/connection/redis-connection-options.d.ts.map +1 -0
  32. package/dist/connection/redis-connection-options.js +2 -0
  33. package/dist/connection/redis-connection-options.js.map +1 -0
  34. package/dist/connection/redis-health.d.ts +15 -0
  35. package/dist/connection/redis-health.d.ts.map +1 -0
  36. package/dist/connection/redis-health.js +31 -0
  37. package/dist/connection/redis-health.js.map +1 -0
  38. package/dist/connection/redis-source.d.ts +5 -0
  39. package/dist/connection/redis-source.d.ts.map +1 -0
  40. package/dist/connection/redis-source.js +2 -0
  41. package/dist/connection/redis-source.js.map +1 -0
  42. package/dist/event-bus.d.ts +22 -0
  43. package/dist/event-bus.d.ts.map +1 -0
  44. package/dist/event-bus.js +10 -0
  45. package/dist/event-bus.js.map +1 -0
  46. package/dist/index.d.ts +17 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +13 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/keys/namespaced.d.ts +3 -0
  51. package/dist/keys/namespaced.d.ts.map +1 -0
  52. package/dist/keys/namespaced.js +5 -0
  53. package/dist/keys/namespaced.js.map +1 -0
  54. package/dist/keys/prefix-pattern.d.ts +3 -0
  55. package/dist/keys/prefix-pattern.d.ts.map +1 -0
  56. package/dist/keys/prefix-pattern.js +5 -0
  57. package/dist/keys/prefix-pattern.js.map +1 -0
  58. package/dist/lock/redis-lock.d.ts +31 -0
  59. package/dist/lock/redis-lock.d.ts.map +1 -0
  60. package/dist/lock/redis-lock.js +66 -0
  61. package/dist/lock/redis-lock.js.map +1 -0
  62. package/dist/rate-limiter/redis-rate-limiter.d.ts +35 -0
  63. package/dist/rate-limiter/redis-rate-limiter.d.ts.map +1 -0
  64. package/dist/rate-limiter/redis-rate-limiter.js +77 -0
  65. package/dist/rate-limiter/redis-rate-limiter.js.map +1 -0
  66. package/dist/relay/redis-relay-signal.d.ts +36 -0
  67. package/dist/relay/redis-relay-signal.d.ts.map +1 -0
  68. package/dist/relay/redis-relay-signal.js +72 -0
  69. package/dist/relay/redis-relay-signal.js.map +1 -0
  70. package/dist/relay/relay-wake-up-middleware.d.ts +11 -0
  71. package/dist/relay/relay-wake-up-middleware.d.ts.map +1 -0
  72. package/dist/relay/relay-wake-up-middleware.js +16 -0
  73. package/dist/relay/relay-wake-up-middleware.js.map +1 -0
  74. package/dist/replies/list-of.d.ts +3 -0
  75. package/dist/replies/list-of.d.ts.map +1 -0
  76. package/dist/replies/list-of.js +8 -0
  77. package/dist/replies/list-of.js.map +1 -0
  78. package/dist/secrecy/conceal.d.ts +8 -0
  79. package/dist/secrecy/conceal.d.ts.map +1 -0
  80. package/dist/secrecy/conceal.js +12 -0
  81. package/dist/secrecy/conceal.js.map +1 -0
  82. package/dist/streams/bury.d.ts +13 -0
  83. package/dist/streams/bury.d.ts.map +1 -0
  84. package/dist/streams/bury.js +14 -0
  85. package/dist/streams/bury.js.map +1 -0
  86. package/dist/streams/claim-due.d.ts +18 -0
  87. package/dist/streams/claim-due.d.ts.map +1 -0
  88. package/dist/streams/claim-due.js +41 -0
  89. package/dist/streams/claim-due.js.map +1 -0
  90. package/dist/streams/codec/decode.d.ts +5 -0
  91. package/dist/streams/codec/decode.d.ts.map +1 -0
  92. package/dist/streams/codec/decode.js +40 -0
  93. package/dist/streams/codec/decode.js.map +1 -0
  94. package/dist/streams/codec/encode.d.ts +7 -0
  95. package/dist/streams/codec/encode.d.ts.map +1 -0
  96. package/dist/streams/codec/encode.js +20 -0
  97. package/dist/streams/codec/encode.js.map +1 -0
  98. package/dist/streams/codec/entries-by-stream.d.ts +4 -0
  99. package/dist/streams/codec/entries-by-stream.d.ts.map +1 -0
  100. package/dist/streams/codec/entries-by-stream.js +14 -0
  101. package/dist/streams/codec/entries-by-stream.js.map +1 -0
  102. package/dist/streams/codec/entries-of.d.ts +4 -0
  103. package/dist/streams/codec/entries-of.d.ts.map +1 -0
  104. package/dist/streams/codec/entries-of.js +16 -0
  105. package/dist/streams/codec/entries-of.js.map +1 -0
  106. package/dist/streams/codec/entry-fields.d.ts +13 -0
  107. package/dist/streams/codec/entry-fields.d.ts.map +1 -0
  108. package/dist/streams/codec/entry-fields.js +13 -0
  109. package/dist/streams/codec/entry-fields.js.map +1 -0
  110. package/dist/streams/codec/entry.d.ts +6 -0
  111. package/dist/streams/codec/entry.d.ts.map +1 -0
  112. package/dist/streams/codec/entry.js +2 -0
  113. package/dist/streams/codec/entry.js.map +1 -0
  114. package/dist/streams/codec/fields-with.d.ts +4 -0
  115. package/dist/streams/codec/fields-with.d.ts.map +1 -0
  116. package/dist/streams/codec/fields-with.js +6 -0
  117. package/dist/streams/codec/fields-with.js.map +1 -0
  118. package/dist/streams/codec/pending-entry.d.ts +7 -0
  119. package/dist/streams/codec/pending-entry.d.ts.map +1 -0
  120. package/dist/streams/codec/pending-entry.js +2 -0
  121. package/dist/streams/codec/pending-entry.js.map +1 -0
  122. package/dist/streams/codec/pending-of.d.ts +4 -0
  123. package/dist/streams/codec/pending-of.d.ts.map +1 -0
  124. package/dist/streams/codec/pending-of.js +11 -0
  125. package/dist/streams/codec/pending-of.js.map +1 -0
  126. package/dist/streams/codec/replay-fields.d.ts +4 -0
  127. package/dist/streams/codec/replay-fields.d.ts.map +1 -0
  128. package/dist/streams/codec/replay-fields.js +15 -0
  129. package/dist/streams/codec/replay-fields.js.map +1 -0
  130. package/dist/streams/consumption.d.ts +22 -0
  131. package/dist/streams/consumption.d.ts.map +1 -0
  132. package/dist/streams/consumption.js +46 -0
  133. package/dist/streams/consumption.js.map +1 -0
  134. package/dist/streams/delivery.d.ts +8 -0
  135. package/dist/streams/delivery.d.ts.map +1 -0
  136. package/dist/streams/delivery.js +2 -0
  137. package/dist/streams/delivery.js.map +1 -0
  138. package/dist/streams/errors/broker-unavailable-error.d.ts +8 -0
  139. package/dist/streams/errors/broker-unavailable-error.d.ts.map +1 -0
  140. package/dist/streams/errors/broker-unavailable-error.js +12 -0
  141. package/dist/streams/errors/broker-unavailable-error.js.map +1 -0
  142. package/dist/streams/errors/consumer-name-required-error.d.ts +5 -0
  143. package/dist/streams/errors/consumer-name-required-error.d.ts.map +1 -0
  144. package/dist/streams/errors/consumer-name-required-error.js +8 -0
  145. package/dist/streams/errors/consumer-name-required-error.js.map +1 -0
  146. package/dist/streams/errors/event-bus-closed-error.d.ts +5 -0
  147. package/dist/streams/errors/event-bus-closed-error.d.ts.map +1 -0
  148. package/dist/streams/errors/event-bus-closed-error.js +8 -0
  149. package/dist/streams/errors/event-bus-closed-error.js.map +1 -0
  150. package/dist/streams/errors/failure-code.d.ts +7 -0
  151. package/dist/streams/errors/failure-code.d.ts.map +1 -0
  152. package/dist/streams/errors/failure-code.js +28 -0
  153. package/dist/streams/errors/failure-code.js.map +1 -0
  154. package/dist/streams/errors/publish-not-confirmed-error.d.ts +9 -0
  155. package/dist/streams/errors/publish-not-confirmed-error.d.ts.map +1 -0
  156. package/dist/streams/errors/publish-not-confirmed-error.js +14 -0
  157. package/dist/streams/errors/publish-not-confirmed-error.js.map +1 -0
  158. package/dist/streams/group-reader.d.ts +57 -0
  159. package/dist/streams/group-reader.d.ts.map +1 -0
  160. package/dist/streams/group-reader.js +187 -0
  161. package/dist/streams/group-reader.js.map +1 -0
  162. package/dist/streams/messaging-system.d.ts +3 -0
  163. package/dist/streams/messaging-system.d.ts.map +1 -0
  164. package/dist/streams/messaging-system.js +3 -0
  165. package/dist/streams/messaging-system.js.map +1 -0
  166. package/dist/streams/options/deduplication-options.d.ts +5 -0
  167. package/dist/streams/options/deduplication-options.d.ts.map +1 -0
  168. package/dist/streams/options/deduplication-options.js +2 -0
  169. package/dist/streams/options/deduplication-options.js.map +1 -0
  170. package/dist/streams/options/default-prefix.d.ts +2 -0
  171. package/dist/streams/options/default-prefix.d.ts.map +1 -0
  172. package/dist/streams/options/default-prefix.js +2 -0
  173. package/dist/streams/options/default-prefix.js.map +1 -0
  174. package/dist/streams/options/reconnect-delay.d.ts +4 -0
  175. package/dist/streams/options/reconnect-delay.d.ts.map +1 -0
  176. package/dist/streams/options/reconnect-delay.js +5 -0
  177. package/dist/streams/options/reconnect-delay.js.map +1 -0
  178. package/dist/streams/options/reconnect-options.d.ts +9 -0
  179. package/dist/streams/options/reconnect-options.d.ts.map +1 -0
  180. package/dist/streams/options/reconnect-options.js +2 -0
  181. package/dist/streams/options/reconnect-options.js.map +1 -0
  182. package/dist/streams/options/redis-streams-delivery.d.ts +13 -0
  183. package/dist/streams/options/redis-streams-delivery.d.ts.map +1 -0
  184. package/dist/streams/options/redis-streams-delivery.js +2 -0
  185. package/dist/streams/options/redis-streams-delivery.js.map +1 -0
  186. package/dist/streams/options/redis-streams-event-bus-options.d.ts +48 -0
  187. package/dist/streams/options/redis-streams-event-bus-options.d.ts.map +1 -0
  188. package/dist/streams/options/redis-streams-event-bus-options.js +2 -0
  189. package/dist/streams/options/redis-streams-event-bus-options.js.map +1 -0
  190. package/dist/streams/options/redis-streams-failure.d.ts +19 -0
  191. package/dist/streams/options/redis-streams-failure.d.ts.map +1 -0
  192. package/dist/streams/options/redis-streams-failure.js +2 -0
  193. package/dist/streams/options/redis-streams-failure.js.map +1 -0
  194. package/dist/streams/options/retention-options.d.ts +10 -0
  195. package/dist/streams/options/retention-options.d.ts.map +1 -0
  196. package/dist/streams/options/retention-options.js +2 -0
  197. package/dist/streams/options/retention-options.js.map +1 -0
  198. package/dist/streams/options/retry-options.d.ts +7 -0
  199. package/dist/streams/options/retry-options.d.ts.map +1 -0
  200. package/dist/streams/options/retry-options.js +2 -0
  201. package/dist/streams/options/retry-options.js.map +1 -0
  202. package/dist/streams/options/settings-of.d.ts +4 -0
  203. package/dist/streams/options/settings-of.d.ts.map +1 -0
  204. package/dist/streams/options/settings-of.js +47 -0
  205. package/dist/streams/options/settings-of.js.map +1 -0
  206. package/dist/streams/options/settings.d.ts +28 -0
  207. package/dist/streams/options/settings.d.ts.map +1 -0
  208. package/dist/streams/options/settings.js +2 -0
  209. package/dist/streams/options/settings.js.map +1 -0
  210. package/dist/streams/publications.d.ts +22 -0
  211. package/dist/streams/publications.d.ts.map +1 -0
  212. package/dist/streams/publications.js +75 -0
  213. package/dist/streams/publications.js.map +1 -0
  214. package/dist/streams/redis-streams-event-bus.d.ts +55 -0
  215. package/dist/streams/redis-streams-event-bus.d.ts.map +1 -0
  216. package/dist/streams/redis-streams-event-bus.js +120 -0
  217. package/dist/streams/redis-streams-event-bus.js.map +1 -0
  218. package/dist/streams/replay.d.ts +13 -0
  219. package/dist/streams/replay.d.ts.map +1 -0
  220. package/dist/streams/replay.js +26 -0
  221. package/dist/streams/replay.js.map +1 -0
  222. package/dist/streams/server-link.d.ts +45 -0
  223. package/dist/streams/server-link.d.ts.map +1 -0
  224. package/dist/streams/server-link.js +129 -0
  225. package/dist/streams/server-link.js.map +1 -0
  226. package/dist/streams/settlement.d.ts +46 -0
  227. package/dist/streams/settlement.d.ts.map +1 -0
  228. package/dist/streams/settlement.js +139 -0
  229. package/dist/streams/settlement.js.map +1 -0
  230. package/dist/streams/topology/consumer-binding.d.ts +5 -0
  231. package/dist/streams/topology/consumer-binding.d.ts.map +1 -0
  232. package/dist/streams/topology/consumer-binding.js +2 -0
  233. package/dist/streams/topology/consumer-binding.js.map +1 -0
  234. package/dist/streams/topology/create-group.d.ts +4 -0
  235. package/dist/streams/topology/create-group.d.ts.map +1 -0
  236. package/dist/streams/topology/create-group.js +13 -0
  237. package/dist/streams/topology/create-group.js.map +1 -0
  238. package/dist/streams/topology/dead-stream-of.d.ts +3 -0
  239. package/dist/streams/topology/dead-stream-of.d.ts.map +1 -0
  240. package/dist/streams/topology/dead-stream-of.js +5 -0
  241. package/dist/streams/topology/dead-stream-of.js.map +1 -0
  242. package/dist/streams/topology/declare-topology.d.ts +5 -0
  243. package/dist/streams/topology/declare-topology.d.ts.map +1 -0
  244. package/dist/streams/topology/declare-topology.js +8 -0
  245. package/dist/streams/topology/declare-topology.js.map +1 -0
  246. package/dist/streams/topology/group-description.d.ts +7 -0
  247. package/dist/streams/topology/group-description.d.ts.map +1 -0
  248. package/dist/streams/topology/group-description.js +2 -0
  249. package/dist/streams/topology/group-description.js.map +1 -0
  250. package/dist/streams/topology/group-of.d.ts +5 -0
  251. package/dist/streams/topology/group-of.d.ts.map +1 -0
  252. package/dist/streams/topology/group-of.js +4 -0
  253. package/dist/streams/topology/group-of.js.map +1 -0
  254. package/dist/streams/topology/redis-streams-topology.d.ts +8 -0
  255. package/dist/streams/topology/redis-streams-topology.d.ts.map +1 -0
  256. package/dist/streams/topology/redis-streams-topology.js +2 -0
  257. package/dist/streams/topology/redis-streams-topology.js.map +1 -0
  258. package/dist/streams/topology/stream-description.d.ts +12 -0
  259. package/dist/streams/topology/stream-description.d.ts.map +1 -0
  260. package/dist/streams/topology/stream-description.js +2 -0
  261. package/dist/streams/topology/stream-description.js.map +1 -0
  262. package/dist/streams/topology/stream-names-of.d.ts +5 -0
  263. package/dist/streams/topology/stream-names-of.d.ts.map +1 -0
  264. package/dist/streams/topology/stream-names-of.js +11 -0
  265. package/dist/streams/topology/stream-names-of.js.map +1 -0
  266. package/dist/streams/topology/stream-names.d.ts +5 -0
  267. package/dist/streams/topology/stream-names.d.ts.map +1 -0
  268. package/dist/streams/topology/stream-names.js +2 -0
  269. package/dist/streams/topology/stream-names.js.map +1 -0
  270. package/dist/streams/topology/topology-of.d.ts +5 -0
  271. package/dist/streams/topology/topology-of.d.ts.map +1 -0
  272. package/dist/streams/topology/topology-of.js +21 -0
  273. package/dist/streams/topology/topology-of.js.map +1 -0
  274. package/dist/streams/topology/topology-settings.d.ts +7 -0
  275. package/dist/streams/topology/topology-settings.d.ts.map +1 -0
  276. package/dist/streams/topology/topology-settings.js +2 -0
  277. package/dist/streams/topology/topology-settings.js.map +1 -0
  278. package/dist/testing.d.ts +2 -0
  279. package/dist/testing.d.ts.map +1 -0
  280. package/dist/testing.js +2 -0
  281. package/dist/testing.js.map +1 -0
  282. package/package.json +51 -4
@@ -0,0 +1,7 @@
1
+ import type { IntegrationEvent } from '@ddd-ts-kit/kernel';
2
+ /**
3
+ * The fields of an entry: the whole envelope as JSON, so any client of the protocol can
4
+ * consume it, and beside it what an operator, a tracer or a filter needs without parsing it.
5
+ */
6
+ export declare function encode(event: IntegrationEvent): string[];
7
+ //# sourceMappingURL=encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/encode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAU3D;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAaxD"}
@@ -0,0 +1,20 @@
1
+ import { CORRELATION_FIELD, ENVELOPE_FIELD, EVENT_ID_FIELD, EVENT_TYPE_FIELD, EVENT_VERSION_FIELD, TRACEPARENT_FIELD, } from './entry-fields.js';
2
+ /**
3
+ * The fields of an entry: the whole envelope as JSON, so any client of the protocol can
4
+ * consume it, and beside it what an operator, a tracer or a filter needs without parsing it.
5
+ */
6
+ export function encode(event) {
7
+ return [
8
+ EVENT_ID_FIELD,
9
+ event.id,
10
+ EVENT_TYPE_FIELD,
11
+ event.type,
12
+ EVENT_VERSION_FIELD,
13
+ String(event.version),
14
+ ...(event.traceparent === undefined ? [] : [TRACEPARENT_FIELD, event.traceparent]),
15
+ ...(event.correlationId === undefined ? [] : [CORRELATION_FIELD, event.correlationId]),
16
+ ENVELOPE_FIELD,
17
+ JSON.stringify(event),
18
+ ];
19
+ }
20
+ //# sourceMappingURL=encode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.js","sourceRoot":"","sources":["../../../src/streams/codec/encode.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,KAAuB;IAC5C,OAAO;QACL,cAAc;QACd,KAAK,CAAC,EAAE;QACR,gBAAgB;QAChB,KAAK,CAAC,IAAI;QACV,mBAAmB;QACnB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACrB,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QAClF,GAAG,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QACtF,cAAc;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Entry } from './entry.js';
2
+ /** The reply of `XREADGROUP`: the entries read, stream by stream. Nothing to read is `null`. */
3
+ export declare function entriesByStream(reply: unknown): Map<string, Entry[]>;
4
+ //# sourceMappingURL=entries-by-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-by-stream.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/entries-by-stream.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAYpE"}
@@ -0,0 +1,14 @@
1
+ import { listOf } from '../../replies/list-of.js';
2
+ import { entriesOf } from './entries-of.js';
3
+ /** The reply of `XREADGROUP`: the entries read, stream by stream. Nothing to read is `null`. */
4
+ export function entriesByStream(reply) {
5
+ const read = new Map();
6
+ for (const answer of listOf(reply)) {
7
+ const [stream, entries] = listOf(answer);
8
+ if (typeof stream === 'string') {
9
+ read.set(stream, entriesOf(entries));
10
+ }
11
+ }
12
+ return read;
13
+ }
14
+ //# sourceMappingURL=entries-by-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-by-stream.js","sourceRoot":"","sources":["../../../src/streams/codec/entries-by-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,gGAAgG;AAChG,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmB,CAAC;IAExC,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAEzC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Entry } from './entry.js';
2
+ /** The reply of `XRANGE` and `XCLAIM`. An entry deleted from its stream comes back empty and is left out. */
3
+ export declare function entriesOf(reply: unknown): Entry[];
4
+ //# sourceMappingURL=entries-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-of.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/entries-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,6GAA6G;AAC7G,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,CAMjD"}
@@ -0,0 +1,16 @@
1
+ import { listOf } from '../../replies/list-of.js';
2
+ /** The reply of `XRANGE` and `XCLAIM`. An entry deleted from its stream comes back empty and is left out. */
3
+ export function entriesOf(reply) {
4
+ return listOf(reply).flatMap((answer) => {
5
+ const [id, fields] = listOf(answer);
6
+ return typeof id === 'string' && Array.isArray(fields) ? [{ id, fields: fieldMapOf(fields) }] : [];
7
+ });
8
+ }
9
+ function fieldMapOf(flat) {
10
+ const fields = new Map();
11
+ for (let index = 0; index + 1 < flat.length; index += 2) {
12
+ fields.set(String(flat[index]), String(flat[index + 1]));
13
+ }
14
+ return fields;
15
+ }
16
+ //# sourceMappingURL=entries-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-of.js","sourceRoot":"","sources":["../../../src/streams/codec/entries-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,6GAA6G;AAC7G,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACtC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAEpC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACrG,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,IAAwB;IAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACxD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const ENVELOPE_FIELD = "envelope";
2
+ export declare const EVENT_ID_FIELD = "id";
3
+ export declare const EVENT_TYPE_FIELD = "type";
4
+ export declare const EVENT_VERSION_FIELD = "version";
5
+ export declare const TRACEPARENT_FIELD = "traceparent";
6
+ export declare const CORRELATION_FIELD = "correlation-id";
7
+ export declare const REPLAY_FOR_FIELD = "replay-for";
8
+ export declare const ERROR_CODE_FIELD = "error-code";
9
+ export declare const DEAD_REASON_FIELD = "dead-reason";
10
+ export declare const ATTEMPT_FIELD = "attempt";
11
+ export declare const CONSUMER_FIELD = "consumer";
12
+ export declare const ENTRY_ID_FIELD = "entry-id";
13
+ //# sourceMappingURL=entry-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-fields.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/entry-fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAClD,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAC/C,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,cAAc,aAAa,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const ENVELOPE_FIELD = 'envelope';
2
+ export const EVENT_ID_FIELD = 'id';
3
+ export const EVENT_TYPE_FIELD = 'type';
4
+ export const EVENT_VERSION_FIELD = 'version';
5
+ export const TRACEPARENT_FIELD = 'traceparent';
6
+ export const CORRELATION_FIELD = 'correlation-id';
7
+ export const REPLAY_FOR_FIELD = 'replay-for';
8
+ export const ERROR_CODE_FIELD = 'error-code';
9
+ export const DEAD_REASON_FIELD = 'dead-reason';
10
+ export const ATTEMPT_FIELD = 'attempt';
11
+ export const CONSUMER_FIELD = 'consumer';
12
+ export const ENTRY_ID_FIELD = 'entry-id';
13
+ //# sourceMappingURL=entry-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-fields.js","sourceRoot":"","sources":["../../../src/streams/codec/entry-fields.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAC/C,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** One entry of a stream: its id and its fields, in the order the server holds them. */
2
+ export interface Entry {
3
+ readonly id: string;
4
+ readonly fields: ReadonlyMap<string, string>;
5
+ }
6
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/entry.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../src/streams/codec/entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { Entry } from './entry.js';
2
+ /** The fields of an entry, flat, with `added` put last: where a field is repeated, the last one is read. */
3
+ export declare function fieldsWith(entry: Entry, added: Readonly<Record<string, string>>): string[];
4
+ //# sourceMappingURL=fields-with.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields-with.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/fields-with.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,CAI1F"}
@@ -0,0 +1,6 @@
1
+ /** The fields of an entry, flat, with `added` put last: where a field is repeated, the last one is read. */
2
+ export function fieldsWith(entry, added) {
3
+ const kept = [...entry.fields].filter(([name]) => !(name in added));
4
+ return [...kept, ...Object.entries(added)].flat();
5
+ }
6
+ //# sourceMappingURL=fields-with.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields-with.js","sourceRoot":"","sources":["../../../src/streams/codec/fields-with.ts"],"names":[],"mappings":"AAEA,4GAA4G;AAC5G,MAAM,UAAU,UAAU,CAAC,KAAY,EAAE,KAAuC;IAC9E,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC;IAEpE,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** One line of the pending entry list of a group. */
2
+ export interface PendingEntry {
3
+ readonly id: string;
4
+ readonly consumer: string;
5
+ readonly deliveries: number;
6
+ }
7
+ //# sourceMappingURL=pending-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-entry.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/pending-entry.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pending-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-entry.js","sourceRoot":"","sources":["../../../src/streams/codec/pending-entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { PendingEntry } from './pending-entry.js';
2
+ /** The reply of the extended `XPENDING`: id, owner, idle time, delivery counter. */
3
+ export declare function pendingOf(reply: unknown): PendingEntry[];
4
+ //# sourceMappingURL=pending-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-of.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/pending-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,EAAE,CAQxD"}
@@ -0,0 +1,11 @@
1
+ import { listOf } from '../../replies/list-of.js';
2
+ /** The reply of the extended `XPENDING`: id, owner, idle time, delivery counter. */
3
+ export function pendingOf(reply) {
4
+ return listOf(reply).flatMap((answer) => {
5
+ const [id, consumer, , deliveries] = listOf(answer);
6
+ return typeof id === 'string' && typeof consumer === 'string'
7
+ ? [{ id, consumer, deliveries: Number(deliveries) }]
8
+ : [];
9
+ });
10
+ }
11
+ //# sourceMappingURL=pending-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-of.js","sourceRoot":"","sources":["../../../src/streams/codec/pending-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACtC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,AAAD,EAAG,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAEpD,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC3D,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Entry } from './entry.js';
2
+ /** The fields of a dead entry as they were published, addressed to the consumer it died for. */
3
+ export declare function replayFields(dead: Entry, consumer: string): string[];
4
+ //# sourceMappingURL=replay-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-fields.d.ts","sourceRoot":"","sources":["../../../src/streams/codec/replay-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAmBxC,gGAAgG;AAChG,wBAAgB,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAIpE"}
@@ -0,0 +1,15 @@
1
+ import { ATTEMPT_FIELD, CONSUMER_FIELD, DEAD_REASON_FIELD, ENTRY_ID_FIELD, ERROR_CODE_FIELD, REPLAY_FOR_FIELD, } from './entry-fields.js';
2
+ const DEAD_LETTER_FIELDS = new Set([
3
+ ERROR_CODE_FIELD,
4
+ DEAD_REASON_FIELD,
5
+ ATTEMPT_FIELD,
6
+ CONSUMER_FIELD,
7
+ ENTRY_ID_FIELD,
8
+ REPLAY_FOR_FIELD,
9
+ ]);
10
+ /** The fields of a dead entry as they were published, addressed to the consumer it died for. */
11
+ export function replayFields(dead, consumer) {
12
+ const published = [...dead.fields].filter(([name]) => !DEAD_LETTER_FIELDS.has(name));
13
+ return [...published, [REPLAY_FOR_FIELD, consumer]].flat();
14
+ }
15
+ //# sourceMappingURL=replay-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-fields.js","sourceRoot":"","sources":["../../../src/streams/codec/replay-fields.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,cAAc;IACd,gBAAgB;CACjB,CAAC,CAAC;AAEH,gGAAgG;AAChG,MAAM,UAAU,YAAY,CAAC,IAAW,EAAE,QAAgB;IACxD,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAErF,OAAO,CAAC,GAAG,SAAS,EAAE,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Redis } from 'ioredis';
2
+ import type { IntegrationEventCallback, Subscription } from '@ddd-ts-kit/kernel';
3
+ import type { Settings } from './options/settings.js';
4
+ import type { ServerLink } from './server-link.js';
5
+ import type { ConsumerBinding } from './topology/consumer-binding.js';
6
+ /** The consuming side: one reader per consumer name, started with its first subscription. */
7
+ export declare class Consumption {
8
+ private readonly link;
9
+ private readonly settings;
10
+ private readonly readers;
11
+ constructor(link: ServerLink, settings: Settings);
12
+ /** Entries read by this bus and not settled yet. */
13
+ get inFlight(): number;
14
+ bindings(): ConsumerBinding[];
15
+ add({ consumer, type }: ConsumerBinding, handler: IntegrationEventCallback): Subscription;
16
+ /** Creates the groups of the subscriptions made so far: what is published next reaches them. */
17
+ declare(client: Redis): Promise<void>;
18
+ /** Stops every reader, each after the batch it is handling. */
19
+ drain(): Promise<void>;
20
+ private dismissIfIdle;
21
+ }
22
+ //# sourceMappingURL=consumption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumption.d.ts","sourceRoot":"","sources":["../../src/streams/consumption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,6FAA6F;AAC7F,qBAAa,WAAW;IAIpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJ3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,YACmB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,QAAQ,EACjC;IAEJ,oDAAoD;IACpD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,QAAQ,IAAI,eAAe,EAAE,CAE5B;IAED,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,wBAAwB,GAAG,YAAY,CAaxF;IAED,gGAAgG;IAC1F,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1C;IAED,+DAA+D;IACzD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3B;IAED,OAAO,CAAC,aAAa;CAMtB"}
@@ -0,0 +1,46 @@
1
+ import { GroupReader } from './group-reader.js';
2
+ /** The consuming side: one reader per consumer name, started with its first subscription. */
3
+ export class Consumption {
4
+ link;
5
+ settings;
6
+ readers = new Map();
7
+ constructor(link, settings) {
8
+ this.link = link;
9
+ this.settings = settings;
10
+ }
11
+ /** Entries read by this bus and not settled yet. */
12
+ get inFlight() {
13
+ return [...this.readers.values()].reduce((total, reader) => total + reader.inFlight, 0);
14
+ }
15
+ bindings() {
16
+ return [...this.readers.values()].flatMap((reader) => reader.bindings());
17
+ }
18
+ add({ consumer, type }, handler) {
19
+ const reader = this.readers.get(consumer) ?? new GroupReader(consumer, this.link, this.settings);
20
+ this.readers.set(consumer, reader);
21
+ const subscription = reader.subscribe(type, handler);
22
+ return {
23
+ unsubscribe: () => {
24
+ subscription.unsubscribe();
25
+ this.dismissIfIdle(consumer, reader);
26
+ },
27
+ };
28
+ }
29
+ /** Creates the groups of the subscriptions made so far: what is published next reaches them. */
30
+ async declare(client) {
31
+ await Promise.all([...this.readers.values()].map((reader) => reader.declare(client)));
32
+ }
33
+ /** Stops every reader, each after the batch it is handling. */
34
+ async drain() {
35
+ const readers = [...this.readers.values()];
36
+ this.readers.clear();
37
+ await Promise.all(readers.map((reader) => reader.stop()));
38
+ }
39
+ dismissIfIdle(consumer, reader) {
40
+ if (reader.idle && this.readers.get(consumer) === reader) {
41
+ this.readers.delete(consumer);
42
+ void reader.stop();
43
+ }
44
+ }
45
+ }
46
+ //# sourceMappingURL=consumption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumption.js","sourceRoot":"","sources":["../../src/streams/consumption.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,6FAA6F;AAC7F,MAAM,OAAO,WAAW;IAIH,IAAI;IACJ,QAAQ;IAJV,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE1D,YACmB,IAAgB,EAChB,QAAkB;oBADlB,IAAI;wBACJ,QAAQ;IACxB,CAAC;IAEJ,oDAAoD;IACpD,IAAI,QAAQ;QACV,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAmB,EAAE,OAAiC;QACxE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEjG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAEnC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAErD,OAAO;YACL,WAAW,EAAE,GAAG,EAAE;gBAChB,YAAY,CAAC,WAAW,EAAE,CAAC;gBAC3B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACvC,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gGAAgG;IAChG,KAAK,CAAC,OAAO,CAAC,MAAa;QACzB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,KAAK;QACT,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAE3C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;IAEO,aAAa,CAAC,QAAgB,EAAE,MAAmB;QACzD,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,MAAM,EAAE,CAAC;YACzD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { Entry } from './codec/entry.js';
2
+ /** One entry handed to this process, with the number of times the group delivered it. */
3
+ export interface Delivery {
4
+ readonly stream: string;
5
+ readonly entry: Entry;
6
+ readonly attempt: number;
7
+ }
8
+ //# sourceMappingURL=delivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../src/streams/delivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,yFAAyF;AACzF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=delivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../src/streams/delivery.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /** No live connection: the first one failed, or ioredis is between two reconnection attempts. */
2
+ export declare class BrokerUnavailableError extends Error {
3
+ readonly reason: string;
4
+ readonly code = "BROKER_UNAVAILABLE";
5
+ /** `reason` is the code of what made the server unreachable, never a message. */
6
+ constructor(reason: string);
7
+ }
8
+ //# sourceMappingURL=broker-unavailable-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-unavailable-error.d.ts","sourceRoot":"","sources":["../../../src/streams/errors/broker-unavailable-error.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,qBAAa,sBAAuB,SAAQ,KAAK;IAInC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHnC,QAAQ,CAAC,IAAI,wBAAwB;IAErC,iFAAiF;IACjF,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACF"}
@@ -0,0 +1,12 @@
1
+ /** No live connection: the first one failed, or ioredis is between two reconnection attempts. */
2
+ export class BrokerUnavailableError extends Error {
3
+ reason;
4
+ code = 'BROKER_UNAVAILABLE';
5
+ /** `reason` is the code of what made the server unreachable, never a message. */
6
+ constructor(reason) {
7
+ super(`The server is unavailable (${reason})`);
8
+ this.reason = reason;
9
+ this.name = 'BrokerUnavailableError';
10
+ }
11
+ }
12
+ //# sourceMappingURL=broker-unavailable-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-unavailable-error.js","sourceRoot":"","sources":["../../../src/streams/errors/broker-unavailable-error.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAI1B,MAAM;IAHlB,IAAI,GAAG,oBAAoB,CAAC;IAErC,iFAAiF;IACjF,YAAqB,MAAc;QACjC,KAAK,CAAC,8BAA8B,MAAM,GAAG,CAAC,CAAC;sBAD5B,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare class ConsumerNameRequiredError extends Error {
2
+ readonly code = "CONSUMER_NAME_REQUIRED";
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=consumer-name-required-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-name-required-error.d.ts","sourceRoot":"","sources":["../../../src/streams/errors/consumer-name-required-error.ts"],"names":[],"mappings":"AAAA,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,4BAA4B;IAEzC,cAGC;CACF"}
@@ -0,0 +1,8 @@
1
+ export class ConsumerNameRequiredError extends Error {
2
+ code = 'CONSUMER_NAME_REQUIRED';
3
+ constructor() {
4
+ super('Subscribing needs a consumer name: build the bus with `consumer`, or use `forConsumer(name)`');
5
+ this.name = 'ConsumerNameRequiredError';
6
+ }
7
+ }
8
+ //# sourceMappingURL=consumer-name-required-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-name-required-error.js","sourceRoot":"","sources":["../../../src/streams/errors/consumer-name-required-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,IAAI,GAAG,wBAAwB,CAAC;IAEzC;QACE,KAAK,CAAC,8FAA8F,CAAC,CAAC;QACtG,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare class EventBusClosedError extends Error {
2
+ readonly code = "EVENT_BUS_CLOSED";
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=event-bus-closed-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus-closed-error.d.ts","sourceRoot":"","sources":["../../../src/streams/errors/event-bus-closed-error.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,sBAAsB;IAEnC,cAGC;CACF"}
@@ -0,0 +1,8 @@
1
+ export class EventBusClosedError extends Error {
2
+ code = 'EVENT_BUS_CLOSED';
3
+ constructor() {
4
+ super('The event bus is closed');
5
+ this.name = 'EventBusClosedError';
6
+ }
7
+ }
8
+ //# sourceMappingURL=event-bus-closed-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus-closed-error.js","sourceRoot":"","sources":["../../../src/streams/errors/event-bus-closed-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,GAAG,kBAAkB,CAAC;IAEnC;QACE,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * What may be reported about a caught error: its `code` when it carries one (`ECONNREFUSED`),
3
+ * the kind of an error answered by the server (`REDIS_NOGROUP`, `REDIS_OOM`), else its class
4
+ * name. Never the message, which may quote a key, a URL or payload data.
5
+ */
6
+ export declare function failureCode(error: unknown): string;
7
+ //# sourceMappingURL=failure-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure-code.d.ts","sourceRoot":"","sources":["../../../src/streams/errors/failure-code.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBlD"}
@@ -0,0 +1,28 @@
1
+ const IDENTIFIER = /^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;
2
+ /** The protocol starts an error reply with its kind in capitals: only that word is kept. */
3
+ const REPLY_KIND = /^[A-Z][A-Z0-9]{1,31}(?= |$)/;
4
+ /**
5
+ * What may be reported about a caught error: its `code` when it carries one (`ECONNREFUSED`),
6
+ * the kind of an error answered by the server (`REDIS_NOGROUP`, `REDIS_OOM`), else its class
7
+ * name. Never the message, which may quote a key, a URL or payload data.
8
+ */
9
+ export function failureCode(error) {
10
+ if (typeof error !== 'object' || error === null) {
11
+ return 'UNKNOWN_ERROR';
12
+ }
13
+ if ('code' in error && typeof error.code === 'string' && IDENTIFIER.test(error.code)) {
14
+ return error.code;
15
+ }
16
+ if (!(error instanceof Error)) {
17
+ return 'UNKNOWN_ERROR';
18
+ }
19
+ if (error.name === 'ReplyError') {
20
+ return replyKind(error.message);
21
+ }
22
+ return IDENTIFIER.test(error.constructor.name) ? error.constructor.name : 'UNKNOWN_ERROR';
23
+ }
24
+ function replyKind(reply) {
25
+ const kind = REPLY_KIND.exec(reply)?.[0];
26
+ return kind === undefined ? 'REDIS_ERROR' : `REDIS_${kind}`;
27
+ }
28
+ //# sourceMappingURL=failure-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure-code.js","sourceRoot":"","sources":["../../../src/streams/errors/failure-code.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,iCAAiC,CAAC;AAErD,4FAA4F;AAC5F,MAAM,UAAU,GAAG,6BAA6B,CAAC;AAEjD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrF,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC;AAC5F,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** The server did not acknowledge the entry: it may or may not hold it. Publish again. */
2
+ export declare class PublishNotConfirmedError extends Error {
3
+ readonly eventId: string;
4
+ readonly reason: string;
5
+ readonly code = "PUBLISH_NOT_CONFIRMED";
6
+ /** `reason` is the code of the failure: a transport error, or the kind of error the server answered. */
7
+ constructor(eventId: string, reason: string);
8
+ }
9
+ //# sourceMappingURL=publish-not-confirmed-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-not-confirmed-error.d.ts","sourceRoot":"","sources":["../../../src/streams/errors/publish-not-confirmed-error.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,qBAAa,wBAAyB,SAAQ,KAAK;IAK/C,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM;IALzB,QAAQ,CAAC,IAAI,2BAA2B;IAExC,wGAAwG;IACxG,YACW,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EAIxB;CACF"}
@@ -0,0 +1,14 @@
1
+ /** The server did not acknowledge the entry: it may or may not hold it. Publish again. */
2
+ export class PublishNotConfirmedError extends Error {
3
+ eventId;
4
+ reason;
5
+ code = 'PUBLISH_NOT_CONFIRMED';
6
+ /** `reason` is the code of the failure: a transport error, or the kind of error the server answered. */
7
+ constructor(eventId, reason) {
8
+ super(`The server did not acknowledge event ${eventId} (${reason})`);
9
+ this.eventId = eventId;
10
+ this.reason = reason;
11
+ this.name = 'PublishNotConfirmedError';
12
+ }
13
+ }
14
+ //# sourceMappingURL=publish-not-confirmed-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-not-confirmed-error.js","sourceRoot":"","sources":["../../../src/streams/errors/publish-not-confirmed-error.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAKtC,OAAO;IACP,MAAM;IALR,IAAI,GAAG,uBAAuB,CAAC;IAExC,wGAAwG;IACxG,YACW,OAAe,EACf,MAAc;QAEvB,KAAK,CAAC,wCAAwC,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC;uBAH5D,OAAO;sBACP,MAAM;QAGf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ import type { Redis } from 'ioredis';
2
+ import { type IntegrationEventCallback, type Subscription } from '@ddd-ts-kit/kernel';
3
+ import type { Settings } from './options/settings.js';
4
+ import type { ServerLink } from './server-link.js';
5
+ import type { ConsumerBinding } from './topology/consumer-binding.js';
6
+ /**
7
+ * One consumer on its dedicated connection: a blocking read must not hold up the connection
8
+ * that publishes and acknowledges. The consumer is a group on each stream it subscribed to,
9
+ * and this process one member of it. A turn takes back the pending entries that are due, then
10
+ * waits for new ones for a bounded time; the entries of a stream are handled in their order,
11
+ * one at a time.
12
+ */
13
+ export declare class GroupReader {
14
+ private readonly consumer;
15
+ private readonly link;
16
+ private readonly settings;
17
+ private readonly subscriptions;
18
+ private readonly declared;
19
+ private readonly settlement;
20
+ private running;
21
+ private interrupt;
22
+ private stopping;
23
+ private unsettled;
24
+ private failures;
25
+ private sweptAt;
26
+ constructor(consumer: string, link: ServerLink, settings: Settings);
27
+ /** Entries read by this reader and not settled yet. */
28
+ get inFlight(): number;
29
+ get idle(): boolean;
30
+ bindings(): ConsumerBinding[];
31
+ subscribe(type: string, handler: IntegrationEventCallback): Subscription;
32
+ /** Creates the group on every stream subscribed to so far that does not have it yet. */
33
+ declare(client: Redis): Promise<void>;
34
+ /** Reads nothing more, lets the batch in progress finish and settle, then leaves the group. */
35
+ stop(): Promise<void>;
36
+ private remove;
37
+ private run;
38
+ private turn;
39
+ private sweepIsDue;
40
+ private redelivery;
41
+ private handle;
42
+ private inOrder;
43
+ private read;
44
+ /**
45
+ * After a failure the groups are created again before the next read: a server that came
46
+ * back without its data has lost them. The link already reported a connection that is down.
47
+ */
48
+ private recover;
49
+ private rest;
50
+ private leave;
51
+ /**
52
+ * Removes this process from its groups, where it leaves nothing pending: deleting a
53
+ * consumer drops its pending entries, and those must stay for another instance to claim.
54
+ */
55
+ private retire;
56
+ }
57
+ //# sourceMappingURL=group-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-reader.d.ts","sourceRoot":"","sources":["../../src/streams/group-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAgB,KAAK,wBAAwB,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASpG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAWtE;;;;;;GAMG;AACH,qBAAa,WAAW;IAoBpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IArB3B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyC;IAEvE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAE9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,OAAO,CAAC,OAAO,CAA4B;IAE3C,OAAO,CAAC,SAAS,CAA2B;IAE5C,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,SAAS,CAAK;IAEtB,OAAO,CAAC,QAAQ,CAAK;IAErB,OAAO,CAAC,OAAO,CAAK;IAEpB,YACmB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,QAAQ,EAGpC;IAED,uDAAuD;IACvD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,QAAQ,IAAI,eAAe,EAAE,CAE5B;IAED,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,YAAY,CAevE;IAED,wFAAwF;IAClF,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAS1C;IAED,+FAA+F;IACzF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAI1B;IAGD,OAAO,CAAC,MAAM;YAUA,GAAG;YAeH,IAAI;IAgBlB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,UAAU;YAQJ,MAAM;YAUN,OAAO;YASP,IAAI;IAuBlB;;;OAGG;YACW,OAAO;IAWrB,OAAO,CAAC,IAAI;YAeE,KAAK;IAKnB;;;OAGG;YACW,MAAM;CAYrB"}