@aeolus-fleet/core 0.29.2 → 0.30.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 (236) hide show
  1. package/README.md +21 -0
  2. package/dist/adapters/http/server.js +5 -0
  3. package/dist/adapters/http/server.js.map +1 -1
  4. package/dist/adapters/prisma/generated/browser.d.ts +24 -0
  5. package/dist/adapters/prisma/generated/client.d.ts +24 -0
  6. package/dist/adapters/prisma/generated/commonInputTypes.d.ts +30 -0
  7. package/dist/adapters/prisma/generated/internal/class.d.ts +33 -0
  8. package/dist/adapters/prisma/generated/internal/class.js +4 -4
  9. package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
  10. package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +262 -1
  11. package/dist/adapters/prisma/generated/internal/prismaNamespace.js +33 -0
  12. package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
  13. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +36 -0
  14. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +33 -0
  15. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
  16. package/dist/adapters/prisma/generated/models/Fleet.d.ts +993 -0
  17. package/dist/adapters/prisma/generated/models/HealthSnapshot.d.ts +1282 -0
  18. package/dist/adapters/prisma/generated/models/HealthSnapshot.js +2 -0
  19. package/dist/adapters/prisma/generated/models/HealthSnapshot.js.map +1 -0
  20. package/dist/adapters/prisma/generated/models/HealthSnapshotDelivery.d.ts +1470 -0
  21. package/dist/adapters/prisma/generated/models/HealthSnapshotDelivery.js +2 -0
  22. package/dist/adapters/prisma/generated/models/HealthSnapshotDelivery.js.map +1 -0
  23. package/dist/adapters/prisma/generated/models/MessageDay.d.ts +1193 -0
  24. package/dist/adapters/prisma/generated/models/MessageDay.js +2 -0
  25. package/dist/adapters/prisma/generated/models/MessageDay.js.map +1 -0
  26. package/dist/adapters/prisma/generated/models.d.ts +3 -0
  27. package/dist/adapters/prisma/health-snapshots.d.ts +30 -0
  28. package/dist/adapters/prisma/health-snapshots.js +250 -0
  29. package/dist/adapters/prisma/health-snapshots.js.map +1 -0
  30. package/dist/adapters/prisma/health.d.ts +58 -1
  31. package/dist/adapters/prisma/health.js +157 -65
  32. package/dist/adapters/prisma/health.js.map +1 -1
  33. package/dist/adapters/prisma/history.d.ts +19 -0
  34. package/dist/adapters/prisma/history.js +167 -69
  35. package/dist/adapters/prisma/history.js.map +1 -1
  36. package/dist/adapters/prisma/installation.d.ts +5 -1
  37. package/dist/adapters/prisma/installation.js +27 -11
  38. package/dist/adapters/prisma/installation.js.map +1 -1
  39. package/dist/adapters/prisma/messaging.d.ts +12 -1
  40. package/dist/adapters/prisma/messaging.js +33 -1
  41. package/dist/adapters/prisma/messaging.js.map +1 -1
  42. package/dist/adapters/prisma/network.js +4 -3
  43. package/dist/adapters/prisma/network.js.map +1 -1
  44. package/dist/adapters/prisma/registry.d.ts +26 -7
  45. package/dist/adapters/prisma/registry.js +291 -12
  46. package/dist/adapters/prisma/registry.js.map +1 -1
  47. package/dist/adapters/prisma/ship-counts.d.ts +34 -0
  48. package/dist/adapters/prisma/ship-counts.js +116 -0
  49. package/dist/adapters/prisma/ship-counts.js.map +1 -0
  50. package/dist/adapters/prisma/telemetry.d.ts +5 -0
  51. package/dist/adapters/prisma/telemetry.js +40 -0
  52. package/dist/adapters/prisma/telemetry.js.map +1 -0
  53. package/dist/adapters/prisma/unit-of-work.d.ts +13 -3
  54. package/dist/adapters/prisma/unit-of-work.js +13 -1
  55. package/dist/adapters/prisma/unit-of-work.js.map +1 -1
  56. package/dist/adapters/telemetry/calls.d.ts +14 -0
  57. package/dist/adapters/telemetry/calls.js +48 -0
  58. package/dist/adapters/telemetry/calls.js.map +1 -0
  59. package/dist/adapters/telemetry/requests.d.ts +8 -0
  60. package/dist/adapters/telemetry/requests.js +28 -0
  61. package/dist/adapters/telemetry/requests.js.map +1 -0
  62. package/dist/adapters/telemetry/sdk.d.ts +2 -0
  63. package/dist/adapters/telemetry/sdk.js +40 -0
  64. package/dist/adapters/telemetry/sdk.js.map +1 -0
  65. package/dist/adapters/telemetry/telemetry.d.ts +21 -0
  66. package/dist/adapters/telemetry/telemetry.js +16 -0
  67. package/dist/adapters/telemetry/telemetry.js.map +1 -0
  68. package/dist/adapters/trpc/context.d.ts +28 -0
  69. package/dist/adapters/trpc/fleet.d.ts +721 -243
  70. package/dist/adapters/trpc/fleet.js +171 -44
  71. package/dist/adapters/trpc/fleet.js.map +1 -1
  72. package/dist/adapters/trpc/health.d.ts +42 -1
  73. package/dist/adapters/trpc/health.js +18 -10
  74. package/dist/adapters/trpc/health.js.map +1 -1
  75. package/dist/adapters/trpc/installation.d.ts +2 -2
  76. package/dist/adapters/trpc/router.d.ts +694 -233
  77. package/dist/adapters/trpc/ship-contract.js +3 -0
  78. package/dist/adapters/trpc/ship-contract.js.map +1 -1
  79. package/dist/adapters/trpc/ship.d.ts +6 -4
  80. package/dist/adapters/trpc/ship.js +5 -2
  81. package/dist/adapters/trpc/ship.js.map +1 -1
  82. package/dist/adapters/trpc/trpc.d.ts +8 -0
  83. package/dist/adapters/trpc/trpc.js +35 -1
  84. package/dist/adapters/trpc/trpc.js.map +1 -1
  85. package/dist/app.d.ts +2 -1
  86. package/dist/app.js +11 -3
  87. package/dist/app.js.map +1 -1
  88. package/dist/domain/messaging/check-inbox.d.ts +12 -4
  89. package/dist/domain/messaging/check-inbox.js +16 -7
  90. package/dist/domain/messaging/check-inbox.js.map +1 -1
  91. package/dist/domain/messaging/daily-message-limit.d.ts +1 -1
  92. package/dist/domain/messaging/daily-message-limit.js +1 -1
  93. package/dist/domain/messaging/daily-message-limit.js.map +1 -1
  94. package/dist/domain/messaging/ports.d.ts +2 -2
  95. package/dist/domain/registry/check-network-rules-file.d.ts +38 -0
  96. package/dist/domain/registry/check-network-rules-file.js +50 -0
  97. package/dist/domain/registry/check-network-rules-file.js.map +1 -0
  98. package/dist/domain/registry/count-ships.d.ts +18 -0
  99. package/dist/domain/registry/count-ships.js +10 -0
  100. package/dist/domain/registry/count-ships.js.map +1 -0
  101. package/dist/domain/registry/export-network-rules.d.ts +27 -0
  102. package/dist/domain/registry/export-network-rules.js +55 -0
  103. package/dist/domain/registry/export-network-rules.js.map +1 -0
  104. package/dist/domain/registry/found-fleet.d.ts +5 -1
  105. package/dist/domain/registry/found-fleet.js +5 -1
  106. package/dist/domain/registry/found-fleet.js.map +1 -1
  107. package/dist/domain/registry/get-installation-fleet.d.ts +3 -1
  108. package/dist/domain/registry/get-installation-fleet.js +2 -2
  109. package/dist/domain/registry/get-installation-fleet.js.map +1 -1
  110. package/dist/domain/registry/import-network-rules.d.ts +40 -0
  111. package/dist/domain/registry/import-network-rules.js +98 -0
  112. package/dist/domain/registry/import-network-rules.js.map +1 -0
  113. package/dist/domain/registry/label.d.ts +2 -6
  114. package/dist/domain/registry/label.js +1 -9
  115. package/dist/domain/registry/label.js.map +1 -1
  116. package/dist/domain/registry/list-fleet.d.ts +21 -10
  117. package/dist/domain/registry/list-fleet.js +20 -11
  118. package/dist/domain/registry/list-fleet.js.map +1 -1
  119. package/dist/domain/registry/list-installation-fleets.d.ts +3 -1
  120. package/dist/domain/registry/list-installation-fleets.js +2 -2
  121. package/dist/domain/registry/list-installation-fleets.js.map +1 -1
  122. package/dist/domain/registry/list-labels.d.ts +16 -5
  123. package/dist/domain/registry/list-labels.js +12 -3
  124. package/dist/domain/registry/list-labels.js.map +1 -1
  125. package/dist/domain/registry/list-ship-types.d.ts +18 -0
  126. package/dist/domain/registry/list-ship-types.js +12 -0
  127. package/dist/domain/registry/list-ship-types.js.map +1 -0
  128. package/dist/domain/registry/network-rules-file.d.ts +91 -0
  129. package/dist/domain/registry/network-rules-file.js +292 -0
  130. package/dist/domain/registry/network-rules-file.js.map +1 -0
  131. package/dist/domain/registry/network-settings.d.ts +15 -0
  132. package/dist/domain/registry/network-settings.js +18 -13
  133. package/dist/domain/registry/network-settings.js.map +1 -1
  134. package/dist/domain/registry/ports.d.ts +45 -4
  135. package/dist/domain/registry/read-listed-ship.d.ts +21 -0
  136. package/dist/domain/registry/read-listed-ship.js +22 -0
  137. package/dist/domain/registry/read-listed-ship.js.map +1 -0
  138. package/dist/domain/registry/read-reach-refusals.d.ts +8 -3
  139. package/dist/domain/registry/read-reach-refusals.js +6 -7
  140. package/dist/domain/registry/read-reach-refusals.js.map +1 -1
  141. package/dist/domain/registry/ship-counts.d.ts +28 -0
  142. package/dist/domain/registry/ship-counts.js +35 -0
  143. package/dist/domain/registry/ship-counts.js.map +1 -0
  144. package/dist/domain/registry/ship-order.d.ts +29 -0
  145. package/dist/domain/registry/ship-order.js +54 -0
  146. package/dist/domain/registry/ship-order.js.map +1 -0
  147. package/dist/domain/shared/close-health-snapshots.d.ts +24 -0
  148. package/dist/domain/shared/close-health-snapshots.js +67 -0
  149. package/dist/domain/shared/close-health-snapshots.js.map +1 -0
  150. package/dist/domain/shared/count-open-inbox.d.ts +20 -0
  151. package/dist/domain/shared/count-open-inbox.js +26 -0
  152. package/dist/domain/shared/count-open-inbox.js.map +1 -0
  153. package/dist/domain/shared/errors.d.ts +1 -1
  154. package/dist/domain/shared/errors.js.map +1 -1
  155. package/dist/domain/shared/health-fold.d.ts +51 -0
  156. package/dist/domain/shared/health-fold.js +105 -0
  157. package/dist/domain/shared/health-fold.js.map +1 -0
  158. package/dist/domain/shared/health-read.d.ts +35 -0
  159. package/dist/domain/shared/health-read.js +113 -0
  160. package/dist/domain/shared/health-read.js.map +1 -0
  161. package/dist/domain/shared/health-snapshot.d.ts +222 -0
  162. package/dist/domain/shared/health-snapshot.js +204 -0
  163. package/dist/domain/shared/health-snapshot.js.map +1 -0
  164. package/dist/domain/shared/health.d.ts +3 -13
  165. package/dist/domain/shared/health.js +6 -15
  166. package/dist/domain/shared/health.js.map +1 -1
  167. package/dist/domain/shared/history.d.ts +35 -10
  168. package/dist/domain/shared/history.js.map +1 -1
  169. package/dist/domain/shared/page.d.ts +24 -0
  170. package/dist/domain/shared/page.js +10 -0
  171. package/dist/domain/shared/page.js.map +1 -0
  172. package/dist/domain/shared/read-acknowledged.d.ts +19 -0
  173. package/dist/domain/shared/read-acknowledged.js +19 -0
  174. package/dist/domain/shared/read-acknowledged.js.map +1 -0
  175. package/dist/domain/shared/read-fleet-limits.d.ts +2 -2
  176. package/dist/domain/shared/read-fleet-limits.js +1 -1
  177. package/dist/domain/shared/read-fleet-limits.js.map +1 -1
  178. package/dist/domain/shared/read-health.d.ts +4 -2
  179. package/dist/domain/shared/read-health.js +3 -5
  180. package/dist/domain/shared/read-health.js.map +1 -1
  181. package/dist/domain/shared/read-inbox-message.d.ts +21 -0
  182. package/dist/domain/shared/read-inbox-message.js +21 -0
  183. package/dist/domain/shared/read-inbox-message.js.map +1 -0
  184. package/dist/domain/shared/read-inbox-withdrawals.d.ts +22 -0
  185. package/dist/domain/shared/read-inbox-withdrawals.js +20 -0
  186. package/dist/domain/shared/read-inbox-withdrawals.js.map +1 -0
  187. package/dist/domain/shared/read-inbox.d.ts +18 -3
  188. package/dist/domain/shared/read-inbox.js +24 -10
  189. package/dist/domain/shared/read-inbox.js.map +1 -1
  190. package/dist/domain/shared/read-needs-attention.d.ts +16 -7
  191. package/dist/domain/shared/read-needs-attention.js +14 -8
  192. package/dist/domain/shared/read-needs-attention.js.map +1 -1
  193. package/dist/domain/shared/read-ship-messages.d.ts +7 -6
  194. package/dist/domain/shared/read-ship-messages.js +18 -16
  195. package/dist/domain/shared/read-ship-messages.js.map +1 -1
  196. package/dist/domain/shared/read-ship-timeline.d.ts +6 -5
  197. package/dist/domain/shared/read-ship-timeline.js +6 -7
  198. package/dist/domain/shared/read-ship-timeline.js.map +1 -1
  199. package/dist/domain/shared/read-stuck-count.d.ts +23 -0
  200. package/dist/domain/shared/read-stuck-count.js +20 -0
  201. package/dist/domain/shared/read-stuck-count.js.map +1 -0
  202. package/dist/domain/shared/read-stuck-history.d.ts +21 -0
  203. package/dist/domain/shared/read-stuck-history.js +18 -0
  204. package/dist/domain/shared/read-stuck-history.js.map +1 -0
  205. package/dist/domain/shared/read-stuck-summary.d.ts +44 -0
  206. package/dist/domain/shared/read-stuck-summary.js +44 -0
  207. package/dist/domain/shared/read-stuck-summary.js.map +1 -0
  208. package/dist/domain/shared/read-stuck.d.ts +41 -0
  209. package/dist/domain/shared/read-stuck.js +43 -0
  210. package/dist/domain/shared/read-stuck.js.map +1 -0
  211. package/dist/domain/shared/stuck.d.ts +4 -1
  212. package/dist/domain/shared/stuck.js +4 -2
  213. package/dist/domain/shared/stuck.js.map +1 -1
  214. package/dist/domain/shared/wait-buckets.d.ts +15 -0
  215. package/dist/domain/shared/wait-buckets.js +54 -0
  216. package/dist/domain/shared/wait-buckets.js.map +1 -0
  217. package/dist/start.d.ts +2 -1
  218. package/dist/start.js +8 -2
  219. package/dist/start.js.map +1 -1
  220. package/dist/wiring.d.ts +31 -1
  221. package/dist/wiring.js +40 -5
  222. package/dist/wiring.js.map +1 -1
  223. package/package.json +10 -2
  224. package/src/adapters/prisma/migrations/20261022130000_message_days/migration.sql +20 -0
  225. package/src/adapters/prisma/migrations/20261022130100_messages_fleet_time_index/migration.sql +3 -0
  226. package/src/adapters/prisma/migrations/20261022140000_health_snapshots/migration.sql +41 -0
  227. package/src/adapters/prisma/migrations/20261023090000_timeline_page_indexes/migration.sql +7 -0
  228. package/src/adapters/prisma/migrations/20261023090100_messages_page_indexes/migration.sql +7 -0
  229. package/src/adapters/prisma/migrations/20261023090200_inbox_page_index/migration.sql +3 -0
  230. package/src/adapters/prisma/migrations/20261023090300_reach_refusals_page_index/migration.sql +4 -0
  231. package/src/adapters/prisma/migrations/20261023090400_messages_question_id_index/migration.sql +5 -0
  232. package/src/adapters/prisma/migrations/20261023210000_health_snapshot_acknowledged_waits/migration.sql +15 -0
  233. package/src/adapters/prisma/migrations/20261024090000_ship_listing_indexes/migration.sql +13 -0
  234. package/src/adapters/prisma/migrations/20261024120000_ship_listing_every_status_indexes/migration.sql +5 -0
  235. package/src/adapters/prisma/migrations/20261024150000_ship_kind_listing_index/migration.sql +2 -0
  236. package/src/adapters/prisma/schema.prisma +88 -5
@@ -0,0 +1,20 @@
1
+ import { PAGE_SIZE_DEFAULT } from '@aeolus-fleet/common';
2
+ import { inboxReadOf } from './read-inbox.js';
3
+ /**
4
+ * Use case: a page of the messages to the caller's own inbox, argo's for the
5
+ * console, that withdraw or replace a question (decision 0038), oldest first,
6
+ * found by the question's uuid: what makes the question stale, whatever their
7
+ * filter. Only those the caller's read reach reads (decision 0034). The
8
+ * caller's scope (fleet:read) is checked before this runs.
9
+ */
10
+ export function createReadInboxWithdrawals(deps) {
11
+ return async (caller, { questionId, cursor, limit = PAGE_SIZE_DEFAULT }) => {
12
+ const inbox = await inboxReadOf(deps, caller);
13
+ if (!inbox) {
14
+ return { items: [], nextCursor: null };
15
+ }
16
+ const page = await deps.history.inboxWithdrawals(caller.fleetId, { shipId: inbox.shipId, questionId, cursor, limit });
17
+ return { items: page.items.filter(inbox.reads), nextCursor: page.nextCursor };
18
+ };
19
+ }
20
+ //# sourceMappingURL=read-inbox-withdrawals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-inbox-withdrawals.js","sourceRoot":"","sources":["../../../src/domain/shared/read-inbox-withdrawals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,sBAAsB,CAAC;AAM1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAuG;IAChJ,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAG,iBAAiB,EAAE,EAAE,EAAE;QACzE,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACtH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;IAChF,CAAC,CAAC;AACJ,CAAC"}
@@ -1,12 +1,27 @@
1
- import type { InboxFilter } from '@aeolus-fleet/common';
1
+ import { type DeliveryId, type InboxFilter, type ShipId } from '@aeolus-fleet/common';
2
2
  import { type ReadReachOf, type ShipRepository } from '../registry/public.js';
3
3
  import { type Caller } from './caller.js';
4
4
  import type { InboxEntry, ShipHistory } from './history.js';
5
+ import type { Page } from './page.js';
5
6
  export type ReadInbox = (caller: Caller, input: {
6
7
  filter: InboxFilter;
7
- }) => Promise<InboxEntry[]>;
8
+ cursor?: DeliveryId;
9
+ limit?: number;
10
+ }) => Promise<Page<InboxEntry, DeliveryId>>;
8
11
  /**
9
- * Use case: the caller's own inbox, for the operator inbox of argo
12
+ * Whose inbox the caller reads and which of its messages: a ship its own,
13
+ * whole; a viewer session or an account argo's, by its read reach. Undefined
14
+ * when the fleet has no argo.
15
+ */
16
+ export declare function inboxReadOf(deps: {
17
+ ships: Pick<ShipRepository, 'findOperatorShip'>;
18
+ readReach: ReadReachOf;
19
+ }, caller: Caller): Promise<{
20
+ shipId: ShipId;
21
+ reads: (entry: InboxEntry) => boolean;
22
+ } | undefined>;
23
+ /**
24
+ * Use case: a page of the caller's own inbox, for the operator inbox of argo
10
25
  * (docs/blueprint.md, "Inbox"): the messages addressed to it that the filter
11
26
  * keeps (open, done or all), newest first, each with when it was read, when
12
27
  * and by which reply it was done, and its whole payload. Messages to its type
@@ -1,7 +1,24 @@
1
+ import { PAGE_SIZE_DEFAULT } from '@aeolus-fleet/common';
1
2
  import { readsMessage } from '../registry/public.js';
2
3
  import { isShipCaller } from './caller.js';
3
4
  /**
4
- * Use case: the caller's own inbox, for the operator inbox of argo
5
+ * Whose inbox the caller reads and which of its messages: a ship its own,
6
+ * whole; a viewer session or an account argo's, by its read reach. Undefined
7
+ * when the fleet has no argo.
8
+ */
9
+ export async function inboxReadOf(deps, caller) {
10
+ if (isShipCaller(caller) && caller.kind !== 'viewer') {
11
+ return { shipId: caller.shipId, reads: () => true };
12
+ }
13
+ const argo = await deps.ships.findOperatorShip(caller.fleetId);
14
+ if (!argo) {
15
+ return undefined;
16
+ }
17
+ const reach = await deps.readReach(caller);
18
+ return { shipId: argo.id, reads: (entry) => readsMessage(reach, { senderId: entry.message.sender.id, recipient: { kind: 'ship', shipId: argo.id }, claimedBy: null }) };
19
+ }
20
+ /**
21
+ * Use case: a page of the caller's own inbox, for the operator inbox of argo
5
22
  * (docs/blueprint.md, "Inbox"): the messages addressed to it that the filter
6
23
  * keeps (open, done or all), newest first, each with when it was read, when
7
24
  * and by which reply it was done, and its whole payload. Messages to its type
@@ -13,16 +30,13 @@ import { isShipCaller } from './caller.js';
13
30
  * argo's. The caller's scope (fleet:read) is checked before this runs.
14
31
  */
15
32
  export function createReadInbox(deps) {
16
- return async (caller, { filter }) => {
17
- if (isShipCaller(caller) && caller.kind !== 'viewer') {
18
- return deps.history.inbox(caller.fleetId, { shipId: caller.shipId, filter });
19
- }
20
- const argo = await deps.ships.findOperatorShip(caller.fleetId);
21
- if (!argo) {
22
- return [];
33
+ return async (caller, { filter, cursor, limit = PAGE_SIZE_DEFAULT }) => {
34
+ const inbox = await inboxReadOf(deps, caller);
35
+ if (!inbox) {
36
+ return { items: [], nextCursor: null };
23
37
  }
24
- const [inbox, reach] = await Promise.all([deps.history.inbox(caller.fleetId, { shipId: argo.id, filter }), deps.readReach(caller)]);
25
- return inbox.filter((entry) => readsMessage(reach, { senderId: entry.message.sender.id, recipient: { kind: 'ship', shipId: argo.id }, claimedBy: null }));
38
+ const page = await deps.history.inbox(caller.fleetId, { shipId: inbox.shipId, filter, cursor, limit });
39
+ return { items: page.items.filter(inbox.reads), nextCursor: page.nextCursor };
26
40
  };
27
41
  }
28
42
  //# sourceMappingURL=read-inbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-inbox.js","sourceRoot":"","sources":["../../../src/domain/shared/read-inbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAyC,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAKxD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,IAAuG;IACrI,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAClC,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpI,OAAO,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CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC1K,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,IAAuG;IACrI,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,iBAAiB,EAAE,EAAE,EAAE;QACrE,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACvG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;IAChF,CAAC,CAAC;AACJ,CAAC"}
@@ -1,13 +1,22 @@
1
+ import { type DeliveryId, type ShipId } from '@aeolus-fleet/common';
1
2
  import { type ReadReachOf } from '../registry/public.js';
2
3
  import type { Caller } from './caller.js';
3
- import { type ShipHistory, type ShownNeedsAttentionEntry } from './history.js';
4
- export type ReadNeedsAttention = (caller: Caller) => Promise<ShownNeedsAttentionEntry[]>;
4
+ import { type NeedsAttentionState, type ShipHistory, type ShownNeedsAttentionEntry } from './history.js';
5
+ import type { Page } from './page.js';
6
+ export type ReadNeedsAttention = (caller: Caller, input: {
7
+ shipId?: ShipId;
8
+ state?: NeedsAttentionState;
9
+ cursor?: DeliveryId;
10
+ limit?: number;
11
+ }) => Promise<Page<ShownNeedsAttentionEntry, DeliveryId>>;
5
12
  /**
6
- * Use case: Needs attention, every undeliverable or not handled delivery of
7
- * the caller's fleet, oldest first, each with its state and whole message,
8
- * telling whether it is a ping, for the operator to resend or dismiss. Abandoned deliveries are never listed: they stay in the
9
- * timelines only. Only the deliveries whose message the caller reads
10
- * (decision 0034). The caller's scope (fleet:read) is checked before this runs.
13
+ * Use case: a page of Needs attention, the undeliverable or not handled
14
+ * deliveries of the caller's fleet, or of one ship for its page, oldest
15
+ * first, each with its state and whole message, telling whether it is a
16
+ * ping, for the operator to resend or dismiss. Abandoned deliveries are never
17
+ * listed: they stay in the timelines only. Only the deliveries whose message
18
+ * the caller reads (decision 0034). The caller's scope (fleet:read) is
19
+ * checked before this runs.
11
20
  */
12
21
  export declare function createReadNeedsAttention(deps: {
13
22
  history: ShipHistory;
@@ -1,16 +1,22 @@
1
+ import { PAGE_SIZE_DEFAULT } from '@aeolus-fleet/common';
1
2
  import { readsMessage } from '../registry/public.js';
2
3
  import { partiesOf, withPing } from './history.js';
3
4
  /**
4
- * Use case: Needs attention, every undeliverable or not handled delivery of
5
- * the caller's fleet, oldest first, each with its state and whole message,
6
- * telling whether it is a ping, for the operator to resend or dismiss. Abandoned deliveries are never listed: they stay in the
7
- * timelines only. Only the deliveries whose message the caller reads
8
- * (decision 0034). The caller's scope (fleet:read) is checked before this runs.
5
+ * Use case: a page of Needs attention, the undeliverable or not handled
6
+ * deliveries of the caller's fleet, or of one ship for its page, oldest
7
+ * first, each with its state and whole message, telling whether it is a
8
+ * ping, for the operator to resend or dismiss. Abandoned deliveries are never
9
+ * listed: they stay in the timelines only. Only the deliveries whose message
10
+ * the caller reads (decision 0034). The caller's scope (fleet:read) is
11
+ * checked before this runs.
9
12
  */
10
13
  export function createReadNeedsAttention(deps) {
11
- return async (caller) => {
12
- const reach = await deps.readReach(caller);
13
- return (await deps.history.needsAttention(caller.fleetId)).filter((entry) => readsMessage(reach, partiesOf(entry.message, entry.ship))).map((entry) => ({ ...entry, message: withPing(entry.message) }));
14
+ return async (caller, { shipId, state, cursor, limit = PAGE_SIZE_DEFAULT }) => {
15
+ const [page, reach] = await Promise.all([deps.history.needsAttention(caller.fleetId, { shipId, state, cursor, limit }), deps.readReach(caller)]);
16
+ return {
17
+ items: page.items.filter((entry) => readsMessage(reach, partiesOf(entry.message, entry.ship))).map((entry) => ({ ...entry, message: withPing(entry.message) })),
18
+ nextCursor: page.nextCursor,
19
+ };
14
20
  };
15
21
  }
16
22
  //# sourceMappingURL=read-needs-attention.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-needs-attention.js","sourceRoot":"","sources":["../../../src/domain/shared/read-needs-attention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAmD,MAAM,cAAc,CAAC;AAIpG;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAsD;IAC7F,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3M,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"read-needs-attention.js","sourceRoot":"","sources":["../../../src/domain/shared/read-needs-attention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgC,MAAM,sBAAsB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAoB,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAA6E,MAAM,cAAc,CAAC;AAQ9H;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAsD;IAC7F,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,iBAAiB,EAAE,EAAE,EAAE;QAC5E,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjJ,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC/J,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,11 +1,10 @@
1
- import type { ShipId } from '@aeolus-fleet/common';
1
+ import { type MessageId, type ShipId } from '@aeolus-fleet/common';
2
2
  import type { Caller } from './caller.js';
3
3
  import { type DomainError } from './errors.js';
4
4
  import { type ReadReachOf } from '../registry/public.js';
5
5
  import { type HistoryMessage, type ShipHistory } from './history.js';
6
+ import type { Page } from './page.js';
6
7
  import { type Result } from './result.js';
7
- /** The most messages the ship page lists: the newest ones. */
8
- export declare const MESSAGES_LIMIT = 200;
9
8
  /** How much of a payload the list shows. */
10
9
  export declare const PREVIEW_LENGTH = 120;
11
10
  /** A message as the ship page lists it: its payload cut to a preview. */
@@ -18,12 +17,14 @@ export type ListedMessage = Omit<HistoryMessage, 'payload' | 'delivery'> & {
18
17
  };
19
18
  export type ReadShipMessages = (caller: Caller, input: {
20
19
  shipId: ShipId;
21
- }) => Promise<Result<ListedMessage[], DomainError<'SHIP_NOT_FOUND'>>>;
20
+ cursor?: MessageId;
21
+ limit?: number;
22
+ }) => Promise<Result<Page<ListedMessage, MessageId>, DomainError<'SHIP_NOT_FOUND'>>>;
22
23
  /** The start of a payload on one line: whitespace runs become one space. */
23
24
  export declare function previewOf(payload: string): string;
24
25
  /**
25
- * Use case: the messages a ship sent, was sent, or claimed as a ship of their
26
- * type, newest first, each with its delivery as it stands. A message to a type
26
+ * Use case: a page of the messages a ship sent, was sent, or claimed as a ship
27
+ * of their type, newest first, each with its delivery as it stands. A message to a type
27
28
  * shows on the page of each ship that claimed it, never on every ship of the
28
29
  * type. Only the messages the caller reads, through their sender or their
29
30
  * recipient (decision 0034). The caller's scope (fleet:read) is checked
@@ -1,9 +1,8 @@
1
+ import { PAGE_SIZE_DEFAULT } from '@aeolus-fleet/common';
1
2
  import { refuse } from './errors.js';
2
3
  import { readsMessage } from '../registry/public.js';
3
4
  import { partiesOf } from './history.js';
4
5
  import { ok } from './result.js';
5
- /** The most messages the ship page lists: the newest ones. */
6
- export const MESSAGES_LIMIT = 200;
7
6
  /** How much of a payload the list shows. */
8
7
  export const PREVIEW_LENGTH = 120;
9
8
  /** The start of a payload on one line: whitespace runs become one space. */
@@ -11,30 +10,33 @@ export function previewOf(payload) {
11
10
  return payload.replace(/\s+/g, ' ').trim().slice(0, PREVIEW_LENGTH);
12
11
  }
13
12
  /**
14
- * Use case: the messages a ship sent, was sent, or claimed as a ship of their
15
- * type, newest first, each with its delivery as it stands. A message to a type
13
+ * Use case: a page of the messages a ship sent, was sent, or claimed as a ship
14
+ * of their type, newest first, each with its delivery as it stands. A message to a type
16
15
  * shows on the page of each ship that claimed it, never on every ship of the
17
16
  * type. Only the messages the caller reads, through their sender or their
18
17
  * recipient (decision 0034). The caller's scope (fleet:read) is checked
19
18
  * before this runs.
20
19
  */
21
20
  export function createReadShipMessages(deps) {
22
- return async (caller, { shipId }) => {
23
- const messages = await deps.history.messages(caller.fleetId, { shipId, limit: MESSAGES_LIMIT });
21
+ return async (caller, { shipId, cursor, limit = PAGE_SIZE_DEFAULT }) => {
22
+ const messages = await deps.history.messages(caller.fleetId, { shipId, cursor, limit });
24
23
  if (!messages) {
25
24
  return refuse('SHIP_NOT_FOUND', `No ship ${shipId} in this fleet`);
26
25
  }
27
26
  const reach = await deps.readReach(caller);
28
- return ok(messages.filter((message) => readsMessage(reach, partiesOf(message, message.delivery.claimedBy))).map(({ payload, delivery, ...message }) => ({
29
- ...message,
30
- preview: previewOf(payload),
31
- delivery: {
32
- id: delivery.id,
33
- state: delivery.state,
34
- claimedBy: delivery.claimedBy,
35
- isPulled: delivery.state === 'handed' && delivery.handOverNumber === null,
36
- },
37
- })));
27
+ return ok({
28
+ items: messages.items.filter((message) => readsMessage(reach, partiesOf(message, message.delivery.claimedBy))).map(({ payload, delivery, ...message }) => ({
29
+ ...message,
30
+ preview: previewOf(payload),
31
+ delivery: {
32
+ id: delivery.id,
33
+ state: delivery.state,
34
+ claimedBy: delivery.claimedBy,
35
+ isPulled: delivery.state === 'handed' && delivery.handOverNumber === null,
36
+ },
37
+ })),
38
+ nextCursor: messages.nextCursor,
39
+ });
38
40
  };
39
41
  }
40
42
  //# sourceMappingURL=read-ship-messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-ship-messages.js","sourceRoot":"","sources":["../../../src/domain/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AAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,MAAM,CAAC,gBAAgB,EAAE,WAAW,MAAM,gBAAgB,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,EAAE,CAAC;YACR,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;gBACzJ,GAAG,OAAO;gBACV,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC;gBAC3B,QAAQ,EAAE;oBACR,EAAE,EAAE,QAAQ,CAAC,EAAE;oBACf,KAAK,EAAE,QAAQ,CAAC,KAAK;oBACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;oBAC7B,QAAQ,EAAE,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,cAAc,KAAK,IAAI;iBAC1E;aACF,CAAC,CAAC;YACH,UAAU,EAAE,QAAQ,CAAC,UAAU;SAChC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1,16 +1,17 @@
1
- import type { ShipId } from '@aeolus-fleet/common';
1
+ import { type EventId, type ShipId } from '@aeolus-fleet/common';
2
2
  import type { Caller } from './caller.js';
3
3
  import { type DomainError } from './errors.js';
4
4
  import { type ReadReachOf } from '../registry/public.js';
5
5
  import { type ShipHistory, type ShownTimelineEntry } from './history.js';
6
+ import type { Page } from './page.js';
6
7
  import { type Result } from './result.js';
7
- /** The most events a timeline shows: the newest ones. */
8
- export declare const TIMELINE_LIMIT = 200;
9
8
  export type ReadShipTimeline = (caller: Caller, input: {
10
9
  shipId: ShipId;
11
- }) => Promise<Result<ShownTimelineEntry[], DomainError<'SHIP_NOT_FOUND'>>>;
10
+ cursor?: EventId;
11
+ limit?: number;
12
+ }) => Promise<Result<Page<ShownTimelineEntry, EventId>, DomainError<'SHIP_NOT_FOUND'>>>;
12
13
  /**
13
- * Use case: every change to a ship, newest first: the events naming it and
14
+ * Use case: a page of every change to a ship, newest first: the events naming it and
14
15
  * the ones it caused, such as the messages it sent, each message telling
15
16
  * whether it is a ping. Only the events the caller reads (decision 0034): a
16
17
  * message's through the message, its ship standing for who claimed one to a
@@ -1,25 +1,24 @@
1
+ import { PAGE_SIZE_DEFAULT } from '@aeolus-fleet/common';
1
2
  import { refuse } from './errors.js';
2
3
  import { readsEvent } from '../registry/public.js';
3
4
  import { partiesOf, withPing } from './history.js';
4
5
  import { ok } from './result.js';
5
- /** The most events a timeline shows: the newest ones. */
6
- export const TIMELINE_LIMIT = 200;
7
6
  /**
8
- * Use case: every change to a ship, newest first: the events naming it and
7
+ * Use case: a page of every change to a ship, newest first: the events naming it and
9
8
  * the ones it caused, such as the messages it sent, each message telling
10
9
  * whether it is a ping. Only the events the caller reads (decision 0034): a
11
10
  * message's through the message, its ship standing for who claimed one to a
12
11
  * type. The caller's scope (fleet:read) is checked before this runs.
13
12
  */
14
13
  export function createReadShipTimeline(deps) {
15
- return async (caller, { shipId }) => {
16
- const timeline = await deps.history.timeline(caller.fleetId, { shipId, limit: TIMELINE_LIMIT });
14
+ return async (caller, { shipId, cursor, limit = PAGE_SIZE_DEFAULT }) => {
15
+ const timeline = await deps.history.timeline(caller.fleetId, { shipId, cursor, limit });
17
16
  if (!timeline) {
18
17
  return refuse('SHIP_NOT_FOUND', `No ship ${shipId} in this fleet`);
19
18
  }
20
19
  const reach = await deps.readReach(caller);
21
- const read = timeline.filter((entry) => readsEvent(reach, { type: entry.type, shipId: entry.ship?.id ?? null, message: entry.message && partiesOf(entry.message, entry.ship) }));
22
- return ok(read.map((entry) => ({ ...entry, message: entry.message === null ? null : withPing(entry.message) })));
20
+ const read = timeline.items.filter((entry) => readsEvent(reach, { type: entry.type, shipId: entry.ship?.id ?? null, message: entry.message && partiesOf(entry.message, entry.ship) }));
21
+ return ok({ items: read.map((entry) => ({ ...entry, message: entry.message === null ? null : withPing(entry.message) })), nextCursor: timeline.nextCursor });
23
22
  };
24
23
  }
25
24
  //# sourceMappingURL=read-ship-timeline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-ship-timeline.js","sourceRoot":"","sources":["../../../src/domain/shared/read-ship-timeline.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,UAAU,EAAoB,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAA6C,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,EAAE,EAAe,MAAM,aAAa,CAAC;AAE9C,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAOlC;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAsD;IAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,MAAM,CAAC,gBAAgB,EAAE,WAAW,MAAM,gBAAgB,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,C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C,CAAC;QACxF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,MAAM,CAAC,gBAAgB,EAAE,WAAW,MAAM,gBAAgB,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACvL,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC/J,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ReadReachOf } from '../registry/public.js';
2
+ import type { Caller } from './caller.js';
3
+ import type { Clock } from './clock.js';
4
+ import type { HealthSnapshots } from './health-snapshot.js';
5
+ import type { HealthRecords } from './health.js';
6
+ /** How many deliveries are stuck now, and since when the oldest of them waits; none when nothing is stuck. */
7
+ export interface StuckNowCount {
8
+ count: number;
9
+ oldestSince: Date | null;
10
+ }
11
+ export type ReadStuckCount = (caller: Caller) => Promise<StuckNowCount>;
12
+ /**
13
+ * Use case: how many deliveries of the caller's fleet are stuck now, of every
14
+ * cause and place, and since when the oldest waits, for the navigation and the
15
+ * overview; counting only the deliveries whose message the caller reads
16
+ * (decision 0034). The caller's scope (fleet:read) is checked before this runs.
17
+ */
18
+ export declare function createReadStuckCount(deps: {
19
+ health: HealthRecords;
20
+ snapshots: HealthSnapshots;
21
+ clock: Clock;
22
+ readReach: ReadReachOf;
23
+ }): ReadStuckCount;
@@ -0,0 +1,20 @@
1
+ import { readStuckNowOf } from './health-read.js';
2
+ /**
3
+ * Use case: how many deliveries of the caller's fleet are stuck now, of every
4
+ * cause and place, and since when the oldest waits, for the navigation and the
5
+ * overview; counting only the deliveries whose message the caller reads
6
+ * (decision 0034). The caller's scope (fleet:read) is checked before this runs.
7
+ */
8
+ export function createReadStuckCount(deps) {
9
+ return async (caller) => {
10
+ const reach = await deps.readReach(caller);
11
+ const stuck = await readStuckNowOf({ records: deps.health, snapshots: deps.snapshots }, {
12
+ fleetId: caller.fleetId,
13
+ now: deps.clock.now(),
14
+ reach,
15
+ });
16
+ const [oldest] = stuck.map((delivery) => delivery.since).toSorted((first, second) => first.getTime() - second.getTime());
17
+ return { count: stuck.length, oldestSince: oldest ?? null };
18
+ };
19
+ }
20
+ //# sourceMappingURL=read-stuck-count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-stuck-count.js","sourceRoot":"","sources":["../../../src/domain/shared/read-stuck-count.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYlD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAiG;IACpI,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE;YACtF,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACrB,KAAK;SACN,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACzH,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ReadReachOf } from '../registry/public.js';
2
+ import type { Caller } from './caller.js';
3
+ import type { Clock } from './clock.js';
4
+ import type { HealthSnapshots } from './health-snapshot.js';
5
+ import type { HealthRecords } from './health.js';
6
+ export type ReadStuckHistory = (caller: Caller) => Promise<{
7
+ at: Date;
8
+ count: number;
9
+ }[]>;
10
+ /**
11
+ * Use case: how many deliveries of the caller's fleet were stuck at each hour of
12
+ * the last 7 days, oldest first, the last one now, for the Health page's trend;
13
+ * counting only the deliveries whose message the caller reads (decision
14
+ * 0034). The caller's scope (fleet:read) is checked before this runs.
15
+ */
16
+ export declare function createReadStuckHistory(deps: {
17
+ health: HealthRecords;
18
+ snapshots: HealthSnapshots;
19
+ clock: Clock;
20
+ readReach: ReadReachOf;
21
+ }): ReadStuckHistory;
@@ -0,0 +1,18 @@
1
+ import { readStuckHistoryOf } from './health-read.js';
2
+ /**
3
+ * Use case: how many deliveries of the caller's fleet were stuck at each hour of
4
+ * the last 7 days, oldest first, the last one now, for the Health page's trend;
5
+ * counting only the deliveries whose message the caller reads (decision
6
+ * 0034). The caller's scope (fleet:read) is checked before this runs.
7
+ */
8
+ export function createReadStuckHistory(deps) {
9
+ return async (caller) => {
10
+ const reach = await deps.readReach(caller);
11
+ return readStuckHistoryOf({ records: deps.health, snapshots: deps.snapshots }, {
12
+ fleetId: caller.fleetId,
13
+ now: deps.clock.now(),
14
+ reach,
15
+ });
16
+ };
17
+ }
18
+ //# sourceMappingURL=read-stuck-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-stuck-history.js","sourceRoot":"","sources":["../../../src/domain/shared/read-stuck-history.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAMtD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAiG;IACtI,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE;YAC7E,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACrB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { type ShipId, type StuckCause } from '@aeolus-fleet/common';
2
+ import type { ReadReachOf } from '../registry/public.js';
3
+ import type { Caller } from './caller.js';
4
+ import type { Clock } from './clock.js';
5
+ import type { HealthSnapshots } from './health-snapshot.js';
6
+ import type { HealthRecords, StuckPlaceHealth } from './health.js';
7
+ /** How many deliveries are stuck now and in how many places, in all, per cause and per machine. */
8
+ export interface StuckSummary {
9
+ count: number;
10
+ places: number;
11
+ /** Since when the oldest stuck delivery waits; none when nothing is stuck. */
12
+ oldestSince: Date | null;
13
+ /** Each cause with stuck deliveries, in the causes' order. */
14
+ byCause: {
15
+ cause: StuckCause;
16
+ count: number;
17
+ places: number;
18
+ }[];
19
+ /** Each machine behind a ship deliveries are stuck at, by name. */
20
+ byMachine: {
21
+ machine: {
22
+ id: ShipId;
23
+ name: string;
24
+ };
25
+ count: number;
26
+ }[];
27
+ }
28
+ export type ReadStuckSummary = (caller: Caller) => Promise<StuckSummary>;
29
+ /** The summary of the stuck places. */
30
+ export declare function stuckSummaryOf(places: readonly StuckPlaceHealth[]): StuckSummary;
31
+ /**
32
+ * Use case: how many deliveries of the caller's fleet are stuck now and in how
33
+ * many places, in all, per cause and per machine, for the Health page's
34
+ * verdict, cause cards, machines panel and cause page; counting only the
35
+ * deliveries whose message the caller reads, and a machine only behind a ship
36
+ * the caller reads (decision 0034). The caller's scope (fleet:read) is checked
37
+ * before this runs.
38
+ */
39
+ export declare function createReadStuckSummary(deps: {
40
+ health: HealthRecords;
41
+ snapshots: HealthSnapshots;
42
+ clock: Clock;
43
+ readReach: ReadReachOf;
44
+ }): ReadStuckSummary;
@@ -0,0 +1,44 @@
1
+ import { STUCK_CAUSES } from '@aeolus-fleet/common';
2
+ import { readStuckPlacesOf } from './health-read.js';
3
+ /** The summary of the stuck places. */
4
+ export function stuckSummaryOf(places) {
5
+ const [oldest] = places.map((place) => place.oldestSince).toSorted((first, second) => first.getTime() - second.getTime());
6
+ const byMachine = new Map();
7
+ for (const { place, count } of places) {
8
+ const machine = place.kind === 'ship' ? place.machine : null;
9
+ if (machine !== null) {
10
+ const counted = byMachine.get(machine.id);
11
+ byMachine.set(machine.id, { machine: { id: machine.id, name: machine.name }, count: (counted?.count ?? 0) + count });
12
+ }
13
+ }
14
+ return {
15
+ count: places.reduce((sum, place) => sum + place.count, 0),
16
+ places: places.length,
17
+ oldestSince: oldest ?? null,
18
+ byCause: STUCK_CAUSES.flatMap((cause) => {
19
+ const ofCause = places.filter((place) => place.cause === cause);
20
+ return ofCause.length === 0 ? [] : [{ cause, count: ofCause.reduce((sum, place) => sum + place.count, 0), places: ofCause.length }];
21
+ }),
22
+ byMachine: [...byMachine.values()].toSorted((first, second) => first.machine.name.localeCompare(second.machine.name) || first.machine.id.localeCompare(second.machine.id)),
23
+ };
24
+ }
25
+ /**
26
+ * Use case: how many deliveries of the caller's fleet are stuck now and in how
27
+ * many places, in all, per cause and per machine, for the Health page's
28
+ * verdict, cause cards, machines panel and cause page; counting only the
29
+ * deliveries whose message the caller reads, and a machine only behind a ship
30
+ * the caller reads (decision 0034). The caller's scope (fleet:read) is checked
31
+ * before this runs.
32
+ */
33
+ export function createReadStuckSummary(deps) {
34
+ return async (caller) => {
35
+ const reach = await deps.readReach(caller);
36
+ const places = await readStuckPlacesOf({ records: deps.health, snapshots: deps.snapshots }, {
37
+ fleetId: caller.fleetId,
38
+ now: deps.clock.now(),
39
+ reach,
40
+ });
41
+ return stuckSummaryOf(places);
42
+ };
43
+ }
44
+ //# sourceMappingURL=read-stuck-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-stuck-summary.js","sourceRoot":"","sources":["../../../src/domain/shared/read-stuck-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgC,MAAM,sBAAsB,CAAC;AAKlF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkBrD,uCAAuC;AACvC,MAAM,UAAU,cAAc,CAAC,MAAmC;IAChE,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1H,MAAM,SAAS,GAAG,IAAI,GAAG,EAA6C,CAAC;IACvE,KAAK,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,C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,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KAC3K,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAiG;IACtI,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE;YAC1F,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACrB,KAAK;SACN,CAAC,CAAC;QACH,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type DeliveryId, type StuckCause } from '@aeolus-fleet/common';
2
+ import type { ReadReachOf } from '../registry/public.js';
3
+ import type { Caller } from './caller.js';
4
+ import type { Clock } from './clock.js';
5
+ import type { HealthSnapshots } from './health-snapshot.js';
6
+ import type { StuckPlaceHealth, HealthRecords } from './health.js';
7
+ /** Where a page of stuck places ends: the oldest delivery of its last place, as places are ordered. */
8
+ export interface StuckCursor {
9
+ oldestSince: Date;
10
+ deliveryId: DeliveryId;
11
+ }
12
+ /** A page of stuck places, and the cursor the next page starts after; null on the last page. */
13
+ export interface StuckPage {
14
+ items: StuckPlaceHealth[];
15
+ nextCursor: StuckCursor | null;
16
+ }
17
+ export type ReadStuck = (caller: Caller, input: {
18
+ cause?: StuckCause;
19
+ cursor?: StuckCursor;
20
+ limit?: number;
21
+ }) => Promise<StuckPage>;
22
+ /** The page of the places after the cursor, of the cause when asked. */
23
+ export declare function stuckPageOf(places: readonly StuckPlaceHealth[], page: {
24
+ cause?: StuckCause;
25
+ cursor?: StuckCursor;
26
+ limit?: number;
27
+ }): StuckPage;
28
+ /**
29
+ * Use case: a page of the deliveries of the caller's fleet stuck now by cause
30
+ * and place, the oldest waiting first, after the cursor and of one cause when
31
+ * asked, each ship by name with the machine behind it only
32
+ * when the caller reads the ship, for the Health page's causes and machines;
33
+ * counting only the deliveries whose message the caller reads (decision
34
+ * 0034). The caller's scope (fleet:read) is checked before this runs.
35
+ */
36
+ export declare function createReadStuck(deps: {
37
+ health: HealthRecords;
38
+ snapshots: HealthSnapshots;
39
+ clock: Clock;
40
+ readReach: ReadReachOf;
41
+ }): ReadStuck;