@aeolus-fleet/core 0.26.1 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/http/request-credentials.d.ts +2 -9
  3. package/dist/adapters/http/request-credentials.js +8 -1
  4. package/dist/adapters/http/request-credentials.js.map +1 -1
  5. package/dist/adapters/http/server.js +2 -1
  6. package/dist/adapters/http/server.js.map +1 -1
  7. package/dist/adapters/mcp/mcp-endpoint.js +11 -1
  8. package/dist/adapters/mcp/mcp-endpoint.js.map +1 -1
  9. package/dist/adapters/prisma/generated/browser.d.ts +14 -0
  10. package/dist/adapters/prisma/generated/client.d.ts +14 -0
  11. package/dist/adapters/prisma/generated/commonInputTypes.d.ts +30 -0
  12. package/dist/adapters/prisma/generated/enums.d.ts +10 -0
  13. package/dist/adapters/prisma/generated/enums.js +10 -1
  14. package/dist/adapters/prisma/generated/enums.js.map +1 -1
  15. package/dist/adapters/prisma/generated/internal/class.d.ts +22 -0
  16. package/dist/adapters/prisma/generated/internal/class.js +4 -4
  17. package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
  18. package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +186 -1
  19. package/dist/adapters/prisma/generated/internal/prismaNamespace.js +27 -2
  20. package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
  21. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +27 -0
  22. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +27 -2
  23. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
  24. package/dist/adapters/prisma/generated/models/Delivery.d.ts +71 -1
  25. package/dist/adapters/prisma/generated/models/Fleet.d.ts +558 -0
  26. package/dist/adapters/prisma/generated/models/Lease.d.ts +172 -1
  27. package/dist/adapters/prisma/generated/models/NetworkSettings.d.ts +185 -21
  28. package/dist/adapters/prisma/generated/models/PluginConnection.d.ts +1180 -0
  29. package/dist/adapters/prisma/generated/models/PluginConnection.js +2 -0
  30. package/dist/adapters/prisma/generated/models/PluginConnection.js.map +1 -0
  31. package/dist/adapters/prisma/generated/models/ReachRefusal.d.ts +71 -1
  32. package/dist/adapters/prisma/generated/models/ScopeNamespace.d.ts +1220 -0
  33. package/dist/adapters/prisma/generated/models/ScopeNamespace.js +2 -0
  34. package/dist/adapters/prisma/generated/models/ScopeNamespace.js.map +1 -0
  35. package/dist/adapters/prisma/generated/models/Ship.d.ts +1269 -51
  36. package/dist/adapters/prisma/generated/models.d.ts +2 -0
  37. package/dist/adapters/prisma/health.js +27 -7
  38. package/dist/adapters/prisma/health.js.map +1 -1
  39. package/dist/adapters/prisma/history.js +18 -72
  40. package/dist/adapters/prisma/history.js.map +1 -1
  41. package/dist/adapters/prisma/messaging.js +31 -35
  42. package/dist/adapters/prisma/messaging.js.map +1 -1
  43. package/dist/adapters/prisma/network.js +45 -15
  44. package/dist/adapters/prisma/network.js.map +1 -1
  45. package/dist/adapters/prisma/overdue.js +4 -3
  46. package/dist/adapters/prisma/overdue.js.map +1 -1
  47. package/dist/adapters/prisma/plugin-connections.d.ts +4 -0
  48. package/dist/adapters/prisma/plugin-connections.js +20 -0
  49. package/dist/adapters/prisma/plugin-connections.js.map +1 -0
  50. package/dist/adapters/prisma/registry.js +68 -13
  51. package/dist/adapters/prisma/registry.js.map +1 -1
  52. package/dist/adapters/prisma/rows.d.ts +3 -0
  53. package/dist/adapters/prisma/rows.js +22 -7
  54. package/dist/adapters/prisma/rows.js.map +1 -1
  55. package/dist/adapters/prisma/scope-namespaces.d.ts +4 -0
  56. package/dist/adapters/prisma/scope-namespaces.js +39 -0
  57. package/dist/adapters/prisma/scope-namespaces.js.map +1 -0
  58. package/dist/adapters/prisma/unit-of-work.d.ts +3 -1
  59. package/dist/adapters/prisma/unit-of-work.js +4 -0
  60. package/dist/adapters/prisma/unit-of-work.js.map +1 -1
  61. package/dist/adapters/rest/rest-api.js +2 -2
  62. package/dist/adapters/rest/rest-api.js.map +1 -1
  63. package/dist/adapters/trpc/console.d.ts +1 -1
  64. package/dist/adapters/trpc/console.js +6 -4
  65. package/dist/adapters/trpc/console.js.map +1 -1
  66. package/dist/adapters/trpc/context.d.ts +28 -4
  67. package/dist/adapters/trpc/fleet.d.ts +243 -90
  68. package/dist/adapters/trpc/fleet.js +146 -57
  69. package/dist/adapters/trpc/fleet.js.map +1 -1
  70. package/dist/adapters/trpc/router.d.ts +366 -86
  71. package/dist/adapters/trpc/ship-contract.js +5 -0
  72. package/dist/adapters/trpc/ship-contract.js.map +1 -1
  73. package/dist/adapters/trpc/ship-protocol.js +7 -5
  74. package/dist/adapters/trpc/ship-protocol.js.map +1 -1
  75. package/dist/adapters/trpc/ship.d.ts +156 -3
  76. package/dist/adapters/trpc/ship.js +89 -8
  77. package/dist/adapters/trpc/ship.js.map +1 -1
  78. package/dist/adapters/trpc/trpc.d.ts +13 -9
  79. package/dist/adapters/trpc/trpc.js +90 -26
  80. package/dist/adapters/trpc/trpc.js.map +1 -1
  81. package/dist/domain/messaging/check-inbox.d.ts +5 -5
  82. package/dist/domain/messaging/check-inbox.js +9 -7
  83. package/dist/domain/messaging/check-inbox.js.map +1 -1
  84. package/dist/domain/messaging/delivery.d.ts +8 -2
  85. package/dist/domain/messaging/delivery.js +14 -9
  86. package/dist/domain/messaging/delivery.js.map +1 -1
  87. package/dist/domain/messaging/dismiss-delivery.d.ts +9 -4
  88. package/dist/domain/messaging/dismiss-delivery.js +26 -19
  89. package/dist/domain/messaging/dismiss-delivery.js.map +1 -1
  90. package/dist/domain/messaging/hand-over-delivery.d.ts +1 -0
  91. package/dist/domain/messaging/hand-over-delivery.js +1 -0
  92. package/dist/domain/messaging/hand-over-delivery.js.map +1 -1
  93. package/dist/domain/messaging/message.d.ts +11 -5
  94. package/dist/domain/messaging/message.js +11 -4
  95. package/dist/domain/messaging/message.js.map +1 -1
  96. package/dist/domain/messaging/overdue.d.ts +2 -0
  97. package/dist/domain/messaging/overdue.js +3 -0
  98. package/dist/domain/messaging/overdue.js.map +1 -1
  99. package/dist/domain/messaging/ping-ship.d.ts +3 -3
  100. package/dist/domain/messaging/ping-ship.js +6 -2
  101. package/dist/domain/messaging/ping-ship.js.map +1 -1
  102. package/dist/domain/messaging/ports.d.ts +11 -3
  103. package/dist/domain/messaging/push-receive-deliveries.d.ts +4 -1
  104. package/dist/domain/messaging/push-receive-deliveries.js +5 -3
  105. package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
  106. package/dist/domain/messaging/receive-deliveries.d.ts +23 -0
  107. package/dist/domain/messaging/receive-deliveries.js +6 -3
  108. package/dist/domain/messaging/receive-deliveries.js.map +1 -1
  109. package/dist/domain/messaging/receive-reply.d.ts +32 -0
  110. package/dist/domain/messaging/receive-reply.js +25 -0
  111. package/dist/domain/messaging/receive-reply.js.map +1 -0
  112. package/dist/domain/messaging/resend-delivery.d.ts +5 -2
  113. package/dist/domain/messaging/resend-delivery.js +8 -4
  114. package/dist/domain/messaging/resend-delivery.js.map +1 -1
  115. package/dist/domain/messaging/send-message.d.ts +9 -2
  116. package/dist/domain/messaging/send-message.js +12 -2
  117. package/dist/domain/messaging/send-message.js.map +1 -1
  118. package/dist/domain/messaging/send-request.d.ts +3 -1
  119. package/dist/domain/messaging/send-request.js +4 -2
  120. package/dist/domain/messaging/send-request.js.map +1 -1
  121. package/dist/domain/registry/assign-label.d.ts +2 -1
  122. package/dist/domain/registry/assign-label.js +3 -2
  123. package/dist/domain/registry/assign-label.js.map +1 -1
  124. package/dist/domain/registry/check-reach.d.ts +69 -6
  125. package/dist/domain/registry/check-reach.js +109 -12
  126. package/dist/domain/registry/check-reach.js.map +1 -1
  127. package/dist/domain/registry/commission-ship.d.ts +21 -8
  128. package/dist/domain/registry/commission-ship.js +55 -10
  129. package/dist/domain/registry/commission-ship.js.map +1 -1
  130. package/dist/domain/registry/connect-plugin.d.ts +30 -0
  131. package/dist/domain/registry/connect-plugin.js +35 -0
  132. package/dist/domain/registry/connect-plugin.js.map +1 -0
  133. package/dist/domain/registry/crew-request.d.ts +1 -1
  134. package/dist/domain/registry/declare-scopes.d.ts +38 -0
  135. package/dist/domain/registry/declare-scopes.js +34 -0
  136. package/dist/domain/registry/declare-scopes.js.map +1 -0
  137. package/dist/domain/registry/declared-network-rules.d.ts +2 -1
  138. package/dist/domain/registry/declared-network-rules.js +11 -5
  139. package/dist/domain/registry/declared-network-rules.js.map +1 -1
  140. package/dist/domain/registry/discover.d.ts +29 -0
  141. package/dist/domain/registry/discover.js +54 -0
  142. package/dist/domain/registry/discover.js.map +1 -0
  143. package/dist/domain/registry/explain-reach.d.ts +13 -12
  144. package/dist/domain/registry/explain-reach.js +35 -12
  145. package/dist/domain/registry/explain-reach.js.map +1 -1
  146. package/dist/domain/registry/get-ship.d.ts +11 -3
  147. package/dist/domain/registry/get-ship.js +8 -2
  148. package/dist/domain/registry/get-ship.js.map +1 -1
  149. package/dist/domain/registry/get-starting-prompt.d.ts +18 -2
  150. package/dist/domain/registry/get-starting-prompt.js +7 -7
  151. package/dist/domain/registry/get-starting-prompt.js.map +1 -1
  152. package/dist/domain/registry/grant-scopes.d.ts +34 -0
  153. package/dist/domain/registry/grant-scopes.js +35 -0
  154. package/dist/domain/registry/grant-scopes.js.map +1 -0
  155. package/dist/domain/registry/label.d.ts +12 -7
  156. package/dist/domain/registry/label.js +21 -4
  157. package/dist/domain/registry/label.js.map +1 -1
  158. package/dist/domain/registry/leases.d.ts +6 -3
  159. package/dist/domain/registry/leases.js +7 -5
  160. package/dist/domain/registry/leases.js.map +1 -1
  161. package/dist/domain/registry/list-fleet.d.ts +19 -6
  162. package/dist/domain/registry/list-fleet.js +18 -3
  163. package/dist/domain/registry/list-fleet.js.map +1 -1
  164. package/dist/domain/registry/list-scopes.d.ts +24 -0
  165. package/dist/domain/registry/list-scopes.js +22 -0
  166. package/dist/domain/registry/list-scopes.js.map +1 -0
  167. package/dist/domain/registry/managed-or-assigned.d.ts +25 -0
  168. package/dist/domain/registry/managed-or-assigned.js +23 -0
  169. package/dist/domain/registry/managed-or-assigned.js.map +1 -0
  170. package/dist/domain/registry/named-namespaces.d.ts +19 -0
  171. package/dist/domain/registry/named-namespaces.js +19 -0
  172. package/dist/domain/registry/named-namespaces.js.map +1 -0
  173. package/dist/domain/registry/network-settings.d.ts +95 -24
  174. package/dist/domain/registry/network-settings.js +146 -46
  175. package/dist/domain/registry/network-settings.js.map +1 -1
  176. package/dist/domain/registry/plugin-connection.d.ts +48 -0
  177. package/dist/domain/registry/plugin-connection.js +35 -0
  178. package/dist/domain/registry/plugin-connection.js.map +1 -0
  179. package/dist/domain/registry/ports.d.ts +75 -1
  180. package/dist/domain/registry/public.d.ts +3 -2
  181. package/dist/domain/registry/public.js +3 -2
  182. package/dist/domain/registry/public.js.map +1 -1
  183. package/dist/domain/registry/reach-refusal.d.ts +12 -4
  184. package/dist/domain/registry/read-assigned-crew-requests.d.ts +12 -3
  185. package/dist/domain/registry/read-assigned-crew-requests.js +8 -8
  186. package/dist/domain/registry/read-assigned-crew-requests.js.map +1 -1
  187. package/dist/domain/registry/read-built-in-rules.d.ts +20 -0
  188. package/dist/domain/registry/read-built-in-rules.js +24 -0
  189. package/dist/domain/registry/read-built-in-rules.js.map +1 -0
  190. package/dist/domain/registry/read-clear-requests.d.ts +5 -3
  191. package/dist/domain/registry/read-clear-requests.js +7 -5
  192. package/dist/domain/registry/read-clear-requests.js.map +1 -1
  193. package/dist/domain/registry/read-network-plugin.d.ts +23 -0
  194. package/dist/domain/registry/read-network-plugin.js +15 -0
  195. package/dist/domain/registry/read-network-plugin.js.map +1 -0
  196. package/dist/domain/registry/read-on-behalf.d.ts +20 -0
  197. package/dist/domain/registry/read-on-behalf.js +31 -0
  198. package/dist/domain/registry/read-on-behalf.js.map +1 -0
  199. package/dist/domain/registry/read-reach.d.ts +64 -0
  200. package/dist/domain/registry/read-reach.js +83 -0
  201. package/dist/domain/registry/read-reach.js.map +1 -0
  202. package/dist/domain/registry/recrew-ship.d.ts +3 -2
  203. package/dist/domain/registry/recrew-ship.js +8 -1
  204. package/dist/domain/registry/recrew-ship.js.map +1 -1
  205. package/dist/domain/registry/release-ship.d.ts +10 -5
  206. package/dist/domain/registry/release-ship.js +11 -8
  207. package/dist/domain/registry/release-ship.js.map +1 -1
  208. package/dist/domain/registry/remove-crew-request.d.ts +4 -3
  209. package/dist/domain/registry/remove-crew-request.js +6 -1
  210. package/dist/domain/registry/remove-crew-request.js.map +1 -1
  211. package/dist/domain/registry/rename-ship.d.ts +7 -5
  212. package/dist/domain/registry/rename-ship.js +9 -3
  213. package/dist/domain/registry/rename-ship.js.map +1 -1
  214. package/dist/domain/registry/request-crew.d.ts +5 -4
  215. package/dist/domain/registry/request-crew.js +6 -1
  216. package/dist/domain/registry/request-crew.js.map +1 -1
  217. package/dist/domain/registry/request-worktree-clear.d.ts +3 -2
  218. package/dist/domain/registry/request-worktree-clear.js +6 -1
  219. package/dist/domain/registry/request-worktree-clear.js.map +1 -1
  220. package/dist/domain/registry/retire-ship.d.ts +17 -7
  221. package/dist/domain/registry/retire-ship.js +48 -5
  222. package/dist/domain/registry/retire-ship.js.map +1 -1
  223. package/dist/domain/registry/scope-grant.d.ts +53 -0
  224. package/dist/domain/registry/scope-grant.js +74 -0
  225. package/dist/domain/registry/scope-grant.js.map +1 -0
  226. package/dist/domain/registry/scope-namespace.d.ts +68 -0
  227. package/dist/domain/registry/scope-namespace.js +82 -0
  228. package/dist/domain/registry/scope-namespace.js.map +1 -0
  229. package/dist/domain/registry/set-built-in-rule.d.ts +28 -0
  230. package/dist/domain/registry/set-built-in-rule.js +33 -0
  231. package/dist/domain/registry/set-built-in-rule.js.map +1 -0
  232. package/dist/domain/registry/set-network-rules.d.ts +3 -3
  233. package/dist/domain/registry/set-network-rules.js +2 -2
  234. package/dist/domain/registry/set-owner.d.ts +30 -0
  235. package/dist/domain/registry/set-owner.js +37 -0
  236. package/dist/domain/registry/set-owner.js.map +1 -0
  237. package/dist/domain/registry/set-statement.d.ts +27 -0
  238. package/dist/domain/registry/set-statement.js +28 -0
  239. package/dist/domain/registry/set-statement.js.map +1 -0
  240. package/dist/domain/registry/ship.d.ts +74 -10
  241. package/dist/domain/registry/ship.js +128 -10
  242. package/dist/domain/registry/ship.js.map +1 -1
  243. package/dist/domain/registry/statement.d.ts +32 -0
  244. package/dist/domain/registry/statement.js +39 -0
  245. package/dist/domain/registry/statement.js.map +1 -0
  246. package/dist/domain/registry/unassign-label.js +1 -1
  247. package/dist/domain/registry/unassign-label.js.map +1 -1
  248. package/dist/domain/registry/whoami.d.ts +5 -1
  249. package/dist/domain/registry/whoami.js +7 -4
  250. package/dist/domain/registry/whoami.js.map +1 -1
  251. package/dist/domain/shared/caller.d.ts +5 -2
  252. package/dist/domain/shared/caller.js.map +1 -1
  253. package/dist/domain/shared/delivery-way.d.ts +9 -5
  254. package/dist/domain/shared/delivery-way.js +17 -5
  255. package/dist/domain/shared/delivery-way.js.map +1 -1
  256. package/dist/domain/shared/errors.d.ts +1 -1
  257. package/dist/domain/shared/errors.js.map +1 -1
  258. package/dist/domain/shared/events-read.d.ts +16 -0
  259. package/dist/domain/shared/events-read.js +15 -0
  260. package/dist/domain/shared/events-read.js.map +1 -0
  261. package/dist/domain/shared/follow-fleet.d.ts +8 -2
  262. package/dist/domain/shared/follow-fleet.js +14 -4
  263. package/dist/domain/shared/follow-fleet.js.map +1 -1
  264. package/dist/domain/shared/health.d.ts +11 -2
  265. package/dist/domain/shared/health.js +11 -3
  266. package/dist/domain/shared/health.js.map +1 -1
  267. package/dist/domain/shared/history.d.ts +11 -42
  268. package/dist/domain/shared/history.js +9 -0
  269. package/dist/domain/shared/history.js.map +1 -1
  270. package/dist/domain/shared/read-fleet-events.d.ts +8 -2
  271. package/dist/domain/shared/read-fleet-events.js +10 -4
  272. package/dist/domain/shared/read-fleet-events.js.map +1 -1
  273. package/dist/domain/shared/read-health.d.ts +5 -1
  274. package/dist/domain/shared/read-health.js +13 -2
  275. package/dist/domain/shared/read-health.js.map +1 -1
  276. package/dist/domain/shared/read-inbox.d.ts +6 -3
  277. package/dist/domain/shared/read-inbox.js +14 -4
  278. package/dist/domain/shared/read-inbox.js.map +1 -1
  279. package/dist/domain/shared/read-message.d.ts +6 -2
  280. package/dist/domain/shared/read-message.js +6 -2
  281. package/dist/domain/shared/read-message.js.map +1 -1
  282. package/dist/domain/shared/read-needs-attention.d.ts +4 -1
  283. package/dist/domain/shared/read-needs-attention.js +8 -3
  284. package/dist/domain/shared/read-needs-attention.js.map +1 -1
  285. package/dist/domain/shared/read-sent-message.d.ts +31 -0
  286. package/dist/domain/shared/read-sent-message.js +28 -0
  287. package/dist/domain/shared/read-sent-message.js.map +1 -0
  288. package/dist/domain/shared/read-ship-messages.d.ts +6 -2
  289. package/dist/domain/shared/read-ship-messages.js +7 -2
  290. package/dist/domain/shared/read-ship-messages.js.map +1 -1
  291. package/dist/domain/shared/read-ship-timeline.d.ts +5 -2
  292. package/dist/domain/shared/read-ship-timeline.js +11 -6
  293. package/dist/domain/shared/read-ship-timeline.js.map +1 -1
  294. package/dist/domain/shared/read-ship-way.d.ts +11 -4
  295. package/dist/domain/shared/read-ship-way.js +9 -2
  296. package/dist/domain/shared/read-ship-way.js.map +1 -1
  297. package/dist/domain/shared/stuck.d.ts +10 -1
  298. package/dist/domain/shared/stuck.js +5 -3
  299. package/dist/domain/shared/stuck.js.map +1 -1
  300. package/dist/testing/container-images.d.ts +14 -0
  301. package/dist/testing/container-images.js +18 -0
  302. package/dist/testing/container-images.js.map +1 -0
  303. package/dist/testing/database.d.ts +14 -0
  304. package/dist/testing/database.js +48 -0
  305. package/dist/testing/database.js.map +1 -0
  306. package/dist/testing/fleet.d.ts +13 -0
  307. package/dist/testing/fleet.js +17 -0
  308. package/dist/testing/fleet.js.map +1 -0
  309. package/dist/testing/index.d.ts +12 -0
  310. package/dist/testing/index.js +12 -0
  311. package/dist/testing/index.js.map +1 -0
  312. package/dist/testing/keys.d.ts +1 -0
  313. package/dist/testing/keys.js +7 -0
  314. package/dist/testing/keys.js.map +1 -0
  315. package/dist/testing/migrate-lock.d.ts +12 -0
  316. package/dist/testing/migrate-lock.js +51 -0
  317. package/dist/testing/migrate-lock.js.map +1 -0
  318. package/dist/testing/migrated-template.d.ts +12 -0
  319. package/dist/testing/migrated-template.js +29 -0
  320. package/dist/testing/migrated-template.js.map +1 -0
  321. package/dist/testing/postgres-container.d.ts +16 -0
  322. package/dist/testing/postgres-container.js +30 -0
  323. package/dist/testing/postgres-container.js.map +1 -0
  324. package/dist/testing/postgres-global-setup.d.ts +15 -0
  325. package/dist/testing/postgres-global-setup.js +20 -0
  326. package/dist/testing/postgres-global-setup.js.map +1 -0
  327. package/dist/testing/prisma-cli.d.ts +5 -0
  328. package/dist/testing/prisma-cli.js +15 -0
  329. package/dist/testing/prisma-cli.js.map +1 -0
  330. package/dist/testing/result.d.ts +5 -0
  331. package/dist/testing/result.js +15 -0
  332. package/dist/testing/result.js.map +1 -0
  333. package/dist/wiring.d.ts +26 -4
  334. package/dist/wiring.js +51 -18
  335. package/dist/wiring.js.map +1 -1
  336. package/package.json +28 -2
  337. package/src/adapters/prisma/migrations/20261018100000_force_scope/migration.sql +8 -0
  338. package/src/adapters/prisma/migrations/20261018110000_forced_delivery/migration.sql +4 -0
  339. package/src/adapters/prisma/migrations/20261018120000_person_and_app_ships/migration.sql +3 -0
  340. package/src/adapters/prisma/migrations/20261018130000_owners/migration.sql +14 -0
  341. package/src/adapters/prisma/migrations/20261018140000_owners_on_reach_refusals/migration.sql +14 -0
  342. package/src/adapters/prisma/migrations/20261018150000_network_verbs/migration.sql +9 -0
  343. package/src/adapters/prisma/migrations/20261018160000_built_in_rules/migration.sql +13 -0
  344. package/src/adapters/prisma/migrations/20261018170000_network_rules_a_list/migration.sql +5 -0
  345. package/src/adapters/prisma/migrations/20261018180000_verb_on_reach_refusals/migration.sql +4 -0
  346. package/src/adapters/prisma/migrations/20261018200000_lease_statements/migration.sql +3 -0
  347. package/src/adapters/prisma/migrations/20261018210000_declare_and_grant_scopes/migration.sql +8 -0
  348. package/src/adapters/prisma/migrations/20261018220000_plugin_scopes/migration.sql +14 -0
  349. package/src/adapters/prisma/migrations/20261018230000_scope_namespaces/migration.sql +20 -0
  350. package/src/adapters/prisma/migrations/20261018240000_trierarch_plugin_crew_run/migration.sql +44 -0
  351. package/src/adapters/prisma/migrations/20261018250000_scope_catalogue/migration.sql +67 -0
  352. package/src/adapters/prisma/migrations/20261019090000_reach_refusal_asked_by/migration.sql +2 -0
  353. package/src/adapters/prisma/migrations/20261019100000_on_behalf_scope/migration.sql +61 -0
  354. package/src/adapters/prisma/migrations/20261019110000_events_fleet_id_occurred_at/migration.sql +2 -0
  355. package/src/adapters/prisma/migrations/20261019130000_plugin_connections/migration.sql +54 -0
  356. package/src/adapters/prisma/migrations/20261019150000_network_plugin_registered_at/migration.sql +23 -0
  357. package/src/adapters/prisma/migrations/20261019160000_lease_waker/migration.sql +4 -0
  358. package/src/adapters/prisma/schema.prisma +81 -7
  359. package/dist/domain/shared/read-no-ship-can-take.d.ts +0 -13
  360. package/dist/domain/shared/read-no-ship-can-take.js +0 -12
  361. package/dist/domain/shared/read-no-ship-can-take.js.map +0 -1
  362. package/dist/domain/shared/read-overdue.d.ts +0 -13
  363. package/dist/domain/shared/read-overdue.js +0 -12
  364. package/dist/domain/shared/read-overdue.js.map +0 -1
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A plugin argo connected (decision 0034): its ship reads every ship of its
3
+ * fleet, whatever the rules, until a release or a retire of the ship ends it.
4
+ * Connecting is argo's act in the console's Connect.
5
+ */
6
+ import type { FleetId, IdGenerator, ShipId } from '@aeolus-fleet/common';
7
+ import { type DomainError } from '../shared/errors.js';
8
+ import { type Actor, type EventLog, type NewEvent } from '../shared/events.js';
9
+ import { type Result } from '../shared/result.js';
10
+ import type { PluginConnectionRepository } from './ports.js';
11
+ import type { Ship } from './ship.js';
12
+ export interface PluginConnection {
13
+ fleetId: FleetId;
14
+ shipId: ShipId;
15
+ connectedAt: Date;
16
+ }
17
+ /** Why a connection ended: its ship was released, or retired. */
18
+ export type PluginDisconnectedWhy = 'released' | 'retired';
19
+ export type ConnectPluginRefusal = DomainError<'NOT_AN_AGENT_SHIP' | 'SHIP_ALREADY_RETIRED'>;
20
+ /**
21
+ * Connects the ship as a plugin, with PluginConnected: an active agent ship,
22
+ * never argo's own or the viewer. A ship connected already changes nothing.
23
+ */
24
+ export declare function connectPlugin(ship: Ship, change: {
25
+ current: PluginConnection | undefined;
26
+ at: Date;
27
+ actor: Actor;
28
+ }): Result<{
29
+ connection: PluginConnection | null;
30
+ events: NewEvent[];
31
+ }, ConnectPluginRefusal>;
32
+ /**
33
+ * Ends the ship's connection, if it holds one, with PluginDisconnected saying
34
+ * why: a release or a retire of its ship. In the caller's unit of work.
35
+ */
36
+ export declare function endPluginConnection(deps: {
37
+ tx: {
38
+ pluginConnections: PluginConnectionRepository;
39
+ events: EventLog;
40
+ };
41
+ ids: IdGenerator;
42
+ }, end: {
43
+ fleetId: FleetId;
44
+ shipId: ShipId;
45
+ why: PluginDisconnectedWhy;
46
+ at: Date;
47
+ actor: Actor;
48
+ }): Promise<void>;
@@ -0,0 +1,35 @@
1
+ import { refuse } from '../shared/errors.js';
2
+ import { recordEvent } from '../shared/events.js';
3
+ import { ok } from '../shared/result.js';
4
+ /**
5
+ * Connects the ship as a plugin, with PluginConnected: an active agent ship,
6
+ * never argo's own or the viewer. A ship connected already changes nothing.
7
+ */
8
+ export function connectPlugin(ship, change) {
9
+ if (ship.kind === 'operator' || ship.kind === 'viewer') {
10
+ return refuse('NOT_AN_AGENT_SHIP', `${ship.name} is argo's own ship or the viewer, never a plugin's`);
11
+ }
12
+ if (ship.retiredAt !== null) {
13
+ return refuse('SHIP_ALREADY_RETIRED', `${ship.name} is retired: a retired ship is never connected`);
14
+ }
15
+ if (change.current) {
16
+ return ok({ connection: null, events: [] });
17
+ }
18
+ return ok({
19
+ connection: { fleetId: ship.fleetId, shipId: ship.id, connectedAt: change.at },
20
+ events: [{ fleetId: ship.fleetId, type: 'PluginConnected', occurredAt: change.at, actor: change.actor, shipId: ship.id, details: {} }],
21
+ });
22
+ }
23
+ /**
24
+ * Ends the ship's connection, if it holds one, with PluginDisconnected saying
25
+ * why: a release or a retire of its ship. In the caller's unit of work.
26
+ */
27
+ export async function endPluginConnection(deps, end) {
28
+ const { fleetId, shipId, why, at, actor } = end;
29
+ if (!(await deps.tx.pluginConnections.find(fleetId, shipId))) {
30
+ return;
31
+ }
32
+ await deps.tx.pluginConnections.disconnect(fleetId, shipId);
33
+ await recordEvent({ events: deps.tx.events, ids: deps.ids }, { fleetId, type: 'PluginDisconnected', occurredAt: at, actor, shipId, details: { why } });
34
+ }
35
+ //# sourceMappingURL=plugin-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-connection.js","sourceRoot":"","sources":["../../../src/domain/registry/plugin-connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAA4C,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAetD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAU,EACV,MAAyE;IAEzE,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,IAAI,qDAAqD,CAAC,CAAC;IACxG,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,sBAAsB,EAAE,GAAG,IAAI,CAAC,IAAI,gDAAgD,CAAC,CAAC;IACtG,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,CAAC;QACR,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE;QAC9E,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;KACvI,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAmG,EACnG,GAA6F;IAE7F,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAChD,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;QAC7D,OAAO;IACT,CAAC;IACD,MAAM,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5D,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACzJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { DeliveryId, DeliveryState, FleetId, LabelId, LabelValueId, LeaseId, MessageId, ShipId } from '@aeolus-fleet/common';
1
+ import type { DeliveryId, DeliveryState, FleetId, LabelId, LabelValueId, LeaseId, LeaseWaker, MessageId, ScopeName, ShipId } from '@aeolus-fleet/common';
2
2
  import type { Recipient } from '../shared/selector.js';
3
3
  import type { ClearRequest } from './clear-request.js';
4
4
  import type { CrewRequest } from './crew-request.js';
@@ -9,9 +9,12 @@ import type { FleetLimitSettings, InstallationSettings } from './limits.js';
9
9
  import type { Lease, Location } from './lease.js';
10
10
  import type { DeclaredNetworkRules } from './declared-network-rules.js';
11
11
  import type { NetworkSettings } from './network-settings.js';
12
+ import type { PluginConnection } from './plugin-connection.js';
12
13
  import type { ReachRefusal } from './reach-refusal.js';
14
+ import type { ScopeNamespace } from './scope-namespace.js';
13
15
  import type { Ship } from './ship.js';
14
16
  import type { ShipReport } from './ship-report.js';
17
+ import type { StatedStatement } from './statement.js';
15
18
  import type { Turn } from './turn.js';
16
19
  /** The crew a report speaks for: its ship and lease, in its fleet. */
17
20
  export interface CrewOfLease {
@@ -112,6 +115,8 @@ export interface ShipRepository {
112
115
  findActiveByNameForShare(fleetId: FleetId, name: string): Promise<Ship | undefined>;
113
116
  /** Whether at least one ship of the fleet with this type is not retired and receives: the viewer ship receives nothing (decision 0022). */
114
117
  hasActiveShipOfType(fleetId: FleetId, type: string): Promise<boolean>;
118
+ /** Every ship of the fleet, retired ones and the viewer ship included. By id. */
119
+ list(fleetId: FleetId): Promise<Ship[]>;
115
120
  /** The fleet's ships that are not retired and receive, argo included, never the viewer ship (decision 0022). By id. */
116
121
  listActive(fleetId: FleetId): Promise<Ship[]>;
117
122
  /** The fleet's ships of the type that may take a type delivery: not retired, never the viewer ship. By id. */
@@ -122,12 +127,49 @@ export interface ShipRepository {
122
127
  shipId: ShipId;
123
128
  name: string;
124
129
  }): Promise<void>;
130
+ /** The active ships the owner owns, each locked as findForUpdate locks it, by id (decision 0045). */
131
+ listActiveOwnedByForUpdate(fleetId: FleetId, ownerShipId: ShipId): Promise<Ship[]>;
132
+ /** Gives the ship a new owner (decision 0045). */
133
+ setOwner(change: {
134
+ fleetId: FleetId;
135
+ shipId: ShipId;
136
+ ownerShipId: ShipId;
137
+ }): Promise<void>;
125
138
  /** Marks the ship retired at `at`: never claimed or addressed again, its name free. */
126
139
  retire(change: {
127
140
  fleetId: FleetId;
128
141
  shipId: ShipId;
129
142
  at: Date;
130
143
  }): Promise<void>;
144
+ /** Gives the ship these scopes, in this order, in place of the ones it held (decision 0046). */
145
+ setScopes(change: {
146
+ fleetId: FleetId;
147
+ shipId: ShipId;
148
+ scopes: readonly ScopeName[];
149
+ }): Promise<void>;
150
+ /** The ships not retired that hold any scope of this plugin namespace, each locked as findForUpdate locks it, by id (decision 0046). */
151
+ listActiveHoldingInForUpdate(fleetId: FleetId, namespace: string): Promise<Ship[]>;
152
+ /** The scopes of this plugin namespace that a ship not retired holds, each once, by name (decision 0046). */
153
+ scopesHeldIn(fleetId: FleetId, namespace: string): Promise<ScopeName[]>;
154
+ }
155
+ /**
156
+ * Outbound port: the plugin namespaces of a fleet (decision 0046), one per
157
+ * declaring ship, unique in the fleet. Lock order: the declaring or granted
158
+ * ship, then the namespace.
159
+ */
160
+ export interface ScopeNamespaceRepository {
161
+ /** Holds the lock on this namespace in the fleet until the unit of work ends: a declaration, and a grant of its scopes, wait for each other. */
162
+ lockNamespace(fleetId: FleetId, namespace: string): Promise<void>;
163
+ /** The namespace, read without a lock. */
164
+ find(fleetId: FleetId, namespace: string): Promise<ScopeNamespace | undefined>;
165
+ /** The namespace this ship declared, if any. */
166
+ findByDeclarer(fleetId: FleetId, shipId: ShipId): Promise<ScopeNamespace | undefined>;
167
+ /** Every plugin namespace of the fleet, by namespace. */
168
+ list(fleetId: FleetId): Promise<ScopeNamespace[]>;
169
+ /** Stores the namespace with its whole list of scopes, replacing the list it had. */
170
+ save(namespace: ScopeNamespace): Promise<void>;
171
+ /** The namespace goes, freed for another ship. */
172
+ remove(fleetId: FleetId, namespace: string): Promise<void>;
131
173
  }
132
174
  /** Outbound port: leases, always within one fleet. */
133
175
  export interface LeaseRepository {
@@ -167,6 +209,20 @@ export interface LeaseRepository {
167
209
  leaseId: LeaseId;
168
210
  report: ShipReport;
169
211
  }): Promise<void>;
212
+ /** The lease's statement, the lease locked until the unit of work ends; undefined once it has ended (decision 0047). */
213
+ findStatementForUpdate(fleetId: FleetId, leaseId: LeaseId): Promise<{
214
+ stated: StatedStatement | null;
215
+ } | undefined>;
216
+ saveStatement(change: {
217
+ fleetId: FleetId;
218
+ leaseId: LeaseId;
219
+ stated: StatedStatement;
220
+ }): Promise<void>;
221
+ /** Every open lease of the fleet by its ship, with the statement it holds, read without a lock: who is crewed now, and what each crew stated. */
222
+ listOpenStatements(fleetId: FleetId): Promise<{
223
+ shipId: ShipId;
224
+ stated: StatedStatement | null;
225
+ }[]>;
170
226
  /** The open lease's turn, locked until the unit of work ends, so two turn reports take turns; undefined once it has ended. */
171
227
  findTurnForUpdate(fleetId: FleetId, leaseId: LeaseId): Promise<{
172
228
  turn: Turn | null;
@@ -194,11 +250,13 @@ export interface LeaseRepository {
194
250
  * Marks the open lease pushed from `at`, keeping an earlier mark, before
195
251
  * anything else of the lease is locked: two marks take turns and never
196
252
  * deadlock with the units of work holding it. True when this call marked it.
253
+ * The waker it states is kept with the first mark only (interop 5.1).
197
254
  */
198
255
  markPushed(pushed: {
199
256
  fleetId: FleetId;
200
257
  leaseId: LeaseId;
201
258
  at: Date;
259
+ waker: LeaseWaker | null;
202
260
  }): Promise<boolean>;
203
261
  /** Whether a push receive marked the lease pushed. */
204
262
  isPushed(fleetId: FleetId, leaseId: LeaseId): Promise<boolean>;
@@ -245,6 +303,8 @@ export interface ClearRequestRepository {
245
303
  export interface NetworkSettingsRepository {
246
304
  /** The fleet's settings, held shared until the unit of work ends; none at version 0 when it never set rules. */
247
305
  findForShare(fleetId: FleetId): Promise<NetworkSettings>;
306
+ /** The fleet's settings as they stand, with no lock: for a call that takes them exclusively later, which a shared hold would deadlock against. */
307
+ find(fleetId: FleetId): Promise<NetworkSettings>;
248
308
  /** The fleet's settings, held exclusively until the unit of work ends, even before the fleet first set rules. */
249
309
  findForUpdate(fleetId: FleetId): Promise<NetworkSettings>;
250
310
  save(settings: NetworkSettings): Promise<void>;
@@ -258,6 +318,15 @@ export interface DeclaredNetworkRulesRepository {
258
318
  /** Keeps the ship's whole list from now on; an empty one keeps none. */
259
319
  save(declared: DeclaredNetworkRules): Promise<void>;
260
320
  }
321
+ /** Outbound port: the plugins argo connected, one per ship, always within one fleet (decision 0034). */
322
+ export interface PluginConnectionRepository {
323
+ /** The ship's connection; none while it is not connected. */
324
+ find(fleetId: FleetId, shipId: ShipId): Promise<PluginConnection | undefined>;
325
+ /** Keeps the connection of a ship that holds none. */
326
+ connect(connection: PluginConnection): Promise<void>;
327
+ /** Ends the ship's connection, if it holds one. */
328
+ disconnect(fleetId: FleetId, shipId: ShipId): Promise<void>;
329
+ }
261
330
  /** Outbound port: the records of the sends the fleet's network rules refused (decision 0034). */
262
331
  export interface ReachRefusalRepository {
263
332
  record(refusal: ReachRefusal): Promise<void>;
@@ -352,6 +421,11 @@ export interface ShipFacts {
352
421
  id: ShipId;
353
422
  name: string;
354
423
  } | null;
424
+ /** The ship's owner by id and name; null for argo and the viewer (decision 0045). */
425
+ owner: {
426
+ id: ShipId;
427
+ name: string;
428
+ } | null;
355
429
  /** The trierarchs that gave its crew request back, by id and name, oldest first (#382); none without a request. */
356
430
  crewRequestGivenBack: {
357
431
  trierarch: {
@@ -2,8 +2,9 @@ export { location, refuseEndedLease, type Lease, type LeaseEnded, type LeaseEndR
2
2
  export { endLease, holdLease, isLeasePushed, markLeasePushed, takeOverOperatorLease, type HoldLeaseTx, type LeaseTx } from './leases.js';
3
3
  export type { FleetRepository, InFlightDeliveries, LeaseRepository, ShipRepository } from './ports.js';
4
4
  export { findPingableShip, type PingableShipTx, type UnpingableShip } from './pingable-ship.js';
5
- export { checkReach, type CheckReachTx, type NotReachable } from './check-reach.js';
5
+ export { checkManage, checkRead, checkReach, keepingReachRefusal, type CheckManageTx, type CheckReachTx, type CheckReadTx, type NotReachable } from './check-reach.js';
6
6
  export { resolveSelector, type ResolveSelectorTx, type UnresolvableSelector } from './resolve-selector.js';
7
7
  export { findOperatorShip, findShip, findViewerShip, type FindShipTx, type ShipTx } from './ships.js';
8
- export { OPERATOR_SHIP_NAME, type Ship } from './ship.js';
8
+ export { isConsoleShip, OPERATOR_SHIP_NAME, type Ship } from './ship.js';
9
9
  export { appliedLimits, type AppliedLimitsTx } from './applied-limits.js';
10
+ export { readsEvent, readsMessage, readsShip, type MessageParties, type ReadReach, type ReadReachOf } from './read-reach.js';
@@ -3,9 +3,10 @@
3
3
  export { location, refuseEndedLease } from './lease.js';
4
4
  export { endLease, holdLease, isLeasePushed, markLeasePushed, takeOverOperatorLease } from './leases.js';
5
5
  export { findPingableShip } from './pingable-ship.js';
6
- export { checkReach } from './check-reach.js';
6
+ export { checkManage, checkRead, checkReach, keepingReachRefusal } from './check-reach.js';
7
7
  export { resolveSelector } from './resolve-selector.js';
8
8
  export { findOperatorShip, findShip, findViewerShip } from './ships.js';
9
- export { OPERATOR_SHIP_NAME } from './ship.js';
9
+ export { isConsoleShip, OPERATOR_SHIP_NAME } from './ship.js';
10
10
  export { appliedLimits } from './applied-limits.js';
11
+ export { readsEvent, readsMessage, readsShip } from './read-reach.js';
11
12
  //# sourceMappingURL=public.js.map
@@ -1 +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,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAkC,MAAM,aAAa,CAAC;AAEzI,OAAO,EAAE,gBAAgB,EAA4C,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAwC,MAAM,kBAAkB,CAAC;AACpF,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"}
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,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAkC,MAAM,aAAa,CAAC;AAEzI,OAAO,EAAE,gBAAgB,EAA4C,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAA8E,MAAM,kBAAkB,CAAC;AACvK,OAAO,EAAE,eAAe,EAAqD,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAgC,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAa,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAwB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAyD,MAAM,iBAAiB,CAAC"}
@@ -1,15 +1,19 @@
1
- import type { FleetId, ReachRefusalId, ShipId, WhileUnavailable } from '@aeolus-fleet/common';
1
+ import type { FleetId, NetworkVerb, ReachRefusalId, ShipId, WhileUnavailable } from '@aeolus-fleet/common';
2
2
  import type { CarriedLabel } from './label.js';
3
- /** A ship as a refusal saw it: its id, its name and the label values it carried then, by key. */
3
+ /** A ship as a refusal saw it: its id, its name, the label values it carried then, by key, and its owner's ship then. */
4
4
  export interface RefusedShip {
5
5
  id: ShipId;
6
6
  name: string;
7
7
  labels: readonly CarriedLabel[];
8
+ owner: {
9
+ id: ShipId;
10
+ name: string;
11
+ } | null;
8
12
  }
9
13
  /**
10
14
  * The record of a send the network rules refused (decision 0034): who tried
11
- * to reach whom, both ships as they were at that moment, so a later rename or
12
- * relabelling keeps it true, and the version of the settings that refused it.
15
+ * to reach whom, both ships as they were at that moment, so a later rename,
16
+ * relabelling or change of owner keeps it true, and the version of the settings that refused it.
13
17
  * Not an event: only argo reads it.
14
18
  */
15
19
  export interface ReachRefusal {
@@ -17,6 +21,8 @@ export interface ReachRefusal {
17
21
  id: ReachRefusalId;
18
22
  at: Date;
19
23
  sender: RefusedShip;
24
+ /** The plugin ship that read on behalf of the sender (decision 0034), as it was then; null for the sender's own call. */
25
+ askedBy: RefusedShip | null;
20
26
  /** The ship it was for, or the type and each ship of it, none of which the sender may reach. */
21
27
  recipient: {
22
28
  kind: 'ship';
@@ -26,6 +32,8 @@ export interface ReachRefusal {
26
32
  type: string;
27
33
  ships: readonly RefusedShip[];
28
34
  };
35
+ /** What the sender tried to do: send, or read for a read refused rather than filtered (decision 0034). */
36
+ verb: NetworkVerb;
29
37
  settingsVersion: number;
30
38
  /** What the networking plugin declared, when it refused while the plugin was not responding (decision 0035); null otherwise. */
31
39
  whilePluginUnavailable: Exclude<WhileUnavailable, 'open-all'> | null;
@@ -1,8 +1,16 @@
1
+ import type { ShipId } from '@aeolus-fleet/common';
1
2
  import type { Caller } from '../shared/caller.js';
2
3
  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, how it stands, and whether its crew is final. */
5
- export type AssignedCrewRequest = Pick<CrewRequest, 'shipId' | 'settings' | 'settingsVersion' | 'requestedAt' | 'status' | 'isFinal'>;
4
+ import type { CrewRequestRepository, ShipRepository } from './ports.js';
5
+ /**
6
+ * A crew request as its trierarch reads it: which ship, with what settings,
7
+ * how it stands, whether its crew is final, and the ship's owner as it is
8
+ * now, by id and name, where its trouble goes (decision 0045).
9
+ */
10
+ export type AssignedCrewRequest = Pick<CrewRequest, 'shipId' | 'settings' | 'settingsVersion' | 'requestedAt' | 'status' | 'isFinal'> & {
11
+ ownerShipId: ShipId | null;
12
+ ownerName: string | null;
13
+ };
6
14
  export type ReadAssignedCrewRequests = (caller: Caller) => Promise<AssignedCrewRequest[]>;
7
15
  /**
8
16
  * Use case: a trierarch reads the crew requests assigned to its ship, oldest
@@ -11,4 +19,5 @@ export type ReadAssignedCrewRequests = (caller: Caller) => Promise<AssignedCrewR
11
19
  */
12
20
  export declare function createReadAssignedCrewRequests(deps: {
13
21
  crewRequests: Pick<CrewRequestRepository, 'listAssignedTo'>;
22
+ ships: Pick<ShipRepository, 'find'>;
14
23
  }): ReadAssignedCrewRequests;
@@ -4,13 +4,13 @@
4
4
  * (decision 0029). Its scope (crew:run) is checked before this runs.
5
5
  */
6
6
  export function createReadAssignedCrewRequests(deps) {
7
- return async (caller) => (await deps.crewRequests.listAssignedTo(caller.fleetId, caller.shipId)).map(({ shipId, settings, settingsVersion, requestedAt, status, isFinal }) => ({
8
- shipId,
9
- settings,
10
- settingsVersion,
11
- requestedAt,
12
- status,
13
- isFinal,
14
- }));
7
+ return async (caller) => {
8
+ const requests = await deps.crewRequests.listAssignedTo(caller.fleetId, caller.shipId);
9
+ return Promise.all(requests.map(async ({ shipId, settings, settingsVersion, requestedAt, status, isFinal }) => {
10
+ const ownerShipId = (await deps.ships.find(caller.fleetId, shipId))?.owner ?? null;
11
+ const owner = ownerShipId === null ? undefined : await deps.ships.find(caller.fleetId, ownerShipId);
12
+ return { shipId, settings, settingsVersion, requestedAt, status, isFinal, ownerShipId: owner?.id ?? null, ownerName: owner?.name ?? null };
13
+ }));
14
+ };
15
15
  }
16
16
  //# sourceMappingURL=read-assigned-crew-requests.js.map
@@ -1 +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,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QACpJ,MAAM;QACN,QAAQ;QACR,eAAe;QACf,WAAW;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC,CAAC;AACR,CAAC"}
1
+ {"version":3,"file":"read-assigned-crew-requests.js","sourceRoot":"","sources":["../../../src/domain/registry/read-assigned-crew-requests.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAA0G;IACvJ,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACvF,OAAO,OAAO,CAAC,GAAG,CAChB,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;YACzF,MAAM,WAAW,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;YACnF,MAAM,KAAK,GAAG,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACpG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,IAAI,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;QAC7I,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type BuiltInRuleState } from '@aeolus-fleet/common';
2
+ import type { Caller } from '../shared/caller.js';
3
+ import { type Result } from '../shared/result.js';
4
+ import type { UnitOfWork } from '../shared/unit-of-work.js';
5
+ import type { NetworkSettingsRepository } from './ports.js';
6
+ export interface ReadBuiltInRulesTx {
7
+ networkSettings: Pick<NetworkSettingsRepository, 'findForShare'>;
8
+ }
9
+ export type ReadBuiltInRules = (caller: Caller) => Promise<Result<BuiltInRuleState[], never>>;
10
+ /**
11
+ * Use case: every built-in rule of the caller's fleet as it is now (decision
12
+ * 0034), in the order the rule list shows them, first: argo, the owner, the
13
+ * answer and a connected plugin's reading, always on; the viewer reading as argo turned it; open per verb
14
+ * as the networking plugin turned it. Its scope (fleet:network, which argo
15
+ * holds) is checked before this runs. Read under the shared settings lock,
16
+ * so it answers one version.
17
+ */
18
+ export declare function createReadBuiltInRules(deps: {
19
+ uow: UnitOfWork<ReadBuiltInRulesTx>;
20
+ }): ReadBuiltInRules;
@@ -0,0 +1,24 @@
1
+ import { NETWORK_VERBS } from '@aeolus-fleet/common';
2
+ import { ok } from '../shared/result.js';
3
+ /**
4
+ * Use case: every built-in rule of the caller's fleet as it is now (decision
5
+ * 0034), in the order the rule list shows them, first: argo, the owner, the
6
+ * answer and a connected plugin's reading, always on; the viewer reading as argo turned it; open per verb
7
+ * as the networking plugin turned it. Its scope (fleet:network, which argo
8
+ * holds) is checked before this runs. Read under the shared settings lock,
9
+ * so it answers one version.
10
+ */
11
+ export function createReadBuiltInRules(deps) {
12
+ return (caller) => deps.uow.run(async (tx) => {
13
+ const { builtIns } = await tx.networkSettings.findForShare(caller.fleetId);
14
+ return ok([
15
+ { rule: 'argo', isOn: true },
16
+ { rule: 'owner', isOn: true },
17
+ { rule: 'answer', isOn: true },
18
+ { rule: 'pluginRead', isOn: true },
19
+ { rule: 'viewerRead', isOn: builtIns.isViewerReadOn },
20
+ ...NETWORK_VERBS.map((verb) => ({ rule: 'open', verb, isOn: builtIns.open[verb] })),
21
+ ]);
22
+ });
23
+ }
24
+ //# sourceMappingURL=read-built-in-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-built-in-rules.js","sourceRoot":"","sources":["../../../src/domain/registry/read-built-in-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAG5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAUtD;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAA6C;IAClF,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAA8C,EAAE;QACpE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3E,OAAO,EAAE,CAAC;YACR,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;YAC5B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE;YAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE;YAC9B,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE;YAClC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,CAAC,cAAc,EAAE;YACrD,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC7F,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,15 +1,17 @@
1
1
  import { type Caller } from '../shared/caller.js';
2
2
  import type { ClearRequest } from './clear-request.js';
3
3
  import type { ClearRequestRepository } from './ports.js';
4
+ import { type ReadReachOf } from './read-reach.js';
4
5
  /** A pending clear request as it is read: whose, which worktree, who asked and when. */
5
6
  export type ListedClearRequest = Omit<ClearRequest, 'fleetId'>;
6
7
  export type ReadClearRequests = (caller: Caller) => Promise<ListedClearRequest[]>;
7
8
  /**
8
9
  * Use case: the pending clear requests (decision 0032). A caller with
9
- * fleet:read reads every trierarch's, so the console shows a worktree
10
- * clearing; a trierarch with crew:run reads its own. One of the two scopes is
11
- * checked before this runs.
10
+ * fleet:read reads every trierarch's for the ships it reads (decision 0034),
11
+ * so the console shows a worktree clearing; a trierarch with crew:run reads
12
+ * its own. One of the two scopes is checked before this runs.
12
13
  */
13
14
  export declare function createReadClearRequests(deps: {
14
15
  clearRequests: Pick<ClearRequestRepository, 'list' | 'listFor'>;
16
+ readReach: ReadReachOf;
15
17
  }): ReadClearRequests;
@@ -1,14 +1,16 @@
1
1
  import { hasScope } from '../shared/caller.js';
2
+ import { readsShip } from './read-reach.js';
2
3
  /**
3
4
  * Use case: the pending clear requests (decision 0032). A caller with
4
- * fleet:read reads every trierarch's, so the console shows a worktree
5
- * clearing; a trierarch with crew:run reads its own. One of the two scopes is
6
- * checked before this runs.
5
+ * fleet:read reads every trierarch's for the ships it reads (decision 0034),
6
+ * so the console shows a worktree clearing; a trierarch with crew:run reads
7
+ * its own. One of the two scopes is checked before this runs.
7
8
  */
8
9
  export function createReadClearRequests(deps) {
9
10
  return async (caller) => {
10
- const requests = hasScope(caller, 'fleet:read')
11
- ? await deps.clearRequests.list(caller.fleetId)
11
+ const reach = hasScope(caller, 'fleet:read') ? await deps.readReach(caller) : undefined;
12
+ const requests = reach
13
+ ? (await deps.clearRequests.list(caller.fleetId)).filter((request) => readsShip(reach, request.shipId))
12
14
  : await deps.clearRequests.listFor(caller.fleetId, caller.shipId);
13
15
  return requests.map(({ trierarchShipId, shipId, repository, requestedBy, requestedAt }) => ({ trierarchShipId, shipId, repository, requestedBy, requestedAt }));
14
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"read-clear-requests.js","sourceRoot":"","sources":["../../../src/domain/registry/read-clear-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,qBAAqB,CAAC;AAS5D;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAyE;IAC/G,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;YAC7C,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAC/C,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACpE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAClK,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"read-clear-requests.js","sourceRoot":"","sources":["../../../src/domain/registry/read-clear-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAC;AAO9D;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAiG;IACvI,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxF,MAAM,QAAQ,GAAG,KAAK;YACpB,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACvG,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACpE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAClK,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ShipId } from '@aeolus-fleet/common';
2
+ import type { Caller } from '../shared/caller.js';
3
+ import { type Result } from '../shared/result.js';
4
+ import type { UnitOfWork } from '../shared/unit-of-work.js';
5
+ import type { NetworkSettingsRepository } from './ports.js';
6
+ export interface ReadNetworkPluginTx {
7
+ networkSettings: Pick<NetworkSettingsRepository, 'findForShare'>;
8
+ }
9
+ export interface RegisteredNetworkPlugin {
10
+ shipId: ShipId;
11
+ registeredAt: Date;
12
+ }
13
+ export type ReadNetworkPlugin = (caller: Caller) => Promise<Result<RegisteredNetworkPlugin | null, never>>;
14
+ /**
15
+ * Use case: the caller's fleet's networking plugin, its ship and when it
16
+ * registered, or none (decision 0035): the gateway switches on for a fleet
17
+ * only while it has one (interop I-3). Its scope (fleet:read) is checked
18
+ * before this runs. Read under the shared settings lock, so it answers one
19
+ * version.
20
+ */
21
+ export declare function createReadNetworkPlugin(deps: {
22
+ uow: UnitOfWork<ReadNetworkPluginTx>;
23
+ }): ReadNetworkPlugin;
@@ -0,0 +1,15 @@
1
+ import { ok } from '../shared/result.js';
2
+ /**
3
+ * Use case: the caller's fleet's networking plugin, its ship and when it
4
+ * registered, or none (decision 0035): the gateway switches on for a fleet
5
+ * only while it has one (interop I-3). Its scope (fleet:read) is checked
6
+ * before this runs. Read under the shared settings lock, so it answers one
7
+ * version.
8
+ */
9
+ export function createReadNetworkPlugin(deps) {
10
+ return (caller) => deps.uow.run(async (tx) => {
11
+ const { plugin } = await tx.networkSettings.findForShare(caller.fleetId);
12
+ return ok(plugin === null ? null : { shipId: plugin.shipId, registeredAt: plugin.registeredAt });
13
+ });
14
+ }
15
+ //# sourceMappingURL=read-network-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-network-plugin.js","sourceRoot":"","sources":["../../../src/domain/registry/read-network-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAetD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAA8C;IACpF,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAA0D,EAAE;QAChF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzE,OAAO,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IACnG,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ShipId } from '@aeolus-fleet/common';
2
+ import { type Caller } from '../shared/caller.js';
3
+ import { type DomainError } from '../shared/errors.js';
4
+ import { type Result } from '../shared/result.js';
5
+ import type { ShipRepository } from './ports.js';
6
+ export type ReadOnBehalf = (caller: Caller, input: {
7
+ shipId: ShipId;
8
+ }) => Promise<Result<Caller, DomainError<'SCOPE_NOT_HELD' | 'SHIP_NOT_FOUND' | 'SHIP_NOT_READ_ON_BEHALF'>>>;
9
+ /**
10
+ * Use case: the reader a plugin ship reads as on behalf of a named ship
11
+ * (decision 0034): the named ship with fleet:read only, so every fleet:read
12
+ * read filters by that ship's read reach whatever its own scopes, with the
13
+ * plugin kept as the one that asked. The plugin needs fleet:read and
14
+ * fleet:on-behalf itself: fleet:read alone reads only as its own ship. argo
15
+ * and the viewer are never named: their read is the whole fleet, which a
16
+ * plugin would gain by naming them.
17
+ */
18
+ export declare function createReadOnBehalf(deps: {
19
+ ships: Pick<ShipRepository, 'find'>;
20
+ }): ReadOnBehalf;
@@ -0,0 +1,31 @@
1
+ import { hasScope } from '../shared/caller.js';
2
+ import { refuse } from '../shared/errors.js';
3
+ import { ok } from '../shared/result.js';
4
+ /**
5
+ * Use case: the reader a plugin ship reads as on behalf of a named ship
6
+ * (decision 0034): the named ship with fleet:read only, so every fleet:read
7
+ * read filters by that ship's read reach whatever its own scopes, with the
8
+ * plugin kept as the one that asked. The plugin needs fleet:read and
9
+ * fleet:on-behalf itself: fleet:read alone reads only as its own ship. argo
10
+ * and the viewer are never named: their read is the whole fleet, which a
11
+ * plugin would gain by naming them.
12
+ */
13
+ export function createReadOnBehalf(deps) {
14
+ return async (caller, { shipId }) => {
15
+ if (!hasScope(caller, 'fleet:read')) {
16
+ return refuse('SCOPE_NOT_HELD', 'Reading on behalf of a ship needs the fleet:read scope');
17
+ }
18
+ if (!hasScope(caller, 'fleet:on-behalf')) {
19
+ return refuse('SCOPE_NOT_HELD', 'Reading on behalf of a ship needs the fleet:on-behalf scope');
20
+ }
21
+ const ship = await deps.ships.find(caller.fleetId, shipId);
22
+ if (ship?.retiredAt !== null) {
23
+ return refuse('SHIP_NOT_FOUND', `No ship ${shipId} in this fleet`);
24
+ }
25
+ if (ship.kind === 'operator' || ship.kind === 'viewer') {
26
+ return refuse('SHIP_NOT_READ_ON_BEHALF', `A plugin reads on behalf of no ${ship.kind === 'operator' ? 'argo' : 'viewer'}: its read is the whole fleet`);
27
+ }
28
+ return ok({ fleetId: caller.fleetId, shipId: ship.id, kind: ship.kind, scopes: ['fleet:read'], askedBy: caller.shipId });
29
+ };
30
+ }
31
+ //# sourceMappingURL=read-on-behalf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-on-behalf.js","sourceRoot":"","sources":["../../../src/domain/registry/read-on-behalf.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAe,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAQtD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAA6C;IAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAClC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,gBAAgB,EAAE,wDAAwD,CAAC,CAAC;QAC5F,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,CAAC;YACzC,OAAO,MAAM,CAAC,gBAAgB,EAAE,6DAA6D,CAAC,CAAC;QACjG,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,IAAI,EAAE,SAAS,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,gBAAgB,EAAE,WAAW,MAAM,gBAAgB,CAAC,CAAC;QACrE,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,OAAO,MAAM,CAAC,yBAAyB,EAAE,kCAAkC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAC1J,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3H,CAAC,CAAC;AACJ,CAAC"}