@aeolus-fleet/core 0.27.0 → 0.28.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 (452) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/crypto/account-token-signatures.d.ts +12 -0
  3. package/dist/adapters/crypto/account-token-signatures.js +104 -0
  4. package/dist/adapters/crypto/account-token-signatures.js.map +1 -0
  5. package/dist/adapters/http/request-credentials.d.ts +7 -1
  6. package/dist/adapters/http/request-credentials.js +18 -5
  7. package/dist/adapters/http/request-credentials.js.map +1 -1
  8. package/dist/adapters/http/server.js +4 -2
  9. package/dist/adapters/http/server.js.map +1 -1
  10. package/dist/adapters/prisma/event-log.js +13 -1
  11. package/dist/adapters/prisma/event-log.js.map +1 -1
  12. package/dist/adapters/prisma/generated/browser.d.ts +36 -0
  13. package/dist/adapters/prisma/generated/client.d.ts +36 -0
  14. package/dist/adapters/prisma/generated/commonInputTypes.d.ts +150 -0
  15. package/dist/adapters/prisma/generated/enums.d.ts +33 -0
  16. package/dist/adapters/prisma/generated/enums.js +29 -1
  17. package/dist/adapters/prisma/generated/enums.js.map +1 -1
  18. package/dist/adapters/prisma/generated/internal/class.d.ts +55 -0
  19. package/dist/adapters/prisma/generated/internal/class.js +4 -4
  20. package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
  21. package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +463 -8
  22. package/dist/adapters/prisma/generated/internal/prismaNamespace.js +45 -10
  23. package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
  24. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +47 -7
  25. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +45 -10
  26. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
  27. package/dist/adapters/prisma/generated/models/AccountCutOff.d.ts +944 -0
  28. package/dist/adapters/prisma/generated/models/AccountCutOff.js +2 -0
  29. package/dist/adapters/prisma/generated/models/AccountCutOff.js.map +1 -0
  30. package/dist/adapters/prisma/generated/models/ConsoleSession.d.ts +59 -1
  31. package/dist/adapters/prisma/generated/models/Event.d.ts +426 -1
  32. package/dist/adapters/prisma/generated/models/Fleet.d.ts +1270 -116
  33. package/dist/adapters/prisma/generated/models/InstallationDeclaredNetworkRules.d.ts +1031 -0
  34. package/dist/adapters/prisma/generated/models/InstallationDeclaredNetworkRules.js +2 -0
  35. package/dist/adapters/prisma/generated/models/InstallationDeclaredNetworkRules.js.map +1 -0
  36. package/dist/adapters/prisma/generated/models/Label.d.ts +113 -39
  37. package/dist/adapters/prisma/generated/models/Lease.d.ts +60 -1
  38. package/dist/adapters/prisma/generated/models/NetworkRulesDraft.d.ts +1133 -0
  39. package/dist/adapters/prisma/generated/models/NetworkRulesDraft.js +2 -0
  40. package/dist/adapters/prisma/generated/models/NetworkRulesDraft.js.map +1 -0
  41. package/dist/adapters/prisma/generated/models/NetworkSettings.d.ts +24 -223
  42. package/dist/adapters/prisma/generated/models/PluginConnection.d.ts +1180 -0
  43. package/dist/adapters/prisma/generated/models/PluginConnection.js +2 -0
  44. package/dist/adapters/prisma/generated/models/PluginConnection.js.map +1 -0
  45. package/dist/adapters/prisma/generated/models/ReachRefusal.d.ts +1 -40
  46. package/dist/adapters/prisma/generated/models/Ship.d.ts +1072 -6
  47. package/dist/adapters/prisma/generated/models/SignInTicket.d.ts +39 -1
  48. package/dist/adapters/prisma/generated/models/VerifiedFacts.d.ts +1325 -0
  49. package/dist/adapters/prisma/generated/models/VerifiedFacts.js +2 -0
  50. package/dist/adapters/prisma/generated/models/VerifiedFacts.js.map +1 -0
  51. package/dist/adapters/prisma/generated/models.d.ts +5 -0
  52. package/dist/adapters/prisma/history.js +5 -2
  53. package/dist/adapters/prisma/history.js.map +1 -1
  54. package/dist/adapters/prisma/identity.d.ts +3 -1
  55. package/dist/adapters/prisma/identity.js +41 -8
  56. package/dist/adapters/prisma/identity.js.map +1 -1
  57. package/dist/adapters/prisma/messaging.js +5 -2
  58. package/dist/adapters/prisma/messaging.js.map +1 -1
  59. package/dist/adapters/prisma/network.d.ts +7 -2
  60. package/dist/adapters/prisma/network.js +92 -62
  61. package/dist/adapters/prisma/network.js.map +1 -1
  62. package/dist/adapters/prisma/overdue.js +4 -3
  63. package/dist/adapters/prisma/overdue.js.map +1 -1
  64. package/dist/adapters/prisma/plugin-connections.d.ts +4 -0
  65. package/dist/adapters/prisma/plugin-connections.js +20 -0
  66. package/dist/adapters/prisma/plugin-connections.js.map +1 -0
  67. package/dist/adapters/prisma/registry.js +22 -16
  68. package/dist/adapters/prisma/registry.js.map +1 -1
  69. package/dist/adapters/prisma/rows.d.ts +9 -4
  70. package/dist/adapters/prisma/rows.js +77 -19
  71. package/dist/adapters/prisma/rows.js.map +1 -1
  72. package/dist/adapters/prisma/unit-of-work.d.ts +5 -2
  73. package/dist/adapters/prisma/unit-of-work.js +7 -2
  74. package/dist/adapters/prisma/unit-of-work.js.map +1 -1
  75. package/dist/adapters/prisma/verified-facts.d.ts +4 -0
  76. package/dist/adapters/prisma/verified-facts.js +65 -0
  77. package/dist/adapters/prisma/verified-facts.js.map +1 -0
  78. package/dist/adapters/rest/rest-api.js +2 -2
  79. package/dist/adapters/rest/rest-api.js.map +1 -1
  80. package/dist/adapters/trpc/console.d.ts +3 -1
  81. package/dist/adapters/trpc/context.d.ts +28 -6
  82. package/dist/adapters/trpc/fleet.d.ts +314 -51
  83. package/dist/adapters/trpc/fleet.js +137 -75
  84. package/dist/adapters/trpc/fleet.js.map +1 -1
  85. package/dist/adapters/trpc/installation-token.d.ts +7 -0
  86. package/dist/adapters/trpc/installation-token.js +10 -0
  87. package/dist/adapters/trpc/installation-token.js.map +1 -0
  88. package/dist/adapters/trpc/installation.d.ts +32 -2
  89. package/dist/adapters/trpc/installation.js +14 -10
  90. package/dist/adapters/trpc/installation.js.map +1 -1
  91. package/dist/adapters/trpc/router.d.ts +435 -42
  92. package/dist/adapters/trpc/ship-contract.js +6 -3
  93. package/dist/adapters/trpc/ship-contract.js.map +1 -1
  94. package/dist/adapters/trpc/ship-protocol.js +1 -1
  95. package/dist/adapters/trpc/ship-protocol.js.map +1 -1
  96. package/dist/adapters/trpc/ship.d.ts +117 -1
  97. package/dist/adapters/trpc/ship.js +52 -6
  98. package/dist/adapters/trpc/ship.js.map +1 -1
  99. package/dist/adapters/trpc/trpc.d.ts +43 -17
  100. package/dist/adapters/trpc/trpc.js +131 -31
  101. package/dist/adapters/trpc/trpc.js.map +1 -1
  102. package/dist/app.d.ts +2 -0
  103. package/dist/app.js +22 -0
  104. package/dist/app.js.map +1 -1
  105. package/dist/config.d.ts +5 -0
  106. package/dist/config.js +3 -1
  107. package/dist/config.js.map +1 -1
  108. package/dist/domain/identity/authenticate-account.d.ts +35 -0
  109. package/dist/domain/identity/authenticate-account.js +54 -0
  110. package/dist/domain/identity/authenticate-account.js.map +1 -0
  111. package/dist/domain/identity/authenticate-installation.d.ts +23 -0
  112. package/dist/domain/identity/authenticate-installation.js +20 -0
  113. package/dist/domain/identity/authenticate-installation.js.map +1 -0
  114. package/dist/domain/identity/authenticate.d.ts +2 -2
  115. package/dist/domain/identity/console-session.d.ts +6 -3
  116. package/dist/domain/identity/console-session.js.map +1 -1
  117. package/dist/domain/identity/cut-off-account.d.ts +29 -0
  118. package/dist/domain/identity/cut-off-account.js +37 -0
  119. package/dist/domain/identity/cut-off-account.js.map +1 -0
  120. package/dist/domain/identity/dismiss-notice.d.ts +2 -2
  121. package/dist/domain/identity/issue-sign-in-ticket.d.ts +9 -3
  122. package/dist/domain/identity/issue-sign-in-ticket.js +8 -2
  123. package/dist/domain/identity/issue-sign-in-ticket.js.map +1 -1
  124. package/dist/domain/identity/ports.d.ts +52 -5
  125. package/dist/domain/identity/read-account.d.ts +8 -4
  126. package/dist/domain/identity/read-account.js +1 -1
  127. package/dist/domain/identity/read-account.js.map +1 -1
  128. package/dist/domain/identity/read-guide.d.ts +2 -2
  129. package/dist/domain/identity/read-notices.d.ts +2 -2
  130. package/dist/domain/identity/record-guide-progress.d.ts +2 -2
  131. package/dist/domain/identity/redeem-sign-in-ticket.d.ts +2 -1
  132. package/dist/domain/identity/redeem-sign-in-ticket.js +3 -2
  133. package/dist/domain/identity/redeem-sign-in-ticket.js.map +1 -1
  134. package/dist/domain/identity/set-theme.d.ts +2 -2
  135. package/dist/domain/identity/sign-in-ticket.d.ts +3 -1
  136. package/dist/domain/identity/sign-in.d.ts +2 -2
  137. package/dist/domain/identity/sign-in.js +2 -0
  138. package/dist/domain/identity/sign-in.js.map +1 -1
  139. package/dist/domain/identity/sign-out.d.ts +2 -2
  140. package/dist/domain/identity/sign-out.js +1 -1
  141. package/dist/domain/identity/sign-out.js.map +1 -1
  142. package/dist/domain/identity/start-console-session.d.ts +4 -2
  143. package/dist/domain/identity/start-console-session.js +6 -4
  144. package/dist/domain/identity/start-console-session.js.map +1 -1
  145. package/dist/domain/identity/start-viewer-session.js +1 -0
  146. package/dist/domain/identity/start-viewer-session.js.map +1 -1
  147. package/dist/domain/messaging/delivery.d.ts +11 -3
  148. package/dist/domain/messaging/delivery.js +23 -15
  149. package/dist/domain/messaging/delivery.js.map +1 -1
  150. package/dist/domain/messaging/dismiss-delivery.d.ts +2 -2
  151. package/dist/domain/messaging/hand-over-delivery.d.ts +1 -0
  152. package/dist/domain/messaging/hand-over-delivery.js +1 -0
  153. package/dist/domain/messaging/hand-over-delivery.js.map +1 -1
  154. package/dist/domain/messaging/message.d.ts +3 -1
  155. package/dist/domain/messaging/message.js +1 -1
  156. package/dist/domain/messaging/message.js.map +1 -1
  157. package/dist/domain/messaging/overdue.d.ts +2 -0
  158. package/dist/domain/messaging/overdue.js +3 -0
  159. package/dist/domain/messaging/overdue.js.map +1 -1
  160. package/dist/domain/messaging/ping-ship.d.ts +2 -2
  161. package/dist/domain/messaging/ping-ship.js +1 -1
  162. package/dist/domain/messaging/ping-ship.js.map +1 -1
  163. package/dist/domain/messaging/ports.d.ts +2 -0
  164. package/dist/domain/messaging/push-receive-deliveries.d.ts +4 -1
  165. package/dist/domain/messaging/push-receive-deliveries.js +5 -3
  166. package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
  167. package/dist/domain/messaging/receive-deliveries.d.ts +21 -0
  168. package/dist/domain/messaging/receive-deliveries.js +5 -3
  169. package/dist/domain/messaging/receive-deliveries.js.map +1 -1
  170. package/dist/domain/messaging/receive-reply.d.ts +32 -0
  171. package/dist/domain/messaging/receive-reply.js +25 -0
  172. package/dist/domain/messaging/receive-reply.js.map +1 -0
  173. package/dist/domain/messaging/resend-delivery.d.ts +2 -2
  174. package/dist/domain/messaging/resend-delivery.js +1 -0
  175. package/dist/domain/messaging/resend-delivery.js.map +1 -1
  176. package/dist/domain/messaging/send-message.d.ts +3 -3
  177. package/dist/domain/messaging/send-message.js +1 -0
  178. package/dist/domain/messaging/send-message.js.map +1 -1
  179. package/dist/domain/registry/apply-network-rules.d.ts +32 -0
  180. package/dist/domain/registry/apply-network-rules.js +33 -0
  181. package/dist/domain/registry/apply-network-rules.js.map +1 -0
  182. package/dist/domain/registry/assign-crew.d.ts +2 -2
  183. package/dist/domain/registry/assign-crew.js +3 -2
  184. package/dist/domain/registry/assign-crew.js.map +1 -1
  185. package/dist/domain/registry/assign-label.d.ts +7 -5
  186. package/dist/domain/registry/assign-label.js +16 -6
  187. package/dist/domain/registry/assign-label.js.map +1 -1
  188. package/dist/domain/registry/change-label-values.d.ts +1 -1
  189. package/dist/domain/registry/change-label-values.js +4 -3
  190. package/dist/domain/registry/change-label-values.js.map +1 -1
  191. package/dist/domain/registry/check-reach.d.ts +49 -24
  192. package/dist/domain/registry/check-reach.js +77 -42
  193. package/dist/domain/registry/check-reach.js.map +1 -1
  194. package/dist/domain/registry/clear-request.d.ts +1 -1
  195. package/dist/domain/registry/clear-request.js +1 -1
  196. package/dist/domain/registry/clear-request.js.map +1 -1
  197. package/dist/domain/registry/commission-ship.d.ts +26 -13
  198. package/dist/domain/registry/commission-ship.js +199 -22
  199. package/dist/domain/registry/commission-ship.js.map +1 -1
  200. package/dist/domain/registry/confirm-crew-release.d.ts +2 -2
  201. package/dist/domain/registry/confirm-crew-release.js +3 -2
  202. package/dist/domain/registry/confirm-crew-release.js.map +1 -1
  203. package/dist/domain/registry/confirm-worktree-cleared.d.ts +2 -2
  204. package/dist/domain/registry/confirm-worktree-cleared.js +3 -2
  205. package/dist/domain/registry/confirm-worktree-cleared.js.map +1 -1
  206. package/dist/domain/registry/connect-plugin.d.ts +31 -0
  207. package/dist/domain/registry/connect-plugin.js +34 -0
  208. package/dist/domain/registry/connect-plugin.js.map +1 -0
  209. package/dist/domain/registry/crew-request.d.ts +2 -2
  210. package/dist/domain/registry/crew-request.js.map +1 -1
  211. package/dist/domain/registry/declare-network-rules.d.ts +9 -6
  212. package/dist/domain/registry/declare-network-rules.js +13 -8
  213. package/dist/domain/registry/declare-network-rules.js.map +1 -1
  214. package/dist/domain/registry/declare-scopes.d.ts +2 -2
  215. package/dist/domain/registry/declared-network-rules.d.ts +30 -21
  216. package/dist/domain/registry/declared-network-rules.js +46 -22
  217. package/dist/domain/registry/declared-network-rules.js.map +1 -1
  218. package/dist/domain/registry/define-label.d.ts +1 -1
  219. package/dist/domain/registry/define-label.js +5 -5
  220. package/dist/domain/registry/define-label.js.map +1 -1
  221. package/dist/domain/registry/delete-label.d.ts +1 -1
  222. package/dist/domain/registry/delete-label.js +4 -3
  223. package/dist/domain/registry/delete-label.js.map +1 -1
  224. package/dist/domain/registry/discard-network-rules-draft.d.ts +23 -0
  225. package/dist/domain/registry/discard-network-rules-draft.js +24 -0
  226. package/dist/domain/registry/discard-network-rules-draft.js.map +1 -0
  227. package/dist/domain/registry/discover.d.ts +12 -10
  228. package/dist/domain/registry/discover.js +11 -5
  229. package/dist/domain/registry/discover.js.map +1 -1
  230. package/dist/domain/registry/explain-crew-request.d.ts +2 -2
  231. package/dist/domain/registry/explain-crew-request.js +3 -2
  232. package/dist/domain/registry/explain-crew-request.js.map +1 -1
  233. package/dist/domain/registry/explain-reach.d.ts +22 -14
  234. package/dist/domain/registry/explain-reach.js +53 -53
  235. package/dist/domain/registry/explain-reach.js.map +1 -1
  236. package/dist/domain/registry/get-ship.d.ts +2 -2
  237. package/dist/domain/registry/get-starting-prompt.d.ts +4 -2
  238. package/dist/domain/registry/get-starting-prompt.js +7 -5
  239. package/dist/domain/registry/get-starting-prompt.js.map +1 -1
  240. package/dist/domain/registry/give-back-crew-request.d.ts +2 -2
  241. package/dist/domain/registry/give-back-crew-request.js +3 -2
  242. package/dist/domain/registry/give-back-crew-request.js.map +1 -1
  243. package/dist/domain/registry/grant-scopes.d.ts +8 -5
  244. package/dist/domain/registry/grant-scopes.js +14 -5
  245. package/dist/domain/registry/grant-scopes.js.map +1 -1
  246. package/dist/domain/registry/label.d.ts +69 -18
  247. package/dist/domain/registry/label.js +79 -28
  248. package/dist/domain/registry/label.js.map +1 -1
  249. package/dist/domain/registry/lease.d.ts +1 -1
  250. package/dist/domain/registry/leases.d.ts +6 -3
  251. package/dist/domain/registry/leases.js +7 -5
  252. package/dist/domain/registry/leases.js.map +1 -1
  253. package/dist/domain/registry/list-fleet.d.ts +2 -0
  254. package/dist/domain/registry/list-fleet.js +1 -0
  255. package/dist/domain/registry/list-fleet.js.map +1 -1
  256. package/dist/domain/registry/list-scopes.d.ts +2 -1
  257. package/dist/domain/registry/list-scopes.js +2 -1
  258. package/dist/domain/registry/list-scopes.js.map +1 -1
  259. package/dist/domain/registry/managed-or-assigned.d.ts +12 -4
  260. package/dist/domain/registry/managed-or-assigned.js +25 -7
  261. package/dist/domain/registry/managed-or-assigned.js.map +1 -1
  262. package/dist/domain/registry/network-rules-draft.d.ts +45 -0
  263. package/dist/domain/registry/network-rules-draft.js +41 -0
  264. package/dist/domain/registry/network-rules-draft.js.map +1 -0
  265. package/dist/domain/registry/network-settings.d.ts +96 -115
  266. package/dist/domain/registry/network-settings.js +101 -150
  267. package/dist/domain/registry/network-settings.js.map +1 -1
  268. package/dist/domain/registry/plugin-connection.d.ts +48 -0
  269. package/dist/domain/registry/plugin-connection.js +35 -0
  270. package/dist/domain/registry/plugin-connection.js.map +1 -0
  271. package/dist/domain/registry/ports.d.ts +60 -12
  272. package/dist/domain/registry/reach-refusal.d.ts +18 -4
  273. package/dist/domain/registry/read-assigned-crew-requests.d.ts +2 -2
  274. package/dist/domain/registry/read-built-in-rules.d.ts +5 -4
  275. package/dist/domain/registry/read-built-in-rules.js +9 -7
  276. package/dist/domain/registry/read-built-in-rules.js.map +1 -1
  277. package/dist/domain/registry/read-clear-requests.d.ts +2 -2
  278. package/dist/domain/registry/read-clear-requests.js.map +1 -1
  279. package/dist/domain/registry/read-declared-network-rules.d.ts +5 -5
  280. package/dist/domain/registry/read-declared-network-rules.js +4 -4
  281. package/dist/domain/registry/read-declared-network-rules.js.map +1 -1
  282. package/dist/domain/registry/read-network-rules-draft-changes.d.ts +22 -0
  283. package/dist/domain/registry/read-network-rules-draft-changes.js +53 -0
  284. package/dist/domain/registry/read-network-rules-draft-changes.js.map +1 -0
  285. package/dist/domain/registry/read-network-rules.d.ts +30 -0
  286. package/dist/domain/registry/read-network-rules.js +18 -0
  287. package/dist/domain/registry/read-network-rules.js.map +1 -0
  288. package/dist/domain/registry/read-on-behalf.d.ts +3 -3
  289. package/dist/domain/registry/read-on-behalf.js.map +1 -1
  290. package/dist/domain/registry/read-reach-refusals.d.ts +6 -5
  291. package/dist/domain/registry/read-reach-refusals.js +13 -8
  292. package/dist/domain/registry/read-reach-refusals.js.map +1 -1
  293. package/dist/domain/registry/read-reach.d.ts +10 -10
  294. package/dist/domain/registry/read-reach.js +26 -16
  295. package/dist/domain/registry/read-reach.js.map +1 -1
  296. package/dist/domain/registry/recrew-ship.d.ts +2 -2
  297. package/dist/domain/registry/recrew-ship.js +5 -3
  298. package/dist/domain/registry/recrew-ship.js.map +1 -1
  299. package/dist/domain/registry/release-ship.d.ts +7 -4
  300. package/dist/domain/registry/release-ship.js +8 -4
  301. package/dist/domain/registry/release-ship.js.map +1 -1
  302. package/dist/domain/registry/remove-crew-request.d.ts +2 -2
  303. package/dist/domain/registry/remove-crew-request.js +4 -3
  304. package/dist/domain/registry/remove-crew-request.js.map +1 -1
  305. package/dist/domain/registry/rename-ship.d.ts +1 -1
  306. package/dist/domain/registry/rename-ship.js +4 -3
  307. package/dist/domain/registry/rename-ship.js.map +1 -1
  308. package/dist/domain/registry/report-crew-status.d.ts +2 -2
  309. package/dist/domain/registry/report-crew-status.js +3 -2
  310. package/dist/domain/registry/report-crew-status.js.map +1 -1
  311. package/dist/domain/registry/request-crew.d.ts +3 -3
  312. package/dist/domain/registry/request-crew.js +4 -3
  313. package/dist/domain/registry/request-crew.js.map +1 -1
  314. package/dist/domain/registry/request-worktree-clear.d.ts +2 -2
  315. package/dist/domain/registry/request-worktree-clear.js +4 -3
  316. package/dist/domain/registry/request-worktree-clear.js.map +1 -1
  317. package/dist/domain/registry/retire-ship.d.ts +17 -12
  318. package/dist/domain/registry/retire-ship.js +30 -21
  319. package/dist/domain/registry/retire-ship.js.map +1 -1
  320. package/dist/domain/registry/save-network-rules-draft.d.ts +31 -0
  321. package/dist/domain/registry/save-network-rules-draft.js +27 -0
  322. package/dist/domain/registry/save-network-rules-draft.js.map +1 -0
  323. package/dist/domain/registry/scope-grant.d.ts +19 -19
  324. package/dist/domain/registry/scope-grant.js +8 -9
  325. package/dist/domain/registry/scope-grant.js.map +1 -1
  326. package/dist/domain/registry/set-built-in-rule.d.ts +3 -3
  327. package/dist/domain/registry/set-built-in-rule.js +5 -9
  328. package/dist/domain/registry/set-built-in-rule.js.map +1 -1
  329. package/dist/domain/registry/set-owner.d.ts +9 -6
  330. package/dist/domain/registry/set-owner.js +14 -8
  331. package/dist/domain/registry/set-owner.js.map +1 -1
  332. package/dist/domain/registry/set-verified-facts.d.ts +36 -0
  333. package/dist/domain/registry/set-verified-facts.js +58 -0
  334. package/dist/domain/registry/set-verified-facts.js.map +1 -0
  335. package/dist/domain/registry/ship.d.ts +55 -17
  336. package/dist/domain/registry/ship.js +107 -16
  337. package/dist/domain/registry/ship.js.map +1 -1
  338. package/dist/domain/registry/statement.d.ts +2 -2
  339. package/dist/domain/registry/statement.js +2 -2
  340. package/dist/domain/registry/statement.js.map +1 -1
  341. package/dist/domain/registry/turn.d.ts +2 -2
  342. package/dist/domain/registry/turn.js +2 -2
  343. package/dist/domain/registry/turn.js.map +1 -1
  344. package/dist/domain/registry/unassign-label.d.ts +8 -5
  345. package/dist/domain/registry/unassign-label.js +17 -6
  346. package/dist/domain/registry/unassign-label.js.map +1 -1
  347. package/dist/domain/registry/verified-facts.d.ts +75 -0
  348. package/dist/domain/registry/verified-facts.js +107 -0
  349. package/dist/domain/registry/verified-facts.js.map +1 -0
  350. package/dist/domain/registry/whoami.d.ts +2 -2
  351. package/dist/domain/shared/caller.d.ts +40 -6
  352. package/dist/domain/shared/caller.js +20 -0
  353. package/dist/domain/shared/caller.js.map +1 -1
  354. package/dist/domain/shared/delivery-way.d.ts +9 -5
  355. package/dist/domain/shared/delivery-way.js +17 -5
  356. package/dist/domain/shared/delivery-way.js.map +1 -1
  357. package/dist/domain/shared/errors.d.ts +1 -1
  358. package/dist/domain/shared/errors.js.map +1 -1
  359. package/dist/domain/shared/events.d.ts +13 -2
  360. package/dist/domain/shared/events.js.map +1 -1
  361. package/dist/domain/shared/health.d.ts +3 -1
  362. package/dist/domain/shared/health.js +5 -3
  363. package/dist/domain/shared/health.js.map +1 -1
  364. package/dist/domain/shared/history.d.ts +5 -1
  365. package/dist/domain/shared/history.js.map +1 -1
  366. package/dist/domain/shared/read-fleet-limits.d.ts +2 -2
  367. package/dist/domain/shared/read-health.d.ts +4 -3
  368. package/dist/domain/shared/read-health.js +9 -3
  369. package/dist/domain/shared/read-health.js.map +1 -1
  370. package/dist/domain/shared/read-inbox.d.ts +2 -2
  371. package/dist/domain/shared/read-message.d.ts +2 -2
  372. package/dist/domain/shared/read-needs-attention.d.ts +2 -2
  373. package/dist/domain/shared/read-sent-message.d.ts +31 -0
  374. package/dist/domain/shared/read-sent-message.js +28 -0
  375. package/dist/domain/shared/read-sent-message.js.map +1 -0
  376. package/dist/domain/shared/read-ship-messages.d.ts +2 -2
  377. package/dist/domain/shared/read-ship-timeline.d.ts +2 -2
  378. package/dist/domain/shared/read-ship-way.d.ts +2 -2
  379. package/dist/domain/shared/read-ship-way.js +1 -1
  380. package/dist/domain/shared/read-ship-way.js.map +1 -1
  381. package/dist/domain/shared/stuck.js +4 -2
  382. package/dist/domain/shared/stuck.js.map +1 -1
  383. package/dist/start.js +1 -0
  384. package/dist/start.js.map +1 -1
  385. package/dist/testing/account-token-issuer.d.ts +30 -0
  386. package/dist/testing/account-token-issuer.js +48 -0
  387. package/dist/testing/account-token-issuer.js.map +1 -0
  388. package/dist/testing/container-images.d.ts +14 -0
  389. package/dist/testing/container-images.js +18 -0
  390. package/dist/testing/container-images.js.map +1 -0
  391. package/dist/testing/database.d.ts +14 -0
  392. package/dist/testing/database.js +48 -0
  393. package/dist/testing/database.js.map +1 -0
  394. package/dist/testing/fleet.d.ts +13 -0
  395. package/dist/testing/fleet.js +17 -0
  396. package/dist/testing/fleet.js.map +1 -0
  397. package/dist/testing/index.d.ts +12 -0
  398. package/dist/testing/index.js +12 -0
  399. package/dist/testing/index.js.map +1 -0
  400. package/dist/testing/keys.d.ts +1 -0
  401. package/dist/testing/keys.js +7 -0
  402. package/dist/testing/keys.js.map +1 -0
  403. package/dist/testing/migrate-lock.d.ts +12 -0
  404. package/dist/testing/migrate-lock.js +51 -0
  405. package/dist/testing/migrate-lock.js.map +1 -0
  406. package/dist/testing/migrated-template.d.ts +12 -0
  407. package/dist/testing/migrated-template.js +29 -0
  408. package/dist/testing/migrated-template.js.map +1 -0
  409. package/dist/testing/postgres-container.d.ts +16 -0
  410. package/dist/testing/postgres-container.js +30 -0
  411. package/dist/testing/postgres-container.js.map +1 -0
  412. package/dist/testing/postgres-global-setup.d.ts +15 -0
  413. package/dist/testing/postgres-global-setup.js +20 -0
  414. package/dist/testing/postgres-global-setup.js.map +1 -0
  415. package/dist/testing/prisma-cli.d.ts +5 -0
  416. package/dist/testing/prisma-cli.js +15 -0
  417. package/dist/testing/prisma-cli.js.map +1 -0
  418. package/dist/testing/result.d.ts +5 -0
  419. package/dist/testing/result.js +15 -0
  420. package/dist/testing/result.js.map +1 -0
  421. package/dist/wiring.d.ts +27 -6
  422. package/dist/wiring.js +44 -11
  423. package/dist/wiring.js.map +1 -1
  424. package/package.json +26 -3
  425. package/src/adapters/prisma/migrations/20261018250000_scope_catalogue/migration.sql +8 -7
  426. package/src/adapters/prisma/migrations/20261019100000_on_behalf_scope/migration.sql +3 -1
  427. package/src/adapters/prisma/migrations/20261019130000_plugin_connections/migration.sql +54 -0
  428. package/src/adapters/prisma/migrations/20261019150000_network_plugin_registered_at/migration.sql +23 -0
  429. package/src/adapters/prisma/migrations/20261019160000_lease_waker/migration.sql +4 -0
  430. package/src/adapters/prisma/migrations/20261019200000_account_cut_offs/migration.sql +10 -0
  431. package/src/adapters/prisma/migrations/20261019210000_event_actors/migration.sql +32 -0
  432. package/src/adapters/prisma/migrations/20261020090000_argos_jobs_as_scopes/migration.sql +65 -0
  433. package/src/adapters/prisma/migrations/20261020100000_installation_labels/migration.sql +7 -0
  434. package/src/adapters/prisma/migrations/20261020110000_installation_declared_network_rules/migration.sql +10 -0
  435. package/src/adapters/prisma/migrations/20261020120000_commissioning_actors/migration.sql +14 -0
  436. package/src/adapters/prisma/migrations/20261020130000_console_sign_in_accounts/migration.sql +4 -0
  437. package/src/adapters/prisma/migrations/20261020140000_event_signed_in_accounts/migration.sql +4 -0
  438. package/src/adapters/prisma/migrations/20261020150000_account_cut_off_ends_console_sessions/migration.sql +2 -0
  439. package/src/adapters/prisma/migrations/20261020160000_network_in_core/migration.sql +30 -0
  440. package/src/adapters/prisma/migrations/20261020170000_verify_scope/migration.sql +64 -0
  441. package/src/adapters/prisma/migrations/20261020180000_verified_facts/migration.sql +21 -0
  442. package/src/adapters/prisma/migrations/20261020190000_verified_facts_by_writer/migration.sql +3 -0
  443. package/src/adapters/prisma/schema.prisma +160 -22
  444. package/dist/domain/registry/register-network-plugin.d.ts +0 -28
  445. package/dist/domain/registry/register-network-plugin.js +0 -26
  446. package/dist/domain/registry/register-network-plugin.js.map +0 -1
  447. package/dist/domain/registry/set-network-rules.d.ts +0 -31
  448. package/dist/domain/registry/set-network-rules.js +0 -27
  449. package/dist/domain/registry/set-network-rules.js.map +0 -1
  450. package/dist/domain/registry/unregister-network-plugin.d.ts +0 -27
  451. package/dist/domain/registry/unregister-network-plugin.js +0 -25
  452. package/dist/domain/registry/unregister-network-plugin.js.map +0 -1
@@ -2,118 +2,74 @@
2
2
  * The fleet's network settings (decision 0034): which ships may send to,
3
3
  * read or manage which. A rule names its verb and says that the ships
4
4
  * matching one selector may do it to the ships matching another; allow-only,
5
- * no deny rules, no precedence. Beside its rules a fleet holds the switches
6
- * of the built-in rules that can be off, with a version that moves on every
7
- * change, so a refusal names the settings that refused it.
5
+ * no deny rules, no precedence. The fleet holds its own rules, set whole by
6
+ * applying a draft, or none for all-to-all, beside the switch of the viewer
7
+ * reading, with a version that moves on every change of what is in force, so
8
+ * a refusal names the settings that refused it.
8
9
  */
9
- import { type FleetId, type LabelId, type LabelValueId, type BuiltInRule, type NetworkPluginDeclaration, type NetworkVerb, type SelectorTerm, type SetBuiltInRuleInput, type ShipId, type ShipKind, type WhileUnavailable } from '@aeolus-fleet/common';
10
+ import { type FleetId, type LabelId, type LabelValueId, type BuiltInRule, type NetworkVerb, type SelectorTerm, type SetBuiltInRuleInput, type ShipId, type ShipKind } from '@aeolus-fleet/common';
10
11
  import { type DomainError } from '../shared/errors.js';
11
12
  import type { Actor, NewEvent } from '../shared/events.js';
12
13
  import { type Result } from '../shared/result.js';
14
+ import type { DeclaredNetworkRules } from './declared-network-rules.js';
15
+ import type { LabelOwner } from './label.js';
13
16
  /** The ships for which every term of `from` holds may do its verb to the ships for which every term of `to` holds. */
14
17
  export interface NetworkRule {
15
18
  verb: NetworkVerb;
16
19
  from: readonly SelectorTerm[];
17
20
  to: readonly SelectorTerm[];
18
21
  }
19
- /**
20
- * The fleet's networking plugin (decision 0035): the ship that alone sets the
21
- * rules while registered, with what it declared for while it is unavailable.
22
- */
23
- export interface NetworkPlugin extends NetworkPluginDeclaration {
24
- shipId: ShipId;
25
- }
26
- /**
27
- * The built-in rules that can be off (decision 0034): the viewer reading
28
- * every ship, argo's to switch, and open, every ship to every ship, one per
29
- * verb, the networking plugin's to switch. A fleet starts with all on.
30
- */
31
- export interface BuiltInSwitches {
32
- isViewerReadOn: boolean;
33
- open: Readonly<Record<NetworkVerb, boolean>>;
34
- }
35
22
  export interface NetworkSettings {
36
23
  fleetId: FleetId;
37
- /** The rules beside the built-in ones, the networking plugin's (decision 0035); none allows only the built-in rules. */
38
- rules: readonly NetworkRule[];
39
- builtIns: BuiltInSwitches;
40
- /** 0 until the fleet first changes its settings; one more on every change. */
24
+ /** The fleet's own rules beside the built-in and the declared ones, as last applied; none while none are, all-to-all with open on. */
25
+ rules: readonly NetworkRule[] | null;
26
+ /** The viewer reading every ship, the one built-in rule an actor turns (decision 0034); on at fleet create. */
27
+ isViewerReadOn: boolean;
28
+ /** 0 until the fleet first changes its settings; one more on every change of what is in force. */
41
29
  version: number;
42
- /** The fleet's networking plugin, or none: then the fleet has no rules, and nobody sets them. */
43
- plugin: NetworkPlugin | null;
44
30
  }
45
- /** Every built-in rule on: what a fleet starts with, and what no networking plugin leaves. */
46
- export declare const BUILT_INS_ON: BuiltInSwitches;
47
- /** A fleet that never set rules: none, every built-in rule on, at version 0, without a plugin. */
31
+ /** A fleet that never set rules: none applied, the viewer reading on, at version 0. */
48
32
  export declare function noNetworkSettings(fleetId: FleetId): NetworkSettings;
49
- export type NotTheNetworkPlugin = DomainError<'NOT_THE_NETWORK_PLUGIN'>;
50
- export type SetNetworkRulesRefusal = DomainError<'INVALID_NETWORK_RULES'> | NotTheNetworkPlugin;
51
- export type RegisterNetworkPluginRefusal = DomainError<'NETWORK_PLUGIN_REGISTERED'>;
33
+ export type InvalidNetworkRules = DomainError<'INVALID_NETWORK_RULES'>;
52
34
  /**
53
- * The ship becomes the fleet's networking plugin, with what it declared, at
54
- * the next version, with NetworkPluginRegistered. A fleet without a plugin
55
- * has no rules, so the plugin starts from none until it supplies its own. The plugin may register again, replacing what it
56
- * declared; another ship is refused until it unregisters: one owner of the
57
- * rules, as a label has one.
35
+ * What breaks the decisions' limits on the fleet's own rules, said for the
36
+ * caller with its decision, or undefined when they keep them: at most 200,
37
+ * counted alone, beside the declared ones (decision 0037); each selector at
38
+ * most 20 terms, as a ship carries no more label values, each term once, and
39
+ * a term of the same value on a label on both sides of its rule, as it binds
40
+ * that label there. An id need not exist: an unknown one matches no ship, as
41
+ * in label selection. None, all-to-all, keeps them.
58
42
  */
59
- export declare function registerNetworkPlugin(current: NetworkSettings, change: {
60
- shipId: ShipId;
61
- declaration: NetworkPluginDeclaration;
62
- at: Date;
63
- actor: Actor;
64
- }): Result<{
65
- settings: NetworkSettings;
66
- events: NewEvent[];
67
- }, RegisterNetworkPluginRefusal>;
68
- /**
69
- * The fleet's plugin goes, and its rules with it, and the open rules are on
70
- * again: no plugin is all-to-all (decision 0035), at the next version, with
71
- * NetworkPluginUnregistered. The viewer reading stays as argo set it. Only
72
- * the plugin's own ship unregisters it; its retirement does too.
73
- */
74
- export declare function unregisterNetworkPlugin(current: NetworkSettings, change: {
75
- shipId: ShipId;
76
- at: Date;
77
- actor: Actor;
78
- }): Result<{
79
- settings: NetworkSettings;
80
- events: NewEvent[];
81
- }, NotTheNetworkPlugin>;
43
+ export declare function invalidRules(rules: readonly NetworkRule[] | null): string | undefined;
82
44
  /**
83
- * The fleet's rules from now on, replacing the ones it had, at the next
84
- * version, with NetworkRulesSet. The rules are within the decisions' limits:
85
- * at most 200 of argo's plus every rule the fleet's ships declared, which the
86
- * plugin adds to argo's when it supplies them (decision 0037); each selector
87
- * at most 20 terms, as a ship carries no more label values, each term once, and a term of the same value on a label on
88
- * both sides of its rule, as it binds that label there. An id need not
89
- * exist: an unknown one matches no ship, as in label selection. Only the
90
- * fleet's registered networking plugin sets them, argo included: rules exist
91
- * only through a plugin (decision 0035).
45
+ * The fleet's rules from now on, the draft's, replacing the ones it had, at
46
+ * the next version, with NetworkRulesSet naming how many, none for
47
+ * all-to-all. The caller saw the settings at `version`: once they moved, the
48
+ * draft's reach may differ from what the caller looked at, so the apply is
49
+ * refused and the draft kept.
92
50
  */
93
- export declare function setNetworkRules(current: NetworkSettings, change: {
94
- rules: readonly NetworkRule[];
95
- declaredRules: number;
96
- shipId: ShipId;
51
+ export declare function applyNetworkRules(current: NetworkSettings, change: {
52
+ rules: readonly NetworkRule[] | null;
53
+ version: number;
97
54
  at: Date;
98
55
  actor: Actor;
99
56
  }): Result<{
100
57
  settings: NetworkSettings;
101
58
  events: NewEvent[];
102
- }, SetNetworkRulesRefusal>;
103
- export type SetBuiltInRuleRefusal = DomainError<'BUILT_IN_RULE_FIXED' | 'NOT_THE_OPERATOR_SHIP'> | NotTheNetworkPlugin;
59
+ }, DomainError<'NETWORK_SETTINGS_CHANGED'>>;
60
+ /** The settings at the next version, as the declared rules in force changed with them (decision 0037). */
61
+ export declare function withDeclaredRulesChanged(current: NetworkSettings): NetworkSettings;
62
+ export type SetBuiltInRuleRefusal = DomainError<'BUILT_IN_RULE_FIXED'>;
104
63
  /**
105
64
  * A built-in rule turned on or off, as its own action (decision 0034): the
106
- * viewer reading by argo, open for one verb by the fleet's networking plugin.
107
- * argo, the owner and the answer are never off, so turning them is refused.
108
- * A change moves the version and writes BuiltInRuleChanged; a rule already
109
- * as asked changes nothing.
65
+ * viewer reading, by any actor holding fleet:network (decision 0053). argo,
66
+ * the owner, the answer, a connected plugin's reading and the installation's
67
+ * managing are never off, and open follows the applied rules, so turning them
68
+ * is refused. A change moves the version and writes BuiltInRuleChanged; a
69
+ * rule already as asked changes nothing.
110
70
  */
111
71
  export declare function setBuiltInRule(current: NetworkSettings, change: {
112
72
  input: SetBuiltInRuleInput;
113
- caller: {
114
- shipId: ShipId;
115
- isOperator: boolean;
116
- };
117
73
  at: Date;
118
74
  actor: Actor;
119
75
  }): Result<{
@@ -127,69 +83,94 @@ export declare function termText(term: SelectorTerm): string;
127
83
  /** A copy of the rule, so what is kept never changes with what was given. */
128
84
  export declare function copyOfRule(rule: NetworkRule): NetworkRule;
129
85
  /**
130
- * Whether the plugin responds at `now` (decision 0035): its ship holds a
131
- * lease whose crew called the fleet no longer ago than it declared. Its last
132
- * call is the lease's last seen; nothing else acts on it, and nothing here
133
- * ends the lease.
86
+ * What a check is made against (decisions 0034, 0037): open while the
87
+ * fleet's own rules are none, all-to-all; the viewer reading as it was
88
+ * turned; otherwise the fleet's own rules, then every declarer's, merged at
89
+ * check time, each named by its place in its own list.
134
90
  */
135
- export declare function isNetworkPluginResponding(plugin: NetworkPlugin, crew: {
136
- lastSeenAt: Date | undefined;
137
- now: Date;
138
- }): boolean;
139
- /** The rules and built-in switches a send is checked against, and what the plugin declared when it is the reason. */
140
91
  export interface RulesInForce {
92
+ isOpen: boolean;
93
+ isViewerReadOn: boolean;
141
94
  rules: readonly NetworkRule[];
142
- builtIns: BuiltInSwitches;
143
- whilePluginUnavailable: Exclude<WhileUnavailable, 'open-all'> | null;
95
+ declared: readonly DeclaredNetworkRules[];
144
96
  }
145
- /**
146
- * The rules in force: the settings' own, unless the fleet's networking plugin
147
- * is not responding. Then what it declared applies: block-all leaves only
148
- * the built-in rules that are never off and the viewer reading, open-all
149
- * open on for every verb (all-to-all), keep-latest the rules and switches it
150
- * left last.
151
- */
152
- export declare function rulesInForce(settings: NetworkSettings, isPluginResponding: boolean): RulesInForce;
97
+ /** The rules in force for the fleet's own rules, applied or a draft's, beside the declared ones. */
98
+ export declare function rulesInForce(own: {
99
+ rules: readonly NetworkRule[] | null;
100
+ isViewerReadOn: boolean;
101
+ }, declared: readonly DeclaredNetworkRules[]): RulesInForce;
153
102
  /** A label value a ship carries, with the label it is of, so a term of any or the same value finds it. */
154
103
  export interface ReachingLabel {
155
104
  labelId: LabelId;
156
105
  valueId: LabelValueId;
157
106
  }
158
- /** A ship as a send's check sees it: its id and owner, for the owner exception, its kind, for the argo exception, and the label values it carries. */
107
+ /**
108
+ * A ship as a send's check sees it: its id and owner, for the owner exception,
109
+ * its kind, for the argo exception, whether argo connected it as a plugin,
110
+ * whether its owner is a person ship, for the installation's rule, and the
111
+ * label values it carries.
112
+ */
159
113
  export interface ReachingShip {
160
114
  id: ShipId;
161
115
  owner: ShipId | null;
162
116
  kind: ShipKind;
117
+ isConnectedPlugin: boolean;
118
+ /** Whether it is owned by a person ship, a person ship owning itself (decision 0045). */
119
+ isOwnedByPerson: boolean;
163
120
  labels: readonly ReachingLabel[];
164
121
  }
122
+ /**
123
+ * An account as a check sees it (decision 0057): the label values of `group`
124
+ * its token carries, and its person ship, which owns itself and through
125
+ * which the account owns: a selector's owner terms see the person ship as
126
+ * the account's owner.
127
+ */
128
+ export interface ReachingAccount {
129
+ kind: 'account';
130
+ personShipId: ShipId | null;
131
+ labels: readonly ReachingLabel[];
132
+ }
133
+ /** The installation as a check sees it: no labels, no owner; it manages person ships and what they own by its built-in rule. */
134
+ export interface ReachingInstallation {
135
+ kind: 'installation';
136
+ }
137
+ /** Whoever does the verb: a ship, an account or the installation (decision 0057). */
138
+ export type ReachingActor = ReachingShip | ReachingAccount | ReachingInstallation;
165
139
  /**
166
140
  * The rule that lets the sender do the verb to the recipient, or undefined
167
141
  * when none does. The built-in rules that are never off hold whatever the
168
142
  * rules: argo reaches every ship and every ship reaches argo, but reads argo
169
143
  * only by a rule, so argo's messages are not every ship's to read; an owner's
170
- * ship reaches the ships it owns (decision 0045), and a ship answers the sender of
171
- * a message it received. The viewer reads every ship while that is on, and
172
- * every ship reaches every ship by a verb while open is on for it. Otherwise
173
- * a rule of the verb must match the sender with its `from` and the recipient
174
- * with its `to`, named by its place in the list. The built-in rules come
175
- * first, in that order, as the rule list shows them.
144
+ * ship reaches the ships it owns (decision 0045), and an account the ships
145
+ * its person ship owns; a ship answers the sender of a message it received;
146
+ * a plugin argo connected reads every ship; and the installation manages
147
+ * person ships and the ships they own (decision 0020). The viewer reads
148
+ * every ship while that is on, and every actor reaches every ship by every
149
+ * verb while open is. Otherwise a rule of the verb must match the sender
150
+ * with its `from` and the recipient with its `to`: one of the fleet's own,
151
+ * named by its place in that list, or a declared one, named by its declarer
152
+ * and its place in the declarer's list. The built-in rules come first, in
153
+ * that order, as the rule list shows them.
176
154
  */
177
- export declare function reachRuleOf(settings: Pick<RulesInForce, 'rules' | 'builtIns'>, send: {
155
+ export declare function reachRuleOf(inForce: RulesInForce, send: {
178
156
  verb: NetworkVerb;
179
- sender: ReachingShip;
157
+ sender: ReachingActor;
180
158
  recipient: ReachingShip;
181
159
  isAnswerToSender: boolean;
182
160
  }): ReachRule | undefined;
183
- /** A built-in rule, or one of the settings' rules by its place in the list. */
161
+ /** A built-in rule, one of the fleet's own rules by its place in that list, or a declared rule by its declarer and its place in the declarer's list. */
184
162
  export type ReachRule = {
185
163
  builtIn: BuiltInRule;
186
164
  } | {
165
+ rule: number;
166
+ } | {
167
+ declared: LabelOwner;
187
168
  index: number;
188
169
  };
189
- /** Whether the settings let the sender do the verb to the recipient: some rule does (see reachRuleOf). */
190
- export declare function allowsReach(settings: Pick<RulesInForce, 'rules' | 'builtIns'>, send: {
170
+ /** Whether the rules in force let the sender do the verb to the recipient: some rule does (see reachRuleOf). */
171
+ export declare function allowsReach(inForce: RulesInForce, send: {
191
172
  verb: NetworkVerb;
192
- sender: ReachingShip;
173
+ sender: ReachingActor;
193
174
  recipient: ReachingShip;
194
175
  isAnswerToSender: boolean;
195
176
  }): boolean;
@@ -2,102 +2,50 @@
2
2
  * The fleet's network settings (decision 0034): which ships may send to,
3
3
  * read or manage which. A rule names its verb and says that the ships
4
4
  * matching one selector may do it to the ships matching another; allow-only,
5
- * no deny rules, no precedence. Beside its rules a fleet holds the switches
6
- * of the built-in rules that can be off, with a version that moves on every
7
- * change, so a refusal names the settings that refused it.
5
+ * no deny rules, no precedence. The fleet holds its own rules, set whole by
6
+ * applying a draft, or none for all-to-all, beside the switch of the viewer
7
+ * reading, with a version that moves on every change of what is in force, so
8
+ * a refusal names the settings that refused it.
8
9
  */
9
- import { ANY_LABEL_VALUE, NETWORK_RULES_MAX, NETWORK_VERBS, SAME_LABEL_VALUE, SHIP_LABELS_MAX, isOwnerTerm, } from '@aeolus-fleet/common';
10
+ import { ANY_LABEL_VALUE, NETWORK_RULES_MAX, SAME_LABEL_VALUE, SHIP_LABELS_MAX, isOwnerTerm, } from '@aeolus-fleet/common';
10
11
  import { refuse } from '../shared/errors.js';
11
12
  import { ok } from '../shared/result.js';
12
- /** Every built-in rule on: what a fleet starts with, and what no networking plugin leaves. */
13
- export const BUILT_INS_ON = { isViewerReadOn: true, open: { send: true, read: true, manage: true } };
14
- /** A fleet that never set rules: none, every built-in rule on, at version 0, without a plugin. */
13
+ /** A fleet that never set rules: none applied, the viewer reading on, at version 0. */
15
14
  export function noNetworkSettings(fleetId) {
16
- return { fleetId, rules: [], builtIns: BUILT_INS_ON, version: 0, plugin: null };
17
- }
18
- function refuseNotThePlugin() {
19
- return refuse('NOT_THE_NETWORK_PLUGIN', "Only the fleet's networking plugin does this (decision 0035)");
15
+ return { fleetId, rules: null, isViewerReadOn: true, version: 0 };
20
16
  }
21
17
  /**
22
- * The ship becomes the fleet's networking plugin, with what it declared, at
23
- * the next version, with NetworkPluginRegistered. A fleet without a plugin
24
- * has no rules, so the plugin starts from none until it supplies its own. The plugin may register again, replacing what it
25
- * declared; another ship is refused until it unregisters: one owner of the
26
- * rules, as a label has one.
18
+ * What breaks the decisions' limits on the fleet's own rules, said for the
19
+ * caller with its decision, or undefined when they keep them: at most 200,
20
+ * counted alone, beside the declared ones (decision 0037); each selector at
21
+ * most 20 terms, as a ship carries no more label values, each term once, and
22
+ * a term of the same value on a label on both sides of its rule, as it binds
23
+ * that label there. An id need not exist: an unknown one matches no ship, as
24
+ * in label selection. None, all-to-all, keeps them.
27
25
  */
28
- export function registerNetworkPlugin(current, change) {
29
- const { shipId, declaration } = change;
30
- if (current.plugin !== null && current.plugin.shipId !== shipId) {
31
- return refuse('NETWORK_PLUGIN_REGISTERED', 'The fleet already has a networking plugin; it unregisters first (decision 0035)');
26
+ export function invalidRules(rules) {
27
+ if (rules === null) {
28
+ return undefined;
32
29
  }
33
- const settings = {
34
- ...current,
35
- version: current.version + 1,
36
- plugin: { shipId, whileUnavailable: declaration.whileUnavailable, notRespondingAfterSeconds: declaration.notRespondingAfterSeconds },
37
- };
38
- return ok({
39
- settings,
40
- events: [
41
- {
42
- type: 'NetworkPluginRegistered',
43
- fleetId: current.fleetId,
44
- occurredAt: change.at,
45
- actor: change.actor,
46
- shipId,
47
- details: { version: settings.version, whileUnavailable: declaration.whileUnavailable, notRespondingAfterSeconds: declaration.notRespondingAfterSeconds },
48
- },
49
- ],
50
- });
51
- }
52
- /**
53
- * The fleet's plugin goes, and its rules with it, and the open rules are on
54
- * again: no plugin is all-to-all (decision 0035), at the next version, with
55
- * NetworkPluginUnregistered. The viewer reading stays as argo set it. Only
56
- * the plugin's own ship unregisters it; its retirement does too.
57
- */
58
- export function unregisterNetworkPlugin(current, change) {
59
- if (current.plugin?.shipId !== change.shipId) {
60
- return refuseNotThePlugin();
30
+ if (rules.length > NETWORK_RULES_MAX) {
31
+ return `A fleet holds at most ${String(NETWORK_RULES_MAX)} network rules of its own, beside the ones its ships declared (decision 0037)`;
61
32
  }
62
- const settings = { fleetId: current.fleetId, rules: [], builtIns: { ...current.builtIns, open: BUILT_INS_ON.open }, version: current.version + 1, plugin: null };
63
- return ok({
64
- settings,
65
- events: [
66
- {
67
- type: 'NetworkPluginUnregistered',
68
- fleetId: current.fleetId,
69
- occurredAt: change.at,
70
- actor: change.actor,
71
- shipId: change.shipId,
72
- details: { version: settings.version },
73
- },
74
- ],
75
- });
33
+ const invalid = rules.map(invalidRule).find((broken) => broken !== undefined);
34
+ return invalid === undefined ? undefined : `${invalid} (decision 0034)`;
76
35
  }
77
36
  /**
78
- * The fleet's rules from now on, replacing the ones it had, at the next
79
- * version, with NetworkRulesSet. The rules are within the decisions' limits:
80
- * at most 200 of argo's plus every rule the fleet's ships declared, which the
81
- * plugin adds to argo's when it supplies them (decision 0037); each selector
82
- * at most 20 terms, as a ship carries no more label values, each term once, and a term of the same value on a label on
83
- * both sides of its rule, as it binds that label there. An id need not
84
- * exist: an unknown one matches no ship, as in label selection. Only the
85
- * fleet's registered networking plugin sets them, argo included: rules exist
86
- * only through a plugin (decision 0035).
37
+ * The fleet's rules from now on, the draft's, replacing the ones it had, at
38
+ * the next version, with NetworkRulesSet naming how many, none for
39
+ * all-to-all. The caller saw the settings at `version`: once they moved, the
40
+ * draft's reach may differ from what the caller looked at, so the apply is
41
+ * refused and the draft kept.
87
42
  */
88
- export function setNetworkRules(current, change) {
89
- const { rules, declaredRules } = change;
90
- if (current.plugin?.shipId !== change.shipId) {
91
- return refuseNotThePlugin();
92
- }
93
- if (rules.length > NETWORK_RULES_MAX + declaredRules) {
94
- return refuse('INVALID_NETWORK_RULES', `A fleet holds at most ${String(NETWORK_RULES_MAX)} network rules of argo's plus the ${String(declaredRules)} its ships declared (decision 0037)`);
43
+ export function applyNetworkRules(current, change) {
44
+ const { rules } = change;
45
+ if (change.version !== current.version) {
46
+ return refuse('NETWORK_SETTINGS_CHANGED', `The network settings are at version ${String(current.version)} now, not ${String(change.version)}: look at the draft again before applying it`);
95
47
  }
96
- const invalid = rules.map(invalidRule).find((broken) => broken !== undefined);
97
- if (invalid !== undefined) {
98
- return refuse('INVALID_NETWORK_RULES', `${invalid} (decision 0034)`);
99
- }
100
- const settings = { ...current, rules: rules.map(copyOfRule), version: current.version + 1 };
48
+ const settings = { ...current, rules: rules === null ? null : rules.map(copyOfRule), version: current.version + 1 };
101
49
  return ok({
102
50
  settings,
103
51
  events: [
@@ -106,38 +54,35 @@ export function setNetworkRules(current, change) {
106
54
  fleetId: current.fleetId,
107
55
  occurredAt: change.at,
108
56
  actor: change.actor,
109
- details: { version: settings.version, rules: rules.length },
57
+ details: { version: settings.version, rules: rules === null ? null : rules.length },
110
58
  },
111
59
  ],
112
60
  });
113
61
  }
62
+ /** The settings at the next version, as the declared rules in force changed with them (decision 0037). */
63
+ export function withDeclaredRulesChanged(current) {
64
+ return { ...current, version: current.version + 1 };
65
+ }
114
66
  /**
115
67
  * A built-in rule turned on or off, as its own action (decision 0034): the
116
- * viewer reading by argo, open for one verb by the fleet's networking plugin.
117
- * argo, the owner and the answer are never off, so turning them is refused.
118
- * A change moves the version and writes BuiltInRuleChanged; a rule already
119
- * as asked changes nothing.
68
+ * viewer reading, by any actor holding fleet:network (decision 0053). argo,
69
+ * the owner, the answer, a connected plugin's reading and the installation's
70
+ * managing are never off, and open follows the applied rules, so turning them
71
+ * is refused. A change moves the version and writes BuiltInRuleChanged; a
72
+ * rule already as asked changes nothing.
120
73
  */
121
74
  export function setBuiltInRule(current, change) {
122
- const { input, caller } = change;
123
- if (input.rule === 'argo' || input.rule === 'owner' || input.rule === 'answer') {
124
- return refuse('BUILT_IN_RULE_FIXED', `The built-in rule ${input.rule} is never off (decision 0034)`);
75
+ const { input } = change;
76
+ if (input.rule === 'open') {
77
+ return refuse('BUILT_IN_RULE_FIXED', 'The built-in rule open is on exactly while the fleet has no rules applied (decision 0034)');
125
78
  }
126
- if (input.rule === 'viewerRead' && !caller.isOperator) {
127
- return refuse('NOT_THE_OPERATOR_SHIP', 'Only argo turns the viewer reading on or off (decision 0034)');
128
- }
129
- if (input.rule === 'open' && current.plugin?.shipId !== caller.shipId) {
130
- return refuseNotThePlugin();
79
+ if (input.rule !== 'viewerRead') {
80
+ return refuse('BUILT_IN_RULE_FIXED', `The built-in rule ${input.rule} is never off (decision 0034)`);
131
81
  }
132
- // The input names a verb for open and for open only (common's schema).
133
- const { verb } = input;
134
- const builtIns = input.rule === 'viewerRead' || verb === undefined
135
- ? { ...current.builtIns, isViewerReadOn: input.rule === 'viewerRead' ? input.isOn : current.builtIns.isViewerReadOn }
136
- : { ...current.builtIns, open: { ...current.builtIns.open, [verb]: input.isOn } };
137
- if (builtIns.isViewerReadOn === current.builtIns.isViewerReadOn && NETWORK_VERBS.every((verb) => builtIns.open[verb] === current.builtIns.open[verb])) {
82
+ if (input.isOn === current.isViewerReadOn) {
138
83
  return ok({ settings: current, events: [] });
139
84
  }
140
- const settings = { ...current, builtIns, version: current.version + 1 };
85
+ const settings = { ...current, isViewerReadOn: input.isOn, version: current.version + 1 };
141
86
  return ok({
142
87
  settings,
143
88
  events: [
@@ -146,7 +91,7 @@ export function setBuiltInRule(current, change) {
146
91
  fleetId: current.fleetId,
147
92
  occurredAt: change.at,
148
93
  actor: change.actor,
149
- details: { rule: input.rule, ...(verb === undefined ? {} : { verb }), isOn: input.isOn, version: settings.version },
94
+ details: { rule: input.rule, isOn: input.isOn, version: settings.version },
150
95
  },
151
96
  ],
152
97
  });
@@ -193,76 +138,82 @@ export function copyOfRule(rule) {
193
138
  function copyOfTerm(term) {
194
139
  return typeof term === 'string' ? term : { ...term };
195
140
  }
196
- const MILLISECONDS_PER_SECOND = 1000;
197
- /**
198
- * Whether the plugin responds at `now` (decision 0035): its ship holds a
199
- * lease whose crew called the fleet no longer ago than it declared. Its last
200
- * call is the lease's last seen; nothing else acts on it, and nothing here
201
- * ends the lease.
202
- */
203
- export function isNetworkPluginResponding(plugin, crew) {
204
- const { lastSeenAt, now } = crew;
205
- return lastSeenAt !== undefined && now.getTime() - lastSeenAt.getTime() <= plugin.notRespondingAfterSeconds * MILLISECONDS_PER_SECOND;
141
+ /** The rules in force for the fleet's own rules, applied or a draft's, beside the declared ones. */
142
+ export function rulesInForce(own, declared) {
143
+ return { isOpen: own.rules === null, isViewerReadOn: own.isViewerReadOn, rules: own.rules ?? [], declared };
206
144
  }
207
- /**
208
- * The rules in force: the settings' own, unless the fleet's networking plugin
209
- * is not responding. Then what it declared applies: block-all leaves only
210
- * the built-in rules that are never off and the viewer reading, open-all
211
- * open on for every verb (all-to-all), keep-latest the rules and switches it
212
- * left last.
213
- */
214
- export function rulesInForce(settings, isPluginResponding) {
215
- const { plugin, rules, builtIns } = settings;
216
- if (plugin === null || isPluginResponding) {
217
- return { rules, builtIns, whilePluginUnavailable: null };
145
+ function selectedOf(actor) {
146
+ if (actor.kind === 'account') {
147
+ return { owner: actor.personShipId, labels: actor.labels };
218
148
  }
219
- switch (plugin.whileUnavailable) {
220
- case 'block-all':
221
- return { rules: [], builtIns: { ...builtIns, open: { send: false, read: false, manage: false } }, whilePluginUnavailable: 'block-all' };
222
- case 'open-all':
223
- return { rules, builtIns: { ...builtIns, open: BUILT_INS_ON.open }, whilePluginUnavailable: null };
224
- case 'keep-latest':
225
- return { rules, builtIns, whilePluginUnavailable: 'keep-latest' };
149
+ return actor.kind === 'installation' ? { owner: null, labels: [] } : { owner: actor.owner, labels: actor.labels };
150
+ }
151
+ /** The ship the actor owns ships as: a ship itself, an account its person ship; the installation none. */
152
+ function owningShipOf(actor) {
153
+ if (actor.kind === 'account') {
154
+ return actor.personShipId;
226
155
  }
156
+ return actor.kind === 'installation' ? null : actor.id;
227
157
  }
228
158
  /**
229
159
  * The rule that lets the sender do the verb to the recipient, or undefined
230
160
  * when none does. The built-in rules that are never off hold whatever the
231
161
  * rules: argo reaches every ship and every ship reaches argo, but reads argo
232
162
  * only by a rule, so argo's messages are not every ship's to read; an owner's
233
- * ship reaches the ships it owns (decision 0045), and a ship answers the sender of
234
- * a message it received. The viewer reads every ship while that is on, and
235
- * every ship reaches every ship by a verb while open is on for it. Otherwise
236
- * a rule of the verb must match the sender with its `from` and the recipient
237
- * with its `to`, named by its place in the list. The built-in rules come
238
- * first, in that order, as the rule list shows them.
163
+ * ship reaches the ships it owns (decision 0045), and an account the ships
164
+ * its person ship owns; a ship answers the sender of a message it received;
165
+ * a plugin argo connected reads every ship; and the installation manages
166
+ * person ships and the ships they own (decision 0020). The viewer reads
167
+ * every ship while that is on, and every actor reaches every ship by every
168
+ * verb while open is. Otherwise a rule of the verb must match the sender
169
+ * with its `from` and the recipient with its `to`: one of the fleet's own,
170
+ * named by its place in that list, or a declared one, named by its declarer
171
+ * and its place in the declarer's list. The built-in rules come first, in
172
+ * that order, as the rule list shows them.
239
173
  */
240
- export function reachRuleOf(settings, send) {
174
+ export function reachRuleOf(inForce, send) {
241
175
  const { verb, sender, recipient, isAnswerToSender } = send;
242
- const { rules, builtIns } = settings;
243
176
  if (sender.kind === 'operator' || (recipient.kind === 'operator' && verb !== 'read')) {
244
177
  return { builtIn: 'argo' };
245
178
  }
246
- if (recipient.owner === sender.id) {
179
+ const owningShip = owningShipOf(sender);
180
+ if (owningShip !== null && recipient.owner === owningShip) {
247
181
  return { builtIn: 'owner' };
248
182
  }
249
183
  if (verb === 'send' && isAnswerToSender) {
250
184
  return { builtIn: 'answer' };
251
185
  }
252
- if (verb === 'read' && sender.kind === 'viewer' && builtIns.isViewerReadOn) {
186
+ if (verb === 'read' && sender.kind !== 'account' && sender.kind !== 'installation' && sender.isConnectedPlugin) {
187
+ return { builtIn: 'pluginRead' };
188
+ }
189
+ if (verb === 'read' && sender.kind === 'viewer' && inForce.isViewerReadOn) {
253
190
  return { builtIn: 'viewerRead' };
254
191
  }
255
- if (builtIns.open[verb]) {
192
+ if (verb === 'manage' && sender.kind === 'installation' && (recipient.kind === 'person' || recipient.isOwnedByPerson)) {
193
+ return { builtIn: 'installation' };
194
+ }
195
+ if (inForce.isOpen) {
256
196
  return { builtIn: 'open' };
257
197
  }
258
- const index = rules.findIndex((rule) => rule.verb === verb && matches(rule.from, { ship: sender, otherSide: recipient }) && matches(rule.to, { ship: recipient, otherSide: sender }));
259
- return index === -1 ? undefined : { index };
198
+ const [from, to] = [selectedOf(sender), selectedOf(recipient)];
199
+ const allows = (rule) => rule.verb === verb && matches(rule.from, { actor: from, otherSide: to }) && matches(rule.to, { actor: to, otherSide: from });
200
+ const index = inForce.rules.findIndex(allows);
201
+ if (index !== -1) {
202
+ return { rule: index };
203
+ }
204
+ for (const { declarer, rules } of inForce.declared) {
205
+ const declaredIndex = rules.findIndex(allows);
206
+ if (declaredIndex !== -1) {
207
+ return { declared: declarer, index: declaredIndex };
208
+ }
209
+ }
210
+ return undefined;
260
211
  }
261
- /** Whether the settings let the sender do the verb to the recipient: some rule does (see reachRuleOf). */
262
- export function allowsReach(settings, send) {
263
- return reachRuleOf(settings, send) !== undefined;
212
+ /** Whether the rules in force let the sender do the verb to the recipient: some rule does (see reachRuleOf). */
213
+ export function allowsReach(inForce, send) {
214
+ return reachRuleOf(inForce, send) !== undefined;
264
215
  }
265
- /** A ship matches a selector when every term of it holds, combined with AND. */
216
+ /** An actor matches a selector when every term of it holds, combined with AND. */
266
217
  function matches(selector, sides) {
267
218
  return selector.every((term) => holds(term, sides));
268
219
  }
@@ -275,7 +226,7 @@ function matches(selector, sides) {
275
226
  * same owner as the other side.
276
227
  */
277
228
  function holds(term, sides) {
278
- const { ship, otherSide } = sides;
229
+ const { actor: ship, otherSide } = sides;
279
230
  if (typeof term === 'string') {
280
231
  return ship.labels.some((label) => label.valueId === term);
281
232
  }