@powerhousedao/reactor 4.1.0-dev.5 → 4.1.0-dev.50

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 (148) hide show
  1. package/dist/bench/event-bus.bench.js +18 -28
  2. package/dist/bench/event-bus.bench.js.map +1 -1
  3. package/dist/bench/queue-only.bench.js +9 -3
  4. package/dist/bench/queue-only.bench.js.map +1 -1
  5. package/dist/bench/reactor-throughput.bench.js +42 -35
  6. package/dist/bench/reactor-throughput.bench.js.map +1 -1
  7. package/dist/src/events/event-bus.d.ts +3 -3
  8. package/dist/src/events/event-bus.d.ts.map +1 -1
  9. package/dist/src/events/event-bus.js +1 -1
  10. package/dist/src/events/event-bus.js.map +1 -1
  11. package/dist/src/events/interfaces.d.ts +1 -1
  12. package/dist/src/events/interfaces.d.ts.map +1 -1
  13. package/dist/src/events/types.d.ts +1 -1
  14. package/dist/src/events/types.d.ts.map +1 -1
  15. package/dist/src/events/types.js.map +1 -1
  16. package/dist/src/executor/interfaces.d.ts +31 -54
  17. package/dist/src/executor/interfaces.d.ts.map +1 -1
  18. package/dist/src/executor/simple-job-executor-manager.d.ts +27 -0
  19. package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -0
  20. package/dist/src/executor/simple-job-executor-manager.js +128 -0
  21. package/dist/src/executor/simple-job-executor-manager.js.map +1 -0
  22. package/dist/src/executor/simple-job-executor.d.ts +19 -0
  23. package/dist/src/executor/simple-job-executor.d.ts.map +1 -0
  24. package/dist/src/executor/simple-job-executor.js +69 -0
  25. package/dist/src/executor/simple-job-executor.js.map +1 -0
  26. package/dist/src/executor/types.d.ts +23 -8
  27. package/dist/src/executor/types.d.ts.map +1 -1
  28. package/dist/src/executor/types.js.map +1 -1
  29. package/dist/src/index.d.ts +9 -2
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +8 -2
  32. package/dist/src/index.js.map +1 -1
  33. package/dist/src/interfaces/reactor.d.ts +121 -0
  34. package/dist/src/interfaces/reactor.d.ts.map +1 -0
  35. package/dist/src/interfaces/reactor.js +2 -0
  36. package/dist/src/interfaces/reactor.js.map +1 -0
  37. package/dist/src/queue/interfaces.d.ts +45 -5
  38. package/dist/src/queue/interfaces.d.ts.map +1 -1
  39. package/dist/src/queue/job-execution-handle.d.ts +23 -0
  40. package/dist/src/queue/job-execution-handle.d.ts.map +1 -0
  41. package/dist/src/queue/job-execution-handle.js +62 -0
  42. package/dist/src/queue/job-execution-handle.js.map +1 -0
  43. package/dist/src/queue/queue.d.ts +54 -5
  44. package/dist/src/queue/queue.d.ts.map +1 -1
  45. package/dist/src/queue/queue.js +237 -23
  46. package/dist/src/queue/queue.js.map +1 -1
  47. package/dist/src/queue/types.d.ts +26 -1
  48. package/dist/src/queue/types.d.ts.map +1 -1
  49. package/dist/src/queue/types.js +12 -0
  50. package/dist/src/queue/types.js.map +1 -1
  51. package/dist/src/reactor.d.ts +109 -0
  52. package/dist/src/reactor.d.ts.map +1 -0
  53. package/dist/src/reactor.js +610 -0
  54. package/dist/src/reactor.js.map +1 -0
  55. package/dist/src/registry/implementation.d.ts +62 -0
  56. package/dist/src/registry/implementation.d.ts.map +1 -0
  57. package/dist/src/registry/implementation.js +96 -0
  58. package/dist/src/registry/implementation.js.map +1 -0
  59. package/dist/src/registry/index.d.ts +3 -0
  60. package/dist/src/registry/index.d.ts.map +1 -0
  61. package/dist/src/registry/index.js +2 -0
  62. package/dist/src/registry/index.js.map +1 -0
  63. package/dist/src/registry/interfaces.d.ts +39 -0
  64. package/dist/src/registry/interfaces.d.ts.map +1 -0
  65. package/dist/src/registry/interfaces.js +2 -0
  66. package/dist/src/registry/interfaces.js.map +1 -0
  67. package/dist/src/shared/factories.d.ts +16 -0
  68. package/dist/src/shared/factories.d.ts.map +1 -0
  69. package/dist/src/shared/factories.js +33 -0
  70. package/dist/src/shared/factories.js.map +1 -0
  71. package/dist/src/shared/types.d.ts +83 -19
  72. package/dist/src/shared/types.d.ts.map +1 -1
  73. package/dist/src/shared/types.js +30 -1
  74. package/dist/src/shared/types.js.map +1 -1
  75. package/dist/src/shared/utils.d.ts +3 -0
  76. package/dist/src/shared/utils.d.ts.map +1 -0
  77. package/dist/src/shared/utils.js +8 -0
  78. package/dist/src/shared/utils.js.map +1 -0
  79. package/dist/src/utils.d.ts +11 -0
  80. package/dist/src/utils.d.ts.map +1 -0
  81. package/dist/src/utils.js +31 -0
  82. package/dist/src/utils.js.map +1 -0
  83. package/dist/test/event-bus.test.js +23 -14
  84. package/dist/test/event-bus.test.js.map +1 -1
  85. package/dist/test/executor/executor-integration.test.d.ts +2 -0
  86. package/dist/test/executor/executor-integration.test.d.ts.map +1 -0
  87. package/dist/test/executor/executor-integration.test.js +287 -0
  88. package/dist/test/executor/executor-integration.test.js.map +1 -0
  89. package/dist/test/executor/job-execution-handle.test.d.ts +2 -0
  90. package/dist/test/executor/job-execution-handle.test.d.ts.map +1 -0
  91. package/dist/test/executor/job-execution-handle.test.js +272 -0
  92. package/dist/test/executor/job-execution-handle.test.js.map +1 -0
  93. package/dist/test/executor/simple-job-executor-manager.test.d.ts +2 -0
  94. package/dist/test/executor/simple-job-executor-manager.test.d.ts.map +1 -0
  95. package/dist/test/executor/simple-job-executor-manager.test.js +132 -0
  96. package/dist/test/executor/simple-job-executor-manager.test.js.map +1 -0
  97. package/dist/test/executor/simple-job-executor.test.d.ts +2 -0
  98. package/dist/test/executor/simple-job-executor.test.d.ts.map +1 -0
  99. package/dist/test/executor/simple-job-executor.test.js +139 -0
  100. package/dist/test/executor/simple-job-executor.test.js.map +1 -0
  101. package/dist/test/factories.d.ts +122 -0
  102. package/dist/test/factories.d.ts.map +1 -0
  103. package/dist/test/factories.js +319 -0
  104. package/dist/test/factories.js.map +1 -0
  105. package/dist/test/integration/document-drive-integration.test.d.ts +2 -0
  106. package/dist/test/integration/document-drive-integration.test.d.ts.map +1 -0
  107. package/dist/test/integration/document-drive-integration.test.js +1102 -0
  108. package/dist/test/integration/document-drive-integration.test.js.map +1 -0
  109. package/dist/test/integration/reactor-read.test.d.ts +2 -0
  110. package/dist/test/integration/reactor-read.test.d.ts.map +1 -0
  111. package/dist/test/integration/reactor-read.test.js +300 -0
  112. package/dist/test/integration/reactor-read.test.js.map +1 -0
  113. package/dist/test/queue/queue-integration.test.d.ts +2 -0
  114. package/dist/test/queue/queue-integration.test.d.ts.map +1 -0
  115. package/dist/test/queue/queue-integration.test.js +322 -0
  116. package/dist/test/queue/queue-integration.test.js.map +1 -0
  117. package/dist/test/{queue.test.d.ts.map → queue/queue.test.d.ts.map} +1 -1
  118. package/dist/test/queue/queue.test.js +770 -0
  119. package/dist/test/queue/queue.test.js.map +1 -0
  120. package/dist/test/registry/registry.test.d.ts +2 -0
  121. package/dist/test/registry/registry.test.d.ts.map +1 -0
  122. package/dist/test/registry/registry.test.js +182 -0
  123. package/dist/test/registry/registry.test.js.map +1 -0
  124. package/dist/test/utils.test.d.ts +2 -0
  125. package/dist/test/utils.test.d.ts.map +1 -0
  126. package/dist/test/utils.test.js +66 -0
  127. package/dist/test/utils.test.js.map +1 -0
  128. package/dist/tsconfig.tsbuildinfo +1 -1
  129. package/dist/vitest.config.d.ts +3 -0
  130. package/dist/vitest.config.d.ts.map +1 -0
  131. package/dist/vitest.config.js +11 -0
  132. package/dist/vitest.config.js.map +1 -0
  133. package/package.json +6 -1
  134. package/dist/bench/end-to-end-flow.bench.d.ts +0 -2
  135. package/dist/bench/end-to-end-flow.bench.d.ts.map +0 -1
  136. package/dist/bench/end-to-end-flow.bench.js +0 -256
  137. package/dist/bench/end-to-end-flow.bench.js.map +0 -1
  138. package/dist/src/executor/job-executor.d.ts +0 -62
  139. package/dist/src/executor/job-executor.d.ts.map +0 -1
  140. package/dist/src/executor/job-executor.js +0 -325
  141. package/dist/src/executor/job-executor.js.map +0 -1
  142. package/dist/test/job-executor.test.d.ts +0 -2
  143. package/dist/test/job-executor.test.d.ts.map +0 -1
  144. package/dist/test/job-executor.test.js +0 -581
  145. package/dist/test/job-executor.test.js.map +0 -1
  146. package/dist/test/queue.test.js +0 -396
  147. package/dist/test/queue.test.js.map +0 -1
  148. /package/dist/test/{queue.test.d.ts → queue/queue.test.d.ts} +0 -0
@@ -0,0 +1,62 @@
1
+ import type { DocumentModelModule } from "document-model";
2
+ import type { IDocumentModelRegistry } from "./interfaces.js";
3
+ /**
4
+ * Error thrown when a document model module is not found in the registry.
5
+ */
6
+ export declare class ModuleNotFoundError extends Error {
7
+ constructor(documentType: string);
8
+ }
9
+ /**
10
+ * Error thrown when attempting to register a module that already exists.
11
+ */
12
+ export declare class DuplicateModuleError extends Error {
13
+ constructor(documentType: string);
14
+ }
15
+ /**
16
+ * Error thrown when a module is invalid or malformed.
17
+ */
18
+ export declare class InvalidModuleError extends Error {
19
+ constructor(message: string);
20
+ }
21
+ /**
22
+ * In-memory implementation of the IDocumentModelRegistry interface.
23
+ * Manages document model modules and provides centralized access to their reducers, utils, and specifications.
24
+ */
25
+ export declare class DocumentModelRegistry implements IDocumentModelRegistry {
26
+ private modules;
27
+ /**
28
+ * Register multiple modules at once.
29
+ *
30
+ * @param modules Document model modules to register
31
+ * @throws DuplicateModuleError if a module with the same document type is already registered
32
+ * @throws InvalidModuleError if a module is malformed
33
+ */
34
+ registerModules(...modules: DocumentModelModule<any>[]): void;
35
+ /**
36
+ * Unregister multiple document model modules at once.
37
+ *
38
+ * @param documentTypes The document types to unregister
39
+ * @returns true if all modules were unregistered, false if any were not found
40
+ */
41
+ unregisterModules(...documentTypes: string[]): boolean;
42
+ /**
43
+ * Get a specific document model module by document type.
44
+ *
45
+ * @param documentType The document type identifier
46
+ * @returns The document model module
47
+ * @throws ModuleNotFoundError if the document type is not registered
48
+ */
49
+ getModule(documentType: string): DocumentModelModule<any>;
50
+ /**
51
+ * Get all registered document model modules.
52
+ * Note: This only returns loaded modules, not lazy-loaded ones.
53
+ *
54
+ * @returns Array of all registered modules
55
+ */
56
+ getAllModules(): DocumentModelModule<any>[];
57
+ /**
58
+ * Clear all registered modules
59
+ */
60
+ clear(): void;
61
+ }
62
+ //# sourceMappingURL=implementation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/registry/implementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,YAAY,EAAE,MAAM;CAIjC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,YAAY,EAAE,MAAM;CAIjC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,sBAAsB;IAClE,OAAO,CAAC,OAAO,CAA+C;IAE9D;;;;;;OAMG;IACH,eAAe,CAAC,GAAG,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI;IAY7D;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO;IAatD;;;;;;OAMG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC;IAUzD;;;;;OAKG;IACH,aAAa,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE;IAI3C;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Error thrown when a document model module is not found in the registry.
3
+ */
4
+ export class ModuleNotFoundError extends Error {
5
+ constructor(documentType) {
6
+ super(`Document model module not found for type: ${documentType}`);
7
+ this.name = "ModuleNotFoundError";
8
+ }
9
+ }
10
+ /**
11
+ * Error thrown when attempting to register a module that already exists.
12
+ */
13
+ export class DuplicateModuleError extends Error {
14
+ constructor(documentType) {
15
+ super(`Document model module already registered for type: ${documentType}`);
16
+ this.name = "DuplicateModuleError";
17
+ }
18
+ }
19
+ /**
20
+ * Error thrown when a module is invalid or malformed.
21
+ */
22
+ export class InvalidModuleError extends Error {
23
+ constructor(message) {
24
+ super(`Invalid document model module: ${message}`);
25
+ this.name = "InvalidModuleError";
26
+ }
27
+ }
28
+ /**
29
+ * In-memory implementation of the IDocumentModelRegistry interface.
30
+ * Manages document model modules and provides centralized access to their reducers, utils, and specifications.
31
+ */
32
+ export class DocumentModelRegistry {
33
+ modules = new Map();
34
+ /**
35
+ * Register multiple modules at once.
36
+ *
37
+ * @param modules Document model modules to register
38
+ * @throws DuplicateModuleError if a module with the same document type is already registered
39
+ * @throws InvalidModuleError if a module is malformed
40
+ */
41
+ registerModules(...modules) {
42
+ for (const module of modules) {
43
+ const documentType = module.documentModel.id;
44
+ if (this.modules.has(documentType)) {
45
+ throw new DuplicateModuleError(documentType);
46
+ }
47
+ this.modules.set(documentType, module);
48
+ }
49
+ }
50
+ /**
51
+ * Unregister multiple document model modules at once.
52
+ *
53
+ * @param documentTypes The document types to unregister
54
+ * @returns true if all modules were unregistered, false if any were not found
55
+ */
56
+ unregisterModules(...documentTypes) {
57
+ let allFound = true;
58
+ for (const documentType of documentTypes) {
59
+ const wasDeleted = this.modules.delete(documentType);
60
+ if (!wasDeleted) {
61
+ allFound = false;
62
+ }
63
+ }
64
+ return allFound;
65
+ }
66
+ /**
67
+ * Get a specific document model module by document type.
68
+ *
69
+ * @param documentType The document type identifier
70
+ * @returns The document model module
71
+ * @throws ModuleNotFoundError if the document type is not registered
72
+ */
73
+ getModule(documentType) {
74
+ const module = this.modules.get(documentType);
75
+ if (module) {
76
+ return module;
77
+ }
78
+ throw new ModuleNotFoundError(documentType);
79
+ }
80
+ /**
81
+ * Get all registered document model modules.
82
+ * Note: This only returns loaded modules, not lazy-loaded ones.
83
+ *
84
+ * @returns Array of all registered modules
85
+ */
86
+ getAllModules() {
87
+ return Array.from(this.modules.values());
88
+ }
89
+ /**
90
+ * Clear all registered modules
91
+ */
92
+ clear() {
93
+ this.modules.clear();
94
+ }
95
+ }
96
+ //# sourceMappingURL=implementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/registry/implementation.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,YAAoB;QAC9B,KAAK,CAAC,6CAA6C,YAAY,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,YAAoB;QAC9B,KAAK,CAAC,sDAAsD,YAAY,EAAE,CAAC,CAAC;QAC5E,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACxB,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;IAE9D;;;;;;OAMG;IACH,eAAe,CAAC,GAAG,OAAmC;QACpD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;YAE7C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAC;YAC/C,CAAC;YAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,aAAuB;QAC1C,IAAI,QAAQ,GAAG,IAAI,CAAC;QAEpB,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACrD,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,QAAQ,GAAG,KAAK,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,YAAoB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAE9C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,IAAI,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { DocumentModelRegistry, DuplicateModuleError, InvalidModuleError, ModuleNotFoundError, } from "./implementation.js";
2
+ export type { IDocumentModelRegistry } from "./interfaces.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { DocumentModelRegistry, DuplicateModuleError, InvalidModuleError, ModuleNotFoundError, } from "./implementation.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { DocumentModelModule } from "document-model";
2
+ /**
3
+ * Registry for managing document model modules.
4
+ * Provides centralized access to document models' reducers, utils, and specifications.
5
+ */
6
+ export interface IDocumentModelRegistry {
7
+ /**
8
+ * Register multiple modules at once.
9
+ *
10
+ * @param modules Document model modules to register
11
+ * @throws Error if a module with the same document type is already registered
12
+ */
13
+ registerModules(...modules: DocumentModelModule<any>[]): void;
14
+ /**
15
+ * Unregister multiple document model modules at once.
16
+ *
17
+ * @param documentTypes The document types to unregister
18
+ * @returns true if all modules were unregistered, false if any were not found
19
+ */
20
+ unregisterModules(...documentTypes: string[]): boolean;
21
+ /**
22
+ * Get a specific document model module by document type.
23
+ *
24
+ * @param documentType The document type identifier
25
+ * @returns The document model module
26
+ * @throws Error if the document type is not registered
27
+ */
28
+ getModule(documentType: string): DocumentModelModule<any>;
29
+ /**
30
+ * Get all registered document model modules
31
+ * @returns Array of all registered modules
32
+ */
33
+ getAllModules(): DocumentModelModule<any>[];
34
+ /**
35
+ * Clear all registered modules
36
+ */
37
+ clear(): void;
38
+ }
39
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/registry/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,eAAe,CAAC,GAAG,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC;IAE9D;;;;;OAKG;IACH,iBAAiB,CAAC,GAAG,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEvD;;;;;;OAMG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAE1D;;;OAGG;IACH,aAAa,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;IAE5C;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/registry/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { type ShutdownStatus } from "./types.js";
2
+ /**
3
+ * Factory method to create a ShutdownStatus object
4
+ *
5
+ * @param isShutdown - Initial shutdown state
6
+ * @returns A ShutdownStatus object with a getter for the shutdown state
7
+ */
8
+ export declare function createShutdownStatus(isShutdown: boolean): ShutdownStatus;
9
+ /**
10
+ * Factory method to create a ShutdownStatus that can be updated
11
+ *
12
+ * @param initialState - Initial shutdown state (default: false)
13
+ * @returns A tuple of [ShutdownStatus, setter function]
14
+ */
15
+ export declare function createMutableShutdownStatus(initialState?: boolean): [ShutdownStatus, (value: boolean) => void];
16
+ //# sourceMappingURL=factories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/shared/factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,cAAc,CAQxE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,UAAQ,GACnB,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,CAc5C"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Factory method to create a ShutdownStatus object
3
+ *
4
+ * @param isShutdown - Initial shutdown state
5
+ * @returns A ShutdownStatus object with a getter for the shutdown state
6
+ */
7
+ export function createShutdownStatus(isShutdown) {
8
+ const shutdownState = isShutdown;
9
+ return {
10
+ get isShutdown() {
11
+ return shutdownState;
12
+ },
13
+ };
14
+ }
15
+ /**
16
+ * Factory method to create a ShutdownStatus that can be updated
17
+ *
18
+ * @param initialState - Initial shutdown state (default: false)
19
+ * @returns A tuple of [ShutdownStatus, setter function]
20
+ */
21
+ export function createMutableShutdownStatus(initialState = false) {
22
+ let shutdownState = initialState;
23
+ const status = {
24
+ get isShutdown() {
25
+ return shutdownState;
26
+ },
27
+ };
28
+ const setShutdown = (value) => {
29
+ shutdownState = value;
30
+ };
31
+ return [status, setShutdown];
32
+ }
33
+ //# sourceMappingURL=factories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../src/shared/factories.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAmB;IACtD,MAAM,aAAa,GAAG,UAAU,CAAC;IAEjC,OAAO;QACL,IAAI,UAAU;YACZ,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAAY,GAAG,KAAK;IAEpB,IAAI,aAAa,GAAG,YAAY,CAAC;IAEjC,MAAM,MAAM,GAAmB;QAC7B,IAAI,UAAU;YACZ,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,EAAE;QACrC,aAAa,GAAG,KAAK,CAAC;IACxB,CAAC,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAC/B,CAAC"}
@@ -1,23 +1,87 @@
1
1
  /**
2
- * Basic Operation type for the queue
3
- * This is a simplified version that includes the essential fields needed for queuing
4
- */
5
- export type Operation = {
6
- /** Position of the operation in the history */
7
- index: number;
8
- /** Timestamp of when the operation was added */
9
- timestamp: string;
10
- /** Hash of the resulting document data after the operation */
11
- hash: string;
12
- /** The number of operations skipped with this Operation */
13
- skip: number;
14
- /** The type/name of the operation */
15
- type: string;
16
- /** The input data for the operation */
17
- input: any;
18
- /** Error message for a failed action */
2
+ * Describes the status of a shutdown operation.
3
+ */
4
+ export type ShutdownStatus = {
5
+ /**
6
+ * True if and only if the system has been shutdown.
7
+ *
8
+ * This value is meant to be polled to determine if the system has been shutdown.
9
+ *
10
+ * In the case of a browser process, the `kill` method should be able to synchronously set this to true.
11
+ *
12
+ * In the case of a server process, a graceful shutdown period should be allowed for the system to finish its work.
13
+ */
14
+ get isShutdown(): boolean;
15
+ };
16
+ /**
17
+ * Enum that determines deletion propagation.
18
+ */
19
+ export declare enum PropagationMode {
20
+ None = "none",
21
+ Cascade = "cascade"
22
+ }
23
+ /**
24
+ * Enum that describes the type of relationship change.
25
+ */
26
+ export declare enum RelationshipChangeType {
27
+ Added = "added",
28
+ Removed = "removed"
29
+ }
30
+ /**
31
+ * Describes the current state of a job.
32
+ */
33
+ export type JobInfo = {
34
+ id: string;
35
+ status: JobStatus;
19
36
  error?: string;
20
- /** Unique operation id */
21
- id?: string;
37
+ };
38
+ /**
39
+ * Job execution statuses
40
+ */
41
+ export declare enum JobStatus {
42
+ /** Job is queued but not yet started */
43
+ PENDING = "PENDING",
44
+ /** Job is currently being executed */
45
+ RUNNING = "RUNNING",
46
+ /** Job completed successfully */
47
+ COMPLETED = "COMPLETED",
48
+ /** Job failed (may be retried) */
49
+ FAILED = "FAILED"
50
+ }
51
+ /**
52
+ * Describe the view of a set of documents. That is, what pieces of the
53
+ * documents are populated.
54
+ */
55
+ export type ViewFilter = {
56
+ branch?: string;
57
+ scopes?: string[];
58
+ revision?: number;
59
+ };
60
+ /**
61
+ * Describes filter options for searching documents.
62
+ *
63
+ * Each parameter is treated as an AND condition.
64
+ */
65
+ export type SearchFilter = {
66
+ type?: string;
67
+ parentId?: string;
68
+ ids?: string[];
69
+ slugs?: string[];
70
+ };
71
+ /**
72
+ * Describes the options for paging.
73
+ */
74
+ export type PagingOptions = {
75
+ cursor: string;
76
+ limit: number;
77
+ };
78
+ /**
79
+ * The paged result.
80
+ */
81
+ export type PagedResults<T> = {
82
+ results: T[];
83
+ options: PagingOptions;
84
+ next?: () => Promise<PagedResults<T>>;
85
+ nextCursor?: string;
22
86
  };
23
87
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,KAAK,EAAE,GAAG,CAAC;IACX,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;OAQG;IACH,IAAI,UAAU,IAAI,OAAO,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAChC,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IACnB,wCAAwC;IACxC,OAAO,YAAY;IACnB,sCAAsC;IACtC,OAAO,YAAY;IACnB,iCAAiC;IACjC,SAAS,cAAc;IACvB,kCAAkC;IAClC,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;IAEvB,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
@@ -1,2 +1,31 @@
1
- export {};
1
+ /**
2
+ * Enum that determines deletion propagation.
3
+ */
4
+ export var PropagationMode;
5
+ (function (PropagationMode) {
6
+ PropagationMode["None"] = "none";
7
+ PropagationMode["Cascade"] = "cascade";
8
+ })(PropagationMode || (PropagationMode = {}));
9
+ /**
10
+ * Enum that describes the type of relationship change.
11
+ */
12
+ export var RelationshipChangeType;
13
+ (function (RelationshipChangeType) {
14
+ RelationshipChangeType["Added"] = "added";
15
+ RelationshipChangeType["Removed"] = "removed";
16
+ })(RelationshipChangeType || (RelationshipChangeType = {}));
17
+ /**
18
+ * Job execution statuses
19
+ */
20
+ export var JobStatus;
21
+ (function (JobStatus) {
22
+ /** Job is queued but not yet started */
23
+ JobStatus["PENDING"] = "PENDING";
24
+ /** Job is currently being executed */
25
+ JobStatus["RUNNING"] = "RUNNING";
26
+ /** Job completed successfully */
27
+ JobStatus["COMPLETED"] = "COMPLETED";
28
+ /** Job failed (may be retried) */
29
+ JobStatus["FAILED"] = "FAILED";
30
+ })(JobStatus || (JobStatus = {}));
2
31
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,6CAAmB,CAAA;AACrB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAWD;;GAEG;AACH,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB,wCAAwC;IACxC,gCAAmB,CAAA;IACnB,sCAAsC;IACtC,gCAAmB,CAAA;IACnB,iCAAiC;IACjC,oCAAuB,CAAA;IACvB,kCAAkC;IAClC,8BAAiB,CAAA;AACnB,CAAC,EATW,SAAS,KAAT,SAAS,QASpB"}
@@ -0,0 +1,3 @@
1
+ import type { ViewFilter } from "./types.js";
2
+ export declare function matchesScope(view: ViewFilter | undefined, scope: string): boolean;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,YAAK,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO1E"}
@@ -0,0 +1,8 @@
1
+ export function matchesScope(view = {}, scope) {
2
+ if (view.scopes) {
3
+ return view.scopes.includes(scope);
4
+ }
5
+ // if there are no scopes specified, we match all scopes
6
+ return true;
7
+ }
8
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/shared/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,OAAmB,EAAE,EAAE,KAAa;IAC/D,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,wDAAwD;IACxD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type PHDocument } from "document-model";
2
+ import { type PagedResults } from "./shared/types.js";
3
+ /**
4
+ * Filters paged results by parent ID
5
+ */
6
+ export declare function filterByParentId(results: PagedResults<PHDocument>, parentId: string): PagedResults<PHDocument>;
7
+ /**
8
+ * Filters paged results by document type
9
+ */
10
+ export declare function filterByType(results: PagedResults<PHDocument>, type: string): PagedResults<PHDocument>;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,EAEjC,QAAQ,EAAE,MAAM,GACf,YAAY,CAAC,UAAU,CAAC,CAG1B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,EACjC,IAAI,EAAE,MAAM,GACX,YAAY,CAAC,UAAU,CAAC,CAoB1B"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Filters paged results by parent ID
3
+ */
4
+ export function filterByParentId(results,
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
+ parentId) {
7
+ // TODO: Implement filterByParentId
8
+ return results;
9
+ }
10
+ /**
11
+ * Filters paged results by document type
12
+ */
13
+ export function filterByType(results, type) {
14
+ // Filter documents by their document type from the header
15
+ const filteredDocuments = results.results.filter((document) => document.header.documentType === type);
16
+ // Create new paged results with filtered documents
17
+ // Note: This maintains the same paging structure but with filtered results
18
+ return {
19
+ results: filteredDocuments,
20
+ options: results.options,
21
+ nextCursor: results.nextCursor,
22
+ next: results.next
23
+ ? async () => {
24
+ // If there's a next function, apply the same filter to the next page
25
+ const nextResults = await results.next();
26
+ return filterByType(nextResults, type);
27
+ }
28
+ : undefined,
29
+ };
30
+ }
31
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAiC;AACjC,6DAA6D;AAC7D,QAAgB;IAEhB,mCAAmC;IACnC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAiC,EACjC,IAAY;IAEZ,0DAA0D;IAC1D,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAC9C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,KAAK,IAAI,CACpD,CAAC;IAEF,mDAAmD;IACnD,2EAA2E;IAC3E,OAAO;QACL,OAAO,EAAE,iBAAiB;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;YAChB,CAAC,CAAC,KAAK,IAAI,EAAE;gBACT,qEAAqE;gBACrE,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,IAAK,EAAE,CAAC;gBAC1C,OAAO,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC;YACH,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC"}
@@ -75,12 +75,12 @@ describe("EventBus", () => {
75
75
  // Subscriber for event type 1 with delay
76
76
  eventBus.subscribe(eventType1, async (type, data) => {
77
77
  await new Promise((resolve) => setTimeout(resolve, 100));
78
- results.push({ eventType: type, data, timestamp: Date.now() });
78
+ results.push({ eventType: type, data, timestampUtcMs: Date.now() });
79
79
  });
80
80
  // Subscriber for event type 2 with shorter delay
81
81
  eventBus.subscribe(eventType2, async (type, data) => {
82
82
  await new Promise((resolve) => setTimeout(resolve, 50));
83
- results.push({ eventType: type, data, timestamp: Date.now() });
83
+ results.push({ eventType: type, data, timestampUtcMs: Date.now() });
84
84
  });
85
85
  const startTime = Date.now();
86
86
  // Emit both events concurrently
@@ -111,17 +111,17 @@ describe("EventBus", () => {
111
111
  eventBus.subscribe(eventType, async (type, data) => {
112
112
  await new Promise((resolve) => setTimeout(resolve, 30));
113
113
  results.push({
114
- emitId: data.emitId,
114
+ emitId: data.emitId ?? "",
115
115
  subscriberId: 1,
116
- timestamp: Date.now(),
116
+ timestampUtcMs: Date.now(),
117
117
  });
118
118
  });
119
119
  eventBus.subscribe(eventType, async (type, data) => {
120
120
  await new Promise((resolve) => setTimeout(resolve, 20));
121
121
  results.push({
122
- emitId: data.emitId,
122
+ emitId: data.emitId ?? "",
123
123
  subscriberId: 2,
124
- timestamp: Date.now(),
124
+ timestampUtcMs: Date.now(),
125
125
  });
126
126
  });
127
127
  // Emit the same event type concurrently
@@ -148,16 +148,16 @@ describe("EventBus", () => {
148
148
  const eventType = 1;
149
149
  // Synchronous subscriber
150
150
  eventBus.subscribe(eventType, (type, data) => {
151
- results.push({ type: "sync", value: data.value });
151
+ results.push({ type: "sync", value: data.value ?? 0 });
152
152
  });
153
153
  // Asynchronous subscriber
154
154
  eventBus.subscribe(eventType, async (type, data) => {
155
155
  await new Promise((resolve) => setTimeout(resolve, 10));
156
- results.push({ type: "async", value: data.value });
156
+ results.push({ type: "async", value: data.value ?? 0 });
157
157
  });
158
158
  // Another synchronous subscriber
159
159
  eventBus.subscribe(eventType, (type, data) => {
160
- results.push({ type: "sync2", value: data.value });
160
+ results.push({ type: "sync2", value: data.value ?? 0 });
161
161
  });
162
162
  await eventBus.emit(eventType, { value: 42 });
163
163
  expect(results).toHaveLength(3);
@@ -194,7 +194,7 @@ describe("EventBus", () => {
194
194
  eventBus.subscribe(eventType, () => {
195
195
  throw new Error("Sync error");
196
196
  });
197
- eventBus.subscribe(eventType, async () => {
197
+ eventBus.subscribe(eventType, () => {
198
198
  throw new Error("Async error");
199
199
  });
200
200
  await expect(eventBus.emit(eventType, {})).rejects.toThrow(EventBusAggregateError);
@@ -217,18 +217,24 @@ describe("EventBus", () => {
217
217
  const unsubscribe = eventBus.subscribe(eventType, () => {
218
218
  callCount++;
219
219
  });
220
+ // Emit event before unsubscribing
221
+ eventBus.emit(eventType, { data: "test" });
222
+ expect(callCount).toBe(1);
220
223
  // Call unsubscribe multiple times
221
224
  unsubscribe();
222
225
  unsubscribe();
223
226
  unsubscribe();
224
227
  // Should not throw and should work correctly
225
228
  expect(() => unsubscribe()).not.toThrow();
229
+ // Emit again to verify unsubscribe worked
230
+ eventBus.emit(eventType, { data: "test" });
231
+ expect(callCount).toBe(1); // Should still be 1
226
232
  });
227
233
  it("should handle unsubscribe during emission", async () => {
228
234
  const eventBus = new EventBus();
229
235
  const results = [];
230
236
  const eventType = 1;
231
- let unsubscribe2;
237
+ let unsubscribe2 = undefined;
232
238
  eventBus.subscribe(eventType, () => {
233
239
  results.push(1);
234
240
  // Unsubscribe subscriber 2 during emission
@@ -250,7 +256,7 @@ describe("EventBus", () => {
250
256
  await eventBus.emit(eventType, {});
251
257
  expect(results).toEqual([1, 3]);
252
258
  });
253
- it("should clean up empty listener arrays", async () => {
259
+ it("should clean up empty listener arrays", () => {
254
260
  const eventBus = new EventBus();
255
261
  const eventType = 1;
256
262
  const unsubscribe1 = eventBus.subscribe(eventType, () => { });
@@ -271,6 +277,9 @@ describe("EventBus", () => {
271
277
  const unsubscribe = eventBus.subscribe(eventType, () => { });
272
278
  // Manually remove the subscriber to simulate edge case
273
279
  const listeners = eventBus.eventTypeToSubscribers.get(eventType);
280
+ if (!listeners) {
281
+ throw new Error("Listeners not found");
282
+ }
274
283
  listeners.length = 0;
275
284
  // Should not throw
276
285
  expect(() => unsubscribe()).not.toThrow();
@@ -290,7 +299,7 @@ describe("EventBus", () => {
290
299
  eventBus.subscribe(eventType, () => {
291
300
  results.push(3);
292
301
  });
293
- eventBus.subscribe(eventType, async () => {
302
+ eventBus.subscribe(eventType, () => {
294
303
  throw new Error("Subscriber 4 error");
295
304
  });
296
305
  eventBus.subscribe(eventType, () => {
@@ -319,7 +328,7 @@ describe("EventBus", () => {
319
328
  eventBus.subscribe(eventType, () => {
320
329
  throw new Error("Second error");
321
330
  });
322
- eventBus.subscribe(eventType, async () => {
331
+ eventBus.subscribe(eventType, () => {
323
332
  throw new Error("Third error");
324
333
  });
325
334
  await expect(eventBus.emit(eventType, {})).rejects.toThrow(EventBusAggregateError);