@aeolus-fleet/core 0.24.1 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +5 -5
  2. package/dist/adapters/prisma/generated/browser.d.ts +15 -5
  3. package/dist/adapters/prisma/generated/client.d.ts +15 -5
  4. package/dist/adapters/prisma/generated/commonInputTypes.d.ts +60 -0
  5. package/dist/adapters/prisma/generated/enums.d.ts +15 -1
  6. package/dist/adapters/prisma/generated/enums.js +13 -1
  7. package/dist/adapters/prisma/generated/enums.js.map +1 -1
  8. package/dist/adapters/prisma/generated/internal/class.d.ts +11 -0
  9. package/dist/adapters/prisma/generated/internal/class.js +4 -4
  10. package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
  11. package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +109 -1
  12. package/dist/adapters/prisma/generated/internal/prismaNamespace.js +16 -0
  13. package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
  14. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +17 -0
  15. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +16 -0
  16. package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
  17. package/dist/adapters/prisma/generated/models/CrewRequest.d.ts +3 -2
  18. package/dist/adapters/prisma/generated/models/Delivery.d.ts +304 -4
  19. package/dist/adapters/prisma/generated/models/Fleet.d.ts +267 -0
  20. package/dist/adapters/prisma/generated/models/Lease.d.ts +332 -1
  21. package/dist/adapters/prisma/generated/models/OverdueDelivery.d.ts +1687 -0
  22. package/dist/adapters/prisma/generated/models/OverdueDelivery.js +2 -0
  23. package/dist/adapters/prisma/generated/models/OverdueDelivery.js.map +1 -0
  24. package/dist/adapters/prisma/generated/models/Ship.d.ts +271 -0
  25. package/dist/adapters/prisma/generated/models.d.ts +1 -0
  26. package/dist/adapters/prisma/history.js +231 -46
  27. package/dist/adapters/prisma/history.js.map +1 -1
  28. package/dist/adapters/prisma/installation.js +30 -1
  29. package/dist/adapters/prisma/installation.js.map +1 -1
  30. package/dist/adapters/prisma/messaging.js +11 -7
  31. package/dist/adapters/prisma/messaging.js.map +1 -1
  32. package/dist/adapters/prisma/overdue.d.ts +4 -0
  33. package/dist/adapters/prisma/overdue.js +63 -0
  34. package/dist/adapters/prisma/overdue.js.map +1 -0
  35. package/dist/adapters/prisma/registry.js +32 -7
  36. package/dist/adapters/prisma/registry.js.map +1 -1
  37. package/dist/adapters/prisma/rows.d.ts +12 -1
  38. package/dist/adapters/prisma/rows.js +46 -1
  39. package/dist/adapters/prisma/rows.js.map +1 -1
  40. package/dist/adapters/prisma/unit-of-work.d.ts +2 -1
  41. package/dist/adapters/prisma/unit-of-work.js +2 -0
  42. package/dist/adapters/prisma/unit-of-work.js.map +1 -1
  43. package/dist/adapters/trpc/context.d.ts +16 -0
  44. package/dist/adapters/trpc/fleet.d.ts +233 -15
  45. package/dist/adapters/trpc/fleet.js +52 -8
  46. package/dist/adapters/trpc/fleet.js.map +1 -1
  47. package/dist/adapters/trpc/installation.d.ts +14 -0
  48. package/dist/adapters/trpc/installation.js +7 -1
  49. package/dist/adapters/trpc/installation.js.map +1 -1
  50. package/dist/adapters/trpc/router.d.ts +301 -9
  51. package/dist/adapters/trpc/ship-protocol.js +2 -2
  52. package/dist/adapters/trpc/ship-protocol.js.map +1 -1
  53. package/dist/adapters/trpc/ship.d.ts +87 -0
  54. package/dist/adapters/trpc/ship.js +96 -1
  55. package/dist/adapters/trpc/ship.js.map +1 -1
  56. package/dist/adapters/trpc/starting-prompt-text.d.ts +1 -1
  57. package/dist/adapters/trpc/starting-prompt-text.js +22 -25
  58. package/dist/adapters/trpc/starting-prompt-text.js.map +1 -1
  59. package/dist/adapters/trpc/trpc.js +5 -0
  60. package/dist/adapters/trpc/trpc.js.map +1 -1
  61. package/dist/app.d.ts +4 -2
  62. package/dist/app.js +21 -9
  63. package/dist/app.js.map +1 -1
  64. package/dist/domain/messaging/delivery.d.ts +88 -28
  65. package/dist/domain/messaging/delivery.js +213 -39
  66. package/dist/domain/messaging/delivery.js.map +1 -1
  67. package/dist/domain/messaging/dismiss-delivery.d.ts +1 -1
  68. package/dist/domain/messaging/dismiss-delivery.js +1 -1
  69. package/dist/domain/messaging/hand-over-delivery.d.ts +38 -0
  70. package/dist/domain/messaging/hand-over-delivery.js +46 -0
  71. package/dist/domain/messaging/hand-over-delivery.js.map +1 -0
  72. package/dist/domain/messaging/message.d.ts +12 -1
  73. package/dist/domain/messaging/message.js +2 -0
  74. package/dist/domain/messaging/message.js.map +1 -1
  75. package/dist/domain/messaging/overdue.d.ts +60 -0
  76. package/dist/domain/messaging/overdue.js +52 -0
  77. package/dist/domain/messaging/overdue.js.map +1 -0
  78. package/dist/domain/messaging/ports.d.ts +20 -0
  79. package/dist/domain/messaging/public.d.ts +1 -0
  80. package/dist/domain/messaging/public.js +2 -0
  81. package/dist/domain/messaging/public.js.map +1 -0
  82. package/dist/domain/messaging/push-receive-deliveries.d.ts +48 -0
  83. package/dist/domain/messaging/push-receive-deliveries.js +70 -0
  84. package/dist/domain/messaging/push-receive-deliveries.js.map +1 -0
  85. package/dist/domain/messaging/receive-deliveries.d.ts +39 -6
  86. package/dist/domain/messaging/receive-deliveries.js +80 -50
  87. package/dist/domain/messaging/receive-deliveries.js.map +1 -1
  88. package/dist/domain/messaging/report-handled.d.ts +22 -0
  89. package/dist/domain/messaging/report-handled.js +13 -0
  90. package/dist/domain/messaging/report-handled.js.map +1 -0
  91. package/dist/domain/messaging/report-not-handled.d.ts +22 -0
  92. package/dist/domain/messaging/report-not-handled.js +13 -0
  93. package/dist/domain/messaging/report-not-handled.js.map +1 -0
  94. package/dist/domain/messaging/report-turn-end.d.ts +29 -0
  95. package/dist/domain/messaging/report-turn-end.js +36 -0
  96. package/dist/domain/messaging/report-turn-end.js.map +1 -0
  97. package/dist/domain/messaging/resend-delivery.d.ts +1 -1
  98. package/dist/domain/messaging/resend-delivery.js +1 -1
  99. package/dist/domain/messaging/tell-overdue-deliveries.d.ts +25 -0
  100. package/dist/domain/messaging/tell-overdue-deliveries.js +30 -0
  101. package/dist/domain/messaging/tell-overdue-deliveries.js.map +1 -0
  102. package/dist/domain/registry/crew-request.d.ts +12 -6
  103. package/dist/domain/registry/crew-request.js +21 -3
  104. package/dist/domain/registry/crew-request.js.map +1 -1
  105. package/dist/domain/registry/installation-fleet.d.ts +3 -2
  106. package/dist/domain/registry/installation-fleet.js.map +1 -1
  107. package/dist/domain/registry/leases.d.ts +26 -0
  108. package/dist/domain/registry/leases.js +26 -1
  109. package/dist/domain/registry/leases.js.map +1 -1
  110. package/dist/domain/registry/ping-status.d.ts +2 -2
  111. package/dist/domain/registry/ping-status.js +7 -4
  112. package/dist/domain/registry/ping-status.js.map +1 -1
  113. package/dist/domain/registry/ports.d.ts +40 -0
  114. package/dist/domain/registry/public.d.ts +2 -2
  115. package/dist/domain/registry/public.js +1 -1
  116. package/dist/domain/registry/public.js.map +1 -1
  117. package/dist/domain/registry/report-turn.d.ts +28 -0
  118. package/dist/domain/registry/report-turn.js +28 -0
  119. package/dist/domain/registry/report-turn.js.map +1 -0
  120. package/dist/domain/registry/request-crew.d.ts +6 -2
  121. package/dist/domain/registry/request-crew.js +14 -3
  122. package/dist/domain/registry/request-crew.js.map +1 -1
  123. package/dist/domain/registry/turn.d.ts +25 -0
  124. package/dist/domain/registry/turn.js +30 -0
  125. package/dist/domain/registry/turn.js.map +1 -0
  126. package/dist/domain/shared/delivery-way.d.ts +83 -0
  127. package/dist/domain/shared/delivery-way.js +89 -0
  128. package/dist/domain/shared/delivery-way.js.map +1 -0
  129. package/dist/domain/shared/errors.d.ts +1 -1
  130. package/dist/domain/shared/errors.js.map +1 -1
  131. package/dist/domain/shared/history.d.ts +116 -19
  132. package/dist/domain/shared/history.js +1 -1
  133. package/dist/domain/shared/history.js.map +1 -1
  134. package/dist/domain/shared/read-message.d.ts +7 -3
  135. package/dist/domain/shared/read-message.js +7 -4
  136. package/dist/domain/shared/read-message.js.map +1 -1
  137. package/dist/domain/shared/read-needs-attention.d.ts +5 -5
  138. package/dist/domain/shared/read-needs-attention.js +4 -4
  139. package/dist/domain/shared/read-needs-attention.js.map +1 -1
  140. package/dist/domain/shared/read-no-ship-can-take.d.ts +13 -0
  141. package/dist/domain/shared/read-no-ship-can-take.js +12 -0
  142. package/dist/domain/shared/read-no-ship-can-take.js.map +1 -0
  143. package/dist/domain/shared/read-overdue.d.ts +13 -0
  144. package/dist/domain/shared/read-overdue.js +12 -0
  145. package/dist/domain/shared/read-overdue.js.map +1 -0
  146. package/dist/domain/shared/read-ship-messages.d.ts +4 -1
  147. package/dist/domain/shared/read-ship-messages.js +6 -1
  148. package/dist/domain/shared/read-ship-messages.js.map +1 -1
  149. package/dist/domain/shared/read-ship-way.d.ts +41 -0
  150. package/dist/domain/shared/read-ship-way.js +39 -0
  151. package/dist/domain/shared/read-ship-way.js.map +1 -0
  152. package/dist/repeating-pass.d.ts +15 -0
  153. package/dist/repeating-pass.js +31 -0
  154. package/dist/repeating-pass.js.map +1 -0
  155. package/dist/wiring.d.ts +19 -0
  156. package/dist/wiring.js +25 -0
  157. package/dist/wiring.js.map +1 -1
  158. package/package.json +2 -2
  159. package/src/adapters/prisma/migrations/20261012190000_delivery_handed/migration.sql +11 -0
  160. package/src/adapters/prisma/migrations/20261012210000_push_receive/migration.sql +7 -0
  161. package/src/adapters/prisma/migrations/20261013090000_handled/migration.sql +6 -0
  162. package/src/adapters/prisma/migrations/20261013100000_turn/migration.sql +6 -0
  163. package/src/adapters/prisma/migrations/20261013120000_overdue/migration.sql +28 -0
  164. package/src/adapters/prisma/migrations/20261013140000_delivery_state_index/migration.sql +4 -0
  165. package/src/adapters/prisma/schema.prisma +69 -6
@@ -1,12 +1,15 @@
1
1
  import { refuse } from '../shared/errors.js';
2
2
  import { recordEvent, shipActor } from '../shared/events.js';
3
3
  import { ok } from '../shared/result.js';
4
- import { requestCrew } from './crew-request.js';
4
+ import { machineLabelsOf, requestCrew } from './crew-request.js';
5
5
  /**
6
6
  * Use case: a requester asks that a ship be kept crewed, with these settings,
7
7
  * replacing any request the ship holds. Its scope (fleet:manage) is checked
8
8
  * before this runs. In one unit of work, locking the ship first, as a retire
9
- * does, so a retire and a request never cross: the request and CrewRequested.
9
+ * does, so a retire and a request never cross; then holding the label of
10
+ * each machine label, as an assignment does, so a change of its values waits
11
+ * and the request never names a value it removed: the request and
12
+ * CrewRequested.
10
13
  */
11
14
  export function createRequestCrew(deps) {
12
15
  return (caller, input) => deps.uow.run(async (tx) => {
@@ -15,7 +18,15 @@ export function createRequestCrew(deps) {
15
18
  return refuse('SHIP_NOT_FOUND', `Ship ${input.shipId} does not exist`);
16
19
  }
17
20
  const current = await tx.crewRequests.find(caller.fleetId, ship.id);
18
- const requested = requestCrew({ ship, current }, { settings: input.settings, at: deps.clock.now(), actor: shipActor(caller.shipId) });
21
+ const labelValues = new Set();
22
+ for (const valueId of machineLabelsOf(input.settings)) {
23
+ const label = await tx.labels.findByValueForShare(caller.fleetId, valueId);
24
+ // Read after the lock: a change of values that came first may have removed the value.
25
+ if (label?.values.some((value) => value.id === valueId)) {
26
+ labelValues.add(valueId);
27
+ }
28
+ }
29
+ const requested = requestCrew({ ship, current, labelValues }, { settings: input.settings, at: deps.clock.now(), actor: shipActor(caller.shipId) });
19
30
  if (!requested.isOk) {
20
31
  return requested;
21
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"request-crew.js","sourceRoot":"","sources":["../../../src/domain/registry/request-crew.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAezE;;;;;GAKG;AACH,MAAM,UAAU,i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EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;gBACxD,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QACD,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnJ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpD,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3C,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,eAAe,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { TurnState } from '@aeolus-fleet/common';
2
+ import type { Crew } from '../shared/caller.js';
3
+ import { type NewEvent } from '../shared/events.js';
4
+ /** The turn a lease holds: idle or busy, since the time the hooks saw it change. */
5
+ export interface Turn {
6
+ state: TurnState;
7
+ at: Date;
8
+ }
9
+ /**
10
+ * The hooks report the turn with the time they saw it (decision 0040): the
11
+ * lease keeps it at that time, and TurnReported is written then, so a report
12
+ * the fleet refused and that is sent again later keeps its own time. The same
13
+ * turn again changes nothing, so the turn keeps the time it changed. A report
14
+ * older than the turn held changes nothing either: a late report never undoes
15
+ * a newer one. A time later than now is taken as now.
16
+ */
17
+ export declare function reportTurn(held: Turn | null, report: {
18
+ crew: Crew;
19
+ turn: TurnState;
20
+ at: Date;
21
+ now: Date;
22
+ }): {
23
+ turn: Turn;
24
+ events: NewEvent[];
25
+ };
@@ -0,0 +1,30 @@
1
+ import { shipActor } from '../shared/events.js';
2
+ /**
3
+ * The hooks report the turn with the time they saw it (decision 0040): the
4
+ * lease keeps it at that time, and TurnReported is written then, so a report
5
+ * the fleet refused and that is sent again later keeps its own time. The same
6
+ * turn again changes nothing, so the turn keeps the time it changed. A report
7
+ * older than the turn held changes nothing either: a late report never undoes
8
+ * a newer one. A time later than now is taken as now.
9
+ */
10
+ export function reportTurn(held, report) {
11
+ const { crew, turn, now } = report;
12
+ const at = report.at > now ? now : report.at;
13
+ if (held !== null && (held.state === turn || at < held.at)) {
14
+ return { turn: held, events: [] };
15
+ }
16
+ return {
17
+ turn: { state: turn, at },
18
+ events: [
19
+ {
20
+ fleetId: crew.fleetId,
21
+ type: 'TurnReported',
22
+ occurredAt: at,
23
+ actor: shipActor(crew.shipId),
24
+ shipId: crew.shipId,
25
+ details: { leaseId: crew.leaseId, turn },
26
+ },
27
+ ],
28
+ };
29
+ }
30
+ //# sourceMappingURL=turn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn.js","sourceRoot":"","sources":["../../../src/domain/registry/turn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAQ/D;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,IAAiB,EACjB,MAA4D;IAE5D,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IACnC,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7C,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACpC,CAAC;IACD,OAAO;QACL,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACzB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,IAAI,EAAE,cAAc;gBACpB,UAAU,EAAE,EAAE;gBACd,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE;aACzC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { type ComputerSide, type CrewStatus, type DeliveryHolder, type DeliveryState, type LeaseEndReason, type OverdueClock, type ShipId, type TurnState } from '@aeolus-fleet/common';
2
+ import type { Location } from '../registry/public.js';
3
+ import type { SequencedEvent } from './events.js';
4
+ import { type DeliveryChange, type HistoryParty } from './history.js';
5
+ /**
6
+ * A message's way through (decision 0040, #756): who holds its delivery, the
7
+ * part each step was taken by, and the clocks that speak for it. Read models
8
+ * only, from the event log and the leases its steps name.
9
+ */
10
+ /** What the history reads of a lease on a delivery's way. */
11
+ export interface WayLease {
12
+ location: Location;
13
+ harness: string | null;
14
+ /** The ship other than argo whose starting prompt its crew claimed with: its trierarch; null crewed by hand. */
15
+ trierarch: HistoryParty | null;
16
+ /** From its first push receive until it ends. */
17
+ isPushed: boolean;
18
+ isEnded: boolean;
19
+ /** Why it ended, as its LeaseRevoked says; null while open. */
20
+ endReason: LeaseEndReason | null;
21
+ /** Its session's turn as its hooks last reported it; null until they report. */
22
+ turn: {
23
+ state: TurnState;
24
+ at: Date;
25
+ } | null;
26
+ }
27
+ /** An overdue clock argo was told of that still stands: the delivery is still in the state it was told in, on that open lease. */
28
+ export interface StandingOverdue {
29
+ clock: OverdueClock;
30
+ minutes: number;
31
+ toldAt: Date;
32
+ }
33
+ /** How a trierarch says the crew of a ship stands, from its crew request. */
34
+ export interface WayCrew {
35
+ status: CrewStatus;
36
+ attempt: number;
37
+ startedAt: Date | null;
38
+ }
39
+ /** Where a delivery stands on its way. */
40
+ export interface DeliveryWay {
41
+ holder: DeliveryHolder | null;
42
+ /** When it entered its state. */
43
+ since: Date;
44
+ /** A plain receive handed it last, with no hand-over number. */
45
+ isPulled: boolean;
46
+ overdue: StandingOverdue | null;
47
+ /** The lease that holds it, or a pending delivery to one ship waits for. */
48
+ lease: {
49
+ by: ComputerSide | null;
50
+ isEnded: boolean;
51
+ turn: WayLease['turn'];
52
+ } | null;
53
+ /** The crew the lease's trierarch runs; none for a session crewed by hand. */
54
+ crew: WayCrew | null;
55
+ }
56
+ /**
57
+ * The part that receives and hands over for a pushed lease's session: its
58
+ * trierarch, or else the plugin watcher of a session crewed by hand. A pull
59
+ * lease has none: its agent receives itself.
60
+ */
61
+ export declare function computerSideOf(lease: Pick<WayLease, 'isPushed' | 'trierarch'>): ComputerSide | null;
62
+ /**
63
+ * One step of a delivery's way from its event: the ship it names, where a
64
+ * hand-over's session ran, the computer side that received it or handed it
65
+ * over, and what the event's details say of it. No step for an event that is
66
+ * no delivery change.
67
+ */
68
+ export declare function deliveryStepOf(event: SequencedEvent, read: {
69
+ party: (id: ShipId) => HistoryParty;
70
+ leases: ReadonlyMap<string, WayLease>;
71
+ }): DeliveryChange[];
72
+ /**
73
+ * Where a delivery stands on its way, from its state, its steps newest first,
74
+ * the lease that holds it or that it waits for, the overdue clock that stands
75
+ * and the crew request of that lease's ship.
76
+ */
77
+ export declare function deliveryWayOf(read: {
78
+ state: DeliveryState;
79
+ history: readonly DeliveryChange[];
80
+ lease: WayLease | null;
81
+ overdue: StandingOverdue | null;
82
+ crew: WayCrew | null;
83
+ }): DeliveryWay;
@@ -0,0 +1,89 @@
1
+ import { OVERDUE_CLOCKS, } from '@aeolus-fleet/common';
2
+ import { isDeliveryChangeType } from './history.js';
3
+ /**
4
+ * The part that receives and hands over for a pushed lease's session: its
5
+ * trierarch, or else the plugin watcher of a session crewed by hand. A pull
6
+ * lease has none: its agent receives itself.
7
+ */
8
+ export function computerSideOf(lease) {
9
+ if (!lease.isPushed) {
10
+ return null;
11
+ }
12
+ return lease.trierarch ? { kind: 'trierarch', trierarch: lease.trierarch } : { kind: 'pluginWatcher' };
13
+ }
14
+ function isOverdueClock(value) {
15
+ return OVERDUE_CLOCKS.some((clock) => clock === value);
16
+ }
17
+ /**
18
+ * One step of a delivery's way from its event: the ship it names, where a
19
+ * hand-over's session ran, the computer side that received it or handed it
20
+ * over, and what the event's details say of it. No step for an event that is
21
+ * no delivery change.
22
+ */
23
+ export function deliveryStepOf(event, read) {
24
+ const { type, details } = event;
25
+ if (!isDeliveryChangeType(type)) {
26
+ return [];
27
+ }
28
+ const lease = typeof details.leaseId === 'string' ? read.leases.get(details.leaseId) : undefined;
29
+ const isTakenBySession = type === 'DeliveryReceived' || type === 'DeliveryHanded';
30
+ const { attempts, handOverNumber, clock, minutes } = details;
31
+ return [
32
+ {
33
+ seq: event.seq,
34
+ type,
35
+ occurredAt: event.occurredAt,
36
+ ship: type === 'MessageAccepted' || event.shipId === undefined ? null : read.party(event.shipId),
37
+ location: type === 'DeliveryHanded' && lease ? lease.location : null,
38
+ harness: type === 'DeliveryHanded' && lease ? lease.harness : null,
39
+ attempts: typeof attempts === 'number' ? attempts : null,
40
+ by: isTakenBySession && lease ? computerSideOf(lease) : null,
41
+ handOverNumber: typeof handOverNumber === 'number' ? handOverNumber : null,
42
+ isAgain: details.again === true,
43
+ isOnceMore: details.onceMore === true,
44
+ overdue: type === 'DeliveryOverdue' && isOverdueClock(clock) && typeof minutes === 'number' ? { clock, minutes } : null,
45
+ leaseEnd: type === 'DeliveryReturned' ? (lease?.endReason ?? null) : null,
46
+ },
47
+ ];
48
+ }
49
+ /** Who holds a delivery in its state: the fleet while pending, the computer side while received, the agent once handed. */
50
+ function holderOf(state, lease) {
51
+ switch (state) {
52
+ case 'pending':
53
+ return { kind: 'fleet' };
54
+ case 'received':
55
+ return lease ? computerSideOf(lease) : null;
56
+ case 'handed':
57
+ case 'acknowledged':
58
+ return { kind: 'agent' };
59
+ case 'handled':
60
+ case 'notHandled':
61
+ case 'undeliverable':
62
+ case 'dismissed':
63
+ case 'abandoned':
64
+ return null;
65
+ }
66
+ }
67
+ /** Whether a step changed the delivery's state: an overdue clock, a receive again and a hand-over once more do not. */
68
+ function isStateChange(step) {
69
+ return step.type !== 'DeliveryOverdue' && !step.isAgain && !step.isOnceMore;
70
+ }
71
+ /**
72
+ * Where a delivery stands on its way, from its state, its steps newest first,
73
+ * the lease that holds it or that it waits for, the overdue clock that stands
74
+ * and the crew request of that lease's ship.
75
+ */
76
+ export function deliveryWayOf(read) {
77
+ const { state, history, lease, overdue, crew } = read;
78
+ const entered = history.find(isStateChange);
79
+ const lastHandOver = history.find((step) => step.type === 'DeliveryHanded');
80
+ return {
81
+ holder: holderOf(state, lease),
82
+ since: entered?.occurredAt ?? history.at(-1)?.occurredAt ?? new Date(0),
83
+ isPulled: lastHandOver?.handOverNumber === null && !lastHandOver.isOnceMore,
84
+ overdue,
85
+ lease: lease && { by: computerSideOf(lease), isEnded: lease.isEnded, turn: lease.turn },
86
+ crew: lease?.trierarch ? crew : null,
87
+ };
88
+ }
89
+ //# sourceMappingURL=delivery-way.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-way.js","sourceRoot":"","sources":["../../../src/domain/shared/delivery-way.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GASf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,oBAAoB,EAA0C,MAAM,cAAc,CAAC;AAmD5F;;;;GAIG;AAC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,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;KACrC,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type Err } from './result.js';
2
2
  /** Every reason the domain refuses a request. */
3
- export type DomainErrorKind = 'ASSIGNEE_NOT_ACTIVE' | 'CLEAR_REQUEST_LIMIT_REACHED' | 'CLEAR_REQUEST_NOT_FOUND' | 'CREW_REQUEST_ALREADY_ASSIGNED' | 'CREW_REQUEST_NOT_ASSIGNED_TO_CALLER' | 'CREW_REQUEST_NOT_FOUND' | 'CREW_REQUEST_NOT_RELEASING' | 'CREW_REQUEST_RELEASING' | 'CREW_REQUEST_FINAL' | 'CREW_REQUEST_SETTINGS_CHANGED' | 'CREW_REQUEST_SETTINGS_TOO_LARGE' | 'DELIVERY_HELD_BY_ANOTHER_SHIP' | 'DELIVERY_NOT_FOUND' | 'DELIVERY_NOT_A_PING' | 'DELIVERY_NOT_IN_FLIGHT' | 'DELIVERY_NOT_OPEN' | 'DELIVERY_NOT_UNDELIVERABLE' | 'FLEET_ALREADY_EXISTS' | 'FLEET_LIMIT_REACHED' | 'FLEET_NOT_FOUND' | 'FLEET_HAS_NO_VIEWER' | 'NOTICE_NOT_FOUND' | 'NOTICE_NOT_DISMISSIBLE' | 'GUIDE_NOT_FOUND' | 'GUIDE_STEP_NOT_FOUND' | 'IDEMPOTENCY_KEY_REUSED' | 'IN_REPLY_TO_NOT_FOUND' | 'MESSAGE_LIMIT_REACHED' | 'MODEL_REQUIRED' | 'INVALID_HARNESS' | 'MODEL_FROM_ARGO' | 'INVALID_CONTENT_TYPE' | 'INVALID_EMAIL' | 'INVALID_FLEET_NAME' | 'INVALID_FOLLOW_MAX' | 'INVALID_FOLLOW_WAIT' | 'INVALID_IDEMPOTENCY_KEY' | 'INVALID_INBOX_WAIT' | 'INVALID_LABEL_KEY' | 'INVALID_LABEL_VALUE' | 'INVALID_LABEL_VALUES' | 'INVALID_LIMIT' | 'INVALID_LOCATION' | 'INVALID_NETWORK_RULES' | 'INVALID_PASSWORD' | 'INVALID_RECEIVE_MAX' | 'INVALID_CREW_REQUEST_REASON' | 'INVALID_REPORT_DETAILS' | 'INVALID_REPORT_NOTE' | 'INVALID_REPORT_STATE' | 'INVALID_SHIP_NAME' | 'INVALID_SHIP_NOTE' | 'INVALID_SHIP_TYPE' | 'LABEL_CARRIED' | 'LABEL_KEY_TAKEN' | 'LABEL_NOT_FOUND' | 'LABEL_VALUE_CARRIED' | 'LABEL_VALUE_NOT_FOUND' | 'LEASE_ENDED' | 'MESSAGE_NOT_FOUND' | 'NETWORK_PLUGIN_REGISTERED' | 'NOT_A_TRIERARCH' | 'NOT_THE_LABEL_OWNER' | 'NOT_REACHABLE' | 'NOT_THE_NETWORK_PLUGIN' | 'NOT_THE_OPERATOR_SHIP' | 'OPERATOR_EMAIL_TAKEN' | 'OPERATOR_HAS_NO_PASSWORD' | 'OPERATOR_SHIP_GETS_NO_STARTING_PROMPT' | 'OPERATOR_SHIP_HAS_NO_SECRET' | 'OPERATOR_SHIP_IS_NOT_PINGED' | 'OPERATOR_SHIP_IS_PERMANENT' | 'PAYLOAD_TOO_LARGE' | 'PING_NOT_RESENT' | 'REPORT_DETAILS_TOO_LARGE' | 'RESERVED_CONTENT_TYPE' | 'SHIP_ALREADY_RETIRED' | 'SHIP_NAME_RESERVED' | 'SHIP_NAME_TAKEN' | 'SHIP_NOT_AWAITING_CREW' | 'SHIP_NOT_CREWED' | 'SHIP_LABEL_LIMIT_REACHED' | 'SHIP_LIMIT_REACHED' | 'SHIP_NOT_FOUND' | 'SIGN_IN_TICKET_INVALID' | 'UNKNOWN_CREW_TOKEN' | 'UNRESOLVABLE_SELECTOR' | 'WRONG_EMAIL_OR_PASSWORD' | 'WRONG_SHIP_ID_OR_SECRET';
3
+ export type DomainErrorKind = 'ASSIGNEE_NOT_ACTIVE' | 'CLEAR_REQUEST_LIMIT_REACHED' | 'CLEAR_REQUEST_NOT_FOUND' | 'CREW_REQUEST_ALREADY_ASSIGNED' | 'CREW_REQUEST_NOT_ASSIGNED_TO_CALLER' | 'CREW_REQUEST_NOT_FOUND' | 'CREW_REQUEST_NOT_RELEASING' | 'CREW_REQUEST_RELEASING' | 'CREW_REQUEST_FINAL' | 'CREW_REQUEST_SETTINGS_CHANGED' | 'CREW_REQUEST_SETTINGS_INVALID' | 'CREW_REQUEST_SETTINGS_TOO_LARGE' | 'DELIVERY_HANDED_ONCE_MORE' | 'DELIVERY_HELD_BY_ANOTHER_SHIP' | 'DELIVERY_NOT_FOUND' | 'DELIVERY_NOT_A_PING' | 'DELIVERY_NOT_ACKNOWLEDGED' | 'DELIVERY_NOT_HANDED_ONCE_MORE' | 'DELIVERY_NOT_IN_FLIGHT' | 'DELIVERY_NOT_OPEN' | 'DELIVERY_NOT_UNDELIVERABLE' | 'FLEET_ALREADY_EXISTS' | 'FLEET_LIMIT_REACHED' | 'FLEET_NOT_FOUND' | 'FLEET_HAS_NO_VIEWER' | 'NOTICE_NOT_FOUND' | 'NOTICE_NOT_DISMISSIBLE' | 'GUIDE_NOT_FOUND' | 'GUIDE_STEP_NOT_FOUND' | 'IDEMPOTENCY_KEY_REUSED' | 'IN_REPLY_TO_NOT_FOUND' | 'MESSAGE_LIMIT_REACHED' | 'MODEL_REQUIRED' | 'INVALID_HARNESS' | 'MODEL_FROM_ARGO' | 'INVALID_CONTENT_TYPE' | 'INVALID_EMAIL' | 'INVALID_FLEET_NAME' | 'INVALID_FOLLOW_MAX' | 'INVALID_FOLLOW_WAIT' | 'INVALID_IDEMPOTENCY_KEY' | 'INVALID_INBOX_WAIT' | 'INVALID_LABEL_KEY' | 'INVALID_LABEL_VALUE' | 'INVALID_LABEL_VALUES' | 'INVALID_LIMIT' | 'INVALID_LOCATION' | 'INVALID_NETWORK_RULES' | 'INVALID_PASSWORD' | 'INVALID_RECEIVE_MAX' | 'INVALID_CREW_REQUEST_REASON' | 'INVALID_REPORT_DETAILS' | 'INVALID_REPORT_NOTE' | 'INVALID_REPORT_STATE' | 'INVALID_SHIP_NAME' | 'INVALID_SHIP_NOTE' | 'INVALID_SHIP_TYPE' | 'LABEL_CARRIED' | 'LABEL_KEY_TAKEN' | 'LABEL_NOT_FOUND' | 'LABEL_VALUE_CARRIED' | 'LABEL_VALUE_NOT_FOUND' | 'LEASE_ENDED' | 'MESSAGE_NOT_FOUND' | 'NETWORK_PLUGIN_REGISTERED' | 'NOT_A_TRIERARCH' | 'NOT_THE_LABEL_OWNER' | 'NOT_REACHABLE' | 'NOT_THE_NETWORK_PLUGIN' | 'NOT_THE_OPERATOR_SHIP' | 'OPERATOR_EMAIL_TAKEN' | 'OPERATOR_HAS_NO_PASSWORD' | 'OPERATOR_SHIP_GETS_NO_STARTING_PROMPT' | 'OPERATOR_SHIP_HAS_NO_SECRET' | 'OPERATOR_SHIP_IS_NOT_PINGED' | 'OPERATOR_SHIP_IS_PERMANENT' | 'PAYLOAD_TOO_LARGE' | 'PING_NOT_RESENT' | 'REPORT_DETAILS_TOO_LARGE' | 'RESERVED_CONTENT_TYPE' | 'SHIP_ALREADY_RETIRED' | 'SHIP_NAME_RESERVED' | 'SHIP_NAME_TAKEN' | 'SHIP_NOT_AWAITING_CREW' | 'SHIP_NOT_CREWED' | 'SHIP_LABEL_LIMIT_REACHED' | 'SHIP_LIMIT_REACHED' | 'SHIP_NOT_FOUND' | 'SIGN_IN_TICKET_INVALID' | 'UNKNOWN_CREW_TOKEN' | 'UNRESOLVABLE_SELECTOR' | 'WRONG_EMAIL_OR_PASSWORD' | 'WRONG_SHIP_ID_OR_SECRET';
4
4
  /**
5
5
  * Why the domain refused a request. Adapters map the kind to their own error
6
6
  * shape (a tRPC code, an exit code); the message is safe to show a caller.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/domain/shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;AAuG5C,qDAAqD;AACrD,MAAM,UAAU,MAAM,CAA4B,IAAO,EAAE,OAAe;IACxE,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/domain/shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;AA2G5C,qDAAqD;AACrD,MAAM,UAAU,MAAM,CAA4B,IAAO,EAAE,OAAe;IACxE,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAChC,CAAC"}
@@ -1,5 +1,7 @@
1
- import { DELIVERY_HISTORY_TYPES, type InboxFilter, type DeliveryId, type DeliveryState, type EventId, type EventType, type FleetId, type MessageId, type ShipId } from '@aeolus-fleet/common';
1
+ import { DELIVERY_HISTORY_TYPES, type ComputerSide, type LeaseEndReason, type InboxFilter, type DeliveryId, type DeliveryState, type EventId, type EventType, type FleetId, type MessageId, type ShipId } from '@aeolus-fleet/common';
2
+ import type { OverdueClock, WaitingState } from '../messaging/public.js';
2
3
  import type { Location } from '../registry/public.js';
4
+ import type { StandingOverdue, WayCrew, WayLease } from './delivery-way.js';
3
5
  import type { EventDetails } from './events.js';
4
6
  /**
5
7
  * What the console reads: a ship's timeline from the event log, its
@@ -52,9 +54,17 @@ export declare function withPing<T extends {
52
54
  export type ShownTimelineEntry = Omit<TimelineEntry, 'message'> & {
53
55
  message: WithPing<NonNullable<TimelineEntry['message']>> | null;
54
56
  };
55
- /** An undeliverable delivery as Needs attention answers it, its message telling whether it is a ping. */
56
- export type ShownUndeliverableEntry = Omit<UndeliverableEntry, 'message'> & {
57
- message: WithPing<UndeliverableEntry['message']>;
57
+ /** A delivery no ship can take as it is answered, its message telling whether it is a ping. */
58
+ export type ShownNoShipCanTakeEntry = Omit<NoShipCanTakeEntry, 'message'> & {
59
+ message: WithPing<NoShipCanTakeEntry['message']>;
60
+ };
61
+ /** An overdue delivery as it is answered, its message telling whether it is a ping. */
62
+ export type ShownOverdueEntry = Omit<OverdueEntry, 'message'> & {
63
+ message: WithPing<OverdueEntry['message']>;
64
+ };
65
+ /** A delivery in Needs attention as it is answered, its message telling whether it is a ping. */
66
+ export type ShownNeedsAttentionEntry = Omit<NeedsAttentionEntry, 'message'> & {
67
+ message: WithPing<NeedsAttentionEntry['message']>;
58
68
  };
59
69
  /** One message with its delivery as it stands. */
60
70
  export interface HistoryMessage {
@@ -72,33 +82,112 @@ export interface HistoryMessage {
72
82
  state: DeliveryState;
73
83
  attempts: number;
74
84
  claimedBy: HistoryParty | null;
85
+ /** The number of its last hand-over by a pushed crew's computer side; null when a plain receive or a push receive took it last, or before any. */
86
+ handOverNumber: number | null;
75
87
  };
76
88
  }
77
- /** The events that change a delivery: stored, claimed, returned, acknowledged or undeliverable. */
89
+ /** The events of a delivery's way: stored, received, handed, returned, acknowledged, handled or not, overdue, and its dead ends. */
78
90
  export type DeliveryChangeType = (typeof DELIVERY_HISTORY_TYPES)[number];
79
91
  export declare function isDeliveryChangeType(type: EventType): type is DeliveryChangeType;
80
- /** One change to a delivery. */
92
+ /** One step of a delivery's way. */
81
93
  export interface DeliveryChange {
82
94
  seq: number;
83
95
  type: DeliveryChangeType;
84
96
  occurredAt: Date;
85
- /** The ship that claimed, returned or acknowledged it; null when it was stored. */
97
+ /** The ship that received, was handed, returned or acknowledged it; null when it was stored. */
86
98
  ship: HistoryParty | null;
87
- /** Where the claiming session ran, for a claim. */
99
+ /** Where the claiming session ran, for a hand-over. */
88
100
  location: Location | null;
89
- /** The harness the claiming session ran in, for a claim. */
101
+ /** The harness the claiming session ran in, for a hand-over. */
90
102
  harness: string | null;
91
- /** The claims counted by then, where the event records them. */
103
+ /** The attempts counted by then, where the event records them. */
92
104
  attempts: number | null;
105
+ /** The computer side that received it or handed it over, on a pushed lease. */
106
+ by: ComputerSide | null;
107
+ /** The number of a pushed hand-over; none for a plain receive's. */
108
+ handOverNumber: number | null;
109
+ /** A push receive of a delivery its crew already held. */
110
+ isAgain: boolean;
111
+ /** A confirmed message handed once more after its turn died. */
112
+ isOnceMore: boolean;
113
+ /** Which clock ran out and after how long, for DeliveryOverdue. */
114
+ overdue: {
115
+ clock: OverdueClock;
116
+ minutes: number;
117
+ } | null;
118
+ /** Why its lease ended, for DeliveryReturned. */
119
+ leaseEnd: LeaseEndReason | null;
120
+ }
121
+ /** A reply to a message. */
122
+ export interface HistoryReply {
123
+ id: MessageId;
124
+ sender: HistoryParty;
125
+ sentAt: Date;
93
126
  }
94
- /** An undeliverable delivery, for Needs attention: its claims, since when, and its whole message. */
95
- export interface UndeliverableEntry {
127
+ /**
128
+ * One message as the history reads it: its delivery's steps newest first,
129
+ * its replies oldest first, and what its way is read from: the lease that
130
+ * holds it or that a pending delivery to one ship waits for, the overdue
131
+ * clock that stands, and the crew request of that lease's ship.
132
+ */
133
+ export type MessageRead = HistoryMessage & {
134
+ history: DeliveryChange[];
135
+ replies: HistoryReply[];
136
+ lease: WayLease | null;
137
+ overdue: StandingOverdue | null;
138
+ crew: WayCrew | null;
139
+ };
140
+ /**
141
+ * What a ship's side of the way is read from (#756): the open lease of the
142
+ * session crewing it, and the messages whose deliveries wait for it, oldest
143
+ * sent first. A delivery waits for it as the clocks count it: pending for the
144
+ * ship or for a type it may take, or received or handed with its open lease.
145
+ * Nothing waits while no session crews it.
146
+ */
147
+ export interface ShipWayRead {
148
+ lease: WayLease | null;
149
+ waiting: MessageId[];
150
+ }
151
+ /**
152
+ * A delivery in Needs attention: undeliverable, or not handled after its turn
153
+ * died twice (decision 0040). Its claims, since when, and its whole message.
154
+ */
155
+ export interface NeedsAttentionEntry {
96
156
  deliveryId: DeliveryId;
157
+ state: NeedsAttentionState;
97
158
  attempts: number;
98
- /** When it became undeliverable. */
159
+ /** A pushed crew's computer side handed it over, with numbers; false when plain receives handed it. */
160
+ isPushed: boolean;
161
+ /** When it became undeliverable, or was reported not handled. */
99
162
  since: Date;
100
163
  message: Omit<HistoryMessage, 'delivery'>;
101
164
  }
165
+ /** The delivery states Needs attention lists, each waiting for the operator to resend or dismiss it. */
166
+ export type NeedsAttentionState = Extract<DeliveryState, 'undeliverable' | 'notHandled'>;
167
+ /**
168
+ * A delivery argo was told is overdue (decision 0040): the ship whose clock
169
+ * ran out, the state it waits in, which clock, when argo was told, and its
170
+ * whole message. Listed until it clears by itself.
171
+ */
172
+ export interface OverdueEntry {
173
+ deliveryId: DeliveryId;
174
+ ship: HistoryParty;
175
+ state: WaitingState;
176
+ clock: OverdueClock;
177
+ minutes: number;
178
+ toldAt: Date;
179
+ message: Omit<HistoryMessage, 'delivery'>;
180
+ }
181
+ /**
182
+ * A pending delivery to a type no active ship can take (decision 0041): none
183
+ * of the type is left, or none of the ships its sender may reach (decision
184
+ * 0034). Its type and its whole message; listed until a ship can take it.
185
+ */
186
+ export interface NoShipCanTakeEntry {
187
+ deliveryId: DeliveryId;
188
+ type: string;
189
+ message: Omit<HistoryMessage, 'delivery'>;
190
+ }
102
191
  /** A reply the inbox's ship sent to a message in its inbox. */
103
192
  export interface InboxReply {
104
193
  id: MessageId;
@@ -139,12 +228,20 @@ export interface ShipHistory {
139
228
  shipId: ShipId;
140
229
  limit: number;
141
230
  }): Promise<HistoryMessage[] | undefined>;
142
- /** The message, with its delivery's changes newest first. */
143
- message(fleetId: FleetId, messageId: MessageId): Promise<(HistoryMessage & {
144
- history: DeliveryChange[];
145
- }) | undefined>;
146
- /** Every undeliverable delivery, oldest first by when it became undeliverable. */
147
- undeliverable(fleetId: FleetId): Promise<UndeliverableEntry[]>;
231
+ /** The message, with its delivery's steps newest first and what its way is read from. */
232
+ message(fleetId: FleetId, messageId: MessageId): Promise<MessageRead | undefined>;
233
+ /** Every undeliverable or not handled delivery, oldest first by since when. */
234
+ needsAttention(fleetId: FleetId): Promise<NeedsAttentionEntry[]>;
235
+ /**
236
+ * Every delivery argo was told is overdue that still stands, oldest told
237
+ * first: still in the state it was told in, on the lease it was told on,
238
+ * which has not ended.
239
+ */
240
+ overdue(fleetId: FleetId): Promise<OverdueEntry[]>;
241
+ /** Every pending delivery to a type no active ship can take, oldest sent first. */
242
+ noShipCanTake(fleetId: FleetId): Promise<NoShipCanTakeEntry[]>;
243
+ /** What the ship's side of the way is read from: the open lease of the session crewing it and what waits for it. */
244
+ shipWay(fleetId: FleetId, shipId: ShipId): Promise<ShipWayRead | undefined>;
148
245
  /** The messages addressed to the ship itself that the filter keeps, newest first. */
149
246
  inbox(fleetId: FleetId, query: {
150
247
  shipId: ShipId;
@@ -9,7 +9,7 @@ export function isDeliveryChangeType(type) {
9
9
  export function isKeptBy(filter, state) {
10
10
  switch (filter) {
11
11
  case 'open':
12
- return state === 'pending' || state === 'delivered';
12
+ return state === 'pending' || state === 'received' || state === 'handed';
13
13
  case 'done':
14
14
  return state === 'acknowledged';
15
15
  case 'all':
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/domain/shared/history.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GASlB,MAAM,sBAAsB,CAAC;AAsC9B,MAAM,UAAU,QAAQ,CAAoC,OAAU;IACpE,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;AACxE,CAAC;AAyBD,MAAM,UAAU,oBAAoB,CAAC,IAAe;IAClD,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;AAClE,CAAC;AAiDD,+FAA+F;AAC/F,MAAM,UAAU,QAAQ,CAAC,MAAmB,EAAE,KAAoB;IAChE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,WAAW,CAAC;QACtD,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,cAAc,CAAC;QAClC,KAAK,KAAK;YACR,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/domain/shared/history.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAWlB,MAAM,sBAAsB,CAAC;AAwC9B,MAAM,UAAU,QAAQ,CAAoC,OAAU;IACpE,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;AACxE,CAAC;AAsCD,MAAM,UAAU,oBAAoB,CAAC,IAAe;IAClD,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;AAClE,CAAC;AAiID,+FAA+F;AAC/F,MAAM,UAAU,QAAQ,CAAC,MAAmB,EAAE,KAAoB;IAChE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,QAAQ,CAAC;QAC3E,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,cAAc,CAAC;QAClC,KAAK,KAAK;YACR,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -1,10 +1,13 @@
1
1
  import type { MessageId } from '@aeolus-fleet/common';
2
2
  import type { Caller } from './caller.js';
3
3
  import { type DomainError } from './errors.js';
4
- import type { DeliveryChange, HistoryMessage, ShipHistory } from './history.js';
4
+ import { type DeliveryWay } from './delivery-way.js';
5
+ import type { DeliveryChange, HistoryMessage, HistoryReply, ShipHistory } from './history.js';
5
6
  import { type Result } from './result.js';
6
7
  export type MessageDetail = HistoryMessage & {
8
+ replies: HistoryReply[];
7
9
  delivery: HistoryMessage['delivery'] & {
10
+ way: DeliveryWay;
8
11
  history: DeliveryChange[];
9
12
  };
10
13
  };
@@ -13,8 +16,9 @@ export type ReadMessage = (caller: Caller, input: {
13
16
  }) => Promise<Result<MessageDetail, DomainError<'MESSAGE_NOT_FOUND'>>>;
14
17
  /**
15
18
  * Use case: one message of the caller's fleet: its envelope, its whole
16
- * payload, and its delivery with every change newest first, from the event
17
- * log. The caller's scope (fleet:read) is checked before this runs.
19
+ * payload, its replies, and its delivery's way through: who holds it, since
20
+ * when, the clocks that speak for it and every step newest first, from the
21
+ * event log. The caller's scope (fleet:read) is checked before this runs.
18
22
  */
19
23
  export declare function createReadMessage(deps: {
20
24
  history: ShipHistory;
@@ -1,9 +1,11 @@
1
1
  import { refuse } from './errors.js';
2
+ import { deliveryWayOf } from './delivery-way.js';
2
3
  import { ok } from './result.js';
3
4
  /**
4
5
  * Use case: one message of the caller's fleet: its envelope, its whole
5
- * payload, and its delivery with every change newest first, from the event
6
- * log. The caller's scope (fleet:read) is checked before this runs.
6
+ * payload, its replies, and its delivery's way through: who holds it, since
7
+ * when, the clocks that speak for it and every step newest first, from the
8
+ * event log. The caller's scope (fleet:read) is checked before this runs.
7
9
  */
8
10
  export function createReadMessage(deps) {
9
11
  return async (caller, { messageId }) => {
@@ -11,8 +13,9 @@ export function createReadMessage(deps) {
11
13
  if (!found) {
12
14
  return refuse('MESSAGE_NOT_FOUND', `No message ${messageId} in this fleet`);
13
15
  }
14
- const { history, ...message } = found;
15
- return ok({ ...message, delivery: { ...message.delivery, history } });
16
+ const { history, replies, lease, overdue, crew, ...message } = found;
17
+ const way = deliveryWayOf({ state: message.delivery.state, history, lease, overdue, crew });
18
+ return ok({ ...message, replies, delivery: { ...message.delivery, way, history } });
16
19
  };
17
20
  }
18
21
  //# sourceMappingURL=read-message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-message.js","sourceRoot":"","sources":["../../../src/domain/shared/read-message.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAe,MAAM,aAAa,CAAC;AAS9C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA8B;IAC9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AAa,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5F,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import type { Caller } from './caller.js';
2
- import { type ShipHistory, type ShownUndeliverableEntry } from './history.js';
3
- export type ReadNeedsAttention = (caller: Caller) => Promise<ShownUndeliverableEntry[]>;
2
+ import { type ShipHistory, type ShownNeedsAttentionEntry } from './history.js';
3
+ export type ReadNeedsAttention = (caller: Caller) => Promise<ShownNeedsAttentionEntry[]>;
4
4
  /**
5
- * Use case: Needs attention, every undeliverable delivery of the caller's
6
- * fleet, oldest first, each with its whole message, telling whether it is a
7
- * ping, for the operator to resend or dismiss. Abandoned deliveries are never listed: they stay in the
5
+ * Use case: Needs attention, every undeliverable or not handled delivery of
6
+ * the caller's fleet, oldest first, each with its state and whole message,
7
+ * telling whether it is a ping, for the operator to resend or dismiss. Abandoned deliveries are never listed: they stay in the
8
8
  * timelines only. The caller's scope (fleet:read) is checked before this runs.
9
9
  */
10
10
  export declare function createReadNeedsAttention(deps: {
@@ -1,11 +1,11 @@
1
1
  import { withPing } from './history.js';
2
2
  /**
3
- * Use case: Needs attention, every undeliverable delivery of the caller's
4
- * fleet, oldest first, each with its whole message, telling whether it is a
5
- * ping, for the operator to resend or dismiss. Abandoned deliveries are never listed: they stay in the
3
+ * Use case: Needs attention, every undeliverable or not handled delivery of
4
+ * the caller's fleet, oldest first, each with its state and whole message,
5
+ * telling whether it is a ping, for the operator to resend or dismiss. Abandoned deliveries are never listed: they stay in the
6
6
  * timelines only. The caller's scope (fleet:read) is checked before this runs.
7
7
  */
8
8
  export function createReadNeedsAttention(deps) {
9
- return async (caller) => (await deps.history.undeliverable(caller.fleetId)).map((entry) => ({ ...entry, message: withPing(entry.message) }));
9
+ return async (caller) => (await deps.history.needsAttention(caller.fleetId)).map((entry) => ({ ...entry, message: withPing(entry.message) }));
10
10
  }
11
11
  //# 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":"AACA,OAAO,EAAE,QAAQ,EAAkD,MAAM,cAAc,CAAC;AAIxF;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAA8B;IACrE,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,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;AAC/I,CAAC"}
1
+ {"version":3,"file":"read-needs-attention.js","sourceRoot":"","sources":["../../../src/domain/shared/read-needs-attention.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAmD,MAAM,cAAc,CAAC;AAIzF;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAA8B;IACrE,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,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;AAChJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Caller } from './caller.js';
2
+ import { type ShipHistory, type ShownNoShipCanTakeEntry } from './history.js';
3
+ export type ReadNoShipCanTake = (caller: Caller) => Promise<ShownNoShipCanTakeEntry[]>;
4
+ /**
5
+ * Use case: the pending deliveries of the caller's fleet to a type no active
6
+ * ship can take (decision 0041), oldest sent first, for Needs attention. Each
7
+ * clears by itself once a ship of the type can take it; there is nothing to
8
+ * resend or dismiss. The caller's scope (fleet:read) is checked before this
9
+ * runs.
10
+ */
11
+ export declare function createReadNoShipCanTake(deps: {
12
+ history: ShipHistory;
13
+ }): ReadNoShipCanTake;