@aeolus-fleet/core 0.20.4 → 0.21.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/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 +5 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +8 -3
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +5 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +8 -3
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/CrewRequest.d.ts +53 -1
- package/dist/adapters/prisma/generated/models/NetworkSettings.d.ts +107 -1
- package/dist/adapters/prisma/generated/models/ReachRefusal.d.ts +40 -1
- package/dist/adapters/prisma/migrate.js +17 -4
- package/dist/adapters/prisma/migrate.js.map +1 -1
- package/dist/adapters/prisma/network.js +30 -10
- package/dist/adapters/prisma/network.js.map +1 -1
- package/dist/adapters/prisma/registry.js +14 -6
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.d.ts +2 -0
- package/dist/adapters/prisma/rows.js +8 -1
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +6 -0
- package/dist/adapters/trpc/fleet.d.ts +35 -3
- package/dist/adapters/trpc/fleet.js +32 -3
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/router.d.ts +32 -3
- package/dist/adapters/trpc/ship-contract.js +2 -0
- package/dist/adapters/trpc/ship-contract.js.map +1 -1
- package/dist/adapters/trpc/trpc.js +2 -0
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/domain/registry/check-reach.d.ts +20 -1
- package/dist/domain/registry/check-reach.js +20 -6
- package/dist/domain/registry/check-reach.js.map +1 -1
- package/dist/domain/registry/crew-request.d.ts +9 -3
- package/dist/domain/registry/crew-request.js +18 -6
- package/dist/domain/registry/crew-request.js.map +1 -1
- package/dist/domain/registry/explain-reach.d.ts +34 -0
- package/dist/domain/registry/explain-reach.js +42 -0
- package/dist/domain/registry/explain-reach.js.map +1 -0
- package/dist/domain/registry/network-settings.d.ts +70 -6
- package/dist/domain/registry/network-settings.js +97 -4
- package/dist/domain/registry/network-settings.js.map +1 -1
- package/dist/domain/registry/ports.d.ts +8 -0
- package/dist/domain/registry/reach-refusal.d.ts +3 -1
- package/dist/domain/registry/read-assigned-crew-requests.d.ts +2 -2
- package/dist/domain/registry/read-assigned-crew-requests.js +2 -1
- package/dist/domain/registry/read-assigned-crew-requests.js.map +1 -1
- package/dist/domain/registry/register-network-plugin.d.ts +28 -0
- package/dist/domain/registry/register-network-plugin.js +26 -0
- package/dist/domain/registry/register-network-plugin.js.map +1 -0
- package/dist/domain/registry/retire-ship.d.ts +7 -4
- package/dist/domain/registry/retire-ship.js +14 -3
- package/dist/domain/registry/retire-ship.js.map +1 -1
- package/dist/domain/registry/set-network-rules.js +1 -1
- package/dist/domain/registry/set-network-rules.js.map +1 -1
- package/dist/domain/registry/unregister-network-plugin.d.ts +27 -0
- package/dist/domain/registry/unregister-network-plugin.js +25 -0
- package/dist/domain/registry/unregister-network-plugin.js.map +1 -0
- package/dist/domain/shared/errors.d.ts +1 -1
- package/dist/domain/shared/errors.js.map +1 -1
- package/dist/wiring.d.ts +6 -0
- package/dist/wiring.js +6 -0
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261010070000_crew_request_is_final/migration.sql +7 -0
- package/src/adapters/prisma/migrations/20261010080000_network_plugin/migration.sql +21 -0
- package/src/adapters/prisma/migrations/20261010110000_network_rules_through_plugin/migration.sql +4 -0
- package/src/adapters/prisma/schema.prisma +13 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ShipId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { Caller } from '../shared/caller.js';
|
|
3
|
+
import type { Clock } from '../shared/clock.js';
|
|
4
|
+
import { type DomainError } from '../shared/errors.js';
|
|
5
|
+
import { type Result } from '../shared/result.js';
|
|
6
|
+
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
7
|
+
import { type CheckReachTx } from './check-reach.js';
|
|
8
|
+
import type { ShipRepository } from './ports.js';
|
|
9
|
+
export interface ExplainReachTx {
|
|
10
|
+
networkSettings: CheckReachTx['networkSettings'];
|
|
11
|
+
ships: Pick<ShipRepository, 'find' | 'listActive'>;
|
|
12
|
+
labels: CheckReachTx['labels'];
|
|
13
|
+
leases: CheckReachTx['leases'];
|
|
14
|
+
}
|
|
15
|
+
export type ExplainReachFailure = DomainError<'NOT_THE_OPERATOR_SHIP' | 'SHIP_NOT_FOUND'>;
|
|
16
|
+
export type ExplainReach = (caller: Caller, input: {
|
|
17
|
+
fromShipId: ShipId;
|
|
18
|
+
toShipId?: ShipId;
|
|
19
|
+
}) => Promise<Result<{
|
|
20
|
+
reachableShipIds: ShipId[];
|
|
21
|
+
}, ExplainReachFailure>>;
|
|
22
|
+
/**
|
|
23
|
+
* Use case: argo asks which ships a ship reaches now, or whether it reaches
|
|
24
|
+
* one ship (design points 11 and 12 on #260). It answers as a send would be
|
|
25
|
+
* checked at this moment: the rules in force, what the networking plugin
|
|
26
|
+
* declared while it does not respond, argo both ways. There is no message, so
|
|
27
|
+
* no answer to a sender. It answers the ships, never the rules or the reasons,
|
|
28
|
+
* and records nothing: an explain is not a send. Only argo; the viewer ship
|
|
29
|
+
* receives nothing, so it is never reached.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createExplainReach(deps: {
|
|
32
|
+
uow: UnitOfWork<ExplainReachTx>;
|
|
33
|
+
clock: Clock;
|
|
34
|
+
}): ExplainReach;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { refuse } from '../shared/errors.js';
|
|
2
|
+
import { ok } from '../shared/result.js';
|
|
3
|
+
import { reaching, rulesInForceAt, shipAsItIs } from './check-reach.js';
|
|
4
|
+
import { allowsReach } from './network-settings.js';
|
|
5
|
+
/**
|
|
6
|
+
* Use case: argo asks which ships a ship reaches now, or whether it reaches
|
|
7
|
+
* one ship (design points 11 and 12 on #260). It answers as a send would be
|
|
8
|
+
* checked at this moment: the rules in force, what the networking plugin
|
|
9
|
+
* declared while it does not respond, argo both ways. There is no message, so
|
|
10
|
+
* no answer to a sender. It answers the ships, never the rules or the reasons,
|
|
11
|
+
* and records nothing: an explain is not a send. Only argo; the viewer ship
|
|
12
|
+
* receives nothing, so it is never reached.
|
|
13
|
+
*/
|
|
14
|
+
export function createExplainReach(deps) {
|
|
15
|
+
return (caller, input) => deps.uow.run(async (tx) => {
|
|
16
|
+
if (caller.kind !== 'operator') {
|
|
17
|
+
return refuse('NOT_THE_OPERATOR_SHIP', 'Only argo explains reach');
|
|
18
|
+
}
|
|
19
|
+
const { fleetId } = caller;
|
|
20
|
+
const from = await tx.ships.find(fleetId, input.fromShipId);
|
|
21
|
+
if (from?.retiredAt !== null) {
|
|
22
|
+
return refuse('SHIP_NOT_FOUND', 'The fleet has no active ship with this id to explain from');
|
|
23
|
+
}
|
|
24
|
+
const active = await tx.ships.listActive(fleetId);
|
|
25
|
+
const others = active.filter((ship) => ship.id !== from.id && (input.toShipId === undefined || ship.id === input.toShipId));
|
|
26
|
+
if (input.toShipId !== undefined && others.length === 0 && input.toShipId !== from.id) {
|
|
27
|
+
return refuse('SHIP_NOT_FOUND', 'The fleet has no active ship with this id to explain reach to');
|
|
28
|
+
}
|
|
29
|
+
const settings = await tx.networkSettings.findForShare(fleetId);
|
|
30
|
+
const inForce = await rulesInForceAt(tx, { settings, now: deps.clock.now() });
|
|
31
|
+
const sender = reaching(await shipAsItIs(tx, from));
|
|
32
|
+
const reachableShipIds = [];
|
|
33
|
+
for (const ship of others) {
|
|
34
|
+
const recipient = reaching(await shipAsItIs(tx, ship));
|
|
35
|
+
if (allowsReach(inForce, { sender, recipient, isAnswerToSender: false })) {
|
|
36
|
+
reachableShipIds.push(ship.id);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return ok({ reachableShipIds });
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=explain-reach.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain-reach.js","sourceRoot":"","sources":["../../../src/domain/registry/explain-reach.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAiBpD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAuD;IACxF,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAwE,EAAE;QAC9F,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAC5D,IAAI,IAAI,EAAE,SAAS,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,gBAAgB,EAAE,2DAA2D,CAAC,CAAC;QAC/F,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClD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 -5,7 +5,7 @@
|
|
|
5
5
|
* fleet holds its rules, or none (all-to-all), with a version that moves on
|
|
6
6
|
* every set, so a refusal names the settings that refused it.
|
|
7
7
|
*/
|
|
8
|
-
import { type FleetId, type LabelValueId, type ShipKind } from '@aeolus-fleet/common';
|
|
8
|
+
import { type FleetId, type LabelValueId, type NetworkPluginDeclaration, type ShipId, type ShipKind, type WhileUnavailable } from '@aeolus-fleet/common';
|
|
9
9
|
import { type DomainError } from '../shared/errors.js';
|
|
10
10
|
import type { Actor, NewEvent } from '../shared/events.js';
|
|
11
11
|
import { type Result } from '../shared/result.js';
|
|
@@ -14,31 +14,95 @@ export interface NetworkRule {
|
|
|
14
14
|
from: readonly LabelValueId[];
|
|
15
15
|
to: readonly LabelValueId[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The fleet's networking plugin (decision 0035): the ship that alone sets the
|
|
19
|
+
* rules while registered, with what it declared for while it is unavailable.
|
|
20
|
+
*/
|
|
21
|
+
export interface NetworkPlugin extends NetworkPluginDeclaration {
|
|
22
|
+
shipId: ShipId;
|
|
23
|
+
}
|
|
17
24
|
export interface NetworkSettings {
|
|
18
25
|
fleetId: FleetId;
|
|
19
26
|
/** The rules every send is checked against; none is all-to-all, an empty list allows only the fixed exceptions. */
|
|
20
27
|
rules: readonly NetworkRule[] | null;
|
|
21
|
-
/** 0 until the fleet first
|
|
28
|
+
/** 0 until the fleet first changes its settings; one more on every change. */
|
|
22
29
|
version: number;
|
|
30
|
+
/** The fleet's networking plugin, or none: then the fleet has no rules, and nobody sets them. */
|
|
31
|
+
plugin: NetworkPlugin | null;
|
|
23
32
|
}
|
|
24
|
-
/** A fleet that never set rules: none, at version 0. */
|
|
33
|
+
/** A fleet that never set rules: none, at version 0, without a plugin. */
|
|
25
34
|
export declare function noNetworkSettings(fleetId: FleetId): NetworkSettings;
|
|
26
|
-
export type
|
|
35
|
+
export type NotTheNetworkPlugin = DomainError<'NOT_THE_NETWORK_PLUGIN'>;
|
|
36
|
+
export type SetNetworkRulesRefusal = DomainError<'INVALID_NETWORK_RULES'> | NotTheNetworkPlugin;
|
|
37
|
+
export type RegisterNetworkPluginRefusal = DomainError<'NETWORK_PLUGIN_REGISTERED'>;
|
|
38
|
+
/**
|
|
39
|
+
* The ship becomes the fleet's networking plugin, with what it declared, at
|
|
40
|
+
* the next version, with NetworkPluginRegistered. A fleet without a plugin
|
|
41
|
+
* has no rules, so the plugin starts from none until it supplies its own. The plugin may register again, replacing what it
|
|
42
|
+
* declared; another ship is refused until it unregisters: one owner of the
|
|
43
|
+
* rules, as a label has one.
|
|
44
|
+
*/
|
|
45
|
+
export declare function registerNetworkPlugin(current: NetworkSettings, change: {
|
|
46
|
+
shipId: ShipId;
|
|
47
|
+
declaration: NetworkPluginDeclaration;
|
|
48
|
+
at: Date;
|
|
49
|
+
actor: Actor;
|
|
50
|
+
}): Result<{
|
|
51
|
+
settings: NetworkSettings;
|
|
52
|
+
events: NewEvent[];
|
|
53
|
+
}, RegisterNetworkPluginRefusal>;
|
|
54
|
+
/**
|
|
55
|
+
* The fleet's plugin goes, and its rules with it: no plugin is all-to-all
|
|
56
|
+
* (decision 0035), at the next version, with NetworkPluginUnregistered. Only
|
|
57
|
+
* the plugin's own ship unregisters it; its retirement does too.
|
|
58
|
+
*/
|
|
59
|
+
export declare function unregisterNetworkPlugin(current: NetworkSettings, change: {
|
|
60
|
+
shipId: ShipId;
|
|
61
|
+
at: Date;
|
|
62
|
+
actor: Actor;
|
|
63
|
+
}): Result<{
|
|
64
|
+
settings: NetworkSettings;
|
|
65
|
+
events: NewEvent[];
|
|
66
|
+
}, NotTheNetworkPlugin>;
|
|
27
67
|
/**
|
|
28
68
|
* The fleet's rules from now on, replacing the ones it had, at the next
|
|
29
69
|
* version, with NetworkRulesSet. The rules are within the decision's limits:
|
|
30
70
|
* at most 200, each selector at most 20 label values, as a ship carries no
|
|
31
71
|
* more, each once. A value id need not exist: an unknown one matches no ship,
|
|
32
|
-
* as in label selection.
|
|
72
|
+
* as in label selection. Only the fleet's registered networking plugin sets
|
|
73
|
+
* them, argo included: rules exist only through a plugin (decision 0035).
|
|
33
74
|
*/
|
|
34
75
|
export declare function setNetworkRules(current: NetworkSettings, change: {
|
|
35
76
|
rules: readonly NetworkRule[] | null;
|
|
77
|
+
shipId: ShipId;
|
|
36
78
|
at: Date;
|
|
37
79
|
actor: Actor;
|
|
38
80
|
}): Result<{
|
|
39
81
|
settings: NetworkSettings;
|
|
40
82
|
events: NewEvent[];
|
|
41
83
|
}, SetNetworkRulesRefusal>;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the plugin responds at `now` (decision 0035): its ship holds a
|
|
86
|
+
* lease whose crew called the fleet no longer ago than it declared. Its last
|
|
87
|
+
* call is the lease's last seen; nothing else acts on it, and nothing here
|
|
88
|
+
* ends the lease.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isNetworkPluginResponding(plugin: NetworkPlugin, crew: {
|
|
91
|
+
lastSeenAt: Date | undefined;
|
|
92
|
+
now: Date;
|
|
93
|
+
}): boolean;
|
|
94
|
+
/** The rules a send is checked against, and what the plugin declared when it is the reason. */
|
|
95
|
+
export interface RulesInForce {
|
|
96
|
+
rules: readonly NetworkRule[] | null;
|
|
97
|
+
whilePluginUnavailable: Exclude<WhileUnavailable, 'open-all'> | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The rules in force: the settings' own, unless the fleet's networking plugin
|
|
101
|
+
* is not responding. Then what it declared applies: block-all leaves only
|
|
102
|
+
* the fixed exceptions, open-all none (all-to-all), keep-latest the rules it
|
|
103
|
+
* supplied last.
|
|
104
|
+
*/
|
|
105
|
+
export declare function rulesInForce(settings: NetworkSettings, isPluginResponding: boolean): RulesInForce;
|
|
42
106
|
/** A ship as a send's check sees it: its kind, for the argo exception, and the label values it carries. */
|
|
43
107
|
export interface ReachingShip {
|
|
44
108
|
kind: ShipKind;
|
|
@@ -51,7 +115,7 @@ export interface ReachingShip {
|
|
|
51
115
|
* answers the sender of a message it received. Otherwise a rule must match
|
|
52
116
|
* the sender with its `from` and the recipient with its `to`.
|
|
53
117
|
*/
|
|
54
|
-
export declare function allowsReach(settings: NetworkSettings, send: {
|
|
118
|
+
export declare function allowsReach(settings: Pick<NetworkSettings, 'rules'>, send: {
|
|
55
119
|
sender: ReachingShip;
|
|
56
120
|
recipient: ReachingShip;
|
|
57
121
|
isAnswerToSender: boolean;
|
|
@@ -8,26 +8,88 @@
|
|
|
8
8
|
import { NETWORK_RULES_MAX, SHIP_LABELS_MAX } from '@aeolus-fleet/common';
|
|
9
9
|
import { refuse } from '../shared/errors.js';
|
|
10
10
|
import { ok } from '../shared/result.js';
|
|
11
|
-
/** A fleet that never set rules: none, at version 0. */
|
|
11
|
+
/** A fleet that never set rules: none, at version 0, without a plugin. */
|
|
12
12
|
export function noNetworkSettings(fleetId) {
|
|
13
|
-
return { fleetId, rules: null, version: 0 };
|
|
13
|
+
return { fleetId, rules: null, version: 0, plugin: null };
|
|
14
|
+
}
|
|
15
|
+
function refuseNotThePlugin() {
|
|
16
|
+
return refuse('NOT_THE_NETWORK_PLUGIN', "Only the fleet's networking plugin does this (decision 0035)");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The ship becomes the fleet's networking plugin, with what it declared, at
|
|
20
|
+
* the next version, with NetworkPluginRegistered. A fleet without a plugin
|
|
21
|
+
* has no rules, so the plugin starts from none until it supplies its own. The plugin may register again, replacing what it
|
|
22
|
+
* declared; another ship is refused until it unregisters: one owner of the
|
|
23
|
+
* rules, as a label has one.
|
|
24
|
+
*/
|
|
25
|
+
export function registerNetworkPlugin(current, change) {
|
|
26
|
+
const { shipId, declaration } = change;
|
|
27
|
+
if (current.plugin !== null && current.plugin.shipId !== shipId) {
|
|
28
|
+
return refuse('NETWORK_PLUGIN_REGISTERED', 'The fleet already has a networking plugin; it unregisters first (decision 0035)');
|
|
29
|
+
}
|
|
30
|
+
const settings = {
|
|
31
|
+
...current,
|
|
32
|
+
version: current.version + 1,
|
|
33
|
+
plugin: { shipId, whileUnavailable: declaration.whileUnavailable, notRespondingAfterSeconds: declaration.notRespondingAfterSeconds },
|
|
34
|
+
};
|
|
35
|
+
return ok({
|
|
36
|
+
settings,
|
|
37
|
+
events: [
|
|
38
|
+
{
|
|
39
|
+
type: 'NetworkPluginRegistered',
|
|
40
|
+
fleetId: current.fleetId,
|
|
41
|
+
occurredAt: change.at,
|
|
42
|
+
actor: change.actor,
|
|
43
|
+
shipId,
|
|
44
|
+
details: { version: settings.version, whileUnavailable: declaration.whileUnavailable, notRespondingAfterSeconds: declaration.notRespondingAfterSeconds },
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The fleet's plugin goes, and its rules with it: no plugin is all-to-all
|
|
51
|
+
* (decision 0035), at the next version, with NetworkPluginUnregistered. Only
|
|
52
|
+
* the plugin's own ship unregisters it; its retirement does too.
|
|
53
|
+
*/
|
|
54
|
+
export function unregisterNetworkPlugin(current, change) {
|
|
55
|
+
if (current.plugin?.shipId !== change.shipId) {
|
|
56
|
+
return refuseNotThePlugin();
|
|
57
|
+
}
|
|
58
|
+
const settings = { fleetId: current.fleetId, rules: null, version: current.version + 1, plugin: null };
|
|
59
|
+
return ok({
|
|
60
|
+
settings,
|
|
61
|
+
events: [
|
|
62
|
+
{
|
|
63
|
+
type: 'NetworkPluginUnregistered',
|
|
64
|
+
fleetId: current.fleetId,
|
|
65
|
+
occurredAt: change.at,
|
|
66
|
+
actor: change.actor,
|
|
67
|
+
shipId: change.shipId,
|
|
68
|
+
details: { version: settings.version },
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
14
72
|
}
|
|
15
73
|
/**
|
|
16
74
|
* The fleet's rules from now on, replacing the ones it had, at the next
|
|
17
75
|
* version, with NetworkRulesSet. The rules are within the decision's limits:
|
|
18
76
|
* at most 200, each selector at most 20 label values, as a ship carries no
|
|
19
77
|
* more, each once. A value id need not exist: an unknown one matches no ship,
|
|
20
|
-
* as in label selection.
|
|
78
|
+
* as in label selection. Only the fleet's registered networking plugin sets
|
|
79
|
+
* them, argo included: rules exist only through a plugin (decision 0035).
|
|
21
80
|
*/
|
|
22
81
|
export function setNetworkRules(current, change) {
|
|
23
82
|
const { rules } = change;
|
|
83
|
+
if (current.plugin?.shipId !== change.shipId) {
|
|
84
|
+
return refuseNotThePlugin();
|
|
85
|
+
}
|
|
24
86
|
if (rules !== null) {
|
|
25
87
|
const invalid = invalidRules(rules);
|
|
26
88
|
if (invalid !== undefined) {
|
|
27
89
|
return refuse('INVALID_NETWORK_RULES', `${invalid} (decision 0034)`);
|
|
28
90
|
}
|
|
29
91
|
}
|
|
30
|
-
const settings = {
|
|
92
|
+
const settings = { ...current, rules: rules?.map(copyOfRule) ?? null, version: current.version + 1 };
|
|
31
93
|
return ok({
|
|
32
94
|
settings,
|
|
33
95
|
events: [
|
|
@@ -60,6 +122,37 @@ function invalidRules(rules) {
|
|
|
60
122
|
function copyOfRule(rule) {
|
|
61
123
|
return { from: [...rule.from], to: [...rule.to] };
|
|
62
124
|
}
|
|
125
|
+
const MILLISECONDS_PER_SECOND = 1000;
|
|
126
|
+
/**
|
|
127
|
+
* Whether the plugin responds at `now` (decision 0035): its ship holds a
|
|
128
|
+
* lease whose crew called the fleet no longer ago than it declared. Its last
|
|
129
|
+
* call is the lease's last seen; nothing else acts on it, and nothing here
|
|
130
|
+
* ends the lease.
|
|
131
|
+
*/
|
|
132
|
+
export function isNetworkPluginResponding(plugin, crew) {
|
|
133
|
+
const { lastSeenAt, now } = crew;
|
|
134
|
+
return lastSeenAt !== undefined && now.getTime() - lastSeenAt.getTime() <= plugin.notRespondingAfterSeconds * MILLISECONDS_PER_SECOND;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The rules in force: the settings' own, unless the fleet's networking plugin
|
|
138
|
+
* is not responding. Then what it declared applies: block-all leaves only
|
|
139
|
+
* the fixed exceptions, open-all none (all-to-all), keep-latest the rules it
|
|
140
|
+
* supplied last.
|
|
141
|
+
*/
|
|
142
|
+
export function rulesInForce(settings, isPluginResponding) {
|
|
143
|
+
const { plugin, rules } = settings;
|
|
144
|
+
if (plugin === null || isPluginResponding) {
|
|
145
|
+
return { rules, whilePluginUnavailable: null };
|
|
146
|
+
}
|
|
147
|
+
switch (plugin.whileUnavailable) {
|
|
148
|
+
case 'block-all':
|
|
149
|
+
return { rules: [], whilePluginUnavailable: 'block-all' };
|
|
150
|
+
case 'open-all':
|
|
151
|
+
return { rules: null, whilePluginUnavailable: null };
|
|
152
|
+
case 'keep-latest':
|
|
153
|
+
return { rules, whilePluginUnavailable: 'keep-latest' };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
63
156
|
/**
|
|
64
157
|
* Whether the settings let the sender reach the recipient. With no rules,
|
|
65
158
|
* every ship reaches every ship. The fixed exceptions hold whatever the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-settings.js","sourceRoot":"","sources":["../../../src/domain/registry/network-settings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"network-settings.js","sourceRoot":"","sources":["../../../src/domain/registry/network-settings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAqH,MAAM,sBAAsB,CAAC;AAE7L,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AA0BtD,0EAA0E;AAC1E,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC5D,CAAC;AAQD,SAAS,kBAAkB;IACzB,OAAO,MAAM,CAAC,wBAAwB,E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OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AAClG,CAAC;AAED,qGAAqG;AACrG,SAAS,OAAO,CAAC,QAAiC,EAAE,IAAkB;IACpE,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -110,6 +110,8 @@ export interface ShipRepository {
|
|
|
110
110
|
findActiveByNameForShare(fleetId: FleetId, name: string): Promise<Ship | undefined>;
|
|
111
111
|
/** Whether at least one ship of the fleet with this type is not retired and receives: the viewer ship receives nothing (decision 0022). */
|
|
112
112
|
hasActiveShipOfType(fleetId: FleetId, type: string): Promise<boolean>;
|
|
113
|
+
/** The fleet's ships that are not retired and receive, argo included, never the viewer ship (decision 0022). By id. */
|
|
114
|
+
listActive(fleetId: FleetId): Promise<Ship[]>;
|
|
113
115
|
/** The fleet's ships of the type that may take a type delivery: not retired, never the viewer ship. By id. */
|
|
114
116
|
listActiveOfType(fleetId: FleetId, type: string): Promise<Ship[]>;
|
|
115
117
|
/** Gives the ship a new name. */
|
|
@@ -148,6 +150,12 @@ export interface LeaseRepository {
|
|
|
148
150
|
leaseId: LeaseId;
|
|
149
151
|
at: Date;
|
|
150
152
|
}): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* When the crew of the ship's open lease last called the fleet (when it
|
|
155
|
+
* claimed the ship, before any call), read without a lock; undefined when
|
|
156
|
+
* the ship holds no lease.
|
|
157
|
+
*/
|
|
158
|
+
findLastSeen(fleetId: FleetId, shipId: ShipId): Promise<Date | undefined>;
|
|
151
159
|
/** The lease's report, the lease locked until the unit of work ends; undefined once it has ended. */
|
|
152
160
|
findReportForUpdate(fleetId: FleetId, leaseId: LeaseId): Promise<{
|
|
153
161
|
report: ShipReport | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FleetId, ReachRefusalId, ShipId } from '@aeolus-fleet/common';
|
|
1
|
+
import type { FleetId, ReachRefusalId, ShipId, WhileUnavailable } from '@aeolus-fleet/common';
|
|
2
2
|
import type { CarriedLabel } from './label.js';
|
|
3
3
|
/** A ship as a refusal saw it: its id, its name and the label values it carried then, by key. */
|
|
4
4
|
export interface RefusedShip {
|
|
@@ -27,4 +27,6 @@ export interface ReachRefusal {
|
|
|
27
27
|
ships: readonly RefusedShip[];
|
|
28
28
|
};
|
|
29
29
|
settingsVersion: number;
|
|
30
|
+
/** What the networking plugin declared, when it refused while the plugin was not responding (decision 0035); null otherwise. */
|
|
31
|
+
whilePluginUnavailable: Exclude<WhileUnavailable, 'open-all'> | null;
|
|
30
32
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Caller } from '../shared/caller.js';
|
|
2
2
|
import type { CrewRequest } from './crew-request.js';
|
|
3
3
|
import type { CrewRequestRepository } from './ports.js';
|
|
4
|
-
/** A crew request as its trierarch reads it: which ship, with what settings,
|
|
5
|
-
export type AssignedCrewRequest = Pick<CrewRequest, 'shipId' | 'settings' | 'settingsVersion' | 'requestedAt' | 'status'>;
|
|
4
|
+
/** A crew request as its trierarch reads it: which ship, with what settings, how it stands, and whether its crew is final. */
|
|
5
|
+
export type AssignedCrewRequest = Pick<CrewRequest, 'shipId' | 'settings' | 'settingsVersion' | 'requestedAt' | 'status' | 'isFinal'>;
|
|
6
6
|
export type ReadAssignedCrewRequests = (caller: Caller) => Promise<AssignedCrewRequest[]>;
|
|
7
7
|
/**
|
|
8
8
|
* Use case: a trierarch reads the crew requests assigned to its ship, oldest
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* (decision 0029). Its scope (crew:run) is checked before this runs.
|
|
5
5
|
*/
|
|
6
6
|
export function createReadAssignedCrewRequests(deps) {
|
|
7
|
-
return async (caller) => (await deps.crewRequests.listAssignedTo(caller.fleetId, caller.shipId)).map(({ shipId, settings, settingsVersion, requestedAt, status }) => ({
|
|
7
|
+
return async (caller) => (await deps.crewRequests.listAssignedTo(caller.fleetId, caller.shipId)).map(({ shipId, settings, settingsVersion, requestedAt, status, isFinal }) => ({
|
|
8
8
|
shipId,
|
|
9
9
|
settings,
|
|
10
10
|
settingsVersion,
|
|
11
11
|
requestedAt,
|
|
12
12
|
status,
|
|
13
|
+
isFinal,
|
|
13
14
|
}));
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=read-assigned-crew-requests.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-assigned-crew-requests.js","sourceRoot":"","sources":["../../../src/domain/registry/read-assigned-crew-requests.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAqE;IAClH,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,CACtB,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"read-assigned-crew-requests.js","sourceRoot":"","sources":["../../../src/domain/registry/read-assigned-crew-requests.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,IAAqE;IAClH,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,CACtB,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QACpJ,MAAM;QACN,QAAQ;QACR,eAAe;QACf,WAAW;QACX,MAAM;QACN,OAAO;KACR,CAAC,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IdGenerator, NetworkPluginDeclaration } from '@aeolus-fleet/common';
|
|
2
|
+
import type { Caller } 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 RegisterNetworkPluginRefusal } from './network-settings.js';
|
|
8
|
+
import type { NetworkSettingsRepository } from './ports.js';
|
|
9
|
+
export interface RegisterNetworkPluginTx {
|
|
10
|
+
networkSettings: Pick<NetworkSettingsRepository, 'findForUpdate' | 'save'>;
|
|
11
|
+
events: EventLog;
|
|
12
|
+
}
|
|
13
|
+
export type RegisterNetworkPlugin = (caller: Caller, input: NetworkPluginDeclaration) => Promise<Result<{
|
|
14
|
+
version: number;
|
|
15
|
+
}, RegisterNetworkPluginRefusal>>;
|
|
16
|
+
/**
|
|
17
|
+
* Use case: the caller's ship becomes the fleet's networking plugin, saying
|
|
18
|
+
* what happens to sends while it is unavailable and after how long without a
|
|
19
|
+
* call it is not responding (decision 0035). Its scope (fleet:network) is
|
|
20
|
+
* checked before this runs. In one unit of work, holding the settings
|
|
21
|
+
* exclusively as a set of rules does: the settings at their next version,
|
|
22
|
+
* and NetworkPluginRegistered.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createRegisterNetworkPlugin(deps: {
|
|
25
|
+
uow: UnitOfWork<RegisterNetworkPluginTx>;
|
|
26
|
+
clock: Clock;
|
|
27
|
+
ids: IdGenerator;
|
|
28
|
+
}): RegisterNetworkPlugin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { recordEvent, shipActor } from '../shared/events.js';
|
|
2
|
+
import { ok } from '../shared/result.js';
|
|
3
|
+
import { registerNetworkPlugin } from './network-settings.js';
|
|
4
|
+
/**
|
|
5
|
+
* Use case: the caller's ship becomes the fleet's networking plugin, saying
|
|
6
|
+
* what happens to sends while it is unavailable and after how long without a
|
|
7
|
+
* call it is not responding (decision 0035). Its scope (fleet:network) is
|
|
8
|
+
* checked before this runs. In one unit of work, holding the settings
|
|
9
|
+
* exclusively as a set of rules does: the settings at their next version,
|
|
10
|
+
* and NetworkPluginRegistered.
|
|
11
|
+
*/
|
|
12
|
+
export function createRegisterNetworkPlugin(deps) {
|
|
13
|
+
return (caller, declaration) => deps.uow.run(async (tx) => {
|
|
14
|
+
const current = await tx.networkSettings.findForUpdate(caller.fleetId);
|
|
15
|
+
const registered = registerNetworkPlugin(current, { shipId: caller.shipId, declaration, at: deps.clock.now(), actor: shipActor(caller.shipId) });
|
|
16
|
+
if (!registered.isOk) {
|
|
17
|
+
return registered;
|
|
18
|
+
}
|
|
19
|
+
await tx.networkSettings.save(registered.value.settings);
|
|
20
|
+
for (const event of registered.value.events) {
|
|
21
|
+
await recordEvent({ events: tx.events, ids: deps.ids }, event);
|
|
22
|
+
}
|
|
23
|
+
return ok({ version: registered.value.settings.version });
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=register-network-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-network-plugin.js","sourceRoot":"","sources":["../../../src/domain/registry/register-network-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,qBAAqB,EAAqC,MAAM,uBAAuB,CAAC;AAUjG;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAkF;IAC5H,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAsE,EAAE;QAC5F,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjJ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,MAAM,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzD,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC5C,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,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -6,13 +6,14 @@ import { type DomainError } from '../shared/errors.js';
|
|
|
6
6
|
import { type Result } from '../shared/result.js';
|
|
7
7
|
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
8
8
|
import { type LeaseTx } from './leases.js';
|
|
9
|
-
import type { ClearRequestRepository, CrewRequestRepository, LabelRepository, ShipRepository } from './ports.js';
|
|
9
|
+
import type { ClearRequestRepository, CrewRequestRepository, LabelRepository, NetworkSettingsRepository, ShipRepository } from './ports.js';
|
|
10
10
|
import { type RetireRefusal } from './ship.js';
|
|
11
11
|
export interface RetireShipTx extends LeaseTx, CredentialTx {
|
|
12
12
|
ships: ShipRepository;
|
|
13
13
|
crewRequests: CrewRequestRepository;
|
|
14
14
|
clearRequests: ClearRequestRepository;
|
|
15
15
|
labels: LabelRepository;
|
|
16
|
+
networkSettings: Pick<NetworkSettingsRepository, 'findForUpdate' | 'save'>;
|
|
16
17
|
}
|
|
17
18
|
export type RetireShipRefusal = DomainError<'SHIP_NOT_FOUND'> | RetireRefusal;
|
|
18
19
|
export type RetireShip = (caller: Caller, input: {
|
|
@@ -33,13 +34,15 @@ export type RetireShip = (caller: Caller, input: {
|
|
|
33
34
|
* and the labels it owns retire with it, each locked first and every
|
|
34
35
|
* assignment of it gone first (decision 0031). A retired trierarch clears
|
|
35
36
|
* nothing: its pending clear requests go, one WorktreeClearRemoved each
|
|
36
|
-
* (decision 0032).
|
|
37
|
-
* (fleet:manage) is
|
|
37
|
+
* (decision 0032). A retired networking plugin unregisters, its rules going
|
|
38
|
+
* with it: all-to-all (decision 0035). The caller's scope (fleet:manage) is
|
|
39
|
+
* checked before this runs.
|
|
38
40
|
*
|
|
39
41
|
* It locks the ship first, as a release does (FOR NO KEY UPDATE). A send to
|
|
40
42
|
* the ship holds it FOR SHARE while it resolves the selector, so the two
|
|
41
43
|
* serialise: a send that commits first has its delivery abandoned here, and a
|
|
42
|
-
* send after finds the ship retired and is refused.
|
|
44
|
+
* send after finds the ship retired and is refused. Then it holds the
|
|
45
|
+
* network settings exclusively, after the ship as every send takes them.
|
|
43
46
|
*/
|
|
44
47
|
export declare function createRetireShip(deps: {
|
|
45
48
|
uow: UnitOfWork<RetireShipTx>;
|
|
@@ -6,6 +6,7 @@ import { removeClearRequestsOf } from './clear-request.js';
|
|
|
6
6
|
import { removeCrewRequest } from './crew-request.js';
|
|
7
7
|
import { retireLabelsWith } from './label.js';
|
|
8
8
|
import { endLease } from './leases.js';
|
|
9
|
+
import { unregisterNetworkPlugin } from './network-settings.js';
|
|
9
10
|
import { checkCanRetire } from './ship.js';
|
|
10
11
|
/**
|
|
11
12
|
* Use case: the caller retires a ship of its fleet for good (Retire): any ship
|
|
@@ -20,13 +21,15 @@ import { checkCanRetire } from './ship.js';
|
|
|
20
21
|
* and the labels it owns retire with it, each locked first and every
|
|
21
22
|
* assignment of it gone first (decision 0031). A retired trierarch clears
|
|
22
23
|
* nothing: its pending clear requests go, one WorktreeClearRemoved each
|
|
23
|
-
* (decision 0032).
|
|
24
|
-
* (fleet:manage) is
|
|
24
|
+
* (decision 0032). A retired networking plugin unregisters, its rules going
|
|
25
|
+
* with it: all-to-all (decision 0035). The caller's scope (fleet:manage) is
|
|
26
|
+
* checked before this runs.
|
|
25
27
|
*
|
|
26
28
|
* It locks the ship first, as a release does (FOR NO KEY UPDATE). A send to
|
|
27
29
|
* the ship holds it FOR SHARE while it resolves the selector, so the two
|
|
28
30
|
* serialise: a send that commits first has its delivery abandoned here, and a
|
|
29
|
-
* send after finds the ship retired and is refused.
|
|
31
|
+
* send after finds the ship retired and is refused. Then it holds the
|
|
32
|
+
* network settings exclusively, after the ship as every send takes them.
|
|
30
33
|
*/
|
|
31
34
|
export function createRetireShip(deps) {
|
|
32
35
|
return (caller, { shipId }) => deps.uow.run(async (tx) => {
|
|
@@ -87,6 +90,14 @@ export function createRetireShip(deps) {
|
|
|
87
90
|
for (const event of labels.events) {
|
|
88
91
|
await recordEvent(recorded, event);
|
|
89
92
|
}
|
|
93
|
+
// Any ship but the fleet's networking plugin leaves the settings as they are.
|
|
94
|
+
const unregistered = unregisterNetworkPlugin(await tx.networkSettings.findForUpdate(fleetId), { shipId, at, actor });
|
|
95
|
+
if (unregistered.isOk) {
|
|
96
|
+
await tx.networkSettings.save(unregistered.value.settings);
|
|
97
|
+
for (const event of unregistered.value.events) {
|
|
98
|
+
await recordEvent(recorded, event);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
90
101
|
return ok({ abandonedDeliveries: abandoned.length });
|
|
91
102
|
});
|
|
92
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retire-ship.js","sourceRoot":"","sources":["../../../src/domain/registry/retire-ship.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"retire-ship.js","sourceRoot":"","sources":["../../../src/domain/registry/retire-ship.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AAG5E,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAsB,MAAM,WAAW,CAAC;AAiB/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAIhC;IACC,OAAO,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,C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AC,EAAE,CAAC,CAAC,EAAE,EACtG,EAAE,EAAE,EAAE,KAAK,EAAE,CACd,CAAC;QACF,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3C,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,8EAA8E;QAC9E,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACrH,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;YACtB,MAAM,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC3D,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC9C,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,mBAAmB,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { setNetworkRules } from './network-settings.js';
|
|
|
11
11
|
export function createSetNetworkRules(deps) {
|
|
12
12
|
return (caller, input) => deps.uow.run(async (tx) => {
|
|
13
13
|
const current = await tx.networkSettings.findForUpdate(caller.fleetId);
|
|
14
|
-
const set = setNetworkRules(current, { rules: input.rules, at: deps.clock.now(), actor: shipActor(caller.shipId) });
|
|
14
|
+
const set = setNetworkRules(current, { rules: input.rules, shipId: caller.shipId, at: deps.clock.now(), actor: shipActor(caller.shipId) });
|
|
15
15
|
if (!set.isOk) {
|
|
16
16
|
return set;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-network-rules.js","sourceRoot":"","sources":["../../../src/domain/registry/set-network-rules.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAiD,MAAM,uBAAuB,CAAC;AAUvG;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA4E;IAChH,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAgE,EAAE;QACtF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"set-network-rules.js","sourceRoot":"","sources":["../../../src/domain/registry/set-network-rules.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAiD,MAAM,uBAAuB,CAAC;AAUvG;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA4E;IAChH,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAgE,EAAE;QACtF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC3I,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACd,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClD,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACrC,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,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IdGenerator } from '@aeolus-fleet/common';
|
|
2
|
+
import type { Caller } 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 NotTheNetworkPlugin } from './network-settings.js';
|
|
8
|
+
import type { NetworkSettingsRepository } from './ports.js';
|
|
9
|
+
export interface UnregisterNetworkPluginTx {
|
|
10
|
+
networkSettings: Pick<NetworkSettingsRepository, 'findForUpdate' | 'save'>;
|
|
11
|
+
events: EventLog;
|
|
12
|
+
}
|
|
13
|
+
export type UnregisterNetworkPlugin = (caller: Caller) => Promise<Result<{
|
|
14
|
+
version: number;
|
|
15
|
+
}, NotTheNetworkPlugin>>;
|
|
16
|
+
/**
|
|
17
|
+
* Use case: the fleet's networking plugin unregisters, as it does when it is
|
|
18
|
+
* switched off or deleted for the fleet (decision 0035): no plugin and no
|
|
19
|
+
* rules, all-to-all. Its scope (fleet:network) is checked before this runs.
|
|
20
|
+
* In one unit of work, holding the settings exclusively: the settings at
|
|
21
|
+
* their next version, and NetworkPluginUnregistered.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createUnregisterNetworkPlugin(deps: {
|
|
24
|
+
uow: UnitOfWork<UnregisterNetworkPluginTx>;
|
|
25
|
+
clock: Clock;
|
|
26
|
+
ids: IdGenerator;
|
|
27
|
+
}): UnregisterNetworkPlugin;
|