@aeolus-fleet/core 0.0.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (610) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +98 -1
  3. package/dist/adapters/cli/fleet-init.d.ts +14 -0
  4. package/dist/adapters/cli/fleet-init.js +68 -0
  5. package/dist/adapters/cli/fleet-init.js.map +1 -0
  6. package/dist/adapters/cli/io.d.ts +35 -0
  7. package/dist/adapters/cli/io.js +21 -0
  8. package/dist/adapters/cli/io.js.map +1 -0
  9. package/dist/adapters/cli/migrate.d.ts +11 -0
  10. package/dist/adapters/cli/migrate.js +12 -0
  11. package/dist/adapters/cli/migrate.js.map +1 -0
  12. package/dist/adapters/cli/operator-reset-password.d.ts +12 -0
  13. package/dist/adapters/cli/operator-reset-password.js +49 -0
  14. package/dist/adapters/cli/operator-reset-password.js.map +1 -0
  15. package/dist/adapters/cli/run.d.ts +14 -0
  16. package/dist/adapters/cli/run.js +40 -0
  17. package/dist/adapters/cli/run.js.map +1 -0
  18. package/dist/adapters/cli/terminal.d.ts +20 -0
  19. package/dist/adapters/cli/terminal.js +68 -0
  20. package/dist/adapters/cli/terminal.js.map +1 -0
  21. package/dist/adapters/crypto/passwords.d.ts +2 -0
  22. package/dist/adapters/crypto/passwords.js +59 -0
  23. package/dist/adapters/crypto/passwords.js.map +1 -0
  24. package/dist/adapters/crypto/secrets.d.ts +5 -0
  25. package/dist/adapters/crypto/secrets.js +10 -0
  26. package/dist/adapters/crypto/secrets.js.map +1 -0
  27. package/dist/adapters/http/device-label.d.ts +9 -0
  28. package/dist/adapters/http/device-label.js +39 -0
  29. package/dist/adapters/http/device-label.js.map +1 -0
  30. package/dist/adapters/http/rate-limiter.d.ts +21 -0
  31. package/dist/adapters/http/rate-limiter.js +44 -0
  32. package/dist/adapters/http/rate-limiter.js.map +1 -0
  33. package/dist/adapters/http/request-credentials.d.ts +23 -0
  34. package/dist/adapters/http/request-credentials.js +45 -0
  35. package/dist/adapters/http/request-credentials.js.map +1 -0
  36. package/dist/adapters/http/server.d.ts +47 -0
  37. package/dist/adapters/http/server.js +216 -0
  38. package/dist/adapters/http/server.js.map +1 -0
  39. package/dist/adapters/http/version.d.ts +9 -0
  40. package/dist/adapters/http/version.js +23 -0
  41. package/dist/adapters/http/version.js.map +1 -0
  42. package/dist/adapters/mcp/mcp-endpoint.d.ts +8 -0
  43. package/dist/adapters/mcp/mcp-endpoint.js +127 -0
  44. package/dist/adapters/mcp/mcp-endpoint.js.map +1 -0
  45. package/dist/adapters/prisma/client.d.ts +10 -0
  46. package/dist/adapters/prisma/client.js +20 -0
  47. package/dist/adapters/prisma/client.js.map +1 -0
  48. package/dist/adapters/prisma/delivery-notices.d.ts +34 -0
  49. package/dist/adapters/prisma/delivery-notices.js +113 -0
  50. package/dist/adapters/prisma/delivery-notices.js.map +1 -0
  51. package/dist/adapters/prisma/event-log.d.ts +11 -0
  52. package/dist/adapters/prisma/event-log.js +61 -0
  53. package/dist/adapters/prisma/event-log.js.map +1 -0
  54. package/dist/adapters/prisma/failure-log.d.ts +22 -0
  55. package/dist/adapters/prisma/failure-log.js +70 -0
  56. package/dist/adapters/prisma/failure-log.js.map +1 -0
  57. package/dist/adapters/prisma/fleet-counter.d.ts +3 -0
  58. package/dist/adapters/prisma/fleet-counter.js +6 -0
  59. package/dist/adapters/prisma/fleet-counter.js.map +1 -0
  60. package/dist/adapters/prisma/fleet-event-wakeups.d.ts +33 -0
  61. package/dist/adapters/prisma/fleet-event-wakeups.js +86 -0
  62. package/dist/adapters/prisma/fleet-event-wakeups.js.map +1 -0
  63. package/dist/adapters/prisma/generated/browser.d.ts +127 -0
  64. package/dist/adapters/prisma/generated/browser.js +18 -0
  65. package/dist/adapters/prisma/generated/browser.js.map +1 -0
  66. package/dist/adapters/prisma/generated/client.d.ts +146 -0
  67. package/dist/adapters/prisma/generated/client.js +38 -0
  68. package/dist/adapters/prisma/generated/client.js.map +1 -0
  69. package/dist/adapters/prisma/generated/commonInputTypes.d.ts +879 -0
  70. package/dist/adapters/prisma/generated/commonInputTypes.js +11 -0
  71. package/dist/adapters/prisma/generated/commonInputTypes.js.map +1 -0
  72. package/dist/adapters/prisma/generated/enums.d.ts +75 -0
  73. package/dist/adapters/prisma/generated/enums.js +73 -0
  74. package/dist/adapters/prisma/generated/enums.js.map +1 -0
  75. package/dist/adapters/prisma/generated/internal/class.d.ts +308 -0
  76. package/dist/adapters/prisma/generated/internal/class.js +52 -0
  77. package/dist/adapters/prisma/generated/internal/class.js.map +1 -0
  78. package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +2131 -0
  79. package/dist/adapters/prisma/generated/internal/prismaNamespace.js +295 -0
  80. package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -0
  81. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +273 -0
  82. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +265 -0
  83. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -0
  84. package/dist/adapters/prisma/generated/models/ConsoleSession.d.ts +2137 -0
  85. package/dist/adapters/prisma/generated/models/ConsoleSession.js +2 -0
  86. package/dist/adapters/prisma/generated/models/ConsoleSession.js.map +1 -0
  87. package/dist/adapters/prisma/generated/models/Credential.d.ts +1360 -0
  88. package/dist/adapters/prisma/generated/models/Credential.js +2 -0
  89. package/dist/adapters/prisma/generated/models/Credential.js.map +1 -0
  90. package/dist/adapters/prisma/generated/models/CrewRequest.d.ts +1558 -0
  91. package/dist/adapters/prisma/generated/models/CrewRequest.js +2 -0
  92. package/dist/adapters/prisma/generated/models/CrewRequest.js.map +1 -0
  93. package/dist/adapters/prisma/generated/models/Delivery.d.ts +2211 -0
  94. package/dist/adapters/prisma/generated/models/Delivery.js +2 -0
  95. package/dist/adapters/prisma/generated/models/Delivery.js.map +1 -0
  96. package/dist/adapters/prisma/generated/models/Event.d.ts +1991 -0
  97. package/dist/adapters/prisma/generated/models/Event.js +2 -0
  98. package/dist/adapters/prisma/generated/models/Event.js.map +1 -0
  99. package/dist/adapters/prisma/generated/models/Fleet.d.ts +3032 -0
  100. package/dist/adapters/prisma/generated/models/Fleet.js +2 -0
  101. package/dist/adapters/prisma/generated/models/Fleet.js.map +1 -0
  102. package/dist/adapters/prisma/generated/models/Guide.d.ts +943 -0
  103. package/dist/adapters/prisma/generated/models/Guide.js +2 -0
  104. package/dist/adapters/prisma/generated/models/Guide.js.map +1 -0
  105. package/dist/adapters/prisma/generated/models/GuideProgress.d.ts +1323 -0
  106. package/dist/adapters/prisma/generated/models/GuideProgress.js +2 -0
  107. package/dist/adapters/prisma/generated/models/GuideProgress.js.map +1 -0
  108. package/dist/adapters/prisma/generated/models/InstallationRequest.d.ts +1036 -0
  109. package/dist/adapters/prisma/generated/models/InstallationRequest.js +2 -0
  110. package/dist/adapters/prisma/generated/models/InstallationRequest.js.map +1 -0
  111. package/dist/adapters/prisma/generated/models/InstallationSettings.d.ts +1027 -0
  112. package/dist/adapters/prisma/generated/models/InstallationSettings.js +2 -0
  113. package/dist/adapters/prisma/generated/models/InstallationSettings.js.map +1 -0
  114. package/dist/adapters/prisma/generated/models/Lease.d.ts +2076 -0
  115. package/dist/adapters/prisma/generated/models/Lease.js +2 -0
  116. package/dist/adapters/prisma/generated/models/Lease.js.map +1 -0
  117. package/dist/adapters/prisma/generated/models/Message.d.ts +2869 -0
  118. package/dist/adapters/prisma/generated/models/Message.js +2 -0
  119. package/dist/adapters/prisma/generated/models/Message.js.map +1 -0
  120. package/dist/adapters/prisma/generated/models/Notice.d.ts +1068 -0
  121. package/dist/adapters/prisma/generated/models/Notice.js +2 -0
  122. package/dist/adapters/prisma/generated/models/Notice.js.map +1 -0
  123. package/dist/adapters/prisma/generated/models/NoticeDismissal.d.ts +1245 -0
  124. package/dist/adapters/prisma/generated/models/NoticeDismissal.js +2 -0
  125. package/dist/adapters/prisma/generated/models/NoticeDismissal.js.map +1 -0
  126. package/dist/adapters/prisma/generated/models/Operator.d.ts +1173 -0
  127. package/dist/adapters/prisma/generated/models/Operator.js +2 -0
  128. package/dist/adapters/prisma/generated/models/Operator.js.map +1 -0
  129. package/dist/adapters/prisma/generated/models/Ship.d.ts +3320 -0
  130. package/dist/adapters/prisma/generated/models/Ship.js +2 -0
  131. package/dist/adapters/prisma/generated/models/Ship.js.map +1 -0
  132. package/dist/adapters/prisma/generated/models/SignInTicket.d.ts +1222 -0
  133. package/dist/adapters/prisma/generated/models/SignInTicket.js +2 -0
  134. package/dist/adapters/prisma/generated/models/SignInTicket.js.map +1 -0
  135. package/dist/adapters/prisma/generated/models.d.ts +18 -0
  136. package/dist/adapters/prisma/generated/models.js +2 -0
  137. package/dist/adapters/prisma/generated/models.js.map +1 -0
  138. package/dist/adapters/prisma/history.d.ts +3 -0
  139. package/dist/adapters/prisma/history.js +289 -0
  140. package/dist/adapters/prisma/history.js.map +1 -0
  141. package/dist/adapters/prisma/identity.d.ts +10 -0
  142. package/dist/adapters/prisma/identity.js +213 -0
  143. package/dist/adapters/prisma/identity.js.map +1 -0
  144. package/dist/adapters/prisma/installation.d.ts +13 -0
  145. package/dist/adapters/prisma/installation.js +155 -0
  146. package/dist/adapters/prisma/installation.js.map +1 -0
  147. package/dist/adapters/prisma/messaging.d.ts +4 -0
  148. package/dist/adapters/prisma/messaging.js +156 -0
  149. package/dist/adapters/prisma/messaging.js.map +1 -0
  150. package/dist/adapters/prisma/migrate.d.ts +5 -0
  151. package/dist/adapters/prisma/migrate.js +40 -0
  152. package/dist/adapters/prisma/migrate.js.map +1 -0
  153. package/dist/adapters/prisma/receiver-wakeups.d.ts +26 -0
  154. package/dist/adapters/prisma/receiver-wakeups.js +79 -0
  155. package/dist/adapters/prisma/receiver-wakeups.js.map +1 -0
  156. package/dist/adapters/prisma/registry.d.ts +8 -0
  157. package/dist/adapters/prisma/registry.js +427 -0
  158. package/dist/adapters/prisma/registry.js.map +1 -0
  159. package/dist/adapters/prisma/rows.d.ts +58 -0
  160. package/dist/adapters/prisma/rows.js +408 -0
  161. package/dist/adapters/prisma/rows.js.map +1 -0
  162. package/dist/adapters/prisma/unit-of-work.d.ts +36 -0
  163. package/dist/adapters/prisma/unit-of-work.js +66 -0
  164. package/dist/adapters/prisma/unit-of-work.js.map +1 -0
  165. package/dist/adapters/rest/openapi.d.ts +12 -0
  166. package/dist/adapters/rest/openapi.js +62 -0
  167. package/dist/adapters/rest/openapi.js.map +1 -0
  168. package/dist/adapters/rest/rest-api.d.ts +8 -0
  169. package/dist/adapters/rest/rest-api.js +61 -0
  170. package/dist/adapters/rest/rest-api.js.map +1 -0
  171. package/dist/adapters/trpc/console.d.ts +150 -0
  172. package/dist/adapters/trpc/console.js +102 -0
  173. package/dist/adapters/trpc/console.js.map +1 -0
  174. package/dist/adapters/trpc/context.d.ts +201 -0
  175. package/dist/adapters/trpc/context.js +2 -0
  176. package/dist/adapters/trpc/context.js.map +1 -0
  177. package/dist/adapters/trpc/fleet.d.ts +637 -0
  178. package/dist/adapters/trpc/fleet.js +437 -0
  179. package/dist/adapters/trpc/fleet.js.map +1 -0
  180. package/dist/adapters/trpc/installation.d.ts +414 -0
  181. package/dist/adapters/trpc/installation.js +138 -0
  182. package/dist/adapters/trpc/installation.js.map +1 -0
  183. package/dist/adapters/trpc/router.d.ts +1263 -0
  184. package/dist/adapters/trpc/router.js +15 -0
  185. package/dist/adapters/trpc/router.js.map +1 -0
  186. package/dist/adapters/trpc/ship-contract.d.ts +107 -0
  187. package/dist/adapters/trpc/ship-contract.js +165 -0
  188. package/dist/adapters/trpc/ship-contract.js.map +1 -0
  189. package/dist/adapters/trpc/ship-protocol.d.ts +9 -0
  190. package/dist/adapters/trpc/ship-protocol.js +25 -0
  191. package/dist/adapters/trpc/ship-protocol.js.map +1 -0
  192. package/dist/adapters/trpc/ship.d.ts +209 -0
  193. package/dist/adapters/trpc/ship.js +214 -0
  194. package/dist/adapters/trpc/ship.js.map +1 -0
  195. package/dist/adapters/trpc/starting-prompt-text.d.ts +7 -0
  196. package/dist/adapters/trpc/starting-prompt-text.js +60 -0
  197. package/dist/adapters/trpc/starting-prompt-text.js.map +1 -0
  198. package/dist/adapters/trpc/system.d.ts +29 -0
  199. package/dist/adapters/trpc/system.js +15 -0
  200. package/dist/adapters/trpc/system.js.map +1 -0
  201. package/dist/adapters/trpc/trpc.d.ts +131 -0
  202. package/dist/adapters/trpc/trpc.js +350 -0
  203. package/dist/adapters/trpc/trpc.js.map +1 -0
  204. package/dist/app.d.ts +31 -0
  205. package/dist/app.js +80 -0
  206. package/dist/app.js.map +1 -0
  207. package/dist/bin/aeolus-core.d.ts +2 -0
  208. package/dist/bin/aeolus-core.js +45 -0
  209. package/dist/bin/aeolus-core.js.map +1 -0
  210. package/dist/config.d.ts +35 -0
  211. package/dist/config.js +74 -0
  212. package/dist/config.js.map +1 -0
  213. package/dist/domain/identity/authenticate.d.ts +46 -0
  214. package/dist/domain/identity/authenticate.js +18 -0
  215. package/dist/domain/identity/authenticate.js.map +1 -0
  216. package/dist/domain/identity/console-session.d.ts +54 -0
  217. package/dist/domain/identity/console-session.js +29 -0
  218. package/dist/domain/identity/console-session.js.map +1 -0
  219. package/dist/domain/identity/credential.d.ts +76 -0
  220. package/dist/domain/identity/credential.js +63 -0
  221. package/dist/domain/identity/credential.js.map +1 -0
  222. package/dist/domain/identity/dismiss-notice.d.ts +19 -0
  223. package/dist/domain/identity/dismiss-notice.js +23 -0
  224. package/dist/domain/identity/dismiss-notice.js.map +1 -0
  225. package/dist/domain/identity/get-guide.d.ts +7 -0
  226. package/dist/domain/identity/get-guide.js +5 -0
  227. package/dist/domain/identity/get-guide.js.map +1 -0
  228. package/dist/domain/identity/get-notices.d.ts +7 -0
  229. package/dist/domain/identity/get-notices.js +5 -0
  230. package/dist/domain/identity/get-notices.js.map +1 -0
  231. package/dist/domain/identity/guide.d.ts +24 -0
  232. package/dist/domain/identity/guide.js +3 -0
  233. package/dist/domain/identity/guide.js.map +1 -0
  234. package/dist/domain/identity/issue-sign-in-ticket.d.ts +38 -0
  235. package/dist/domain/identity/issue-sign-in-ticket.js +39 -0
  236. package/dist/domain/identity/issue-sign-in-ticket.js.map +1 -0
  237. package/dist/domain/identity/notice.d.ts +16 -0
  238. package/dist/domain/identity/notice.js +12 -0
  239. package/dist/domain/identity/notice.js.map +1 -0
  240. package/dist/domain/identity/operator-account.d.ts +28 -0
  241. package/dist/domain/identity/operator-account.js +21 -0
  242. package/dist/domain/identity/operator-account.js.map +1 -0
  243. package/dist/domain/identity/ports.d.ts +193 -0
  244. package/dist/domain/identity/ports.js +2 -0
  245. package/dist/domain/identity/ports.js.map +1 -0
  246. package/dist/domain/identity/public.d.ts +3 -0
  247. package/dist/domain/identity/public.js +5 -0
  248. package/dist/domain/identity/public.js.map +1 -0
  249. package/dist/domain/identity/read-account.d.ts +35 -0
  250. package/dist/domain/identity/read-account.js +27 -0
  251. package/dist/domain/identity/read-account.js.map +1 -0
  252. package/dist/domain/identity/read-guide.d.ts +18 -0
  253. package/dist/domain/identity/read-guide.js +21 -0
  254. package/dist/domain/identity/read-guide.js.map +1 -0
  255. package/dist/domain/identity/read-notices.d.ts +13 -0
  256. package/dist/domain/identity/read-notices.js +17 -0
  257. package/dist/domain/identity/read-notices.js.map +1 -0
  258. package/dist/domain/identity/record-guide-progress.d.ts +19 -0
  259. package/dist/domain/identity/record-guide-progress.js +24 -0
  260. package/dist/domain/identity/record-guide-progress.js.map +1 -0
  261. package/dist/domain/identity/redeem-sign-in-ticket.d.ts +34 -0
  262. package/dist/domain/identity/redeem-sign-in-ticket.js +25 -0
  263. package/dist/domain/identity/redeem-sign-in-ticket.js.map +1 -0
  264. package/dist/domain/identity/reset-operator-password.d.ts +34 -0
  265. package/dist/domain/identity/reset-operator-password.js +55 -0
  266. package/dist/domain/identity/reset-operator-password.js.map +1 -0
  267. package/dist/domain/identity/set-guide.d.ts +13 -0
  268. package/dist/domain/identity/set-guide.js +12 -0
  269. package/dist/domain/identity/set-guide.js.map +1 -0
  270. package/dist/domain/identity/set-notices.d.ts +13 -0
  271. package/dist/domain/identity/set-notices.js +12 -0
  272. package/dist/domain/identity/set-notices.js.map +1 -0
  273. package/dist/domain/identity/set-theme.d.ts +21 -0
  274. package/dist/domain/identity/set-theme.js +19 -0
  275. package/dist/domain/identity/set-theme.js.map +1 -0
  276. package/dist/domain/identity/sign-in-ticket.d.ts +21 -0
  277. package/dist/domain/identity/sign-in-ticket.js +5 -0
  278. package/dist/domain/identity/sign-in-ticket.js.map +1 -0
  279. package/dist/domain/identity/sign-in.d.ts +51 -0
  280. package/dist/domain/identity/sign-in.js +43 -0
  281. package/dist/domain/identity/sign-in.js.map +1 -0
  282. package/dist/domain/identity/sign-out.d.ts +20 -0
  283. package/dist/domain/identity/sign-out.js +32 -0
  284. package/dist/domain/identity/sign-out.js.map +1 -0
  285. package/dist/domain/identity/start-console-session.d.ts +27 -0
  286. package/dist/domain/identity/start-console-session.js +54 -0
  287. package/dist/domain/identity/start-console-session.js.map +1 -0
  288. package/dist/domain/identity/start-viewer-session.d.ts +29 -0
  289. package/dist/domain/identity/start-viewer-session.js +42 -0
  290. package/dist/domain/identity/start-viewer-session.js.map +1 -0
  291. package/dist/domain/messaging/acknowledge-delivery.d.ts +30 -0
  292. package/dist/domain/messaging/acknowledge-delivery.js +31 -0
  293. package/dist/domain/messaging/acknowledge-delivery.js.map +1 -0
  294. package/dist/domain/messaging/answer-ping.d.ts +33 -0
  295. package/dist/domain/messaging/answer-ping.js +37 -0
  296. package/dist/domain/messaging/answer-ping.js.map +1 -0
  297. package/dist/domain/messaging/check-inbox.d.ts +33 -0
  298. package/dist/domain/messaging/check-inbox.js +61 -0
  299. package/dist/domain/messaging/check-inbox.js.map +1 -0
  300. package/dist/domain/messaging/content-type.d.ts +9 -0
  301. package/dist/domain/messaging/content-type.js +18 -0
  302. package/dist/domain/messaging/content-type.js.map +1 -0
  303. package/dist/domain/messaging/daily-message-limit.d.ts +19 -0
  304. package/dist/domain/messaging/daily-message-limit.js +24 -0
  305. package/dist/domain/messaging/daily-message-limit.js.map +1 -0
  306. package/dist/domain/messaging/delivery.d.ts +116 -0
  307. package/dist/domain/messaging/delivery.js +201 -0
  308. package/dist/domain/messaging/delivery.js.map +1 -0
  309. package/dist/domain/messaging/dismiss-delivery.d.ts +28 -0
  310. package/dist/domain/messaging/dismiss-delivery.js +29 -0
  311. package/dist/domain/messaging/dismiss-delivery.js.map +1 -0
  312. package/dist/domain/messaging/inbox-wait.d.ts +8 -0
  313. package/dist/domain/messaging/inbox-wait.js +19 -0
  314. package/dist/domain/messaging/inbox-wait.js.map +1 -0
  315. package/dist/domain/messaging/mark-done.d.ts +45 -0
  316. package/dist/domain/messaging/mark-done.js +49 -0
  317. package/dist/domain/messaging/mark-done.js.map +1 -0
  318. package/dist/domain/messaging/mark-read.d.ts +27 -0
  319. package/dist/domain/messaging/mark-read.js +34 -0
  320. package/dist/domain/messaging/mark-read.js.map +1 -0
  321. package/dist/domain/messaging/message.d.ts +104 -0
  322. package/dist/domain/messaging/message.js +84 -0
  323. package/dist/domain/messaging/message.js.map +1 -0
  324. package/dist/domain/messaging/payload.d.ts +9 -0
  325. package/dist/domain/messaging/payload.js +16 -0
  326. package/dist/domain/messaging/payload.js.map +1 -0
  327. package/dist/domain/messaging/ping-ship.d.ts +38 -0
  328. package/dist/domain/messaging/ping-ship.js +42 -0
  329. package/dist/domain/messaging/ping-ship.js.map +1 -0
  330. package/dist/domain/messaging/ports.d.ts +116 -0
  331. package/dist/domain/messaging/ports.js +2 -0
  332. package/dist/domain/messaging/ports.js.map +1 -0
  333. package/dist/domain/messaging/receive-deliveries.d.ts +68 -0
  334. package/dist/domain/messaging/receive-deliveries.js +119 -0
  335. package/dist/domain/messaging/receive-deliveries.js.map +1 -0
  336. package/dist/domain/messaging/receive-max.d.ts +8 -0
  337. package/dist/domain/messaging/receive-max.js +17 -0
  338. package/dist/domain/messaging/receive-max.js.map +1 -0
  339. package/dist/domain/messaging/reply-to-message.d.ts +35 -0
  340. package/dist/domain/messaging/reply-to-message.js +49 -0
  341. package/dist/domain/messaging/reply-to-message.js.map +1 -0
  342. package/dist/domain/messaging/resend-delivery.d.ts +48 -0
  343. package/dist/domain/messaging/resend-delivery.js +97 -0
  344. package/dist/domain/messaging/resend-delivery.js.map +1 -0
  345. package/dist/domain/messaging/send-message.d.ts +88 -0
  346. package/dist/domain/messaging/send-message.js +115 -0
  347. package/dist/domain/messaging/send-message.js.map +1 -0
  348. package/dist/domain/messaging/send-request.d.ts +16 -0
  349. package/dist/domain/messaging/send-request.js +18 -0
  350. package/dist/domain/messaging/send-request.js.map +1 -0
  351. package/dist/domain/registry/applied-limits.d.ts +15 -0
  352. package/dist/domain/registry/applied-limits.js +15 -0
  353. package/dist/domain/registry/applied-limits.js.map +1 -0
  354. package/dist/domain/registry/assign-crew.d.ts +31 -0
  355. package/dist/domain/registry/assign-crew.js +35 -0
  356. package/dist/domain/registry/assign-crew.js.map +1 -0
  357. package/dist/domain/registry/claim-ship.d.ts +49 -0
  358. package/dist/domain/registry/claim-ship.js +59 -0
  359. package/dist/domain/registry/claim-ship.js.map +1 -0
  360. package/dist/domain/registry/commission-ship.d.ts +54 -0
  361. package/dist/domain/registry/commission-ship.js +70 -0
  362. package/dist/domain/registry/commission-ship.js.map +1 -0
  363. package/dist/domain/registry/confirm-crew-release.d.ts +28 -0
  364. package/dist/domain/registry/confirm-crew-release.js +28 -0
  365. package/dist/domain/registry/confirm-crew-release.js.map +1 -0
  366. package/dist/domain/registry/create-fleet.d.ts +39 -0
  367. package/dist/domain/registry/create-fleet.js +56 -0
  368. package/dist/domain/registry/create-fleet.js.map +1 -0
  369. package/dist/domain/registry/crew-request.d.ts +148 -0
  370. package/dist/domain/registry/crew-request.js +175 -0
  371. package/dist/domain/registry/crew-request.js.map +1 -0
  372. package/dist/domain/registry/delete-fleet.d.ts +46 -0
  373. package/dist/domain/registry/delete-fleet.js +34 -0
  374. package/dist/domain/registry/delete-fleet.js.map +1 -0
  375. package/dist/domain/registry/deregister.d.ts +32 -0
  376. package/dist/domain/registry/deregister.js +38 -0
  377. package/dist/domain/registry/deregister.js.map +1 -0
  378. package/dist/domain/registry/explain-crew-request.d.ts +30 -0
  379. package/dist/domain/registry/explain-crew-request.js +31 -0
  380. package/dist/domain/registry/explain-crew-request.js.map +1 -0
  381. package/dist/domain/registry/fleet.d.ts +12 -0
  382. package/dist/domain/registry/fleet.js +12 -0
  383. package/dist/domain/registry/fleet.js.map +1 -0
  384. package/dist/domain/registry/found-fleet.d.ts +32 -0
  385. package/dist/domain/registry/found-fleet.js +43 -0
  386. package/dist/domain/registry/found-fleet.js.map +1 -0
  387. package/dist/domain/registry/get-fleet-limits.d.ts +17 -0
  388. package/dist/domain/registry/get-fleet-limits.js +14 -0
  389. package/dist/domain/registry/get-fleet-limits.js.map +1 -0
  390. package/dist/domain/registry/get-installation-fleet.d.ts +15 -0
  391. package/dist/domain/registry/get-installation-fleet.js +12 -0
  392. package/dist/domain/registry/get-installation-fleet.js.map +1 -0
  393. package/dist/domain/registry/get-installation-settings.d.ts +7 -0
  394. package/dist/domain/registry/get-installation-settings.js +5 -0
  395. package/dist/domain/registry/get-installation-settings.js.map +1 -0
  396. package/dist/domain/registry/get-ship.d.ts +34 -0
  397. package/dist/domain/registry/get-ship.js +36 -0
  398. package/dist/domain/registry/get-ship.js.map +1 -0
  399. package/dist/domain/registry/get-starting-prompt.d.ts +24 -0
  400. package/dist/domain/registry/get-starting-prompt.js +46 -0
  401. package/dist/domain/registry/get-starting-prompt.js.map +1 -0
  402. package/dist/domain/registry/initialise-fleet.d.ts +28 -0
  403. package/dist/domain/registry/initialise-fleet.js +39 -0
  404. package/dist/domain/registry/initialise-fleet.js.map +1 -0
  405. package/dist/domain/registry/installation-fleet.d.ts +36 -0
  406. package/dist/domain/registry/installation-fleet.js +22 -0
  407. package/dist/domain/registry/installation-fleet.js.map +1 -0
  408. package/dist/domain/registry/installation-request.d.ts +23 -0
  409. package/dist/domain/registry/installation-request.js +5 -0
  410. package/dist/domain/registry/installation-request.js.map +1 -0
  411. package/dist/domain/registry/lease.d.ts +51 -0
  412. package/dist/domain/registry/lease.js +39 -0
  413. package/dist/domain/registry/lease.js.map +1 -0
  414. package/dist/domain/registry/leases.d.ts +66 -0
  415. package/dist/domain/registry/leases.js +80 -0
  416. package/dist/domain/registry/leases.js.map +1 -0
  417. package/dist/domain/registry/limits.d.ts +50 -0
  418. package/dist/domain/registry/limits.js +24 -0
  419. package/dist/domain/registry/limits.js.map +1 -0
  420. package/dist/domain/registry/list-fleet.d.ts +70 -0
  421. package/dist/domain/registry/list-fleet.js +47 -0
  422. package/dist/domain/registry/list-fleet.js.map +1 -0
  423. package/dist/domain/registry/list-fleets.d.ts +11 -0
  424. package/dist/domain/registry/list-fleets.js +9 -0
  425. package/dist/domain/registry/list-fleets.js.map +1 -0
  426. package/dist/domain/registry/list-installation-fleets.d.ts +15 -0
  427. package/dist/domain/registry/list-installation-fleets.js +15 -0
  428. package/dist/domain/registry/list-installation-fleets.js.map +1 -0
  429. package/dist/domain/registry/ping-status.d.ts +17 -0
  430. package/dist/domain/registry/ping-status.js +28 -0
  431. package/dist/domain/registry/ping-status.js.map +1 -0
  432. package/dist/domain/registry/pingable-ship.d.ts +22 -0
  433. package/dist/domain/registry/pingable-ship.js +21 -0
  434. package/dist/domain/registry/pingable-ship.js.map +1 -0
  435. package/dist/domain/registry/ports.d.ts +318 -0
  436. package/dist/domain/registry/ports.js +2 -0
  437. package/dist/domain/registry/ports.js.map +1 -0
  438. package/dist/domain/registry/public.d.ts +8 -0
  439. package/dist/domain/registry/public.js +10 -0
  440. package/dist/domain/registry/public.js.map +1 -0
  441. package/dist/domain/registry/read-assigned-crew-requests.d.ts +14 -0
  442. package/dist/domain/registry/read-assigned-crew-requests.js +15 -0
  443. package/dist/domain/registry/read-assigned-crew-requests.js.map +1 -0
  444. package/dist/domain/registry/recrew-ship.d.ts +33 -0
  445. package/dist/domain/registry/recrew-ship.js +34 -0
  446. package/dist/domain/registry/recrew-ship.js.map +1 -0
  447. package/dist/domain/registry/release-ship.d.ts +38 -0
  448. package/dist/domain/registry/release-ship.js +47 -0
  449. package/dist/domain/registry/release-ship.js.map +1 -0
  450. package/dist/domain/registry/remove-crew-request.d.ts +28 -0
  451. package/dist/domain/registry/remove-crew-request.js +36 -0
  452. package/dist/domain/registry/remove-crew-request.js.map +1 -0
  453. package/dist/domain/registry/rename-ship.d.ts +30 -0
  454. package/dist/domain/registry/rename-ship.js +39 -0
  455. package/dist/domain/registry/rename-ship.js.map +1 -0
  456. package/dist/domain/registry/report-crew-status.d.ts +29 -0
  457. package/dist/domain/registry/report-crew-status.js +30 -0
  458. package/dist/domain/registry/report-crew-status.js.map +1 -0
  459. package/dist/domain/registry/report-details.d.ts +18 -0
  460. package/dist/domain/registry/report-details.js +41 -0
  461. package/dist/domain/registry/report-details.js.map +1 -0
  462. package/dist/domain/registry/report-log.d.ts +21 -0
  463. package/dist/domain/registry/report-log.js +16 -0
  464. package/dist/domain/registry/report-log.js.map +1 -0
  465. package/dist/domain/registry/report.d.ts +30 -0
  466. package/dist/domain/registry/report.js +30 -0
  467. package/dist/domain/registry/report.js.map +1 -0
  468. package/dist/domain/registry/request-crew.d.ts +32 -0
  469. package/dist/domain/registry/request-crew.js +29 -0
  470. package/dist/domain/registry/request-crew.js.map +1 -0
  471. package/dist/domain/registry/resolve-selector.d.ts +25 -0
  472. package/dist/domain/registry/resolve-selector.js +32 -0
  473. package/dist/domain/registry/resolve-selector.js.map +1 -0
  474. package/dist/domain/registry/retire-ship.d.ts +42 -0
  475. package/dist/domain/registry/retire-ship.js +68 -0
  476. package/dist/domain/registry/retire-ship.js.map +1 -0
  477. package/dist/domain/registry/set-fleet-limits.d.ts +30 -0
  478. package/dist/domain/registry/set-fleet-limits.js +54 -0
  479. package/dist/domain/registry/set-fleet-limits.js.map +1 -0
  480. package/dist/domain/registry/set-installation-settings.d.ts +18 -0
  481. package/dist/domain/registry/set-installation-settings.js +31 -0
  482. package/dist/domain/registry/set-installation-settings.js.map +1 -0
  483. package/dist/domain/registry/ship-handle.d.ts +5 -0
  484. package/dist/domain/registry/ship-handle.js +20 -0
  485. package/dist/domain/registry/ship-handle.js.map +1 -0
  486. package/dist/domain/registry/ship-note.d.ts +7 -0
  487. package/dist/domain/registry/ship-note.js +15 -0
  488. package/dist/domain/registry/ship-note.js.map +1 -0
  489. package/dist/domain/registry/ship-report.d.ts +42 -0
  490. package/dist/domain/registry/ship-report.js +93 -0
  491. package/dist/domain/registry/ship-report.js.map +1 -0
  492. package/dist/domain/registry/ship.d.ts +190 -0
  493. package/dist/domain/registry/ship.js +334 -0
  494. package/dist/domain/registry/ship.js.map +1 -0
  495. package/dist/domain/registry/ships.d.ts +25 -0
  496. package/dist/domain/registry/ships.js +22 -0
  497. package/dist/domain/registry/ships.js.map +1 -0
  498. package/dist/domain/registry/starting-prompt.d.ts +32 -0
  499. package/dist/domain/registry/starting-prompt.js +22 -0
  500. package/dist/domain/registry/starting-prompt.js.map +1 -0
  501. package/dist/domain/registry/whoami.d.ts +20 -0
  502. package/dist/domain/registry/whoami.js +15 -0
  503. package/dist/domain/registry/whoami.js.map +1 -0
  504. package/dist/domain/shared/caller.d.ts +25 -0
  505. package/dist/domain/shared/caller.js +8 -0
  506. package/dist/domain/shared/caller.js.map +1 -0
  507. package/dist/domain/shared/clock.d.ts +4 -0
  508. package/dist/domain/shared/clock.js +2 -0
  509. package/dist/domain/shared/clock.js.map +1 -0
  510. package/dist/domain/shared/errors.d.ts +13 -0
  511. package/dist/domain/shared/errors.js +6 -0
  512. package/dist/domain/shared/errors.js.map +1 -0
  513. package/dist/domain/shared/events.d.ts +75 -0
  514. package/dist/domain/shared/events.js +9 -0
  515. package/dist/domain/shared/events.js.map +1 -0
  516. package/dist/domain/shared/follow-fleet.d.ts +32 -0
  517. package/dist/domain/shared/follow-fleet.js +65 -0
  518. package/dist/domain/shared/follow-fleet.js.map +1 -0
  519. package/dist/domain/shared/history.d.ts +124 -0
  520. package/dist/domain/shared/history.js +16 -0
  521. package/dist/domain/shared/history.js.map +1 -0
  522. package/dist/domain/shared/idempotency-key.d.ts +8 -0
  523. package/dist/domain/shared/idempotency-key.js +14 -0
  524. package/dist/domain/shared/idempotency-key.js.map +1 -0
  525. package/dist/domain/shared/notifier.d.ts +17 -0
  526. package/dist/domain/shared/notifier.js +2 -0
  527. package/dist/domain/shared/notifier.js.map +1 -0
  528. package/dist/domain/shared/ping.d.ts +18 -0
  529. package/dist/domain/shared/ping.js +8 -0
  530. package/dist/domain/shared/ping.js.map +1 -0
  531. package/dist/domain/shared/read-fleet-events.d.ts +29 -0
  532. package/dist/domain/shared/read-fleet-events.js +25 -0
  533. package/dist/domain/shared/read-fleet-events.js.map +1 -0
  534. package/dist/domain/shared/read-fleet-limits.d.ts +39 -0
  535. package/dist/domain/shared/read-fleet-limits.js +24 -0
  536. package/dist/domain/shared/read-fleet-limits.js.map +1 -0
  537. package/dist/domain/shared/read-inbox.d.ts +20 -0
  538. package/dist/domain/shared/read-inbox.js +16 -0
  539. package/dist/domain/shared/read-inbox.js.map +1 -0
  540. package/dist/domain/shared/read-message.d.ts +21 -0
  541. package/dist/domain/shared/read-message.js +18 -0
  542. package/dist/domain/shared/read-message.js.map +1 -0
  543. package/dist/domain/shared/read-needs-attention.d.ts +12 -0
  544. package/dist/domain/shared/read-needs-attention.js +10 -0
  545. package/dist/domain/shared/read-needs-attention.js.map +1 -0
  546. package/dist/domain/shared/read-ship-messages.d.ts +28 -0
  547. package/dist/domain/shared/read-ship-messages.js +30 -0
  548. package/dist/domain/shared/read-ship-messages.js.map +1 -0
  549. package/dist/domain/shared/read-ship-timeline.d.ts +18 -0
  550. package/dist/domain/shared/read-ship-timeline.js +16 -0
  551. package/dist/domain/shared/read-ship-timeline.js.map +1 -0
  552. package/dist/domain/shared/result.d.ts +16 -0
  553. package/dist/domain/shared/result.js +7 -0
  554. package/dist/domain/shared/result.js.map +1 -0
  555. package/dist/domain/shared/secrets.d.ts +26 -0
  556. package/dist/domain/shared/secrets.js +2 -0
  557. package/dist/domain/shared/secrets.js.map +1 -0
  558. package/dist/domain/shared/selector.d.ts +29 -0
  559. package/dist/domain/shared/selector.js +2 -0
  560. package/dist/domain/shared/selector.js.map +1 -0
  561. package/dist/domain/shared/unit-of-work.d.ts +13 -0
  562. package/dist/domain/shared/unit-of-work.js +2 -0
  563. package/dist/domain/shared/unit-of-work.js.map +1 -0
  564. package/dist/domain/shared/utc-day.d.ts +4 -0
  565. package/dist/domain/shared/utc-day.js +9 -0
  566. package/dist/domain/shared/utc-day.js.map +1 -0
  567. package/dist/index.d.ts +1 -0
  568. package/dist/index.js +2 -0
  569. package/dist/index.js.map +1 -0
  570. package/dist/start.d.ts +6 -0
  571. package/dist/start.js +29 -0
  572. package/dist/start.js.map +1 -0
  573. package/dist/wiring.d.ts +158 -0
  574. package/dist/wiring.js +185 -0
  575. package/dist/wiring.js.map +1 -0
  576. package/package.json +58 -3
  577. package/prisma.config.ts +18 -0
  578. package/src/adapters/prisma/migrations/20260929124818_init/migration.sql +201 -0
  579. package/src/adapters/prisma/migrations/20260929160000_fleet_argo_console_session/migration.sql +130 -0
  580. package/src/adapters/prisma/migrations/20260929220017_operator_login/migration.sql +27 -0
  581. package/src/adapters/prisma/migrations/20260930090000_crew_token/migration.sql +5 -0
  582. package/src/adapters/prisma/migrations/20260930120000_send/migration.sql +30 -0
  583. package/src/adapters/prisma/migrations/20260930150000_receive/migration.sql +24 -0
  584. package/src/adapters/prisma/migrations/20261001010000_event_seq/migration.sql +34 -0
  585. package/src/adapters/prisma/migrations/20261001020000_console_session_end_reason/migration.sql +14 -0
  586. package/src/adapters/prisma/migrations/20261001030000_account_theme_session_device/migration.sql +8 -0
  587. package/src/adapters/prisma/migrations/20261001040000_lease_last_seen/migration.sql +2 -0
  588. package/src/adapters/prisma/migrations/20261002190000_lease_report/migration.sql +7 -0
  589. package/src/adapters/prisma/migrations/20261003140000_commission_key/migration.sql +7 -0
  590. package/src/adapters/prisma/migrations/20261003200000_message_model/migration.sql +5 -0
  591. package/src/adapters/prisma/migrations/20261003201000_lease_harness/migration.sql +2 -0
  592. package/src/adapters/prisma/migrations/20261004120000_operator_without_password/migration.sql +2 -0
  593. package/src/adapters/prisma/migrations/20261004121000_installation_requests/migration.sql +21 -0
  594. package/src/adapters/prisma/migrations/20261004122000_events_deleted_with_their_fleet/migration.sql +11 -0
  595. package/src/adapters/prisma/migrations/20261004130000_sign_in_tickets/migration.sql +16 -0
  596. package/src/adapters/prisma/migrations/20261004140000_fleet_limits/migration.sql +6 -0
  597. package/src/adapters/prisma/migrations/20261004141000_installation_settings/migration.sql +12 -0
  598. package/src/adapters/prisma/migrations/20261005090000_viewer_ship/migration.sql +2 -0
  599. package/src/adapters/prisma/migrations/20261005100000_viewer_sessions/migration.sql +20 -0
  600. package/src/adapters/prisma/migrations/20261005110000_notices/migration.sql +37 -0
  601. package/src/adapters/prisma/migrations/20261005120000_guide/migration.sql +34 -0
  602. package/src/adapters/prisma/migrations/20261006100000_fleet_crew_scope/migration.sql +8 -0
  603. package/src/adapters/prisma/migrations/20261006140000_lease_report_details/migration.sql +3 -0
  604. package/src/adapters/prisma/migrations/20261006160000_crew_requests/migration.sql +20 -0
  605. package/src/adapters/prisma/migrations/20261006180000_crew_scopes/migration.sql +9 -0
  606. package/src/adapters/prisma/migrations/20261006190000_crew_assignment/migration.sql +13 -0
  607. package/src/adapters/prisma/migrations/20261006200000_crew_request_reason/migration.sql +3 -0
  608. package/src/adapters/prisma/migrations/20261007020000_broad_crewing_scope_retired/migration.sql +8 -0
  609. package/src/adapters/prisma/migrations/migration_lock.toml +3 -0
  610. package/src/adapters/prisma/schema.prisma +558 -0
@@ -0,0 +1,318 @@
1
+ import type { DeliveryId, DeliveryState, FleetId, LeaseId, MessageId, ShipId } from '@aeolus-fleet/common';
2
+ import type { Recipient } from '../shared/selector.js';
3
+ import type { CrewRequest } from './crew-request.js';
4
+ import type { Fleet } from './fleet.js';
5
+ import type { InstallationRequest } from './installation-request.js';
6
+ import type { FleetLimitSettings, InstallationSettings } from './limits.js';
7
+ import type { Lease, Location } from './lease.js';
8
+ import type { Ship } from './ship.js';
9
+ import type { ShipReport } from './ship-report.js';
10
+ /** The crew a report speaks for: its ship and lease, in its fleet. */
11
+ export interface CrewOfLease {
12
+ fleetId: FleetId;
13
+ shipId: ShipId;
14
+ leaseId: LeaseId;
15
+ }
16
+ /** Outbound port: fleets. The only repository whose reads are not scoped to one fleet. */
17
+ export interface FleetRepository {
18
+ /**
19
+ * Holds the installation-wide initialisation lock until the unit of work
20
+ * ends, so two initialisations never both see an installation without fleets.
21
+ */
22
+ lockInitialisation(): Promise<void>;
23
+ count(): Promise<number>;
24
+ list(): Promise<Fleet[]>;
25
+ create(fleet: Fleet): Promise<void>;
26
+ /** The fleet, locked until the unit of work ends, so two deletes of it never both run. */
27
+ findForUpdate(fleetId: FleetId): Promise<Fleet | undefined>;
28
+ /**
29
+ * Deletes the fleet and every record in it, for good: its ships, leases,
30
+ * secrets, operator account, console sessions and sign-in tickets, messages, deliveries,
31
+ * events, and the installation's record of the request that created it
32
+ * (decision 0020).
33
+ */
34
+ delete(fleetId: FleetId): Promise<void>;
35
+ /** How the fleet's limits are set; undefined when there is no such fleet. */
36
+ limitSettings(fleetId: FleetId): Promise<FleetLimitSettings | undefined>;
37
+ setLimitSettings(fleetId: FleetId, settings: FleetLimitSettings): Promise<void>;
38
+ }
39
+ /** Outbound port: the installation's settings, one set for the whole installation, not scoped to a fleet (decision 0020). */
40
+ export interface InstallationSettingsRepository {
41
+ read(): Promise<InstallationSettings>;
42
+ write(settings: InstallationSettings): Promise<void>;
43
+ }
44
+ /** Outbound port: the installation's requests, by request id; not scoped to a fleet (decision 0020). */
45
+ export interface InstallationRequestRepository {
46
+ /** Holds the lock on this request id until the unit of work ends, so a request and its replay never both run. */
47
+ lock(requestId: string): Promise<void>;
48
+ find(requestId: string): Promise<InstallationRequest | undefined>;
49
+ record(request: InstallationRequest): Promise<void>;
50
+ }
51
+ /** Outbound port: ships, always within one fleet. */
52
+ export interface ShipRepository {
53
+ create(ship: Ship): Promise<void>;
54
+ findOperatorShip(fleetId: FleetId): Promise<Ship | undefined>;
55
+ /** The fleet's viewer ship, when it has one (decision 0022). */
56
+ findViewerShip(fleetId: FleetId): Promise<Ship | undefined>;
57
+ /**
58
+ * Holds the lock on this name in the fleet until the unit of work ends, so
59
+ * two commissions of one name never both find it free.
60
+ */
61
+ lockName(fleetId: FleetId, name: string): Promise<void>;
62
+ /** The ship, read without a lock. */
63
+ find(fleetId: FleetId, shipId: ShipId): Promise<Ship | undefined>;
64
+ /** The ship of the fleet that is not retired and has this name. */
65
+ findActiveByName(fleetId: FleetId, name: string): Promise<Ship | undefined>;
66
+ /**
67
+ * Holds the lock on this commissioning ship's idempotency key until the unit
68
+ * of work ends, so two commissions under one key never both find it unused.
69
+ */
70
+ lockCommissionKey(key: {
71
+ fleetId: FleetId;
72
+ by: ShipId;
73
+ idempotencyKey: string;
74
+ }): Promise<void>;
75
+ /**
76
+ * Holds the fleet's ship-count lock until the unit of work ends, so two
77
+ * commissions at the ship limit never both see room for one more.
78
+ */
79
+ lockShipCount(fleetId: FleetId): Promise<void>;
80
+ /** The fleet's ships that are not retired, argo included. */
81
+ countActive(fleetId: FleetId): Promise<number>;
82
+ /** The ship this commissioning ship commissioned under this idempotency key, retired or not. */
83
+ findByCommissionKey(key: {
84
+ fleetId: FleetId;
85
+ by: ShipId;
86
+ idempotencyKey: string;
87
+ }): Promise<Ship | undefined>;
88
+ /**
89
+ * The ship, locked against a second lock until the unit of work ends: a use
90
+ * case that locks it, such as a new starting prompt, locks it first. Lock
91
+ * order: the ship, then its credential, then console sessions, then leases.
92
+ * Rows that only point at the ship can still be written meanwhile. A claim
93
+ * never locks the ship: it holds the credential, which a prompt holding the
94
+ * ship waits for, so locking the ship there would deadlock.
95
+ */
96
+ findForUpdate(fleetId: FleetId, shipId: ShipId): Promise<Ship | undefined>;
97
+ /**
98
+ * The ship a message is addressed to, held until the unit of work ends
99
+ * against a use case that locks it to change it, such as a retire: that use
100
+ * case waits for the send and then sees its delivery, or the send waits for
101
+ * it and then reads the ship as it left it. Many sends to one ship hold it
102
+ * at once.
103
+ */
104
+ findForShare(fleetId: FleetId, shipId: ShipId): Promise<Ship | undefined>;
105
+ /** The ship of the fleet that is not retired and has this name, held as {@link findForShare} holds it. */
106
+ findActiveByNameForShare(fleetId: FleetId, name: string): Promise<Ship | undefined>;
107
+ /** Whether at least one ship of the fleet with this type is not retired and receives: the viewer ship receives nothing (decision 0022). */
108
+ hasActiveShipOfType(fleetId: FleetId, type: string): Promise<boolean>;
109
+ /** Gives the ship a new name. */
110
+ rename(change: {
111
+ fleetId: FleetId;
112
+ shipId: ShipId;
113
+ name: string;
114
+ }): Promise<void>;
115
+ /** Marks the ship retired at `at`: never claimed or addressed again, its name free. */
116
+ retire(change: {
117
+ fleetId: FleetId;
118
+ shipId: ShipId;
119
+ at: Date;
120
+ }): Promise<void>;
121
+ }
122
+ /** Outbound port: leases, always within one fleet. */
123
+ export interface LeaseRepository {
124
+ /** The ship's open lease, locked until the unit of work ends. */
125
+ findOpenForUpdate(fleetId: FleetId, shipId: ShipId): Promise<Lease | undefined>;
126
+ /**
127
+ * The lease if it is still open, held until the unit of work ends against a
128
+ * use case that ends it, such as a release or a takeover: that one waits for
129
+ * this unit of work, then finds what it wrote. Many units of work hold one
130
+ * lease at once.
131
+ */
132
+ findOpenByIdForShare(fleetId: FleetId, leaseId: LeaseId): Promise<Lease | undefined>;
133
+ /** The ship's open lease, held as {@link findOpenByIdForShare} holds it. */
134
+ findOpenForShare(fleetId: FleetId, shipId: ShipId): Promise<Lease | undefined>;
135
+ open(lease: Lease): Promise<void>;
136
+ /**
137
+ * Marks the lease last seen `at`, as a call by its crew does, keeping a
138
+ * later mark: two overlapping writes never move it back.
139
+ */
140
+ markSeen(seen: {
141
+ fleetId: FleetId;
142
+ leaseId: LeaseId;
143
+ at: Date;
144
+ }): Promise<void>;
145
+ /** The lease's report, the lease locked until the unit of work ends; undefined once it has ended. */
146
+ findReportForUpdate(fleetId: FleetId, leaseId: LeaseId): Promise<{
147
+ report: ShipReport | null;
148
+ } | undefined>;
149
+ saveReport(change: {
150
+ fleetId: FleetId;
151
+ leaseId: LeaseId;
152
+ report: ShipReport;
153
+ }): Promise<void>;
154
+ /**
155
+ * The lease's report and the last report of the lease its ship held before
156
+ * it, the one that ended last; undefined once this lease has ended.
157
+ */
158
+ findReportLog(fleetId: FleetId, leaseId: LeaseId): Promise<{
159
+ report: ShipReport | null;
160
+ previousCrew: ShipReport | null;
161
+ } | undefined>;
162
+ /** Ends the lease if it is still open and returns it; undefined when it had already ended. */
163
+ end(change: {
164
+ fleetId: FleetId;
165
+ leaseId: LeaseId;
166
+ endedAt: Date;
167
+ }): Promise<Lease | undefined>;
168
+ }
169
+ /**
170
+ * Outbound port: crew requests, at most one per ship, always within one
171
+ * fleet. A use case that changes one locks its ship first.
172
+ */
173
+ export interface CrewRequestRepository {
174
+ find(fleetId: FleetId, shipId: ShipId): Promise<CrewRequest | undefined>;
175
+ /** Stores the ship's request, replacing the one it held. */
176
+ save(request: CrewRequest): Promise<void>;
177
+ remove(fleetId: FleetId, shipId: ShipId): Promise<void>;
178
+ /** The requests assigned to this trierarch ship, oldest ship first. */
179
+ listAssignedTo(fleetId: FleetId, trierarchShipId: ShipId): Promise<CrewRequest[]>;
180
+ }
181
+ /** A delivery a lease held in flight, pending again: which one, the message it carries, who it is for and its claims so far. */
182
+ export interface ReturnedDelivery {
183
+ deliveryId: DeliveryId;
184
+ messageId: MessageId;
185
+ /** The ship or the type it is pending for again. */
186
+ recipient: Recipient;
187
+ attempts: number;
188
+ }
189
+ /**
190
+ * Outbound port: the deliveries a lease holds in flight. Registry's need,
191
+ * stated in its own words, so it never reaches into Messaging.
192
+ */
193
+ export interface InFlightDeliveries {
194
+ /**
195
+ * Returns every delivery the lease holds in flight to pending and lists
196
+ * them, oldest first. Only the claim is cleared: the recipient stays, so a
197
+ * delivery to the ship is back in its inbox and one to a type back in that
198
+ * type's queue, and its attempts stay, so the fifth claim still stops it.
199
+ */
200
+ returnToPending(fleetId: FleetId, leaseId: LeaseId): Promise<ReturnedDelivery[]>;
201
+ /**
202
+ * Abandons every delivery pending for the ship itself and lists them,
203
+ * oldest first. Deliveries to its type stay, for the other ships of the
204
+ * type; an undeliverable one stays for the operator.
205
+ */
206
+ abandonPendingTo(fleetId: FleetId, shipId: ShipId): Promise<AbandonedDelivery[]>;
207
+ }
208
+ /** A delivery to a ship that was retired before taking it. */
209
+ export interface AbandonedDelivery {
210
+ deliveryId: DeliveryId;
211
+ messageId: MessageId;
212
+ }
213
+ /** What the fleet listing reads about one ship: the ship, the lease of the session crewing it, and its valid secret. */
214
+ export interface ShipFacts {
215
+ ship: Ship;
216
+ /**
217
+ * Where the session holding the ship's open lease runs, since when, and its
218
+ * last call (its claim until it calls again); null while no session crews it.
219
+ */
220
+ openLease: {
221
+ location: Location;
222
+ harness: string | null;
223
+ startedAt: Date;
224
+ lastSeenAt: Date;
225
+ report: ShipReport | null;
226
+ } | null;
227
+ /** When the ship's valid secret was issued and claimed; null when it holds none. */
228
+ validSecret: {
229
+ issuedAt: Date;
230
+ claimedAt: Date | null;
231
+ } | null;
232
+ /** The ship's crew request; null when it holds none. */
233
+ crewRequest: CrewRequest | null;
234
+ /** The trierarch ship its crew request is assigned to, by id and name; null while unassigned or without a request. */
235
+ crewRequestAssignee: {
236
+ id: ShipId;
237
+ name: string;
238
+ } | null;
239
+ /**
240
+ * The ship that got the starting prompt the open lease claimed with, by id
241
+ * and name: the actor of the ship's last StartingPromptIssued before the
242
+ * lease started. Null while no session crews it, or when no prompt is known.
243
+ */
244
+ crewedBy: {
245
+ id: ShipId;
246
+ name: string;
247
+ } | null;
248
+ /**
249
+ * The newest ping to the ship: when it was sent, its delivery's state, and
250
+ * when pong answered it, if pong did; null before any ping.
251
+ */
252
+ lastPing: {
253
+ sentAt: Date;
254
+ deliveryState: DeliveryState;
255
+ answeredWithPongAt: Date | null;
256
+ } | null;
257
+ /** The last model the ship's sessions stated on a send, and when, resends left out; null before any. */
258
+ lastModel: {
259
+ id: string;
260
+ statedAt: Date;
261
+ } | null;
262
+ /** The viewer ship's: when one of its viewer sessions, which hold no lease, was last used; null before any (decision 0022). */
263
+ lastViewedAt: Date | null;
264
+ /** When the ship's last ended lease ended (a release, deregister or takeover); null before any. */
265
+ lastLeaseEndedAt: Date | null;
266
+ }
267
+ /**
268
+ * Outbound port: every ship of the fleet with its lease and secret, read in one
269
+ * query, oldest ship first. Registry's need for secret dates, stated in its own
270
+ * words, so it never reaches into Identity.
271
+ */
272
+ /** A fleet as the installation sees it (docs/architecture.md, "Installation"). */
273
+ export interface InstallationFleetFacts {
274
+ fleetId: FleetId;
275
+ name: string;
276
+ operatorEmail: string;
277
+ createdAt: Date;
278
+ /** Its ships that are not retired, argo included. */
279
+ shipCount: number;
280
+ /** Every message stored in the fleet at or after the given time, whatever its kind or sender. */
281
+ messagesSince: number;
282
+ /** The time of its newest event of any kind; null before any. */
283
+ lastActivityAt: Date | null;
284
+ /** The UTF-8 bytes of every message payload it ever stored. */
285
+ storage: number;
286
+ /** The messages it stored on each UTC day (YYYY-MM-DD) from the window's first day on; a day without any is left out. */
287
+ messagesPerUtcDay: {
288
+ date: string;
289
+ count: number;
290
+ }[];
291
+ /** How its limits are set. */
292
+ limitSettings: FleetLimitSettings;
293
+ }
294
+ /** What a read of the installation's fleets counts messages over: since a moment, and per UTC day from a first day. */
295
+ export interface InstallationFleetWindow {
296
+ since: Date;
297
+ firstDay: Date;
298
+ }
299
+ /** Outbound port: the fleets read across the installation; reachable only with the installation token. */
300
+ export interface InstallationFleets {
301
+ /** Every fleet, oldest first, counting its messages over the window. */
302
+ list(window: InstallationFleetWindow): Promise<InstallationFleetFacts[]>;
303
+ find(fleetId: FleetId, window: InstallationFleetWindow): Promise<InstallationFleetFacts | undefined>;
304
+ }
305
+ export interface FleetListing {
306
+ ships(fleetId: FleetId): Promise<ShipFacts[]>;
307
+ /** One ship of the fleet, read the same way; undefined when the fleet has no such ship. */
308
+ ship(fleetId: FleetId, shipId: ShipId): Promise<ShipFacts | undefined>;
309
+ /**
310
+ * The ship's deliveries as its page counts them: in flight with it (what a
311
+ * release returns) and its direct ones pending or in flight (what a retire
312
+ * abandons).
313
+ */
314
+ deliveryCounts(fleetId: FleetId, shipId: ShipId): Promise<{
315
+ inFlight: number;
316
+ open: number;
317
+ }>;
318
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../../src/domain/registry/ports.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export { location, refuseEndedLease, type Lease, type LeaseEnded, type LeaseEndReason, type Location } from './lease.js';
2
+ export { endLease, holdLease, takeOverOperatorLease, type HoldLeaseTx, type LeaseTx } from './leases.js';
3
+ export type { InFlightDeliveries, LeaseRepository, ShipRepository } from './ports.js';
4
+ export { findPingableShip, type PingableShipTx, type UnpingableShip } from './pingable-ship.js';
5
+ export { resolveSelector, type ResolveSelectorTx, type UnresolvableSelector } from './resolve-selector.js';
6
+ export { findOperatorShip, findShip, findViewerShip, type FindShipTx, type ShipTx } from './ships.js';
7
+ export { OPERATOR_SHIP_NAME, type Ship } from './ship.js';
8
+ export { appliedLimits, type AppliedLimitsTx } from './applied-limits.js';
@@ -0,0 +1,10 @@
1
+ // Registry's published surface: what other contexts may use. Use cases are not
2
+ // part of it; adapters import them from their own modules.
3
+ export { location, refuseEndedLease } from './lease.js';
4
+ export { endLease, holdLease, takeOverOperatorLease } from './leases.js';
5
+ export { findPingableShip } from './pingable-ship.js';
6
+ export { resolveSelector } from './resolve-selector.js';
7
+ export { findOperatorShip, findShip, findViewerShip } from './ships.js';
8
+ export { OPERATOR_SHIP_NAME } from './ship.js';
9
+ export { appliedLimits } from './applied-limits.js';
10
+ //# sourceMappingURL=public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/registry/public.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAmE,MAAM,YAAY,CAAC;AACzH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,qBAAqB,EAAkC,MAAM,aAAa,CAAC;AAEzG,OAAO,EAAE,gBAAgB,EAA4C,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAqD,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAgC,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAa,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAwB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Caller } from '../shared/caller.js';
2
+ import type { CrewRequest } from './crew-request.js';
3
+ import type { CrewRequestRepository } from './ports.js';
4
+ /** A crew request as its trierarch reads it: which ship, with what settings, and how it stands. */
5
+ export type AssignedCrewRequest = Pick<CrewRequest, 'shipId' | 'settings' | 'settingsVersion' | 'requestedAt' | 'status'>;
6
+ export type ReadAssignedCrewRequests = (caller: Caller) => Promise<AssignedCrewRequest[]>;
7
+ /**
8
+ * Use case: a trierarch reads the crew requests assigned to its ship, oldest
9
+ * ship first: its ships are this query, never a list kept on its ship
10
+ * (decision 0029). Its scope (crew:run) is checked before this runs.
11
+ */
12
+ export declare function createReadAssignedCrewRequests(deps: {
13
+ crewRequests: Pick<CrewRequestRepository, 'listAssignedTo'>;
14
+ }): ReadAssignedCrewRequests;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Use case: a trierarch reads the crew requests assigned to its ship, oldest
3
+ * ship first: its ships are this query, never a list kept on its ship
4
+ * (decision 0029). Its scope (crew:run) is checked before this runs.
5
+ */
6
+ export function createReadAssignedCrewRequests(deps) {
7
+ return async (caller) => (await deps.crewRequests.listAssignedTo(caller.fleetId, caller.shipId)).map(({ shipId, settings, settingsVersion, requestedAt, status }) => ({
8
+ shipId,
9
+ settings,
10
+ settingsVersion,
11
+ requestedAt,
12
+ status,
13
+ }));
14
+ }
15
+ //# sourceMappingURL=read-assigned-crew-requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-assigned-crew-requests.js","sourceRoot":"","sources":["../../../src/domain/registry/read-assigned-crew-requests.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAqE;IAClH,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,CACtB,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3I,MAAM;QACN,QAAQ;QACR,eAAe;QACf,WAAW;QACX,MAAM;KACP,CAAC,CAAC,CAAC;AACR,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { IdGenerator, ShipId } from '@aeolus-fleet/common';
2
+ import { type SecretTools } from '../identity/public.js';
3
+ import type { Caller } from '../shared/caller.js';
4
+ import type { Clock } from '../shared/clock.js';
5
+ import { type DomainError } from '../shared/errors.js';
6
+ import { type Result } from '../shared/result.js';
7
+ import type { UnitOfWork } from '../shared/unit-of-work.js';
8
+ import { type LeaseTx } from './leases.js';
9
+ import type { ShipRepository } from './ports.js';
10
+ import type { ReleaseShipTx } from './release-ship.js';
11
+ import { type ReleaseRefusal } from './ship.js';
12
+ import { type IssuedStartingPrompt, type StartingPromptTx } from './starting-prompt.js';
13
+ export type RecrewShipTx = ReleaseShipTx & StartingPromptTx & LeaseTx & {
14
+ ships: ShipRepository;
15
+ };
16
+ export type RecrewShipRefusal = DomainError<'SHIP_NOT_FOUND'> | ReleaseRefusal;
17
+ export type RecrewShip = (caller: Caller, input: {
18
+ shipId: ShipId;
19
+ }) => Promise<Result<IssuedStartingPrompt, RecrewShipRefusal>>;
20
+ /**
21
+ * Use case: a new crew for a crewed ship whose session is gone (Re-crew): a
22
+ * release, then a new starting prompt, in one unit of work. No rule of its
23
+ * own: the session crewing the ship loses it, its crew token and secret stop
24
+ * working, what it held in flight returns to pending, and a new secret is
25
+ * issued, shown once. Never half done: a refusal or a failure leaves the ship crewed as it was. The caller's scope
26
+ * (fleet:manage) is checked before this runs.
27
+ */
28
+ export declare function createRecrewShip(deps: {
29
+ uow: UnitOfWork<RecrewShipTx>;
30
+ clock: Clock;
31
+ ids: IdGenerator;
32
+ secrets: Omit<SecretTools, 'ids'>;
33
+ }): RecrewShip;
@@ -0,0 +1,34 @@
1
+ import { revokeShipSecret } from '../identity/public.js';
2
+ import { refuse } from '../shared/errors.js';
3
+ import { shipActor } from '../shared/events.js';
4
+ import { ok } from '../shared/result.js';
5
+ import { endLease } from './leases.js';
6
+ import { checkCanRelease } from './ship.js';
7
+ import { issueStartingPrompt } from './starting-prompt.js';
8
+ /**
9
+ * Use case: a new crew for a crewed ship whose session is gone (Re-crew): a
10
+ * release, then a new starting prompt, in one unit of work. No rule of its
11
+ * own: the session crewing the ship loses it, its crew token and secret stop
12
+ * working, what it held in flight returns to pending, and a new secret is
13
+ * issued, shown once. Never half done: a refusal or a failure leaves the ship crewed as it was. The caller's scope
14
+ * (fleet:manage) is checked before this runs.
15
+ */
16
+ export function createRecrewShip(deps) {
17
+ return (caller, { shipId }) => deps.uow.run(async (tx) => {
18
+ const { fleetId } = caller;
19
+ const ship = await tx.ships.findForUpdate(fleetId, shipId);
20
+ if (!ship) {
21
+ return refuse('SHIP_NOT_FOUND', `Ship ${shipId} does not exist`);
22
+ }
23
+ const actor = shipActor(caller.shipId);
24
+ const at = deps.clock.now();
25
+ await revokeShipSecret({ tx, ids: deps.ids }, { fleetId, shipId, actor, at });
26
+ const lease = checkCanRelease(ship, await tx.leases.findOpenForUpdate(fleetId, shipId));
27
+ if (!lease.isOk) {
28
+ return lease;
29
+ }
30
+ await endLease({ tx, ids: deps.ids }, { fleetId, leaseId: lease.value.id, actor, at, reason: 'released' });
31
+ return ok(await issueStartingPrompt({ tx, secrets: { ...deps.secrets, ids: deps.ids } }, { fleetId, shipId, actor, at }));
32
+ });
33
+ }
34
+ //# sourceMappingURL=recrew-ship.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recrew-ship.js","sourceRoot":"","sources":["../../../src/domain/registry/recrew-ship.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAG3E,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAuB,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAoD,MAAM,sBAAsB,CAAC;AAW7G;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAKhC;IACC,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAA4D,EAAE;QAClF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,MAAM,CAAC,gBAAgB,EAAE,QAAQ,MAAM,iBAAiB,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAE5B,MAAM,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAC3G,OAAO,EAAE,CACP,MAAM,mBAAmB,CACvB,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EACnD,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { IdGenerator, ShipId } from '@aeolus-fleet/common';
2
+ import { type CredentialTx } from '../identity/public.js';
3
+ import type { Caller } from '../shared/caller.js';
4
+ import type { Clock } from '../shared/clock.js';
5
+ import { type DomainError } from '../shared/errors.js';
6
+ import { type Result } from '../shared/result.js';
7
+ import type { UnitOfWork } from '../shared/unit-of-work.js';
8
+ import { type LeaseTx } from './leases.js';
9
+ import type { CrewRequestRepository, ShipRepository } from './ports.js';
10
+ import { type ReleaseRefusal } from './ship.js';
11
+ export interface ReleaseShipTx extends LeaseTx, CredentialTx {
12
+ ships: ShipRepository;
13
+ crewRequests: Pick<CrewRequestRepository, 'find'>;
14
+ }
15
+ export type ReleaseShipRefusal = DomainError<'SHIP_NOT_FOUND' | 'CREW_REQUEST_NOT_ASSIGNED_TO_CALLER'> | ReleaseRefusal;
16
+ export type ReleaseShip = (caller: Caller, input: {
17
+ shipId: ShipId;
18
+ }) => Promise<Result<undefined, ReleaseShipRefusal>>;
19
+ /**
20
+ * Use case: the caller releases a crewed ship of its fleet (Release): the
21
+ * session crewing it loses it, and the ship awaits a new crew (ADR 0010). In
22
+ * one unit of work: the secret is invalidated, the lease ends and with it the
23
+ * crew token, and the deliveries the lease held in flight return to pending,
24
+ * their attempts kept. The next crew needs a new starting prompt. The caller's
25
+ * scope (fleet:manage or crew:run) is checked before this runs;
26
+ * crew:run reaches only the ships whose crew requests are assigned to the
27
+ * caller's ship.
28
+ *
29
+ * Locks in the fleet's order: the ship, then its secret, then its lease. A
30
+ * receive holding the lease makes the release wait, then the release returns
31
+ * what the receive claimed. The lease is read last, like a new starting
32
+ * prompt reads it, and a refusal rolls the revoked secret back.
33
+ */
34
+ export declare function createReleaseShip(deps: {
35
+ uow: UnitOfWork<ReleaseShipTx>;
36
+ clock: Clock;
37
+ ids: IdGenerator;
38
+ }): ReleaseShip;
@@ -0,0 +1,47 @@
1
+ import { revokeShipSecret } from '../identity/public.js';
2
+ import { refuse } from '../shared/errors.js';
3
+ import { shipActor } from '../shared/events.js';
4
+ import { ok } from '../shared/result.js';
5
+ import { endLease } from './leases.js';
6
+ import { checkReaches } from './crew-request.js';
7
+ import { checkCanRelease } from './ship.js';
8
+ /** The scopes that release every ship; crew:run releases only the ships assigned to the caller's ship. */
9
+ const RELEASE_SCOPES = ['fleet:manage'];
10
+ /**
11
+ * Use case: the caller releases a crewed ship of its fleet (Release): the
12
+ * session crewing it loses it, and the ship awaits a new crew (ADR 0010). In
13
+ * one unit of work: the secret is invalidated, the lease ends and with it the
14
+ * crew token, and the deliveries the lease held in flight return to pending,
15
+ * their attempts kept. The next crew needs a new starting prompt. The caller's
16
+ * scope (fleet:manage or crew:run) is checked before this runs;
17
+ * crew:run reaches only the ships whose crew requests are assigned to the
18
+ * caller's ship.
19
+ *
20
+ * Locks in the fleet's order: the ship, then its secret, then its lease. A
21
+ * receive holding the lease makes the release wait, then the release returns
22
+ * what the receive claimed. The lease is read last, like a new starting
23
+ * prompt reads it, and a refusal rolls the revoked secret back.
24
+ */
25
+ export function createReleaseShip(deps) {
26
+ return (caller, { shipId }) => deps.uow.run(async (tx) => {
27
+ const { fleetId } = caller;
28
+ const ship = await tx.ships.findForUpdate(fleetId, shipId);
29
+ if (!ship) {
30
+ return refuse('SHIP_NOT_FOUND', `Ship ${shipId} does not exist`);
31
+ }
32
+ const reaches = checkReaches(caller, { ship, current: await tx.crewRequests.find(fleetId, shipId), broadScopes: RELEASE_SCOPES });
33
+ if (!reaches.isOk) {
34
+ return reaches;
35
+ }
36
+ const actor = shipActor(caller.shipId);
37
+ const at = deps.clock.now();
38
+ await revokeShipSecret({ tx, ids: deps.ids }, { fleetId, shipId, actor, at });
39
+ const lease = checkCanRelease(ship, await tx.leases.findOpenForUpdate(fleetId, shipId));
40
+ if (!lease.isOk) {
41
+ return lease;
42
+ }
43
+ await endLease({ tx, ids: deps.ids }, { fleetId, leaseId: lease.value.id, actor, at, reason: 'released' });
44
+ return ok(undefined);
45
+ });
46
+ }
47
+ //# sourceMappingURL=release-ship.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-ship.js","sourceRoot":"","sources":["../../../src/domain/registry/release-ship.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAuB,MAAM,WAAW,CAAC;AASjE,0GAA0G;AAC1G,MAAM,cAAc,GAAG,CAAC,cAAc,CAAU,CAAC;AAOjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAIjC;IACC,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAkD,EAAE;QACxE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,MAAM,CAAC,gBAAgB,EAAE,QAAQ,MAAM,iBAAiB,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;QAClI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAE5B,MAAM,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACxF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAC3G,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { IdGenerator, ShipId } from '@aeolus-fleet/common';
2
+ import type { Caller } from '../shared/caller.js';
3
+ import type { Clock } from '../shared/clock.js';
4
+ import { type DomainError } from '../shared/errors.js';
5
+ import { type EventLog } from '../shared/events.js';
6
+ import { type Result } from '../shared/result.js';
7
+ import type { UnitOfWork } from '../shared/unit-of-work.js';
8
+ import type { CrewRequestRepository, ShipRepository } from './ports.js';
9
+ export interface RemoveCrewRequestTx {
10
+ ships: Pick<ShipRepository, 'findForUpdate'>;
11
+ crewRequests: CrewRequestRepository;
12
+ events: EventLog;
13
+ }
14
+ export type RemoveCrewRequest = (caller: Caller, input: {
15
+ shipId: ShipId;
16
+ }) => Promise<Result<undefined, DomainError<'SHIP_NOT_FOUND' | 'CREW_REQUEST_NOT_FOUND'>>>;
17
+ /**
18
+ * Use case: a requester removes a ship's crew request. Its scope
19
+ * (fleet:manage) is checked before this runs. In one unit of work, locking the
20
+ * ship first: an unassigned request goes, with CrewRequestRemoved; an
21
+ * assigned one is marked releasing, for its trierarch to release the ship and
22
+ * confirm. A crew aboard without a trierarch stays aboard.
23
+ */
24
+ export declare function createRemoveCrewRequest(deps: {
25
+ uow: UnitOfWork<RemoveCrewRequestTx>;
26
+ clock: Clock;
27
+ ids: IdGenerator;
28
+ }): RemoveCrewRequest;
@@ -0,0 +1,36 @@
1
+ import { refuse } from '../shared/errors.js';
2
+ import { recordEvent, shipActor } from '../shared/events.js';
3
+ import { ok } from '../shared/result.js';
4
+ import { removeCrewRequest } from './crew-request.js';
5
+ /**
6
+ * Use case: a requester removes a ship's crew request. Its scope
7
+ * (fleet:manage) is checked before this runs. In one unit of work, locking the
8
+ * ship first: an unassigned request goes, with CrewRequestRemoved; an
9
+ * assigned one is marked releasing, for its trierarch to release the ship and
10
+ * confirm. A crew aboard without a trierarch stays aboard.
11
+ */
12
+ export function createRemoveCrewRequest(deps) {
13
+ return (caller, input) => deps.uow.run(async (tx) => {
14
+ const ship = await tx.ships.findForUpdate(caller.fleetId, input.shipId);
15
+ if (!ship) {
16
+ return refuse('SHIP_NOT_FOUND', `Ship ${input.shipId} does not exist`);
17
+ }
18
+ const current = await tx.crewRequests.find(caller.fleetId, ship.id);
19
+ const removed = removeCrewRequest({ ship, current }, { at: deps.clock.now(), actor: shipActor(caller.shipId) });
20
+ if (!removed.isOk) {
21
+ return removed;
22
+ }
23
+ const { request } = removed.value;
24
+ if (request) {
25
+ await tx.crewRequests.save(request);
26
+ }
27
+ else {
28
+ await tx.crewRequests.remove(caller.fleetId, ship.id);
29
+ }
30
+ for (const event of removed.value.events) {
31
+ await recordEvent({ events: tx.events, ids: deps.ids }, event);
32
+ }
33
+ return ok(undefined);
34
+ });
35
+ }
36
+ //# sourceMappingURL=remove-crew-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-crew-request.js","sourceRoot":"","sources":["../../../src/domain/registry/remove-crew-request.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AActD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAA8E;IACpH,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAwF,EAAE;QAC9G,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,MAAM,CAAC,gBAAgB,EAAE,QAAQ,KAAK,CAAC,MAAM,iBAAiB,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,iBAAiB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChH,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;QAClC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACzC,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}