@bgord/bun 1.12.11 → 1.14.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 (210) hide show
  1. package/dist/event-finder-noop.adapter.d.ts +9 -0
  2. package/dist/event-finder-noop.adapter.d.ts.map +1 -0
  3. package/dist/event-finder-noop.adapter.js +10 -0
  4. package/dist/event-finder-noop.adapter.js.map +1 -0
  5. package/dist/event-finder.port.d.ts +6 -0
  6. package/dist/event-finder.port.d.ts.map +1 -0
  7. package/dist/event-finder.port.js +2 -0
  8. package/dist/event-finder.port.js.map +1 -0
  9. package/dist/event-inserter-noop.adapter.d.ts +6 -0
  10. package/dist/event-inserter-noop.adapter.d.ts.map +1 -0
  11. package/dist/event-inserter-noop.adapter.js +6 -0
  12. package/dist/event-inserter-noop.adapter.js.map +1 -0
  13. package/dist/event-inserter.port.d.ts +5 -0
  14. package/dist/event-inserter.port.d.ts.map +1 -0
  15. package/dist/event-inserter.port.js +2 -0
  16. package/dist/event-inserter.port.js.map +1 -0
  17. package/dist/event-revision-assigner.adapter.d.ts +7 -0
  18. package/dist/event-revision-assigner.adapter.d.ts.map +1 -0
  19. package/dist/event-revision-assigner.adapter.js +7 -0
  20. package/dist/event-revision-assigner.adapter.js.map +1 -0
  21. package/dist/event-revision-assigner.port.d.ts +5 -0
  22. package/dist/event-revision-assigner.port.d.ts.map +1 -0
  23. package/dist/event-revision-assigner.port.js +2 -0
  24. package/dist/event-revision-assigner.port.js.map +1 -0
  25. package/dist/event-serializer-collecting.adapter.d.ts +8 -0
  26. package/dist/event-serializer-collecting.adapter.d.ts.map +1 -0
  27. package/dist/event-serializer-collecting.adapter.js +13 -0
  28. package/dist/event-serializer-collecting.adapter.js.map +1 -0
  29. package/dist/event-serializer-json.adapter.d.ts +6 -0
  30. package/dist/event-serializer-json.adapter.d.ts.map +1 -0
  31. package/dist/event-serializer-json.adapter.js +9 -0
  32. package/dist/event-serializer-json.adapter.js.map +1 -0
  33. package/dist/event-serializer.port.d.ts +5 -0
  34. package/dist/event-serializer.port.d.ts.map +1 -0
  35. package/dist/event-serializer.port.js +2 -0
  36. package/dist/event-serializer.port.js.map +1 -0
  37. package/dist/event-store-collecting.adapter.d.ts +10 -0
  38. package/dist/event-store-collecting.adapter.d.ts.map +1 -0
  39. package/dist/event-store-collecting.adapter.js +11 -0
  40. package/dist/event-store-collecting.adapter.js.map +1 -0
  41. package/dist/event-store-dispatching.adapter.d.ts +17 -0
  42. package/dist/event-store-dispatching.adapter.d.ts.map +1 -0
  43. package/dist/event-store-dispatching.adapter.js +15 -0
  44. package/dist/event-store-dispatching.adapter.js.map +1 -0
  45. package/dist/event-store-noop.adapter.d.ts +9 -0
  46. package/dist/event-store-noop.adapter.d.ts.map +1 -0
  47. package/dist/event-store-noop.adapter.js +9 -0
  48. package/dist/event-store-noop.adapter.js.map +1 -0
  49. package/dist/event-store.adapter.d.ts +20 -0
  50. package/dist/event-store.adapter.d.ts.map +1 -0
  51. package/dist/event-store.adapter.js +27 -0
  52. package/dist/event-store.adapter.js.map +1 -0
  53. package/dist/event-store.port.d.ts +8 -0
  54. package/dist/event-store.port.d.ts.map +1 -0
  55. package/dist/event-store.port.js +2 -0
  56. package/dist/event-store.port.js.map +1 -0
  57. package/dist/event-validator-registry-zod.adapter.d.ts +24 -0
  58. package/dist/event-validator-registry-zod.adapter.d.ts.map +1 -0
  59. package/dist/event-validator-registry-zod.adapter.js +25 -0
  60. package/dist/event-validator-registry-zod.adapter.js.map +1 -0
  61. package/dist/event-validator-registry.port.d.ts +7 -0
  62. package/dist/event-validator-registry.port.d.ts.map +1 -0
  63. package/dist/event-validator-registry.port.js +2 -0
  64. package/dist/event-validator-registry.port.js.map +1 -0
  65. package/dist/event.types.d.ts +13 -14
  66. package/dist/event.types.d.ts.map +1 -1
  67. package/dist/index.d.ts +22 -13
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +22 -13
  70. package/dist/index.js.map +1 -1
  71. package/dist/message-handler-bare.strategy.d.ts +8 -0
  72. package/dist/message-handler-bare.strategy.d.ts.map +1 -0
  73. package/dist/message-handler-bare.strategy.js +6 -0
  74. package/dist/message-handler-bare.strategy.js.map +1 -0
  75. package/dist/message-handler-noop.strategy.d.ts +8 -0
  76. package/dist/message-handler-noop.strategy.d.ts.map +1 -0
  77. package/dist/message-handler-noop.strategy.js +6 -0
  78. package/dist/message-handler-noop.strategy.js.map +1 -0
  79. package/dist/message-handler-with-logger.strategy.d.ts +17 -0
  80. package/dist/message-handler-with-logger.strategy.d.ts.map +1 -0
  81. package/dist/{event-handler-with-logger.strategy.js → message-handler-with-logger.strategy.js} +7 -7
  82. package/dist/message-handler-with-logger.strategy.js.map +1 -0
  83. package/dist/message-handler.strategy.d.ts +7 -0
  84. package/dist/message-handler.strategy.d.ts.map +1 -0
  85. package/dist/message-handler.strategy.js +2 -0
  86. package/dist/message-handler.strategy.js.map +1 -0
  87. package/dist/modules/preferences/command-handlers/handleSetUserLanguageCommand.d.ts +2 -2
  88. package/dist/modules/preferences/command-handlers/handleSetUserLanguageCommand.d.ts.map +1 -1
  89. package/dist/modules/system/services/passage-of-time-hourly.service.d.ts +2 -2
  90. package/dist/modules/system/services/passage-of-time-hourly.service.d.ts.map +1 -1
  91. package/dist/modules/system/services/passage-of-time-minute.service.d.ts +2 -2
  92. package/dist/modules/system/services/passage-of-time-minute.service.d.ts.map +1 -1
  93. package/dist/security-countermeasure-ban.strategy.d.ts +2 -2
  94. package/dist/security-countermeasure-ban.strategy.d.ts.map +1 -1
  95. package/dist/sse-hono.handler.d.ts +20 -0
  96. package/dist/sse-hono.handler.d.ts.map +1 -0
  97. package/dist/sse-hono.handler.js +35 -0
  98. package/dist/sse-hono.handler.js.map +1 -0
  99. package/dist/sse-registry-collecting.adapter.d.ts +6 -6
  100. package/dist/sse-registry-collecting.adapter.d.ts.map +1 -1
  101. package/dist/sse-registry-collecting.adapter.js +4 -4
  102. package/dist/sse-registry-collecting.adapter.js.map +1 -1
  103. package/dist/sse-registry-noop.adapter.d.ts +5 -5
  104. package/dist/sse-registry-noop.adapter.d.ts.map +1 -1
  105. package/dist/sse-registry-noop.adapter.js +3 -3
  106. package/dist/sse-registry-noop.adapter.js.map +1 -1
  107. package/dist/sse-registry-with-logger.adapter.d.ts +5 -5
  108. package/dist/sse-registry-with-logger.adapter.d.ts.map +1 -1
  109. package/dist/sse-registry-with-logger.adapter.js +11 -11
  110. package/dist/sse-registry-with-logger.adapter.js.map +1 -1
  111. package/dist/sse-registry.adapter.d.ts +6 -6
  112. package/dist/sse-registry.adapter.d.ts.map +1 -1
  113. package/dist/sse-registry.adapter.js +10 -10
  114. package/dist/sse-registry.adapter.js.map +1 -1
  115. package/dist/sse-registry.port.d.ts +5 -4
  116. package/dist/sse-registry.port.d.ts.map +1 -1
  117. package/dist/tsconfig.tsbuildinfo +1 -1
  118. package/package.json +8 -8
  119. package/readme.md +21 -12
  120. package/src/event-finder-noop.adapter.ts +14 -0
  121. package/src/event-finder.port.ts +9 -0
  122. package/src/event-inserter-noop.adapter.ts +10 -0
  123. package/src/event-inserter.port.ts +5 -0
  124. package/src/event-revision-assigner.adapter.ts +13 -0
  125. package/src/event-revision-assigner.port.ts +8 -0
  126. package/src/event-serializer-collecting.adapter.ts +19 -0
  127. package/src/event-serializer-json.adapter.ts +11 -0
  128. package/src/event-serializer.port.ts +4 -0
  129. package/src/event-store-collecting.adapter.ts +21 -0
  130. package/src/event-store-dispatching.adapter.ts +29 -0
  131. package/src/event-store-noop.adapter.ts +17 -0
  132. package/src/event-store.adapter.ts +49 -0
  133. package/src/event-store.port.ts +12 -0
  134. package/src/event-validator-registry-zod.adapter.ts +47 -0
  135. package/src/event-validator-registry.port.ts +7 -0
  136. package/src/event.types.ts +12 -15
  137. package/src/index.ts +22 -13
  138. package/src/message-handler-bare.strategy.ts +11 -0
  139. package/src/message-handler-noop.strategy.ts +11 -0
  140. package/src/message-handler-with-logger.strategy.ts +32 -0
  141. package/src/message-handler.strategy.ts +8 -0
  142. package/src/modules/preferences/command-handlers/handleSetUserLanguageCommand.ts +2 -2
  143. package/src/modules/system/services/passage-of-time-hourly.service.ts +2 -2
  144. package/src/modules/system/services/passage-of-time-minute.service.ts +2 -2
  145. package/src/security-countermeasure-ban.strategy.ts +2 -2
  146. package/src/sse-hono.handler.ts +52 -0
  147. package/src/sse-registry-collecting.adapter.ts +7 -7
  148. package/src/sse-registry-noop.adapter.ts +5 -5
  149. package/src/sse-registry-with-logger.adapter.ts +13 -13
  150. package/src/sse-registry.adapter.ts +11 -11
  151. package/src/sse-registry.port.ts +6 -4
  152. package/dist/dispatching-event-store.d.ts +0 -15
  153. package/dist/dispatching-event-store.d.ts.map +0 -1
  154. package/dist/dispatching-event-store.js +0 -16
  155. package/dist/dispatching-event-store.js.map +0 -1
  156. package/dist/event-handler-bare.strategy.d.ts +0 -6
  157. package/dist/event-handler-bare.strategy.d.ts.map +0 -1
  158. package/dist/event-handler-bare.strategy.js +0 -6
  159. package/dist/event-handler-bare.strategy.js.map +0 -1
  160. package/dist/event-handler-noop.strategy.d.ts +0 -6
  161. package/dist/event-handler-noop.strategy.d.ts.map +0 -1
  162. package/dist/event-handler-noop.strategy.js +0 -6
  163. package/dist/event-handler-noop.strategy.js.map +0 -1
  164. package/dist/event-handler-with-logger.strategy.d.ts +0 -15
  165. package/dist/event-handler-with-logger.strategy.d.ts.map +0 -1
  166. package/dist/event-handler-with-logger.strategy.js.map +0 -1
  167. package/dist/event-handler.strategy.d.ts +0 -5
  168. package/dist/event-handler.strategy.d.ts.map +0 -1
  169. package/dist/event-handler.strategy.js +0 -2
  170. package/dist/event-handler.strategy.js.map +0 -1
  171. package/dist/event-store-like.types.d.ts +0 -5
  172. package/dist/event-store-like.types.d.ts.map +0 -1
  173. package/dist/event-store-like.types.js +0 -2
  174. package/dist/event-store-like.types.js.map +0 -1
  175. package/dist/event-store.d.ts +0 -22
  176. package/dist/event-store.d.ts.map +0 -1
  177. package/dist/event-store.js +0 -37
  178. package/dist/event-store.js.map +0 -1
  179. package/dist/sse-connection-hono.adapter.d.ts +0 -19
  180. package/dist/sse-connection-hono.adapter.d.ts.map +0 -1
  181. package/dist/sse-connection-hono.adapter.js +0 -38
  182. package/dist/sse-connection-hono.adapter.js.map +0 -1
  183. package/dist/sse-connection-hono.handler.d.ts +0 -17
  184. package/dist/sse-connection-hono.handler.d.ts.map +0 -1
  185. package/dist/sse-connection-hono.handler.js +0 -19
  186. package/dist/sse-connection-hono.handler.js.map +0 -1
  187. package/dist/sse-connection-noop.adapter.d.ts +0 -7
  188. package/dist/sse-connection-noop.adapter.d.ts.map +0 -1
  189. package/dist/sse-connection-noop.adapter.js +0 -5
  190. package/dist/sse-connection-noop.adapter.js.map +0 -1
  191. package/dist/sse-connection-with-logger.adapter.d.ts +0 -16
  192. package/dist/sse-connection-with-logger.adapter.d.ts.map +0 -1
  193. package/dist/sse-connection-with-logger.adapter.js +0 -27
  194. package/dist/sse-connection-with-logger.adapter.js.map +0 -1
  195. package/dist/sse-connection.port.d.ts +0 -6
  196. package/dist/sse-connection.port.d.ts.map +0 -1
  197. package/dist/sse-connection.port.js +0 -2
  198. package/dist/sse-connection.port.js.map +0 -1
  199. package/src/dispatching-event-store.ts +0 -34
  200. package/src/event-handler-bare.strategy.ts +0 -8
  201. package/src/event-handler-noop.strategy.ts +0 -8
  202. package/src/event-handler-with-logger.strategy.ts +0 -29
  203. package/src/event-handler.strategy.ts +0 -5
  204. package/src/event-store-like.types.ts +0 -5
  205. package/src/event-store.ts +0 -64
  206. package/src/sse-connection-hono.adapter.ts +0 -49
  207. package/src/sse-connection-hono.handler.ts +0 -22
  208. package/src/sse-connection-noop.adapter.ts +0 -8
  209. package/src/sse-connection-with-logger.adapter.ts +0 -34
  210. package/src/sse-connection.port.ts +0 -7
@@ -0,0 +1,52 @@
1
+ import type * as tools from "@bgord/tools";
2
+ import { createFactory } from "hono/factory";
3
+ import { streamSSE } from "hono/streaming";
4
+ import type { HandlerHonoPort } from "./handler-hono.port";
5
+ import type { HashContentStrategy } from "./hash-content.strategy";
6
+ import type { Message } from "./message.types";
7
+ import { RequestContextHonoAdapter } from "./request-context-hono.adapter";
8
+ import type { SseRegistryPort } from "./sse-registry.port";
9
+ import { SubjectRequestResolver } from "./subject-request-resolver.vo";
10
+ import { SubjectSegmentUserStrategy } from "./subject-segment-user.strategy";
11
+
12
+ export type SseHonoHandlerConfig = { keepalive: tools.Duration };
13
+
14
+ type Dependencies<Messages extends Message> = {
15
+ registry: SseRegistryPort<Messages>;
16
+ HashContent: HashContentStrategy;
17
+ };
18
+
19
+ const factory = createFactory();
20
+
21
+ export class SseHonoHandler<Messages extends Message> implements HandlerHonoPort {
22
+ constructor(
23
+ private readonly config: SseHonoHandlerConfig,
24
+ private readonly deps: Dependencies<Messages>,
25
+ ) {}
26
+
27
+ handle() {
28
+ return factory.createHandlers(async (c) => {
29
+ const context = new RequestContextHonoAdapter(c);
30
+ const resolver = new SubjectRequestResolver([new SubjectSegmentUserStrategy()], this.deps);
31
+
32
+ const subject = await resolver.resolve(context);
33
+
34
+ return streamSSE(c, async (stream) => {
35
+ const send = async <M extends Messages>(message: M) => {
36
+ await stream.writeSSE({ event: message.name, data: JSON.stringify(message) });
37
+ };
38
+
39
+ this.deps.registry.register(subject.hex.get(), send);
40
+
41
+ // Stryker disable all
42
+ stream.onAbort(() => this.deps.registry.unregister(subject.hex.get(), send));
43
+ // Stryker restore all
44
+
45
+ while (!stream.closed) {
46
+ await stream.sleep(this.config.keepalive.ms);
47
+ await stream.writeSSE({ event: "ping", data: JSON.stringify({ keepalive: true }) });
48
+ }
49
+ });
50
+ });
51
+ }
52
+ }
@@ -1,15 +1,15 @@
1
+ import type { HashValueType } from "./hash-value.vo";
1
2
  import type { Message } from "./message.types";
2
- import type { SseConnectionPort } from "./sse-connection.port";
3
- import type { SseRegistryPort } from "./sse-registry.port";
3
+ import type { SseRegistryPort, SseSenderType } from "./sse-registry.port";
4
4
 
5
5
  export class SseRegistryCollectingAdapter<Messages extends Message> implements SseRegistryPort<Messages> {
6
- public emitted: Array<{ userId: string; message: Messages }> = [];
6
+ public emitted: Array<{ identity: HashValueType; message: Messages }> = [];
7
7
 
8
- register(_userId: string, _connection: SseConnectionPort<Messages>): void {}
8
+ register(_identity: HashValueType, _sender: SseSenderType<Messages>): void {}
9
9
 
10
- unregister(_userId: string, _connection: SseConnectionPort<Messages>): void {}
10
+ unregister(_identity: HashValueType, _sender: SseSenderType<Messages>): void {}
11
11
 
12
- async emit<M extends Messages>(userId: string, message: M): Promise<void> {
13
- this.emitted.push({ userId, message });
12
+ async emit<M extends Messages>(identity: HashValueType, message: M): Promise<void> {
13
+ this.emitted.push({ identity, message });
14
14
  }
15
15
  }
@@ -1,11 +1,11 @@
1
+ import type { HashValueType } from "./hash-value.vo";
1
2
  import type { Message } from "./message.types";
2
- import type { SseConnectionPort } from "./sse-connection.port";
3
- import type { SseRegistryPort } from "./sse-registry.port";
3
+ import type { SseRegistryPort, SseSenderType } from "./sse-registry.port";
4
4
 
5
5
  export class SseRegistryNoopAdapter<Messages extends Message> implements SseRegistryPort<Messages> {
6
- register(_userId: string, _connection: SseConnectionPort<Messages>): void {}
6
+ register(_identity: HashValueType, _sender: SseSenderType<Messages>): void {}
7
7
 
8
- unregister(_userId: string, _connection: SseConnectionPort<Messages>): void {}
8
+ unregister(_identity: HashValueType, _sender: SseSenderType<Messages>): void {}
9
9
 
10
- async emit<M extends Messages>(_userId: string, _message: M): Promise<void> {}
10
+ async emit<M extends Messages>(_identity: HashValueType, _message: M): Promise<void> {}
11
11
  }
@@ -1,8 +1,8 @@
1
1
  import { CorrelationStorage } from "./correlation-storage.service";
2
+ import type { HashValueType } from "./hash-value.vo";
2
3
  import type { LoggerPort } from "./logger.port";
3
4
  import type { Message } from "./message.types";
4
- import type { SseConnectionPort } from "./sse-connection.port";
5
- import type { SseRegistryPort } from "./sse-registry.port";
5
+ import type { SseRegistryPort, SseSenderType } from "./sse-registry.port";
6
6
 
7
7
  type Dependencies<Messages extends Message> = { inner: SseRegistryPort<Messages>; Logger: LoggerPort };
8
8
 
@@ -11,36 +11,36 @@ export class SseRegistryWithLoggerAdapter<Messages extends Message> implements S
11
11
 
12
12
  constructor(private readonly deps: Dependencies<Messages>) {}
13
13
 
14
- register(userId: string, connection: SseConnectionPort<Messages>): void {
14
+ register(identity: HashValueType, sender: SseSenderType<Messages>): void {
15
15
  this.deps.Logger.info({
16
- message: "SSE connection registered",
17
- metadata: { userId },
16
+ message: "SSE sender registered",
17
+ metadata: { identity },
18
18
  correlationId: CorrelationStorage.get(),
19
19
  ...this.base,
20
20
  });
21
21
 
22
- this.deps.inner.register(userId, connection);
22
+ this.deps.inner.register(identity, sender);
23
23
  }
24
24
 
25
- unregister(userId: string, connection: SseConnectionPort<Messages>): void {
25
+ unregister(identity: HashValueType, sender: SseSenderType<Messages>): void {
26
26
  this.deps.Logger.info({
27
- message: "SSE connection unregistered",
28
- metadata: { userId },
27
+ message: "SSE sender unregistered",
28
+ metadata: { identity },
29
29
  correlationId: CorrelationStorage.get(),
30
30
  ...this.base,
31
31
  });
32
32
 
33
- this.deps.inner.unregister(userId, connection);
33
+ this.deps.inner.unregister(identity, sender);
34
34
  }
35
35
 
36
- async emit<M extends Messages>(userId: string, message: M): Promise<void> {
36
+ async emit<M extends Messages>(identity: HashValueType, message: M): Promise<void> {
37
37
  this.deps.Logger.info({
38
38
  message: `${message.name} emitted`,
39
- metadata: { userId, message },
39
+ metadata: { identity, message },
40
40
  correlationId: CorrelationStorage.get(),
41
41
  ...this.base,
42
42
  });
43
43
 
44
- return this.deps.inner.emit(userId, message);
44
+ return this.deps.inner.emit(identity, message);
45
45
  }
46
46
  }
@@ -1,23 +1,23 @@
1
+ import type { HashValueType } from "./hash-value.vo";
1
2
  import type { Message } from "./message.types";
2
- import type { SseConnectionPort } from "./sse-connection.port";
3
- import type { SseRegistryPort } from "./sse-registry.port";
3
+ import type { SseRegistryPort, SseSenderType } from "./sse-registry.port";
4
4
 
5
5
  export class SseRegistryAdapter<Messages extends Message> implements SseRegistryPort<Messages> {
6
- private readonly connections = new Map<string, Set<SseConnectionPort<Messages>>>();
6
+ private readonly senders = new Map<HashValueType, Set<SseSenderType<Messages>>>();
7
7
 
8
- register(userId: string, connection: SseConnectionPort<Messages>): void {
9
- if (!this.connections.has(userId)) this.connections.set(userId, new Set());
8
+ register(identity: HashValueType, connection: SseSenderType<Messages>): void {
9
+ if (!this.senders.has(identity)) this.senders.set(identity, new Set());
10
10
 
11
- this.connections.get(userId)!.add(connection);
11
+ this.senders.get(identity)!.add(connection);
12
12
  }
13
13
 
14
- unregister(userId: string, connection: SseConnectionPort<Messages>): void {
15
- this.connections.get(userId)?.delete(connection);
14
+ unregister(identity: HashValueType, connection: SseSenderType<Messages>): void {
15
+ this.senders.get(identity)?.delete(connection);
16
16
  }
17
17
 
18
- async emit<M extends Messages>(userId: string, message: M): Promise<void> {
19
- for (const connection of this.connections.get(userId) ?? []) {
20
- await connection.send(message);
18
+ async emit<M extends Messages>(identity: HashValueType, message: M): Promise<void> {
19
+ for (const sender of this.senders.get(identity) ?? []) {
20
+ await sender(message);
21
21
  }
22
22
  }
23
23
  }
@@ -1,10 +1,12 @@
1
+ import type { HashValueType } from "./hash-value.vo";
1
2
  import type { Message } from "./message.types";
2
- import type { SseConnectionPort } from "./sse-connection.port";
3
+
4
+ export type SseSenderType<Messages extends Message> = <M extends Messages>(message: M) => Promise<void>;
3
5
 
4
6
  export interface SseRegistryPort<Messages extends Message> {
5
- register(userId: string, connection: SseConnectionPort<Messages>): void;
7
+ register(identity: HashValueType, sender: SseSenderType<Messages>): void;
6
8
 
7
- unregister(userId: string, connection: SseConnectionPort<Messages>): void;
9
+ unregister(identity: HashValueType, sender: SseSenderType<Messages>): void;
8
10
 
9
- emit<M extends Messages>(userId: string, message: M): Promise<void>;
11
+ emit<M extends Messages>(identity: HashValueType, message: M): Promise<void>;
10
12
  }
@@ -1,15 +0,0 @@
1
- import type * as z from "zod/v4";
2
- import type { GenericEventSchema, GenericParsedEventSchema } from "./event.types";
3
- import { EventStore as BaseStore } from "./event-store";
4
- import type { EventStreamType } from "./event-stream.vo";
5
- import type { EventBusPort } from "./message-bus.port";
6
- export declare class DispatchingEventStore<AllEvents extends GenericEventSchema> extends BaseStore<AllEvents> {
7
- private readonly publisher;
8
- static EMPTY_STREAM_REVISION: number;
9
- constructor(config: {
10
- finder: (stream: EventStreamType, names: ReadonlyArray<string>) => Promise<ReadonlyArray<z.infer<GenericEventSchema>>>;
11
- inserter: (events: ReadonlyArray<z.infer<GenericParsedEventSchema>>) => Promise<ReadonlyArray<z.infer<GenericParsedEventSchema>>>;
12
- }, publisher: EventBusPort<z.infer<AllEvents>>);
13
- save(_events: ReadonlyArray<z.infer<AllEvents>>): Promise<ReadonlyArray<z.infer<AllEvents>>>;
14
- }
15
- //# sourceMappingURL=dispatching-event-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatching-event-store.d.ts","sourceRoot":"","sources":["../src/dispatching-event-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,CAAC,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,qBAAqB,CAAC,SAAS,SAAS,kBAAkB,CAAE,SAAQ,SAAS,CAAC,SAAS,CAAC;IAajG,OAAO,CAAC,QAAQ,CAAC,SAAS;IAZ5B,MAAM,CAAC,qBAAqB,SAAM;gBAGhC,MAAM,EAAE;QACN,MAAM,EAAE,CACN,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,KACzB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACzD,QAAQ,EAAE,CACR,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,KACrD,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;KAChE,EACgB,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAKxD,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;CAOnG"}
@@ -1,16 +0,0 @@
1
- import { EventStore as BaseStore } from "./event-store";
2
- export class DispatchingEventStore extends BaseStore {
3
- publisher;
4
- static EMPTY_STREAM_REVISION = -1;
5
- constructor(config, publisher) {
6
- super(config);
7
- this.publisher = publisher;
8
- }
9
- async save(_events) {
10
- const events = await super.save(_events);
11
- await Promise.all(events.map((event) => this.publisher.emit(event)));
12
- return events;
13
- }
14
- }
15
- // Stryker restore all
16
- //# sourceMappingURL=dispatching-event-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatching-event-store.js","sourceRoot":"","sources":["../src/dispatching-event-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,eAAe,CAAC;AAIxD,MAAM,OAAO,qBAA4D,SAAQ,SAAoB;IAahF;IAZnB,MAAM,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;IAElC,YACE,MAQC,EACgB,SAA2C;QAE5D,KAAK,CAAC,MAAM,CAAC,CAAC;QAFG,cAAS,GAAT,SAAS,CAAkC;IAG9D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAA0C;QACnD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEzC,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErE,OAAO,MAAM,CAAC;IAChB,CAAC;;AAEH,sBAAsB"}
@@ -1,6 +0,0 @@
1
- import type { EventHandlerStrategy } from "./event-handler.strategy";
2
- import type { Message } from "./message.types";
3
- export declare class EventHandlerBareStrategy implements EventHandlerStrategy {
4
- handle<Event extends Message>(handler: (event: Event) => Promise<void>): (event: Event) => Promise<void>;
5
- }
6
- //# sourceMappingURL=event-handler-bare.strategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler-bare.strategy.d.ts","sourceRoot":"","sources":["../src/event-handler-bare.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,MAAM,CAAC,KAAK,SAAS,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,IACtD,OAAO,KAAK;CAE7B"}
@@ -1,6 +0,0 @@
1
- export class EventHandlerBareStrategy {
2
- handle(handler) {
3
- return async (event) => handler(event);
4
- }
5
- }
6
- //# sourceMappingURL=event-handler-bare.strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler-bare.strategy.js","sourceRoot":"","sources":["../src/event-handler-bare.strategy.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,wBAAwB;IACnC,MAAM,CAAwB,OAAwC;QACpE,OAAO,KAAK,EAAE,KAAY,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- import type { EventHandlerStrategy } from "./event-handler.strategy";
2
- import type { Message } from "./message.types";
3
- export declare class EventHandlerNoopStrategy implements EventHandlerStrategy {
4
- handle<Event extends Message>(_handler: (event: Event) => Promise<void>): (_event: Event) => Promise<void>;
5
- }
6
- //# sourceMappingURL=event-handler-noop.strategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler-noop.strategy.d.ts","sourceRoot":"","sources":["../src/event-handler-noop.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,MAAM,CAAC,KAAK,SAAS,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,IACvD,QAAQ,KAAK;CAE9B"}
@@ -1,6 +0,0 @@
1
- export class EventHandlerNoopStrategy {
2
- handle(_handler) {
3
- return async (_event) => { };
4
- }
5
- }
6
- //# sourceMappingURL=event-handler-noop.strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler-noop.strategy.js","sourceRoot":"","sources":["../src/event-handler-noop.strategy.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,wBAAwB;IACnC,MAAM,CAAwB,QAAyC;QACrE,OAAO,KAAK,EAAE,MAAa,EAAE,EAAE,GAAE,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -1,15 +0,0 @@
1
- import type { ClockPort } from "./clock.port";
2
- import type { EventHandlerStrategy } from "./event-handler.strategy";
3
- import type { LoggerPort } from "./logger.port";
4
- import type { Message } from "./message.types";
5
- type Dependencies = {
6
- Logger: LoggerPort;
7
- Clock: ClockPort;
8
- };
9
- export declare class EventHandlerWithLoggerStrategy implements EventHandlerStrategy {
10
- private readonly deps;
11
- constructor(deps: Dependencies);
12
- handle<Event extends Message>(handler: (event: Event) => Promise<void>): (event: Event) => Promise<void>;
13
- }
14
- export {};
15
- //# sourceMappingURL=event-handler-with-logger.strategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler-with-logger.strategy.d.ts","sourceRoot":"","sources":["../src/event-handler-with-logger.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,KAAK,YAAY,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAE7D,qBAAa,8BAA+B,YAAW,oBAAoB;IAC7D,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C,MAAM,CAAC,KAAK,SAAS,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,IACtD,OAAO,KAAK;CAgB7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler-with-logger.strategy.js","sourceRoot":"","sources":["../src/event-handler-with-logger.strategy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,MAAM,OAAO,8BAA8B;IACZ;IAA7B,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAEnD,MAAM,CAAwB,OAAwC;QACpE,OAAO,KAAK,EAAE,KAAY,EAAE,EAAE;YAC5B,MAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE1C,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;oBACrB,OAAO,EAAE,WAAW,KAAK,CAAC,IAAI,sBAAsB;oBACpD,SAAS,EAAE,OAAO;oBAClB,SAAS,EAAE,eAAe;oBAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE;oBACzD,KAAK;iBACN,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
@@ -1,5 +0,0 @@
1
- import type { Message } from "./message.types";
2
- export interface EventHandlerStrategy {
3
- handle<Event extends Message>(handler: (event: Event) => Promise<void>): (event: Event) => Promise<void>;
4
- }
5
- //# sourceMappingURL=event-handler.strategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler.strategy.d.ts","sourceRoot":"","sources":["../src/event-handler.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,KAAK,SAAS,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1G"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=event-handler.strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-handler.strategy.js","sourceRoot":"","sources":["../src/event-handler.strategy.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import type { Message } from "./message.types";
2
- export type EventStoreLike<Event extends Message> = {
3
- save(events: ReadonlyArray<Event>): Promise<unknown>;
4
- };
5
- //# sourceMappingURL=event-store-like.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-store-like.types.d.ts","sourceRoot":"","sources":["../src/event-store-like.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,IAAI;IAClD,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=event-store-like.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-store-like.types.js","sourceRoot":"","sources":["../src/event-store-like.types.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- import type * as z from "zod/v4";
2
- import type { GenericEventSchema, GenericParsedEventSchema } from "./event.types";
3
- import type { EventStreamType } from "./event-stream.vo";
4
- export type EventNameType = z.infer<GenericEventSchema["shape"]["name"]>;
5
- type FindEventsHandler = (stream: EventStreamType, acceptedEventsNames: ReadonlyArray<EventNameType>) => Promise<ReadonlyArray<z.infer<GenericEventSchema>>>;
6
- type InserterEventsHandler = (events: ReadonlyArray<z.infer<GenericParsedEventSchema>>) => Promise<ReadonlyArray<z.infer<GenericParsedEventSchema>>>;
7
- type Config = {
8
- finder: FindEventsHandler;
9
- inserter: InserterEventsHandler;
10
- };
11
- export declare class EventStore<AllEvents extends GenericEventSchema> {
12
- private readonly config;
13
- constructor(config: Config);
14
- static EMPTY_STREAM_REVISION: number;
15
- find<AcceptedEvents extends ReadonlyArray<AllEvents>>(acceptedEvents: AcceptedEvents, stream: EventStreamType): Promise<ReadonlyArray<z.infer<AcceptedEvents[number]>>>;
16
- save(events: ReadonlyArray<z.infer<AllEvents>>): Promise<ReadonlyArray<z.infer<AllEvents>>>;
17
- }
18
- export declare class EventStoreSaveUniqueStream extends Error {
19
- constructor();
20
- }
21
- export {};
22
- //# sourceMappingURL=event-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../src/event-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,CAAC,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEzE,KAAK,iBAAiB,GAAG,CACvB,MAAM,EAAE,eAAe,EACvB,mBAAmB,EAAE,aAAa,CAAC,aAAa,CAAC,KAC9C,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAEzD,KAAK,qBAAqB,GAAG,CAC3B,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,KACrD,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAE/D,KAAK,MAAM,GAAG;IAAE,MAAM,EAAE,iBAAiB,CAAC;IAAC,QAAQ,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAE7E,qBAAa,UAAU,CAAC,SAAS,SAAS,kBAAkB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,MAAM,CAAC,qBAAqB,SAAM;IAE5B,IAAI,CAAC,cAAc,SAAS,aAAa,CAAC,SAAS,CAAC,EACxD,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAWpD,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;CAkBlG;AAED,qBAAa,0BAA2B,SAAQ,KAAK;;CAKpD"}
@@ -1,37 +0,0 @@
1
- export class EventStore {
2
- config;
3
- constructor(config) {
4
- this.config = config;
5
- }
6
- static EMPTY_STREAM_REVISION = -1;
7
- async find(acceptedEvents, stream) {
8
- const acceptedEventsNames = acceptedEvents.map((event) => event.shape.name.value);
9
- const rows = await this.config.finder(stream, acceptedEventsNames);
10
- return rows
11
- .map((row) => ({ ...row, payload: JSON.parse(row.payload) }))
12
- .map((row) => acceptedEvents.find((event) => event.shape.name.value === row.name)?.parse(row))
13
- .filter((event) => event !== undefined);
14
- }
15
- async save(events) {
16
- if (!events[0])
17
- return [];
18
- const stream = events[0].stream;
19
- if (!events.every((event) => event.stream === stream))
20
- throw new EventStoreSaveUniqueStream();
21
- // The returned variable has the `revision` fields added by the inserter,
22
- // but we need to re-parse it to keep the contract.
23
- const processed = await this.config.inserter(events.map((event) => ({ ...event, payload: JSON.stringify(event.payload) })));
24
- return processed.map((event) => ({
25
- ...event,
26
- payload: JSON.parse(event.payload),
27
- }));
28
- }
29
- }
30
- export class EventStoreSaveUniqueStream extends Error {
31
- constructor() {
32
- super();
33
- Object.setPrototypeOf(this, EventStoreSaveUniqueStream.prototype);
34
- }
35
- }
36
- // Stryker restore all
37
- //# sourceMappingURL=event-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-store.js","sourceRoot":"","sources":["../src/event-store.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,MAAM,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;IAElC,KAAK,CAAC,IAAI,CACR,cAA8B,EAC9B,MAAuB;QAEvB,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;QAEnE,OAAO,IAAI;aACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;aAC5D,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;aAC7F,MAAM,CAAC,CAAC,KAAK,EAA4C,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACtF,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAyC;QAClD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;QAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAEhC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;YAAE,MAAM,IAAI,0BAA0B,EAAE,CAAC;QAE9F,yEAAyE;QACzE,mDAAmD;QACnD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAC1C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAC9E,CAAC;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC/B,GAAG,KAAK;YACR,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;SACnC,CAAC,CAA8B,CAAC;IACnC,CAAC;;AAGH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD;QACE,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC;CACF;AACD,sBAAsB"}
@@ -1,19 +0,0 @@
1
- import type * as tools from "@bgord/tools";
2
- import type { Context } from "hono";
3
- import type { Message } from "./message.types";
4
- import type { SseConnectionPort } from "./sse-connection.port";
5
- import type { SseRegistryPort } from "./sse-registry.port";
6
- export type SseConnectionHonoAdapterConfig = {
7
- keepalive: tools.Duration;
8
- };
9
- export declare class SseConnectionHonoAdapter<Messages extends Message> implements SseConnectionPort<Messages> {
10
- private readonly registry;
11
- private readonly userId;
12
- private readonly config;
13
- private stream;
14
- constructor(registry: SseRegistryPort<Messages>, userId: string, config: SseConnectionHonoAdapterConfig);
15
- attach(c: Context): Response;
16
- send<M extends Messages>(message: M): Promise<void>;
17
- close(callback: () => void): void;
18
- }
19
- //# sourceMappingURL=sse-connection-hono.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-hono.adapter.d.ts","sourceRoot":"","sources":["../src/sse-connection-hono.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,8BAA8B,GAAG;IAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAA;CAAE,CAAC;AAE3E,qBAAa,wBAAwB,CAAC,QAAQ,SAAS,OAAO,CAAE,YAAW,iBAAiB,CAAC,QAAQ,CAAC;IAIlG,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,MAAM,CAAwE;gBAGnE,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,EACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,8BAA8B;IAGzD,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,QAAQ;IAiBtB,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAMzD,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;CAOlC"}
@@ -1,38 +0,0 @@
1
- import { streamSSE } from "hono/streaming";
2
- export class SseConnectionHonoAdapter {
3
- registry;
4
- userId;
5
- config;
6
- stream = null;
7
- constructor(registry, userId, config) {
8
- this.registry = registry;
9
- this.userId = userId;
10
- this.config = config;
11
- }
12
- attach(c) {
13
- return streamSSE(c, async (stream) => {
14
- this.stream = stream;
15
- this.registry.register(this.userId, this);
16
- // Stryker disable all
17
- stream.onAbort(() => this.registry.unregister(this.userId, this));
18
- // Stryker restore all
19
- while (!stream.closed) {
20
- await stream.sleep(this.config.keepalive.ms);
21
- await stream.writeSSE({ event: "ping", data: "" });
22
- }
23
- });
24
- }
25
- async send(message) {
26
- // Stryker disable all
27
- await this.stream?.writeSSE({ event: message.name, data: JSON.stringify(message) });
28
- // Stryker restore all;
29
- }
30
- close(callback) {
31
- this.registry.unregister(this.userId, this);
32
- callback();
33
- // Stryker disable all
34
- this.stream?.close();
35
- // Stryker restore all
36
- }
37
- }
38
- //# sourceMappingURL=sse-connection-hono.adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-hono.adapter.js","sourceRoot":"","sources":["../src/sse-connection-hono.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,MAAM,OAAO,wBAAwB;IAIhB;IACA;IACA;IALX,MAAM,GAAmE,IAAI,CAAC;IAEtF,YACmB,QAAmC,EACnC,MAAc,EACd,MAAsC;QAFtC,aAAQ,GAAR,QAAQ,CAA2B;QACnC,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAgC;IACtD,CAAC;IAEJ,MAAM,CAAC,CAAU;QACf,OAAO,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YAErB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAE1C,sBAAsB;YACtB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YAClE,sBAAsB;YAEtB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACtB,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBAC7C,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAqB,OAAU;QACvC,sBAAsB;QACtB,MAAM,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpF,uBAAuB;IACzB,CAAC;IAED,KAAK,CAAC,QAAoB;QACxB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5C,QAAQ,EAAE,CAAC;QACX,sBAAsB;QACtB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;QACrB,sBAAsB;IACxB,CAAC;CACF"}
@@ -1,17 +0,0 @@
1
- import type { HandlerHonoPort } from "./handler-hono.port";
2
- import type { Message } from "./message.types";
3
- import { type SseConnectionHonoAdapterConfig } from "./sse-connection-hono.adapter";
4
- import type { SseRegistryPort } from "./sse-registry.port";
5
- export declare class SseConnectionHonoHandler<Messages extends Message> implements HandlerHonoPort {
6
- private readonly registry;
7
- private readonly config;
8
- constructor(registry: SseRegistryPort<Messages>, config: SseConnectionHonoAdapterConfig);
9
- handle(): [import("hono/types").H<{
10
- Variables: {
11
- user: {
12
- id: string;
13
- };
14
- };
15
- }, string, {}, any>];
16
- }
17
- //# sourceMappingURL=sse-connection-hono.handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-hono.handler.d.ts","sourceRoot":"","sources":["../src/sse-connection-hono.handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAA4B,KAAK,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC9G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI3D,qBAAa,wBAAwB,CAAC,QAAQ,SAAS,OAAO,CAAE,YAAW,eAAe;IAEtF,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,EACnC,MAAM,EAAE,8BAA8B;IAGzD,MAAM;mBACgD;YAAE,IAAI,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE;;CAM/E"}
@@ -1,19 +0,0 @@
1
- import { createFactory } from "hono/factory";
2
- import { SseConnectionHonoAdapter } from "./sse-connection-hono.adapter";
3
- const factory = createFactory();
4
- export class SseConnectionHonoHandler {
5
- registry;
6
- config;
7
- constructor(registry, config) {
8
- this.registry = registry;
9
- this.config = config;
10
- }
11
- handle() {
12
- return factory.createHandlers((c) => {
13
- const userId = c.get("user").id;
14
- const adapter = new SseConnectionHonoAdapter(this.registry, userId, this.config);
15
- return adapter.attach(c);
16
- });
17
- }
18
- }
19
- //# sourceMappingURL=sse-connection-hono.handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-hono.handler.js","sourceRoot":"","sources":["../src/sse-connection-hono.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,wBAAwB,EAAuC,MAAM,+BAA+B,CAAC;AAG9G,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;AAEhC,MAAM,OAAO,wBAAwB;IAEhB;IACA;IAFnB,YACmB,QAAmC,EACnC,MAAsC;QADtC,aAAQ,GAAR,QAAQ,CAA2B;QACnC,WAAM,GAAN,MAAM,CAAgC;IACtD,CAAC;IAEJ,MAAM;QACJ,OAAO,OAAO,CAAC,cAAc,CAAmD,CAAC,CAAC,EAAE,EAAE;YACpF,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,IAAI,wBAAwB,CAAW,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3F,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,7 +0,0 @@
1
- import type { Message } from "./message.types";
2
- import type { SseConnectionPort } from "./sse-connection.port";
3
- export declare class SseConnectionNoopAdapter<Messages extends Message> implements SseConnectionPort<Messages> {
4
- send<M extends Messages>(_message: M): Promise<void>;
5
- close(_callback: () => void): void;
6
- }
7
- //# sourceMappingURL=sse-connection-noop.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-noop.adapter.d.ts","sourceRoot":"","sources":["../src/sse-connection-noop.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,qBAAa,wBAAwB,CAAC,QAAQ,SAAS,OAAO,CAAE,YAAW,iBAAiB,CAAC,QAAQ,CAAC;IAC9F,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAE1C,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,IAAI;CACnC"}
@@ -1,5 +0,0 @@
1
- export class SseConnectionNoopAdapter {
2
- async send(_message) { }
3
- close(_callback) { }
4
- }
5
- //# sourceMappingURL=sse-connection-noop.adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-noop.adapter.js","sourceRoot":"","sources":["../src/sse-connection-noop.adapter.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,wBAAwB;IACnC,KAAK,CAAC,IAAI,CAAqB,QAAW,IAAG,CAAC;IAE9C,KAAK,CAAC,SAAqB,IAAS,CAAC;CACtC"}
@@ -1,16 +0,0 @@
1
- import type { LoggerPort } from "./logger.port";
2
- import type { Message } from "./message.types";
3
- import type { SseConnectionPort } from "./sse-connection.port";
4
- type Dependencies<Messages extends Message> = {
5
- inner: SseConnectionPort<Messages>;
6
- Logger: LoggerPort;
7
- };
8
- export declare class SseConnectionWithLoggerAdapter<Messages extends Message> implements SseConnectionPort<Messages> {
9
- private readonly deps;
10
- private readonly base;
11
- constructor(deps: Dependencies<Messages>);
12
- send<M extends Messages>(message: M): Promise<void>;
13
- close(callback: () => void): void;
14
- }
15
- export {};
16
- //# sourceMappingURL=sse-connection-with-logger.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-connection-with-logger.adapter.d.ts","sourceRoot":"","sources":["../src/sse-connection-with-logger.adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,KAAK,YAAY,CAAC,QAAQ,SAAS,OAAO,IAAI;IAAE,KAAK,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzG,qBAAa,8BAA8B,CAAC,QAAQ,SAAS,OAAO,CAAE,YAAW,iBAAiB,CAAC,QAAQ,CAAC;IAG9F,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuD;gBAE/C,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC;IAEnD,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,EAAE,CAAC;IAWzC,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;CAUlC"}