@bett3r-dev/pv3 1.0.0 → 1.1.7

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 (648) hide show
  1. package/CHANGELOG.md +329 -0
  2. package/build/adapters/cache/memory/index.d.ts.map +1 -1
  3. package/build/adapters/cache/memory/index.js +93 -20
  4. package/build/adapters/cache/memory/index.js.map +1 -1
  5. package/build/adapters/cache/memory/index.test.d.ts +2 -0
  6. package/build/adapters/cache/memory/index.test.d.ts.map +1 -0
  7. package/build/adapters/cache/memory/index.test.js +98 -0
  8. package/build/adapters/cache/memory/index.test.js.map +1 -0
  9. package/build/adapters/configuration/dotEnv.d.ts.map +1 -1
  10. package/build/adapters/configuration/dotEnv.js.map +1 -1
  11. package/build/adapters/database/memory/index.d.ts +5 -1
  12. package/build/adapters/database/memory/index.d.ts.map +1 -1
  13. package/build/adapters/database/memory/index.js +336 -44
  14. package/build/adapters/database/memory/index.js.map +1 -1
  15. package/build/adapters/database/memory/index.test.d.ts +2 -0
  16. package/build/adapters/database/memory/index.test.d.ts.map +1 -0
  17. package/build/adapters/database/memory/index.test.js +167 -0
  18. package/build/adapters/database/memory/index.test.js.map +1 -0
  19. package/build/adapters/database/memory/pagingCursorZero.test.d.ts +2 -0
  20. package/build/adapters/database/memory/pagingCursorZero.test.d.ts.map +1 -0
  21. package/build/adapters/database/memory/pagingCursorZero.test.js +60 -0
  22. package/build/adapters/database/memory/pagingCursorZero.test.js.map +1 -0
  23. package/build/adapters/database/memory/pagingVanishedCursor.test.d.ts +2 -0
  24. package/build/adapters/database/memory/pagingVanishedCursor.test.d.ts.map +1 -0
  25. package/build/adapters/database/memory/pagingVanishedCursor.test.js +72 -0
  26. package/build/adapters/database/memory/pagingVanishedCursor.test.js.map +1 -0
  27. package/build/adapters/endpoints/addAuthUser/index.d.ts +6 -4
  28. package/build/adapters/endpoints/addAuthUser/index.d.ts.map +1 -1
  29. package/build/adapters/endpoints/addAuthUser/index.js +12 -31
  30. package/build/adapters/endpoints/addAuthUser/index.js.map +1 -1
  31. package/build/adapters/endpoints/addDevAuthUser/index.d.ts +32 -0
  32. package/build/adapters/endpoints/addDevAuthUser/index.d.ts.map +1 -0
  33. package/build/adapters/endpoints/addDevAuthUser/index.js +39 -0
  34. package/build/adapters/endpoints/addDevAuthUser/index.js.map +1 -0
  35. package/build/adapters/endpoints/asyncLocalStorage/__tests__/asyncLocalStorage.test.d.ts +2 -0
  36. package/build/adapters/endpoints/asyncLocalStorage/__tests__/asyncLocalStorage.test.d.ts.map +1 -0
  37. package/build/adapters/endpoints/asyncLocalStorage/__tests__/asyncLocalStorage.test.js +97 -0
  38. package/build/adapters/endpoints/asyncLocalStorage/__tests__/asyncLocalStorage.test.js.map +1 -0
  39. package/build/adapters/endpoints/asyncLocalStorage/index.d.ts +22 -0
  40. package/build/adapters/endpoints/asyncLocalStorage/index.d.ts.map +1 -0
  41. package/build/adapters/endpoints/asyncLocalStorage/index.js +62 -0
  42. package/build/adapters/endpoints/asyncLocalStorage/index.js.map +1 -0
  43. package/build/adapters/endpoints/endpointValidation/__tests__/endpointValidation.test.d.ts +2 -0
  44. package/build/adapters/endpoints/endpointValidation/__tests__/endpointValidation.test.d.ts.map +1 -0
  45. package/build/adapters/endpoints/endpointValidation/__tests__/endpointValidation.test.js +98 -0
  46. package/build/adapters/endpoints/endpointValidation/__tests__/endpointValidation.test.js.map +1 -0
  47. package/build/adapters/endpoints/endpointValidation/index.d.ts +2 -2
  48. package/build/adapters/endpoints/endpointValidation/index.d.ts.map +1 -1
  49. package/build/adapters/endpoints/endpointValidation/index.js +19 -9
  50. package/build/adapters/endpoints/endpointValidation/index.js.map +1 -1
  51. package/build/adapters/endpoints/genericMiddleware/index.d.ts +23 -0
  52. package/build/adapters/endpoints/genericMiddleware/index.d.ts.map +1 -0
  53. package/build/adapters/endpoints/genericMiddleware/index.js +30 -0
  54. package/build/adapters/endpoints/genericMiddleware/index.js.map +1 -0
  55. package/build/adapters/endpoints/httpMethodOverride/index.d.ts +8 -0
  56. package/build/adapters/endpoints/httpMethodOverride/index.d.ts.map +1 -0
  57. package/build/adapters/endpoints/httpMethodOverride/index.js +44 -0
  58. package/build/adapters/endpoints/httpMethodOverride/index.js.map +1 -0
  59. package/build/adapters/endpoints/index.d.ts +5 -0
  60. package/build/adapters/endpoints/index.d.ts.map +1 -1
  61. package/build/adapters/endpoints/index.js +5 -1
  62. package/build/adapters/endpoints/index.js.map +1 -1
  63. package/build/adapters/endpoints/localAuthorization/index.d.ts +1 -0
  64. package/build/adapters/endpoints/localAuthorization/index.js +2 -0
  65. package/build/adapters/endpoints/localAuthorization/index.js.map +1 -1
  66. package/build/adapters/endpoints/mapQueryFromHeaders/index.d.ts +8 -0
  67. package/build/adapters/endpoints/mapQueryFromHeaders/index.d.ts.map +1 -0
  68. package/build/adapters/endpoints/mapQueryFromHeaders/index.js +36 -0
  69. package/build/adapters/endpoints/mapQueryFromHeaders/index.js.map +1 -0
  70. package/build/adapters/endpoints/tcpConsumer/index.d.ts.map +1 -1
  71. package/build/adapters/endpoints/tcpConsumer/index.js +8 -7
  72. package/build/adapters/endpoints/tcpConsumer/index.js.map +1 -1
  73. package/build/adapters/endpoints/userSession/__tests__/userSession.test.d.ts +2 -0
  74. package/build/adapters/endpoints/userSession/__tests__/userSession.test.d.ts.map +1 -0
  75. package/build/adapters/endpoints/userSession/__tests__/userSession.test.js +175 -0
  76. package/build/adapters/endpoints/userSession/__tests__/userSession.test.js.map +1 -0
  77. package/build/adapters/endpoints/userSession/index.d.ts +2 -2
  78. package/build/adapters/endpoints/userSession/index.d.ts.map +1 -1
  79. package/build/adapters/endpoints/userSession/index.js +36 -2
  80. package/build/adapters/endpoints/userSession/index.js.map +1 -1
  81. package/build/adapters/eventstore/database.d.ts.map +1 -1
  82. package/build/adapters/eventstore/database.js +261 -58
  83. package/build/adapters/eventstore/database.js.map +1 -1
  84. package/build/adapters/eventstore/database.test.d.ts +2 -0
  85. package/build/adapters/eventstore/database.test.d.ts.map +1 -0
  86. package/build/adapters/eventstore/database.test.js +123 -0
  87. package/build/adapters/eventstore/database.test.js.map +1 -0
  88. package/build/adapters/infrastructure/local/index.d.ts +2 -2
  89. package/build/adapters/infrastructure/local/index.d.ts.map +1 -1
  90. package/build/adapters/infrastructure/local/index.js +3 -3
  91. package/build/adapters/infrastructure/local/index.js.map +1 -1
  92. package/build/adapters/logger/__tests__/json.test.d.ts +2 -0
  93. package/build/adapters/logger/__tests__/json.test.d.ts.map +1 -0
  94. package/build/adapters/logger/__tests__/json.test.js +125 -0
  95. package/build/adapters/logger/__tests__/json.test.js.map +1 -0
  96. package/build/adapters/logger/console.d.ts.map +1 -1
  97. package/build/adapters/logger/console.js +4 -2
  98. package/build/adapters/logger/console.js.map +1 -1
  99. package/build/adapters/logger/http.d.ts +3 -0
  100. package/build/adapters/logger/http.d.ts.map +1 -0
  101. package/build/adapters/logger/http.js +49 -0
  102. package/build/adapters/logger/http.js.map +1 -0
  103. package/build/adapters/logger/index.d.ts +3 -0
  104. package/build/adapters/logger/index.d.ts.map +1 -1
  105. package/build/adapters/logger/index.js +3 -0
  106. package/build/adapters/logger/index.js.map +1 -1
  107. package/build/adapters/logger/json.d.ts +3 -0
  108. package/build/adapters/logger/json.d.ts.map +1 -0
  109. package/build/adapters/logger/json.js +41 -0
  110. package/build/adapters/logger/json.js.map +1 -0
  111. package/build/adapters/logger/stdout.d.ts +3 -0
  112. package/build/adapters/logger/stdout.d.ts.map +1 -0
  113. package/build/adapters/logger/stdout.js +52 -0
  114. package/build/adapters/logger/stdout.js.map +1 -0
  115. package/build/index.d.ts +3 -1
  116. package/build/index.d.ts.map +1 -1
  117. package/build/index.js +3 -1
  118. package/build/index.js.map +1 -1
  119. package/build/libraries/deployment-units/computeMDUs.d.ts +11 -0
  120. package/build/libraries/deployment-units/computeMDUs.d.ts.map +1 -0
  121. package/build/libraries/deployment-units/computeMDUs.js +695 -0
  122. package/build/libraries/deployment-units/computeMDUs.js.map +1 -0
  123. package/build/libraries/deployment-units/computeMDUs.test.d.ts +2 -0
  124. package/build/libraries/deployment-units/computeMDUs.test.d.ts.map +1 -0
  125. package/build/libraries/deployment-units/computeMDUs.test.js +996 -0
  126. package/build/libraries/deployment-units/computeMDUs.test.js.map +1 -0
  127. package/build/libraries/deployment-units/index.d.ts +6 -0
  128. package/build/libraries/deployment-units/index.d.ts.map +1 -0
  129. package/build/libraries/deployment-units/index.js +8 -0
  130. package/build/libraries/deployment-units/index.js.map +1 -0
  131. package/build/libraries/deployment-units/manifestWriter.d.ts +11 -0
  132. package/build/libraries/deployment-units/manifestWriter.d.ts.map +1 -0
  133. package/build/libraries/deployment-units/manifestWriter.js +28 -0
  134. package/build/libraries/deployment-units/manifestWriter.js.map +1 -0
  135. package/build/libraries/deployment-units/types.d.ts +43 -0
  136. package/build/libraries/deployment-units/types.d.ts.map +1 -0
  137. package/build/libraries/deployment-units/types.js +3 -0
  138. package/build/libraries/deployment-units/types.js.map +1 -0
  139. package/build/libraries/eventsourcing/__tests__/fixtures/defaultVisibilityThings.readmodel.d.ts +2 -0
  140. package/build/libraries/eventsourcing/__tests__/fixtures/defaultVisibilityThings.readmodel.d.ts.map +1 -0
  141. package/build/libraries/eventsourcing/__tests__/fixtures/defaultVisibilityThings.readmodel.js +17 -0
  142. package/build/libraries/eventsourcing/__tests__/fixtures/defaultVisibilityThings.readmodel.js.map +1 -0
  143. package/build/libraries/eventsourcing/__tests__/fixtures/dupA/things.readmodel.d.ts +2 -0
  144. package/build/libraries/eventsourcing/__tests__/fixtures/dupA/things.readmodel.d.ts.map +1 -0
  145. package/build/libraries/eventsourcing/__tests__/fixtures/dupA/things.readmodel.js +13 -0
  146. package/build/libraries/eventsourcing/__tests__/fixtures/dupA/things.readmodel.js.map +1 -0
  147. package/build/libraries/eventsourcing/__tests__/fixtures/dupB/things.readmodel.d.ts +2 -0
  148. package/build/libraries/eventsourcing/__tests__/fixtures/dupB/things.readmodel.d.ts.map +1 -0
  149. package/build/libraries/eventsourcing/__tests__/fixtures/dupB/things.readmodel.js +12 -0
  150. package/build/libraries/eventsourcing/__tests__/fixtures/dupB/things.readmodel.js.map +1 -0
  151. package/build/libraries/eventsourcing/__tests__/fixtures/publicThings.readmodel.d.ts +2 -0
  152. package/build/libraries/eventsourcing/__tests__/fixtures/publicThings.readmodel.d.ts.map +1 -0
  153. package/build/libraries/eventsourcing/__tests__/fixtures/publicThings.readmodel.js +21 -0
  154. package/build/libraries/eventsourcing/__tests__/fixtures/publicThings.readmodel.js.map +1 -0
  155. package/build/libraries/eventsourcing/__tests__/fixtures/queryOnlyThings.readmodel.d.ts +2 -0
  156. package/build/libraries/eventsourcing/__tests__/fixtures/queryOnlyThings.readmodel.d.ts.map +1 -0
  157. package/build/libraries/eventsourcing/__tests__/fixtures/queryOnlyThings.readmodel.js +16 -0
  158. package/build/libraries/eventsourcing/__tests__/fixtures/queryOnlyThings.readmodel.js.map +1 -0
  159. package/build/libraries/eventsourcing/__tests__/fixtures/subscribingThings.readmodel.d.ts +2 -0
  160. package/build/libraries/eventsourcing/__tests__/fixtures/subscribingThings.readmodel.d.ts.map +1 -0
  161. package/build/libraries/eventsourcing/__tests__/fixtures/subscribingThings.readmodel.js +14 -0
  162. package/build/libraries/eventsourcing/__tests__/fixtures/subscribingThings.readmodel.js.map +1 -0
  163. package/build/libraries/eventsourcing/__tests__/queryOnlyReadmodel.test.d.ts +2 -0
  164. package/build/libraries/eventsourcing/__tests__/queryOnlyReadmodel.test.d.ts.map +1 -0
  165. package/build/libraries/eventsourcing/__tests__/queryOnlyReadmodel.test.js +88 -0
  166. package/build/libraries/eventsourcing/__tests__/queryOnlyReadmodel.test.js.map +1 -0
  167. package/build/libraries/eventsourcing/__tests__/queryVisibility.test.d.ts +2 -0
  168. package/build/libraries/eventsourcing/__tests__/queryVisibility.test.d.ts.map +1 -0
  169. package/build/libraries/eventsourcing/__tests__/queryVisibility.test.js +82 -0
  170. package/build/libraries/eventsourcing/__tests__/queryVisibility.test.js.map +1 -0
  171. package/build/libraries/eventsourcing/commandHandlers/index.d.ts +40 -0
  172. package/build/libraries/eventsourcing/commandHandlers/index.d.ts.map +1 -0
  173. package/build/libraries/eventsourcing/commandHandlers/index.js +1065 -0
  174. package/build/libraries/eventsourcing/commandHandlers/index.js.map +1 -0
  175. package/build/libraries/eventsourcing/commandTemplates/index.d.ts.map +1 -0
  176. package/build/libraries/eventsourcing/commandTemplates/index.js.map +1 -0
  177. package/build/libraries/eventsourcing/commandTemplates/multiStream.d.ts +7 -0
  178. package/build/libraries/eventsourcing/commandTemplates/multiStream.d.ts.map +1 -0
  179. package/build/libraries/eventsourcing/commandTemplates/multiStream.js +116 -0
  180. package/build/libraries/eventsourcing/commandTemplates/multiStream.js.map +1 -0
  181. package/build/libraries/eventsourcing/commandTemplates/snapshot.d.ts +108 -0
  182. package/build/libraries/eventsourcing/commandTemplates/snapshot.d.ts.map +1 -0
  183. package/build/libraries/eventsourcing/commandTemplates/snapshot.js +127 -0
  184. package/build/libraries/eventsourcing/commandTemplates/snapshot.js.map +1 -0
  185. package/build/libraries/eventsourcing/eventHandlers/__tests__/queryResponseFormatterCaller.test.d.ts +2 -0
  186. package/build/libraries/eventsourcing/eventHandlers/__tests__/queryResponseFormatterCaller.test.d.ts.map +1 -0
  187. package/build/libraries/eventsourcing/eventHandlers/__tests__/queryResponseFormatterCaller.test.js +77 -0
  188. package/build/libraries/eventsourcing/eventHandlers/__tests__/queryResponseFormatterCaller.test.js.map +1 -0
  189. package/build/libraries/eventsourcing/eventHandlers/index.d.ts +52 -0
  190. package/build/libraries/eventsourcing/eventHandlers/index.d.ts.map +1 -0
  191. package/build/libraries/eventsourcing/eventHandlers/index.js +474 -0
  192. package/build/libraries/eventsourcing/eventHandlers/index.js.map +1 -0
  193. package/build/libraries/eventsourcing/executionContext.d.ts +50 -0
  194. package/build/libraries/eventsourcing/executionContext.d.ts.map +1 -0
  195. package/build/libraries/eventsourcing/executionContext.js +10 -0
  196. package/build/libraries/eventsourcing/executionContext.js.map +1 -0
  197. package/build/libraries/eventsourcing/idempotencyChecks/index.d.ts +5 -0
  198. package/build/libraries/eventsourcing/idempotencyChecks/index.d.ts.map +1 -0
  199. package/build/libraries/eventsourcing/idempotencyChecks/index.js +26 -0
  200. package/build/libraries/eventsourcing/idempotencyChecks/index.js.map +1 -0
  201. package/build/libraries/eventsourcing/index.d.ts +14 -0
  202. package/build/libraries/eventsourcing/index.d.ts.map +1 -0
  203. package/build/{ports → libraries}/eventsourcing/index.js +50 -15
  204. package/build/{ports → libraries}/eventsourcing/index.js.map +1 -1
  205. package/build/libraries/eventsourcing/invariants/combinators.d.ts +4 -0
  206. package/build/libraries/eventsourcing/invariants/combinators.d.ts.map +1 -0
  207. package/build/{ports → libraries}/eventsourcing/invariants/combinators.js +3 -3
  208. package/build/libraries/eventsourcing/invariants/combinators.js.map +1 -0
  209. package/build/libraries/eventsourcing/invariants/common.d.ts +15 -0
  210. package/build/libraries/eventsourcing/invariants/common.d.ts.map +1 -0
  211. package/build/libraries/eventsourcing/invariants/common.js +27 -0
  212. package/build/libraries/eventsourcing/invariants/common.js.map +1 -0
  213. package/build/libraries/eventsourcing/invariants/comparisons.d.ts +16 -0
  214. package/build/libraries/eventsourcing/invariants/comparisons.d.ts.map +1 -0
  215. package/build/libraries/eventsourcing/invariants/comparisons.js +35 -0
  216. package/build/libraries/eventsourcing/invariants/comparisons.js.map +1 -0
  217. package/build/libraries/eventsourcing/invariants/comparisons.test.d.ts +2 -0
  218. package/build/libraries/eventsourcing/invariants/comparisons.test.d.ts.map +1 -0
  219. package/build/libraries/eventsourcing/invariants/comparisons.test.js +25 -0
  220. package/build/libraries/eventsourcing/invariants/comparisons.test.js.map +1 -0
  221. package/build/libraries/eventsourcing/invariants/index.d.ts +17 -0
  222. package/build/libraries/eventsourcing/invariants/index.d.ts.map +1 -0
  223. package/build/libraries/eventsourcing/invariants/index.js +47 -0
  224. package/build/libraries/eventsourcing/invariants/index.js.map +1 -0
  225. package/build/libraries/eventsourcing/invariants/stateExistance.d.ts +4 -0
  226. package/build/libraries/eventsourcing/invariants/stateExistance.d.ts.map +1 -0
  227. package/build/libraries/eventsourcing/invariants/stateExistance.js +22 -0
  228. package/build/libraries/eventsourcing/invariants/stateExistance.js.map +1 -0
  229. package/build/libraries/eventsourcing/subscriptions/__tests__/sseSubscriptions.test.d.ts +2 -0
  230. package/build/libraries/eventsourcing/subscriptions/__tests__/sseSubscriptions.test.d.ts.map +1 -0
  231. package/build/libraries/eventsourcing/subscriptions/__tests__/sseSubscriptions.test.js +563 -0
  232. package/build/libraries/eventsourcing/subscriptions/__tests__/sseSubscriptions.test.js.map +1 -0
  233. package/build/libraries/eventsourcing/subscriptions/index.d.ts.map +1 -0
  234. package/build/libraries/eventsourcing/subscriptions/index.js.map +1 -0
  235. package/build/libraries/eventsourcing/subscriptions/sseSubscriptions.d.ts +5 -0
  236. package/build/libraries/eventsourcing/subscriptions/sseSubscriptions.d.ts.map +1 -0
  237. package/build/libraries/eventsourcing/subscriptions/sseSubscriptions.js +198 -0
  238. package/build/libraries/eventsourcing/subscriptions/sseSubscriptions.js.map +1 -0
  239. package/build/libraries/eventsourcing/utils/aggregateBuilder.d.ts +5 -0
  240. package/build/libraries/eventsourcing/utils/aggregateBuilder.d.ts.map +1 -0
  241. package/build/{ports → libraries}/eventsourcing/utils/aggregateBuilder.js +17 -3
  242. package/build/libraries/eventsourcing/utils/aggregateBuilder.js.map +1 -0
  243. package/build/libraries/eventsourcing/utils/commandBuilder.d.ts +3 -0
  244. package/build/libraries/eventsourcing/utils/commandBuilder.d.ts.map +1 -0
  245. package/build/{ports → libraries}/eventsourcing/utils/commandBuilder.js +44 -1
  246. package/build/libraries/eventsourcing/utils/commandBuilder.js.map +1 -0
  247. package/build/{ports → libraries}/eventsourcing/utils/eventHandlerBuilder.d.ts +2 -2
  248. package/build/libraries/eventsourcing/utils/eventHandlerBuilder.d.ts.map +1 -0
  249. package/build/libraries/eventsourcing/utils/eventHandlerBuilder.js.map +1 -0
  250. package/build/libraries/eventsourcing/utils/externalSystemBuilder.d.ts +5 -0
  251. package/build/libraries/eventsourcing/utils/externalSystemBuilder.d.ts.map +1 -0
  252. package/build/libraries/eventsourcing/utils/externalSystemBuilder.js +43 -0
  253. package/build/libraries/eventsourcing/utils/externalSystemBuilder.js.map +1 -0
  254. package/build/libraries/eventsourcing/utils/index.d.ts +22 -0
  255. package/build/libraries/eventsourcing/utils/index.d.ts.map +1 -0
  256. package/build/libraries/eventsourcing/utils/index.js +88 -0
  257. package/build/libraries/eventsourcing/utils/index.js.map +1 -0
  258. package/build/libraries/eventsourcing/utils/policyBuilder.d.ts +4 -0
  259. package/build/libraries/eventsourcing/utils/policyBuilder.d.ts.map +1 -0
  260. package/build/libraries/eventsourcing/utils/policyBuilder.js +53 -0
  261. package/build/libraries/eventsourcing/utils/policyBuilder.js.map +1 -0
  262. package/build/libraries/eventsourcing/utils/readmodelBuilder.d.ts +6 -0
  263. package/build/libraries/eventsourcing/utils/readmodelBuilder.d.ts.map +1 -0
  264. package/build/libraries/eventsourcing/utils/readmodelBuilder.js +68 -0
  265. package/build/libraries/eventsourcing/utils/readmodelBuilder.js.map +1 -0
  266. package/build/libraries/localOutbox/index.d.ts +6 -0
  267. package/build/libraries/localOutbox/index.d.ts.map +1 -0
  268. package/build/libraries/localOutbox/index.js +72 -0
  269. package/build/libraries/localOutbox/index.js.map +1 -0
  270. package/build/libraries/modulePath.d.ts +14 -0
  271. package/build/libraries/modulePath.d.ts.map +1 -0
  272. package/build/libraries/modulePath.js +21 -0
  273. package/build/libraries/modulePath.js.map +1 -0
  274. package/build/libraries/modules/fs.d.ts +2 -4
  275. package/build/libraries/modules/fs.d.ts.map +1 -1
  276. package/build/libraries/modules/fs.js +21 -84
  277. package/build/libraries/modules/fs.js.map +1 -1
  278. package/build/libraries/modules/index.d.ts +2 -0
  279. package/build/libraries/modules/index.d.ts.map +1 -1
  280. package/build/libraries/modules/index.js +2 -0
  281. package/build/libraries/modules/index.js.map +1 -1
  282. package/build/libraries/modules/scopedPortsView.d.ts +42 -0
  283. package/build/libraries/modules/scopedPortsView.d.ts.map +1 -0
  284. package/build/libraries/modules/scopedPortsView.js +55 -0
  285. package/build/libraries/modules/scopedPortsView.js.map +1 -0
  286. package/build/libraries/modules/scopedPortsView.test.d.ts +10 -0
  287. package/build/libraries/modules/scopedPortsView.test.d.ts.map +1 -0
  288. package/build/libraries/modules/scopedPortsView.test.js +103 -0
  289. package/build/libraries/modules/scopedPortsView.test.js.map +1 -0
  290. package/build/libraries/modules/selectiveLoader.d.ts +21 -0
  291. package/build/libraries/modules/selectiveLoader.d.ts.map +1 -0
  292. package/build/libraries/modules/selectiveLoader.js +164 -0
  293. package/build/libraries/modules/selectiveLoader.js.map +1 -0
  294. package/build/libraries/modules/selectiveLoader.test.d.ts +2 -0
  295. package/build/libraries/modules/selectiveLoader.test.d.ts.map +1 -0
  296. package/build/libraries/modules/selectiveLoader.test.js +471 -0
  297. package/build/libraries/modules/selectiveLoader.test.js.map +1 -0
  298. package/build/libraries/openApi/pruneUnusedRef.d.ts.map +1 -1
  299. package/build/libraries/openApi/pruneUnusedRef.js.map +1 -1
  300. package/build/libraries/tcp/index.d.ts +0 -1
  301. package/build/libraries/tcp/index.d.ts.map +1 -1
  302. package/build/libraries/tcp/index.js +32 -9
  303. package/build/libraries/tcp/index.js.map +1 -1
  304. package/build/libraries/tcp/types.d.ts +0 -1
  305. package/build/libraries/tcp/types.d.ts.map +1 -1
  306. package/build/libraries/validation/__tests__/readmodelQuerySchema.test.d.ts +2 -0
  307. package/build/libraries/validation/__tests__/readmodelQuerySchema.test.d.ts.map +1 -0
  308. package/build/libraries/validation/__tests__/readmodelQuerySchema.test.js +100 -0
  309. package/build/libraries/validation/__tests__/readmodelQuerySchema.test.js.map +1 -0
  310. package/build/libraries/validation/__tests__/validation.test.js +17 -7
  311. package/build/libraries/validation/__tests__/validation.test.js.map +1 -1
  312. package/build/libraries/validation/index.d.ts +3 -3
  313. package/build/libraries/validation/index.d.ts.map +1 -1
  314. package/build/libraries/validation/index.js +49 -15
  315. package/build/libraries/validation/index.js.map +1 -1
  316. package/build/ports/authentication/index.js.map +1 -1
  317. package/build/ports/authentication/index.test.d.ts +2 -0
  318. package/build/ports/authentication/index.test.d.ts.map +1 -0
  319. package/build/ports/authentication/index.test.js +38 -0
  320. package/build/ports/authentication/index.test.js.map +1 -0
  321. package/build/ports/base.d.ts.map +1 -1
  322. package/build/ports/base.js +39 -5
  323. package/build/ports/base.js.map +1 -1
  324. package/build/ports/base.test.d.ts +2 -0
  325. package/build/ports/base.test.d.ts.map +1 -0
  326. package/build/ports/base.test.js +92 -0
  327. package/build/ports/base.test.js.map +1 -0
  328. package/build/ports/cache/index.js.map +1 -1
  329. package/build/ports/cache/index.test.d.ts +2 -0
  330. package/build/ports/cache/index.test.d.ts.map +1 -0
  331. package/build/ports/cache/index.test.js +43 -0
  332. package/build/ports/cache/index.test.js.map +1 -0
  333. package/build/ports/configuration/__tests__/cliArgs.test.d.ts +2 -0
  334. package/build/ports/configuration/__tests__/cliArgs.test.d.ts.map +1 -0
  335. package/build/ports/configuration/__tests__/cliArgs.test.js +158 -0
  336. package/build/ports/configuration/__tests__/cliArgs.test.js.map +1 -0
  337. package/build/ports/configuration/__tests__/configurationPortEmitter.test.d.ts +2 -0
  338. package/build/ports/configuration/__tests__/configurationPortEmitter.test.d.ts.map +1 -0
  339. package/build/ports/configuration/__tests__/configurationPortEmitter.test.js +63 -0
  340. package/build/ports/configuration/__tests__/configurationPortEmitter.test.js.map +1 -0
  341. package/build/ports/configuration/__tests__/getArgsSync.test.d.ts +2 -0
  342. package/build/ports/configuration/__tests__/getArgsSync.test.d.ts.map +1 -0
  343. package/build/ports/configuration/__tests__/getArgsSync.test.js +85 -0
  344. package/build/ports/configuration/__tests__/getArgsSync.test.js.map +1 -0
  345. package/build/ports/configuration/args.d.ts +50 -43
  346. package/build/ports/configuration/args.d.ts.map +1 -1
  347. package/build/ports/configuration/args.js +76 -13
  348. package/build/ports/configuration/args.js.map +1 -1
  349. package/build/ports/configuration/common.js +1 -2
  350. package/build/ports/configuration/common.js.map +1 -1
  351. package/build/ports/configuration/index.d.ts +1 -1
  352. package/build/ports/configuration/index.d.ts.map +1 -1
  353. package/build/ports/configuration/index.js +85 -17
  354. package/build/ports/configuration/index.js.map +1 -1
  355. package/build/ports/configuration/localConfig.d.ts.map +1 -1
  356. package/build/ports/configuration/localConfig.js +46 -27
  357. package/build/ports/configuration/localConfig.js.map +1 -1
  358. package/build/ports/database/index.d.ts +1 -2
  359. package/build/ports/database/index.d.ts.map +1 -1
  360. package/build/ports/database/index.js +23 -17
  361. package/build/ports/database/index.js.map +1 -1
  362. package/build/ports/database/index.test.d.ts +2 -0
  363. package/build/ports/database/index.test.d.ts.map +1 -0
  364. package/build/ports/database/index.test.js +43 -0
  365. package/build/ports/database/index.test.js.map +1 -0
  366. package/build/ports/endpoints/__tests__/declarationSite.test.d.ts +2 -0
  367. package/build/ports/endpoints/__tests__/declarationSite.test.d.ts.map +1 -0
  368. package/build/ports/endpoints/__tests__/declarationSite.test.js +165 -0
  369. package/build/ports/endpoints/__tests__/declarationSite.test.js.map +1 -0
  370. package/build/ports/endpoints/__tests__/fixtures/modules/sales/appLoginUrl.d.ts +9 -0
  371. package/build/ports/endpoints/__tests__/fixtures/modules/sales/appLoginUrl.d.ts.map +1 -0
  372. package/build/ports/endpoints/__tests__/fixtures/modules/sales/appLoginUrl.js +20 -0
  373. package/build/ports/endpoints/__tests__/fixtures/modules/sales/appLoginUrl.js.map +1 -0
  374. package/build/ports/endpoints/__tests__/fixtures/modules/sales/index.d.ts +10 -0
  375. package/build/ports/endpoints/__tests__/fixtures/modules/sales/index.d.ts.map +1 -0
  376. package/build/ports/endpoints/__tests__/fixtures/modules/sales/index.js +21 -0
  377. package/build/ports/endpoints/__tests__/fixtures/modules/sales/index.js.map +1 -0
  378. package/build/ports/endpoints/__tests__/fixtures/modules/sales/orders.endpoints.d.ts +15 -0
  379. package/build/ports/endpoints/__tests__/fixtures/modules/sales/orders.endpoints.d.ts.map +1 -0
  380. package/build/ports/endpoints/__tests__/fixtures/modules/sales/orders.endpoints.js +46 -0
  381. package/build/ports/endpoints/__tests__/fixtures/modules/sales/orders.endpoints.js.map +1 -0
  382. package/build/ports/endpoints/__tests__/manifestEndpoints.test.d.ts +2 -0
  383. package/build/ports/endpoints/__tests__/manifestEndpoints.test.d.ts.map +1 -0
  384. package/build/ports/endpoints/__tests__/manifestEndpoints.test.js +117 -0
  385. package/build/ports/endpoints/__tests__/manifestEndpoints.test.js.map +1 -0
  386. package/build/ports/endpoints/declarationSite.d.ts +63 -0
  387. package/build/ports/endpoints/declarationSite.d.ts.map +1 -0
  388. package/build/ports/endpoints/declarationSite.js +126 -0
  389. package/build/ports/endpoints/declarationSite.js.map +1 -0
  390. package/build/ports/endpoints/health.d.ts +26 -0
  391. package/build/ports/endpoints/health.d.ts.map +1 -0
  392. package/build/ports/endpoints/health.js +96 -0
  393. package/build/ports/endpoints/health.js.map +1 -0
  394. package/build/ports/endpoints/index.d.ts +43 -7
  395. package/build/ports/endpoints/index.d.ts.map +1 -1
  396. package/build/ports/endpoints/index.js +317 -67
  397. package/build/ports/endpoints/index.js.map +1 -1
  398. package/build/ports/endpoints/openApi.d.ts +3 -2
  399. package/build/ports/endpoints/openApi.d.ts.map +1 -1
  400. package/build/ports/endpoints/openApi.js +184 -55
  401. package/build/ports/endpoints/openApi.js.map +1 -1
  402. package/build/ports/endpoints/utils.d.ts.map +1 -1
  403. package/build/ports/endpoints/utils.js.map +1 -1
  404. package/build/ports/eventstore/index.d.ts.map +1 -1
  405. package/build/ports/eventstore/index.js +37 -5
  406. package/build/ports/eventstore/index.js.map +1 -1
  407. package/build/ports/eventstore/index.test.d.ts +2 -0
  408. package/build/ports/eventstore/index.test.d.ts.map +1 -0
  409. package/build/ports/eventstore/index.test.js +68 -0
  410. package/build/ports/eventstore/index.test.js.map +1 -0
  411. package/build/ports/infrastructure/index.d.ts +61 -23
  412. package/build/ports/infrastructure/index.d.ts.map +1 -1
  413. package/build/ports/infrastructure/index.js +187 -37
  414. package/build/ports/infrastructure/index.js.map +1 -1
  415. package/build/ports/infrastructure/index.test.d.ts +2 -0
  416. package/build/ports/infrastructure/index.test.d.ts.map +1 -0
  417. package/build/ports/infrastructure/index.test.js +228 -0
  418. package/build/ports/infrastructure/index.test.js.map +1 -0
  419. package/build/ports/infrastructure/utils.d.ts +2 -1
  420. package/build/ports/infrastructure/utils.d.ts.map +1 -1
  421. package/build/ports/infrastructure/utils.js +48 -22
  422. package/build/ports/infrastructure/utils.js.map +1 -1
  423. package/build/ports/logger/__tests__/logger.test.d.ts +2 -0
  424. package/build/ports/logger/__tests__/logger.test.d.ts.map +1 -0
  425. package/build/ports/logger/__tests__/logger.test.js +69 -0
  426. package/build/ports/logger/__tests__/logger.test.js.map +1 -0
  427. package/build/ports/logger/index.d.ts.map +1 -1
  428. package/build/ports/logger/index.js +3 -2
  429. package/build/ports/logger/index.js.map +1 -1
  430. package/build/utils/__tests__/applyCollectionFilterInMemory.test.d.ts +2 -0
  431. package/build/utils/__tests__/applyCollectionFilterInMemory.test.d.ts.map +1 -0
  432. package/build/utils/__tests__/applyCollectionFilterInMemory.test.js +33 -0
  433. package/build/utils/__tests__/applyCollectionFilterInMemory.test.js.map +1 -0
  434. package/build/utils/__tests__/decodeObjectQueryParams.test.d.ts +2 -0
  435. package/build/utils/__tests__/decodeObjectQueryParams.test.d.ts.map +1 -0
  436. package/build/utils/__tests__/decodeObjectQueryParams.test.js +118 -0
  437. package/build/utils/__tests__/decodeObjectQueryParams.test.js.map +1 -0
  438. package/build/utils/index.d.ts +26 -34
  439. package/build/utils/index.d.ts.map +1 -1
  440. package/build/utils/index.js +159 -170
  441. package/build/utils/index.js.map +1 -1
  442. package/package.json +31 -11
  443. package/build/adapters/cache/memory/__tests__/memoryCache.test.d.ts +0 -1
  444. package/build/adapters/cache/memory/__tests__/memoryCache.test.d.ts.map +0 -1
  445. package/build/adapters/cache/memory/__tests__/memoryCache.test.js +0 -6
  446. package/build/adapters/cache/memory/__tests__/memoryCache.test.js.map +0 -1
  447. package/build/adapters/database/memory/__tests__/memoryDb.test.d.ts +0 -1
  448. package/build/adapters/database/memory/__tests__/memoryDb.test.d.ts.map +0 -1
  449. package/build/adapters/database/memory/__tests__/memoryDb.test.js +0 -36
  450. package/build/adapters/database/memory/__tests__/memoryDb.test.js.map +0 -1
  451. package/build/ports/endpoints/__tests__/endpointsCall.test.d.ts +0 -2
  452. package/build/ports/endpoints/__tests__/endpointsCall.test.d.ts.map +0 -1
  453. package/build/ports/endpoints/__tests__/endpointsCall.test.js +0 -21
  454. package/build/ports/endpoints/__tests__/endpointsCall.test.js.map +0 -1
  455. package/build/ports/endpoints/__tests__/test-client-library/base.d.ts +0 -77
  456. package/build/ports/endpoints/__tests__/test-client-library/base.d.ts.map +0 -1
  457. package/build/ports/endpoints/__tests__/test-client-library/base.js +0 -91
  458. package/build/ports/endpoints/__tests__/test-client-library/base.js.map +0 -1
  459. package/build/ports/endpoints/__tests__/test-client-library/index.d.ts +0 -29
  460. package/build/ports/endpoints/__tests__/test-client-library/index.d.ts.map +0 -1
  461. package/build/ports/endpoints/__tests__/test-client-library/index.js +0 -43
  462. package/build/ports/endpoints/__tests__/test-client-library/index.js.map +0 -1
  463. package/build/ports/endpoints/__tests__/test-client-library/services/service.d.ts +0 -106
  464. package/build/ports/endpoints/__tests__/test-client-library/services/service.d.ts.map +0 -1
  465. package/build/ports/endpoints/__tests__/test-client-library/services/service.js +0 -62
  466. package/build/ports/endpoints/__tests__/test-client-library/services/service.js.map +0 -1
  467. package/build/ports/endpoints/__tests__/utils.test.d.ts +0 -1
  468. package/build/ports/endpoints/__tests__/utils.test.d.ts.map +0 -1
  469. package/build/ports/endpoints/__tests__/utils.test.js +0 -53
  470. package/build/ports/endpoints/__tests__/utils.test.js.map +0 -1
  471. package/build/ports/eventsourcing/__tests__/eventhandlers.test.d.ts +0 -2
  472. package/build/ports/eventsourcing/__tests__/eventhandlers.test.d.ts.map +0 -1
  473. package/build/ports/eventsourcing/__tests__/eventhandlers.test.js +0 -35
  474. package/build/ports/eventsourcing/__tests__/eventhandlers.test.js.map +0 -1
  475. package/build/ports/eventsourcing/__tests__/invariants.test.d.ts +0 -2
  476. package/build/ports/eventsourcing/__tests__/invariants.test.d.ts.map +0 -1
  477. package/build/ports/eventsourcing/__tests__/invariants.test.js +0 -210
  478. package/build/ports/eventsourcing/__tests__/invariants.test.js.map +0 -1
  479. package/build/ports/eventsourcing/commandHandlers/index.d.ts +0 -25
  480. package/build/ports/eventsourcing/commandHandlers/index.d.ts.map +0 -1
  481. package/build/ports/eventsourcing/commandHandlers/index.js +0 -392
  482. package/build/ports/eventsourcing/commandHandlers/index.js.map +0 -1
  483. package/build/ports/eventsourcing/commandTemplates/index.d.ts.map +0 -1
  484. package/build/ports/eventsourcing/commandTemplates/index.js.map +0 -1
  485. package/build/ports/eventsourcing/commandTemplates/multiStream.d.ts +0 -4
  486. package/build/ports/eventsourcing/commandTemplates/multiStream.d.ts.map +0 -1
  487. package/build/ports/eventsourcing/commandTemplates/multiStream.js +0 -73
  488. package/build/ports/eventsourcing/commandTemplates/multiStream.js.map +0 -1
  489. package/build/ports/eventsourcing/commandTemplates/snapshot.d.ts +0 -9
  490. package/build/ports/eventsourcing/commandTemplates/snapshot.d.ts.map +0 -1
  491. package/build/ports/eventsourcing/commandTemplates/snapshot.js +0 -39
  492. package/build/ports/eventsourcing/commandTemplates/snapshot.js.map +0 -1
  493. package/build/ports/eventsourcing/eventHandlers/index.d.ts +0 -33
  494. package/build/ports/eventsourcing/eventHandlers/index.d.ts.map +0 -1
  495. package/build/ports/eventsourcing/eventHandlers/index.js +0 -276
  496. package/build/ports/eventsourcing/eventHandlers/index.js.map +0 -1
  497. package/build/ports/eventsourcing/index.d.ts +0 -9
  498. package/build/ports/eventsourcing/index.d.ts.map +0 -1
  499. package/build/ports/eventsourcing/invariants/combinators.d.ts +0 -4
  500. package/build/ports/eventsourcing/invariants/combinators.d.ts.map +0 -1
  501. package/build/ports/eventsourcing/invariants/combinators.js.map +0 -1
  502. package/build/ports/eventsourcing/invariants/common.d.ts +0 -10
  503. package/build/ports/eventsourcing/invariants/common.d.ts.map +0 -1
  504. package/build/ports/eventsourcing/invariants/common.js +0 -37
  505. package/build/ports/eventsourcing/invariants/common.js.map +0 -1
  506. package/build/ports/eventsourcing/invariants/comparisons.d.ts +0 -19
  507. package/build/ports/eventsourcing/invariants/comparisons.d.ts.map +0 -1
  508. package/build/ports/eventsourcing/invariants/comparisons.js +0 -83
  509. package/build/ports/eventsourcing/invariants/comparisons.js.map +0 -1
  510. package/build/ports/eventsourcing/invariants/index.d.ts +0 -5
  511. package/build/ports/eventsourcing/invariants/index.d.ts.map +0 -1
  512. package/build/ports/eventsourcing/invariants/index.js +0 -21
  513. package/build/ports/eventsourcing/invariants/index.js.map +0 -1
  514. package/build/ports/eventsourcing/invariants/stateExistance.d.ts +0 -4
  515. package/build/ports/eventsourcing/invariants/stateExistance.d.ts.map +0 -1
  516. package/build/ports/eventsourcing/invariants/stateExistance.js +0 -33
  517. package/build/ports/eventsourcing/invariants/stateExistance.js.map +0 -1
  518. package/build/ports/eventsourcing/subscriptions/index.d.ts.map +0 -1
  519. package/build/ports/eventsourcing/subscriptions/index.js.map +0 -1
  520. package/build/ports/eventsourcing/subscriptions/sseSubscriptions.d.ts +0 -3
  521. package/build/ports/eventsourcing/subscriptions/sseSubscriptions.d.ts.map +0 -1
  522. package/build/ports/eventsourcing/subscriptions/sseSubscriptions.js +0 -81
  523. package/build/ports/eventsourcing/subscriptions/sseSubscriptions.js.map +0 -1
  524. package/build/ports/eventsourcing/utils/aggregateBuilder.d.ts +0 -4
  525. package/build/ports/eventsourcing/utils/aggregateBuilder.d.ts.map +0 -1
  526. package/build/ports/eventsourcing/utils/aggregateBuilder.js.map +0 -1
  527. package/build/ports/eventsourcing/utils/commandBuilder.d.ts +0 -3
  528. package/build/ports/eventsourcing/utils/commandBuilder.d.ts.map +0 -1
  529. package/build/ports/eventsourcing/utils/commandBuilder.js.map +0 -1
  530. package/build/ports/eventsourcing/utils/eventHandlerBuilder.d.ts.map +0 -1
  531. package/build/ports/eventsourcing/utils/eventHandlerBuilder.js.map +0 -1
  532. package/build/ports/eventsourcing/utils/externalSystemBuilder.d.ts +0 -4
  533. package/build/ports/eventsourcing/utils/externalSystemBuilder.d.ts.map +0 -1
  534. package/build/ports/eventsourcing/utils/externalSystemBuilder.js +0 -34
  535. package/build/ports/eventsourcing/utils/externalSystemBuilder.js.map +0 -1
  536. package/build/ports/eventsourcing/utils/index.d.ts +0 -13
  537. package/build/ports/eventsourcing/utils/index.d.ts.map +0 -1
  538. package/build/ports/eventsourcing/utils/index.js +0 -45
  539. package/build/ports/eventsourcing/utils/index.js.map +0 -1
  540. package/build/ports/eventsourcing/utils/policyBuilder.d.ts +0 -3
  541. package/build/ports/eventsourcing/utils/policyBuilder.d.ts.map +0 -1
  542. package/build/ports/eventsourcing/utils/policyBuilder.js +0 -29
  543. package/build/ports/eventsourcing/utils/policyBuilder.js.map +0 -1
  544. package/build/ports/eventsourcing/utils/readmodelBuilder.d.ts +0 -5
  545. package/build/ports/eventsourcing/utils/readmodelBuilder.d.ts.map +0 -1
  546. package/build/ports/eventsourcing/utils/readmodelBuilder.js +0 -45
  547. package/build/ports/eventsourcing/utils/readmodelBuilder.js.map +0 -1
  548. package/build/ports/infrastructure/__tests__/fixture/index.d.ts +0 -3
  549. package/build/ports/infrastructure/__tests__/fixture/index.d.ts.map +0 -1
  550. package/build/ports/infrastructure/__tests__/fixture/index.js +0 -19
  551. package/build/ports/infrastructure/__tests__/fixture/index.js.map +0 -1
  552. package/build/ports/infrastructure/__tests__/fixture/infrastructureServices.d.ts +0 -19
  553. package/build/ports/infrastructure/__tests__/fixture/infrastructureServices.d.ts.map +0 -1
  554. package/build/ports/infrastructure/__tests__/fixture/infrastructureServices.js +0 -76
  555. package/build/ports/infrastructure/__tests__/fixture/infrastructureServices.js.map +0 -1
  556. package/build/ports/infrastructure/__tests__/fixture/structureState.d.ts +0 -177
  557. package/build/ports/infrastructure/__tests__/fixture/structureState.d.ts.map +0 -1
  558. package/build/ports/infrastructure/__tests__/fixture/structureState.js +0 -258
  559. package/build/ports/infrastructure/__tests__/fixture/structureState.js.map +0 -1
  560. package/build/ports/infrastructure/__tests__/infrastructure.test.d.ts +0 -2
  561. package/build/ports/infrastructure/__tests__/infrastructure.test.d.ts.map +0 -1
  562. package/build/ports/infrastructure/__tests__/infrastructure.test.js +0 -11
  563. package/build/ports/infrastructure/__tests__/infrastructure.test.js.map +0 -1
  564. package/src/adapters/cache/index.ts +0 -1
  565. package/src/adapters/cache/memory/__tests__/memoryCache.test.ts +0 -6
  566. package/src/adapters/cache/memory/index.ts +0 -142
  567. package/src/adapters/configuration/__tests__/.env +0 -4
  568. package/src/adapters/configuration/__tests__/dotEnv.test.ts +0 -38
  569. package/src/adapters/configuration/dotEnv.ts +0 -33
  570. package/src/adapters/configuration/index.ts +0 -1
  571. package/src/adapters/database/index.ts +0 -1
  572. package/src/adapters/database/memory/__tests__/memoryDb.test.ts +0 -37
  573. package/src/adapters/database/memory/index.ts +0 -279
  574. package/src/adapters/endpoints/addAuthUser/index.ts +0 -55
  575. package/src/adapters/endpoints/endpointValidation/index.ts +0 -26
  576. package/src/adapters/endpoints/index.ts +0 -4
  577. package/src/adapters/endpoints/localAuthorization/index.ts +0 -75
  578. package/src/adapters/endpoints/tcpConsumer/index.ts +0 -69
  579. package/src/adapters/endpoints/userSession/index.ts +0 -40
  580. package/src/adapters/eventstore/database.ts +0 -178
  581. package/src/adapters/eventstore/index.ts +0 -1
  582. package/src/adapters/infrastructure/index.ts +0 -1
  583. package/src/adapters/infrastructure/local/index.ts +0 -40
  584. package/src/adapters/logger/console.ts +0 -42
  585. package/src/adapters/logger/index.ts +0 -1
  586. package/src/index.ts +0 -25
  587. package/src/libraries/modules/fs.ts +0 -88
  588. package/src/libraries/modules/index.ts +0 -1
  589. package/src/libraries/openApi/index.ts +0 -1
  590. package/src/libraries/openApi/pruneUnusedRef.ts +0 -35
  591. package/src/libraries/tcp/index.ts +0 -98
  592. package/src/libraries/tcp/types.ts +0 -43
  593. package/src/libraries/validation/__tests__/validation.test.ts +0 -25
  594. package/src/libraries/validation/index.ts +0 -48
  595. package/src/ports/authentication/index.ts +0 -25
  596. package/src/ports/base.ts +0 -20
  597. package/src/ports/cache/index.ts +0 -17
  598. package/src/ports/configuration/__tests__/configurationPort.test.ts +0 -47
  599. package/src/ports/configuration/args.ts +0 -39
  600. package/src/ports/configuration/common.ts +0 -12
  601. package/src/ports/configuration/index.ts +0 -110
  602. package/src/ports/configuration/localConfig.ts +0 -117
  603. package/src/ports/database/index.ts +0 -25
  604. package/src/ports/endpoints/__tests__/endpointsCall.test.ts +0 -20
  605. package/src/ports/endpoints/__tests__/test-client-library/base.ts +0 -167
  606. package/src/ports/endpoints/__tests__/test-client-library/index.ts +0 -23
  607. package/src/ports/endpoints/__tests__/test-client-library/services/service.ts +0 -181
  608. package/src/ports/endpoints/__tests__/utils.test.ts +0 -54
  609. package/src/ports/endpoints/index.ts +0 -272
  610. package/src/ports/endpoints/openApi.ts +0 -191
  611. package/src/ports/endpoints/utils.ts +0 -31
  612. package/src/ports/eventsourcing/__tests__/eventhandlers.test.ts +0 -30
  613. package/src/ports/eventsourcing/__tests__/invariants.test.ts +0 -213
  614. package/src/ports/eventsourcing/commandHandlers/index.ts +0 -625
  615. package/src/ports/eventsourcing/commandTemplates/index.ts +0 -2
  616. package/src/ports/eventsourcing/commandTemplates/multiStream.ts +0 -70
  617. package/src/ports/eventsourcing/commandTemplates/snapshot.ts +0 -43
  618. package/src/ports/eventsourcing/eventHandlers/index.ts +0 -429
  619. package/src/ports/eventsourcing/index.ts +0 -98
  620. package/src/ports/eventsourcing/invariants/combinators.ts +0 -25
  621. package/src/ports/eventsourcing/invariants/common.ts +0 -42
  622. package/src/ports/eventsourcing/invariants/comparisons.ts +0 -90
  623. package/src/ports/eventsourcing/invariants/index.ts +0 -4
  624. package/src/ports/eventsourcing/invariants/stateExistance.ts +0 -34
  625. package/src/ports/eventsourcing/subscriptions/index.ts +0 -1
  626. package/src/ports/eventsourcing/subscriptions/sseSubscriptions.ts +0 -103
  627. package/src/ports/eventsourcing/utils/aggregateBuilder.ts +0 -49
  628. package/src/ports/eventsourcing/utils/commandBuilder.ts +0 -113
  629. package/src/ports/eventsourcing/utils/eventHandlerBuilder.ts +0 -22
  630. package/src/ports/eventsourcing/utils/externalSystemBuilder.ts +0 -42
  631. package/src/ports/eventsourcing/utils/index.ts +0 -25
  632. package/src/ports/eventsourcing/utils/policyBuilder.ts +0 -31
  633. package/src/ports/eventsourcing/utils/readmodelBuilder.ts +0 -52
  634. package/src/ports/eventstore/index.ts +0 -11
  635. package/src/ports/infrastructure/__tests__/fixture/index.ts +0 -2
  636. package/src/ports/infrastructure/__tests__/fixture/infrastructureServices.ts +0 -72
  637. package/src/ports/infrastructure/__tests__/fixture/structureState.ts +0 -254
  638. package/src/ports/infrastructure/__tests__/infrastructure.test.ts +0 -11
  639. package/src/ports/infrastructure/index.ts +0 -162
  640. package/src/ports/infrastructure/utils.ts +0 -130
  641. package/src/ports/logger/index.ts +0 -34
  642. package/src/utils/index.ts +0 -186
  643. package/tsconfig.json +0 -19
  644. /package/build/{ports → libraries}/eventsourcing/commandTemplates/index.d.ts +0 -0
  645. /package/build/{ports → libraries}/eventsourcing/commandTemplates/index.js +0 -0
  646. /package/build/{ports → libraries}/eventsourcing/subscriptions/index.d.ts +0 -0
  647. /package/build/{ports → libraries}/eventsourcing/subscriptions/index.js +0 -0
  648. /package/build/{ports → libraries}/eventsourcing/utils/eventHandlerBuilder.js +0 -0
@@ -0,0 +1,695 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.computeMDUs = void 0;
7
+ const modulePath_1 = require("../modulePath");
8
+ const path_1 = __importDefault(require("path"));
9
+ // ---------------------------------------------------------------------------
10
+ // Union-Find for connected components
11
+ // ---------------------------------------------------------------------------
12
+ class UnionFind {
13
+ parent = new Map();
14
+ rank = new Map();
15
+ add(id) {
16
+ if (!this.parent.has(id)) {
17
+ this.parent.set(id, id);
18
+ this.rank.set(id, 0);
19
+ }
20
+ }
21
+ find(id) {
22
+ let current = id;
23
+ while (this.parent.get(current) !== current) {
24
+ const grandparent = this.parent.get(this.parent.get(current));
25
+ this.parent.set(current, grandparent);
26
+ current = grandparent;
27
+ }
28
+ return current;
29
+ }
30
+ union(a, b) {
31
+ const rootA = this.find(a);
32
+ const rootB = this.find(b);
33
+ if (rootA === rootB)
34
+ return;
35
+ const rankA = this.rank.get(rootA);
36
+ const rankB = this.rank.get(rootB);
37
+ if (rankA < rankB) {
38
+ this.parent.set(rootA, rootB);
39
+ }
40
+ else if (rankA > rankB) {
41
+ this.parent.set(rootB, rootA);
42
+ }
43
+ else {
44
+ this.parent.set(rootB, rootA);
45
+ this.rank.set(rootA, rankA + 1);
46
+ }
47
+ }
48
+ getComponents() {
49
+ const components = new Map();
50
+ for (const id of this.parent.keys()) {
51
+ const root = this.find(id);
52
+ if (!components.has(root)) {
53
+ components.set(root, []);
54
+ }
55
+ components.get(root).push(id);
56
+ }
57
+ return components;
58
+ }
59
+ }
60
+ // ---------------------------------------------------------------------------
61
+ // Helpers
62
+ // ---------------------------------------------------------------------------
63
+ const makeRelativePath = (absolutePath, serviceRoot) => {
64
+ if (!absolutePath)
65
+ return '';
66
+ return path_1.default.relative(serviceRoot, absolutePath).replace(/\\/g, '/');
67
+ };
68
+ /**
69
+ * Derives the named export from an artifact's registered name.
70
+ * getStackTrace() captures the file-derived name (e.g. "ChartOfAccounts" from
71
+ * chartOfAccounts.aggregate.ts), but the actual export in the file typically
72
+ * includes a type suffix (e.g. "ChartOfAccountsAggregate").
73
+ *
74
+ * If the registered name already ends with the expected suffix, it's returned as-is.
75
+ * Otherwise the suffix is appended.
76
+ */
77
+ const typeSuffixMap = {
78
+ aggregate: 'Aggregate',
79
+ externalSystem: 'System',
80
+ readmodel: 'Readmodel',
81
+ policy: 'Policy'
82
+ };
83
+ const deriveExportName = (name, type) => {
84
+ const suffix = typeSuffixMap[type];
85
+ if (!suffix)
86
+ return name; // endpoints and unknown types
87
+ // If name already ends with the suffix, return as-is
88
+ if (name.endsWith(suffix))
89
+ return name;
90
+ return `${name}${suffix}`;
91
+ };
92
+ /**
93
+ * The module a unit is addressed by (`<module>:<Name>` in `--lift`).
94
+ *
95
+ * The filesystem is authoritative: an artifact under `modules/billing/` belongs
96
+ * to billing whatever it declares. The declared subdomain is only a fallback for
97
+ * artifacts that sit outside a module directory, because subdomain answers a
98
+ * different question — it drives route authorization, and billing deliberately
99
+ * declares `.withSubdomain('')` (ADR-026) so its routes carry no `x-subdomain`.
100
+ * Reading the label off the subdomain made all 18 of those units `unknown:` and
101
+ * therefore unaddressable.
102
+ */
103
+ const deriveModule = (filePath, subdomain) => {
104
+ return (0, modulePath_1.moduleFromPath)(filePath) || subdomain || 'unknown';
105
+ };
106
+ /** `healthSync.endpoints.ts` -> `healthSync`, mirroring `getStackTrace()`'s naming. */
107
+ const fileDerivedName = (filePath) => path_1.default.basename(filePath).replace(/\..+$/, '');
108
+ /**
109
+ * A route's identity: `<METHOD> <route>`, method defaulting to GET exactly as
110
+ * `registerOpenApiEndpoint` does for the same endpoint.
111
+ *
112
+ * This string is the join key. Teselly's manifest-coverage guard builds the
113
+ * other side of the comparison with the identical expression (`routeId` in
114
+ * `scripts/checkManifestCoverage.ts`), and a key that differs by so much as the
115
+ * default verb makes that join half-match in silence.
116
+ */
117
+ const routeId = (endpoint) => `${(endpoint.method || 'GET').toUpperCase()} ${endpoint.route}`;
118
+ const groupEndpointsByFile = (customEndpoints) => {
119
+ const groups = new Map();
120
+ for (const endpoint of customEndpoints) {
121
+ const group = groups.get(endpoint.filePath) || {
122
+ filePath: endpoint.filePath,
123
+ name: '',
124
+ subdomain: endpoint.subdomain,
125
+ linkedTo: [],
126
+ routes: [],
127
+ endpoints: []
128
+ };
129
+ group.endpoints.push(endpoint);
130
+ // One endpoint's declaration speaks for the whole file — see `linkedTo` on
131
+ // EndpointGroup. Its undeclared siblings ride along into the linked unit.
132
+ for (const target of endpoint.linkedTo || []) {
133
+ if (!group.linkedTo.includes(target))
134
+ group.linkedTo.push(target);
135
+ }
136
+ // Deduplicated by route id, because `registerEndpoint` stores an endpoint
137
+ // under TWO route-table keys when its path has an optional parameter, so a
138
+ // caller reading that table hands the same route in twice.
139
+ //
140
+ // The `route` guard is not for the port path — `route` is required on
141
+ // `ManifestEndpoint`, and `registerEndpoint` would throw on
142
+ // `endpoint.route.match( … )` immediately after the capture anyway, so a
143
+ // route-less endpoint never reaches the route table. It is for the OTHER
144
+ // caller class: one passing `customEndpoints` in directly, from untyped
145
+ // JavaScript (teselly's manifest fixtures do exactly this). Such an entry
146
+ // contributes nothing rather than a `"GET undefined"` line in a committed,
147
+ // drift-watched artifact.
148
+ if (endpoint.route) {
149
+ const id = routeId(endpoint);
150
+ if (!group.routes.includes(id))
151
+ group.routes.push(id);
152
+ }
153
+ groups.set(endpoint.filePath, group);
154
+ }
155
+ for (const group of groups.values()) {
156
+ const [declaringFunction, ...furtherDeclaringFunctions] = [
157
+ ...new Set(group.endpoints.map(e => e.exportName).filter((name) => !!name))
158
+ ];
159
+ // One declaring function is the shape the loader can honour — it calls that
160
+ // one export. Anything else falls back to the file name and leans on the
161
+ // loader's fuzzy export match.
162
+ group.name = declaringFunction && furtherDeclaringFunctions.length === 0
163
+ ? declaringFunction
164
+ : fileDerivedName(group.filePath);
165
+ }
166
+ return [...groups.values()];
167
+ };
168
+ // ---------------------------------------------------------------------------
169
+ // computeMDUs — the main algorithm
170
+ // ---------------------------------------------------------------------------
171
+ const computeMDUs = (registeredEndpoints, serviceName, serviceRoot, customEndpoints) => {
172
+ const nodes = new Map();
173
+ const uf = new UnionFind();
174
+ const validationErrors = [];
175
+ // Node keys are type-prefixed to avoid collisions (e.g., an aggregate and
176
+ // policy can share the same registered name like "LanggraphAgentRunner")
177
+ const nodeKey = (type, name) => `${type}::${name}`;
178
+ // -----------------------------------------------------------------------
179
+ // 1. INITIALIZE nodes
180
+ // -----------------------------------------------------------------------
181
+ // Aggregates
182
+ for (const [name, data] of Object.entries(registeredEndpoints.aggregates)) {
183
+ const module = deriveModule(data.filePath, data.subdomain);
184
+ const key = nodeKey('aggregate', name);
185
+ nodes.set(key, {
186
+ name,
187
+ type: 'aggregate',
188
+ module,
189
+ filePath: data.filePath
190
+ });
191
+ uf.add(key);
192
+ }
193
+ // External systems
194
+ for (const [name, data] of Object.entries(registeredEndpoints.systems)) {
195
+ const module = deriveModule(data.filePath, data.subdomain);
196
+ const key = nodeKey('externalSystem', name);
197
+ nodes.set(key, {
198
+ name,
199
+ type: 'externalSystem',
200
+ module,
201
+ filePath: data.filePath
202
+ });
203
+ uf.add(key);
204
+ }
205
+ // Readmodels — registered under `projectors`, which since TV1-2275 also holds
206
+ // readmodels that project NOTHING. A query-only readmodel (`ReadmodelBuilder(
207
+ // Schema )` with no events namespace) serves a GET route and is therefore a
208
+ // deployment artifact like any other; it simply consumes nothing, so `events` is
209
+ // empty and it joins no component through an event edge. The map keeps the name:
210
+ // renaming it is a pv3-types breaking change across every consumer, for a naming
211
+ // gain.
212
+ for (const [name, data] of Object.entries(registeredEndpoints.projectors)) {
213
+ const module = deriveModule(data.filePath, data.subdomain);
214
+ const key = nodeKey('readmodel', name);
215
+ nodes.set(key, {
216
+ name,
217
+ type: 'readmodel',
218
+ module,
219
+ filePath: data.filePath,
220
+ events: data.events
221
+ });
222
+ uf.add(key);
223
+ }
224
+ // Policies
225
+ for (const [name, data] of Object.entries(registeredEndpoints.policies)) {
226
+ const module = deriveModule(data.filePath, data.subdomain);
227
+ const key = nodeKey('policy', name);
228
+ nodes.set(key, {
229
+ name,
230
+ type: 'policy',
231
+ module,
232
+ filePath: data.filePath,
233
+ commandHandlerName: data.commandHandlerName,
234
+ linkedTo: data.linkedTo,
235
+ isStandalone: data.isStandalone,
236
+ events: data.events
237
+ });
238
+ uf.add(key);
239
+ }
240
+ // The artifact that already owns a file, by path. A readmodel, aggregate,
241
+ // system or policy file may ALSO register manual routes at the top level of
242
+ // its factory (`featureFlags.readmodel.ts` registers two), and V8 then names
243
+ // the frame after that same factory — so a second node for it would carry the
244
+ // same filePath, name AND exportName as the first. Insertion order decides if
245
+ // one file somehow declares two artifacts; that order is the fixed
246
+ // aggregates -> systems -> readmodels -> policies walk above.
247
+ const artifactNodeByFilePath = new Map();
248
+ for (const [key, node] of nodes) {
249
+ if (!artifactNodeByFilePath.has(node.filePath))
250
+ artifactNodeByFilePath.set(node.filePath, key);
251
+ }
252
+ // Manually registered endpoints, one node per declaring file. Keyed by path
253
+ // rather than by name, so two files that derive the same name cannot collide
254
+ // and silently drop one of them.
255
+ const endpointGroups = groupEndpointsByFile(customEndpoints || []);
256
+ /**
257
+ * The node a declaring file resolves to: the artifact that already owns the
258
+ * file when there is one, otherwise the file's own endpoint node.
259
+ *
260
+ * One file is one unit. A file that already owns an artifact is already
261
+ * placed by it, and emitting a second artifact would put that file in two
262
+ * units — two pods requiring it, both running its factory, both registering
263
+ * every route in it. The routes are attached to the owning artifact instead,
264
+ * which keeps the route -> unit join whole.
265
+ */
266
+ const groupNodeKey = (group) => artifactNodeByFilePath.get(group.filePath) || nodeKey('endpoint', group.filePath);
267
+ for (const group of endpointGroups) {
268
+ const owningKey = artifactNodeByFilePath.get(group.filePath);
269
+ if (owningKey) {
270
+ nodes.get(owningKey).routes = group.routes;
271
+ continue;
272
+ }
273
+ const key = nodeKey('endpoint', group.filePath);
274
+ nodes.set(key, {
275
+ name: group.name,
276
+ type: 'endpoint',
277
+ module: deriveModule(group.filePath, group.subdomain),
278
+ filePath: group.filePath,
279
+ linkedTo: group.linkedTo,
280
+ routes: group.routes
281
+ });
282
+ uf.add(key);
283
+ }
284
+ // Every file in a module that declares no target — and owns no other artifact
285
+ // — joins ONE component, which below becomes `<module>:Endpoints`. Per module
286
+ // rather than per file because that id is hand-written into a topology intent
287
+ // and must survive a file rename — a filename-derived unit id makes a rename
288
+ // silently rewrite a persisted deployment identifier (and it is ~13 units
289
+ // instead of ~35).
290
+ const undeclaredEndpointsByModule = new Map();
291
+ for (const group of endpointGroups) {
292
+ if (group.linkedTo.length > 0)
293
+ continue;
294
+ if (artifactNodeByFilePath.has(group.filePath))
295
+ continue;
296
+ const key = nodeKey('endpoint', group.filePath);
297
+ const module = deriveModule(group.filePath, group.subdomain);
298
+ const first = undeclaredEndpointsByModule.get(module);
299
+ if (first === undefined)
300
+ undeclaredEndpointsByModule.set(module, key);
301
+ else
302
+ uf.union(first, key);
303
+ }
304
+ // Build a lookup of command handler names → node keys (aggregates + systems)
305
+ // Supports both file-derived names ("publications") and function-style names ("PublicationsAggregate")
306
+ const commandHandlerByName = new Map(); // registered name → node key
307
+ const commandHandlerNormalizedLookup = new Map(); // normalized → node key
308
+ const normalizeCommandHandlerName = (name) => name.toLowerCase().replace(/aggregate$|system$|externalsystem$/, '');
309
+ for (const [key, node] of nodes) {
310
+ if (node.type === 'aggregate' || node.type === 'externalSystem') {
311
+ commandHandlerByName.set(node.name, key);
312
+ commandHandlerNormalizedLookup.set(normalizeCommandHandlerName(node.name), key);
313
+ }
314
+ }
315
+ /** Resolves a command handler reference (name) to its node key */
316
+ const resolveCommandHandler = (ref) => {
317
+ if (commandHandlerByName.has(ref))
318
+ return commandHandlerByName.get(ref);
319
+ return commandHandlerNormalizedLookup.get(normalizeCommandHandlerName(ref));
320
+ };
321
+ // Readmodels, by their registered name. A SECOND map on purpose, read only by
322
+ // `resolveEndpointTarget` below — see there.
323
+ const readmodelByName = new Map();
324
+ for (const [key, node] of nodes) {
325
+ if (node.type === 'readmodel')
326
+ readmodelByName.set(node.name, key);
327
+ }
328
+ /**
329
+ * The node an ENDPOINT's `linkedTo` entry names — a command handler, or a
330
+ * readmodel, so a route can be pinned to a query pod and not only to a
331
+ * command one.
332
+ *
333
+ * This is deliberately NOT a widening of `resolveCommandHandler`, and the two
334
+ * must not be merged: the same word means different things on the two
335
+ * declarers. A policy's `linkedTo` asserts *"I dispatch commands here"*, which
336
+ * a readmodel cannot receive — one shared lookup would legalise a command
337
+ * aimed at something that can never take it, silently, at generation time. An
338
+ * endpoint's asserts *"serve me where this lives"*, which a query pod honours
339
+ * exactly as well as a command pod.
340
+ *
341
+ * Readmodels match by their REGISTERED NAME ONLY — no suffix-stripping
342
+ * counterpart to `normalizeCommandHandlerName`. That normalization exists so a
343
+ * declaration may name the export (`ItemsAggregate`) where the registration is
344
+ * file-derived (`Items`); every registered readmodel name already ends in
345
+ * `Readmodel`, so the equivalent buys nothing here. A miss is a loud
346
+ * generation error naming the reference, never a silent placement.
347
+ *
348
+ * Command handlers win a tie: a name that resolves as both keeps resolving to
349
+ * the aggregate it already did, so no existing declaration changes meaning.
350
+ */
351
+ const resolveEndpointTarget = (ref) => resolveCommandHandler(ref) || readmodelByName.get(ref);
352
+ // -----------------------------------------------------------------------
353
+ // 2. BUILD edges (command execution dependencies only)
354
+ // -----------------------------------------------------------------------
355
+ // For each policy: edges from commandHandlerName and linkedTo
356
+ for (const [key, node] of nodes) {
357
+ if (node.type !== 'policy')
358
+ continue;
359
+ const targetKeys = [];
360
+ if (node.commandHandlerName) {
361
+ const resolvedKey = resolveCommandHandler(node.commandHandlerName);
362
+ if (resolvedKey) {
363
+ targetKeys.push(resolvedKey);
364
+ }
365
+ else {
366
+ validationErrors.push(`Policy "${node.name}" references commandHandler "${node.commandHandlerName}" which does not exist in registeredEndpoints.`);
367
+ }
368
+ }
369
+ if (node.linkedTo) {
370
+ for (const target of node.linkedTo) {
371
+ const resolvedKey = resolveCommandHandler(target);
372
+ if (resolvedKey) {
373
+ targetKeys.push(resolvedKey);
374
+ }
375
+ else {
376
+ validationErrors.push(`Policy "${node.name}" has linkedTo "${target}" which does not exist in registeredEndpoints.`);
377
+ }
378
+ }
379
+ }
380
+ // VALIDATE: every policy must have commandHandlerName, linkedTo, or isStandalone
381
+ if (!node.commandHandlerName && (!node.linkedTo || node.linkedTo.length === 0) && !node.isStandalone) {
382
+ validationErrors.push(`Policy "${node.name}" has no dependency declaration. Use .linkedTo() or .standalone().`);
383
+ }
384
+ // Union the policy with each of its targets
385
+ for (const targetKey of targetKeys) {
386
+ uf.union(key, targetKey);
387
+ }
388
+ }
389
+ /** The targets of one endpoint, in declaration order, dropping unresolved ones. */
390
+ const resolveEndpointTargets = (endpoint) => (endpoint.linkedTo || [])
391
+ .map(target => resolveEndpointTarget(target))
392
+ .filter((key) => key !== undefined);
393
+ // For each custom endpoint: edges from linkedTo. Unioned per endpoint rather
394
+ // than per file, because the two cases are not the same declaration: ONE route
395
+ // naming several aggregates deliberately merges them (it writes to all of
396
+ // them), whereas two routes in one file pulling towards different units is an
397
+ // accident of file layout. Merging those silently would fuse two unrelated
398
+ // units, so the per-file check below has to be able to see them apart.
399
+ for (const group of endpointGroups) {
400
+ for (const endpoint of group.endpoints) {
401
+ for (const target of endpoint.linkedTo || []) {
402
+ if (!resolveEndpointTarget(target)) {
403
+ validationErrors.push(`Endpoint "${endpoint.name}" has linkedTo "${target}" which does not exist in registeredEndpoints.`);
404
+ }
405
+ }
406
+ const [firstTarget, ...furtherTargets] = resolveEndpointTargets(endpoint);
407
+ for (const targetKey of furtherTargets) {
408
+ uf.union(firstTarget, targetKey);
409
+ }
410
+ }
411
+ }
412
+ // -----------------------------------------------------------------------
413
+ // Fail fast on validation errors
414
+ // -----------------------------------------------------------------------
415
+ if (validationErrors.length > 0) {
416
+ throw new Error(`[deployment-units] Validation errors:\n${validationErrors.map(e => ` - ${e}`).join('\n')}`);
417
+ }
418
+ // -----------------------------------------------------------------------
419
+ // 2b. One file, one unit — then join the file's artifact to that unit
420
+ // -----------------------------------------------------------------------
421
+ for (const group of endpointGroups) {
422
+ const perEndpointRoots = group.endpoints
423
+ // An endpoint declaring nothing pulls the file nowhere: its file is placed
424
+ // by whatever its siblings declare, or — if none of them declares
425
+ // anything — by its module. Only a declaration can contradict another.
426
+ .filter(endpoint => resolveEndpointTargets(endpoint).length > 0)
427
+ .map(endpoint => {
428
+ // An endpoint's own targets were unioned above, so any one of them names
429
+ // the unit the endpoint resolves to.
430
+ const [firstTarget] = resolveEndpointTargets(endpoint);
431
+ return { endpoint, root: uf.find(firstTarget) };
432
+ });
433
+ if (new Set(perEndpointRoots.map(r => r.root)).size > 1) {
434
+ const declarations = perEndpointRoots
435
+ .map(r => ` - "${r.endpoint.name}" -> ${(r.endpoint.linkedTo || []).join(', ')}`)
436
+ .join('\n');
437
+ throw new Error(`[deployment-units] Endpoints declared in "${makeRelativePath(group.filePath, serviceRoot)}" ` +
438
+ `resolve to different deployment units:\n${declarations}\n` +
439
+ 'A declaring file is one deployment artifact, so it can only belong to one unit. ' +
440
+ 'Split the file so each unit\'s routes live in their own file.');
441
+ }
442
+ // `groupNodeKey` and not the endpoint key: a file that already owns an
443
+ // artifact has no endpoint node, and its `linkedTo` is a co-location claim
444
+ // made by the file — so it is that artifact which joins the target's unit.
445
+ const key = groupNodeKey(group);
446
+ for (const target of group.linkedTo) {
447
+ const resolvedKey = resolveEndpointTarget(target);
448
+ if (resolvedKey)
449
+ uf.union(key, resolvedKey);
450
+ }
451
+ }
452
+ // -----------------------------------------------------------------------
453
+ // 3. COMPUTE connected components
454
+ // -----------------------------------------------------------------------
455
+ const components = uf.getComponents();
456
+ // -----------------------------------------------------------------------
457
+ // 4. CLASSIFY MDUs and build units
458
+ // -----------------------------------------------------------------------
459
+ const units = {};
460
+ const merges = [];
461
+ const componentInfos = [];
462
+ for (const [, memberNames] of components) {
463
+ const componentNodes = memberNames
464
+ .map(n => nodes.get(n))
465
+ .sort((a, b) => a.name.localeCompare(b.name));
466
+ const hasCommandHandler = componentNodes.some(n => n.type === 'aggregate' || n.type === 'externalSystem');
467
+ const hasOnlyReadmodel = componentNodes.length === 1 && componentNodes[0].type === 'readmodel';
468
+ // Already sorted by name, so `[0]` is the alphabetically first readmodel —
469
+ // the same tie-break `hasCommandHandler` uses to pick among aggregates.
470
+ const readmodelNodes = componentNodes.filter(n => n.type === 'readmodel');
471
+ const isStandalonePolicy = componentNodes.length === 1 && componentNodes[0].type === 'policy' && componentNodes[0].isStandalone;
472
+ const hasOnlyEndpoints = componentNodes.every(n => n.type === 'endpoint');
473
+ let unitType;
474
+ let primaryNode;
475
+ if (hasOnlyReadmodel) {
476
+ unitType = 'readmodel';
477
+ primaryNode = componentNodes[0];
478
+ }
479
+ else if (hasCommandHandler) {
480
+ unitType = 'command-group';
481
+ // Primary is the first aggregate/system alphabetically
482
+ primaryNode = componentNodes.find(n => n.type === 'aggregate' || n.type === 'externalSystem');
483
+ }
484
+ else if (isStandalonePolicy) {
485
+ // Standalone policies become their own MDU as command-group (no aggregate)
486
+ unitType = 'command-group';
487
+ primaryNode = componentNodes[0];
488
+ }
489
+ else if (hasOnlyEndpoints) {
490
+ // A module's undeclared routes. Typed like the standalone policy beside
491
+ // it — a unit with no command handler that must still be liftable and
492
+ // routable — and deliberately NOT `readmodel`: nothing here projects an
493
+ // event, and teselly's topology generator reads this label when it
494
+ // decides what a module wildcard expands to.
495
+ unitType = 'command-group';
496
+ primaryNode = componentNodes[0];
497
+ }
498
+ else if (readmodelNodes.length > 0) {
499
+ // A query pod with routes pinned to it. It stays the READMODEL's unit —
500
+ // `<module>:<Readmodel>` is the id a topology intent already names and
501
+ // `--lift` already selects, and letting the fallthrough pick the
502
+ // alphabetically-first member instead renames that unit after whichever
503
+ // endpoint joined it (`register*` sorts before most readmodel names). A
504
+ // pinned route must not be able to rename the pod it asks to live in.
505
+ unitType = 'readmodel';
506
+ primaryNode = readmodelNodes[0];
507
+ }
508
+ else {
509
+ // Readmodel that ended up grouped (shouldn't happen, but handle gracefully)
510
+ unitType = 'readmodel';
511
+ primaryNode = componentNodes[0];
512
+ }
513
+ const primaryModule = primaryNode.module;
514
+ // `<module>:Endpoints` — stable across a rename of any file in it, unlike
515
+ // the first endpoint's name the fallthrough would otherwise pick.
516
+ const unitKey = hasOnlyEndpoints
517
+ ? `${primaryModule}:Endpoints`
518
+ : `${primaryModule}:${primaryNode.name}`;
519
+ // Build artifact entries
520
+ const artifacts = componentNodes.map(node => {
521
+ const entry = {
522
+ name: node.name,
523
+ type: node.type,
524
+ filePath: makeRelativePath(node.filePath, serviceRoot),
525
+ exportName: deriveExportName(node.name, node.type)
526
+ };
527
+ // For policies/endpoints, record what they link to
528
+ if (node.type === 'policy') {
529
+ const targets = [
530
+ ...(node.commandHandlerName ? [node.commandHandlerName] : []),
531
+ ...(node.linkedTo || [])
532
+ ].filter((v, i, a) => a.indexOf(v) === i).sort();
533
+ if (targets.length > 0) {
534
+ entry.linkedTo = targets;
535
+ }
536
+ }
537
+ if (node.type === 'endpoint' && node.linkedTo && node.linkedTo.length > 0) {
538
+ entry.linkedTo = [...node.linkedTo].sort();
539
+ }
540
+ // Any artifact that manually registers routes, not just endpoint ones: a
541
+ // readmodel file that registers its own routes carries them here, because
542
+ // it is the artifact the loader brings up and therefore the one whose pod
543
+ // serves them.
544
+ //
545
+ // Sorted: `.deployment-units.json` is committed and drift-watched, so a
546
+ // list in declaration order reorders whenever a registration moves and
547
+ // dirties the tree for nothing.
548
+ if (node.routes && node.routes.length > 0) {
549
+ entry.routes = [...node.routes].sort();
550
+ }
551
+ return entry;
552
+ });
553
+ // Sort artifacts: by type priority then by name for determinism
554
+ const typePriority = {
555
+ aggregate: 0,
556
+ externalSystem: 1,
557
+ policy: 2,
558
+ endpoint: 3,
559
+ readmodel: 4
560
+ };
561
+ artifacts.sort((a, b) => {
562
+ const typeDiff = (typePriority[a.type] ?? 99) - (typePriority[b.type] ?? 99);
563
+ if (typeDiff !== 0)
564
+ return typeDiff;
565
+ return a.name.localeCompare(b.name);
566
+ });
567
+ // Collect consumed events (informational)
568
+ const consumes = [];
569
+ for (const node of componentNodes) {
570
+ if (node.events) {
571
+ for (const event of node.events) {
572
+ if (!consumes.includes(event)) {
573
+ consumes.push(event);
574
+ }
575
+ }
576
+ }
577
+ }
578
+ consumes.sort();
579
+ const unit = {
580
+ type: unitType,
581
+ module: primaryModule,
582
+ artifacts
583
+ };
584
+ if (consumes.length > 0) {
585
+ unit.consumes = consumes;
586
+ }
587
+ units[unitKey] = unit;
588
+ componentInfos.push({
589
+ componentNodes,
590
+ unitKey,
591
+ type: unitType
592
+ });
593
+ }
594
+ // -----------------------------------------------------------------------
595
+ // 5. DETECT cross-module merges
596
+ // -----------------------------------------------------------------------
597
+ for (const info of componentInfos) {
598
+ const modules = new Set(info.componentNodes.map(n => n.module));
599
+ if (modules.size <= 1)
600
+ continue;
601
+ // Find which artifact triggered the cross-module merge
602
+ // This is the artifact that has linkedTo pointing to a different module
603
+ const triggers = [];
604
+ for (const node of info.componentNodes) {
605
+ if (node.type === 'policy' || node.type === 'endpoint') {
606
+ const targetRefs = [
607
+ ...(node.commandHandlerName ? [node.commandHandlerName] : []),
608
+ ...(node.linkedTo || [])
609
+ ];
610
+ for (const ref of targetRefs) {
611
+ // Resolved the way the declarer's own edges were: an endpoint's
612
+ // `linkedTo` may name a readmodel, and reading it back through the
613
+ // narrow lookup leaves a merge THAT ENDPOINT CAUSED attributed to
614
+ // `unknown` — the reason line is the only record of who joined two
615
+ // modules.
616
+ const resolvedKey = node.type === 'endpoint'
617
+ ? resolveEndpointTarget(ref)
618
+ : resolveCommandHandler(ref);
619
+ const targetNode = resolvedKey ? nodes.get(resolvedKey) : undefined;
620
+ if (targetNode && targetNode.module !== node.module) {
621
+ triggers.push(node.name);
622
+ break;
623
+ }
624
+ }
625
+ }
626
+ }
627
+ // Determine what individual module units would have existed pre-merge
628
+ const mergedUnitKeys = [];
629
+ for (const mod of [...modules].sort()) {
630
+ const moduleAggregates = info.componentNodes
631
+ .filter(n => n.module === mod && (n.type === 'aggregate' || n.type === 'externalSystem'))
632
+ .sort((a, b) => a.name.localeCompare(b.name));
633
+ if (moduleAggregates.length > 0) {
634
+ mergedUnitKeys.push(`${mod}:${moduleAggregates[0].name}`);
635
+ }
636
+ }
637
+ if (mergedUnitKeys.length > 1) {
638
+ const resultKey = info.unitKey;
639
+ const triggerName = triggers.length > 0 ? triggers.sort()[0] : 'unknown';
640
+ // Find the trigger node by scanning componentNodes (since triggerName is a display name, not a key)
641
+ const triggerNode = info.componentNodes.find(n => n.name === triggerName);
642
+ const reason = triggerNode
643
+ ? `${triggerNode.type} "${triggerName}" links to aggregates in modules: ${[...modules].sort().join(', ')}`
644
+ : `Cross-module dependency between modules: ${[...modules].sort().join(', ')}`;
645
+ merges.push({
646
+ reason,
647
+ trigger: triggerName,
648
+ mergedUnits: mergedUnitKeys.sort(),
649
+ resultUnit: resultKey
650
+ });
651
+ }
652
+ }
653
+ // Sort merges for determinism
654
+ merges.sort((a, b) => a.resultUnit.localeCompare(b.resultUnit));
655
+ // -----------------------------------------------------------------------
656
+ // 6. VALIDATE: every non-standalone policy is in a component with its target
657
+ // -----------------------------------------------------------------------
658
+ for (const [key, node] of nodes) {
659
+ if (node.type !== 'policy')
660
+ continue;
661
+ if (node.isStandalone)
662
+ continue;
663
+ const policyRoot = uf.find(key);
664
+ const targetRefs = [
665
+ ...(node.commandHandlerName ? [node.commandHandlerName] : []),
666
+ ...(node.linkedTo || [])
667
+ ];
668
+ for (const ref of targetRefs) {
669
+ const resolvedKey = resolveCommandHandler(ref);
670
+ if (!resolvedKey)
671
+ continue; // Already reported in earlier validation
672
+ const targetRoot = uf.find(resolvedKey);
673
+ if (policyRoot !== targetRoot) {
674
+ // This should never happen with union-find (union was applied), but guard defensively
675
+ throw new Error(`[deployment-units] Internal error: Policy "${node.name}" is not in the same component as its target "${ref}".`);
676
+ }
677
+ }
678
+ }
679
+ // -----------------------------------------------------------------------
680
+ // Build sorted output
681
+ // -----------------------------------------------------------------------
682
+ const sortedUnits = {};
683
+ for (const key of Object.keys(units).sort()) {
684
+ sortedUnits[key] = units[key];
685
+ }
686
+ return {
687
+ version: '1.0',
688
+ generatedAt: new Date().toISOString(),
689
+ service: serviceName,
690
+ units: sortedUnits,
691
+ merges
692
+ };
693
+ };
694
+ exports.computeMDUs = computeMDUs;
695
+ //# sourceMappingURL=computeMDUs.js.map