@aeolus-fleet/core 0.24.0 → 0.25.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.
- package/README.md +5 -5
- package/dist/adapters/prisma/generated/browser.d.ts +12 -3
- package/dist/adapters/prisma/generated/client.d.ts +12 -3
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +60 -0
- package/dist/adapters/prisma/generated/enums.d.ts +15 -1
- package/dist/adapters/prisma/generated/enums.js +13 -1
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +11 -0
- package/dist/adapters/prisma/generated/internal/class.js +4 -4
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +109 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +16 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +17 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +16 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/Delivery.d.ts +304 -4
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +267 -0
- package/dist/adapters/prisma/generated/models/Lease.d.ts +332 -1
- package/dist/adapters/prisma/generated/models/OverdueDelivery.d.ts +1687 -0
- package/dist/adapters/prisma/generated/models/OverdueDelivery.js +2 -0
- package/dist/adapters/prisma/generated/models/OverdueDelivery.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Ship.d.ts +271 -0
- package/dist/adapters/prisma/generated/models.d.ts +1 -0
- package/dist/adapters/prisma/history.js +231 -46
- package/dist/adapters/prisma/history.js.map +1 -1
- package/dist/adapters/prisma/installation.js +30 -1
- package/dist/adapters/prisma/installation.js.map +1 -1
- package/dist/adapters/prisma/messaging.js +11 -7
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/prisma/overdue.d.ts +4 -0
- package/dist/adapters/prisma/overdue.js +63 -0
- package/dist/adapters/prisma/overdue.js.map +1 -0
- package/dist/adapters/prisma/registry.js +32 -7
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.d.ts +12 -1
- package/dist/adapters/prisma/rows.js +46 -1
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/prisma/unit-of-work.d.ts +2 -1
- package/dist/adapters/prisma/unit-of-work.js +2 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +16 -0
- package/dist/adapters/trpc/fleet.d.ts +232 -14
- package/dist/adapters/trpc/fleet.js +49 -6
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/installation.d.ts +14 -0
- package/dist/adapters/trpc/installation.js +7 -1
- package/dist/adapters/trpc/installation.js.map +1 -1
- package/dist/adapters/trpc/router.d.ts +301 -9
- package/dist/adapters/trpc/ship-protocol.js +2 -2
- package/dist/adapters/trpc/ship-protocol.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +87 -0
- package/dist/adapters/trpc/ship.js +96 -1
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/starting-prompt-text.d.ts +1 -1
- package/dist/adapters/trpc/starting-prompt-text.js +22 -25
- package/dist/adapters/trpc/starting-prompt-text.js.map +1 -1
- package/dist/adapters/trpc/trpc.js +3 -0
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.d.ts +4 -2
- package/dist/app.js +21 -9
- package/dist/app.js.map +1 -1
- package/dist/domain/messaging/delivery.d.ts +88 -28
- package/dist/domain/messaging/delivery.js +213 -39
- package/dist/domain/messaging/delivery.js.map +1 -1
- package/dist/domain/messaging/dismiss-delivery.d.ts +1 -1
- package/dist/domain/messaging/dismiss-delivery.js +1 -1
- package/dist/domain/messaging/hand-over-delivery.d.ts +38 -0
- package/dist/domain/messaging/hand-over-delivery.js +46 -0
- package/dist/domain/messaging/hand-over-delivery.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +12 -1
- package/dist/domain/messaging/message.js +2 -0
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/overdue.d.ts +60 -0
- package/dist/domain/messaging/overdue.js +52 -0
- package/dist/domain/messaging/overdue.js.map +1 -0
- package/dist/domain/messaging/ports.d.ts +20 -0
- package/dist/domain/messaging/public.d.ts +1 -0
- package/dist/domain/messaging/public.js +2 -0
- package/dist/domain/messaging/public.js.map +1 -0
- package/dist/domain/messaging/push-receive-deliveries.d.ts +48 -0
- package/dist/domain/messaging/push-receive-deliveries.js +70 -0
- package/dist/domain/messaging/push-receive-deliveries.js.map +1 -0
- package/dist/domain/messaging/receive-deliveries.d.ts +39 -6
- package/dist/domain/messaging/receive-deliveries.js +80 -50
- package/dist/domain/messaging/receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/report-handled.d.ts +22 -0
- package/dist/domain/messaging/report-handled.js +13 -0
- package/dist/domain/messaging/report-handled.js.map +1 -0
- package/dist/domain/messaging/report-not-handled.d.ts +22 -0
- package/dist/domain/messaging/report-not-handled.js +13 -0
- package/dist/domain/messaging/report-not-handled.js.map +1 -0
- package/dist/domain/messaging/report-turn-end.d.ts +29 -0
- package/dist/domain/messaging/report-turn-end.js +36 -0
- package/dist/domain/messaging/report-turn-end.js.map +1 -0
- package/dist/domain/messaging/resend-delivery.d.ts +1 -1
- package/dist/domain/messaging/resend-delivery.js +1 -1
- package/dist/domain/messaging/tell-overdue-deliveries.d.ts +25 -0
- package/dist/domain/messaging/tell-overdue-deliveries.js +30 -0
- package/dist/domain/messaging/tell-overdue-deliveries.js.map +1 -0
- package/dist/domain/registry/installation-fleet.d.ts +3 -2
- package/dist/domain/registry/installation-fleet.js.map +1 -1
- package/dist/domain/registry/leases.d.ts +26 -0
- package/dist/domain/registry/leases.js +26 -1
- package/dist/domain/registry/leases.js.map +1 -1
- package/dist/domain/registry/ping-status.d.ts +2 -2
- package/dist/domain/registry/ping-status.js +7 -4
- package/dist/domain/registry/ping-status.js.map +1 -1
- package/dist/domain/registry/ports.d.ts +40 -0
- package/dist/domain/registry/public.d.ts +2 -2
- package/dist/domain/registry/public.js +1 -1
- package/dist/domain/registry/public.js.map +1 -1
- package/dist/domain/registry/report-turn.d.ts +28 -0
- package/dist/domain/registry/report-turn.js +28 -0
- package/dist/domain/registry/report-turn.js.map +1 -0
- package/dist/domain/registry/turn.d.ts +25 -0
- package/dist/domain/registry/turn.js +30 -0
- package/dist/domain/registry/turn.js.map +1 -0
- package/dist/domain/shared/delivery-way.d.ts +83 -0
- package/dist/domain/shared/delivery-way.js +89 -0
- package/dist/domain/shared/delivery-way.js.map +1 -0
- package/dist/domain/shared/errors.d.ts +1 -1
- package/dist/domain/shared/errors.js.map +1 -1
- package/dist/domain/shared/history.d.ts +116 -19
- package/dist/domain/shared/history.js +1 -1
- package/dist/domain/shared/history.js.map +1 -1
- package/dist/domain/shared/read-message.d.ts +7 -3
- package/dist/domain/shared/read-message.js +7 -4
- package/dist/domain/shared/read-message.js.map +1 -1
- package/dist/domain/shared/read-needs-attention.d.ts +5 -5
- package/dist/domain/shared/read-needs-attention.js +4 -4
- package/dist/domain/shared/read-needs-attention.js.map +1 -1
- package/dist/domain/shared/read-no-ship-can-take.d.ts +13 -0
- package/dist/domain/shared/read-no-ship-can-take.js +12 -0
- package/dist/domain/shared/read-no-ship-can-take.js.map +1 -0
- package/dist/domain/shared/read-overdue.d.ts +13 -0
- package/dist/domain/shared/read-overdue.js +12 -0
- package/dist/domain/shared/read-overdue.js.map +1 -0
- package/dist/domain/shared/read-ship-messages.d.ts +4 -1
- package/dist/domain/shared/read-ship-messages.js +6 -1
- package/dist/domain/shared/read-ship-messages.js.map +1 -1
- package/dist/domain/shared/read-ship-way.d.ts +41 -0
- package/dist/domain/shared/read-ship-way.js +39 -0
- package/dist/domain/shared/read-ship-way.js.map +1 -0
- package/dist/repeating-pass.d.ts +15 -0
- package/dist/repeating-pass.js +31 -0
- package/dist/repeating-pass.js.map +1 -0
- package/dist/wiring.d.ts +19 -0
- package/dist/wiring.js +25 -0
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261012190000_delivery_handed/migration.sql +11 -0
- package/src/adapters/prisma/migrations/20261012210000_push_receive/migration.sql +7 -0
- package/src/adapters/prisma/migrations/20261013090000_handled/migration.sql +6 -0
- package/src/adapters/prisma/migrations/20261013100000_turn/migration.sql +6 -0
- package/src/adapters/prisma/migrations/20261013120000_overdue/migration.sql +28 -0
- package/src/adapters/prisma/migrations/20261013140000_delivery_state_index/migration.sql +4 -0
- package/src/adapters/prisma/schema.prisma +66 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { holdLease } from '../registry/public.js';
|
|
2
|
+
import { refuse } from '../shared/errors.js';
|
|
3
|
+
import { recordEvent } from '../shared/events.js';
|
|
4
|
+
import { ok } from '../shared/result.js';
|
|
5
|
+
import { endTurn } from './delivery.js';
|
|
6
|
+
/**
|
|
7
|
+
* The unit of work of handled and not handled, which differ only in how the
|
|
8
|
+
* turn ended: hold the crew's lease, so a release waits for it and an ended
|
|
9
|
+
* lease is refused; lock the delivery, so two reports take turns; apply the
|
|
10
|
+
* report and write its event.
|
|
11
|
+
*/
|
|
12
|
+
export async function reportTurnEnd(deps, report) {
|
|
13
|
+
const { tx } = deps;
|
|
14
|
+
const { crew, deliveryId, end } = report;
|
|
15
|
+
const held = await holdLease(tx, crew);
|
|
16
|
+
if (!held.isOk) {
|
|
17
|
+
return held;
|
|
18
|
+
}
|
|
19
|
+
const delivery = await tx.deliveries.findForUpdate(crew.fleetId, deliveryId);
|
|
20
|
+
if (!delivery) {
|
|
21
|
+
return refuse('DELIVERY_NOT_FOUND', `Delivery ${deliveryId} does not exist`);
|
|
22
|
+
}
|
|
23
|
+
const ended = endTurn(delivery, { crew, end, at: deps.clock.now() });
|
|
24
|
+
if (!ended.isOk) {
|
|
25
|
+
return ended;
|
|
26
|
+
}
|
|
27
|
+
const { delivery: changed, events } = ended.value;
|
|
28
|
+
if (events.length > 0) {
|
|
29
|
+
await tx.deliveries.update(changed);
|
|
30
|
+
}
|
|
31
|
+
for (const event of events) {
|
|
32
|
+
await recordEvent({ events: tx.events, ids: deps.ids }, event);
|
|
33
|
+
}
|
|
34
|
+
return ok(undefined);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=report-turn-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-turn-end.js","sourceRoot":"","sources":["../../../src/domain/messaging/report-turn-end.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAqC,MAAM,uBAAuB,CAAC;AAGrF,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAqC,MAAM,eAAe,CAAC;AAU3E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAA6D,EAC7D,MAA4D;IAE5D,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IACzC,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC7E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,MAAM,CAAC,oBAAoB,EAAE,YAAY,UAAU,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACrE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;IAClD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -25,7 +25,7 @@ export type ResendDelivery = (caller: Caller, input: {
|
|
|
25
25
|
messageId: MessageId;
|
|
26
26
|
}, ResendDeliveryRefusal>>;
|
|
27
27
|
/**
|
|
28
|
-
* Use case: the operator resends an undeliverable delivery from Needs
|
|
28
|
+
* Use case: the operator resends an undeliverable or not handled delivery from Needs
|
|
29
29
|
* attention (docs/blueprint.md, "DeliveryUndeliverable"). Its scope
|
|
30
30
|
* (fleet:manage) is checked before this runs. A resend is a retry of the same
|
|
31
31
|
* delivery: a new message with the original's sender, selector, payload,
|
|
@@ -16,7 +16,7 @@ function resendKey(deliveryId) {
|
|
|
16
16
|
return `resend-${deliveryId}`;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Use case: the operator resends an undeliverable delivery from Needs
|
|
19
|
+
* Use case: the operator resends an undeliverable or not handled delivery from Needs
|
|
20
20
|
* attention (docs/blueprint.md, "DeliveryUndeliverable"). Its scope
|
|
21
21
|
* (fleet:manage) is checked before this runs. A resend is a retry of the same
|
|
22
22
|
* delivery: a new message with the original's sender, selector, payload,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IdGenerator } from '@aeolus-fleet/common';
|
|
2
|
+
import type { FleetRepository } from '../registry/public.js';
|
|
3
|
+
import type { Clock } from '../shared/clock.js';
|
|
4
|
+
import { type EventLog } from '../shared/events.js';
|
|
5
|
+
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
6
|
+
import type { OverdueDeliveryRepository, PushedCrews } from './ports.js';
|
|
7
|
+
export interface TellOverdueTx {
|
|
8
|
+
overdueDeliveries: OverdueDeliveryRepository;
|
|
9
|
+
events: EventLog;
|
|
10
|
+
}
|
|
11
|
+
export type TellOverdueDeliveries = () => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Use case: one pass of the 10 and 60 minute clocks (#586, decision 0040),
|
|
14
|
+
* run by core, never through the API. For every fleet, each open pushed
|
|
15
|
+
* lease's oldest delivery whose clock ran out is told to argo: stored once
|
|
16
|
+
* per lease and delivery with DeliveryOverdue, in one unit of work. What is
|
|
17
|
+
* stored outlives the process, so a pass after a restart tells nothing again.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createTellOverdueDeliveries(deps: {
|
|
20
|
+
fleets: Pick<FleetRepository, 'list'>;
|
|
21
|
+
pushedCrews: PushedCrews;
|
|
22
|
+
uow: UnitOfWork<TellOverdueTx>;
|
|
23
|
+
clock: Clock;
|
|
24
|
+
ids: IdGenerator;
|
|
25
|
+
}): TellOverdueDeliveries;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { recordEvent } from '../shared/events.js';
|
|
2
|
+
import { ok } from '../shared/result.js';
|
|
3
|
+
import { overdueDelivery, overdueEvent } from './overdue.js';
|
|
4
|
+
/**
|
|
5
|
+
* Use case: one pass of the 10 and 60 minute clocks (#586, decision 0040),
|
|
6
|
+
* run by core, never through the API. For every fleet, each open pushed
|
|
7
|
+
* lease's oldest delivery whose clock ran out is told to argo: stored once
|
|
8
|
+
* per lease and delivery with DeliveryOverdue, in one unit of work. What is
|
|
9
|
+
* stored outlives the process, so a pass after a restart tells nothing again.
|
|
10
|
+
*/
|
|
11
|
+
export function createTellOverdueDeliveries(deps) {
|
|
12
|
+
return async () => {
|
|
13
|
+
for (const fleet of await deps.fleets.list()) {
|
|
14
|
+
for (const crew of await deps.pushedCrews.waiting(fleet.id)) {
|
|
15
|
+
const now = deps.clock.now();
|
|
16
|
+
const overdue = overdueDelivery(crew, now);
|
|
17
|
+
if (!overdue) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
await deps.uow.run(async (tx) => {
|
|
21
|
+
if (await tx.overdueDeliveries.tell(overdue, now)) {
|
|
22
|
+
await recordEvent({ events: tx.events, ids: deps.ids }, overdueEvent(overdue, now));
|
|
23
|
+
}
|
|
24
|
+
return ok(undefined);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tell-overdue-deliveries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tell-overdue-deliveries.js","sourceRoot":"","sources":["../../../src/domain/messaging/tell-overdue-deliveries.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAU7D;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAM3C;IACC,OAAO,KAAK,IAAI,EAAE;QAChB,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7C,KAAK,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;gBAC7B,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,SAAS;gBACX,CAAC;gBACD,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;oBAC9B,IAAI,MAAM,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;wBAClD,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;oBACtF,CAAC;oBACD,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;gBACvB,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { FleetId } from '@aeolus-fleet/common';
|
|
2
2
|
import { type FleetLimit, type InstallationSettings } from './limits.js';
|
|
3
|
-
import type { InstallationFleetFacts, InstallationFleetWindow } from './ports.js';
|
|
3
|
+
import type { FleetHealth, InstallationFleetFacts, InstallationFleetWindow } from './ports.js';
|
|
4
4
|
/** How far back an installation's fleet counts its messages, and over how many UTC days. */
|
|
5
5
|
export declare const MESSAGE_WINDOW_DAYS = 7;
|
|
6
6
|
export declare const MESSAGE_WINDOW_MS: number;
|
|
7
7
|
/**
|
|
8
8
|
* A fleet as the installation describes it (docs/blueprint.md,
|
|
9
9
|
* "Installation"): its facts and measures, its messages today and per UTC day
|
|
10
|
-
* of the last 7 days, today last,
|
|
10
|
+
* of the last 7 days, today last, the limits that apply to it and its health.
|
|
11
11
|
*/
|
|
12
12
|
export interface InstallationFleet {
|
|
13
13
|
fleetId: FleetId;
|
|
@@ -27,6 +27,7 @@ export interface InstallationFleet {
|
|
|
27
27
|
ships: FleetLimit;
|
|
28
28
|
dailyMessages: FleetLimit;
|
|
29
29
|
};
|
|
30
|
+
health: FleetHealth;
|
|
30
31
|
}
|
|
31
32
|
/** What a read at `now` counts over: the last 7 times 24 hours, and the last 7 UTC days from the first one's start. */
|
|
32
33
|
export declare function messageWindow(now: Date): InstallationFleetWindow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation-fleet.js","sourceRoot":"","sources":["../../../src/domain/registry/installation-fleet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAA8C,MAAM,aAAa,CAAC;AAGxF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"installation-fleet.js","sourceRoot":"","sources":["../../../src/domain/registry/installation-fleet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAA8C,MAAM,aAAa,CAAC;AAGxF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAsB9D,gGAAgG;AAChG,SAAS,OAAO,CAAC,GAAS;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,GAAG,CAAC,WAAW,EA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OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IACrI,OAAO,EAAE,GAAG,IAAI,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,CAAC;AAC3J,CAAC"}
|
|
@@ -64,3 +64,29 @@ export declare function holdLease(tx: HoldLeaseTx, crew: {
|
|
|
64
64
|
fleetId: FleetId;
|
|
65
65
|
leaseId: LeaseId;
|
|
66
66
|
}): Promise<Result<Ship, LeaseEnded>>;
|
|
67
|
+
/**
|
|
68
|
+
* Marks the crew's lease pushed (decision 0040): from its first push receive
|
|
69
|
+
* until it ends, the computer side takes its deliveries and the agent's plain
|
|
70
|
+
* receive answers nothing. The first mark writes LeasePushed, caused by the
|
|
71
|
+
* crew's ship; a lease already pushed, or one that has ended, stays as it
|
|
72
|
+
* was. Call it first in the unit of work, before the lease is held.
|
|
73
|
+
*/
|
|
74
|
+
export declare function markLeasePushed(deps: {
|
|
75
|
+
tx: {
|
|
76
|
+
leases: Pick<LeaseRepository, 'markPushed'>;
|
|
77
|
+
events: EventLog;
|
|
78
|
+
};
|
|
79
|
+
ids: IdGenerator;
|
|
80
|
+
}, crew: {
|
|
81
|
+
fleetId: FleetId;
|
|
82
|
+
shipId: ShipId;
|
|
83
|
+
leaseId: LeaseId;
|
|
84
|
+
at: Date;
|
|
85
|
+
}): Promise<void>;
|
|
86
|
+
/** Whether the crew's lease is pushed: a push receive has marked it. */
|
|
87
|
+
export declare function isLeasePushed(tx: {
|
|
88
|
+
leases: Pick<LeaseRepository, 'isPushed'>;
|
|
89
|
+
}, crew: {
|
|
90
|
+
fleetId: FleetId;
|
|
91
|
+
leaseId: LeaseId;
|
|
92
|
+
}): Promise<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { refuse } from '../shared/errors.js';
|
|
2
|
-
import { recordEvent } from '../shared/events.js';
|
|
2
|
+
import { recordEvent, shipActor } from '../shared/events.js';
|
|
3
3
|
import { ok } from '../shared/result.js';
|
|
4
4
|
import { refuseEndedLease } from './lease.js';
|
|
5
5
|
/**
|
|
@@ -77,4 +77,29 @@ export async function holdLease(tx, crew) {
|
|
|
77
77
|
const ship = lease && (await tx.ships.find(crew.fleetId, lease.shipId));
|
|
78
78
|
return ship ? ok(ship) : refuseEndedLease();
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Marks the crew's lease pushed (decision 0040): from its first push receive
|
|
82
|
+
* until it ends, the computer side takes its deliveries and the agent's plain
|
|
83
|
+
* receive answers nothing. The first mark writes LeasePushed, caused by the
|
|
84
|
+
* crew's ship; a lease already pushed, or one that has ended, stays as it
|
|
85
|
+
* was. Call it first in the unit of work, before the lease is held.
|
|
86
|
+
*/
|
|
87
|
+
export async function markLeasePushed(deps, crew) {
|
|
88
|
+
const { tx, ids } = deps;
|
|
89
|
+
const { fleetId, shipId, leaseId, at } = crew;
|
|
90
|
+
if (await tx.leases.markPushed({ fleetId, leaseId, at })) {
|
|
91
|
+
await recordEvent({ events: tx.events, ids }, {
|
|
92
|
+
fleetId,
|
|
93
|
+
type: 'LeasePushed',
|
|
94
|
+
occurredAt: at,
|
|
95
|
+
actor: shipActor(shipId),
|
|
96
|
+
shipId,
|
|
97
|
+
details: { leaseId },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Whether the crew's lease is pushed: a push receive has marked it. */
|
|
102
|
+
export async function isLeasePushed(tx, crew) {
|
|
103
|
+
return tx.leases.isPushed(crew.fleetId, crew.leaseId);
|
|
104
|
+
}
|
|
80
105
|
//# sourceMappingURL=leases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leases.js","sourceRoot":"","sources":["../../../src/domain/registry/leases.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,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAC9C,IAAI,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QACzD,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;YAC5C,OAAO;YACP,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC;YACxB,MAAM;YACN,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAAiD,EACjD,IAA4C;IAE5C,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -9,8 +9,8 @@ export interface PingStatus {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* The status of a ship's last ping: waiting while its delivery is pending or
|
|
12
|
-
* in flight, answered once pong acknowledged it,
|
|
13
|
-
* did, and undeliverable once it was handed out again and again and never
|
|
12
|
+
* in flight, answered once pong acknowledged it, acknowledged when a plain ack
|
|
13
|
+
* did, and so on after its turn ended, handled or not, and undeliverable once it was handed out again and again and never
|
|
14
14
|
* acknowledged (it is in Needs attention too). A ping the operator dismissed,
|
|
15
15
|
* or one abandoned with a retired ship, shows none.
|
|
16
16
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The status of a ship's last ping: waiting while its delivery is pending or
|
|
3
|
-
* in flight, answered once pong acknowledged it,
|
|
4
|
-
* did, and undeliverable once it was handed out again and again and never
|
|
3
|
+
* in flight, answered once pong acknowledged it, acknowledged when a plain ack
|
|
4
|
+
* did, and so on after its turn ended, handled or not, and undeliverable once it was handed out again and again and never
|
|
5
5
|
* acknowledged (it is in Needs attention too). A ping the operator dismissed,
|
|
6
6
|
* or one abandoned with a retired ship, shows none.
|
|
7
7
|
*/
|
|
@@ -12,11 +12,14 @@ export function pingStatusOf(lastPing) {
|
|
|
12
12
|
const { sentAt, deliveryState, answeredWithPongAt } = lastPing;
|
|
13
13
|
switch (deliveryState) {
|
|
14
14
|
case 'pending':
|
|
15
|
-
case '
|
|
15
|
+
case 'received':
|
|
16
|
+
case 'handed':
|
|
16
17
|
return { state: 'waiting', sentAt, answeredAt: null };
|
|
17
18
|
case 'acknowledged':
|
|
19
|
+
case 'handled':
|
|
20
|
+
case 'notHandled':
|
|
18
21
|
return answeredWithPongAt === null
|
|
19
|
-
? { state: '
|
|
22
|
+
? { state: 'acknowledged', sentAt, answeredAt: null }
|
|
20
23
|
: { state: 'answered', sentAt, answeredAt: answeredWithPongAt };
|
|
21
24
|
case 'undeliverable':
|
|
22
25
|
return { state: 'undeliverable', sentAt, answeredAt: null };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping-status.js","sourceRoot":"","sources":["../../../src/domain/registry/ping-status.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAA+B;IAC1D,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAAC;IAC/D,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,SAAS,CAAC;QACf,KAAK,
|
|
1
|
+
{"version":3,"file":"ping-status.js","sourceRoot":"","sources":["../../../src/domain/registry/ping-status.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAA+B;IAC1D,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAAC;IAC/D,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QACxD,KAAK,cAAc,CAAC;QACpB,KAAK,SAAS,CAAC;QACf,KAAK,YAAY;YACf,OAAO,kBAAkB,KAAK,IAAI;gBAChC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE;gBACrD,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;QACpE,KAAK,eAAe;YAClB,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC9D,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -12,6 +12,7 @@ import type { NetworkSettings } from './network-settings.js';
|
|
|
12
12
|
import type { ReachRefusal } from './reach-refusal.js';
|
|
13
13
|
import type { Ship } from './ship.js';
|
|
14
14
|
import type { ShipReport } from './ship-report.js';
|
|
15
|
+
import type { Turn } from './turn.js';
|
|
15
16
|
/** The crew a report speaks for: its ship and lease, in its fleet. */
|
|
16
17
|
export interface CrewOfLease {
|
|
17
18
|
fleetId: FleetId;
|
|
@@ -166,6 +167,15 @@ export interface LeaseRepository {
|
|
|
166
167
|
leaseId: LeaseId;
|
|
167
168
|
report: ShipReport;
|
|
168
169
|
}): Promise<void>;
|
|
170
|
+
/** The open lease's turn, locked until the unit of work ends, so two turn reports take turns; undefined once it has ended. */
|
|
171
|
+
findTurnForUpdate(fleetId: FleetId, leaseId: LeaseId): Promise<{
|
|
172
|
+
turn: Turn | null;
|
|
173
|
+
} | undefined>;
|
|
174
|
+
saveTurn(change: {
|
|
175
|
+
fleetId: FleetId;
|
|
176
|
+
leaseId: LeaseId;
|
|
177
|
+
turn: Turn;
|
|
178
|
+
}): Promise<void>;
|
|
169
179
|
/**
|
|
170
180
|
* The lease's report and the last report of the lease its ship held before
|
|
171
181
|
* it, the one that ended last; undefined once this lease has ended.
|
|
@@ -180,6 +190,18 @@ export interface LeaseRepository {
|
|
|
180
190
|
leaseId: LeaseId;
|
|
181
191
|
endedAt: Date;
|
|
182
192
|
}): Promise<Lease | undefined>;
|
|
193
|
+
/**
|
|
194
|
+
* Marks the open lease pushed from `at`, keeping an earlier mark, before
|
|
195
|
+
* anything else of the lease is locked: two marks take turns and never
|
|
196
|
+
* deadlock with the units of work holding it. True when this call marked it.
|
|
197
|
+
*/
|
|
198
|
+
markPushed(pushed: {
|
|
199
|
+
fleetId: FleetId;
|
|
200
|
+
leaseId: LeaseId;
|
|
201
|
+
at: Date;
|
|
202
|
+
}): Promise<boolean>;
|
|
203
|
+
/** Whether a push receive marked the lease pushed. */
|
|
204
|
+
isPushed(fleetId: FleetId, leaseId: LeaseId): Promise<boolean>;
|
|
183
205
|
}
|
|
184
206
|
/**
|
|
185
207
|
* Outbound port: crew requests, at most one per ship, always within one
|
|
@@ -396,6 +418,24 @@ export interface InstallationFleetFacts {
|
|
|
396
418
|
}[];
|
|
397
419
|
/** How its limits are set. */
|
|
398
420
|
limitSettings: FleetLimitSettings;
|
|
421
|
+
/** Whether its deliveries reach their ships. */
|
|
422
|
+
health: FleetHealth;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* A fleet's health as the installation reads it (#304): where its deliveries
|
|
426
|
+
* wait, read from their states and times, never their payloads.
|
|
427
|
+
*/
|
|
428
|
+
export interface FleetHealth {
|
|
429
|
+
/** When its oldest pending delivery was sent; null when none is pending. */
|
|
430
|
+
oldestPendingAt: Date | null;
|
|
431
|
+
/** Since when its oldest delivery in flight (received or handed) is in its state, as the overdue clocks read it; null when none is. */
|
|
432
|
+
oldestInFlightAt: Date | null;
|
|
433
|
+
/** Its pending deliveries to a type no active ship can take: none of the type, or none of the reachable ones (decision 0034). */
|
|
434
|
+
noShipCanTake: number;
|
|
435
|
+
/** Its undeliverable and not handled deliveries: what Needs attention lists for Resend or Dismiss. */
|
|
436
|
+
needsAttention: number;
|
|
437
|
+
/** The overdue deliveries argo was told of that still stand: what Needs attention shows as overdue. */
|
|
438
|
+
overdue: number;
|
|
399
439
|
}
|
|
400
440
|
/** What a read of the installation's fleets counts messages over: since a moment, and per UTC day from a first day. */
|
|
401
441
|
export interface InstallationFleetWindow {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { location, refuseEndedLease, type Lease, type LeaseEnded, type LeaseEndReason, type Location } from './lease.js';
|
|
2
|
-
export { endLease, holdLease, takeOverOperatorLease, type HoldLeaseTx, type LeaseTx } from './leases.js';
|
|
3
|
-
export type { InFlightDeliveries, LeaseRepository, ShipRepository } from './ports.js';
|
|
2
|
+
export { endLease, holdLease, isLeasePushed, markLeasePushed, takeOverOperatorLease, type HoldLeaseTx, type LeaseTx } from './leases.js';
|
|
3
|
+
export type { FleetRepository, InFlightDeliveries, LeaseRepository, ShipRepository } from './ports.js';
|
|
4
4
|
export { findPingableShip, type PingableShipTx, type UnpingableShip } from './pingable-ship.js';
|
|
5
5
|
export { checkReach, type CheckReachTx, type NotReachable } from './check-reach.js';
|
|
6
6
|
export { resolveSelector, type ResolveSelectorTx, type UnresolvableSelector } from './resolve-selector.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Registry's published surface: what other contexts may use. Use cases are not
|
|
2
2
|
// part of it; adapters import them from their own modules.
|
|
3
3
|
export { location, refuseEndedLease } from './lease.js';
|
|
4
|
-
export { endLease, holdLease, takeOverOperatorLease } from './leases.js';
|
|
4
|
+
export { endLease, holdLease, isLeasePushed, markLeasePushed, takeOverOperatorLease } from './leases.js';
|
|
5
5
|
export { findPingableShip } from './pingable-ship.js';
|
|
6
6
|
export { checkReach } from './check-reach.js';
|
|
7
7
|
export { resolveSelector } from './resolve-selector.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/registry/public.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAmE,MAAM,YAAY,CAAC;AACzH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,qBAAqB,EAAkC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/registry/public.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAmE,MAAM,YAAY,CAAC;AACzH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAkC,MAAM,aAAa,CAAC;AAEzI,OAAO,EAAE,gBAAgB,EAA4C,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAwC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAqD,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAgC,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAa,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAwB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IdGenerator, TurnState } from '@aeolus-fleet/common';
|
|
2
|
+
import type { Crew } from '../shared/caller.js';
|
|
3
|
+
import type { Clock } from '../shared/clock.js';
|
|
4
|
+
import { type EventLog } from '../shared/events.js';
|
|
5
|
+
import { type Result } from '../shared/result.js';
|
|
6
|
+
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
7
|
+
import { type LeaseEnded } from './lease.js';
|
|
8
|
+
import type { LeaseRepository } from './ports.js';
|
|
9
|
+
export interface ReportTurnTx {
|
|
10
|
+
leases: Pick<LeaseRepository, 'findTurnForUpdate' | 'saveTurn'>;
|
|
11
|
+
events: EventLog;
|
|
12
|
+
}
|
|
13
|
+
export type ReportTurn = (crew: Crew, input: {
|
|
14
|
+
turn: TurnState;
|
|
15
|
+
at: Date;
|
|
16
|
+
}) => Promise<Result<undefined, LeaseEnded>>;
|
|
17
|
+
/**
|
|
18
|
+
* Use case: a pushed ship's hooks report its session's turn (`turn`,
|
|
19
|
+
* decision 0040), idle or busy, with the time they saw it. No scope beyond
|
|
20
|
+
* being the crew: it speaks only for its own session. The turn is kept with
|
|
21
|
+
* the crew's lease, locked meanwhile, and TurnReported is written when it
|
|
22
|
+
* changed, in one unit of work. Refused once the lease has ended.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createReportTurn(deps: {
|
|
25
|
+
uow: UnitOfWork<ReportTurnTx>;
|
|
26
|
+
clock: Clock;
|
|
27
|
+
ids: IdGenerator;
|
|
28
|
+
}): ReportTurn;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { recordEvent } from '../shared/events.js';
|
|
2
|
+
import { ok } from '../shared/result.js';
|
|
3
|
+
import { refuseEndedLease } from './lease.js';
|
|
4
|
+
import { reportTurn } from './turn.js';
|
|
5
|
+
/**
|
|
6
|
+
* Use case: a pushed ship's hooks report its session's turn (`turn`,
|
|
7
|
+
* decision 0040), idle or busy, with the time they saw it. No scope beyond
|
|
8
|
+
* being the crew: it speaks only for its own session. The turn is kept with
|
|
9
|
+
* the crew's lease, locked meanwhile, and TurnReported is written when it
|
|
10
|
+
* changed, in one unit of work. Refused once the lease has ended.
|
|
11
|
+
*/
|
|
12
|
+
export function createReportTurn(deps) {
|
|
13
|
+
return (crew, input) => deps.uow.run(async (tx) => {
|
|
14
|
+
const held = await tx.leases.findTurnForUpdate(crew.fleetId, crew.leaseId);
|
|
15
|
+
if (!held) {
|
|
16
|
+
return refuseEndedLease();
|
|
17
|
+
}
|
|
18
|
+
const { turn, events } = reportTurn(held.turn, { crew, ...input, now: deps.clock.now() });
|
|
19
|
+
if (events.length > 0) {
|
|
20
|
+
await tx.leases.saveTurn({ fleetId: crew.fleetId, leaseId: crew.leaseId, turn });
|
|
21
|
+
}
|
|
22
|
+
for (const event of events) {
|
|
23
|
+
await recordEvent({ events: tx.events, ids: deps.ids }, event);
|
|
24
|
+
}
|
|
25
|
+
return ok(undefined);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=report-turn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-turn.js","sourceRoot":"","sources":["../../../src/domain/registry/report-turn.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AASvC;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAuE;IACtG,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACrB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAA0C,EAAE;QAChE,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,gBAAgB,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC1F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -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;
|